@cloudbase/cli 2.10.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
  };
@@ -61,7 +52,10 @@ function spawnNodeProcess(args, options) {
61
52
  cwd: path_1.default.dirname(bootstrapFilePath),
62
53
  windowsHide: true
63
54
  };
64
- const exec = (0, child_process_1.spawn)('node', args, Object.assign(Object.assign({}, commonOptions), options));
55
+ const exec = (0, child_process_1.spawn)('node', args, {
56
+ ...commonOptions,
57
+ ...options
58
+ });
65
59
  exec.on('error', (e) => {
66
60
  console.log((0, i18n_1.t)('进程执行异常:{{message}}', { message: e.message }));
67
61
  setTimeout(() => { }, 100);
@@ -78,110 +72,120 @@ function spawnNodeProcess(args, options) {
78
72
  }
79
73
  });
80
74
  }
81
- function getSecret() {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- const credential = yield (0, utils_1.checkAndGetCredential)();
84
- if (lodash_1.default.isEmpty(credential)) {
85
- console.log((0, i18n_1.t)('未登录,无法直接调用 Node SDK'));
86
- return {};
87
- }
88
- const { secretId, secretKey, token } = credential;
89
- return {
90
- TENCENTCLOUD_SECRETID: secretId,
91
- TENCENTCLOUD_SECRETKEY: secretKey,
92
- TENCENTCLOUD_SESSIONTOKEN: token
93
- };
94
- });
75
+ async function getSecret() {
76
+ const credential = await (0, utils_1.checkAndGetCredential)();
77
+ if (lodash_1.default.isEmpty(credential)) {
78
+ console.log((0, i18n_1.t)('未登录,无法直接调用 Node SDK'));
79
+ return {};
80
+ }
81
+ const { secretId, secretKey, token } = credential;
82
+ return {
83
+ TENCENTCLOUD_SECRETID: secretId,
84
+ TENCENTCLOUD_SECRETKEY: secretKey,
85
+ TENCENTCLOUD_SESSIONTOKEN: token
86
+ };
95
87
  }
