UNPKG

4.78 kBJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.serverWatchNoSsr = exports.serverWatchSsrOnly = exports.serverWatch = exports.stats = exports.clientBuild = exports.clientWatch = exports.rmLibAndBundle = exports.rmBundle = exports.testE2E = exports.testUnit = exports.typecheck = exports.lint = exports.herokuLocalProd = exports.dbMigrTest = exports.dbSeed = exports.dbMigr = exports.babel = exports.DOCKER_WAIT_PG_TEST = exports.DOCKER_WAIT_PG = exports.DOCKER_UP_TEST = exports.dockerDownTest = exports.DOCKER_UP = exports.nodeLocalProd = void 0;
7
8var _checkSetup = require("@sharyn/check-setup");
9
10var _shared = require("./shared");
11
12// flow-disable-next-line
13var pathToSharynWebpackConfig = (0, _checkSetup.pathCascade)('node_modules/@sharyn/webpack-config', 'node_modules/sharyn/webpack-config');
14var pathToGlobalSetup = './src/_testing/global-setup.js';
15var hasGlobalSetup = (0, _checkSetup.hasFile)(pathToGlobalSetup);
16var pathToGlobalTeardown = './src/_testing/global-teardown.js';
17var hasGlobalTeardown = (0, _checkSetup.hasFile)(pathToGlobalTeardown);
18
19var dockerWaitPg = function dockerWaitPg(containerName) {
20 return "until docker run --rm --link ".concat(containerName, ":pg --net sharyn-net postgres:latest pg_isready -U postgres -h pg; do sleep 1; done");
21};
22
23var binDir = null;
24
25var prefix = function prefix(command) {
26 return "".concat(binDir || './node_modules/.bin/').concat(command);
27};
28
29var nodemon = prefix('nodemon -w src -i dist -x "babel-node src/_server/server.js"');
30var migrate = prefix("knex --knexfile ".concat(_shared.knexConfigPath || '', " --cwd . migrate:latest"));
31var webpackProd = prefix("webpack --mode=production --progress ".concat(pathToSharynWebpackConfig ? "--config ".concat(pathToSharynWebpackConfig) : ''));
32var webpackStats = prefix("webpack --mode=production --progress --json ".concat(pathToSharynWebpackConfig ? "--config ".concat(pathToSharynWebpackConfig) : '', " > webpack-stats.json"));
33var jestOptions = "".concat(hasGlobalSetup ? "--globalSetup ".concat(pathToGlobalSetup) : '', " ").concat(hasGlobalTeardown ? "--globalTeardown ".concat(pathToGlobalTeardown) : '');
34var nodeLocalProd = prefix('cross-env NODE_ENV=production ENV_TYPE=local-production node lib/_server/server.js');
35exports.nodeLocalProd = nodeLocalProd;
36var DOCKER_UP = 'docker-compose up -d db redis';
37exports.DOCKER_UP = DOCKER_UP;
38
39var dockerDownTest = function dockerDownTest(id) {
40 return "docker rm -f ".concat(id);
41};
42
43exports.dockerDownTest = dockerDownTest;
44var DOCKER_UP_TEST = 'docker-compose up -d db-test redis-test';
45exports.DOCKER_UP_TEST = DOCKER_UP_TEST;
46var DOCKER_WAIT_PG = dockerWaitPg('db');
47exports.DOCKER_WAIT_PG = DOCKER_WAIT_PG;
48var DOCKER_WAIT_PG_TEST = dockerWaitPg('db-test');
49exports.DOCKER_WAIT_PG_TEST = DOCKER_WAIT_PG_TEST;
50var babel = prefix('babel src -d lib --ignore **/*.test.js');
51exports.babel = babel;
52var dbMigr = migrate;
53exports.dbMigr = dbMigr;
54var dbSeed = prefix("knex --knexfile ".concat(_shared.knexConfigPath || '', " --cwd . seed:run"));
55exports.dbSeed = dbSeed;
56var dbMigrTest = "".concat(prefix('cross-env NODE_ENV=test'), " ").concat(migrate);
57exports.dbMigrTest = dbMigrTest;
58var herokuLocalProd = prefix('cross-env NODE_ENV=production ENV_TYPE=local-production heroku local');
59exports.herokuLocalProd = herokuLocalProd;
60var lint = prefix('eslint src --fix --ext .js,.jsx');
61exports.lint = lint;
62var typecheck = prefix('flow');
63exports.typecheck = typecheck;
64var testUnit = prefix("jest .unit.test.js --testEnvironment node ".concat(jestOptions));
65exports.testUnit = testUnit;
66var testE2E = prefix("jest .e2e.test.js --preset jest-puppeteer --runInBand ".concat(jestOptions));
67exports.testE2E = testE2E;
68var rmBundle = prefix('rimraf dist/js/bundle.js'); // Add .cache when switching back to Parcel
69
70exports.rmBundle = rmBundle;
71var rmLibAndBundle = prefix('rimraf lib dist/js/bundle.js'); // Add .cache when switching back to Parcel
72
73exports.rmLibAndBundle = rmLibAndBundle;
74var clientWatch = prefix("webpack-dev-server --mode=development --progress --hot ".concat(pathToSharynWebpackConfig ? "--config ".concat(pathToSharynWebpackConfig) : ''));
75exports.clientWatch = clientWatch;
76var clientBuild = "".concat(prefix('cross-env NODE_ENV=production'), " ").concat(webpackProd);
77exports.clientBuild = clientBuild;
78var stats = "".concat(prefix('cross-env NODE_ENV=production'), " ").concat(webpackStats);
79exports.stats = stats;
80var serverWatch = nodemon;
81exports.serverWatch = serverWatch;
82var serverWatchSsrOnly = "".concat(prefix('cross-env SSR_ONLY=true'), " ").concat(nodemon);
83exports.serverWatchSsrOnly = serverWatchSsrOnly;
84var serverWatchNoSsr = "".concat(prefix('cross-env NO_SSR=true'), " ").concat(nodemon);
85exports.serverWatchNoSsr = serverWatchNoSsr;
\No newline at end of file