UNPKG

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