arui-scripts 14.4.0 → 14.5.0-feat-modules.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +1 -0
  3. package/build/bin/index.js +1 -0
  4. package/build/commands/build/build-wrapper.d.ts +2 -2
  5. package/build/commands/build/client.js +3 -3
  6. package/build/commands/build/index.js +5 -30
  7. package/build/commands/bundle-analyze/index.js +5 -7
  8. package/build/commands/changelog/index.js +2 -2
  9. package/build/commands/docker-build/index.js +1 -3
  10. package/build/commands/docker-build-compiled/index.js +1 -3
  11. package/build/commands/start/client.js +2 -30
  12. package/build/commands/start/index.js +5 -27
  13. package/build/commands/start/server.js +2 -11
  14. package/build/commands/start-prod/client.d.ts +1 -0
  15. package/build/commands/start-prod/client.js +8 -0
  16. package/build/commands/start-prod/index.d.ts +1 -0
  17. package/build/commands/start-prod/index.js +8 -0
  18. package/build/commands/start-prod/server.d.ts +1 -0
  19. package/build/commands/start-prod/server.js +8 -0
  20. package/build/commands/util/docker-build.d.ts +6 -0
  21. package/build/commands/util/docker-build.js +19 -1
  22. package/build/commands/util/run-client-dev-derver.d.ts +2 -0
  23. package/build/commands/util/run-client-dev-derver.js +47 -0
  24. package/build/commands/util/run-compilers.d.ts +1 -0
  25. package/build/commands/util/run-compilers.js +31 -0
  26. package/build/commands/util/run-server-watch-compiler.d.ts +2 -0
  27. package/build/commands/util/run-server-watch-compiler.js +21 -0
  28. package/build/configs/app-configs/calculate-dependent-config.d.ts +48 -8
  29. package/build/configs/app-configs/calculate-dependent-config.js +11 -13
  30. package/build/configs/app-configs/get-defaults.d.ts +3 -2
  31. package/build/configs/app-configs/get-defaults.js +49 -34
  32. package/build/configs/app-configs/index.d.ts +5 -3
  33. package/build/configs/app-configs/index.js +13 -7
  34. package/build/configs/app-configs/types.d.ts +60 -26
  35. package/build/configs/app-configs/update-with-config-file.d.ts +2 -2
  36. package/build/configs/app-configs/update-with-config-file.js +5 -7
  37. package/build/configs/app-configs/update-with-env.js +3 -8
  38. package/build/configs/app-configs/update-with-package.d.ts +2 -2
  39. package/build/configs/app-configs/update-with-package.js +5 -10
  40. package/build/configs/app-configs/update-with-presets.d.ts +2 -2
  41. package/build/configs/app-configs/update-with-presets.js +8 -15
  42. package/build/configs/app-configs/validate-settings-keys.d.ts +2 -5
  43. package/build/configs/app-configs/validate-settings-keys.js +6 -7
  44. package/build/configs/babel-client.d.ts +33 -1
  45. package/build/configs/babel-dependencies.d.ts +14 -1
  46. package/build/configs/babel-server.d.ts +26 -1
  47. package/build/configs/dev-server.d.ts +15 -2
  48. package/build/configs/jest/index.d.ts +33 -1
  49. package/build/configs/modules.d.ts +15 -0
  50. package/build/configs/modules.js +78 -0
  51. package/build/configs/server-externals-exemptions.d.ts +1 -1
  52. package/build/configs/server-externals-exemptions.js +1 -0
  53. package/build/configs/util/apply-overrides.d.ts +6 -6
  54. package/build/configs/util/get-entry.d.ts +2 -1
  55. package/build/configs/webpack.client.d.ts +5 -2
  56. package/build/configs/webpack.client.dev.d.ts +1 -1
  57. package/build/configs/webpack.client.js +71 -17
  58. package/build/configs/webpack.client.prod.d.ts +1 -1
  59. package/build/index.d.ts +2 -1
  60. package/build/index.js +3 -1
  61. package/build/tsconfig-local.tsbuildinfo +1 -1
  62. package/docs/modules.md +423 -0
  63. package/package.json +5 -2
  64. package/build/configs/app-configs/available-package-settings.d.ts +0 -8
  65. package/build/configs/app-configs/available-package-settings.js +0 -32
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ # [14.5.0-feat-modules.1](https://github.com/core-ds/arui-scripts/compare/v14.4.1...v14.5.0-feat-modules.1) (2023-05-15)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **build:** correctly report build sized for multiple entrypoints ([cc41419](https://github.com/core-ds/arui-scripts/commit/cc414195915bdbd24867c45e291991568ac6e741))
7
+ * **webpack:** turn off performance hints from webpack ([d43f2c8](https://github.com/core-ds/arui-scripts/commit/d43f2c88b73176a173de570da8321b1f8cccc611))
8
+
9
+
10
+ ### Features
11
+
12
+ * add initial modules implementation ([0e2093e](https://github.com/core-ds/arui-scripts/commit/0e2093e350af3a3abb557d15b075b43ce96efe67))
13
+ * add modules build support ([2a0f5c1](https://github.com/core-ds/arui-scripts/commit/2a0f5c10ee8fb496228e7b2e42d1a94727c895e5))
14
+ * add new `start:prod` command ([2944887](https://github.com/core-ds/arui-scripts/commit/2944887758527e65fdd0e11ea5bb7e59afa213c1))
15
+ * **modules:** automaticaly generate expose for embedded modules ([5ecadfc](https://github.com/core-ds/arui-scripts/commit/5ecadfca7ebfbb15a0b65331c1db27f091f4173c))
16
+
17
+ ## [14.4.1](https://github.com/core-ds/arui-scripts/compare/v14.4.0...v14.4.1) (2023-05-07)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **docker:** allow to build x86 images on arm machines ([a115a71](https://github.com/core-ds/arui-scripts/commit/a115a717ef61e076cca3639485d32f9e71218041))
23
+
1
24
  # [14.4.0](https://github.com/core-ds/arui-scripts/compare/v14.3.0...v14.4.0) (2023-05-06)
2
25
 
3
26
 
package/README.md CHANGED
@@ -37,6 +37,7 @@ npm install arui-scripts --save-dev
37
37
  ---
38
38
 
39
39
  - `arui-scripts start` - запускает WebpackDevServer для фронтенда и webpack в режиме `--watch` для сервера.
40
+ - `arui-scripts start:prod` - аналогична команде start, но использует production версию конфигурации для webpack. Может быть полезна для сбора метрик производительности.
40
41
  - `arui-scripts build` - компилирует клиент и сервер для использования в production
41
42
  - `arui-scripts docker-build` - собирает docker контейнер c production билдом и загружает его в артифактори
42
43
  - `arui-scripts docker-build:compiled` - собирает docker контейнер c production билдом, предполагая что код приложения уже скомпилирован
@@ -3,6 +3,7 @@
3
3
  /* eslint import/no-dynamic-require: 0 */
4
4
  const commands = {
5
5
  start: () => require('../commands/start'),
6
+ 'start:prod': () => require('../commands/start-prod'),
6
7
  build: () => require('../commands/build'),
7
8
  'docker-build': () => require('../commands/docker-build'),
8
9
  'docker-build:compiled': () => require('../commands/docker-build-compiled'),
@@ -1,8 +1,8 @@
1
1
  import webpack from 'webpack';
2
2
  type BuildResult = {
3
- stats: webpack.Stats;
3
+ stats: webpack.Stats | webpack.MultiStats;
4
4
  warnings: string[];
5
5
  previousFileSizes: unknown;
6
6
  };
7
- declare function build(config: webpack.Configuration, previousFileSizes?: unknown): Promise<BuildResult>;
7
+ declare function build(config: webpack.Configuration | webpack.Configuration[], previousFileSizes?: unknown): Promise<BuildResult>;
8
8
  export default build;
@@ -22,16 +22,16 @@ console.log(chalk_1.default.magenta('Building client...'));
22
22
  else {
23
23
  console.log(chalk_1.default.green('Client compiled successfully.\n'));
24
24
  }
25
- function printOutputSizes(webpackConfig) {
25
+ function printOutputSizes(webpackConfig, stats) {
26
26
  var _a;
27
27
  const sizes = (0, client_assets_sizes_1.calculateAssetsSizes)(stats, (_a = webpackConfig === null || webpackConfig === void 0 ? void 0 : webpackConfig.output) === null || _a === void 0 ? void 0 : _a.path);
28
28
  (0, client_assets_sizes_1.printAssetsSizes)(sizes);
29
29
  }
30
30
  if (Array.isArray(webpack_client_prod_1.default)) {
31
- webpack_client_prod_1.default.forEach(printOutputSizes);
31
+ webpack_client_prod_1.default.forEach((conf, index) => printOutputSizes(conf, stats.stats[index]));
32
32
  }
33
33
  else {
34
- printOutputSizes(webpack_client_prod_1.default);
34
+ printOutputSizes(webpack_client_prod_1.default, stats);
35
35
  }
36
36
  })
37
37
  .catch((err) => {
@@ -1,35 +1,10 @@
1
1
  "use strict";
2
- // Do this as the first thing so that any code reading it knows the right env.
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
2
  Object.defineProperty(exports, "__esModule", { value: true });
7
- /* eslint import/no-extraneous-dependencies: 0 */
8
- /* eslint no-console: 0 */
9
- const child_process_1 = require("child_process");
10
- const fs_extra_1 = __importDefault(require("fs-extra"));
11
- const path_1 = __importDefault(require("path"));
12
- const check_required_files_1 = __importDefault(require("../util/check-required-files"));
13
- const app_configs_1 = __importDefault(require("../../configs/app-configs"));
3
+ const run_compilers_1 = require("../util/run-compilers");
14
4
  process.env.BABEL_ENV = 'production';
15
5
  process.env.NODE_ENV = 'production';
16
6
  process.env.BROWSERSLIST_CONFIG = process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
17
- if (!(0, check_required_files_1.default)()) {
18
- process.exit(1);
19
- }
20
- if (fs_extra_1.default.pathExistsSync(app_configs_1.default.serverOutputPath)) {
21
- fs_extra_1.default.removeSync(app_configs_1.default.serverOutputPath);
22
- }
23
- const compileServer = (0, child_process_1.spawn)('node', [path_1.default.join(__dirname, './server')], { stdio: 'inherit' });
24
- const compileClient = (0, child_process_1.spawn)('node', [path_1.default.join(__dirname, './client')], { stdio: 'inherit' });
25
- const onProcessExit = (code) => {
26
- if (code !== 0) {
27
- compileServer.kill();
28
- compileClient.kill();
29
- process.exit(code);
30
- }
31
- };
32
- compileClient.on('error', onProcessExit);
33
- compileServer.on('error', onProcessExit);
34
- compileServer.on('close', onProcessExit);
35
- compileClient.on('close', onProcessExit);
7
+ (0, run_compilers_1.runCompilers)([
8
+ require.resolve('./client'),
9
+ require.resolve('./server'),
10
+ ]);
@@ -25,11 +25,9 @@ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
25
25
  statsFilename: app_configs_1.default.statsOutputPath,
26
26
  });
27
27
  let clientWebpackConfig = webpack_client_prod_1.default;
28
- if (Array.isArray(webpack_client_prod_1.default)) {
29
- // В случае, если у пользователя несколько конфигов для клиента - запускаем bundle analyzer только для первого
30
- clientWebpackConfig = webpack_client_prod_1.default[0];
31
- }
32
- (_a = clientWebpackConfig.plugins) === null || _a === void 0 ? void 0 : _a.push(plugin);
33
- clientWebpackConfig.output.path = tmpDir;
34
- (0, webpack_1.default)(clientWebpackConfig).run(() => { });
28
+ // В случае, если у пользователя несколько конфигов для клиента - запускаем bundle analyzer только для первого
29
+ let singleClientConfig = Array.isArray(webpack_client_prod_1.default) ? webpack_client_prod_1.default[0] : webpack_client_prod_1.default;
30
+ (_a = singleClientConfig.plugins) === null || _a === void 0 ? void 0 : _a.push(plugin);
31
+ singleClientConfig.output.path = tmpDir;
32
+ (0, webpack_1.default)(singleClientConfig).run(() => { });
35
33
  }))();
@@ -26,14 +26,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const child_process_1 = require("child_process");
27
27
  const fs_1 = require("fs");
28
28
  const readline_1 = __importDefault(require("readline"));
29
- const get_defaults_1 = require("../../configs/app-configs/get-defaults");
29
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
30
30
  const { readFile, rename, unlink } = fs_1.promises;
31
31
  /**
32
32
  * Сюда пайплайн Jenkins складывает соответствующие части описания версии. Не получается использовать
33
33
  * переменные окружения, т.к. `standard-version` запускает хуки через `child_process.exec`, не передавая туда
34
34
  * ни аргументы ни переменные окружения.
35
35
  */
36
- const { appNodeModulesBin, changelogPath, changelogTmpPath, changelogFeaturesPath, changelogBugfixesPath, changelogBreakingChangesPath } = (0, get_defaults_1.getDefaults)();
36
+ const { appNodeModulesBin, changelogPath, changelogTmpPath, changelogFeaturesPath, changelogBugfixesPath, changelogBreakingChangesPath } = app_configs_1.default;
37
37
  // Пример заголовка – `## [50.1.0](http://git.moscow.alfaintra.net/...) (2022-07-27)`.
38
38
  const changelogHeaderRegExp = /^###? \[\d+\.\d+\.\d+]\([^)]+\) \(\d{4}-\d{2}-\d{2}\)/;
39
39
  (() => __awaiter(void 0, void 0, void 0, function* () {
@@ -47,9 +47,7 @@ const yarn_1 = require("../util/yarn");
47
47
  console.timeEnd('Remove dev dependencies time');
48
48
  }
49
49
  console.time('Build docker image time');
50
- yield (0, exec_1.default)(`docker build -f "./${tempDirName}/Dockerfile" \\
51
- --build-arg START_SH_LOCATION="./${tempDirName}/start.sh" \\
52
- --build-arg NGINX_CONF_LOCATION="./${tempDirName}/nginx.conf" -t ${imageFullName} .`);
50
+ yield (0, exec_1.default)((0, docker_build_1.getDockerBuildCommand)({ tempDirName, imageFullName }));
53
51
  console.timeEnd('Build docker image time');
54
52
  console.time('Cleanup time');
55
53
  // remove temp directory
@@ -33,9 +33,7 @@ const docker_build_1 = require("../util/docker-build");
33
33
  allowLocalStartScript: false,
34
34
  });
35
35
  yield (0, exec_1.default)('echo "node_modules" >> .dockerignore');
36
- yield (0, exec_1.default)(`docker build -f "./${tempDirName}/Dockerfile" \\
37
- --build-arg START_SH_LOCATION="./${tempDirName}/start.sh" \\
38
- --build-arg NGINX_CONF_LOCATION="./${tempDirName}/nginx.conf" -t ${imageFullName} .`);
36
+ yield (0, exec_1.default)((0, docker_build_1.getDockerBuildCommand)({ tempDirName, imageFullName }));
39
37
  yield fs_extra_1.default.remove(pathToTempDir);
40
38
  // guard against pushing the image during tests
41
39
  if (!app_configs_1.default.debug) {
@@ -3,34 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const webpack_1 = __importDefault(require("webpack"));
7
- const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
8
- const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
9
- const print_compiler_output_1 = __importDefault(require("./print-compiler-output"));
10
6
  const webpack_client_dev_1 = __importDefault(require("../../configs/webpack.client.dev"));
11
- const dev_server_1 = __importDefault(require("../../configs/dev-server"));
12
- const clientCompiler = (0, webpack_1.default)(webpack_client_dev_1.default);
13
- // не резолвиться constructor(config: WebpackDevServer.Configuration, webpack?: webpack.Compiler | webpack.MultiCompiler);
14
- // clientCompiler: webpack.Compiler
15
- // @ts-ignore
16
- const clientDevServer = new webpack_dev_server_1.default(dev_server_1.default, clientCompiler);
17
- clientCompiler.hooks.invalid.tap('client', () => console.log('Compiling client...'));
18
- clientCompiler.hooks.done.tap('client', (stats) => (0, print_compiler_output_1.default)('Client', stats));
19
- const DEFAULT_PORT = dev_server_1.default.port;
20
- const HOST = '0.0.0.0';
21
- (0, WebpackDevServerUtils_1.choosePort)(HOST, +(DEFAULT_PORT || 0))
22
- .then((port) => {
23
- if (!port) {
24
- // We have not found a port.
25
- return;
26
- }
27
- clientDevServer.startCallback(() => {
28
- console.log(`Client dev server running at http://${HOST}:${port}...`);
29
- });
30
- })
31
- .catch((err) => {
32
- if (err && err.message) {
33
- console.log(err.message);
34
- }
35
- process.exit(1);
36
- });
7
+ const run_client_dev_derver_1 = require("../util/run-client-dev-derver");
8
+ (0, run_client_dev_derver_1.runClientDevServer)(webpack_client_dev_1.default);
@@ -1,30 +1,8 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const child_process_1 = require("child_process");
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const check_required_files_1 = __importDefault(require("../util/check-required-files"));
10
- const app_configs_1 = __importDefault(require("../../configs/app-configs"));
3
+ const run_compilers_1 = require("../util/run-compilers");
11
4
  process.env.BROWSERSLIST_CONFIG = process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
12
- if (!(0, check_required_files_1.default)()) {
13
- process.exit(1);
14
- }
15
- if (fs_extra_1.default.pathExistsSync(app_configs_1.default.serverOutputPath)) {
16
- fs_extra_1.default.removeSync(app_configs_1.default.serverOutputPath);
17
- }
18
- const compileServer = (0, child_process_1.spawn)('node', [path_1.default.join(__dirname, './server')], { stdio: 'inherit' });
19
- const compileClient = (0, child_process_1.spawn)('node', [path_1.default.join(__dirname, './client')], { stdio: 'inherit' });
20
- const onProcessExit = (code) => {
21
- if (code !== 0) {
22
- compileServer.kill();
23
- compileClient.kill();
24
- process.exit(code);
25
- }
26
- };
27
- compileClient.on('error', onProcessExit);
28
- compileServer.on('error', onProcessExit);
29
- compileServer.on('close', onProcessExit);
30
- compileClient.on('close', onProcessExit);
5
+ (0, run_compilers_1.runCompilers)([
6
+ require.resolve('./client'),
7
+ require.resolve('./server'),
8
+ ]);
@@ -3,15 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const webpack_1 = __importDefault(require("webpack"));
7
- const print_compiler_output_1 = __importDefault(require("./print-compiler-output"));
8
6
  const webpack_server_dev_1 = __importDefault(require("../../configs/webpack.server.dev"));
9
- const app_configs_1 = __importDefault(require("../../configs/app-configs"));
10
- const serverCompiler = (0, webpack_1.default)(webpack_server_dev_1.default);
11
- serverCompiler.hooks.compile.tap('server', () => console.log('Compiling server...'));
12
- serverCompiler.hooks.invalid.tap('server', () => console.log('Compiling server...'));
13
- serverCompiler.hooks.done.tap('server', (stats) => (0, print_compiler_output_1.default)('Server', stats));
14
- serverCompiler.watch({
15
- aggregateTimeout: 50,
16
- ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
17
- }, () => { });
7
+ const run_server_watch_compiler_1 = require("../util/run-server-watch-compiler");
8
+ (0, run_server_watch_compiler_1.runServerWatchCompiler)(webpack_server_dev_1.default);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const webpack_client_prod_1 = __importDefault(require("../../configs/webpack.client.prod"));
7
+ const run_client_dev_derver_1 = require("../util/run-client-dev-derver");
8
+ (0, run_client_dev_derver_1.runClientDevServer)(webpack_client_prod_1.default);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const run_compilers_1 = require("../util/run-compilers");
4
+ process.env.BROWSERSLIST_CONFIG = process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
5
+ (0, run_compilers_1.runCompilers)([
6
+ require.resolve('./client'),
7
+ require.resolve('./server'),
8
+ ]);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const webpack_server_prod_1 = __importDefault(require("../../configs/webpack.server.prod"));
7
+ const run_server_watch_compiler_1 = require("../util/run-server-watch-compiler");
8
+ (0, run_server_watch_compiler_1.runServerWatchCompiler)(webpack_server_prod_1.default);
@@ -12,4 +12,10 @@ type PrepareFilesForDockerParams = {
12
12
  allowLocalStartScript: boolean;
13
13
  };
14
14
  export declare function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript }: PrepareFilesForDockerParams): Promise<void>;
15
+ export declare function dockerVersionSatisfies(request: string): boolean;
16
+ type DockerBuildCommandParams = {
17
+ tempDirName: string;
18
+ imageFullName: string;
19
+ };
20
+ export declare function getDockerBuildCommand({ tempDirName, imageFullName }: DockerBuildCommandParams): string;
15
21
  export {};
@@ -12,10 +12,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.prepareFilesForDocker = exports.getBuildParamsFromArgs = void 0;
15
+ exports.getDockerBuildCommand = exports.dockerVersionSatisfies = exports.prepareFilesForDocker = exports.getBuildParamsFromArgs = void 0;
16
16
  const app_configs_1 = __importDefault(require("../../configs/app-configs"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  const fs_extra_1 = __importDefault(require("fs-extra"));
19
+ const shelljs_1 = __importDefault(require("shelljs"));
20
+ const satisfies_1 = __importDefault(require("semver/functions/satisfies"));
19
21
  function getBuildParamsFromArgs() {
20
22
  let imageVersion = app_configs_1.default.version;
21
23
  let imageName = app_configs_1.default.name;
@@ -69,3 +71,19 @@ function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScr
69
71
  });
70
72
  }
71
73
  exports.prepareFilesForDocker = prepareFilesForDocker;
74
+ function dockerVersionSatisfies(request) {
75
+ const dockerVersion = shelljs_1.default.exec('docker version --format \'{{.Server.Version}}\'', { silent: true });
76
+ return (0, satisfies_1.default)(dockerVersion.toString(), request);
77
+ }
78
+ exports.dockerVersionSatisfies = dockerVersionSatisfies;
79
+ function getDockerBuildCommand({ tempDirName, imageFullName }) {
80
+ // если пытаться собрать проект на маках с m1, докер будет пытаться вытянуть базовый образ под свою платформу и
81
+ // упадет с ошибкой. Чтобы этого избежать - достаточно использовать флаг --platform. Но он поддерживается только начиная
82
+ // с docker 17.12, а на многих серверах, используемых для сборки до сих пор живет докер 1.13.1
83
+ // Соответственно они будут падать при наличии этого флага.
84
+ const canUsePlatformFlag = dockerVersionSatisfies('>=17.12');
85
+ return `docker build ${canUsePlatformFlag ? '--platform linux/x86_64' : ''} -f "./${tempDirName}/Dockerfile" \\
86
+ --build-arg START_SH_LOCATION="./${tempDirName}/start.sh" \\
87
+ --build-arg NGINX_CONF_LOCATION="./${tempDirName}/nginx.conf" -t ${imageFullName} .`;
88
+ }
89
+ exports.getDockerBuildCommand = getDockerBuildCommand;
@@ -0,0 +1,2 @@
1
+ import { Configuration } from 'webpack';
2
+ export declare function runClientDevServer(configuration: Configuration | Configuration[]): Promise<void>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.runClientDevServer = void 0;
16
+ const webpack_1 = __importDefault(require("webpack"));
17
+ const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
18
+ const dev_server_1 = __importDefault(require("../../configs/dev-server"));
19
+ const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
20
+ const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
21
+ function runClientDevServer(configuration) {
22
+ return __awaiter(this, void 0, void 0, function* () {
23
+ const clientCompiler = (0, webpack_1.default)(configuration); // типы вебпака не умеют выбирать между конфигурациями и массивом конфигураций
24
+ const clientDevServer = new webpack_dev_server_1.default(dev_server_1.default, clientCompiler);
25
+ clientCompiler.hooks.invalid.tap('client', () => console.log('Compiling client...'));
26
+ clientCompiler.hooks.done.tap('client', (stats) => (0, print_compiler_output_1.default)('Client', stats));
27
+ const DEFAULT_PORT = dev_server_1.default.port;
28
+ const HOST = '0.0.0.0';
29
+ try {
30
+ const port = yield (0, WebpackDevServerUtils_1.choosePort)(HOST, +(DEFAULT_PORT || 0));
31
+ if (!port) {
32
+ // We have not found a port.
33
+ return;
34
+ }
35
+ clientDevServer.startCallback(() => {
36
+ console.log(`Client dev server running at http://${HOST}:${port}...`);
37
+ });
38
+ }
39
+ catch (err) {
40
+ if (err && err.message) {
41
+ console.log(err.message);
42
+ }
43
+ process.exit(1);
44
+ }
45
+ });
46
+ }
47
+ exports.runClientDevServer = runClientDevServer;
@@ -0,0 +1 @@
1
+ export declare function runCompilers(pathToCompilers: string[]): void;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runCompilers = void 0;
7
+ const check_required_files_1 = __importDefault(require("./check-required-files"));
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
10
+ const child_process_1 = require("child_process");
11
+ function runCompilers(pathToCompilers) {
12
+ if (!(0, check_required_files_1.default)()) {
13
+ process.exit(1);
14
+ }
15
+ if (fs_extra_1.default.pathExistsSync(app_configs_1.default.serverOutputPath)) {
16
+ fs_extra_1.default.removeSync(app_configs_1.default.serverOutputPath);
17
+ }
18
+ const compilers = pathToCompilers.map((pathToCompiler) => {
19
+ const compiler = (0, child_process_1.spawn)('node', [pathToCompiler], { stdio: 'inherit' });
20
+ compiler.on('error', onProcessExit);
21
+ compiler.on('close', onProcessExit);
22
+ return compiler;
23
+ });
24
+ function onProcessExit(code) {
25
+ if (code !== 0) {
26
+ compilers.forEach((compiler) => compiler.kill());
27
+ process.exit(code);
28
+ }
29
+ }
30
+ }
31
+ exports.runCompilers = runCompilers;
@@ -0,0 +1,2 @@
1
+ import webpack from 'webpack';
2
+ export declare function runServerWatchCompiler(config: webpack.Configuration): void;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runServerWatchCompiler = void 0;
7
+ const webpack_1 = __importDefault(require("webpack"));
8
+ const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
9
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
10
+ function runServerWatchCompiler(config) {
11
+ const serverCompiler = (0, webpack_1.default)(config);
12
+ serverCompiler.hooks.compile.tap('server', () => console.log('Compiling server...'));
13
+ serverCompiler.hooks.invalid.tap('server', () => console.log('Compiling server...'));
14
+ serverCompiler.hooks.done.tap('server', (stats) => (0, print_compiler_output_1.default)('Server', stats));
15
+ serverCompiler.watch({
16
+ aggregateTimeout: 50,
17
+ ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
18
+ }, () => {
19
+ });
20
+ }
21
+ exports.runServerWatchCompiler = runServerWatchCompiler;
@@ -1,13 +1,53 @@
1
- import { AppConfigs } from './types';
1
+ import { AppConfigs, AppContext } from './types';
2
2
  /**
3
3
  * Обновление ключей конфига, зависящих от других. Это нужно делать в самый последний момент
4
4
  */
5
- export declare function calculateDependentConfig(config: AppConfigs): AppConfigs & {
6
- publicPath: string;
7
- serverOutputPath: string;
8
- clientOutputPath: string;
5
+ export declare function calculateDependentConfig(config: AppConfigs): {
9
6
  clientPolyfillsEntry: string[];
10
- statsOutputPath: string;
11
- watchIgnorePath: string[];
12
- babelRuntimeVersion: string;
7
+ clientServerPort: number;
8
+ serverPort: number;
9
+ debug: boolean;
10
+ devSourceMaps: string;
11
+ useServerHMR: boolean;
12
+ presets: string | null;
13
+ buildPath: string;
14
+ assetsPath: string;
15
+ additionalBuildPath: string[];
16
+ statsOutputFilename: string;
17
+ serverEntry: string | string[] | Record<string, string | string[]>;
18
+ serverOutput: string;
19
+ clientEntry: string;
20
+ dockerRegistry: string;
21
+ baseDockerImage: string;
22
+ nginxRootPath: string;
23
+ runFromNonRootUser: boolean;
24
+ removeDevDependenciesDuringDockerBuild: boolean;
25
+ archiveName: string;
26
+ keepPropTypes: boolean;
27
+ useTscLoader: boolean;
28
+ webpack4Compatibility: boolean;
29
+ installServerSourceMaps: boolean;
30
+ componentsTheme: string | undefined;
31
+ keepCssVars: boolean;
32
+ embeddedModules: {
33
+ shared?: {
34
+ [libraryName: string]: string;
35
+ } | undefined;
36
+ exposes?: {
37
+ [moduleId: string]: {
38
+ entry: string;
39
+ embeddedConfig?: Record<string, string> | undefined;
40
+ cssPrefix?: string | false | undefined;
41
+ };
42
+ } | undefined;
43
+ } | null;
44
+ mfModules: {
45
+ name?: string | undefined;
46
+ shared: any;
47
+ exposes?: Record<string, string> | undefined;
48
+ } | null;
13
49
  };
50
+ /**
51
+ * Обновление контекста в зависимости от ключей конфига
52
+ */
53
+ export declare function calculateDependentContext(config: AppConfigs, context: AppContext): AppContext;
@@ -3,16 +3,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.calculateDependentConfig = void 0;
6
+ exports.calculateDependentContext = exports.calculateDependentConfig = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const path_1 = __importDefault(require("path"));
9
- const lodash_merge_1 = __importDefault(require("lodash.merge"));
10
9
  const get_polyfills_1 = require("../util/get-polyfills");
11
10
  const resolve_1 = require("../util/resolve");
12
11
  /**
13
12
  * Обновление ключей конфига, зависящих от других. Это нужно делать в самый последний момент
14
13
  */
15
14
  function calculateDependentConfig(config) {
15
+ return Object.assign(Object.assign({}, config), { clientPolyfillsEntry: (0, get_polyfills_1.getPolyfills)(config) });
16
+ }
17
+ exports.calculateDependentConfig = calculateDependentConfig;
18
+ /**
19
+ * Обновление контекста в зависимости от ключей конфига
20
+ */
21
+ function calculateDependentContext(config, context) {
16
22
  let babelRuntimeVersion;
17
23
  try {
18
24
  // В проекте может стоять babel/runtime отличный от того, что установлен как зависимость arui-scripts.
@@ -20,20 +26,12 @@ function calculateDependentConfig(config) {
20
26
  // Поэтому мы читаем версию того babel/runtime, который установлен в проекте.
21
27
  // Так же мы не можем использовать require для получения контента из babel/runtime/package.json,
22
28
  // потому что webpack.cache будет ругаться на то, что мы пытаемся импортировать файлы НЕ из своего node_modules.
23
- const pathToProjectBabelRuntime = (0, resolve_1.resolveNodeModuleRelativeTo)(config.cwd, '@babel/runtime/package.json');
29
+ const pathToProjectBabelRuntime = (0, resolve_1.resolveNodeModuleRelativeTo)(context.cwd, '@babel/runtime/package.json');
24
30
  babelRuntimeVersion = JSON.parse(fs_1.default.readFileSync(pathToProjectBabelRuntime, 'utf8')).version;
25
31
  }
26
32
  catch (e) {
27
33
  babelRuntimeVersion = require('@babel/runtime/package.json').version;
28
34
  }
29
- return (0, lodash_merge_1.default)(config, {
30
- publicPath: `${config.assetsPath}/`,
31
- serverOutputPath: path_1.default.resolve(config.cwd, config.buildPath),
32
- clientOutputPath: path_1.default.resolve(config.cwd, config.buildPath, config.assetsPath),
33
- clientPolyfillsEntry: (0, get_polyfills_1.getPolyfills)(config),
34
- statsOutputPath: path_1.default.resolve(config.cwd, config.buildPath, config.statsOutputFilename),
35
- watchIgnorePath: ['node_modules', config.buildPath],
36
- babelRuntimeVersion,
37
- });
35
+ return Object.assign(Object.assign({}, context), { publicPath: `${config.assetsPath}/`, serverOutputPath: path_1.default.resolve(context.cwd, config.buildPath), clientOutputPath: path_1.default.resolve(context.cwd, config.buildPath, config.assetsPath), statsOutputPath: path_1.default.resolve(context.cwd, config.buildPath, config.statsOutputFilename), watchIgnorePath: ['node_modules', config.buildPath], babelRuntimeVersion });
38
36
  }
39
- exports.calculateDependentConfig = calculateDependentConfig;
37
+ exports.calculateDependentContext = calculateDependentContext;
@@ -1,2 +1,3 @@
1
- import { AppConfigs } from './types';
2
- export declare function getDefaults(): AppConfigs;
1
+ import { AppConfigs, AppContext } from './types';
2
+ export declare function getDefaultAppConfig(): AppConfigs;
3
+ export declare function getDefaultAppContext(): AppContext;