@cloudbase/cli 2.7.0-alpha.3 → 2.7.0-alpha.5
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/lib/commands/iac/index.js +61 -68
- package/lib/commands/lowcode/app.js +4 -0
- package/package.json +3 -3
|
@@ -29,13 +29,12 @@ const cals_1 = require("@cloudbase/cals");
|
|
|
29
29
|
const iac_core_1 = require("@cloudbase/iac-core");
|
|
30
30
|
const type_1 = require("@cloudbase/iac-core/lib/src/type");
|
|
31
31
|
const inquirer_1 = __importDefault(require("inquirer"));
|
|
32
|
-
const lodash_1 = require("lodash");
|
|
33
32
|
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
34
|
const path_1 = __importDefault(require("path"));
|
|
35
35
|
const decorators_1 = require("../../decorators");
|
|
36
36
|
const utils_1 = require("../../utils");
|
|
37
37
|
const common_1 = require("../common");
|
|
38
|
-
const fs_extra_1 = require("fs-extra");
|
|
39
38
|
inquirer_1.default.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
|
|
40
39
|
let IaCInitRepo = class IaCInitRepo extends common_1.Command {
|
|
41
40
|
get options() {
|
|
@@ -181,7 +180,6 @@ let IaCInit = class IaCInit extends common_1.Command {
|
|
|
181
180
|
resource,
|
|
182
181
|
action: type_1.ResourceAction.Init,
|
|
183
182
|
log,
|
|
184
|
-
needEnvId: false,
|
|
185
183
|
specResourceLogic: function (resource, config) {
|
|
186
184
|
return __awaiter(this, void 0, void 0, function* () {
|
|
187
185
|
switch (resource) {
|
|
@@ -263,6 +261,13 @@ let IaCInit = class IaCInit extends common_1.Command {
|
|
|
263
261
|
choices: iac_core_1.IAC.WebApp.getAvailableTemplates()
|
|
264
262
|
});
|
|
265
263
|
Object.assign(config, templateRes);
|
|
264
|
+
const nameRes = yield inquirer_1.default.prompt({
|
|
265
|
+
type: 'input',
|
|
266
|
+
name: 'name',
|
|
267
|
+
message: '应用名称',
|
|
268
|
+
default: config.name
|
|
269
|
+
});
|
|
270
|
+
Object.assign(config, nameRes);
|
|
266
271
|
}
|
|
267
272
|
}
|
|
268
273
|
});
|
|
@@ -311,8 +316,7 @@ let IaCPull = class IaCPull extends common_1.Command {
|
|
|
311
316
|
resource,
|
|
312
317
|
action: type_1.ResourceAction.Pull,
|
|
313
318
|
envId,
|
|
314
|
-
log
|
|
315
|
-
needEnvId: true
|
|
319
|
+
log
|
|
316
320
|
}));
|
|
317
321
|
});
|
|
318
322
|
}
|
|
@@ -350,8 +354,7 @@ let IaCBuild = class IaCBuild extends common_1.Command {
|
|
|
350
354
|
name,
|
|
351
355
|
action: type_1.ResourceAction.Build,
|
|
352
356
|
resource,
|
|
353
|
-
log
|
|
354
|
-
needEnvId: false
|
|
357
|
+
log
|
|
355
358
|
}));
|
|
356
359
|
});
|
|
357
360
|
}
|
|
@@ -376,22 +379,6 @@ let IaCDev = class IaCDev extends common_1.Command {
|
|
|
376
379
|
return getOptions({
|
|
377
380
|
childCmd: 'dev',
|
|
378
381
|
options: [
|
|
379
|
-
{
|
|
380
|
-
flags: '--data <data>',
|
|
381
|
-
desc: '要传递给调用函数的序列化 Event 数据(仅当 resource=SCF 时有效)'
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
flags: '--dataPath <dataPath>',
|
|
385
|
-
desc: '要传递给调用函数 Event 的 json 文件所在路径(仅当 resource=SCF 时有效)'
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
flags: '--context <context>',
|
|
389
|
-
desc: '要传递给调用函数的序列化 Context 数据(仅当 resource=SCF 时有效)'
|
|
390
|
-
},
|
|
391
|
-
{
|
|
392
|
-
flags: '--contextPath <contextPath>',
|
|
393
|
-
desc: '要传递给调用函数 Context 的 json 文件所在路径(仅当 resource=SCF 时有效)'
|
|
394
|
-
},
|
|
395
382
|
{
|
|
396
383
|
flags: '--platform <platform>',
|
|
397
384
|
desc: '运行平台,可选为 web | mp。默认为 web(仅当 resource=App 时有效)'
|
|
@@ -412,13 +399,12 @@ let IaCDev = class IaCDev extends common_1.Command {
|
|
|
412
399
|
return getCredential(ctx, options);
|
|
413
400
|
}
|
|
414
401
|
});
|
|
415
|
-
yield iac_core_1.IAC.resource.dev(getAPIParams({
|
|
402
|
+
const devInst = yield iac_core_1.IAC.resource.dev(getAPIParams({
|
|
416
403
|
cwd,
|
|
417
404
|
name,
|
|
418
405
|
resource,
|
|
419
406
|
action: type_1.ResourceAction.Dev,
|
|
420
407
|
log,
|
|
421
|
-
needEnvId: false,
|
|
422
408
|
extraData: { data, dataPath, context, contextPath, platform },
|
|
423
409
|
specResourceLogic(resource, config) {
|
|
424
410
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -436,6 +422,17 @@ let IaCDev = class IaCDev extends common_1.Command {
|
|
|
436
422
|
});
|
|
437
423
|
}
|
|
438
424
|
}));
|
|
425
|
+
try {
|
|
426
|
+
if (Array.isArray(devInst)) {
|
|
427
|
+
yield Promise.all(devInst.map((item) => item === null || item === void 0 ? void 0 : item.run));
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
yield (devInst === null || devInst === void 0 ? void 0 : devInst.run);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
catch (e) {
|
|
434
|
+
trackCallback({ type: 'error', details: e.message }, log);
|
|
435
|
+
}
|
|
439
436
|
});
|
|
440
437
|
}
|
|
441
438
|
};
|
|
@@ -486,7 +483,6 @@ let IaCApply = class IaCApply extends common_1.Command {
|
|
|
486
483
|
action: type_1.ResourceAction.Apply,
|
|
487
484
|
envId,
|
|
488
485
|
log,
|
|
489
|
-
needEnvId: true,
|
|
490
486
|
extraData: { comment },
|
|
491
487
|
specResourceLogic: function (resource, config) {
|
|
492
488
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -547,8 +543,7 @@ let IaCDestory = class IaCDestory extends common_1.Command {
|
|
|
547
543
|
resource,
|
|
548
544
|
action: type_1.ResourceAction.Destory,
|
|
549
545
|
envId,
|
|
550
|
-
log
|
|
551
|
-
needEnvId: true
|
|
546
|
+
log
|
|
552
547
|
}));
|
|
553
548
|
});
|
|
554
549
|
}
|
|
@@ -593,8 +588,7 @@ let IaCState = class IaCState extends common_1.Command {
|
|
|
593
588
|
resource,
|
|
594
589
|
action: type_1.ResourceAction.State,
|
|
595
590
|
envId,
|
|
596
|
-
log
|
|
597
|
-
needEnvId: true
|
|
591
|
+
log
|
|
598
592
|
}));
|
|
599
593
|
if (data) {
|
|
600
594
|
log.info(JSON.stringify(data, null, 2));
|
|
@@ -647,22 +641,18 @@ function getOptions({ childCmd, options, desc, resourceSupportList, needEnvIdOpt
|
|
|
647
641
|
autoRunLogin: true
|
|
648
642
|
};
|
|
649
643
|
}
|
|
650
|
-
function getResource(
|
|
644
|
+
function getResource(action) {
|
|
651
645
|
return __awaiter(this, void 0, void 0, function* () {
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
});
|
|
663
|
-
selectedResource = res.resource;
|
|
664
|
-
}
|
|
665
|
-
return selectedResource;
|
|
646
|
+
const res = yield inquirer_1.default.prompt({
|
|
647
|
+
type: 'list',
|
|
648
|
+
name: 'resource',
|
|
649
|
+
message: '请选择资源类型',
|
|
650
|
+
choices: iac_core_1.IAC.tools.getResourceList(action).map((item) => ({
|
|
651
|
+
name: `${item.value} - ${item.name}`,
|
|
652
|
+
value: item.value
|
|
653
|
+
}))
|
|
654
|
+
});
|
|
655
|
+
return res.resource;
|
|
666
656
|
});
|
|
667
657
|
}
|
|
668
658
|
function trackCallback(message, log) {
|
|
@@ -688,28 +678,26 @@ function getCredential(ctx, options) {
|
|
|
688
678
|
});
|
|
689
679
|
}
|
|
690
680
|
function getAPIParams(config) {
|
|
691
|
-
const { cwd, resource, action, name, envId, log,
|
|
681
|
+
const { cwd, resource, action, name, envId, log, extraData = {}, specResourceLogic } = config;
|
|
692
682
|
return {
|
|
693
683
|
cwd,
|
|
694
|
-
|
|
695
|
-
|
|
684
|
+
envId,
|
|
685
|
+
getEnvId: () => {
|
|
686
|
+
return showEnvIdUI();
|
|
687
|
+
},
|
|
688
|
+
name,
|
|
689
|
+
getName: (nameOptions) => {
|
|
690
|
+
return showNameUI(nameOptions);
|
|
691
|
+
},
|
|
692
|
+
resourceType: resource,
|
|
693
|
+
getResourceType: () => {
|
|
694
|
+
return getResource(action);
|
|
696
695
|
},
|
|
697
|
-
getConfig: function (resource, envObj
|
|
696
|
+
getConfig: function (resource, envObj) {
|
|
698
697
|
return __awaiter(this, void 0, void 0, function* () {
|
|
699
|
-
const config = (0, lodash_1.assignWith)(
|
|
698
|
+
const config = (0, lodash_1.assignWith)(envObj, extraData, function customizer(objValue, srcValue) {
|
|
700
699
|
return (0, lodash_1.isUndefined)(objValue) ? srcValue : objValue;
|
|
701
700
|
});
|
|
702
|
-
const { resourceGroupDir } = otherInfo;
|
|
703
|
-
if (!config.name) {
|
|
704
|
-
const nameRes = yield showNameUI(resourceGroupDir);
|
|
705
|
-
Object.assign(config, { name: nameRes });
|
|
706
|
-
}
|
|
707
|
-
if (needEnvId) {
|
|
708
|
-
if (!config.envId) {
|
|
709
|
-
const envIdRes = yield showEnvIdUI();
|
|
710
|
-
Object.assign(config, { envId: envIdRes });
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
701
|
yield (specResourceLogic === null || specResourceLogic === void 0 ? void 0 : specResourceLogic(resource, config));
|
|
714
702
|
return config;
|
|
715
703
|
});
|
|
@@ -719,10 +707,10 @@ function getAPIParams(config) {
|
|
|
719
707
|
}
|
|
720
708
|
};
|
|
721
709
|
}
|
|
722
|
-
function showNameUI(
|
|
710
|
+
function showNameUI(nameOptions) {
|
|
723
711
|
return __awaiter(this, void 0, void 0, function* () {
|
|
724
712
|
let res;
|
|
725
|
-
if (
|
|
713
|
+
if (nameOptions.length === 0) {
|
|
726
714
|
res = yield inquirer_1.default.prompt({
|
|
727
715
|
type: 'input',
|
|
728
716
|
name: 'name',
|
|
@@ -739,11 +727,10 @@ function showNameUI(resourceGroupDir) {
|
|
|
739
727
|
res = yield inquirer_1.default.prompt({
|
|
740
728
|
type: 'autocomplete',
|
|
741
729
|
name: 'name',
|
|
742
|
-
message: '
|
|
730
|
+
message: '请选择资源标识或直接输入资源目录名',
|
|
743
731
|
source: function (answersSoFar, input = '') {
|
|
744
732
|
return __awaiter(this, void 0, void 0, function* () {
|
|
745
|
-
const
|
|
746
|
-
const filtered = choices.filter((choice) => choice.toLowerCase().includes(input.toLowerCase()));
|
|
733
|
+
const filtered = nameOptions.filter((choice) => choice.toLowerCase().includes(input.toLowerCase()));
|
|
747
734
|
return input ? [input, ...filtered] : filtered;
|
|
748
735
|
});
|
|
749
736
|
},
|
|
@@ -768,8 +755,14 @@ function showEnvIdUI(options) {
|
|
|
768
755
|
message,
|
|
769
756
|
source: function (answersSoFar, input = '') {
|
|
770
757
|
return __awaiter(this, void 0, void 0, function* () {
|
|
771
|
-
const filtered = envList.filter((
|
|
772
|
-
|
|
758
|
+
const filtered = envList.filter((env) => env.name.toLowerCase().includes((input === null || input === void 0 ? void 0 : input.toLowerCase()) || ''));
|
|
759
|
+
const choices = filtered.map((env) => ({
|
|
760
|
+
name: env.name,
|
|
761
|
+
value: env.value
|
|
762
|
+
}));
|
|
763
|
+
return required
|
|
764
|
+
? choices
|
|
765
|
+
: (0, lodash_1.compact)([input ? undefined : { name: '不提供', value: null }, ...choices]);
|
|
773
766
|
});
|
|
774
767
|
},
|
|
775
768
|
validate: required
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.7.0-alpha.
|
|
3
|
+
"version": "2.7.0-alpha.5",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@cloudbase/cloud-api": "^0.5.5",
|
|
35
35
|
"@cloudbase/framework-core": "^1.9.7",
|
|
36
|
-
"@cloudbase/iac-core": "alpha",
|
|
37
|
-
"@cloudbase/lowcode-cli": "^0.
|
|
36
|
+
"@cloudbase/iac-core": "^0.0.2-alpha.7",
|
|
37
|
+
"@cloudbase/lowcode-cli": "^0.22.1-alpha.0",
|
|
38
38
|
"@cloudbase/manager-node": "4.2.8",
|
|
39
39
|
"@cloudbase/toolbox": "^0.7.5",
|
|
40
40
|
"@sentry/node": "^5.10.2",
|