UNPKG

1.66 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const config_1 = require("@kano/kit-app-shell-core/lib/config");
4const rc_1 = require("@kano/kit-app-shell-core/lib/rc");
5const deepMerge = require("deepmerge");
6function deleteCommandKeys(obj) {
7 [
8 'build',
9 'run',
10 'test',
11 ].forEach((key) => {
12 delete obj[key];
13 });
14}
15function agregateArgv(argv, platformId, command) {
16 return rc_1.RcLoader.load(argv.app)
17 .then((rcOpts) => {
18 const rcPlatformOpts = rcOpts[platformId] || {};
19 delete rcOpts[platformId];
20 const rcPlatformCommandOpts = rcPlatformOpts[command] || {};
21 deleteCommandKeys(rcPlatformOpts);
22 const rcCommandOpts = rcOpts[command] || {};
23 deleteCommandKeys(rcOpts);
24 const allOpts = [
25 rcOpts,
26 rcCommandOpts,
27 rcPlatformOpts,
28 rcPlatformCommandOpts,
29 argv,
30 ];
31 Object.keys(argv).forEach((key) => {
32 if (typeof argv[key] === 'undefined' || argv[key] === null) {
33 delete argv[key];
34 }
35 });
36 const opts = allOpts.reduce((acc, item) => deepMerge(acc, item), {});
37 return opts;
38 });
39}
40exports.agregateArgv = agregateArgv;
41function addConfig(opts) {
42 const config = config_1.ConfigLoader.load(opts.app, opts.env, opts['override-app-config'], opts['require-config']);
43 config.BUILD_NUMBER = process.env.BUILD_NUMBER ? parseInt(process.env.BUILD_NUMBER, 10) : opts.buildNumber;
44 opts.config = config;
45 return opts;
46}
47exports.addConfig = addConfig;
48//# sourceMappingURL=argv.js.map
\No newline at end of file