@cloudbase/cli 2.6.11 → 2.6.13

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.
@@ -24,81 +24,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.CloudFunctionRunCommand = exports.CloudFunctionDownloadCommand = exports.CloudFunctionDeployCommand = exports.CloudFunctionListCommand = void 0;
27
+ exports.CloudFunctionRunCommand = exports.CloudFunctionDownloadCommand = exports.CloudFunctionDeployCommand = void 0;
28
28
  const functions_framework_1 = require("@cloudbase/functions-framework");
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
- const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
31
29
  const iac_core_1 = require("@cloudbase/iac-core");
30
+ const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
32
31
  const inquirer_1 = __importDefault(require("inquirer"));
32
+ const nodemon_1 = __importDefault(require("nodemon"));
33
33
  const path_1 = __importDefault(require("path"));
34
34
  const decorators_1 = require("../../decorators");
35
- const utils_1 = require("../../utils");
36
35
  const common_1 = require("../common");
37
36
  const constants_1 = require("../constants");
38
- const utils_2 = require("../utils");
39
- const nodemon_1 = __importDefault(require("nodemon"));
40
- const { CloudAPI } = iac_core_1.CloudAPI;
41
- const scfService = utils_1.CloudApiService.getInstance('tcb');
42
- class CloudFunctionListCommand extends common_1.Command {
43
- get options() {
44
- return {
45
- cmd: 'cloudfunction',
46
- childCmd: 'list',
47
- options: [
48
- {
49
- flags: '-e, --envId <envId>',
50
- desc: '环境 Id'
51
- }
52
- ],
53
- requiredEnvId: false,
54
- autoRunLogin: true,
55
- desc: '查看函数式托管服务列表'
56
- };
57
- }
58
- execute(envId, log) {
59
- var _a;
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const loading = (0, utils_1.loadingFactory)();
62
- if (!envId) {
63
- envId = yield _selectEnv();
64
- }
65
- else {
66
- log.info(`当前环境 Id:${envId}`);
67
- }
68
- try {
69
- loading.start('获取函数式托管服务列表中…');
70
- let serverListRes = yield scfService
71
- .request('DescribeCloudBaseRunServers', {
72
- EnvId: envId,
73
- Limit: 100,
74
- Offset: 0
75
- })
76
- .finally(() => loading.stop());
77
- const serverList = (_a = serverListRes.CloudBaseRunServerSet) === null || _a === void 0 ? void 0 : _a.filter((item) => item.Tag === 'function');
78
- const head = ['服务名称', '状态', '创建时间', '更新时间'];
79
- const tableData = serverList.map((serverItem) => [
80
- serverItem.ServerName,
81
- serverItem.Status,
82
- serverItem.CreatedTime,
83
- serverItem.UpdatedTime
84
- ]);
85
- (0, utils_1.printHorizontalTable)(head, tableData);
86
- }
87
- catch (e) {
88
- log.error('获取函数式托管服务列表失败:' + e.message);
89
- }
90
- });
91
- }
92
- }
93
- __decorate([
94
- (0, decorators_1.InjectParams)(),
95
- __param(0, (0, decorators_1.EnvId)()),
96
- __param(1, (0, decorators_1.Log)()),
97
- __metadata("design:type", Function),
98
- __metadata("design:paramtypes", [Object, decorators_1.Logger]),
99
- __metadata("design:returntype", Promise)
100
- ], CloudFunctionListCommand.prototype, "execute", null);
101
- exports.CloudFunctionListCommand = CloudFunctionListCommand;
37
+ const utils_1 = require("../utils");
102
38
  let CloudFunctionDeployCommand = class CloudFunctionDeployCommand extends common_1.Command {
103
39
  get options() {
104
40
  return {
@@ -141,7 +77,7 @@ let CloudFunctionDeployCommand = class CloudFunctionDeployCommand extends common
141
77
  log.info(`当前环境 Id:${envId}`);
142
78
  }
143
79
  if (!serviceName) {
144
- const { shortName } = yield (0, utils_2.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
80
+ const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
145
81
  serviceName = yield _inputServiceName(shortName);
146
82
  }
147
83
  const answers = yield inquirer_1.default.prompt([
@@ -158,7 +94,7 @@ let CloudFunctionDeployCommand = class CloudFunctionDeployCommand extends common
158
94
  yield iac_core_1.IAC.init({
159
95
  cwd: targetDir,
160
96
  getCredential: () => {
161
- return getCredential(ctx, options);
97
+ return (0, utils_1.getCredential)(ctx, options);
162
98
  },
163
99
  polyRepoMode: true
164
100
  });
@@ -167,25 +103,25 @@ let CloudFunctionDeployCommand = class CloudFunctionDeployCommand extends common
167
103
  var _a;
168
104
  return __awaiter(this, void 0, void 0, function* () {
169
105
  try {
170
- const res = yield iac_core_1.IAC.Function.apply({
106
+ yield iac_core_1.IAC.Function.apply({
171
107
  cwd: targetDir,
172
108
  envId: envId,
173
109
  name: serviceName
174
110
  }, function (message) {
175
- trackCallback(message, log);
111
+ (0, utils_1.trackCallback)(message, log);
176
112
  });
177
113
  }
178
114
  catch (e) {
179
115
  if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateFunctionConfiguration' &&
180
116
  ((_a = e === null || e === void 0 ? void 0 : e.message) === null || _a === void 0 ? void 0 : _a.includes('当前函数处于Updating状态,无法进行此操作,请稍后重试'))) {
181
- trackCallback({
117
+ (0, utils_1.trackCallback)({
182
118
  type: 'error',
183
119
  details: '当前函数处于更新状态,无法进行此操作,请稍后重试',
184
120
  originalError: e
185
121
  }, log);
186
122
  }
187
123
  else {
188
- trackCallback({
124
+ (0, utils_1.trackCallback)({
189
125
  type: 'error',
190
126
  details: `${e.message}`,
191
127
  originalError: e
@@ -247,13 +183,13 @@ let CloudFunctionDownloadCommand = class CloudFunctionDownloadCommand extends co
247
183
  log.info(`当前环境 Id:${envId}`);
248
184
  }
249
185
  if (!serviceName) {
250
- const { shortName } = yield (0, utils_2.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
186
+ const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
251
187
  serviceName = yield _inputServiceName(shortName);
252
188
  if (serviceName !== shortName) {
253
189
  targetDir = path_1.default.join(targetDir, serviceName);
254
190
  }
255
191
  }
256
- const needTips = !(yield isDirectoryEmptyOrNotExists(targetDir));
192
+ const needTips = !(yield (0, utils_1.isDirectoryEmptyOrNotExists)(targetDir));
257
193
  if (needTips) {
258
194
  const answers = yield inquirer_1.default.prompt([
259
195
  {
@@ -270,7 +206,7 @@ let CloudFunctionDownloadCommand = class CloudFunctionDownloadCommand extends co
270
206
  yield iac_core_1.IAC.init({
271
207
  cwd: targetDir,
272
208
  getCredential: () => {
273
- return getCredential(ctx, options);
209
+ return (0, utils_1.getCredential)(ctx, options);
274
210
  },
275
211
  polyRepoMode: true
276
212
  });
@@ -280,11 +216,11 @@ let CloudFunctionDownloadCommand = class CloudFunctionDownloadCommand extends co
280
216
  envId: envId,
281
217
  name: serviceName
282
218
  }, function (message) {
283
- trackCallback(message, log);
219
+ (0, utils_1.trackCallback)(message, log);
284
220
  });
285
221
  }
286
222
  catch (e) {
287
- trackCallback({
223
+ (0, utils_1.trackCallback)({
288
224
  type: 'error',
289
225
  details: `${e.message}`,
290
226
  originalError: e
@@ -339,7 +275,7 @@ let CloudFunctionRunCommand = class CloudFunctionRunCommand extends common_1.Com
339
275
  const watchFlag = ['--watch', '-w'];
340
276
  const defaultIgnoreFiles = ['logs/*.*'];
341
277
  const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(process.cwd()));
342
- const credential = yield getCredential(ctx, options);
278
+ const credential = yield (0, utils_1.getCredential)(ctx, options);
343
279
  process.env.TCB_ENV = envConfig.envId;
344
280
  process.env.TENCENTCLOUD_SECRETID = credential.secretId;
345
281
  process.env.TENCENTCLOUD_SECRETKEY = credential.secretKey;
@@ -400,7 +336,7 @@ CloudFunctionRunCommand = __decorate([
400
336
  exports.CloudFunctionRunCommand = CloudFunctionRunCommand;
401
337
  function _selectEnv() {
402
338
  return __awaiter(this, void 0, void 0, function* () {
403
- return (0, utils_2.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
339
+ return (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
404
340
  });
405
341
  }
406
342
  function _inputServiceName(defaultVal = '') {
@@ -425,40 +361,3 @@ function _inputServiceName(defaultVal = '') {
425
361
  return answers['serviceName'];
426
362
  });
427
363
  }
428
- function getCredential(ctx, options) {
429
- return __awaiter(this, void 0, void 0, function* () {
430
- let credential;
431
- if (ctx.hasPrivateSettings) {
432
- process.env.IS_PRIVATE = 'true';
433
- const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, options.cmd);
434
- credential = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.credential;
435
- }
436
- else {
437
- credential = yield utils_1.authSupevisor.getLoginState();
438
- }
439
- return credential;
440
- });
441
- }
442
- function isDirectoryEmptyOrNotExists(dirPath) {
443
- return __awaiter(this, void 0, void 0, function* () {
444
- try {
445
- const exists = yield fs_extra_1.default.pathExists(dirPath);
446
- if (!exists) {
447
- return true;
448
- }
449
- const files = yield fs_extra_1.default.readdir(dirPath);
450
- return files.length === 0;
451
- }
452
- catch (error) {
453
- return true;
454
- }
455
- });
456
- }
457
- function trackCallback(message, log) {
458
- if (message.type === 'error') {
459
- log.error(message.details);
460
- }
461
- else {
462
- log.info(message.details);
463
- }
464
- }
@@ -0,0 +1,206 @@
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.CloudRunDeployCommand = void 0;
28
+ const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
29
+ const iac_core_1 = require("@cloudbase/iac-core");
30
+ const inquirer_1 = __importDefault(require("inquirer"));
31
+ const path_1 = __importDefault(require("path"));
32
+ const decorators_1 = require("../../decorators");
33
+ const common_1 = require("../common");
34
+ const constants_1 = require("../constants");
35
+ const utils_1 = require("../utils");
36
+ const { CloudAPI } = iac_core_1.CloudAPI;
37
+ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command {
38
+ get options() {
39
+ return {
40
+ cmd: 'cloudrun',
41
+ childCmd: 'deploy',
42
+ options: [
43
+ {
44
+ flags: '-e, --envId <envId>',
45
+ desc: '环境 Id'
46
+ },
47
+ {
48
+ flags: '-s, --serviceName <serviceName>',
49
+ desc: '服务名称'
50
+ },
51
+ {
52
+ flags: '--source <source>',
53
+ desc: '目标云托管代码文件所在目录路径。默认为当前路径'
54
+ }
55
+ ],
56
+ requiredEnvId: false,
57
+ autoRunLogin: true,
58
+ desc: '部署云托管服务'
59
+ };
60
+ }
61
+ execute(ctx, envId, log, options) {
62
+ return __awaiter(this, void 0, void 0, function* () {
63
+ let { serviceName, source } = options;
64
+ const targetDir = path_1.default.resolve(source || process.cwd());
65
+ if (!envId) {
66
+ const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
67
+ if (envConfig.envId) {
68
+ envId = envConfig.envId;
69
+ log.info(`当前环境 Id:${envId}`);
70
+ }
71
+ else {
72
+ envId = yield _selectEnv();
73
+ }
74
+ }
75
+ else {
76
+ log.info(`当前环境 Id:${envId}`);
77
+ }
78
+ if (!serviceName) {
79
+ const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
80
+ serviceName = yield _inputServiceName(shortName);
81
+ }
82
+ const answers = yield inquirer_1.default.prompt([
83
+ {
84
+ type: 'confirm',
85
+ name: 'confirm',
86
+ message: `即将开始部署,是否确认继续?`,
87
+ default: true
88
+ }
89
+ ]);
90
+ if (!answers.confirm) {
91
+ return;
92
+ }
93
+ yield iac_core_1.IAC.init({
94
+ cwd: targetDir,
95
+ getCredential: () => {
96
+ return (0, utils_1.getCredential)(ctx, options);
97
+ },
98
+ polyRepoMode: true
99
+ });
100
+ yield _runDeploy();
101
+ function _runDeploy() {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ try {
104
+ const res = yield iac_core_1.IAC.Cloudrun.apply({
105
+ cwd: targetDir,
106
+ envId: envId,
107
+ name: serviceName
108
+ }, function (message) {
109
+ (0, utils_1.trackCallback)(message, log);
110
+ });
111
+ const { envId: _envId, name, resourceType: _resourceType } = res === null || res === void 0 ? void 0 : res.data;
112
+ (0, utils_1.trackCallback)({
113
+ details: `请打开链接查看部署状态: https://tcb.cloud.tencent.com/dev?envId=${_envId}#/platform-run/service/detail?serverName=${name}&tabId=deploy&envId=${_envId}`
114
+ }, log);
115
+ }
116
+ catch (e) {
117
+ if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateCloudRunServer' && (e === null || e === void 0 ? void 0 : e.code) === 'ResourceInUse') {
118
+ inquirer_1.default
119
+ .prompt([
120
+ {
121
+ type: 'confirm',
122
+ name: 'confirm',
123
+ message: `平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码`,
124
+ default: true
125
+ }
126
+ ])
127
+ .then((answers) => __awaiter(this, void 0, void 0, function* () {
128
+ if (answers.confirm) {
129
+ try {
130
+ const { task } = yield CloudAPI.tcbrServiceRequest('DescribeServerManageTask', {
131
+ envId,
132
+ serverName: serviceName,
133
+ taskId: 0
134
+ });
135
+ const id = task === null || task === void 0 ? void 0 : task.id;
136
+ yield CloudAPI.tcbrServiceRequest('OperateServerManage', {
137
+ envId,
138
+ operateType: 'cancel',
139
+ serverName: serviceName,
140
+ taskId: id
141
+ });
142
+ yield _runDeploy();
143
+ }
144
+ catch (e) {
145
+ (0, utils_1.trackCallback)({
146
+ type: 'error',
147
+ details: e.message
148
+ }, log);
149
+ }
150
+ }
151
+ }));
152
+ }
153
+ else {
154
+ (0, utils_1.trackCallback)({
155
+ type: 'error',
156
+ details: `${e.message}`,
157
+ originalError: e
158
+ }, log);
159
+ }
160
+ }
161
+ });
162
+ }
163
+ });
164
+ }
165
+ };
166
+ __decorate([
167
+ (0, decorators_1.InjectParams)(),
168
+ __param(0, (0, decorators_1.CmdContext)()),
169
+ __param(1, (0, decorators_1.EnvId)()),
170
+ __param(2, (0, decorators_1.Log)()),
171
+ __param(3, (0, decorators_1.ArgsOptions)()),
172
+ __metadata("design:type", Function),
173
+ __metadata("design:paramtypes", [Object, Object, decorators_1.Logger, Object]),
174
+ __metadata("design:returntype", Promise)
175
+ ], CloudRunDeployCommand.prototype, "execute", null);
176
+ CloudRunDeployCommand = __decorate([
177
+ (0, common_1.ICommand)()
178
+ ], CloudRunDeployCommand);
179
+ exports.CloudRunDeployCommand = CloudRunDeployCommand;
180
+ function _selectEnv() {
181
+ return __awaiter(this, void 0, void 0, function* () {
182
+ return (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
183
+ });
184
+ }
185
+ function _inputServiceName(defaultVal = '') {
186
+ return __awaiter(this, void 0, void 0, function* () {
187
+ const questions = [
188
+ {
189
+ type: 'input',
190
+ name: 'serviceName',
191
+ message: '请输入服务名称',
192
+ default: defaultVal,
193
+ validate: (val) => {
194
+ const isValid = !val.startsWith('lcap') &&
195
+ !val.startsWith('lowcode') &&
196
+ /^[A-Za-z][\w-_]{0,43}[A-Za-z0-9]$/.test(val);
197
+ return isValid
198
+ ? true
199
+ : '支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符';
200
+ }
201
+ }
202
+ ];
203
+ const answers = yield inquirer_1.default.prompt(questions);
204
+ return answers['serviceName'];
205
+ });
206
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./base"), exports);
@@ -31,3 +31,4 @@ __exportStar(require("./db"), exports);
31
31
  __exportStar(require("./fun"), exports);
32
32
  __exportStar(require("./runf"), exports);
33
33
  __exportStar(require("./cloudfunction"), exports);
34
+ __exportStar(require("./cloudrun"), exports);
@@ -24,81 +24,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
25
  };
26
26
  Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.RunfRunCommand = exports.RunfDownloadCommand = exports.RunfDeployCommand = exports.RunfListCommand = void 0;
27
+ exports.RunfRunCommand = exports.RunfDownloadCommand = exports.RunfDeployCommand = void 0;
28
28
  const functions_framework_1 = require("@cloudbase/functions-framework");
29
- const fs_extra_1 = __importDefault(require("fs-extra"));
30
- const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
31
29
  const iac_core_1 = require("@cloudbase/iac-core");
30
+ const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
32
31
  const inquirer_1 = __importDefault(require("inquirer"));
32
+ const nodemon_1 = __importDefault(require("nodemon"));
33
33
  const path_1 = __importDefault(require("path"));
34
34
  const decorators_1 = require("../../decorators");
35
- const utils_1 = require("../../utils");
36
35
  const common_1 = require("../common");
37
36
  const constants_1 = require("../constants");
38
- const utils_2 = require("../utils");
39
- const nodemon_1 = __importDefault(require("nodemon"));
37
+ const utils_1 = require("../utils");
40
38
  const { CloudAPI } = iac_core_1.CloudAPI;
41
- const scfService = utils_1.CloudApiService.getInstance('tcb');
42
- class RunfListCommand extends common_1.Command {
43
- get options() {
44
- return {
45
- cmd: 'cloudrunfunction',
46
- childCmd: 'list',
47
- options: [
48
- {
49
- flags: '-e, --envId <envId>',
50
- desc: '环境 Id'
51
- }
52
- ],
53
- requiredEnvId: false,
54
- autoRunLogin: true,
55
- desc: '查看函数式托管服务列表'
56
- };
57
- }
58
- execute(envId, log) {
59
- var _a;
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const loading = (0, utils_1.loadingFactory)();
62
- if (!envId) {
63
- envId = yield _selectEnv();
64
- }
65
- else {
66
- log.info(`当前环境 Id:${envId}`);
67
- }
68
- try {
69
- loading.start('获取函数式托管服务列表中…');
70
- let serverListRes = yield scfService
71
- .request('DescribeCloudBaseRunServers', {
72
- EnvId: envId,
73
- Limit: 100,
74
- Offset: 0
75
- })
76
- .finally(() => loading.stop());
77
- const serverList = (_a = serverListRes.CloudBaseRunServerSet) === null || _a === void 0 ? void 0 : _a.filter((item) => item.Tag === 'function');
78
- const head = ['服务名称', '状态', '创建时间', '更新时间'];
79
- const tableData = serverList.map((serverItem) => [
80
- serverItem.ServerName,
81
- serverItem.Status,
82
- serverItem.CreatedTime,
83
- serverItem.UpdatedTime
84
- ]);
85
- (0, utils_1.printHorizontalTable)(head, tableData);
86
- }
87
- catch (e) {
88
- log.error('获取函数式托管服务列表失败:' + e.message);
89
- }
90
- });
91
- }
92
- }
93
- __decorate([
94
- (0, decorators_1.InjectParams)(),
95
- __param(0, (0, decorators_1.EnvId)()),
96
- __param(1, (0, decorators_1.Log)()),
97
- __metadata("design:type", Function),
98
- __metadata("design:paramtypes", [Object, decorators_1.Logger]),
99
- __metadata("design:returntype", Promise)
100
- ], RunfListCommand.prototype, "execute", null);
101
- exports.RunfListCommand = RunfListCommand;
102
39
  let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
103
40
  get options() {
104
41
  return {
@@ -141,7 +78,7 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
141
78
  log.info(`当前环境 Id:${envId}`);
142
79
  }
143
80
  if (!serviceName) {
144
- const { shortName } = yield (0, utils_2.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
81
+ const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
145
82
  serviceName = yield _inputServiceName(shortName);
146
83
  }
147
84
  const answers = yield inquirer_1.default.prompt([
@@ -158,7 +95,7 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
158
95
  yield iac_core_1.IAC.init({
159
96
  cwd: targetDir,
160
97
  getCredential: () => {
161
- return getCredential(ctx, options);
98
+ return (0, utils_1.getCredential)(ctx, options);
162
99
  },
163
100
  polyRepoMode: true
164
101
  });
@@ -171,10 +108,10 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
171
108
  envId: envId,
172
109
  name: serviceName
173
110
  }, function (message) {
174
- trackCallback(message, log);
111
+ (0, utils_1.trackCallback)(message, log);
175
112
  });
176
113
  const { envId: _envId, name, resourceType: _resourceType } = res === null || res === void 0 ? void 0 : res.data;
177
- trackCallback({
114
+ (0, utils_1.trackCallback)({
178
115
  details: `请打开链接查看部署状态: https://tcb.cloud.tencent.com/dev?envId=${_envId}#/platform-run/service/detail?serverName=${name}&tabId=deploy&envId=${_envId}`
179
116
  }, log);
180
117
  }
@@ -207,7 +144,7 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
207
144
  yield _runDeploy();
208
145
  }
209
146
  catch (e) {
210
- trackCallback({
147
+ (0, utils_1.trackCallback)({
211
148
  type: 'error',
212
149
  details: e.message
213
150
  }, log);
@@ -216,7 +153,7 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
216
153
  }));
217
154
  }
218
155
  else {
219
- trackCallback({
156
+ (0, utils_1.trackCallback)({
220
157
  type: 'error',
221
158
  details: `${e.message}`,
222
159
  originalError: e
@@ -278,13 +215,13 @@ let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
278
215
  log.info(`当前环境 Id:${envId}`);
279
216
  }
280
217
  if (!serviceName) {
281
- const { shortName } = yield (0, utils_2.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
218
+ const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
282
219
  serviceName = yield _inputServiceName(shortName);
283
220
  if (serviceName !== shortName) {
284
221
  targetDir = path_1.default.join(targetDir, serviceName);
285
222
  }
286
223
  }
287
- const needTips = !(yield isDirectoryEmptyOrNotExists(targetDir));
224
+ const needTips = !(yield (0, utils_1.isDirectoryEmptyOrNotExists)(targetDir));
288
225
  if (needTips) {
289
226
  const answers = yield inquirer_1.default.prompt([
290
227
  {
@@ -301,7 +238,7 @@ let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
301
238
  yield iac_core_1.IAC.init({
302
239
  cwd: targetDir,
303
240
  getCredential: () => {
304
- return getCredential(ctx, options);
241
+ return (0, utils_1.getCredential)(ctx, options);
305
242
  },
306
243
  polyRepoMode: true
307
244
  });
@@ -311,11 +248,11 @@ let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
311
248
  envId: envId,
312
249
  name: serviceName
313
250
  }, function (message) {
314
- trackCallback(message, log);
251
+ (0, utils_1.trackCallback)(message, log);
315
252
  });
316
253
  }
317
254
  catch (e) {
318
- trackCallback({
255
+ (0, utils_1.trackCallback)({
319
256
  type: 'error',
320
257
  details: `${e.message}`,
321
258
  originalError: e
@@ -413,7 +350,7 @@ let RunfRunCommand = class RunfRunCommand extends common_1.Command {
413
350
  const watchFlag = ['--watch', '-w'];
414
351
  const defaultIgnoreFiles = ['logs/*.*'];
415
352
  const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(process.cwd()));
416
- const credential = yield getCredential(ctx, options);
353
+ const credential = yield (0, utils_1.getCredential)(ctx, options);
417
354
  process.env.EXTENDED_CONTEXT = JSON.stringify({
418
355
  tmpSecret: {
419
356
  secretId: credential.secretId,
@@ -478,7 +415,7 @@ RunfRunCommand = __decorate([
478
415
  exports.RunfRunCommand = RunfRunCommand;
479
416
  function _selectEnv() {
480
417
  return __awaiter(this, void 0, void 0, function* () {
481
- return (0, utils_2.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
418
+ return (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
482
419
  });
483
420
  }
484
421
  function _inputServiceName(defaultVal = '') {
@@ -503,40 +440,3 @@ function _inputServiceName(defaultVal = '') {
503
440
  return answers['serviceName'];
504
441
  });
505
442
  }
506
- function getCredential(ctx, options) {
507
- return __awaiter(this, void 0, void 0, function* () {
508
- let credential;
509
- if (ctx.hasPrivateSettings) {
510
- process.env.IS_PRIVATE = 'true';
511
- const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, options.cmd);
512
- credential = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.credential;
513
- }
514
- else {
515
- credential = yield utils_1.authSupevisor.getLoginState();
516
- }
517
- return credential;
518
- });
519
- }
520
- function isDirectoryEmptyOrNotExists(dirPath) {
521
- return __awaiter(this, void 0, void 0, function* () {
522
- try {
523
- const exists = yield fs_extra_1.default.pathExists(dirPath);
524
- if (!exists) {
525
- return true;
526
- }
527
- const files = yield fs_extra_1.default.readdir(dirPath);
528
- return files.length === 0;
529
- }
530
- catch (error) {
531
- return true;
532
- }
533
- });
534
- }
535
- function trackCallback(message, log) {
536
- if (message.type === 'error') {
537
- log.error(message.details);
538
- }
539
- else {
540
- log.info(message.details);
541
- }
542
- }
@@ -12,13 +12,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getPackageJsonName = exports.selectEnv = void 0;
15
+ exports.getCredential = exports.trackCallback = exports.isDirectoryEmptyOrNotExists = exports.getPackageJsonName = exports.selectEnv = void 0;
16
+ const fs_1 = require("@cloudbase/iac-core/lib/src/fs");
17
+ const fs_extra_1 = require("fs-extra");
18
+ const inquirer_1 = __importDefault(require("inquirer"));
16
19
  const lodash_1 = require("lodash");
17
20
  const env_1 = require("../env");
18
- const constants_1 = require("./constants");
19
- const inquirer_1 = __importDefault(require("inquirer"));
20
21
  const utils_1 = require("../utils");
21
- const fs_1 = require("@cloudbase/iac-core/lib/src/fs");
22
+ const constants_1 = require("./constants");
22
23
  function selectEnv(options = {}) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
24
25
  const loading = (0, utils_1.loadingFactory)();
@@ -59,3 +60,43 @@ function getPackageJsonName(pkgPath) {
59
60
  });
60
61
  }
61
62
  exports.getPackageJsonName = getPackageJsonName;
63
+ function isDirectoryEmptyOrNotExists(dirPath) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ try {
66
+ const exists = yield (0, fs_extra_1.pathExists)(dirPath);
67
+ if (!exists) {
68
+ return true;
69
+ }
70
+ const files = yield (0, fs_extra_1.readdir)(dirPath);
71
+ return files.length === 0;
72
+ }
73
+ catch (error) {
74
+ return true;
75
+ }
76
+ });
77
+ }
78
+ exports.isDirectoryEmptyOrNotExists = isDirectoryEmptyOrNotExists;
79
+ function trackCallback(message, log) {
80
+ if (message.type === 'error') {
81
+ log.error(message.details);
82
+ }
83
+ else {
84
+ log.info(message.details);
85
+ }
86
+ }
87
+ exports.trackCallback = trackCallback;
88
+ function getCredential(ctx, options) {
89
+ return __awaiter(this, void 0, void 0, function* () {
90
+ let credential;
91
+ if (ctx.hasPrivateSettings) {
92
+ process.env.IS_PRIVATE = 'true';
93
+ const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, options.cmd);
94
+ credential = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.credential;
95
+ }
96
+ else {
97
+ credential = yield utils_1.authSupevisor.getLoginState();
98
+ }
99
+ return credential;
100
+ });
101
+ }
102
+ exports.getCredential = getCredential;
package/lib/help.js CHANGED
@@ -21,6 +21,7 @@ const outputHelpInfo = () => {
21
21
  service [cmd] HTTP 访问服务管理操作
22
22
  run:deprecated [cmd] 云托管环境管理操作 (BAAS 或 RUN 类型环境)
23
23
  run [cmd] 云托管环境管理操作 (TCBR 类型环境)
24
+ cloudrun [cmd] 云托管服务管理操作(新版云开发平台)
24
25
  cloudrunfunction [cmd] 云函数 2.0 服务管理操作`;
25
26
  const options = `
26
27
  选项
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/cli",
3
- "version": "2.6.11",
3
+ "version": "2.6.13",
4
4
  "description": "cli tool for cloudbase",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -34,8 +34,8 @@
34
34
  "@cloudbase/cloud-api": "^0.5.5",
35
35
  "@cloudbase/framework-core": "^1.9.7",
36
36
  "@cloudbase/functions-framework": "^1.5.0",
37
- "@cloudbase/iac-core": "^0.0.3-alpha.6",
38
- "@cloudbase/lowcode-cli": "^0.22.0",
37
+ "@cloudbase/iac-core": "^0.0.3-alpha.8",
38
+ "@cloudbase/lowcode-cli": "^0.22.2",
39
39
  "@cloudbase/manager-node": "4.2.8",
40
40
  "@cloudbase/toolbox": "^0.7.5",
41
41
  "@sentry/node": "^5.10.2",
@@ -1,19 +1,5 @@
1
1
  import { Logger } from '../../decorators';
2
2
  import { Command } from '../common';
3
- export declare class CloudFunctionListCommand extends Command {
4
- get options(): {
5
- cmd: string;
6
- childCmd: string;
7
- options: {
8
- flags: string;
9
- desc: string;
10
- }[];
11
- requiredEnvId: boolean;
12
- autoRunLogin: boolean;
13
- desc: string;
14
- };
15
- execute(envId: any, log: Logger): Promise<void>;
16
- }
17
3
  export declare class CloudFunctionDeployCommand extends Command {
18
4
  get options(): {
19
5
  cmd: string;
@@ -0,0 +1,16 @@
1
+ import { Logger } from '../../decorators';
2
+ import { Command } from '../common';
3
+ export declare class CloudRunDeployCommand extends Command {
4
+ get options(): {
5
+ cmd: string;
6
+ childCmd: string;
7
+ options: {
8
+ flags: string;
9
+ desc: string;
10
+ }[];
11
+ requiredEnvId: boolean;
12
+ autoRunLogin: boolean;
13
+ desc: string;
14
+ };
15
+ execute(ctx: any, envId: any, log: Logger, options: any): Promise<void>;
16
+ }
@@ -0,0 +1 @@
1
+ export * from './base';
@@ -15,3 +15,4 @@ export * from './db';
15
15
  export * from './fun';
16
16
  export * from './runf';
17
17
  export * from './cloudfunction';
18
+ export * from './cloudrun';
@@ -1,19 +1,5 @@
1
1
  import { Logger } from '../../decorators';
2
2
  import { Command } from '../common';
3
- export declare class RunfListCommand extends Command {
4
- get options(): {
5
- cmd: string;
6
- childCmd: string;
7
- options: {
8
- flags: string;
9
- desc: string;
10
- }[];
11
- requiredEnvId: boolean;
12
- autoRunLogin: boolean;
13
- desc: string;
14
- };
15
- execute(envId: any, log: Logger): Promise<void>;
16
- }
17
3
  export declare class RunfDeployCommand extends Command {
18
4
  get options(): {
19
5
  cmd: string;
@@ -1,3 +1,4 @@
1
+ import { Logger } from '../decorators';
1
2
  export declare function selectEnv(options?: {
2
3
  source?: string[];
3
4
  }): Promise<string>;
@@ -5,3 +6,6 @@ export declare function getPackageJsonName(pkgPath: string): Promise<{
5
6
  fullName: any;
6
7
  shortName: any;
7
8
  }>;
9
+ export declare function isDirectoryEmptyOrNotExists(dirPath: string): Promise<boolean>;
10
+ export declare function trackCallback(message: any, log: Logger): void;
11
+ export declare function getCredential(ctx: any, options: any): Promise<any>;