1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const config_1 = require("@kano/kit-app-shell-core/lib/config");
|
4 | const rc_1 = require("@kano/kit-app-shell-core/lib/rc");
|
5 | const deepMerge = require("deepmerge");
|
6 | function deleteCommandKeys(obj) {
|
7 | [
|
8 | 'build',
|
9 | 'run',
|
10 | 'test',
|
11 | ].forEach((key) => {
|
12 | delete obj[key];
|
13 | });
|
14 | }
|
15 | function 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 | }
|
40 | exports.agregateArgv = agregateArgv;
|
41 | function 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 | }
|
47 | exports.addConfig = addConfig;
|
48 |
|
\ | No newline at end of file |