arui-scripts 15.3.0 → 15.4.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.
- package/.turbo/turbo-build.log +0 -0
- package/.turbo/turbo-test.log +91 -0
- package/CHANGELOG.md +278 -656
- package/README.md +31 -2
- package/bin/build.sh +2 -1
- package/build/commands/build/build-wrapper.d.ts +2 -2
- package/build/commands/build/client.js +3 -3
- package/build/commands/bundle-analyze/index.js +15 -15
- package/build/commands/changelog/index.js +2 -2
- package/build/commands/util/make-tmp-dir.d.ts +1 -1
- package/build/commands/util/make-tmp-dir.js +2 -2
- package/build/commands/util/run-client-dev-server.d.ts +1 -1
- package/build/commands/util/run-client-dev-server.js +1 -4
- package/build/configs/app-configs/calculate-dependent-config.d.ts +54 -8
- package/build/configs/app-configs/calculate-dependent-config.js +11 -13
- package/build/configs/app-configs/get-defaults.d.ts +3 -2
- package/build/configs/app-configs/get-defaults.js +75 -55
- package/build/configs/app-configs/index.d.ts +5 -3
- package/build/configs/app-configs/index.js +13 -7
- package/build/configs/app-configs/types.d.ts +51 -38
- package/build/configs/app-configs/update-with-config-file.d.ts +2 -2
- package/build/configs/app-configs/update-with-config-file.js +5 -7
- package/build/configs/app-configs/update-with-env.js +3 -8
- package/build/configs/app-configs/update-with-package.d.ts +2 -2
- package/build/configs/app-configs/update-with-package.js +5 -10
- package/build/configs/app-configs/update-with-presets.d.ts +2 -2
- package/build/configs/app-configs/update-with-presets.js +8 -15
- package/build/configs/app-configs/validate-settings-keys.d.ts +2 -5
- package/build/configs/app-configs/validate-settings-keys.js +6 -7
- package/build/configs/babel-client.d.ts +33 -1
- package/build/configs/babel-dependencies.d.ts +14 -1
- package/build/configs/babel-server.d.ts +26 -1
- package/build/configs/dev-server.d.ts +15 -1
- package/build/configs/jest/index.d.ts +33 -1
- package/build/configs/postcss.config.d.ts +1 -1
- package/build/configs/postcss.d.ts +1 -1
- package/build/configs/process-assets-plugin-output.d.ts +2 -0
- package/build/configs/process-assets-plugin-output.js +32 -0
- package/build/configs/server-externals-exemptions.d.ts +1 -1
- package/build/configs/util/apply-overrides.d.ts +23 -7
- package/build/configs/util/apply-overrides.js +3 -2
- package/build/configs/util/get-entry.d.ts +2 -1
- package/build/configs/webpack.client.d.ts +10 -2
- package/build/configs/webpack.client.dev.js +1 -1
- package/build/configs/webpack.client.js +51 -37
- package/build/configs/webpack.client.prod.js +1 -1
- package/build/index.d.ts +1 -1
- package/build/tsconfig-local.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/build/configs/app-configs/available-package-settings.d.ts +0 -8
- package/build/configs/app-configs/available-package-settings.js +0 -34
package/README.md
CHANGED
|
@@ -80,7 +80,10 @@ npm install arui-scripts --save-dev
|
|
|
80
80
|
- `keepCssVars` - отключает `postcss-custom-properties`, css переменные будут оставаться в бандле.
|
|
81
81
|
- `removeDevDependenciesDuringDockerBuild` - отключает удаление devDependencies из node_modules при сборке докер образа. Используется когда вам не нужно удалять devDependencies, т.к. в своём Dockerfile вы не переносите node_modules в докер-контейнер.
|
|
82
82
|
- `dataUrlMaxSize` - ресурсы, не превышающие данный размер (в байтах), будут включены в исходники `inline`, иначе вынесены в отдельный файл. По умолчанию `1536`.
|
|
83
|
-
- `imageMinimizer` - раздел настроек, связанных с оптимизацией
|
|
83
|
+
- `imageMinimizer` - раздел настроек, связанных с оптимизацией графики.<br/><br/>
|
|
84
|
+
:warning: **Внимание!** Если вы планируете использовать любые `imagemin`-плагины, кроме `svgo`, необходимо установить их дополнительно. <br/>
|
|
85
|
+
Так как после установки плагинам необходим прямой доступ в сеть для скачивания утилит (`cjpeg` и пр.), они указаны в `peerDependencies` `arui-scripts`, чтобы не приводить к ошибкам в закрытых контурах.<br/><br/>
|
|
86
|
+
|
|
84
87
|
- `imageMinimizer.svg.enabled` - включает/отключает оптимизацию `svg`. По умолчанию `true`.
|
|
85
88
|
- `imageMinimizer.gif.enabled` - включает/отключает оптимизацию `gif`. По умолчанию `false`.
|
|
86
89
|
- `imageMinimizer.gif.optimizationLevel` - уровень сжатия `gif`. От `1` до `3`. По умолчанию `1`.
|
|
@@ -590,7 +593,7 @@ export default overrides;
|
|
|
590
593
|
const { files } = postcssPluginsOptions['@csstools/postcss-global-data'];
|
|
591
594
|
const newOption = {
|
|
592
595
|
...postcssPluginsOptions,
|
|
593
|
-
'@csstools/postcss-global-data': {
|
|
596
|
+
'@csstools/postcss-global-data': {
|
|
594
597
|
files:files.concat(['./vars.css'])
|
|
595
598
|
}
|
|
596
599
|
};
|
|
@@ -621,6 +624,32 @@ export default overrides;
|
|
|
621
624
|
|
|
622
625
|
Для некоторых конфигураций определены несколько ключей, они будут применяться в том порядке, в котором они приведены в этом файле.
|
|
623
626
|
|
|
627
|
+
### Создание дополнительных конфигураций для webpack
|
|
628
|
+
На некоторых проектах может потребоваться создать дополнительные конфигурации для webpack. Например, для создания
|
|
629
|
+
service worker'а (или любых других кейсов). Для этого можно использовать функцию-хелпер `createSingleWebpackConfig`:
|
|
630
|
+
|
|
631
|
+
```ts
|
|
632
|
+
import type { OverrideFile } from 'arui-scripts';
|
|
633
|
+
|
|
634
|
+
const overrides: OverrideFile = {
|
|
635
|
+
webpackClient: (config, appConfig, { createSingleClientWebpackConfig }) => {
|
|
636
|
+
return [
|
|
637
|
+
config,
|
|
638
|
+
createSingleClientWebpackConfig(
|
|
639
|
+
'./src/sw.js', // entrypoint, может быть массивом/объектом
|
|
640
|
+
'sw', // наименование сборки, влияет на имена чанков
|
|
641
|
+
),
|
|
642
|
+
];
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
export default overrides;
|
|
647
|
+
```
|
|
648
|
+
Эта функция вернет независимую конфигурацию для webpack, которую можно использовать в качестве оверрайда. Вы так же можете ее модифицировать,
|
|
649
|
+
не боясь что это повлияет на другие конфигурации.
|
|
650
|
+
|
|
651
|
+
Созданная таким образом конфигурация будет шарить с оригинальной конфигурацией только плагин для формирования assets-manifest'а.
|
|
652
|
+
|
|
624
653
|
Пресеты
|
|
625
654
|
===
|
|
626
655
|
|
package/bin/build.sh
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
|
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 } =
|
|
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* () {
|
|
@@ -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(
|
|
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):
|
|
6
|
-
publicPath: string;
|
|
7
|
-
serverOutputPath: string;
|
|
8
|
-
clientOutputPath: string;
|
|
5
|
+
export declare function calculateDependentConfig(config: AppConfigs): {
|
|
9
6
|
clientPolyfillsEntry: string[];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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)(
|
|
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 (
|
|
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.
|
|
37
|
+
exports.calculateDependentContext = calculateDependentContext;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { AppConfigs } from './types';
|
|
2
|
-
export declare function
|
|
1
|
+
import { AppConfigs, AppContext } from './types';
|
|
2
|
+
export declare function getDefaultAppConfig(): AppConfigs;
|
|
3
|
+
export declare function getDefaultAppContext(): AppContext;
|
|
@@ -3,17 +3,83 @@ 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.
|
|
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
|
-
|
|
11
|
-
|
|
10
|
+
const CWD = process.cwd();
|
|
11
|
+
const absoluteSrcPath = path_1.default.resolve(CWD, 'src');
|
|
12
|
+
function getDefaultAppConfig() {
|
|
13
|
+
var _a;
|
|
14
|
+
const appPackage = getPackageJson();
|
|
15
|
+
return {
|
|
16
|
+
/// general settings
|
|
17
|
+
clientServerPort: 8080,
|
|
18
|
+
serverPort: 3000,
|
|
19
|
+
debug: false,
|
|
20
|
+
devSourceMaps: 'eval',
|
|
21
|
+
devServerCors: false,
|
|
22
|
+
useServerHMR: false,
|
|
23
|
+
presets: ((_a = appPackage.aruiScripts) === null || _a === void 0 ? void 0 : _a.presets) || null,
|
|
24
|
+
// paths
|
|
25
|
+
buildPath: '.build',
|
|
26
|
+
assetsPath: 'assets',
|
|
27
|
+
additionalBuildPath: ['config'],
|
|
28
|
+
statsOutputFilename: 'stats.json',
|
|
29
|
+
serverEntry: path_1.default.resolve(absoluteSrcPath, 'server/index'),
|
|
30
|
+
serverOutput: 'server.js',
|
|
31
|
+
clientPolyfillsEntry: null,
|
|
32
|
+
clientEntry: path_1.default.resolve(absoluteSrcPath, 'index'),
|
|
33
|
+
// docker compilation configs
|
|
34
|
+
dockerRegistry: '',
|
|
35
|
+
baseDockerImage: 'alfabankui/arui-scripts:latest',
|
|
36
|
+
nginxRootPath: '/src',
|
|
37
|
+
runFromNonRootUser: true,
|
|
38
|
+
removeDevDependenciesDuringDockerBuild: true,
|
|
39
|
+
// archive compilation configs
|
|
40
|
+
archiveName: 'build.tar',
|
|
41
|
+
// build tuning
|
|
42
|
+
keepPropTypes: false,
|
|
43
|
+
useTscLoader: false,
|
|
44
|
+
webpack4Compatibility: false,
|
|
45
|
+
installServerSourceMaps: false,
|
|
46
|
+
// image processing
|
|
47
|
+
dataUrlMaxSize: 1536,
|
|
48
|
+
imageMinimizer: {
|
|
49
|
+
svg: {
|
|
50
|
+
enabled: true,
|
|
51
|
+
},
|
|
52
|
+
gif: {
|
|
53
|
+
enabled: false,
|
|
54
|
+
optimizationLevel: 1,
|
|
55
|
+
},
|
|
56
|
+
jpg: {
|
|
57
|
+
enabled: false,
|
|
58
|
+
quality: 75,
|
|
59
|
+
},
|
|
60
|
+
png: {
|
|
61
|
+
enabled: false,
|
|
62
|
+
optimizationLevel: 3,
|
|
63
|
+
bitDepthReduction: false,
|
|
64
|
+
colorTypeReduction: false,
|
|
65
|
+
paletteReduction: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
// CSS
|
|
69
|
+
componentsTheme: null,
|
|
70
|
+
keepCssVars: false,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
exports.getDefaultAppConfig = getDefaultAppConfig;
|
|
74
|
+
function getPackageJson() {
|
|
12
75
|
const appPackage = JSON.parse(fs_1.default.readFileSync(path_1.default.join(CWD, 'package.json'), 'utf8'));
|
|
13
76
|
if (appPackage['arui-scripts']) {
|
|
14
77
|
throw Error('arui-scripts in package.json is not supported. Use aruiScripts instead.');
|
|
15
78
|
}
|
|
16
|
-
|
|
79
|
+
return appPackage;
|
|
80
|
+
}
|
|
81
|
+
function getDefaultAppContext() {
|
|
82
|
+
const appPackage = getPackageJson();
|
|
17
83
|
const absoluteNodeModulesPath = path_1.default.resolve(CWD, 'node_modules');
|
|
18
84
|
const absoluteNodeModulesBinPath = path_1.default.resolve(absoluteNodeModulesPath, '.bin');
|
|
19
85
|
const projectTsConfigPath = path_1.default.join(CWD, 'tsconfig.json');
|
|
@@ -25,47 +91,22 @@ function getDefaults() {
|
|
|
25
91
|
return {
|
|
26
92
|
appPackage,
|
|
27
93
|
name: appPackage.name,
|
|
94
|
+
normalizedName: appPackage.name.replace(/-/g, '_'),
|
|
28
95
|
version: appPackage.version,
|
|
29
|
-
dockerRegistry: '',
|
|
30
|
-
baseDockerImage: 'alfabankui/arui-scripts:latest',
|
|
31
96
|
// general paths
|
|
32
97
|
cwd: CWD,
|
|
33
98
|
appSrc: absoluteSrcPath,
|
|
34
99
|
appNodeModules: absoluteNodeModulesPath,
|
|
35
100
|
appNodeModulesBin: absoluteNodeModulesBinPath,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
additionalBuildPath: ['config'],
|
|
39
|
-
nginxRootPath: '/src',
|
|
40
|
-
runFromNonRootUser: true,
|
|
41
|
-
archiveName: 'build.tar',
|
|
101
|
+
overridesPath: overridesPath ? [overridesPath] : [],
|
|
102
|
+
// tools availability
|
|
42
103
|
babelRuntimeVersion: '7.0.0-beta.0',
|
|
43
|
-
|
|
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,
|
|
104
|
+
useYarn: fs_1.default.existsSync(yarnLockFilePath),
|
|
50
105
|
// compilation configs locations
|
|
51
106
|
tsconfig: fs_1.default.existsSync(projectTsConfigPath) ? projectTsConfigPath : null,
|
|
52
107
|
localNginxConf: fs_1.default.existsSync(nginxConfFilePath) ? nginxConfFilePath : null,
|
|
53
108
|
localDockerfile: fs_1.default.existsSync(dockerfileFilePath) ? dockerfileFilePath : null,
|
|
54
109
|
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
110
|
// Эти пути зависят от других настроек, которые могут быть переопределены пользователем
|
|
70
111
|
publicPath: '',
|
|
71
112
|
serverOutputPath: '',
|
|
@@ -78,27 +119,6 @@ function getDefaults() {
|
|
|
78
119
|
changelogFeaturesPath: path_1.default.resolve(CWD, './changelog_features.tmp'),
|
|
79
120
|
changelogBugfixesPath: path_1.default.resolve(CWD, './changelog_bugfixes.tmp'),
|
|
80
121
|
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
122
|
};
|
|
103
123
|
}
|
|
104
|
-
exports.
|
|
124
|
+
exports.getDefaultAppContext = getDefaultAppContext;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import '../util/register-ts-node';
|
|
2
|
-
import { AppConfigs } from './types';
|
|
3
|
-
declare
|
|
4
|
-
export
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
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):
|
|
1
|
+
import { AppConfigs, AppContext } from './types';
|
|
2
|
+
export declare function updateWithConfigFile(config: AppConfigs, context: AppContext): any;
|