UNPKG

1.85 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const enquirer_1 = require("enquirer");
4const deepMerge = require("deepmerge");
5const util_1 = require("@kano/kit-app-shell-core/lib/util");
6const rc_1 = require("@kano/kit-app-shell-core/lib/rc");
7const process_state_1 = require("@kano/kit-app-shell-core/lib/process-state");
8const chalk_1 = require("chalk");
9function configure(platformId) {
10 process_state_1.processState.setInfo(`Configuring options for platform ${chalk_1.default.green(platformId)}`);
11 return util_1.util.platform.loadPlatformKey(platformId, 'configure')
12 .then((platformConfigure) => {
13 return rc_1.RcLoader.loadHomeRc()
14 .then((cfg) => {
15 if (typeof platformConfigure.enquire !== 'function') {
16 process_state_1.processState.setInfo(`Platform '${platformId}' does not require any configuration`);
17 return null;
18 }
19 return platformConfigure.enquire(enquirer_1.prompt, cfg[platformId] || {})
20 .then((answers) => {
21 if (typeof platformConfigure.generate !== 'function') {
22 return answers;
23 }
24 return platformConfigure.generate(answers);
25 })
26 .then((answers) => {
27 const scopedAnswers = {
28 [platformId]: answers || {},
29 };
30 return deepMerge(cfg, scopedAnswers);
31 })
32 .then((updatedCfg) => rc_1.RcLoader.saveHomeRc(updatedCfg))
33 .then(() => {
34 process_state_1.processState.setSuccess(`Your local config has been updated. Use ${chalk_1.default.cyan('kash open config')} to see it`);
35 });
36 });
37 });
38}
39exports.default = configure;
40//# sourceMappingURL=configure.js.map
\No newline at end of file