arui-scripts 15.3.0 → 15.4.0

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 (51) hide show
  1. package/.turbo/turbo-build.log +0 -0
  2. package/.turbo/turbo-test.log +91 -0
  3. package/CHANGELOG.md +270 -656
  4. package/README.md +27 -1
  5. package/bin/build.sh +2 -1
  6. package/build/commands/build/build-wrapper.d.ts +2 -2
  7. package/build/commands/build/client.js +3 -3
  8. package/build/commands/bundle-analyze/index.js +15 -15
  9. package/build/commands/changelog/index.js +2 -2
  10. package/build/commands/util/make-tmp-dir.d.ts +1 -1
  11. package/build/commands/util/make-tmp-dir.js +2 -2
  12. package/build/commands/util/run-client-dev-server.d.ts +1 -1
  13. package/build/commands/util/run-client-dev-server.js +1 -4
  14. package/build/configs/app-configs/calculate-dependent-config.d.ts +54 -8
  15. package/build/configs/app-configs/calculate-dependent-config.js +11 -13
  16. package/build/configs/app-configs/get-defaults.d.ts +3 -2
  17. package/build/configs/app-configs/get-defaults.js +69 -55
  18. package/build/configs/app-configs/index.d.ts +5 -3
  19. package/build/configs/app-configs/index.js +13 -7
  20. package/build/configs/app-configs/types.d.ts +51 -38
  21. package/build/configs/app-configs/update-with-config-file.d.ts +2 -2
  22. package/build/configs/app-configs/update-with-config-file.js +5 -7
  23. package/build/configs/app-configs/update-with-env.js +3 -8
  24. package/build/configs/app-configs/update-with-package.d.ts +2 -2
  25. package/build/configs/app-configs/update-with-package.js +5 -10
  26. package/build/configs/app-configs/update-with-presets.d.ts +2 -2
  27. package/build/configs/app-configs/update-with-presets.js +8 -15
  28. package/build/configs/app-configs/validate-settings-keys.d.ts +2 -5
  29. package/build/configs/app-configs/validate-settings-keys.js +6 -7
  30. package/build/configs/babel-client.d.ts +33 -1
  31. package/build/configs/babel-dependencies.d.ts +14 -1
  32. package/build/configs/babel-server.d.ts +26 -1
  33. package/build/configs/dev-server.d.ts +15 -1
  34. package/build/configs/jest/index.d.ts +33 -1
  35. package/build/configs/postcss.config.d.ts +1 -1
  36. package/build/configs/postcss.d.ts +1 -1
  37. package/build/configs/process-assets-plugin-output.d.ts +2 -0
  38. package/build/configs/process-assets-plugin-output.js +32 -0
  39. package/build/configs/server-externals-exemptions.d.ts +1 -1
  40. package/build/configs/util/apply-overrides.d.ts +23 -7
  41. package/build/configs/util/apply-overrides.js +3 -2
  42. package/build/configs/util/get-entry.d.ts +2 -1
  43. package/build/configs/webpack.client.d.ts +10 -2
  44. package/build/configs/webpack.client.dev.js +1 -1
  45. package/build/configs/webpack.client.js +42 -13
  46. package/build/configs/webpack.client.prod.js +1 -1
  47. package/build/index.d.ts +1 -1
  48. package/build/tsconfig-local.tsbuildinfo +1 -1
  49. package/package.json +1 -1
  50. package/build/configs/app-configs/available-package-settings.d.ts +0 -8
  51. package/build/configs/app-configs/available-package-settings.js +0 -34
package/README.md CHANGED
@@ -590,7 +590,7 @@ export default overrides;
590
590
  const { files } = postcssPluginsOptions['@csstools/postcss-global-data'];