96
- function debugFunctionByPath(functionPath, options) {
97
- return __awaiter(this, void 0, void 0, function* () {
98
- const { params, debug, port } = options;
99
- params && checkJSON(params);
100
- const filePath = path_1.default.resolve(functionPath);
101
- (0, utils_1.checkFullAccess)(filePath);
102
- let debugDirname;
103
- const isDir = (0, utils_1.isDirectory)(filePath);
104
- if (isDir) {
105
- const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, 'index.js'));
106
- if (!exists) {
107
- errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
108
- }
109
- debugDirname = filePath;
88
+ async function debugFunctionByPath(functionPath, options) {
89
+ const { params, debug, port } = options;
90
+ params && checkJSON(params);
91
+ const filePath = path_1.default.resolve(functionPath);
92
+ (0, utils_1.checkFullAccess)(filePath);
93
+ let debugDirname;
94
+ const isDir = (0, utils_1.isDirectory)(filePath);
95
+ if (isDir) {
96
+ const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, 'index.js'));
97
+ if (!exists) {
98
+ errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
110
99
  }
111
- else {
112
- const { base, dir } = path_1.default.parse(filePath);
113
- if (base !== 'index.js') {
114
- errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
115
- }
116
- debugDirname = dir;
100
+ debugDirname = filePath;
101
+ }
102
+ else {
103
+ const { base, dir } = path_1.default.parse(filePath);
104
+ if (base !== 'index.js') {
105
+ errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
117
106
  }
118
- try {
119
- const fileExports = require(path_1.default.join(debugDirname, 'index.js'));
120
- if (!fileExports.main) {
121
- errorLog((0, i18n_1.t)('main 方法不存在!'), debug);
122
- }
107
+ debugDirname = dir;
108
+ }
109
+ try {
110
+ const fileExports = require(path_1.default.join(debugDirname, 'index.js'));
111
+ if (!fileExports.main) {
112
+ errorLog((0, i18n_1.t)('main 方法不存在!'), debug);
123
113
  }
124
- catch (e) {
125
- errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
114
+ }
115
+ catch (e) {
116
+ errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
117
+ }
118
+ const secret = await getSecret();
119
+ const debugArgs = getDebugArgs(port);
120
+ const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
121
+ console.log((0, i18n_1.t)('> 以默认配置启动 Node 云函数调试'));
122
+ spawnNodeProcess(args, {
123
+ env: {
124
+ ...process.env,
125
+ SCF_FUNCTION_HANDLER: 'index.main',
126
+ SCF_FUNCTION_NAME: 'main',
127
+ GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep),
128
+ SCF_EVENT_BODY: params || '{}',
129
+ ...secret
126
130
  }
127
- const secret = yield getSecret();
128
- const debugArgs = getDebugArgs(port);
129
- const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
130
- console.log((0, i18n_1.t)('> 以默认配置启动 Node 云函数调试'));
131
- spawnNodeProcess(args, {
132
- env: Object.assign(Object.assign(Object.assign({}, process.env), { SCF_FUNCTION_HANDLER: 'index.main', SCF_FUNCTION_NAME: 'main', GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep), SCF_EVENT_BODY: params || '{}' }), secret)
133
- });
134
131
  });
135
132
  }
136
133
  exports.debugFunctionByPath = debugFunctionByPath;
137
- function debugByConfig(ctx, name) {
138
- return __awaiter(this, void 0, void 0, function* () {
139
- const { config, options, envId } = ctx;
140
- const { params, debug, port } = options;
141
- params && checkJSON(params);
142
- let functionPath = path_1.default.resolve(config.functionRoot, name);
143
- const filePath = path_1.default.resolve(functionPath);
144
- (0, utils_1.checkFullAccess)(filePath, !debug);
145
- let debugDirname;
146
- const funcConfig = config.functions.find((item) => item.name === name);
147
- const handlers = ((funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.handler) || 'index.main').split('.');
148
- const indexFileName = handlers[0];
149
- const indexFile = `${indexFileName}.js`;
150
- const mainFunction = handlers[1];
151
- const isDir = (0, utils_1.isDirectory)(filePath);
152
- if (isDir) {
153
- const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, indexFile));
154
- if (!exists) {
155
- errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
156
- }
157
- debugDirname = filePath;
134
+ async function debugByConfig(ctx, name) {
135
+ const { config, options, envId } = ctx;
136
+ const { params, debug, port } = options;
137
+ params && checkJSON(params);
138
+ let functionPath = path_1.default.resolve(config.functionRoot, name);
139
+ const filePath = path_1.default.resolve(functionPath);
140
+ (0, utils_1.checkFullAccess)(filePath, !debug);
141
+ let debugDirname;
142
+ const funcConfig = config.functions.find((item) => item.name === name);
143
+ const handlers = ((funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.handler) || 'index.main').split('.');
144
+ const indexFileName = handlers[0];
145
+ const indexFile = `${indexFileName}.js`;
146
+ const mainFunction = handlers[1];
147
+ const isDir = (0, utils_1.isDirectory)(filePath);
148
+ if (isDir) {
149
+ const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, indexFile));
150
+ if (!exists) {
151
+ errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
158
152
  }
159
- else {
160
- const { base, dir } = path_1.default.parse(filePath);
161
- if (base !== indexFile) {
162
- errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
163
- }
164
- debugDirname = dir;
153
+ debugDirname = filePath;
154
+ }
155
+ else {
156
+ const { base, dir } = path_1.default.parse(filePath);
157
+ if (base !== indexFile) {
158
+ errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
165
159
  }
166
- try {
167
- const finalPath = path_1.default.join(debugDirname, indexFile);
168
- const requirePath = process.platform === 'win32'
169
- ? finalPath.replace(/\\/g, '\\\\')
170
- : finalPath;
171
- const fileExports = require(requirePath);
172
- if (!fileExports[mainFunction]) {
173
- errorLog((0, i18n_1.t)('handler 中的 {{mainFunction}} 方法不存在,请检查你的配置!', { mainFunction }), debug);
174
- }
160
+ debugDirname = dir;
161
+ }
162
+ try {
163
+ const finalPath = path_1.default.join(debugDirname, indexFile);
164
+ const requirePath = process.platform === 'win32'
165
+ ? finalPath.replace(/\\/g, '\\\\')
166
+ : finalPath;
167
+ const fileExports = require(requirePath);
168
+ if (!fileExports[mainFunction]) {
169
+ errorLog((0, i18n_1.t)('handler 中的 {{mainFunction}} 方法不存在,请检查你的配置!', { mainFunction }), debug);
175
170
  }
176
- catch (e) {
177
- errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
171
+ }
172
+ catch (e) {
173
+ errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
174
+ }
175
+ const secret = await getSecret();
176
+ const debugArgs = getDebugArgs(port);
177
+ const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
178
+ spawnNodeProcess(args, {
179
+ env: {
180
+ ...process.env,
181
+ SCF_NAMESPACE: envId,
182
+ SCF_FUNCTION_HANDLER: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.handler) || 'index.main',
183
+ SCF_FUNCTION_NAME: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.name) || 'main',
184
+ GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep),
185
+ SCF_EVENT_BODY: params || JSON.stringify((funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.params) || {}),
186
+ ...funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.envVariables,
187
+ ...secret
178
188
  }
179
- const secret = yield getSecret();
180
- const debugArgs = getDebugArgs(port);
181
- const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
182
- spawnNodeProcess(args, {
183
- env: Object.assign(Object.assign(Object.assign(Object.assign({}, process.env), { SCF_NAMESPACE: envId, SCF_FUNCTION_HANDLER: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.handler) || 'index.main', SCF_FUNCTION_NAME: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.name) || 'main', GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep), SCF_EVENT_BODY: params || JSON.stringify((funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.params) || {}) }), funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.envVariables), secret)
184
- });
185
189
  });
