arui-scripts 15.8.0 → 15.8.2

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 (75) hide show
  1. package/.eslintignore +2 -0
  2. package/.eslintrc.js +13 -0
  3. package/.turbo/turbo-lint.log +260 -0
  4. package/.turbo/turbo-test.log +26 -26
  5. package/CHANGELOG.md +317 -305
  6. package/build/bin/index.js +9 -1
  7. package/build/commands/archive-build/index.js +4 -4
  8. package/build/commands/build/build-wrapper.js +3 -2
  9. package/build/commands/build/index.js +3 -5
  10. package/build/commands/bundle-analyze/index.js +5 -3
  11. package/build/commands/changelog/index.js +4 -2
  12. package/build/commands/docker-build/index.js +1 -1
  13. package/build/commands/docker-build-compiled/index.js +1 -1
  14. package/build/commands/start/index.js +8 -13
  15. package/build/commands/start/print-compiler-output.js +2 -1
  16. package/build/commands/start-prod/index.js +3 -5
  17. package/build/commands/test/index.js +10 -1
  18. package/build/commands/util/check-required-files.js +12 -8
  19. package/build/commands/util/client-assets-sizes.js +17 -22
  20. package/build/commands/util/docker-build.d.ts +1 -1
  21. package/build/commands/util/docker-build.js +12 -7
  22. package/build/commands/util/exec.js +2 -0
  23. package/build/commands/util/format-webpack-messages.js +9 -7
  24. package/build/commands/util/make-tmp-dir.js +3 -3
  25. package/build/commands/util/run-client-dev-server.js +1 -1
  26. package/build/commands/util/run-compilers.d.ts +1 -1
  27. package/build/commands/util/run-compilers.js +11 -11
  28. package/build/commands/util/run-server-watch-compiler.js +2 -3
  29. package/build/commands/util/yarn.js +1 -1
  30. package/build/configs/app-configs/calculate-dependent-config.js +2 -0
  31. package/build/configs/app-configs/get-defaults.js +4 -2
  32. package/build/configs/app-configs/index.d.ts +1 -1
  33. package/build/configs/app-configs/index.js +3 -3
  34. package/build/configs/app-configs/read-config-file.d.ts +1 -0
  35. package/build/configs/app-configs/read-config-file.js +25 -0
  36. package/build/configs/app-configs/types.d.ts +1 -1
  37. package/build/configs/app-configs/update-with-config-file.js +4 -10
  38. package/build/configs/app-configs/update-with-env.js +1 -1
  39. package/build/configs/app-configs/update-with-presets.js +11 -3
  40. package/build/configs/babel-client.js +21 -15
  41. package/build/configs/babel-dependencies.js +3 -3
  42. package/build/configs/babel-server.js +10 -10
  43. package/build/configs/config-extras/minimizers/imagemin/imagemin.d.ts +1 -1
  44. package/build/configs/config-extras/minimizers/imagemin/imagemin.js +23 -14
  45. package/build/configs/dev-server.js +20 -18
  46. package/build/configs/jest/babel-transform.js +2 -0
  47. package/build/configs/jest/file-transform.js +2 -0
  48. package/build/configs/jest/index.js +13 -13
  49. package/build/configs/modules.js +11 -4
  50. package/build/configs/mq.css +18 -18
  51. package/build/configs/postcss.config.js +3 -6
  52. package/build/configs/process-assets-plugin-output.js +1 -1
  53. package/build/configs/stats-options.js +1 -1
  54. package/build/configs/supporting-browsers.js +1 -6
  55. package/build/configs/util/apply-overrides.d.ts +2 -2
  56. package/build/configs/util/apply-overrides.js +7 -2
  57. package/build/configs/util/find-loader.d.ts +1 -1
  58. package/build/configs/util/find-loader.js +2 -0
  59. package/build/configs/util/install-sourcemap-support.js +4 -0
  60. package/build/configs/util/node-assets-ignore.js +8 -6
  61. package/build/configs/util/register-ts-node.js +3 -2
  62. package/build/configs/webpack.client.js +131 -95
  63. package/build/configs/webpack.server.js +74 -54
  64. package/build/plugins/postcss-prefix-selector.js +5 -3
  65. package/build/plugins/reload-server-webpack-plugin.js +8 -6
  66. package/build/plugins/watch-missing-node-modules-plugin.js +3 -3
  67. package/build/templates/dockerfile-compiled.template.js +4 -2
  68. package/build/templates/dockerfile.template.js +2 -2
  69. package/build/tsconfig-local.tsbuildinfo +1 -1
  70. package/docs/modules.md +429 -358
  71. package/jest-preset.js +8 -8
  72. package/package.json +12 -3
  73. package/release.config.js +8 -2
  74. package/stylelint.config.js +11 -0
  75. package/tsconfig.eslint.json +5 -0
@@ -1,6 +1,10 @@
1
1
  #! /usr/bin/env node
