@gravity-ui/app-builder 0.10.0 → 0.11.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/dist/cli.js +3 -5
- package/dist/commands/build/build-lib.js +23 -20
- package/dist/commands/build/build-service/client.js +1 -2
- package/dist/commands/build/build-service/index.js +1 -1
- package/dist/commands/build/build-service/server.js +23 -21
- package/dist/commands/build/index.js +1 -1
- package/dist/commands/dev/client.js +31 -33
- package/dist/commands/dev/index.js +3 -3
- package/dist/commands/dev/server.d.ts +1 -1
- package/dist/commands/dev/server.js +3 -4
- package/dist/common/babel/index.js +1 -2
- package/dist/common/child-process/controllable-script.d.ts +2 -4
- package/dist/common/child-process/controllable-script.js +4 -4
- package/dist/common/child-process/utils.js +1 -2
- package/dist/common/config.js +61 -36
- package/dist/common/library/babel-plugin-replace-paths.js +1 -0
- package/dist/common/library/index.js +1 -2
- package/dist/common/logger/colors.d.ts +2 -2
- package/dist/common/logger/index.d.ts +4 -6
- package/dist/common/logger/index.js +9 -6
- package/dist/common/logger/log-config.js +2 -2
- package/dist/common/logger/pretty-time.js +2 -3
- package/dist/common/models/index.d.ts +13 -18
- package/dist/common/models/index.js +3 -4
- package/dist/common/s3-upload/compress.js +2 -3
- package/dist/common/s3-upload/s3-client.d.ts +0 -1
- package/dist/common/s3-upload/s3-client.js +8 -14
- package/dist/common/s3-upload/upload.js +9 -6
- package/dist/common/typescript/compile.js +2 -3
- package/dist/common/typescript/diagnostic.js +1 -2
- package/dist/common/typescript/transformers.js +4 -3
- package/dist/common/typescript/utils.d.ts +4 -1
- package/dist/common/typescript/utils.js +31 -7
- package/dist/common/typescript/watch.js +2 -2
- package/dist/common/utils.d.ts +1 -1
- package/dist/common/utils.js +7 -8
- package/dist/common/webpack/compile.js +1 -2
- package/dist/common/webpack/config.d.ts +2 -7
- package/dist/common/webpack/config.js +15 -58
- package/dist/common/webpack/lazy-client.js +4 -4
- package/dist/common/webpack/progress-plugin.js +1 -0
- package/dist/common/webpack/storybook.js +2 -3
- package/dist/common/webpack/utils.js +3 -4
- package/dist/common/webpack/worker/web-worker.d.mts +1 -1
- package/dist/common/webpack/worker/web-worker.mjs +0 -1
- package/dist/common/webpack/worker/worker-loader.js +5 -1
- package/dist/create-cli.d.ts +2 -2
- package/dist/create-cli.js +17 -25
- package/package.json +67 -72
- package/dist/common/links/link.d.ts +0 -1
- package/dist/common/links/link.js +0 -132
- package/dist/common/links/unlink.d.ts +0 -3
- package/dist/common/links/unlink.js +0 -95
- package/dist/common/package.d.ts +0 -19
- package/dist/common/package.js +0 -65
- package/dist/common/tempData.d.ts +0 -13
- package/dist/common/tempData.js +0 -67
|
@@ -26,12 +26,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.webpackConfigFactory = webpackConfigFactory;
|
|
30
|
+
exports.configureModuleRules = configureModuleRules;
|
|
31
|
+
exports.configureResolve = configureResolve;
|
|
32
|
+
exports.configureOptimization = configureOptimization;
|
|
30
33
|
/* eslint-disable complexity */
|
|
31
34
|
const path = __importStar(require("node:path"));
|
|
32
35
|
const fs = __importStar(require("node:fs"));
|
|
33
36
|
const webpack = __importStar(require("webpack"));
|
|
34
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
35
37
|
const clean_webpack_plugin_1 = require("clean-webpack-plugin");
|
|
36
38
|
const webpack_manifest_plugin_1 = require("webpack-manifest-plugin");
|
|
37
39
|
const fork_ts_checker_webpack_plugin_1 = __importDefault(require("fork-ts-checker-webpack-plugin"));
|
|
@@ -43,25 +45,22 @@ const moment_timezone_data_webpack_plugin_1 = __importDefault(require("moment-ti
|
|
|
43
45
|
const webpack_plugin_1 = __importDefault(require("@statoscope/webpack-plugin"));
|
|
44
46
|
const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
|
|
45
47
|
const paths_1 = __importDefault(require("../paths"));
|
|
46
|
-
const tempData_1 = __importDefault(require("../tempData"));
|
|
47
48
|
const babel_1 = require("../babel");
|
|
48
49
|
const progress_plugin_1 = require("./progress-plugin");
|
|
49
50
|
const utils_1 = require("./utils");
|
|
50
51
|
const s3_upload_1 = require("../s3-upload");
|
|
51
52
|
const log_config_1 = require("../logger/log-config");
|
|
53
|
+
const utils_2 = require("../typescript/utils");
|
|
52
54
|
const imagesSizeLimit = 2048;
|
|
53
55
|
const fontSizeLimit = 8192;
|
|
54
56
|
async function webpackConfigFactory(webpackMode, config, { logger } = {}) {
|
|
55
57
|
const isEnvDevelopment = webpackMode === "development" /* WebpackMode.Dev */;
|
|
56
58
|
const isEnvProduction = webpackMode === "production" /* WebpackMode.Prod */;
|
|
57
|
-
const { updateIncludes, tsLinkedPackages } = updateIncludesFactory();
|
|
58
59
|
const helperOptions = {
|
|
59
60
|
config,
|
|
60
61
|
logger,
|
|
61
62
|
isEnvDevelopment,
|
|
62
63
|
isEnvProduction,
|
|
63
|
-
updateIncludes,
|
|
64
|
-
tsLinkedPackages,
|
|
65
64
|
configType: webpackMode,
|
|
66
65
|
};
|
|
67
66
|
let webpackConfig = {
|
|
@@ -99,7 +98,6 @@ async function webpackConfigFactory(webpackMode, config, { logger } = {}) {
|
|
|
99
98
|
}
|
|
100
99
|
return webpackConfig;
|
|
101
100
|
}
|
|
102
|
-
exports.webpackConfigFactory = webpackConfigFactory;
|
|
103
101
|
function configureModuleRules(helperOptions, additionalRules = []) {
|
|
104
102
|
const jsLoader = createJavaScriptLoader(helperOptions);
|
|
105
103
|
return [
|
|
@@ -119,36 +117,6 @@ function configureModuleRules(helperOptions, additionalRules = []) {
|
|
|
119
117
|
},
|
|
120
118
|
];
|
|
121
119
|
}
|
|
122
|
-
exports.configureModuleRules = configureModuleRules;
|
|
123
|
-
function updateIncludesFactory() {
|
|
124
|
-
const { linkedPackages } = tempData_1.default.getSettings();
|
|
125
|
-
const linkedPackagesArr = linkedPackages
|
|
126
|
-
? linkedPackages.keys.map((key) => linkedPackages.data[key])
|
|
127
|
-
: [];
|
|
128
|
-
if (linkedPackagesArr.length === 0) {
|
|
129
|
-
return {};
|
|
130
|
-
}
|
|
131
|
-
const tsLinkedPackages = linkedPackagesArr.filter(({ typescript }) => typescript);
|
|
132
|
-
const linkedPackagesJsIncludes = linkedPackagesArr.map((data) => `${data.package}/src`);
|
|
133
|
-
const linkedPackagesRootAssetsIncludes = linkedPackagesArr.map((data) => `${data.package}/assets`);
|
|
134
|
-
const linkedPackagesRootStylesIncludes = linkedPackagesArr.map((data) => `${data.package}/styles`);
|
|
135
|
-
return {
|
|
136
|
-
updateIncludes: (includes, options) => {
|
|
137
|
-
let result = includes.filter((pathname) => lodash_1.default.every(linkedPackagesArr, (linkedPackage) =>
|
|
138
|
-
// eslint-disable-next-line security/detect-non-literal-regexp
|
|
139
|
-
!new RegExp(linkedPackage.name).test(pathname)));
|
|
140
|
-
result = [...result, ...linkedPackagesJsIncludes];
|
|
141
|
-
if (options?.includeRootAssets) {
|
|
142
|
-
result = [...result, ...linkedPackagesRootAssetsIncludes];
|
|
143
|
-
}
|
|
144
|
-
if (options?.includeRootStyles) {
|
|
145
|
-
result = [...result, ...linkedPackagesRootStylesIncludes];
|
|
146
|
-
}
|
|
147
|
-
return result;
|
|
148
|
-
},
|
|
149
|
-
tsLinkedPackages,
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
120
|
function configureDevTool({ isEnvProduction, config }) {
|
|
153
121
|
let format = 'cheap-module-source-map';
|
|
154
122
|
if (isEnvProduction) {
|
|
@@ -197,7 +165,7 @@ function configureExperiments({ config, isEnvProduction, }) {
|
|
|
197
165
|
lazyCompilation,
|
|
198
166
|
};
|
|
199
167
|
}
|
|
200
|
-
function configureResolve({ isEnvProduction, config
|
|
168
|
+
function configureResolve({ isEnvProduction, config }) {
|
|
201
169
|
const alias = { ...config.alias };
|
|
202
170
|
for (const [key, value] of Object.entries(alias)) {
|
|
203
171
|
alias[key] = path.resolve(paths_1.default.app, value);
|
|
@@ -206,11 +174,6 @@ function configureResolve({ isEnvProduction, config, tsLinkedPackages, }) {
|
|
|
206
174
|
alias['react-dom$'] = 'react-dom/profiling';
|
|
207
175
|
alias['scheduler/tracing'] = 'scheduler/tracing-profiling';
|
|
208
176
|
}
|
|
209
|
-
if (tsLinkedPackages) {
|
|
210
|
-
tsLinkedPackages.forEach(({ name }) => {
|
|
211
|
-
alias[`${name}$`] = `${name}/src`;
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
177
|
const { aliases, modules = [] } = (0, utils_1.resolveTsconfigPathsToAlias)(path.resolve(paths_1.default.appClient, 'tsconfig.json')) || {};
|
|
215
178
|
return {
|
|
216
179
|
alias: {
|
|
@@ -223,7 +186,6 @@ function configureResolve({ isEnvProduction, config, tsLinkedPackages, }) {
|
|
|
223
186
|
fallback: config.fallback,
|
|
224
187
|
};
|
|
225
188
|
}
|
|
226
|
-
exports.configureResolve = configureResolve;
|
|
227
189
|
function createEntryArray(entry) {
|
|
228
190
|
return [require.resolve('./public-path'), entry];
|
|
229
191
|
}
|
|
@@ -297,14 +259,14 @@ function createJavaScriptLoader({ isEnvProduction, isEnvDevelopment, configType,
|
|
|
297
259
|
},
|
|
298
260
|
};
|
|
299
261
|
}
|
|
300
|
-
function createJavaScriptRule({
|
|
301
|
-
const include =
|
|
262
|
+
function createJavaScriptRule({ config, isEnvProduction }, jsLoader) {
|
|
263
|
+
const include = [
|
|
302
264
|
paths_1.default.appClient,
|
|
303
265
|
...(config.monaco && isEnvProduction
|
|
304
266
|
? [path.resolve(paths_1.default.appNodeModules, 'monaco-editor/esm/vs')]
|
|
305
267
|
: []),
|
|
306
268
|
...(config.includes || []),
|
|
307
|
-
]
|
|
269
|
+
];
|
|
308
270
|
return {
|
|
309
271
|
test: [/\.[jt]sx?$/, /\.[cm]js$/],
|
|
310
272
|
include,
|
|
@@ -456,12 +418,10 @@ function createIconsRule({ isEnvProduction, config }, jsLoader) {
|
|
|
456
418
|
}),
|
|
457
419
|
};
|
|
458
420
|
}
|
|
459
|
-
function createAssetsRules({
|
|
421
|
+
function createAssetsRules({ isEnvProduction, config }) {
|
|
460
422
|
const imagesRule = {
|
|
461
423
|
test: /\.(ico|bmp|gif|jpe?g|png|svg)$/,
|
|
462
|
-
include:
|
|
463
|
-
includeRootAssets: true,
|
|
464
|
-
}),
|
|
424
|
+
include: [paths_1.default.appClient, ...(config.images || [])],
|
|
465
425
|
type: 'asset',
|
|
466
426
|
parser: {
|
|
467
427
|
dataUrlCondition: {
|
|
@@ -492,9 +452,7 @@ function createAssetsRules({ updateIncludes = lodash_1.default.identity, isEnvPr
|
|
|
492
452
|
rules.unshift({
|
|
493
453
|
test: /\.(ico|bmp|gif|jpe?g|png|svg)$/,
|
|
494
454
|
issuer: /\.s?css$/,
|
|
495
|
-
include:
|
|
496
|
-
includeRootAssets: true,
|
|
497
|
-
}),
|
|
455
|
+
include: [paths_1.default.appClient, ...(config.images || [])],
|
|
498
456
|
type: 'asset',
|
|
499
457
|
parser: {
|
|
500
458
|
dataUrlCondition: {
|
|
@@ -623,11 +581,11 @@ function configurePlugins(options) {
|
|
|
623
581
|
}
|
|
624
582
|
plugins.push(new circular_dependency_plugin_1.default(circularPluginOptions));
|
|
625
583
|
}
|
|
626
|
-
if (
|
|
584
|
+
if (config.forkTsChecker !== false) {
|
|
627
585
|
plugins.push(new fork_ts_checker_webpack_plugin_1.default({
|
|
628
586
|
...config.forkTsChecker,
|
|
629
587
|
typescript: {
|
|
630
|
-
typescriptPath:
|
|
588
|
+
typescriptPath: (0, utils_2.resolveTypescript)(),
|
|
631
589
|
configFile: path.resolve(paths_1.default.app, 'src/ui/tsconfig.json'),
|
|
632
590
|
diagnosticOptions: {
|
|
633
591
|
syntactic: true,
|
|
@@ -647,7 +605,7 @@ function configurePlugins(options) {
|
|
|
647
605
|
ignoreOrder: true,
|
|
648
606
|
}));
|
|
649
607
|
if (config.sentryConfig) {
|
|
650
|
-
const sentryPlugin = require('@sentry/webpack-plugin');
|
|
608
|
+
const sentryPlugin = require('@sentry/webpack-plugin').sentryWebpackPlugin;
|
|
651
609
|
plugins.push(sentryPlugin({ ...config.sentryConfig }));
|
|
652
610
|
}
|
|
653
611
|
if (config.analyzeBundle === 'true') {
|
|
@@ -817,4 +775,3 @@ function configureOptimization({ config }) {
|
|
|
817
775
|
};
|
|
818
776
|
return optimization;
|
|
819
777
|
}
|
|
820
|
-
exports.configureOptimization = configureOptimization;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-env browser */
|
|
2
2
|
/* global __resourceQuery */
|
|
3
3
|
'use strict';
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
4
|
if (typeof EventSource !== 'function') {
|
|
6
5
|
throw new Error("Environment doesn't support lazy compilation (requires EventSource)");
|
|
7
6
|
}
|
|
@@ -45,18 +44,19 @@ exports.keepAlive = function (options) {
|
|
|
45
44
|
updateEventSource();
|
|
46
45
|
}
|
|
47
46
|
if (!active && !module.hot) {
|
|
47
|
+
// eslint-disable-next-line no-console
|
|
48
48
|
console.log('Hot Module Replacement is not enabled. Waiting for process restart...');
|
|
49
49
|
}
|
|
50
50
|
return function () {
|
|
51
51
|
errorHandlers.delete(onError);
|
|
52
52
|
setTimeout(function () {
|
|
53
|
-
const
|
|
54
|
-
if (
|
|
53
|
+
const valueToReduce = activeKeys.get(data);
|
|
54
|
+
if (valueToReduce === 1) {
|
|
55
55
|
activeKeys.delete(data);
|
|
56
56
|
updateEventSource();
|
|
57
57
|
}
|
|
58
58
|
else {
|
|
59
|
-
activeKeys.set(data,
|
|
59
|
+
activeKeys.set(data, valueToReduce - 1);
|
|
60
60
|
}
|
|
61
61
|
}, 1000);
|
|
62
62
|
};
|
|
@@ -61,5 +61,6 @@ class ProgressPlugin extends webpack.ProgressPlugin {
|
|
|
61
61
|
}
|
|
62
62
|
exports.ProgressPlugin = ProgressPlugin;
|
|
63
63
|
function hook(compiler, hookName, callback) {
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
65
|
compiler.hooks[hookName].tap(`app-builder: ${hookName}`, callback);
|
|
65
66
|
}
|
|
@@ -26,7 +26,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.
|
|
29
|
+
exports.configureServiceWebpackConfig = configureServiceWebpackConfig;
|
|
30
|
+
exports.configureWebpackConfigForStorybook = configureWebpackConfigForStorybook;
|
|
30
31
|
const path = __importStar(require("node:path"));
|
|
31
32
|
const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
32
33
|
const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
|
|
@@ -82,7 +83,6 @@ async function configureServiceWebpackConfig(mode, storybookConfig) {
|
|
|
82
83
|
},
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
|
-
exports.configureServiceWebpackConfig = configureServiceWebpackConfig;
|
|
86
86
|
async function configureWebpackConfigForStorybook(mode, userConfig = {}, storybookModuleRules = []) {
|
|
87
87
|
const isEnvDevelopment = mode === "development" /* WebpackMode.Dev */;
|
|
88
88
|
const isEnvProduction = mode === "production" /* WebpackMode.Prod */;
|
|
@@ -109,7 +109,6 @@ async function configureWebpackConfigForStorybook(mode, userConfig = {}, storybo
|
|
|
109
109
|
},
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
exports.configureWebpackConfigForStorybook = configureWebpackConfigForStorybook;
|
|
113
112
|
function configurePlugins({ isEnvDevelopment, isEnvProduction, config }) {
|
|
114
113
|
const plugins = [];
|
|
115
114
|
if (config.definitions) {
|
|
@@ -23,7 +23,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.
|
|
26
|
+
exports.webpackCompilerHandlerFactory = webpackCompilerHandlerFactory;
|
|
27
|
+
exports.resolveTsconfigPathsToAlias = resolveTsconfigPathsToAlias;
|
|
27
28
|
const path = __importStar(require("node:path"));
|
|
28
29
|
const fs = __importStar(require("node:fs"));
|
|
29
30
|
const pretty_time_1 = require("../logger/pretty-time");
|
|
@@ -51,14 +52,13 @@ function webpackCompilerHandlerFactory(logger, onCompilationEnd) {
|
|
|
51
52
|
}
|
|
52
53
|
if (stats) {
|
|
53
54
|
const time = stats.endTime - stats.startTime;
|
|
54
|
-
logger.success(`Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(
|
|
55
|
+
logger.success(`Client was successfully compiled in ${(0, pretty_time_1.prettyTime)(BigInt(time) * BigInt(1_000_000))}`);
|
|
55
56
|
}
|
|
56
57
|
else {
|
|
57
58
|
logger.success(`Client was successfully compiled`);
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
|
-
exports.webpackCompilerHandlerFactory = webpackCompilerHandlerFactory;
|
|
62
62
|
const endStarRe = /\/?\*$/;
|
|
63
63
|
function resolveTsconfigPathsToAlias(tsConfigPath) {
|
|
64
64
|
if (!fs.existsSync(tsConfigPath) || !fs.statSync(tsConfigPath).isFile) {
|
|
@@ -84,7 +84,6 @@ function resolveTsconfigPathsToAlias(tsConfigPath) {
|
|
|
84
84
|
}
|
|
85
85
|
return { aliases, modules };
|
|
86
86
|
}
|
|
87
|
-
exports.resolveTsconfigPathsToAlias = resolveTsconfigPathsToAlias;
|
|
88
87
|
function readJsonConfig(pathname) {
|
|
89
88
|
try {
|
|
90
89
|
const json = fs.readFileSync(pathname, 'utf-8');
|
|
@@ -3,6 +3,6 @@ declare class WebWorker extends Worker {
|
|
|
3
3
|
constructor(url: string | URL, options?: WorkerOptions);
|
|
4
4
|
}
|
|
5
5
|
declare class SharedWebWorker extends SharedWorkerPolyfill {
|
|
6
|
-
constructor(url: string | URL, options?:
|
|
6
|
+
constructor(url: string | URL, options?: WorkerOptions);
|
|
7
7
|
}
|
|
8
8
|
export { WebWorker as Worker, SharedWebWorker as SharedWorker };
|
|
@@ -93,7 +93,11 @@ const pitch = function (request) {
|
|
|
93
93
|
}
|
|
94
94
|
const cache = workerCompiler.getCache(pluginId);
|
|
95
95
|
const cacheIdent = request;
|
|
96
|
-
const
|
|
96
|
+
const objectToHash = compilation.assets[filename];
|
|
97
|
+
if (!objectToHash) {
|
|
98
|
+
throw new Error(`Asset ${filename} not found in compilation`);
|
|
99
|
+
}
|
|
100
|
+
const cacheETag = cache.getLazyHashedEtag(objectToHash);
|
|
97
101
|
return cache.get(cacheIdent, cacheETag, (getCacheError, cacheContent) => {
|
|
98
102
|
if (getCacheError) {
|
|
99
103
|
return cb(getCacheError);
|
package/dist/create-cli.d.ts
CHANGED
|
@@ -2,11 +2,11 @@ export type CliArgs = Awaited<ReturnType<typeof createCli>>;
|
|
|
2
2
|
export declare function createCli(argv: string[]): {
|
|
3
3
|
[x: string]: unknown;
|
|
4
4
|
verbose: boolean | undefined;
|
|
5
|
-
c: unknown;
|
|
6
5
|
cdn: string | undefined;
|
|
7
6
|
env: string[] | undefined;
|
|
8
7
|
target: "client" | "server" | undefined;
|
|
9
8
|
inspect: number | undefined;
|
|
9
|
+
c: unknown;
|
|
10
10
|
inspectBrk: number | undefined;
|
|
11
11
|
"inspect-brk": number | undefined;
|
|
12
12
|
entryFilter: string[] | undefined;
|
|
@@ -30,11 +30,11 @@ export declare function createCli(argv: string[]): {
|
|
|
30
30
|
} | Promise<{
|
|
31
31
|
[x: string]: unknown;
|
|
32
32
|
verbose: boolean | undefined;
|
|
33
|
-
c: unknown;
|
|
34
33
|
cdn: string | undefined;
|
|
35
34
|
env: string[] | undefined;
|
|
36
35
|
target: "client" | "server" | undefined;
|
|
37
36
|
inspect: number | undefined;
|
|
37
|
+
c: unknown;
|
|
38
38
|
inspectBrk: number | undefined;
|
|
39
39
|
"inspect-brk": number | undefined;
|
|
40
40
|
entryFilter: string[] | undefined;
|
package/dist/create-cli.js
CHANGED
|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.createCli =
|
|
29
|
+
exports.createCli = createCli;
|
|
30
30
|
const yargs_1 = __importDefault(require("yargs"));
|
|
31
31
|
const helpers_1 = require("yargs/helpers");
|
|
32
32
|
const path = __importStar(require("node:path"));
|
|
@@ -34,7 +34,7 @@ const logger_1 = __importDefault(require("./common/logger"));
|
|
|
34
34
|
const config_1 = require("./common/config");
|
|
35
35
|
const models_1 = require("./common/models");
|
|
36
36
|
function createCli(argv) {
|
|
37
|
-
const cli = (0, yargs_1.default)(
|
|
37
|
+
const cli = (0, yargs_1.default)().parserConfiguration({
|
|
38
38
|
'boolean-negation': false,
|
|
39
39
|
});
|
|
40
40
|
cli.scriptName('app-builder')
|
|
@@ -59,38 +59,39 @@ function createCli(argv) {
|
|
|
59
59
|
describe: 'Configuration file to use',
|
|
60
60
|
})
|
|
61
61
|
.option('env', {
|
|
62
|
-
describe: 'Environment passed to the configuration when it is a function.',
|
|
62
|
+
describe: 'Environment passed to the configuration when it is a function. Ex. --env foo.bar=1 --env foo.baz=2 ',
|
|
63
63
|
type: 'array',
|
|
64
64
|
string: true,
|
|
65
65
|
coerce: (args) => {
|
|
66
66
|
if (!args) {
|
|
67
67
|
return {};
|
|
68
68
|
}
|
|
69
|
+
// [foo.bar=1, foo.baz, bar=2, baz=] => {foo: {bar: 1, baz: true}, bar: 2, baz: undefined}
|
|
69
70
|
return args.reduce((values, value) => {
|
|
70
|
-
if (value.endsWith('=')) {
|
|
71
|
-
value = value.concat('""');
|
|
72
|
-
}
|
|
73
71
|
// This ensures we're only splitting by the first `=`
|
|
74
72
|
const [allKeys, val] = value.split(/[=](.+)/, 2);
|
|
75
73
|
if (typeof allKeys === 'string') {
|
|
76
74
|
const splitKeys = allKeys.split(/\.(?!$)/);
|
|
77
75
|
let prevRef = values;
|
|
78
76
|
splitKeys.forEach((someKey, index) => {
|
|
79
|
-
if (!prevRef[someKey]) {
|
|
80
|
-
prevRef[someKey] = {};
|
|
81
|
-
}
|
|
82
|
-
if (typeof prevRef[someKey] === 'string') {
|
|
83
|
-
prevRef[someKey] = {};
|
|
84
|
-
}
|
|
85
77
|
if (index === splitKeys.length - 1) {
|
|
86
78
|
if (typeof val === 'string') {
|
|
87
79
|
prevRef[someKey] = val;
|
|
88
80
|
}
|
|
81
|
+
else if (someKey.endsWith('=')) {
|
|
82
|
+
prevRef[someKey.slice(0, -1)] = undefined;
|
|
83
|
+
}
|
|
89
84
|
else {
|
|
90
85
|
prevRef[someKey] = true;
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
|
-
|
|
88
|
+
else {
|
|
89
|
+
let nextRef = prevRef[someKey];
|
|
90
|
+
if (!nextRef || typeof nextRef !== 'object') {
|
|
91
|
+
nextRef = prevRef[someKey] = {};
|
|
92
|
+
}
|
|
93
|
+
prevRef = nextRef;
|
|
94
|
+
}
|
|
94
95
|
});
|
|
95
96
|
}
|
|
96
97
|
return values;
|
|
@@ -108,13 +109,13 @@ function createCli(argv) {
|
|
|
108
109
|
group: 'Server',
|
|
109
110
|
type: 'number',
|
|
110
111
|
describe: 'Opens a port for debugging',
|
|
111
|
-
coerce: (arg) => (arg === undefined ?
|
|
112
|
+
coerce: (arg) => (arg === undefined ? true : arg),
|
|
112
113
|
})
|
|
113
114
|
.option('inspect-brk', {
|
|
114
115
|
group: 'Server',
|
|
115
116
|
type: 'number',
|
|
116
117
|
describe: 'Opens a port for debugging. Will block until debugger is attached',
|
|
117
|
-
coerce: (arg) => (arg === undefined ?
|
|
118
|
+
coerce: (arg) => (arg === undefined ? true : arg),
|
|
118
119
|
})
|
|
119
120
|
.option('entry-filter', {
|
|
120
121
|
group: 'Client',
|
|
@@ -147,14 +148,6 @@ function createCli(argv) {
|
|
|
147
148
|
throw new Error('dev command can be used only for services, but got the library config');
|
|
148
149
|
}
|
|
149
150
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
150
|
-
if (args.server) {
|
|
151
|
-
if (args.server.inspect !== undefined) {
|
|
152
|
-
args.server.inspect = args.server.inspect || 9229;
|
|
153
|
-
}
|
|
154
|
-
if (args.server.inspectBrk !== undefined) {
|
|
155
|
-
args.server.inspectBrk = args.server.inspectBrk || 9229;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
151
|
cmd(args);
|
|
159
152
|
// Return an empty promise to prevent handlerP from exiting early.
|
|
160
153
|
// The development server shouldn't ever exit until the user directly
|
|
@@ -213,7 +206,6 @@ function createCli(argv) {
|
|
|
213
206
|
.recommendCommands()
|
|
214
207
|
.parse((0, helpers_1.hideBin)(argv));
|
|
215
208
|
}
|
|
216
|
-
exports.createCli = createCli;
|
|
217
209
|
function getVersionInfo() {
|
|
218
210
|
const { version } = require('../package.json');
|
|
219
211
|
return `app-builder CLI version: ${version}`;
|
|
@@ -244,7 +236,7 @@ function resolveLocalCommand(command) {
|
|
|
244
236
|
if (cmd.__esModule) {
|
|
245
237
|
cmd = cmd.default;
|
|
246
238
|
}
|
|
247
|
-
if (cmd
|
|
239
|
+
if (typeof cmd === 'function') {
|
|
248
240
|
return cmd;
|
|
249
241
|
}
|
|
250
242
|
return logger_1.default.panic(`Handler for command "${command}" is not a function.`);
|