@cloudbase/cli 2.10.0-beta.0 → 2.11.0-beta.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 (205) hide show
  1. package/lib/auth/login.js +51 -65
  2. package/lib/auth/logout.js +3 -14
  3. package/lib/commands/account/login.js +136 -149
  4. package/lib/commands/account/logout.js +3 -14
  5. package/lib/commands/ag/base.js +203 -0
  6. package/lib/commands/ag/create.js +301 -0
  7. package/lib/commands/ag/debug/index.html +699 -0
  8. package/lib/commands/ag/delete.js +200 -0
  9. package/lib/commands/ag/deploy.js +185 -0
  10. package/lib/commands/ag/detail.js +113 -0
  11. package/lib/commands/ag/index.js +22 -0
  12. package/lib/commands/ag/list.js +155 -0
  13. package/lib/commands/ag/run.js +644 -0
  14. package/lib/commands/ai/index.js +76 -95
  15. package/lib/commands/cloudfunction/base.js +182 -203
  16. package/lib/commands/cloudrun/base.js +578 -603
  17. package/lib/commands/common.js +48 -63
  18. package/lib/commands/config/delete.js +16 -27
  19. package/lib/commands/config/get.js +13 -24
  20. package/lib/commands/config/list.js +16 -27
  21. package/lib/commands/config/set.js +33 -44
  22. package/lib/commands/db/base.js +221 -240
  23. package/lib/commands/env/base.js +36 -49
  24. package/lib/commands/env/domain.js +79 -94
  25. package/lib/commands/env/login.js +120 -135
  26. package/lib/commands/framework/index.js +32 -49
  27. package/lib/commands/fun/base.js +223 -244
  28. package/lib/commands/functions/alias/getRoute.js +33 -44
  29. package/lib/commands/functions/alias/setRoute.js +36 -47
  30. package/lib/commands/functions/code-download.js +43 -54
  31. package/lib/commands/functions/code-update.js +23 -34
  32. package/lib/commands/functions/concurrency/delete.js +11 -22
  33. package/lib/commands/functions/concurrency/list.js +20 -31
  34. package/lib/commands/functions/concurrency/set.js +13 -24
  35. package/lib/commands/functions/config-update.js +30 -41
  36. package/lib/commands/functions/copy.js +12 -23
  37. package/lib/commands/functions/delete.js +30 -41
  38. package/lib/commands/functions/deploy.js +184 -202
  39. package/lib/commands/functions/detail.js +23 -34
  40. package/lib/commands/functions/invoke.js +69 -75
  41. package/lib/commands/functions/layer/bind.js +102 -105
  42. package/lib/commands/functions/layer/create.js +29 -35
  43. package/lib/commands/functions/layer/delete.js +42 -48
  44. package/lib/commands/functions/layer/download.js +52 -58
  45. package/lib/commands/functions/layer/list.js +44 -50
  46. package/lib/commands/functions/layer/sort.js +39 -45
  47. package/lib/commands/functions/list.js +25 -36
  48. package/lib/commands/functions/log.js +65 -73
  49. package/lib/commands/functions/run.js +118 -116
  50. package/lib/commands/functions/trigger-create.js +32 -43
  51. package/lib/commands/functions/trigger-delete.js +50 -61
  52. package/lib/commands/functions/version/list.js +29 -40
  53. package/lib/commands/functions/version/publish.js +11 -22
  54. package/lib/commands/gateway/create.js +50 -61
  55. package/lib/commands/gateway/delete.js +38 -49
  56. package/lib/commands/gateway/domain.js +65 -80
  57. package/lib/commands/gateway/list.js +31 -42
  58. package/lib/commands/gateway/switch.js +48 -61
  59. package/lib/commands/helpers/init.js +226 -249
  60. package/lib/commands/helpers/new.js +35 -46
  61. package/lib/commands/helpers/open.js +22 -33
  62. package/lib/commands/hosting/hosting.js +157 -178
  63. package/lib/commands/index.js +1 -0
  64. package/lib/commands/lowcode/app.js +114 -144
  65. package/lib/commands/lowcode/comps.js +136 -127
  66. package/lib/commands/lowcode/utils.js +11 -22
  67. package/lib/commands/pull/pull.js +33 -46
  68. package/lib/commands/run/delete.js +35 -46
  69. package/lib/commands/run/image/delete.js +32 -39
  70. package/lib/commands/run/image/download.js +26 -33
  71. package/lib/commands/run/image/list.js +41 -48
  72. package/lib/commands/run/image/upload.js +26 -33
  73. package/lib/commands/run/list.js +32 -43
  74. package/lib/commands/run/service/config.js +17 -28
  75. package/lib/commands/run/service/deploy.js +15 -26
  76. package/lib/commands/run/service/list.js +48 -59
  77. package/lib/commands/run/service/update.js +7 -18
  78. package/lib/commands/run/standalonegateway/create.js +35 -42
  79. package/lib/commands/run/standalonegateway/destroy.js +23 -30
  80. package/lib/commands/run/standalonegateway/list.js +19 -26
  81. package/lib/commands/run/standalonegateway/package.js +31 -38
  82. package/lib/commands/run/standalonegateway/turn.js +27 -34
  83. package/lib/commands/run/version/create.js +198 -205
  84. package/lib/commands/run/version/delete.js +31 -38
  85. package/lib/commands/run/version/list.js +42 -49
  86. package/lib/commands/run/version/modify.js +27 -34
  87. package/lib/commands/run/version/update.js +201 -208
  88. package/lib/commands/runf/base.js +216 -237
  89. package/lib/commands/self-update.js +59 -72
  90. package/lib/commands/smart.js +66 -79
  91. package/lib/commands/storage/storage.js +192 -219
  92. package/lib/commands/third/thirdAttach.js +16 -27
  93. package/lib/commands/utils.js +119 -149
  94. package/lib/db/index.js +48 -67
  95. package/lib/decorators/captureError.js +10 -21
  96. package/lib/decorators/guard.js +11 -22
  97. package/lib/decorators/injectParams.js +29 -40
  98. package/lib/decorators/params/common.js +5 -2
  99. package/lib/decorators/params/index.js +3 -12
  100. package/lib/env/domain.js +13 -28
  101. package/lib/env/index.js +25 -44
  102. package/lib/env/login.js +30 -45
  103. package/lib/function/alias.js +31 -44
  104. package/lib/function/base.js +187 -215
  105. package/lib/function/code.js +8 -19
  106. package/lib/function/concurrency.js +43 -58
  107. package/lib/function/create.js +43 -53
  108. package/lib/function/delete.js +22 -35
  109. package/lib/function/layer/attach.js +33 -46
  110. package/lib/function/layer/create.js +34 -45
  111. package/lib/function/layer/delete.js +5 -16
  112. package/lib/function/layer/download.js +11 -22
  113. package/lib/function/layer/list.js +12 -25
  114. package/lib/function/layer/sort.js +6 -17
  115. package/lib/function/trigger.js +65 -82
  116. package/lib/function/update.js +24 -32
  117. package/lib/function/version.js +29 -42
  118. package/lib/function/vpc.js +12 -25
  119. package/lib/gateway/index.js +77 -104
  120. package/lib/hosting.js +157 -188
  121. package/lib/run/delete.js +3 -12
  122. package/lib/run/image/build.js +6 -15
  123. package/lib/run/image/delete.js +3 -12
  124. package/lib/run/image/info.js +3 -12
  125. package/lib/run/image/list.js +6 -15
  126. package/lib/run/list.js +19 -30
  127. package/lib/run/repo.js +6 -15
  128. package/lib/run/service/common.js +160 -173
  129. package/lib/run/service/config.js +44 -57
  130. package/lib/run/service/deployPackage.js +33 -44
  131. package/lib/run/service/list.js +8 -14
  132. package/lib/run/service/showLogs.js +69 -90
  133. package/lib/run/service/update.js +50 -63
  134. package/lib/run/standalonegateway/create.js +3 -12
  135. package/lib/run/standalonegateway/destroy.js +3 -12
  136. package/lib/run/standalonegateway/list.js +3 -12
  137. package/lib/run/standalonegateway/package/list.js +3 -12
  138. package/lib/run/standalonegateway/turn/off.js +3 -12
  139. package/lib/run/standalonegateway/turn/on.js +3 -12
  140. package/lib/run/version/create.js +41 -31
  141. package/lib/run/version/delete.js +3 -12
  142. package/lib/run/version/list.js +3 -12
  143. package/lib/run/version/modify.js +3 -12
  144. package/lib/run/version/repo.js +6 -15
  145. package/lib/run/version/update.js +37 -26
  146. package/lib/storage.js +62 -93
  147. package/lib/third/index.js +6 -17
  148. package/lib/utils/ai/banner.js +49 -60
  149. package/lib/utils/ai/claudeWindows.js +2 -2
  150. package/lib/utils/ai/config.js +169 -206
  151. package/lib/utils/ai/ensureFiles.js +6 -17
  152. package/lib/utils/ai/env.js +16 -27
  153. package/lib/utils/ai/envLocalManager.js +35 -52
  154. package/lib/utils/ai/router.js +927 -1005
  155. package/lib/utils/ai/setup.js +527 -563
  156. package/lib/utils/auth.js +3 -14
  157. package/lib/utils/checkTcbrEnv.js +20 -31
  158. package/lib/utils/cli-table.js +6 -1
  159. package/lib/utils/config.js +4 -13
  160. package/lib/utils/dts.js +98 -113
  161. package/lib/utils/env.js +154 -175
  162. package/lib/utils/function-packer.js +29 -42
  163. package/lib/utils/log.js +10 -21
  164. package/lib/utils/mcp-config-modifier.js +105 -120
  165. package/lib/utils/net/cloud-api-request.js +15 -23
  166. package/lib/utils/net/credential.js +26 -39
  167. package/lib/utils/net/http-request.js +63 -80
  168. package/lib/utils/net/manager-service.js +22 -35
  169. package/lib/utils/notice.js +16 -27
  170. package/lib/utils/output/loading.js +3 -12
  171. package/lib/utils/parallel.js +32 -43
  172. package/lib/utils/platform/mac.js +4 -15
  173. package/lib/utils/platform/port.js +4 -15
  174. package/lib/utils/prompt/select.js +6 -15
  175. package/lib/utils/report.js +28 -33
  176. package/lib/utils/reporter/agree.js +11 -22
  177. package/lib/utils/reporter/download.js +17 -28
  178. package/lib/utils/reporter/usage.js +12 -23
  179. package/lib/utils/store/auth.js +17 -30
  180. package/lib/utils/store/config.js +11 -25
  181. package/lib/utils/store/db.js +17 -36
  182. package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
  183. package/lib/utils/template-manager.js +215 -242
  184. package/lib/utils/template.js +81 -96
  185. package/lib/utils/tools/common.js +45 -56
  186. package/lib/utils/tools/time.js +5 -16
  187. package/lib/utils/url.js +10 -4
  188. package/package.json +2 -2
  189. package/specs/ag-command/design.md +421 -0
  190. package/specs/ag-command/doc.md +204 -0
  191. package/specs/ag-command/requirements.md +173 -0
  192. package/specs/ag-command/summary.md +174 -0
  193. package/specs/ag-command/tasks.md +197 -0
  194. package/specs/ag-command/usage-guide.md +420 -0
  195. package/tsconfig.json +1 -1
  196. package/types/commands/ag/base.d.ts +44 -0
  197. package/types/commands/ag/create.d.ts +25 -0
  198. package/types/commands/ag/delete.d.ts +32 -0
  199. package/types/commands/ag/deploy.d.ts +31 -0
  200. package/types/commands/ag/detail.d.ts +28 -0
  201. package/types/commands/ag/index.d.ts +6 -0
  202. package/types/commands/ag/list.d.ts +35 -0
  203. package/types/commands/ag/run.d.ts +52 -0
  204. package/types/commands/cloudrun/base.d.ts +10 -0
  205. package/types/commands/index.d.ts +1 -0
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
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
14
  var __importDefault = (this && this.__importDefault) || function (mod) {
24
15
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
16
  };
