@cloudbase/cli 2.6.0-alpha.7 → 2.7.0-alpha.0

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.
Files changed (40) hide show
  1. package/.yarn/cache/@cloudbase-functions-framework-npm-1.0.0-beta.11-9bbeceb6ff-3aa0efd307.zip +0 -0
  2. package/.yarn/cache/@cloudbase-functions-typings-npm-1.0.0-beta.3-0b2fc0975b-ebe46cc101.zip +0 -0
  3. package/.yarn/cache/ajv-npm-8.17.1-12ade7edc6-1797bf242c.zip +0 -0
  4. package/.yarn/cache/fast-uri-npm-3.0.1-20477a5d16-106143ff83.zip +0 -0
  5. package/.yarn/cache/radix3-npm-1.1.2-bf27d7ceee-c4d49a3f60.zip +0 -0
  6. package/.yarn/install-state.gz +0 -0
  7. package/lib/commands/env/base.js +1 -2
  8. package/lib/commands/iac/index.js +642 -0
  9. package/lib/commands/index.js +1 -1
  10. package/lib/commands/lowcode/utils.js +2 -1
  11. package/lib/utils/net/cloud-api-request.js +9 -9
  12. package/package.json +5 -6
  13. package/types/commands/iac/index.d.ts +30 -0
  14. package/types/commands/index.d.ts +1 -1
  15. package/types/decorators/params/common.d.ts +1 -1
  16. package/types/types.d.ts +2 -2
  17. package/types/utils/config.d.ts +1 -1
  18. package/types/utils/fs/index.d.ts +1 -1
  19. package/types/utils/net/http-request.d.ts +3 -3
  20. package/types/utils/output/loading.d.ts +1 -1
  21. package/types/utils/parallel.d.ts +1 -1
  22. package/types/utils/validator.d.ts +1 -1
  23. package/.history/src/commands/lowcode/app_20220728111717.ts +0 -52
  24. package/.history/src/commands/lowcode/app_20220728112031.ts +0 -34
  25. package/.history/src/commands/lowcode/app_20220729172854.ts +0 -34
  26. package/.history/src/index_20220624162613.ts +0 -13
  27. package/.history/src/index_20220627113609.ts +0 -15
  28. package/.history/src/index_20220627114102.ts +0 -13
  29. package/.yarn/cache/@cloudbase-functions-framework-npm-1.0.0-beta.3-68c4d9136e-3d11f97edc.zip +0 -0
  30. package/.yarn/cache/@koa-router-npm-12.0.1-6a9764e4df-4b8d3940cb.zip +0 -0
  31. package/.yarn/cache/path-to-regexp-npm-6.2.2-0bf7f6805c-b7b0005c36.zip +0 -0
  32. package/.yarnrc.yml +0 -1
  33. package/lib/commands/constants.js +0 -11
  34. package/lib/commands/fun/base.js +0 -419
  35. package/lib/commands/fun/index.js +0 -17
  36. package/lib/commands/utils.js +0 -47
  37. package/types/commands/constants.d.ts +0 -8
  38. package/types/commands/fun/base.d.ts +0 -43
  39. package/types/commands/fun/index.d.ts +0 -1
  40. package/types/commands/utils.d.ts +0 -3
Binary file
@@ -27,7 +27,6 @@ const error_1 = require("../../error");
27
27
  const env_1 = require("../../env");
28
28
  const decorators_1 = require("../../decorators");
29
29
  const utils_1 = require("../../utils");