2
2
  "use strict";
3
+ // TODO: remove eslint-disable and eslint-disable-next-line
4
+ /* eslint-disable global-require */
3
5
  /* eslint import/no-dynamic-require: 0 */
6
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
7
+ // @ts-ignore
4
8
  const commands = {
5
9
  start: () => require('../commands/start'),
6
10
  'start:prod': () => require('../commands/start-prod'),
@@ -13,9 +17,13 @@ const commands = {
13
17
  'bundle-analyze': () => require('../commands/bundle-analyze'),
14
18
  changelog: () => require('../commands/changelog'),
15
19
  };
20
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
21
+ // @ts-ignore
16
22
  const command = process.argv[2];
17
23
  if (!command || !commands[command]) {
18
- console.error(`Please specify one of available commands: ${Object.keys(commands).map(c => `"${c}"`).join(' ')}`);
24
+ console.error(`Please specify one of available commands: ${Object.keys(commands)
25
+ .map((c) => `"${c}"`)
26
+ .join(' ')}`);
19
27
  process.exit(-1);
20
28
  }
21
29
  commands[command]();
@@ -12,13 +12,13 @@ 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
- const tar_1 = __importDefault(require("tar"));
16
15
  const path_1 = __importDefault(require("path"));
17
16
  const fs_extra_1 = __importDefault(require("fs-extra"));
17
+ const tar_1 = __importDefault(require("tar"));
18
18
  const app_configs_1 = __importDefault(require("../../configs/app-configs"));
19
- const exec_1 = __importDefault(require("../util/exec"));
20
19
  const nginx_conf_template_1 = __importDefault(require("../../templates/nginx.conf.template"));
21
20
  const start_template_1 = __importDefault(require("../../templates/start.template"));
21
+ const exec_1 = __importDefault(require("../util/exec"));
22
22
  const yarn_1 = require("../util/yarn");
23
23
  const tempDirName = '.archive-build';
24
24
  const nginxConfFileName = 'nginx.conf';
@@ -57,11 +57,11 @@ const packageJsonPath = path_1.default.join(app_configs_1.default.cwd, packageJs
57
57
  fs_extra_1.default.copy(app_configs_1.default.buildPath, path_1.default.join(pathToTempDir, app_configs_1.default.buildPath)),
58
58
  fs_extra_1.default.copy(nodeModulesPath, path_1.default.join(pathToTempDir, nodeModulesDirName)),
59
59
  fs_extra_1.default.copy(packageJsonPath, path_1.default.join(pathToTempDir, packageJsonFileName)),
60
- ...app_configs_1.default.additionalBuildPath.map(additionalPath => (fs_extra_1.default.copy(path_1.default.join(app_configs_1.default.cwd, additionalPath), path_1.default.join(pathToTempDir, additionalPath))))
60
+ ...app_configs_1.default.additionalBuildPath.map((additionalPath) => fs_extra_1.default.copy(path_1.default.join(app_configs_1.default.cwd, additionalPath), path_1.default.join(pathToTempDir, additionalPath))),
61
61
  ]);
62
62
  yield tar_1.default.c({
63
63
  file: app_configs_1.default.archiveName,
64
- cwd: pathToTempDir
64
+ cwd: pathToTempDir,
65
65
  }, fs_extra_1.default.readdirSync(pathToTempDir));
66
66
  console.timeEnd('Archive build time');
67
67
  console.time('Cleanup time');
@@ -24,7 +24,8 @@ function build(config, previousFileSizes) {
24
24
  }
25
25
  return reject(new Error(messages.errors.join('\n\n')));
26
26
  }
27
- if (process.env.CI && (process.env.CI.toLowerCase() !== 'false') &&
27
+ if (process.env.CI &&
28
+ process.env.CI.toLowerCase() !== 'false' &&
28
29
  messages.warnings.length) {
29
30
  console.log(chalk_1.default.yellow('\nTreating warnings as errors because process.env.CI = true.\n' +
30
31
  'Most CI servers set it automatically.\n'));
@@ -33,7 +34,7 @@ function build(config, previousFileSizes) {
33
34
  return resolve({
34
35
  stats,
35
36
  warnings: messages.warnings,
36
- previousFileSizes
37
+ previousFileSizes,
37
38
  });
38
39
  });
39
40
  });
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const run_compilers_1 = require("../util/run-compilers");
4
4
  process.env.BABEL_ENV = 'production';
5
5
  process.env.NODE_ENV = 'production';
6
- process.env.BROWSERSLIST_CONFIG = process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
7
- (0, run_compilers_1.runCompilers)([
8
- require.resolve('./client'),
9
- require.resolve('./server'),
10
- ]);
6
+ process.env.BROWSERSLIST_CONFIG =
7
+ process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
8
+ (0, run_compilers_1.runCompilers)([require.resolve('./client'), require.resolve('./server')]);
@@ -12,13 +12,15 @@ 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
+ // TODO: remove eslint-disable
16
+ /* eslint-disable no-param-reassign */
15
17
  const webpack_1 = __importDefault(require("webpack"));