591
591
  const newOption = {
592
592
  ...postcssPluginsOptions,
593
- '@csstools/postcss-global-data': {
593
+ '@csstools/postcss-global-data': {
594
594
  files:files.concat(['./vars.css'])
595
595
  }
596
596
  };
@@ -621,6 +621,32 @@ export default overrides;
621
621
 
622
622
  Для некоторых конфигураций определены несколько ключей, они будут применяться в том порядке, в котором они приведены в этом файле.
623
623
 
624
+ ### Создание дополнительных конфигураций для webpack
625
+ На некоторых проектах может потребоваться создать дополнительные конфигурации для webpack. Например, для создания
626
+ service worker'а (или любых других кейсов). Для этого можно использовать функцию-хелпер `createSingleWebpackConfig`:
627
+
628
+ ```ts
629
+ import type { OverrideFile } from 'arui-scripts';
630
+
631
+ const overrides: OverrideFile = {
632
+ webpackClient: (config, appConfig, { createSingleClientWebpackConfig }) => {
633
+ return [
634
+ config,
635
+ createSingleClientWebpackConfig(
636
+ './src/sw.js', // entrypoint, может быть массивом/объектом
637
+ 'sw', // наименование сборки, влияет на имена чанков
638
+ ),
639
+ ];
640
+ }
641
+ };
642
+
643
+ export default overrides;
644
+ ```
645
+ Эта функция вернет независимую конфигурацию для webpack, которую можно использовать в качестве оверрайда. Вы так же можете ее модифицировать,
646
+ не боясь что это повлияет на другие конфигурации.
647
+
648
+ Созданная таким образом конфигурация будет шарить с оригинальной конфигурацией только плагин для формирования assets-manifest'а.
649
+
624
650
  Пресеты
625
651
  ===
626
652
 
package/bin/build.sh CHANGED
@@ -1 +1,2 @@
1
- tsc --project tsconfig-local.json;cp ./src/configs/mq.css build/configs/mq.css;
1
+ set -e;
2
+ tsc --project tsconfig-local.json;cp ./src/configs/mq.css build/configs/mq.css;
@@ -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) => {
@@ -16,20 +16,20 @@ const webpack_1 = __importDefault(require("webpack"));
16
16
  const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
17
17
  const make_tmp_dir_1 = __importDefault(require("../util/make-tmp-dir"));
18
18
  const webpack_client_prod_1 = __importDefault(require("../../configs/webpack.client.prod"));
19
- const app_configs_1 = __importDefault(require("../../configs/app-configs"));
20
19
  (() => __awaiter(void 0, void 0, void 0, function* () {
21
- var _a;
22
- const tmpDir = yield (0, make_tmp_dir_1.default)();
23
- const plugin = new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
24
- generateStatsFile: true,
25
- statsFilename: app_configs_1.default.statsOutputPath,
26
- });
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(() => { });
20
+ let clientWebpackConfigs = Array.isArray(webpack_client_prod_1.default) ? webpack_client_prod_1.default : [webpack_client_prod_1.default];
21
+ const promises = clientWebpackConfigs.map((config, i) => __awaiter(void 0, void 0, void 0, function* () {
22
+ const tmpDir = yield (0, make_tmp_dir_1.default)(i.toString());
23
+ config.plugins = [
24
+ ...config.plugins,
25
+ new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
26
+ generateStatsFile: true,
27
+ statsFilename: config.statsOutputPath,
28
+ analyzerPort: 'auto',
29
+ }),
30
+ ];
31
+ config.output = Object.assign(Object.assign({}, config.output), { path: tmpDir });
32
+ }));
33
+ yield Promise.all(promises);
34
+ (0, webpack_1.default)(clientWebpackConfigs).run(() => { });
35
35
  }))();