@@ -32,7 +23,7 @@ const inquirer_1 = __importDefault(require("inquirer"));
32
23
  const nodemon = (() => { try {
33
24
  return require('nodemon');
34
25
  }
35
- catch (_a) {
26
+ catch {
36
27
  return null;
37
28
  } })();
38
29
  const path_1 = __importDefault(require("path"));
@@ -67,109 +58,105 @@ let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
67
58
  desc: (0, i18n_1.t)('部署云函数 2.0 服务')
68
59
  };
69
60
  }
70
- execute(ctx, envId, log, options) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- let { serviceName, source } = options;
73
- const targetDir = path_1.default.resolve(source || process.cwd());
74
- if (!envId) {
75
- const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
76
- if (envConfig.envId) {
77
- envId = envConfig.envId;
78
- log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
79
- }
80
- else {
81
- envId = yield _selectEnv();
82
- }
61
+ async execute(ctx, envId, log, options) {
62
+ let { serviceName, source } = options;
63
+ const targetDir = path_1.default.resolve(source || process.cwd());
64
+ if (!envId) {
65
+ const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(targetDir));
66
+ if (envConfig.envId) {
67
+ envId = envConfig.envId;
68
+ log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
83
69
  }
84
70
  else {
85
- log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
71
+ envId = await _selectEnv();
86
72
  }
87
- if (!serviceName) {
88
- const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
89
- serviceName = yield _inputServiceName(shortName);
73
+ }
74
+ else {
75
+ log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
76
+ }
77
+ if (!serviceName) {
78
+ const { shortName } = await (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
79
+ serviceName = await _inputServiceName(shortName);
80
+ }
81
+ const answers = await inquirer_1.default.prompt([
82
+ {
83
+ type: 'confirm',
84
+ name: 'confirm',
85
+ message: (0, i18n_1.t)('即将开始部署,是否确认继续?'),
86
+ default: true
90
87
  }
91
- const answers = yield inquirer_1.default.prompt([
92
- {
93
- type: 'confirm',
94
- name: 'confirm',
95
- message: (0, i18n_1.t)('即将开始部署,是否确认继续?'),
96
- default: true
97
- }
98
- ]);
99
- if (!answers.confirm) {
100
- return;
88
+ ]);
89
+ if (!answers.confirm) {
90
+ return;
91
+ }
92
+ await iac_core_1.IAC.init({
93
+ cwd: targetDir,
94
+ getCredential: () => {
95
+ return (0, utils_1.getCredential)(ctx, options);
96
+ },
97
+ polyRepoMode: true
98
+ });
99
+ await _runDeploy();
100
+ async function _runDeploy() {
101
+ try {
102
+ const res = await iac_core_1.IAC.FunctionV2.apply({
103
+ cwd: targetDir,
104
+ envId: envId,
105
+ name: serviceName
106
+ }, function (message) {
107
+ (0, utils_1.trackCallback)(message, log);
108
+ });
109
+ const { envId: _envId, name, resourceType: _resourceType } = res === null || res === void 0 ? void 0 : res.data;
110
+ (0, utils_1.trackCallback)({
111
+ details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_2.EUrl.DevPlatform}?envId=${_envId}#/platform-run/service/detail?serverName=${name}&tabId=deploy&envId=${_envId}` })
112
+ }, log);
101
113
  }
102
- yield iac_core_1.IAC.init({
103
- cwd: targetDir,
104
- getCredential: () => {
105
- return (0, utils_1.getCredential)(ctx, options);
106
- },
107
- polyRepoMode: true
108
- });
109
- yield _runDeploy();
110
- function _runDeploy() {
111
- return __awaiter(this, void 0, void 0, function* () {
112
- try {
113
- const res = yield iac_core_1.IAC.FunctionV2.apply({
114
- cwd: targetDir,
115
- envId: envId,
116
- name: serviceName
117
- }, function (message) {
118
- (0, utils_1.trackCallback)(message, log);
119
- });
120
- const { envId: _envId, name, resourceType: _resourceType } = res === null || res === void 0 ? void 0 : res.data;
121
- (0, utils_1.trackCallback)({
122
- details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_2.EUrl.DevPlatform}?envId=${_envId}#/platform-run/service/detail?serverName=${name}&tabId=deploy&envId=${_envId}` })
123
- }, log);
124
- }
125
- catch (e) {
126
- if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateCloudRunServer' && (e === null || e === void 0 ? void 0 : e.code) === 'ResourceInUse') {
127
- inquirer_1.default
128
- .prompt([
129
- {
130
- type: 'confirm',
131
- name: 'confirm',
132
- message: (0, i18n_1.t)('平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码'),
133
- default: true
134
- }
135
- ])
136
- .then((answers) => __awaiter(this, void 0, void 0, function* () {
137
- if (answers.confirm) {
138
- try {
139
- const { task } = yield CloudAPI.tcbrServiceRequest('DescribeServerManageTask', {
140
- envId,
141
- serverName: serviceName,
142
- taskId: 0
143
- });
144
- const id = task === null || task === void 0 ? void 0 : task.id;
145
- yield CloudAPI.tcbrServiceRequest('OperateServerManage', {
146
- envId,
147
- operateType: 'cancel',
148
- serverName: serviceName,
149
- taskId: id
150
- });
151
- yield _runDeploy();
152
- }
153
- catch (e) {
154
- (0, utils_1.trackCallback)({
155
- type: 'error',
156
- details: e.message
157
- }, log);
158
- }
159
- }
160
- }));
114
+ catch (e) {
115
+ if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateCloudRunServer' && (e === null || e === void 0 ? void 0 : e.code) === 'ResourceInUse') {
116
+ inquirer_1.default
117
+ .prompt([
118
+ {
119
+ type: 'confirm',
120
+ name: 'confirm',
121
+ message: (0, i18n_1.t)('平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码'),
122
+ default: true
161
123
  }
162
- else {
163
- (0, utils_1.trackCallback)({
164
- type: 'error',
165
- details: `${e.message}`,
166
- originalError: e
167
- }, log);
124
+ ])
125
+ .then(async (answers) => {
126
+ if (answers.confirm) {
127
+ try {
128
+ const { task } = await CloudAPI.tcbrServiceRequest('DescribeServerManageTask', {
129
+ envId,
130
+ serverName: serviceName,
131
+ taskId: 0
132
+ });
133
+ const id = task === null || task === void 0 ? void 0 : task.id;
134
+ await CloudAPI.tcbrServiceRequest('OperateServerManage', {
135
+ envId,
136
+ operateType: 'cancel',
137
+ serverName: serviceName,
138
+ taskId: id
139
+ });
140
+ await _runDeploy();
141
+ }
142
+ catch (e) {
143
+ (0, utils_1.trackCallback)({
144
+ type: 'error',
145
+ details: e.message
146
+ }, log);
147
+ }
168
148
  }
169
- }
170
- });
149
+ });
150
+ }
151
+ else {
152
+ (0, utils_1.trackCallback)({
153
+ type: 'error',
154
+ details: `${e.message}`,
155
+ originalError: e
156
+ }, log);
157
+ }
171
158
  }
172
- });
159
+ }
173
160
  }