30
- const constants_1 = require("../constants");
31
30
  let EnvListCommand = class EnvListCommand extends common_1.Command {
32
31
  get options() {
33
32
  return {
@@ -59,7 +58,7 @@ let EnvListCommand = class EnvListCommand extends common_1.Command {
59
58
  item.Alias,
60
59
  item.EnvId,
61
60
  item.PackageName || '按量计费',
62
- item.Source === constants_1.EnvSource.MINIAPP ? '小程序' : '云开发',
61
+ item.Source === 'miniapp' ? '小程序' : '云开发',
63
62
  item.CreateTime,
64
63
  item.Status === 'NORMAL' ? '正常' : '不可用'
65
64
  ]);
@@ -0,0 +1,642 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var __importDefault = (this && this.__importDefault) || function (mod) {
24
+ return (mod && mod.__esModule) ? mod : { "default": mod };
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.IaCState = exports.IaCDestory = exports.IaCApply = exports.IaCDev = exports.IaCBuild = exports.IaCPull = exports.IaCInit = void 0;
28
+ const cals_1 = require("@cloudbase/cals");
29
+ const iac_core_1 = require("@cloudbase/iac-core");
30
+ const type_1 = require("@cloudbase/iac-core/lib/src/type");
31
+ const toolbox_1 = require("@cloudbase/toolbox");
32
+ const inquirer_1 = __importDefault(require("inquirer"));
33
+ const lodash_1 = require("lodash");
34
+ const decorators_1 = require("../../decorators");
35
+ const utils_1 = require("../../utils");
36
+ const common_1 = require("../common");
37
+ const loading = (0, toolbox_1.loadingFactory)();
38
+ let IaCInit = class IaCInit extends common_1.Command {
39
+ get options() {
40
+ return getOptions({
41
+ childCmd: 'init',
42
+ options: [],
43
+ desc: '初始化资源代码项目',
44
+ needEnvIdOption: false,
45
+ resourceSupportList: iac_core_1.IAC.actionSupportedResourceTypes.init
46
+ });
47
+ }
48
+ execute(ctx, options, log) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ let { resource, name, cwd = '.' } = options;
51
+ yield iac_core_1.IAC.resource.init(getAPIParams({
52
+ cwd,
53
+ name,
54
+ resource,
55
+ log,
56
+ needEnvId: false,
57
+ specResourceLogic: function (resource, config) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ switch (resource) {
60
+ case type_1.ResourceType.SCF:
61
+ {
62
+ const runtimeRes = yield inquirer_1.default.prompt({
63
+ type: 'list',
64
+ name: 'runtime',
65
+ message: '请选择运行环境',
66
+ default: type_1.IFunctionRuntime.Nodejs18_15,
67
+ choices: Object.values(type_1.IFunctionRuntime)
68
+ });
69
+ Object.assign(config, runtimeRes);
70
+ const memorySizeRes = yield inquirer_1.default.prompt({
71
+ type: 'number',
72
+ name: 'memorySize',
73
+ message: '函数内存(MB)',
74
+ default: 256
75
+ });
76
+ Object.assign(config, memorySizeRes);
77
+ const descriptionSizeRes = yield inquirer_1.default.prompt({
78
+ type: 'input',
79
+ name: 'description',
80
+ message: '描述'
81
+ });
82
+ Object.assign(config, descriptionSizeRes);
83
+ }
84
+ break;
85
+ case type_1.ResourceType.App:
86
+ {
87
+ const titleRes = yield inquirer_1.default.prompt({
88
+ type: 'input',
89
+ name: 'title',
90
+ message: '应用名称',
91
+ default: config.name
92
+ });
93
+ Object.assign(config, titleRes);
94
+ }
95
+ break;
96
+ case type_1.ResourceType.Model:
97
+ {
98
+ const titleRes = yield inquirer_1.default.prompt({
99
+ type: 'input',
100
+ name: 'title',
101
+ message: '数据模型名称',
102
+ default: config.name
103
+ });
104
+ Object.assign(config, titleRes);
105
+ const dbInstanceTypeRes = yield inquirer_1.default.prompt({
106
+ type: 'list',
107
+ name: 'dbInstanceType',
108
+ message: '数据库类型',
109
+ default: cals_1.IDatabaseDataSourceDbType.FLEXDB,
110
+ choices: Object.values(cals_1.IDatabaseDataSourceDbType)
111
+ });
112
+ Object.assign(config, dbInstanceTypeRes);
113
+ const descriptionSizeRes = yield inquirer_1.default.prompt({
114
+ type: 'input',
115
+ name: 'description',
116
+ message: '描述'
117
+ });
118
+ Object.assign(config, descriptionSizeRes);
119
+ }
120
+ break;
121
+ }
122
+ });
123
+ }
124
+ }));
125
+ });
126
+ }
127
+ };
128
+ __decorate([
129
+ (0, decorators_1.InjectParams)(),
130
+ __param(0, (0, decorators_1.CmdContext)()),
131
+ __param(1, (0, decorators_1.ArgsOptions)()),
132
+ __param(2, (0, decorators_1.Log)()),
133
+ __metadata("design:type", Function),
134
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
135
+ __metadata("design:returntype", Promise)
136
+ ], IaCInit.prototype, "execute", null);
137
+ IaCInit = __decorate([
138
+ (0, common_1.ICommand)({
139
+ supportPrivate: true
140
+ })
141
+ ], IaCInit);
142
+ exports.IaCInit = IaCInit;
143
+ let IaCPull = class IaCPull extends common_1.Command {
144
+ get options() {
145
+ return getOptions({
146
+ childCmd: 'pull',
147
+ options: [
148
+ {
149
+ flags: '--appId <appId>',
150
+ desc: '应用 ID(仅当 resource=App 时有效)'
151
+ }
152
+ ],
153
+ desc: '拉取资源项目代码',
154
+ needEnvIdOption: true,
155
+ resourceSupportList: iac_core_1.IAC.actionSupportedResourceTypes.pull
156
+ });
157
+ }
158
+ execute(ctx, options, log) {
159
+ return __awaiter(this, void 0, void 0, function* () {
160
+ let { resource, name, envId, cwd = '.' } = options;
161
+ const { appId } = options;
162
+ yield iac_core_1.IAC.init({
163
+ getCredential: () => {
164
+ return getCredential(ctx);
165
+ }
166
+ });
167
+ yield iac_core_1.IAC.resource.pull(getAPIParams({
168
+ cwd,
169
+ name,
170
+ resource,
171
+ envId,
172
+ log,
173
+ needEnvId: true,
174
+ extraData: { appId },
175
+ specResourceLogic: function (resource, config) {
176
+ return __awaiter(this, void 0, void 0, function* () {
177
+ if (resource === type_1.ResourceType.App) {
178
+ if (!config.appId) {
179
+ const appIdRes = yield showAppIdUI();
180
+ Object.assign(config, { appId: appIdRes });
181
+ }
182
+ }
183
+ });
184
+ }
185
+ }));
186
+ });
187
+ }
188
+ };
189
+ __decorate([
190
+ (0, decorators_1.InjectParams)(),
191
+ __param(0, (0, decorators_1.CmdContext)()),
192
+ __param(1, (0, decorators_1.ArgsOptions)()),
193
+ __param(2, (0, decorators_1.Log)()),
194
+ __metadata("design:type", Function),
195
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
196
+ __metadata("design:returntype", Promise)
197
+ ], IaCPull.prototype, "execute", null);
198
+ IaCPull = __decorate([
199
+ (0, common_1.ICommand)({
200
+ supportPrivate: true
201
+ })
202
+ ], IaCPull);
203
+ exports.IaCPull = IaCPull;
204
+ let IaCBuild = class IaCBuild extends common_1.Command {
205
+ get options() {
206
+ return getOptions({
207
+ childCmd: 'build',
208
+ options: [],
209
+ desc: '构建资源项目代码',
210
+ needEnvIdOption: false,
211
+ resourceSupportList: iac_core_1.IAC.actionSupportedResourceTypes.build
212
+ });
213
+ }
214
+ execute(ctx, options, log) {
215
+ return __awaiter(this, void 0, void 0, function* () {
216
+ let { resource, name, cwd = '.' } = options;
217
+ yield iac_core_1.IAC.resource.build(getAPIParams({
218
+ cwd,
219
+ name,
220
+ resource,
221
+ log,
222
+ needEnvId: false
223
+ }));
224
+ });
225
+ }
226
+ };
227
+ __decorate([
228
+ (0, decorators_1.InjectParams)(),
229
+ __param(0, (0, decorators_1.CmdContext)()),
230
+ __param(1, (0, decorators_1.ArgsOptions)()),
231
+ __param(2, (0, decorators_1.Log)()),
232
+ __metadata("design:type", Function),
233
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
234
+ __metadata("design:returntype", Promise)
235
+ ], IaCBuild.prototype, "execute", null);
236
+ IaCBuild = __decorate([
237
+ (0, common_1.ICommand)({
238
+ supportPrivate: true
239
+ })
240
+ ], IaCBuild);
241
+ exports.IaCBuild = IaCBuild;
242
+ let IaCDev = class IaCDev extends common_1.Command {
243
+ get options() {
244
+ return getOptions({
245
+ childCmd: 'dev',
246
+ options: [
247
+ {
248
+ flags: '--data <data>',
249
+ desc: '要传递给调用函数的序列化 Event 数据(仅当 resource=SCF 时有效)'
250
+ },
251
+ {
252
+ flags: '--dataPath <dataPath>',
253
+ desc: '要传递给调用函数 Event 的 json 文件所在路径(仅当 resource=SCF 时有效)'
254
+ },
255
+ {
256
+ flags: '--context <context>',
257
+ desc: '要传递给调用函数的序列化 Context 数据(仅当 resource=SCF 时有效)'
258
+ },
259
+ {
260
+ flags: '--contextPath <contextPath>',
261
+ desc: '要传递给调用函数 Context 的 json 文件所在路径(仅当 resource=SCF 时有效)'
262
+ },
263
+ {
264
+ flags: '--platform <platform>',
265
+ desc: '运行平台,可选为 web | mp。默认为 web(仅当 resource=App 时有效)'
266
+ }
267
+ ],
268
+ desc: '本地开发资源项目代码',
269
+ needEnvIdOption: false,
270
+ resourceSupportList: iac_core_1.IAC.actionSupportedResourceTypes.dev
271
+ });
272
+ }
273
+ execute(ctx, options, log) {
274
+ return __awaiter(this, void 0, void 0, function* () {
275
+ let { resource, name, cwd = '.' } = options;
276
+ const { data, dataPath, context, contextPath, platform } = options;
277
+ yield iac_core_1.IAC.init({
278
+ getCredential: () => {
279
+ return getCredential(ctx);
280
+ }
281
+ });
282
+ yield iac_core_1.IAC.resource.dev(getAPIParams({
283
+ cwd,
284
+ name,
285
+ resource,
286
+ log,
287
+ needEnvId: false,
288
+ extraData: { data, dataPath, context, contextPath, platform }
289
+ }));
290
+ });
291
+ }
292
+ };
293
+ __decorate([
294
+ (0, decorators_1.InjectParams)(),
295
+ __param(0, (0, decorators_1.CmdContext)()),
296
+ __param(1, (0, decorators_1.ArgsOptions)()),
297
+ __param(2, (0, decorators_1.Log)()),
298
+ __metadata("design:type", Function),
299
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
300
+ __metadata("design:returntype", Promise)
301
+ ], IaCDev.prototype, "execute", null);
302
+ IaCDev = __decorate([
303
+ (0, common_1.ICommand)({
304
+ supportPrivate: true
305
+ })
306
+ ], IaCDev);
307
+ exports.IaCDev = IaCDev;
308
+ let IaCApply = class IaCApply extends common_1.Command {
309
+ get options() {
310
+ return getOptions({
311
+ childCmd: 'apply',
312
+ options: [
313
+ {
314
+ flags: '--appId <appId>',
315
+ desc: '应用 ID(仅当 resource=App 时有效)'
316
+ },
317
+ {
318
+ flags: '--comment <comment>',
319
+ desc: '提交信息(仅当 resource=App 时有效)'
320
+ }
321
+ ],
322
+ desc: '本地开发资源项目代码',
323
+ needEnvIdOption: true,
324
+ resourceSupportList: iac_core_1.IAC.actionSupportedResourceTypes.apply
325
+ });
326
+ }
327
+ execute(ctx, options, log) {
328
+ return __awaiter(this, void 0, void 0, function* () {
329
+ let { resource, name, envId, cwd = '.' } = options;
330
+ const { appId, comment } = options;
331
+ yield iac_core_1.IAC.init({
332
+ getCredential: () => {
333
+ return getCredential(ctx);
334
+ }
335
+ });
336
+ yield iac_core_1.IAC.resource.apply(getAPIParams({
337
+ cwd,
338
+ name,
339
+ resource,
340
+ envId,
341
+ log,
342
+ needEnvId: true,
343
+ extraData: { appId, comment },
344
+ specResourceLogic: function (resource, config) {
345
+ return __awaiter(this, void 0, void 0, function* () {
346
+ });
347
+ }
348
+ }));
349
+ });
350
+ }
351
+ };
352
+ __decorate([
353
+ (0, decorators_1.InjectParams)(),
354
+ __param(0, (0, decorators_1.CmdContext)()),
355
+ __param(1, (0, decorators_1.ArgsOptions)()),
356
+ __param(2, (0, decorators_1.Log)()),
357
+ __metadata("design:type", Function),
358
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
359
+ __metadata("design:returntype", Promise)
360
+ ], IaCApply.prototype, "execute", null);
361
+ IaCApply = __decorate([
362
+ (0, common_1.ICommand)({
363
+ supportPrivate: true
364
+ })
365
+ ], IaCApply);
366
+ exports.IaCApply = IaCApply;
367
+ let IaCDestory = class IaCDestory extends common_1.Command {
368
+ get options() {
369
+ return getOptions({
370
+ childCmd: 'destory',
371
+ options: [
372
+ {
373
+ flags: '--appId <appId>',
374
+ desc: '应用 ID(仅当 resource=App 时有效)'
375
+ }
376
+ ],
377
+ desc: '删除资源',
378
+ needEnvIdOption: true,
379
+ resourceSupportList: iac_core_1.IAC.actionSupportedResourceTypes.destory
380
+ });
381
+ }
382
+ execute(ctx, options, log) {
383
+ return __awaiter(this, void 0, void 0, function* () {
384
+ let { resource, name, envId, cwd = '.' } = options;
385
+ const { appId } = options;
386
+ yield iac_core_1.IAC.init({
387
+ getCredential: () => {
388
+ return getCredential(ctx);
389
+ }
390
+ });
391
+ yield iac_core_1.IAC.resource.destory(getAPIParams({
392
+ cwd,
393
+ name,
394
+ resource,
395
+ envId,
396
+ log,
397
+ needEnvId: true,
398
+ extraData: { appId },
399
+ specResourceLogic: function (resource, config) {
400
+ return __awaiter(this, void 0, void 0, function* () {
401
+ if (resource === type_1.ResourceType.App) {
402
+ if (!config.appId) {
403
+ const appIdRes = yield showAppIdUI();
404
+ Object.assign(config, { appId: appIdRes });
405
+ }
406
+ }
407
+ });
408
+ }
409
+ }));
410
+ });
411
+ }
412
+ };
413
+ __decorate([
414
+ (0, decorators_1.InjectParams)(),
415
+ __param(0, (0, decorators_1.CmdContext)()),
416
+ __param(1, (0, decorators_1.ArgsOptions)()),
417
+ __param(2, (0, decorators_1.Log)()),
418
+ __metadata("design:type", Function),
419
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
420
+ __metadata("design:returntype", Promise)
421
+ ], IaCDestory.prototype, "execute", null);
422
+ IaCDestory = __decorate([
423
+ (0, common_1.ICommand)({
424
+ supportPrivate: true
425
+ })
426
+ ], IaCDestory);
427
+ exports.IaCDestory = IaCDestory;
428
+ let IaCState = class IaCState extends common_1.Command {
429
+ get options() {
430
+ return getOptions({
431
+ childCmd: 'state',
432
+ options: [
433
+ {
434
+ flags: '--appId <appId>',
435
+ desc: '应用 ID(仅当 resource=App 时有效)'
436
+ }
437
+ ],
438
+ desc: '查询资源信息',
439
+ needEnvIdOption: true,
440
+ resourceSupportList: iac_core_1.IAC.actionSupportedResourceTypes.state
441
+ });
442
+ }
443
+ execute(ctx, options, log) {
444
+ return __awaiter(this, void 0, void 0, function* () {
445
+ const { resource, name, cwd = '.', envId } = options;
446
+ const { appId } = options;
447
+ yield iac_core_1.IAC.init({
448
+ getCredential: () => {
449
+ return getCredential(ctx);
450
+ }
451
+ });
452
+ const data = yield iac_core_1.IAC.resource.state(getAPIParams({
453
+ cwd,
454
+ name,
455
+ resource,
456
+ envId,
457
+ log,
458
+ needEnvId: true,
459
+ extraData: { appId },
460
+ specResourceLogic: function (resource, config) {
461
+ return __awaiter(this, void 0, void 0, function* () {
462
+ if (resource === type_1.ResourceType.App) {
463
+ if (!config.appId) {
464
+ const appIdRes = yield showAppIdUI();
465
+ Object.assign(config, { appId: appIdRes });
466
+ }
467
+ }
468
+ });
469
+ }
470
+ }));
471
+ log.info(JSON.stringify(data, null, 2));
472
+ });
473
+ }
474
+ };
475
+ __decorate([
476
+ (0, decorators_1.InjectParams)(),
477
+ __param(0, (0, decorators_1.CmdContext)()),
478
+ __param(1, (0, decorators_1.ArgsOptions)()),
479
+ __param(2, (0, decorators_1.Log)()),
480
+ __metadata("design:type", Function),
481
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger]),
482
+ __metadata("design:returntype", Promise)
483
+ ], IaCState.prototype, "execute", null);
484
+ IaCState = __decorate([
485
+ (0, common_1.ICommand)({
486
+ supportPrivate: true
487
+ })
488
+ ], IaCState);
489
+ exports.IaCState = IaCState;
490
+ function getOptions({ childCmd, options, desc, resourceSupportList, needEnvIdOption = true }) {
491
+ return {
492
+ cmd: 'iac',
493
+ childCmd,
494
+ options: (0, lodash_1.compact)([
495
+ {
496
+ flags: '--resource <resource>',
497
+ desc: '资源类型。当前支持 ' + resourceSupportList.join(' / ')
498
+ },
499
+ {
500
+ flags: '--name <name>',
501
+ desc: '资源名称'
502
+ },
503
+ {
504
+ flags: '--cwd <cwd>',
505
+ desc: '项目路径'
506
+ },
507
+ needEnvIdOption
508
+ ? {
509
+ flags: '--envId <envId>',
510
+ desc: '环境 Id'
511
+ }
512
+ : null,
513
+ ...options
514
+ ]),
515
+ desc,
516
+ requiredEnvId: false,
517
+ autoRunLogin: true
518
+ };
519
+ }
520
+ function getResource(resource) {
521
+ return __awaiter(this, void 0, void 0, function* () {
522
+ if (!resource) {
523
+ const res = yield inquirer_1.default.prompt({
524
+ type: 'list',
525
+ name: 'resource',
526
+ message: '请选择资源类型',
527
+ choices: iac_core_1.IAC.actionSupportedResourceTypes.init
528
+ });
529
+ resource = res.resource;
530
+ }
531
+ return resource;
532
+ });
533
+ }
534
+ function trackCallback(message, log) {
535
+ if (message.status === 'progress') {
536
+ loading.start(message.details);
537
+ }
538
+ else if (message.status === 'done') {
539
+ loading.succeed(message.details);
540
+ }
541
+ else {
542
+ if (message.type === 'error') {
543
+ loading.fail(message.details);
544
+ }
545
+ else {
546
+ log.info(message.details);
547
+ }
548
+ }
549
+ }
550
+ function getCredential(ctx) {
551
+ return __awaiter(this, void 0, void 0, function* () {
552
+ let credential;
553
+ if (ctx.hasPrivateSettings) {
554
+ process.env.IS_PRIVATE = 'true';
555
+ const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd);
556
+ credential = privateSettings.credential;
557
+ }
558
+ else {
559
+ credential = yield utils_1.authSupevisor.getLoginState();
560
+ }
561
+ return credential;
562
+ });
563
+ }
564
+ function getAPIParams(config) {
565
+ const { cwd, resource, name, envId, log, needEnvId = true, extraData = {}, specResourceLogic } = config;
566
+ return {
567
+ cwd,
568
+ getResource: () => {
569
+ return getResource(resource);
570
+ },
571
+ getConfig: function (resource, envObj) {
572
+ return __awaiter(this, void 0, void 0, function* () {
573
+ const config = (0, lodash_1.assignWith)(envObj, { name, envId }, extraData, function customizer(objValue, srcValue) {
574
+ return (0, lodash_1.isUndefined)(objValue) ? srcValue : objValue;
575
+ });
576
+ if (!config.name) {
577
+ const nameRes = yield showNameUI();
578
+ Object.assign(config, { name: nameRes });
579
+ }
580
+ if (needEnvId) {
581
+ if (!config.envId) {
582
+ const envIdRes = yield showEnvIdUI();
583
+ Object.assign(config, { envId: envIdRes });
584
+ }
585
+ }
586
+ yield (specResourceLogic === null || specResourceLogic === void 0 ? void 0 : specResourceLogic(resource, config));
587
+ return config;
588
+ });
589
+ },
590
+ trackCallback: (message) => {
591
+ trackCallback(message, log);
592
+ }
593
+ };
594
+ }
595
+ function showNameUI() {
596
+ return __awaiter(this, void 0, void 0, function* () {
597
+ const res = yield inquirer_1.default.prompt({
598
+ type: 'input',
599
+ name: 'name',
600
+ message: '请输入资源标识',
601
+ validate: function (input) {
602
+ if (input.trim() === '') {
603
+ return '资源名称不能为空';
604
+ }
605
+ return true;
606
+ }
607
+ });
608
+ return res.name;
609
+ });
610
+ }
611
+ function showEnvIdUI() {
612
+ return __awaiter(this, void 0, void 0, function* () {
613
+ const res = yield inquirer_1.default.prompt({
614
+ type: 'input',
615
+ name: 'envId',
616
+ message: '环境 ID',
617
+ validate: function (input) {
618
+ if (input.trim() === '') {
619
+ return '环境 ID不能为空';
620
+ }
621
+ return true;
622
+ }
623
+ });
624
+ return res.envId;
625
+ });
626
+ }
627
+ function showAppIdUI() {
628
+ return __awaiter(this, void 0, void 0, function* () {
629
+ const res = yield inquirer_1.default.prompt({
630
+ type: 'input',
631
+ name: 'appId',
632
+ message: '应用 ID',
633
+ validate: function (input) {
634
+ if (input.trim() === '') {
635
+ return '应用 ID不能为空';
636
+ }
637
+ return true;
638
+ }
639
+ });
640
+ return res.appId;
641
+ });
642
+ }
@@ -28,4 +28,4 @@ __exportStar(require("./smart"), exports);
28
28
  __exportStar(require("./lowcode"), exports);
29
29
  __exportStar(require("./run"), exports);
30
30
  __exportStar(require("./db"), exports);
31
- __exportStar(require("./fun"), exports);
31
+ __exportStar(require("./iac"), exports);
@@ -60,11 +60,12 @@ function promisifyProcess(p, pipe = false) {
60
60
  exports.promisifyProcess = promisifyProcess;
61
61
  function getLowcodeCli() {
62
62
  return __awaiter(this, void 0, void 0, function* () {
63
+ var _a;
63
64
  const key = '@cloudbase/lowcode-cli';
64
65
  const cache = new Map();
65
66
  let result;
66
67
  if (!cache.get(key)) {
67
- const module = yield Promise.resolve().then(() => __importStar(require(key)));
68
+ const module = yield (_a = key, Promise.resolve().then(() => __importStar(require(_a))));
68
69
  cache.set(key, module);
69
70
  }
70
71
  result = cache.get(key);