186
190
  }
187
191
  exports.debugByConfig = debugByConfig;
@@ -216,20 +220,18 @@ let FunctionDebug = class FunctionDebug extends common_1.Command {
216
220
  desc: (0, i18n_1.t)('本地运行云函数(当前仅支持 Node)')
217
221
  };
218
222
  }
219
- execute(ctx) {
220
- return __awaiter(this, void 0, void 0, function* () {
221
- const { options } = ctx;
222
- const { path, name } = options;
223
- if (path) {
224
- yield debugFunctionByPath(path, options);
225
- }
226
- else if (typeof name === 'string') {
227
- yield debugByConfig(ctx, name);
228
- }
229
- else {
230
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定运行函数的名称或函数的路径\n\n例如 cloudbase functions:run --name app'));
231
- }
232
- });
223
+ async execute(ctx) {
224
+ const { options } = ctx;
225
+ const { path, name } = options;
226
+ if (path) {
227
+ await debugFunctionByPath(path, options);
228
+ }
229
+ else if (typeof name === 'string') {
230
+ await debugByConfig(ctx, name);
231
+ }
232
+ else {
233
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定运行函数的名称或函数的路径\n\n例如 cloudbase functions:run --name app'));
234
+ }
233
235
  }
234
236
  };
235
237
  __decorate([
@@ -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
  };
@@ -48,41 +39,39 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
48
39
  desc: (0, i18n_1.t)('创建云函数触发器')
49
40
  };
50
41
  }