174
161
  };
175
162
  __decorate([
@@ -210,62 +197,60 @@ let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
210
197
  desc: (0, i18n_1.t)('下载云函数 2.0 服务代码')
211
198
  };
212
199
  }
213
- execute(ctx, envId, log, options) {
214
- return __awaiter(this, void 0, void 0, function* () {
215
- let { serviceName, source } = options;
216
- let targetDir = path_1.default.resolve(source || process.cwd());
217
- if (!envId) {
218
- const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
219
- envId = envConfig.envId || (yield _selectEnv());
220
- }
221
- else {
222
- log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
200
+ async execute(ctx, envId, log, options) {
201
+ let { serviceName, source } = options;
202
+ let targetDir = path_1.default.resolve(source || process.cwd());
203
+ if (!envId) {
204
+ const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(targetDir));
205
+ envId = envConfig.envId || (await _selectEnv());
206
+ }
207
+ else {
208
+ log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
209
+ }
210
+ if (!serviceName) {
211
+ const { shortName } = await (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
212
+ serviceName = await _inputServiceName(shortName);
213
+ if (serviceName !== shortName) {
214
+ targetDir = path_1.default.join(targetDir, serviceName);
223
215
  }
224
- if (!serviceName) {
225
- const { shortName } = yield (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
226
- serviceName = yield _inputServiceName(shortName);
227
- if (serviceName !== shortName) {
228
- targetDir = path_1.default.join(targetDir, serviceName);
229
- }
230
- }
231
- const needTips = !(yield (0, utils_1.isDirectoryEmptyOrNotExists)(targetDir));
232
- if (needTips) {
233
- const answers = yield inquirer_1.default.prompt([
234
- {
235
- type: 'confirm',
236
- name: 'confirm',
237
- message: (0, i18n_1.t)('下载将覆盖 {{targetDir}} 目录下的代码,是否继续?', { targetDir }),
238
- default: true
239
- }
240
- ]);
241
- if (!answers.confirm) {
242
- return;
216
+ }
217
+ const needTips = !(await (0, utils_1.isDirectoryEmptyOrNotExists)(targetDir));
218
+ if (needTips) {
219
+ const answers = await inquirer_1.default.prompt([
220
+ {
221
+ type: 'confirm',
222
+ name: 'confirm',
223
+ message: (0, i18n_1.t)('下载将覆盖 {{targetDir}} 目录下的代码,是否继续?', { targetDir }),
224
+ default: true
243
225
  }
226
+ ]);
227
+ if (!answers.confirm) {
228
+ return;
244
229
  }
245
- yield iac_core_1.IAC.init({
230
+ }
231
+ await iac_core_1.IAC.init({
232
+ cwd: targetDir,
233
+ getCredential: () => {
234
+ return (0, utils_1.getCredential)(ctx, options);
235
+ },
236
+ polyRepoMode: true
237
+ });
238
+ try {
239
+ await iac_core_1.IAC.FunctionV2.pull({
246
240
  cwd: targetDir,
247
- getCredential: () => {
248
- return (0, utils_1.getCredential)(ctx, options);
249
- },
250
- polyRepoMode: true
241
+ envId: envId,
242
+ name: serviceName
243
+ }, function (message) {
244
+ (0, utils_1.trackCallback)(message, log);
251
245
  });
252
- try {
253
- yield iac_core_1.IAC.FunctionV2.pull({
254
- cwd: targetDir,
255
- envId: envId,
256
- name: serviceName
257
- }, function (message) {
258
- (0, utils_1.trackCallback)(message, log);
259
- });
260
- }
261
- catch (e) {
262
- (0, utils_1.trackCallback)({
263
- type: 'error',
264
- details: `${e.message}`,
265
- originalError: e
266
- }, log);
267
- }
268
- });
246
+ }
247
+ catch (e) {
248
+ (0, utils_1.trackCallback)({
249
+ type: 'error',
250
+ details: `${e.message}`,
251
+ originalError: e
252
+ }, log);
253
+ }
269
254
  }
270
255
  };
271
256
  __decorate([
@@ -351,64 +336,62 @@ let RunfRunCommand = class RunfRunCommand extends common_1.Command {
351
336
  desc: (0, i18n_1.t)('本地运行云函数 2.0 代码')
352
337
  };
353
338
  }
354
- execute(logger, ctx, options) {
355
- return __awaiter(this, void 0, void 0, function* () {
356
- const args = process.argv.slice(2);
357
- const watchFlag = ['--watch', '-w'];
358
- const defaultIgnoreFiles = ['logs/*.*'];
359
- const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(process.cwd()));
360
- const credential = yield (0, utils_1.getCredential)(ctx, options);
361
- process.env.EXTENDED_CONTEXT = JSON.stringify({
362
- tmpSecret: {
363
- secretId: credential.secretId,
364
- secretKey: credential.secretKey,
365
- token: credential.token
366
- },
367
- source: 'local_dev',
368
- envId: envConfig.envId
369
- });
370
- if (watchFlag.some((flag) => args.includes(flag))) {
371
- const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
372
- if (!nodemon) {
373
- throw new Error((0, i18n_1.t)('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。'));
374
- }
375
- nodemon({
376
- script: '',
377
- exec: `${process.argv[1]} ${cmd}`,
378
- watchOptions: {
379
- usePolling: true,
380
- ignorePermissionErrors: true,
381
- ignored: defaultIgnoreFiles.join(','),
382
- persistent: true,
383
- interval: 500
384
- }
385
- })
386
- .on('start', () => {
387
- logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
388
- })
389
- .on('quit', (e) => {
390
- logger.info(`Nodemon quit with code ${e}.`);
391
- process.exit(0);
392
- })
393
- .on('restart', (e) => {
394
- var _a, _b;
395
- logger.info(`Server restarted due to changed files: ${(_b = (_a = e === null || e === void 0 ? void 0 : e.matched) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.join(', ')}`);
396
- })
397
- .on('log', (e) => {
398
- logger.info(`[nodemon ${e.type}] ${e.message}`);
399
- })
400
- .on('crash', () => {
401
- logger.error('Server crashed.');
402
- process.exit(1);
403
- })
404
- .on('exit', (e) => {
405
- logger.info(`Server exited with code ${e}.`);
406
- });
407
- }
408
- else {
409
- (0, functions_framework_1.runCLI)();
410
- }
339
+ async execute(logger, ctx, options) {
340
+ const args = process.argv.slice(2);
341
+ const watchFlag = ['--watch', '-w'];
342
+ const defaultIgnoreFiles = ['logs/*.*'];
343
+ const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(process.cwd()));
344
+ const credential = await (0, utils_1.getCredential)(ctx, options);
345
+ process.env.EXTENDED_CONTEXT = JSON.stringify({
346
+ tmpSecret: {
347
+ secretId: credential.secretId,
348
+ secretKey: credential.secretKey,
349
+ token: credential.token
350
+ },
351
+ source: 'local_dev',
352
+ envId: envConfig.envId
411
353
  });
354
+ if (watchFlag.some((flag) => args.includes(flag))) {
355
+ const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
356
+ if (!nodemon) {
357
+ throw new Error((0, i18n_1.t)('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。'));
358
+ }
359
+ nodemon({
360
+ script: '',
361
+ exec: `${process.argv[1]} ${cmd}`,
362
+ watchOptions: {
363
+ usePolling: true,
364
+ ignorePermissionErrors: true,
365
+ ignored: defaultIgnoreFiles.join(','),
366
+ persistent: true,
367
+ interval: 500
368
+ }
369
+ })
370
+ .on('start', () => {
371
+ logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
372
+ })
373
+ .on('quit', (e) => {
374
+ logger.info(`Nodemon quit with code ${e}.`);
375
+ process.exit(0);
376
+ })
377
+ .on('restart', (e) => {
378
+ var _a, _b;
379
+ logger.info(`Server restarted due to changed files: ${(_b = (_a = e === null || e === void 0 ? void 0 : e.matched) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.join(', ')}`);
380
+ })
381
+ .on('log', (e) => {
382
+ logger.info(`[nodemon ${e.type}] ${e.message}`);
383
+ })
384
+ .on('crash', () => {
385
+ logger.error('Server crashed.');
386
+ process.exit(1);
387
+ })
388
+ .on('exit', (e) => {
389
+ logger.info(`Server exited with code ${e}.`);
390
+ });
391
+ }
392
+ else {
393
+ (0, functions_framework_1.runCLI)();
394
+ }
412
395
  }
413
396
  };
414
397
  __decorate([
@@ -424,30 +407,26 @@ RunfRunCommand = __decorate([
424
407
  (0, common_1.ICommand)()
425
408
  ], RunfRunCommand);
426
409
  exports.RunfRunCommand = RunfRunCommand;
427
- function _selectEnv() {
428
- return __awaiter(this, void 0, void 0, function* () {
429
- return (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
430
- });
410
+ async function _selectEnv() {
411
+ return (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
431
412
  }
432
- function _inputServiceName(defaultVal = '') {
433
- return __awaiter(this, void 0, void 0, function* () {
434
- const questions = [
435
- {
436
- type: 'input',
437
- name: 'serviceName',
438
- message: (0, i18n_1.t)('请输入服务名称'),
439
- default: defaultVal,
440
- validate: (val) => {
441
- const isValid = !val.startsWith('lcap') &&
442
- !val.startsWith('lowcode') &&
443
- /^[A-Za-z][\w-_]{0,43}[A-Za-z0-9]$/.test(val);
444
- return isValid
445
- ? true
446
- : (0, i18n_1.t)('支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符');
447
- }
413
+ async function _inputServiceName(defaultVal = '') {
414
+ const questions = [
415
+ {
416
+ type: 'input',
417
+ name: 'serviceName',
418
+ message: (0, i18n_1.t)('请输入服务名称'),
419
+ default: defaultVal,
420
+ validate: (val) => {
421
+ const isValid = !val.startsWith('lcap') &&
422
+ !val.startsWith('lowcode') &&
423
+ /^[A-Za-z][\w-_]{0,43}[A-Za-z0-9]$/.test(val);
424
+ return isValid
425
+ ? true
426
+ : (0, i18n_1.t)('支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符');
448
427
  }
449
- ];
450
- const answers = yield inquirer_1.default.prompt(questions);
451
- return answers['serviceName'];
452
- });
428
+ }
429
+ ];
430
+ const answers = await inquirer_1.default.prompt(questions);
431
+ return answers['serviceName'];
453
432
  }