@@ -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* () {
@@ -2,5 +2,5 @@
2
2
  * Создает и возвращает временную папку
3
3
  * @returns {Promise<string>}
4
4
  */
5
- declare function makeTmpDir(): Promise<string>;
5
+ declare function makeTmpDir(prefix?: string): Promise<string>;
6
6
  export default makeTmpDir;
@@ -21,9 +21,9 @@ const nodeMakeTmpDir = util_1.default.promisify(fs_1.default.mkdtemp);
21
21
  * Создает и возвращает временную папку
22
22
  * @returns {Promise<string>}
23
23
  */
24
- function makeTmpDir() {
24
+ function makeTmpDir(prefix) {
25
25
  return __awaiter(this, void 0, void 0, function* () {
26
- return yield nodeMakeTmpDir(`${os_1.default.tmpdir()}${path_1.default.sep}`);
26
+ return yield nodeMakeTmpDir(path_1.default.join(os_1.default.tmpdir(), prefix || ''));
27
27
  });
28
28
  }
29
29
  exports.default = makeTmpDir;
@@ -1,2 +1,2 @@
1
1
  import { Configuration } from 'webpack';
2
- export declare function runClientDevServer(configuration: Configuration): Promise<void>;
2
+ export declare function runClientDevServer(configuration: Configuration | Configuration[]): Promise<void>;
@@ -20,10 +20,7 @@ const print_compiler_output_1 = __importDefault(require("../start/print-compiler
20
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
- const clientCompiler = (0, webpack_1.default)(configuration);
24
- // не резолвиться constructor(config: WebpackDevServer.Configuration, webpack?: webpack.Compiler | webpack.MultiCompiler);
25
- // clientCompiler: webpack.Compiler
26
- // @ts-ignore
23
+ const clientCompiler = (0, webpack_1.default)(configuration); // типы вебпака не умеют выбирать между конфигурациями и массивом конфигураций
27
24
  const clientDevServer = new webpack_dev_server_1.default(dev_server_1.default, clientCompiler);
28
25
  clientCompiler.hooks.invalid.tap('client', () => console.log('Compiling client...'));
29
26
  clientCompiler.hooks.done.tap('client', (stats) => (0, print_compiler_output_1.default)('Client', stats));
@@ -1,13 +1,59 @@
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
+ devServerCors: boolean;
12
+ useServerHMR: boolean;
13
+ presets: string | null;
14
+ buildPath: string;
15
+ assetsPath: string;
16
+ additionalBuildPath: string[];
17
+ statsOutputFilename: string;
18
+ serverEntry: string | string[] | Record<string, string | string[]>;
19
+ serverOutput: string;
20
+ clientEntry: string | string[] | Record<string, string | string[]>;
21
+ dockerRegistry: string;
22
+ baseDockerImage: string;
23
+ nginxRootPath: string;
24
+ runFromNonRootUser: boolean;
25
+ removeDevDependenciesDuringDockerBuild: boolean;
26
+ archiveName: string;
27
+ keepPropTypes: boolean;
28
+ useTscLoader: boolean;
29
+ webpack4Compatibility: boolean;
30
+ installServerSourceMaps: boolean;
31
+ dataUrlMaxSize?: number | undefined;
32
+ imageMinimizer?: {
33
+ svg?: {
34
+ enabled?: boolean | undefined;
35
+ } | undefined;
36
+ gif?: {
37
+ enabled?: boolean | undefined;
38
+ optimizationLevel?: number | undefined;
39
+ } | undefined;
40
+ jpg?: {
41
+ enabled?: boolean | undefined;
42
+ quality: number;
43
+ } | undefined;
44
+ png?: {
45
+ enabled?: boolean | undefined;
46
+ optimizationLevel?: number | undefined;
47
+ bitDepthReduction?: boolean | undefined;
48
+ colorTypeReduction?: boolean | undefined;
49
+ paletteReduction?: boolean | undefined;
50
+ interlaced?: boolean | undefined;
51
+ } | undefined;
52
+ } | undefined;
53
+ componentsTheme: string | null;
54
+ keepCssVars: boolean;
13
55
  };
56
+ /**
57
+ * Обновление контекста в зависимости от ключей конфига
58
+ */
59
+ 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;
@@ -3,17 +3,77 @@ 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.getDefaults = void 0;
6
+ exports.getDefaultAppContext = exports.getDefaultAppConfig = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const resolve_1 = require("../util/resolve");
10
- function getDefaults() {
11
- const CWD = process.cwd();
10
+ const CWD = process.cwd();
11
+ const absoluteSrcPath = path_1.default.resolve(CWD, 'src');
12
+ function getDefaultAppConfig() {
13
+ return {
14
+ /// general settings
15
+ clientServerPort: 8080,
16
+ serverPort: 3000,
17
+ debug: false,
18
+ devSourceMaps: 'eval',
19
+ devServerCors: false,
20
+ useServerHMR: false,
21
+ presets: null,
22
+ // paths
23
+ buildPath: '.build',
24
+ assetsPath: 'assets',
25
+ additionalBuildPath: ['config'],
26
+ statsOutputFilename: 'stats.json',
27
+ serverEntry: path_1.default.resolve(absoluteSrcPath, 'server/index'),
28
+ serverOutput: 'server.js',
29
+ clientPolyfillsEntry: null,
30
+ clientEntry: path_1.default.resolve(absoluteSrcPath, 'index'),
31
+ // docker compilation configs
32
+ dockerRegistry: '',
33
+ baseDockerImage: 'alfabankui/arui-scripts:latest',
34
+ nginxRootPath: '/src',
35
+ runFromNonRootUser: true,
36
+ removeDevDependenciesDuringDockerBuild: true,
37
+ // archive compilation configs
38
+ archiveName: 'build.tar',
39
+ // build tuning
40
+ keepPropTypes: false,
41
+ useTscLoader: false,
42
+ webpack4Compatibility: false,
43
+ installServerSourceMaps: false,
44
+ // image processing
45
+ dataUrlMaxSize: 1536,
46
+ imageMinimizer: {
47
+ svg: {
48
+ enabled: true,
49
+ },
50
+ gif: {
51
+ enabled: false,
52
+ optimizationLevel: 1,
53
+ },
54
+ jpg: {
55
+ enabled: false,
56
+ quality: 75,
57
+ },
58
+ png: {
59
+ enabled: false,
60
+ optimizationLevel: 3,
61
+ bitDepthReduction: false,
62
+ colorTypeReduction: false,
63
+ paletteReduction: false,
64
+ },
65
+ },
66
+ // CSS
67
+ componentsTheme: null,
68
+ keepCssVars: false,
69
+ };
70
+ }
71
+ exports.getDefaultAppConfig = getDefaultAppConfig;
72
+ function getDefaultAppContext() {
12
73
  const appPackage = JSON.parse(fs_1.default.readFileSync(path_1.default.join(CWD, 'package.json'), 'utf8'));
13
74
  if (appPackage['arui-scripts']) {
14
75
  throw Error('arui-scripts in package.json is not supported. Use aruiScripts instead.');
15
76
  }
16
- const absoluteSrcPath = path_1.default.resolve(CWD, 'src');
17
77
  const absoluteNodeModulesPath = path_1.default.resolve(CWD, 'node_modules');
18
78
  const absoluteNodeModulesBinPath = path_1.default.resolve(absoluteNodeModulesPath, '.bin');
19
79
  const projectTsConfigPath = path_1.default.join(CWD, 'tsconfig.json');
@@ -25,47 +85,22 @@ function getDefaults() {
25
85
  return {
26
86
  appPackage,
27
87
  name: appPackage.name,
88
+ normalizedName: appPackage.name.replace(/-/g, '_'),
28
89
  version: appPackage.version,
29
- dockerRegistry: '',
30
- baseDockerImage: 'alfabankui/arui-scripts:latest',
31
90
  // general paths
32
91
  cwd: CWD,
33
92
  appSrc: absoluteSrcPath,
34
93
  appNodeModules: absoluteNodeModulesPath,
35
94
  appNodeModulesBin: absoluteNodeModulesBinPath,
36
- buildPath: '.build',
37
- assetsPath: 'assets',
38
- additionalBuildPath: ['config'],
39
- nginxRootPath: '/src',
40
- runFromNonRootUser: true,
41
- archiveName: 'build.tar',
95
+ overridesPath: overridesPath ? [overridesPath] : [],
96
+ // tools availability
42
97
  babelRuntimeVersion: '7.0.0-beta.0',
43
- // server compilation configs
44
- serverEntry: path_1.default.resolve(absoluteSrcPath, 'server/index'),
45
- serverOutput: 'server.js',
46
- // client compilation configs
47
- clientPolyfillsEntry: null,
48
- clientEntry: path_1.default.resolve(absoluteSrcPath, 'index'),
49
- keepPropTypes: false,
98
+ useYarn: fs_1.default.existsSync(yarnLockFilePath),
50
99
  // compilation configs locations
51
100
  tsconfig: fs_1.default.existsSync(projectTsConfigPath) ? projectTsConfigPath : null,
52
101
  localNginxConf: fs_1.default.existsSync(nginxConfFilePath) ? nginxConfFilePath : null,
53
102
  localDockerfile: fs_1.default.existsSync(dockerfileFilePath) ? dockerfileFilePath : null,
54
103
  localStartScript: fs_1.default.existsSync(startScriptFilePath) ? startScriptFilePath : null,
55
- devSourceMaps: 'eval',
56
- useTscLoader: false,
57
- useServerHMR: false,
58
- webpack4Compatibility: false,
59
- useYarn: fs_1.default.existsSync(yarnLockFilePath),
60
- clientServerPort: 8080,
61
- serverPort: 3000,
62
- installServerSourceMaps: false,
63
- debug: false,
64
- overridesPath: overridesPath ? [overridesPath] : [],
65
- statsOutputFilename: 'stats.json',
66
- removeDevDependenciesDuringDockerBuild: true,
67
- componentsTheme: undefined,
68
- keepCssVars: false,
69
104
  // Эти пути зависят от других настроек, которые могут быть переопределены пользователем
70
105
  publicPath: '',
71
106
  serverOutputPath: '',
@@ -78,27 +113,6 @@ function getDefaults() {
78
113
  changelogFeaturesPath: path_1.default.resolve(CWD, './changelog_features.tmp'),
79
114
  changelogBugfixesPath: path_1.default.resolve(CWD, './changelog_bugfixes.tmp'),
80
115
  changelogBreakingChangesPath: path_1.default.resolve(CWD, './changelog_breaking_changes.tmp'),
81
- dataUrlMaxSize: 1536,
82
- imageMinimizer: {
83
- svg: {
84
- enabled: true,
85
- },
86
- gif: {
87
- enabled: false,
88
- optimizationLevel: 1,
89
- },
90
- jpg: {
91
- enabled: false,
92
- quality: 75
93
- },
94
- png: {
95
- enabled: false,
96
- optimizationLevel: 3,
97
- bitDepthReduction: false,
98
- colorTypeReduction: false,
99
- paletteReduction: false
100
- }
101
- }
102
116
  };
103
117
  }
104
- exports.getDefaults = getDefaults;
118
+ exports.getDefaultAppContext = getDefaultAppContext;
@@ -1,4 +1,6 @@
1
1
  import '../util/register-ts-node';
2
- import { AppConfigs } from './types';
3
- declare let config: AppConfigs;
4
- export default config;
2
+ import { AppConfigs, AppContext, AppContextWithConfigs } from './types';
3
+ export declare const appContext: AppContext;
4
+ export declare const appConfigs: AppConfigs;
5
+ export declare const configs: AppContextWithConfigs;
6
+ export default configs;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configs = exports.appConfigs = exports.appContext = void 0;
3
4
  require("../util/register-ts-node");
4
5
  const get_defaults_1 = require("./get-defaults");
5
6
  const update_with_env_1 = require("./update-with-env");
@@ -7,10 +8,15 @@ const update_with_package_1 = require("./update-with-package");
7
8
  const update_with_presets_1 = require("./update-with-presets");
8
9
  const calculate_dependent_config_1 = require("./calculate-dependent-config");
9
10
  const update_with_config_file_1 = require("./update-with-config-file");
10
- let config = (0, get_defaults_1.getDefaults)();
11
- config = (0, update_with_presets_1.updateWithPresets)(config);
12
- config = (0, update_with_package_1.updateWithPackage)(config);
13
- config = (0, update_with_config_file_1.updateWithConfigFile)(config);
14
- config = (0, update_with_env_1.updateWithEnv)(config);
15
- config = (0, calculate_dependent_config_1.calculateDependentConfig)(config);
16
- exports.default = config;
11
+ let tmpConfig = (0, get_defaults_1.getDefaultAppConfig)();
12
+ let tmpContext = (0, get_defaults_1.getDefaultAppContext)();
13
+ tmpConfig = (0, update_with_presets_1.updateWithPresets)(tmpConfig, tmpContext);
14
+ tmpConfig = (0, update_with_package_1.updateWithPackage)(tmpConfig, tmpContext);
15
+ tmpConfig = (0, update_with_config_file_1.updateWithConfigFile)(tmpConfig, tmpContext);
16
+ tmpConfig = (0, update_with_env_1.updateWithEnv)(tmpConfig);
17
+ tmpConfig = (0, calculate_dependent_config_1.calculateDependentConfig)(tmpConfig);
18
+ tmpContext = (0, calculate_dependent_config_1.calculateDependentContext)(tmpConfig, tmpContext);
19
+ exports.appContext = tmpContext;
20
+ exports.appConfigs = tmpConfig;
21
+ exports.configs = Object.assign(Object.assign({}, exports.appConfigs), exports.appContext);
22
+ exports.default = exports.configs;
@@ -1,53 +1,32 @@
1
+ /**
2
+ * Конфигурация arui-scripts, которая может быть переопределена приложением
3
+ */
1
4
  export type AppConfigs = {
2
- appPackage: any;
3
- name: string;
4
- version: string;
5
- dockerRegistry: string;
6
- baseDockerImage: string;
7
- cwd: string;
8
- appSrc: string;
9
- appNodeModules: string;
10
- appNodeModulesBin: string;
5
+ clientServerPort: number;
6
+ serverPort: number;
7
+ debug: boolean;
8
+ devSourceMaps: string;
9
+ devServerCors: boolean;
10
+ useServerHMR: boolean;
11
+ presets: string | null;
11
12
  buildPath: string;
12
13
  assetsPath: string;
13
14
  additionalBuildPath: string[];
14
- nginxRootPath: string;
15
- runFromNonRootUser: boolean;
16
- archiveName: string;
17
- babelRuntimeVersion: string;
15
+ statsOutputFilename: string;
18
16
  serverEntry: string | string[] | Record<string, string | string[]>;
19
17
  serverOutput: string;
20
18
  clientPolyfillsEntry: null | string | string[];
21
19
  clientEntry: string | string[] | Record<string, string | string[]>;
20
+ dockerRegistry: string;
21
+ baseDockerImage: string;
22
+ nginxRootPath: string;
23
+ runFromNonRootUser: boolean;
24
+ removeDevDependenciesDuringDockerBuild: boolean;
25
+ archiveName: string;
22
26
  keepPropTypes: boolean;
23
- tsconfig: string | null;
24
- localNginxConf: string | null;
25
- localDockerfile: string | null;
26
- localStartScript: string | null;
27
- devSourceMaps: string;
28
27
  useTscLoader: boolean;
29
- useServerHMR: boolean;
30
28
  webpack4Compatibility: boolean;
31
- useYarn: boolean;
32
- clientServerPort: number;
33
- serverPort: number;
34
29
  installServerSourceMaps: boolean;
35
- debug: boolean;
36
- overridesPath: string[];
37
- statsOutputFilename: string;
38
- removeDevDependenciesDuringDockerBuild: boolean;
39
- componentsTheme: string | undefined;
40
- keepCssVars: boolean;
41
- publicPath: string;
42
- serverOutputPath: string;
43
- clientOutputPath: string;
44
- statsOutputPath: string;
45
- watchIgnorePath: string[];
46
- changelogPath: string;
47
- changelogTmpPath: string;
48
- changelogFeaturesPath: string;
49
- changelogBugfixesPath: string;
50
- changelogBreakingChangesPath: string;
51
30
  dataUrlMaxSize?: number;
52
31
  imageMinimizer?: {
53
32
  svg?: {
@@ -70,4 +49,38 @@ export type AppConfigs = {
70
49
  interlaced?: boolean;
71
50
  };
72
51
  };
52
+ componentsTheme: string | null;
53
+ keepCssVars: boolean;
54
+ };
55
+ /**
56
+ * Внутренний контекст arui-scripts
57
+ */
58
+ export type AppContext = {
59
+ appPackage: any;
60
+ name: string;
61
+ normalizedName: string;
62
+ version: string;
63
+ cwd: string;
64
+ appSrc: string;
65
+ appNodeModules: string;
66
+ appNodeModulesBin: string;
67
+ babelRuntimeVersion: string;
68
+ useYarn: boolean;
69
+ tsconfig: string | null;
70
+ localNginxConf: string | null;
71
+ localDockerfile: string | null;
72
+ localStartScript: string | null;
73
+ overridesPath: string[];
74
+ publicPath: string;
75
+ serverOutputPath: string;
76
+ clientOutputPath: string;
77
+ statsOutputPath: string;
78
+ watchIgnorePath: string[];
79
+ changelogPath: string;
80
+ changelogTmpPath: string;
81
+ changelogFeaturesPath: string;
82
+ changelogBugfixesPath: string;
83
+ changelogBreakingChangesPath: string;
73
84
  };
85
+ export type AppContextWithConfigs = AppContext & AppConfigs;
86
+ export type PackageSettings = Partial<AppConfigs>;
@@ -1,2 +1,2 @@
1
- import { AppConfigs } from './types';
2
- export declare function updateWithConfigFile(config: AppConfigs): AppConfigs;
1
+ import { AppConfigs, AppContext } from './types';
2
+ export declare function updateWithConfigFile(config: AppConfigs, context: AppContext): any;
@@ -5,20 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.updateWithConfigFile = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- const lodash_merge_1 = __importDefault(require("lodash.merge"));
9
8
  const resolve_1 = require("../util/resolve");
10
- const validate_settings_keys_1 = __importDefault(require("./validate-settings-keys"));
11
- const available_package_settings_1 = require("./available-package-settings");
12
- function updateWithConfigFile(config) {
13
- const appConfigPath = (0, resolve_1.tryResolve)(path_1.default.join(config.cwd, '/arui-scripts.config'));
9
+ const validate_settings_keys_1 = require("./validate-settings-keys");
10
+ function updateWithConfigFile(config, context) {
11
+ const appConfigPath = (0, resolve_1.tryResolve)(path_1.default.join(context.cwd, '/arui-scripts.config'));
14
12
  if (appConfigPath) {
15
13
  let appSettings = require(appConfigPath);
16
14
  if (appSettings.__esModule) {
17
15
  // ts-node импортирует esModules, из них надо вытягивать default именно так
18
16
  appSettings = appSettings.default;
19
17
  }
20
- (0, validate_settings_keys_1.default)(available_package_settings_1.availablePackageSettings, appSettings);
21
- config = (0, lodash_merge_1.default)(config, appSettings);
18
+ (0, validate_settings_keys_1.validateSettingsKeys)(config, appSettings, appConfigPath);
19
+ return Object.assign(Object.assign({}, config), appSettings);
22
20
  }
23
21
  return config;
24
22
  }