16
18
  const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
17
- const make_tmp_dir_1 = __importDefault(require("../util/make-tmp-dir"));
18
- const webpack_client_prod_1 = __importDefault(require("../../configs/webpack.client.prod"));
19
19
  const app_configs_1 = __importDefault(require("../../configs/app-configs"));
20
+ const webpack_client_prod_1 = __importDefault(require("../../configs/webpack.client.prod"));
21
+ const make_tmp_dir_1 = __importDefault(require("../util/make-tmp-dir"));
20
22
  (() => __awaiter(void 0, void 0, void 0, function* () {
21
- let clientWebpackConfigs = Array.isArray(webpack_client_prod_1.default) ? webpack_client_prod_1.default : [webpack_client_prod_1.default];
23
+ const clientWebpackConfigs = Array.isArray(webpack_client_prod_1.default) ? webpack_client_prod_1.default : [webpack_client_prod_1.default];
22
24
  const promises = clientWebpackConfigs.map((webpackConfig, i) => __awaiter(void 0, void 0, void 0, function* () {
23
25
  const tmpDir = yield (0, make_tmp_dir_1.default)(i.toString());
24
26
  webpackConfig.plugins = [
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // TODO: remove eslint-disable-next-line
2
3
  /**
3
4
  * Формирует описание версии в `CHANGELOG.md` на основе данных введенных в Jenkins при старте пайплайна.
4
5
  * `standard-version` запускает этот скрипт как `postchangelog` хук.
@@ -33,7 +34,7 @@ const { readFile, rename, unlink } = fs_1.promises;
33
34
  * переменные окружения, т.к. `standard-version` запускает хуки через `child_process.exec`, не передавая туда
34
35
  * ни аргументы ни переменные окружения.
35
36
  */
36
- const { appNodeModulesBin, changelogPath, changelogTmpPath, changelogFeaturesPath, changelogBugfixesPath, changelogBreakingChangesPath } = app_configs_1.default;
37
+ const { appNodeModulesBin, changelogPath, changelogTmpPath, changelogFeaturesPath, changelogBugfixesPath, changelogBreakingChangesPath, } = app_configs_1.default;
37
38
  // Пример заголовка – `## [50.1.0](http://git.moscow.alfaintra.net/...) (2022-07-27)`.
38
39
  const changelogHeaderRegExp = /^###? \[\d+\.\d+\.\d+]\([^)]+\) \(\d{4}-\d{2}-\d{2}\)/;
39
40
  (() => __awaiter(void 0, void 0, void 0, function* () {
@@ -52,6 +53,7 @@ const changelogHeaderRegExp = /^###? \[\d+\.\d+\.\d+]\([^)]+\) \(\d{4}-\d{2}-\d{
52
53
  ws.write(getVersionDescription({ features, bugFixes, breakingChanges }));
53
54
  });
54
55
  try {
56
+ // eslint-disable-next-line no-restricted-syntax
55
57
  for (var _d = true, rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield rl_1.next(), _a = rl_1_1.done, !_a;) {
56
58
  _c = rl_1_1.value;
57
59
  _d = false;
@@ -101,7 +103,7 @@ const changelogHeaderRegExp = /^###? \[\d+\.\d+\.\d+]\([^)]+\) \(\d{4}-\d{2}-\d{
101
103
  (0, child_process_1.execSync)(`${appNodeModulesBin}/prettier -w "${changelogPath}"`);
102
104
  process.exit(0);
103
105
  }))();
104
- function getVersionDescription({ features, bugFixes, breakingChanges }) {
106
+ function getVersionDescription({ features, bugFixes, breakingChanges, }) {
105
107
  let versionDescription = '';
106
108
  if (features) {
107
109
  versionDescription += `### Features\n${features}\n`;
@@ -17,8 +17,8 @@ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
17
17
  const dockerfile_template_1 = __importDefault(require("../../templates/dockerfile.template"));
18
18
  const nginx_conf_template_1 = __importDefault(require("../../templates/nginx.conf.template"));
19
19
  const start_template_1 = __importDefault(require("../../templates/start.template"));
20
- const exec_1 = __importDefault(require("../util/exec"));
21
20
  const docker_build_1 = require("../util/docker-build");
21
+ const exec_1 = __importDefault(require("../util/exec"));
22
22
  const yarn_1 = require("../util/yarn");
23
23
  (() => __awaiter(void 0, void 0, void 0, function* () {
24
24
  const { imageFullName, pathToTempDir, tempDirName } = (0, docker_build_1.getBuildParamsFromArgs)();
@@ -17,8 +17,8 @@ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
17
17
  const dockerfile_compiled_template_1 = __importDefault(require("../../templates/dockerfile-compiled.template"));
18
18
  const nginx_conf_template_1 = __importDefault(require("../../templates/nginx.conf.template"));
19
19
  const start_template_1 = __importDefault(require("../../templates/start.template"));
20
- const exec_1 = __importDefault(require("../util/exec"));
21
20
  const docker_build_1 = require("../util/docker-build");
21
+ const exec_1 = __importDefault(require("../util/exec"));
22
22
  (() => __awaiter(void 0, void 0, void 0, function* () {
23
23
  const { imageFullName, pathToTempDir, tempDirName } = (0, docker_build_1.getBuildParamsFromArgs)();
24
24
  try {
@@ -6,23 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const app_configs_1 = __importDefault(require("../../configs/app-configs"));
7
7
  const run_compilers_1 = require("../util/run-compilers");
8
8
  process.env.BROWSERSLIST_CONFIG =
9
- process.env.BROWSERSLIST_CONFIG ||
10
- require.resolve("../../../.browserslistrc");
9
+ process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
11
10
  if (app_configs_1.default.tsconfig && app_configs_1.default.disableDevWebpackTypecheck) {
12
11
  const TSC_WATCH_COMMAND = [
13
- require.resolve("typescript/lib/tsc.js"),
14
- "--watch",
15
- "--noEmit",
16
- "--project",
12
+ require.resolve('typescript/lib/tsc.js'),
13
+ '--watch',
14
+ '--noEmit',
15
+ '--project',
17
16
  app_configs_1.default.tsconfig,
18
- "--skipLibCheck",
17
+ '--skipLibCheck',
19
18
  ];
20
- (0, run_compilers_1.runCompilers)([
21
- require.resolve("./client"),
22
- require.resolve("./server"),
23
- TSC_WATCH_COMMAND,
24
- ]);
19
+ (0, run_compilers_1.runCompilers)([require.resolve('./client'), require.resolve('./server'), TSC_WATCH_COMMAND]);
25
20
  }
26
21
  else {
27
- (0, run_compilers_1.runCompilers)([require.resolve("./client"), require.resolve("./server")]);
22
+ (0, run_compilers_1.runCompilers)([require.resolve('./client'), require.resolve('./server')]);
28
23
  }
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const chalk_1 = __importDefault(require("chalk"));
7
7
  const stats_options_1 = __importDefault(require("../../configs/stats-options"));
8
8
  function printCompilerOutput(compilerName, stats) {
9
- const output = stats.toString(stats_options_1.default)
9
+ const output = stats
10
+ .toString(stats_options_1.default)
10
11
  .split('\n')
11
12
  .map((line) => `${chalk_1.default.cyan(`[${compilerName}]`)} ${line}`)
12
13
  .join('\n');
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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
- ]);
4
+ process.env.BROWSERSLIST_CONFIG =
5
+ process.env.BROWSERSLIST_CONFIG || require.resolve('../../../.browserslistrc');
6
+ (0, run_compilers_1.runCompilers)([require.resolve('./client'), require.resolve('./server')]);
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
+ // TODO: remove eslint-disable and eslint-disable-next-line
3
+ /* eslint-disable @typescript-eslint/no-var-requires */
2
4
  // Do this as the first thing so that any code reading it knows the right env.
3
5
  process.env.BABEL_ENV = 'test';
4
6
  process.env.NODE_ENV = 'test';
5
7
  process.env.PUBLIC_URL = '';
8
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
9
+ // @ts-ignore
6
10
  const jestRunner = require('jest');
11
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
12
+ // @ts-ignore
7
13
  const jestConfig = require('../../configs/jest');
8
14
  // Makes the script crash on unhandled rejections instead of silently
9
15
  // ignoring them. In the future, promise rejections that are not handled will
10
16
  // terminate the Node.js process with a non-zero exit code.
11
- process.on('unhandledRejection', err => {
17
+ process.on('unhandledRejection', (err) => {
18
+ // eslint-disable-next-line @typescript-eslint/no-throw-literal
12
19
  throw err;
13
20
  });
14
21
  // Skip 'node', 'arui-scripts' and 'test' arguments and take all the rest (or none if there is no more arguments).
22
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-ignore
15
24
  const argv = process.argv.slice(3);
16
25
  argv.push('--config', JSON.stringify(jestConfig));
17
26
  jestRunner.run(argv);
@@ -23,29 +23,33 @@ function entryPointToArray(entryPoint) {
23
23
  const files = [
24
24
  ...entryPointToArray(app_configs_1.default.serverEntry),
25
25
  ...entryPointToArray(app_configs_1.default.clientEntry),
26
- ...(Array.isArray(app_configs_1.default.clientPolyfillsEntry) ? app_configs_1.default.clientPolyfillsEntry : [app_configs_1.default.clientPolyfillsEntry]),
26
+ ...(Array.isArray(app_configs_1.default.clientPolyfillsEntry)
27
+ ? app_configs_1.default.clientPolyfillsEntry
28
+ : [app_configs_1.default.clientPolyfillsEntry]),
27
29
  ];
28
30
  function checkFileWithExtensions(filePath, extensions) {
29
- if (extensions.some(ext => filePath.endsWith(`.${ext}`))) {
31
+ if (extensions.some((ext) => filePath.endsWith(`.${ext}`))) {
30
32
  try {
31
33
  fs_1.default.accessSync(filePath);
32
34
  return true;
33
35
  }
34
- catch (err) { }
36
+ catch (err) {
37
+ // empty error
38
+ }
35
39
  }
36
40
  for (let i = 0; i < extensions.length; i++) {
37
41
  try {
38
42
  fs_1.default.accessSync(`${filePath}.${extensions[i]}`);
39
43
  return true;
40
44
  }
41
- catch (err) { }
45
+ catch (err) {
46
+ // emprty error
47
+ }
42
48
  }
43
49
  return false;
44
50
  }
45
51
  function checkRequiredFiles() {
46
- const unavailableFilePaths = files
47
- .filter(Boolean)
48
- .reduce((result, filePath) => {
52
+ const unavailableFilePaths = files.filter(Boolean).reduce((result, filePath) => {
49
53
  if (filePath && !checkFileWithExtensions(filePath, extensions)) {
50
54
  result.push(filePath);
51
55
  }
@@ -54,7 +58,7 @@ function checkRequiredFiles() {
54
58
  if (unavailableFilePaths.length !== 0) {
55
59
  console.log(chalk_1.default.red('Could not find required files.'));
56
60
  const extensionsString = extensions.join(',');
57
- unavailableFilePaths.forEach(filePath => {
61
+ unavailableFilePaths.forEach((filePath) => {
58
62
  const dirName = path_1.default.dirname(filePath);
59
63
  const fileName = path_1.default.basename(filePath);
60
64
  console.log(chalk_1.default.red(' Name: ') + chalk_1.default.cyan(`${fileName}.{${extensionsString}}`));
@@ -4,17 +4,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.printAssetsSizes = exports.calculateAssetsSizes = void 0;
7
+ // TODO: remove eslint-disable-next-line
7
8
  const fs_1 = __importDefault(require("fs"));
8
9
  const path_1 = __importDefault(require("path"));
9
- const gzip_size_1 = require("gzip-size");
10
+ const chalk_1 = __importDefault(require("chalk"));
10
11
  const filesize_1 = __importDefault(require("filesize"));
12
+ const gzip_size_1 = require("gzip-size");
11
13
  const strip_ansi_1 = __importDefault(require("strip-ansi"));
12
- const chalk_1 = __importDefault(require("chalk"));
13
14
  let brotliSize = () => NaN;
14
15
  try {
16
+ // eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
15
17
  brotliSize = require('brotli-size').sync;
16
18
  }
17
19
  catch (error) {
20
+ // empty error
18
21
  }
19
22
  function canReadAsset(asset) {
20
23
  return (/\.(js|css)$/.test(asset) &&
@@ -27,9 +30,7 @@ function removeFileNameHash(fileName) {
27
30
  .replace(/\/?(.*)(\.[0-9a-f]+)(\.chunk)?(\.js|\.css)/, (match, p1, p2, p3, p4) => p1 + p4);
28
31
  }
29
32
  function calculateAssetsSizes(webpackStats, rootDir = '') {
30
- const assetsStats = (webpackStats
31
- .toJson({ all: false, assets: true })
32
- .assets || []);
33
+ const assetsStats = webpackStats.toJson({ all: false, assets: true }).assets || [];
33
34
  const assets = assetsStats
34
35
  .filter((asset) => canReadAsset(asset.name))
35
36
  .map((asset) => {
@@ -45,44 +46,38 @@ function calculateAssetsSizes(webpackStats, rootDir = '') {
45
46
  size: asset.size,
46
47
  sizeLabel: (0, filesize_1.default)(asset.size),
47
48
  gzipLabel: (0, filesize_1.default)(size),
48
- brotliLabel: brSize ? (0, filesize_1.default)(brSize) : '-'
49
+ brotliLabel: brSize ? (0, filesize_1.default)(brSize) : '-',
49
50
  };
50
51
  });
51
- const totalSizes = (assets || []).reduce((file, total) => {
52
- return {
53
- size: total.size + file.size,
54
- gzipSize: total.gzipSize + file.gzipSize,
55
- brotliSize: total.brotliSize + file.brotliSize
56
- };
57
- }, { size: 0, gzipSize: 0, brotliSize: 0 });
52
+ const totalSizes = (assets || []).reduce((file, total) => ({
53
+ size: total.size + file.size,
54
+ gzipSize: total.gzipSize + file.gzipSize,
55
+ brotliSize: total.brotliSize + file.brotliSize,
56
+ }), { size: 0, gzipSize: 0, brotliSize: 0 });
58
57
  totalSizes.sizeLabel = (0, filesize_1.default)(totalSizes.size || 0);
59
58
  totalSizes.gzipLabel = (0, filesize_1.default)(totalSizes.gzipSize || 0);
60
59
  totalSizes.brotliLabel = totalSizes.brotliSize ? (0, filesize_1.default)(totalSizes.brotliSize) : '-';
61
60
  return {
62
61
  totalSizes: totalSizes,
63
- assets
62
+ assets,
64
63
  };
65
64
  }
66
65
  exports.calculateAssetsSizes = calculateAssetsSizes;
67
66
  function printAssetsSizes(sizes) {
68
- const longestSizeLabelLength = Math.max.apply(null, sizes.assets.map(a => {
67
+ const longestSizeLabelLength = Math.max.apply(null, sizes.assets.map((a) => {
69
68
  const sizeLength = (0, strip_ansi_1.default)(a.gzipLabel).length;
70
69
  return sizeLength + sizeLength + 8;
71
70
  }));
72
71
  console.log(chalk_1.default.blueBright('Assets sizes:'));
73
- sizes.assets.forEach(asset => {
72
+ sizes.assets.forEach((asset) => {
74
73
  let sizeLabel = `${asset.sizeLabel} (${asset.gzipLabel} gzip, ${asset.brotliLabel} br)`;
75
74
  const sizeLength = (0, strip_ansi_1.default)(sizeLabel).length;
76
75
  if (sizeLength < longestSizeLabelLength) {
77
76
  const rightPadding = ' '.repeat(longestSizeLabelLength - sizeLength);
78
77
  sizeLabel += rightPadding;
79
78
  }
80
- console.log(' ' +
81
- sizeLabel +
82
- ' ' +
83
- chalk_1.default.cyan(asset.name));
79
+ console.log(` ${sizeLabel} ${chalk_1.default.cyan(asset.name)}`);
84
80
  });
85
- console.log(chalk_1.default.blueBright('\nTotal size:\n') +
86
- ` ${sizes.totalSizes.sizeLabel} (${sizes.totalSizes.gzipLabel} gzip, ${sizes.totalSizes.brotliLabel} br)\n`);
81
+ console.log(`${chalk_1.default.blueBright('\nTotal size:\n')} ${sizes.totalSizes.sizeLabel} (${sizes.totalSizes.gzipLabel} gzip, ${sizes.totalSizes.brotliLabel} br)\n`);
87
82
  }
88
83
  exports.printAssetsSizes = printAssetsSizes;
@@ -11,7 +11,7 @@ type PrepareFilesForDockerParams = {
11
11
  allowLocalDockerfile: boolean;
12
12
  allowLocalStartScript: boolean;
13
13
  };
14
- export declare function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript }: PrepareFilesForDockerParams): Promise<void>;
14
+ export declare function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript, }: PrepareFilesForDockerParams): Promise<void>;
15
15
  export declare function dockerVersionSatisfies(request: string): boolean;
16
16
  type DockerBuildCommandParams = {
17
17
  tempDirName: string;
@@ -13,17 +13,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.getDockerBuildCommand = exports.dockerVersionSatisfies = exports.prepareFilesForDocker = exports.getBuildParamsFromArgs = void 0;
16
- const app_configs_1 = __importDefault(require("../../configs/app-configs"));
17
16
  const path_1 = __importDefault(require("path"));
18
17
  const fs_extra_1 = __importDefault(require("fs-extra"));
19
- const shelljs_1 = __importDefault(require("shelljs"));
20
18
  const satisfies_1 = __importDefault(require("semver/functions/satisfies"));
19
+ const shelljs_1 = __importDefault(require("shelljs"));
20
+ const app_configs_1 = __importDefault(require("../../configs/app-configs"));
21
21
  function getBuildParamsFromArgs() {
22
22
  let imageVersion = app_configs_1.default.version;
23
23
  let imageName = app_configs_1.default.name;
24
- let dockerRegistry = app_configs_1.default.dockerRegistry;
24
+ let { dockerRegistry } = app_configs_1.default;
25
25
  const commandLineArguments = process.argv.slice(3);
26
- commandLineArguments.forEach(arg => {
26
+ commandLineArguments.forEach((arg) => {
27
27
  let [argName, argValue] = arg.split('=');
28
28
  argName = argName.toLowerCase().trim();
29
29
  argValue = argValue ? argValue.trim() : '';
@@ -51,7 +51,7 @@ function getBuildParamsFromArgs() {
51
51
  };
52
52
  }
53
53
  exports.getBuildParamsFromArgs = getBuildParamsFromArgs;
54
- function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript }) {
54
+ function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScriptTemplate, pathToTempDir, allowLocalDockerfile, allowLocalStartScript, }) {
55
55
  return __awaiter(this, void 0, void 0, function* () {
56
56
  yield fs_extra_1.default.emptyDir(pathToTempDir);
57
57
  const nginxConf = app_configs_1.default.localNginxConf
@@ -66,13 +66,18 @@ function prepareFilesForDocker({ dockerfileTemplate, nginxConfTemplate, startScr
66
66
  yield Promise.all([
67
67
  fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'Dockerfile'), dockerfile, 'utf8'),
68
68
  fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'nginx.conf'), nginxConf, 'utf8'),
69
- fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'start.sh'), startScript, { encoding: 'utf8', mode: 0o555 }),
69
+ fs_extra_1.default.writeFile(path_1.default.join(pathToTempDir, 'start.sh'), startScript, {
70
+ encoding: 'utf8',
71
+ mode: 0o555,
72
+ }),
70
73
  ]);
71
74
  });
72
75
  }
73
76
  exports.prepareFilesForDocker = prepareFilesForDocker;
74
77
  function dockerVersionSatisfies(request) {
75
- const dockerVersion = shelljs_1.default.exec('docker version --format \'{{.Server.Version}}\'', { silent: true });
78
+ const dockerVersion = shelljs_1.default.exec("docker version --format '{{.Server.Version}}'", {
79
+ silent: true,
80
+ });
76
81
  return (0, satisfies_1.default)(dockerVersion.toString(), request);
77
82
  }
78
83
  exports.dockerVersionSatisfies = dockerVersionSatisfies;
@@ -3,10 +3,12 @@ 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
+ // TODO: remove eslint-disable-next-line
6
7
  const shelljs_1 = __importDefault(require("shelljs"));
7
8
  function exec(command) {
8
9
  return new Promise((resolve, reject) => {
9
10
  console.log(`Executing command: ${command}`);
11
+ // eslint-disable-next-line consistent-return
10
12
  shelljs_1.default.exec(command, (code) => {
11
13
  if (code === 0) {
12
14
  return resolve(code);
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
+ // TODO: remove eslint-disable and eslint-disable-next-line
3
+ /* eslint-disable no-param-reassign */
2
4
  /**
3
5
  * Copyright (c) 2015-present, Facebook, Inc.
4
6
  *
@@ -11,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
11
13
  // Some custom utilities to prettify Webpack output.
12
14
  // This is quite hacky and hopefully won't be needed when Webpack fixes this.
13
15
  // https://github.com/webpack/webpack/issues/2878
16
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
14
17
  const chalk = require('chalk');
15
18
  const friendlySyntaxErrorLabel = 'Syntax error:';
16
19
  function isLikelyASyntaxError(message) {
@@ -25,10 +28,10 @@ function formatMessage(message) {
25
28
  let lines = message.split('\n');
26
29
  // Strip webpack-added headers off errors/warnings
27
30
  // https://github.com/webpack/webpack/blob/master/lib/ModuleError.js
28
- lines = lines.filter(line => !/Module [A-z ]+\(from/.test(line));
31
+ lines = lines.filter((line) => !/Module [A-z ]+\(from/.test(line));
29
32
  // Transform parsing error into syntax error
30
33
  // TODO: move this to our ESLint formatter?
31
- lines = lines.map(line => {
34
+ lines = lines.map((line) => {
32
35
  const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
33
36
  if (!parsingError) {
34
37
  return line;
@@ -40,9 +43,9 @@ function formatMessage(message) {
40
43
  // Smoosh syntax errors (commonly found in CSS)
41
44
  message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)\n`);
42
45
  // Clean up export errors
43
- message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$2'.`);
44
- message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$2' does not contain a default export (imported as '$1').`);
45
- message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, `Attempted import error: '$1' is not exported from '$3' (imported as '$2').`);
46
+ message = message.replace(/^.*export '(.+?)' was not found in '(.+?)'.*$/gm, "Attempted import error: '$1' is not exported from '$2'.");
47
+ message = message.replace(/^.*export 'default' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, "Attempted import error: '$2' does not contain a default export (imported as '$1').");
48
+ message = message.replace(/^.*export '(.+?)' \(imported as '(.+?)'\) was not found in '(.+?)'.*$/gm, "Attempted import error: '$1' is not exported from '$3' (imported as '$2').");
46
49
  lines = message.split('\n');
47
50
  // Remove leading newline
48
51
  if (lines.length > 2 && lines[1].trim() === '') {
@@ -62,8 +65,7 @@ function formatMessage(message) {
62
65
  // Add helpful message for users trying to use Sass for the first time
63
66
  if (lines[1] && lines[1].match(/Cannot find module.+node-sass/)) {
64
67
  lines[1] = 'To import Sass files, you first need to install node-sass.\n';
65
- lines[1] +=
66
- 'Run `npm install node-sass` or `yarn add node-sass` inside your workspace.';
68
+ lines[1] += 'Run `npm install node-sass` or `yarn add node-sass` inside your workspace.';
67
69
  }
68
70
  lines[0] = chalk.inverse(lines[0]);
69
71
  message = lines.join('\n');
@@ -12,10 +12,10 @@ 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
- const path_1 = __importDefault(require("path"));
16
- const util_1 = __importDefault(require("util"));
17
15
  const fs_1 = __importDefault(require("fs"));
18
16
  const os_1 = __importDefault(require("os"));
17
+ const path_1 = __importDefault(require("path"));
18
+ const util_1 = __importDefault(require("util"));
19
19
  const nodeMakeTmpDir = util_1.default.promisify(fs_1.default.mkdtemp);
20
20
  /**
21
21
  * Создает и возвращает временную папку
@@ -23,7 +23,7 @@ const nodeMakeTmpDir = util_1.default.promisify(fs_1.default.mkdtemp);
23
23
  */
24
24
  function makeTmpDir(prefix) {
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
- return yield nodeMakeTmpDir(path_1.default.join(os_1.default.tmpdir(), prefix || ''));
26
+ return nodeMakeTmpDir(path_1.default.join(os_1.default.tmpdir(), prefix || ''));
27
27
  });
28
28
  }
29
29
  exports.default = makeTmpDir;
@@ -13,11 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.runClientDevServer = void 0;
16
+ const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
16
17
  const webpack_1 = __importDefault(require("webpack"));
17
18
  const webpack_dev_server_1 = __importDefault(require("webpack-dev-server"));
18
19
  const dev_server_1 = __importDefault(require("../../configs/dev-server"));
19
20
  const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
20
- const WebpackDevServerUtils_1 = require("react-dev-utils/WebpackDevServerUtils");
21
21
  function runClientDevServer(configuration) {
22
22
  return __awaiter(this, void 0, void 0, function* () {
23
23
  const clientCompiler = (0, webpack_1.default)(configuration); // типы вебпака не умеют выбирать между конфигурациями и массивом конфигураций
@@ -1 +1 @@
1
- export declare function runCompilers(pathToCompilers: (string | string[])[]): void;
1
+ export declare function runCompilers(pathToCompilers: Array<string | string[]>): void;
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runCompilers = void 0;
7
- const check_required_files_1 = __importDefault(require("./check-required-files"));
7
+ const child_process_1 = require("child_process");
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const app_configs_1 = __importDefault(require("../../configs/app-configs"));
10
- const child_process_1 = require("child_process");
10
+ const check_required_files_1 = __importDefault(require("./check-required-files"));
11
11
  function runCompilers(pathToCompilers) {
12
12
  if (!(0, check_required_files_1.default)()) {
13
13
  process.exit(1);
@@ -17,19 +17,19 @@ function runCompilers(pathToCompilers) {
17
17
  }
18
18
  const compilers = pathToCompilers.map((pathToCompiler) => {
19
19
  if (Array.isArray(pathToCompiler)) {
20
- const compiler = (0, child_process_1.spawn)("node", pathToCompiler, {
21
- stdio: "inherit",
22
- cwd: app_configs_1.default.cwd
20
+ const compiler = (0, child_process_1.spawn)('node', pathToCompiler, {
21
+ stdio: 'inherit',
22
+ cwd: app_configs_1.default.cwd,
23
23
  });
24
- compiler.on("error", onProcessExit);
25
- compiler.on("close", onProcessExit);
24
+ compiler.on('error', onProcessExit);
25
+ compiler.on('close', onProcessExit);
26
26
  return compiler;
27
27
  }
28
- const compiler = (0, child_process_1.spawn)("node", [pathToCompiler], {
29
- stdio: "inherit",
28
+ const compiler = (0, child_process_1.spawn)('node', [pathToCompiler], {
29
+ stdio: 'inherit',
30
30
  });
31
- compiler.on("error", onProcessExit);
32
- compiler.on("close", onProcessExit);
31
+ compiler.on('error', onProcessExit);
32
+ compiler.on('close', onProcessExit);
33
33
  return compiler;
34
34
  });
35
35
  function onProcessExit(code) {
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runServerWatchCompiler = void 0;
7
7
  const webpack_1 = __importDefault(require("webpack"));
8
- const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
9
8
  const app_configs_1 = __importDefault(require("../../configs/app-configs"));
9
+ const print_compiler_output_1 = __importDefault(require("../start/print-compiler-output"));
10
10
  function runServerWatchCompiler(config) {
11
11
  const serverCompiler = (0, webpack_1.default)(config);
12
12
  serverCompiler.hooks.compile.tap('server', () => console.log('Compiling server...'));
@@ -15,7 +15,6 @@ function runServerWatchCompiler(config) {
15
15
  serverCompiler.watch({
16
16
  aggregateTimeout: 50,
17
17
  ignored: new RegExp(app_configs_1.default.watchIgnorePath.join('|')),
18
- }, () => {
19
- });
18
+ }, () => { });
20
19
  }
21
20
  exports.runServerWatchCompiler = runServerWatchCompiler;