51
- execute(ctx, params) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const { envId, config: { functions } } = ctx;
54
- const name = params === null || params === void 0 ? void 0 : params[0];
55
- const functionService = yield (0, function_1.getFunctionService)(envId);
56
- let isBatchCreateTrigger = false;
57
- if (!name) {
58
- const { isBatch } = yield inquirer_1.default.prompt({
59
- type: 'confirm',
60
- name: 'isBatch',
61
- message: (0, i18n_1.t)('无云函数名称,是否需要部署配置文件中的【全部云函数】的全部触发器?'),
62
- default: false
63
- });
64
- isBatchCreateTrigger = isBatch;
65
- if (!isBatchCreateTrigger) {
66
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
67
- }
68
- }
69
- if (isBatchCreateTrigger) {
70
- return functionService.batchCreateTriggers({
71
- envId,
72
- functions
73
- });
74
- }
75
- const functionItem = functions.find((item) => item.name === name);
76
- if (!functionItem) {
77
- throw new error_1.CloudBaseError((0, i18n_1.t)('未找到相关函数配置,请检查函数名是否正确'));
78
- }
79
- const { triggers } = functionItem;
80
- if (!triggers || !triggers.length) {
81
- throw new error_1.CloudBaseError((0, i18n_1.t)('触发器配置不能为空'));
42
+ async execute(ctx, params) {
43
+ const { envId, config: { functions } } = ctx;
44
+ const name = params === null || params === void 0 ? void 0 : params[0];
45
+ const functionService = await (0, function_1.getFunctionService)(envId);
46
+ let isBatchCreateTrigger = false;
47
+ if (!name) {
48
+ const { isBatch } = await inquirer_1.default.prompt({
49
+ type: 'confirm',
50
+ name: 'isBatch',
51
+ message: (0, i18n_1.t)('无云函数名称,是否需要部署配置文件中的【全部云函数】的全部触发器?'),
52
+ default: false
53
+ });
54
+ isBatchCreateTrigger = isBatch;
55
+ if (!isBatchCreateTrigger) {
56
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
82
57
  }
83
- yield functionService.createFunctionTriggers(name, triggers);
84
- (0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 创建云函数触发器成功!', { name }));
85
- });
58
+ }
59
+ if (isBatchCreateTrigger) {
60
+ return functionService.batchCreateTriggers({
61
+ envId,
62
+ functions
63
+ });
64
+ }
65
+ const functionItem = functions.find((item) => item.name === name);
66
+ if (!functionItem) {
67
+ throw new error_1.CloudBaseError((0, i18n_1.t)('未找到相关函数配置,请检查函数名是否正确'));
68
+ }
69
+ const { triggers } = functionItem;
70
+ if (!triggers || !triggers.length) {
71
+ throw new error_1.CloudBaseError((0, i18n_1.t)('触发器配置不能为空'));
72
+ }
73
+ await functionService.createFunctionTriggers(name, triggers);
74
+ (0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 创建云函数触发器成功!', { name }));
86
75
  }
87
76
  };
88
77
  __decorate([
@@ -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
  };
@@ -47,64 +38,62 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
47
38
  desc: (0, i18n_1.t)('删除云函数触发器')
48
39
  };
49
40
  }
50
- execute(ctx, params) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const { envId, config: { functions } } = ctx;
53
- const name = params === null || params === void 0 ? void 0 : params[0];
54
- const triggerName = params === null || params === void 0 ? void 0 : params[1];
55
- const functionService = yield (0, function_1.getFunctionService)(envId);
56
- let isBatchDeleteTriggers;
57
- let isBatchDeleteFunctionTriggers = false;
58
- if (!name) {
59
- const answer = yield inquirer_1.default.prompt({
41
+ async execute(ctx, params) {
42
+ const { envId, config: { functions } } = ctx;
43
+ const name = params === null || params === void 0 ? void 0 : params[0];
44
+ const triggerName = params === null || params === void 0 ? void 0 : params[1];
45
+ const functionService = await (0, function_1.getFunctionService)(envId);
46
+ let isBatchDeleteTriggers;
47
+ let isBatchDeleteFunctionTriggers = false;
48
+ if (!name) {
49
+ const answer = await inquirer_1.default.prompt({
50
+ type: 'confirm',
51
+ name: 'isBatch',
52
+ message: (0, i18n_1.t)('无云函数名称,是否需要删除配置文件中的【全部云函数】的全部触发器?'),
53
+ default: false
54
+ });
55
+ if (answer.isBatch) {
56
+ const { reConfirm } = await inquirer_1.default.prompt({
60
57
  type: 'confirm',
61
- name: 'isBatch',
62
- message: (0, i18n_1.t)('无云函数名称,是否需要删除配置文件中的【全部云函数】的全部触发器?'),
58
+ name: 'reConfirm',
59
+ message: (0, i18n_1.t)('确定要删除配置文件中的【全部云函数】的全部触发器?'),
63
60
  default: false
64
61
  });
65
- if (answer.isBatch) {
66
- const { reConfirm } = yield inquirer_1.default.prompt({
67
- type: 'confirm',
68
- name: 'reConfirm',
69
- message: (0, i18n_1.t)('确定要删除配置文件中的【全部云函数】的全部触发器?'),
70
- default: false
71
- });
72
- isBatchDeleteTriggers = reConfirm;
73
- }
74
- if (!isBatchDeleteTriggers) {
75
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
76
- }
77
- }
78
- if (isBatchDeleteTriggers) {
79
- return functionService.batchDeleteTriggers({
80
- envId,
81
- functions
82
- });
62
+ isBatchDeleteTriggers = reConfirm;
83
63
  }
84
- if (!triggerName && name) {
85
- const { isBatch } = yield inquirer_1.default.prompt({
86
- type: 'confirm',
87
- name: 'isBatch',
88
- message: (0, i18n_1.t)('没有指定触发器名称,是否需要此云函数的全部触发器?'),
89
- default: false
90
- });
91
- isBatchDeleteFunctionTriggers = isBatch;
92
- if (!isBatchDeleteFunctionTriggers) {
93
- throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
94
- }
95
- }
96
- if (isBatchDeleteFunctionTriggers) {
97
- const func = functions.find((item) => item.name === name);
98
- return functionService.batchDeleteTriggers({
99
- envId,
100
- functions: [func]
101
- });
64
+ if (!isBatchDeleteTriggers) {
65
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
102
66
  }
103
- if (!triggerName) {
104
- throw new error_1.CloudBaseError((0, i18n_1.t)('触发器名称不能为空'));
67
+ }
68
+ if (isBatchDeleteTriggers) {
69
+ return functionService.batchDeleteTriggers({
70
+ envId,
71
+ functions
72
+ });
73
+ }
74
+ if (!triggerName && name) {
75
+ const { isBatch } = await inquirer_1.default.prompt({
76
+ type: 'confirm',
77
+ name: 'isBatch',
78
+ message: (0, i18n_1.t)('没有指定触发器名称,是否需要此云函数的全部触发器?'),
79
+ default: false
80
+ });
81
+ isBatchDeleteFunctionTriggers = isBatch;
82
+ if (!isBatchDeleteFunctionTriggers) {
83
+ throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
105
84
  }
106
- yield functionService.deleteFunctionTrigger(name, triggerName);
107
- });
85
+ }
86
+ if (isBatchDeleteFunctionTriggers) {
87
+ const func = functions.find((item) => item.name === name);
88
+ return functionService.batchDeleteTriggers({
89
+ envId,
90
+ functions: [func]
91
+ });
92
+ }
93
+ if (!triggerName) {
94
+ throw new error_1.CloudBaseError((0, i18n_1.t)('触发器名称不能为空'));
95
+ }
96
+ await functionService.deleteFunctionTrigger(name, triggerName);
108
97
  }
109
98
  };
110
99
  __decorate([
@@ -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
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.ListFunctionVersion = void 0;
25
16
  const common_1 = require("../../common");
@@ -48,38 +39,36 @@ let ListFunctionVersion = class ListFunctionVersion extends common_1.Command {
48
39
  desc: (0, i18n_1.t)('展示函数版本列表')
49
40
  };
50
41
  }
51
- execute(ctx, params, options) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const name = params === null || params === void 0 ? void 0 : params[0];
54
- let { limit = 20, offset = 0 } = options;
55
- limit = Number(limit);
56
- offset = Number(offset);
57
- if (!Number.isInteger(limit) || !Number.isInteger(offset)) {
58
- throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为整数'));
59
- }
60
- if (limit < 0 || offset < 0) {
61
- throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为大于 0 的整数'));
62
- }
63
- const { envId } = ctx;
64
- const loading = (0, utils_1.loadingFactory)();
65
- loading.start((0, i18n_1.t)('拉取函数 [{{name}}] 版本列表中...', { name }));
66
- const res = yield (0, function_1.listFunctionVersions)({
67
- envId,
68
- functionName: name,
69
- offset,
70
- limit
71
- });
72
- loading.stop();
73
- const head = [(0, i18n_1.t)('版本'), (0, i18n_1.t)('描述'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('修改时间'), (0, i18n_1.t)('状态')];
74
- const tableData = res.Versions.map((item) => [
75
- item.Version,
76
- item.Description,
77
- item.AddTime,
78
- item.ModTime,
79
- constant_1.StatusMap[item.Status]
80
- ]);
81
- (0, utils_1.printHorizontalTable)(head, tableData);
42
+ async execute(ctx, params, options) {
43
+ const name = params === null || params === void 0 ? void 0 : params[0];
44
+ let { limit = 20, offset = 0 } = options;
45
+ limit = Number(limit);
46
+ offset = Number(offset);
47
+ if (!Number.isInteger(limit) || !Number.isInteger(offset)) {
48
+ throw new error_1.CloudBaseError((0, i18n_1.t)('limit offset 必须为整数'));
49
+ }
50
+ if (limit < 0 || offset < 0) {
51
+ throw new error_1.CloudBaseError((0, i18n_1.t)('limit offset 必须为大于 0 的整数'));
52
+ }
53
+ const { envId } = ctx;
54
+ const loading = (0, utils_1.loadingFactory)();
55
+ loading.start((0, i18n_1.t)('拉取函数 [{{name}}] 版本列表中...', { name }));
56
+ const res = await (0, function_1.listFunctionVersions)({
57
+ envId,
58
+ functionName: name,
59
+ offset,
60
+ limit
82
61
  });
62
+ loading.stop();
63
+ const head = [(0, i18n_1.t)('版本'), (0, i18n_1.t)('描述'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('修改时间'), (0, i18n_1.t)('状态')];
64
+ const tableData = res.Versions.map((item) => [
65
+ item.Version,
66
+ item.Description,
67
+ item.AddTime,
68
+ item.ModTime,
69
+ constant_1.StatusMap[item.Status]
70
+ ]);
71
+ (0, utils_1.printHorizontalTable)(head, tableData);
83
72
  }
84
73
  };
85
74
  __decorate([
@@ -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
  Object.defineProperty(exports, "__esModule", { value: true });
24
15
  exports.PublishFunctionVersion = void 0;
25
16
  const common_1 = require("../../common");
@@ -41,20 +32,18 @@ let PublishFunctionVersion = class PublishFunctionVersion extends common_1.Comma
41
32
  desc: (0, i18n_1.t)('发布函数新版本')
42
33
  };
43
34
  }
44
- execute(ctx, params) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const name = params === null || params === void 0 ? void 0 : params[0];
47
- const description = params === null || params === void 0 ? void 0 : params[1];
48
- const { envId } = ctx;
49
- const loading = (0, utils_1.loadingFactory)();
50
- loading.start((0, i18n_1.t)('发布函数 [{{name}}] 新版本中...', { name }));
51
- yield (0, function_1.publishVersion)({
52
- envId,
53
- functionName: name,
54
- description
55
- });
56
- loading.succeed((0, i18n_1.t)('发布函数 [{{name}}] 新版本成功!', { name }));
35
+ async execute(ctx, params) {
36
+ const name = params === null || params === void 0 ? void 0 : params[0];
37
+ const description = params === null || params === void 0 ? void 0 : params[1];
38
+ const { envId } = ctx;
39
+ const loading = (0, utils_1.loadingFactory)();
40
+ loading.start((0, i18n_1.t)('发布函数 [{{name}}] 新版本中...', { name }));
41
+ await (0, function_1.publishVersion)({
42
+ envId,
43
+ functionName: name,
44
+ description
57
45
  });
46
+ loading.succeed((0, i18n_1.t)('发布函数 [{{name}}] 新版本成功!', { name }));
58
47
  }
59
48
  };
60
49
  __decorate([