@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
package/lib/utils/env.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -28,195 +19,183 @@ const tcbService = net_1.CloudApiService.getInstance('tcb');
28
19
  const ENV_INIT_TIP = (0, i18n_1.t)('环境初始化中,预计需要三分钟');
29
20
  const CREATE_ENV = 'CREATE';
30
21
  const consoleUrl = `${url_1.EUrl.TcbConsole}/env/index?action=CreateEnv&from=cli`;
31
- function getSelectedEnv(inputEnvId) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- const isInitNow = yield checkTcbService();
34
- let envData = [];
35
- if (isInitNow) {
36
- envData = yield (0, output_1.execWithLoading)(() => {
37
- return new Promise((resolve) => {
38
- const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
39
- const envs = yield (0, env_1.listEnvs)();
40
- if (envs.length) {
41
- clearInterval(timer);
42
- resolve(envs);
43
- }
44
- }), 2000);
45
- });
46
- }, {
47
- startTip: (0, i18n_1.t)('获取环境列表中')
22
+ async function getSelectedEnv(inputEnvId) {
23
+ const isInitNow = await checkTcbService();
24
+ let envData = [];
25
+ if (isInitNow) {
26
+ envData = await (0, output_1.execWithLoading)(() => {
27
+ return new Promise((resolve) => {
28
+ const timer = setInterval(async () => {
29
+ const envs = await (0, env_1.listEnvs)();
30
+ if (envs.length) {
31
+ clearInterval(timer);
32
+ resolve(envs);
33
+ }
34
+ }, 2000);
48
35
  });
36
+ }, {
37
+ startTip: (0, i18n_1.t)('获取环境列表中')
38
+ });
39
+ }
40
+ else {
41
+ envData = await (0, output_1.execWithLoading)(() => (0, env_1.listEnvs)(), {
42
+ startTip: (0, i18n_1.t)('获取环境列表中')
43
+ });
44
+ }
45
+ envData = envData || [];
46
+ if ((envData === null || envData === void 0 ? void 0 : envData.length) && inputEnvId) {
47
+ const inputEnvIdExist = envData.find((_) => _.EnvId === inputEnvId);
48
+ if (!inputEnvIdExist) {
49
+ throw new error_1.CloudBaseError((0, i18n_1.t)('你指定的环境 Id {{envId}} 不存在,请指定正确的环境 Id!', { envId: inputEnvId }));
49
50
  }
50
- else {
51
- envData = yield (0, output_1.execWithLoading)(() => (0, env_1.listEnvs)(), {
52
- startTip: (0, i18n_1.t)('获取环境列表中')
53
- });
51
+ return inputEnvId;
52
+ }
53
+ const envs = envData
54
+ .map((item) => {
55
+ let name = `${item.Alias} - [${item.EnvId}:${item.PackageName || (0, i18n_1.t)('按量计费')}]`;
56
+ if (item.Status !== "NORMAL") {
57
+ name += `(${constant_1.STATUS_TEXT[item.Status]})`;
54
58
  }
55
- envData = envData || [];
56
- if ((envData === null || envData === void 0 ? void 0 : envData.length) && inputEnvId) {
57
- const inputEnvIdExist = envData.find((_) => _.EnvId === inputEnvId);
58
- if (!inputEnvIdExist) {
59
- throw new error_1.CloudBaseError((0, i18n_1.t)('你指定的环境 Id {{envId}} 不存在,请指定正确的环境 Id!', { envId: inputEnvId }));
60
- }
61
- return inputEnvId;
59
+ return {
60
+ name,
61
+ value: item.EnvId
62
+ };
63
+ })
64
+ .sort((prev, next) => prev.value.charCodeAt(0) - next.value.charCodeAt(0));
65
+ const choices = [
66
+ ...envs,
67
+ {
68
+ name: envData.length ? (0, i18n_1.t)('创建新环境') : (0, i18n_1.t)('无可用环境,创建新环境'),
69
+ value: CREATE_ENV
62
70
  }
63
- const envs = envData
64
- .map((item) => {
65
- let name = `${item.Alias} - [${item.EnvId}:${item.PackageName || (0, i18n_1.t)('按量计费')}]`;
66
- if (item.Status !== "NORMAL") {
67
- name += `(${constant_1.STATUS_TEXT[item.Status]})`;
68
- }
69
- return {
70
- name,
71
- value: item.EnvId
72
- };
73
- })
74
- .sort((prev, next) => prev.value.charCodeAt(0) - next.value.charCodeAt(0));
75
- const choices = [
76
- ...envs,
77
- {
78
- name: envData.length ? (0, i18n_1.t)('创建新环境') : (0, i18n_1.t)('无可用环境,创建新环境'),
79
- value: CREATE_ENV
80
- }
81
- ];
82
- let { env } = yield (0, enquirer_1.prompt)({
83
- choices,
84
- type: 'select',
85
- name: 'env',
86
- message: (0, i18n_1.t)('请选择关联环境'),
87
- result(choice) {
88
- return this.map(choice)[choice];
89
- }
90
- });
91
- if (env === CREATE_ENV) {
92
- log_1.logger.success((0, i18n_1.t)('已打开控制台,请前往控制台创建环境'));
93
- const { envId } = yield (0, toolbox_1.getDataFromWeb)((port) => `${consoleUrl}&port=${port}`, 'getData');
94
- if (!envId) {
95
- throw new error_1.CloudBaseError((0, i18n_1.t)('接收环境 Id 信息失败,请重新运行 init 命令!'));
96
- }
97
- log_1.logger.success((0, i18n_1.t)('创建环境成功,环境 Id: {{envId}}', { envId }));
98
- env = envId;
71
+ ];
72
+ let { env } = await (0, enquirer_1.prompt)({
73
+ choices,
74
+ type: 'select',
75
+ name: 'env',
76
+ message: (0, i18n_1.t)('请选择关联环境'),
77
+ result(choice) {
78
+ return this.map(choice)[choice];
99
79
  }
100
- yield checkEnvStatus(env);
101
- return env;
102
80
  });
81
+ if (env === CREATE_ENV) {
82
+ log_1.logger.success((0, i18n_1.t)('已打开控制台,请前往控制台创建环境'));
83
+ const { envId } = await (0, toolbox_1.getDataFromWeb)((port) => `${consoleUrl}&port=${port}`, 'getData');
84
+ if (!envId) {
85
+ throw new error_1.CloudBaseError((0, i18n_1.t)('接收环境 Id 信息失败,请重新运行 init 命令!'));
86
+ }
87
+ log_1.logger.success((0, i18n_1.t)('创建环境成功,环境 Id: {{envId}}', { envId }));
88
+ env = envId;
89
+ }
90
+ await checkEnvStatus(env);
91
+ return env;
103
92
  }
104
93
  exports.getSelectedEnv = getSelectedEnv;
105
- function getSelectRegion() {
106
- return __awaiter(this, void 0, void 0, function* () {
107
- const { region } = yield (0, enquirer_1.prompt)({
108
- choices: [
109
- {
110
- name: (0, i18n_1.t)('上海'),
111
- value: 'ap-shanghai'
112
- },
113
- {
114
- name: (0, i18n_1.t)('广州'),
115
- value: 'ap-guangzhou'
116
- }
117
- ],
118
- type: 'select',
119
- name: 'region',
120
- message: (0, i18n_1.t)('请选择环境所在地域'),
121
- result(choice) {
122
- return this.map(choice)[choice];
94
+ async function getSelectRegion() {
95
+ const { region } = await (0, enquirer_1.prompt)({
96
+ choices: [
97
+ {
98
+ name: (0, i18n_1.t)('上海'),
99
+ value: 'ap-shanghai'
100
+ },
101
+ {
102
+ name: (0, i18n_1.t)('广州'),
103
+ value: 'ap-guangzhou'
123
104
  }
124
- });
125
- tcbService.region = region;
126
- return region;
105
+ ],
106
+ type: 'select',
107
+ name: 'region',
108
+ message: (0, i18n_1.t)('请选择环境所在地域'),
109
+ result(choice) {
110
+ return this.map(choice)[choice];
111
+ }
127
112
  });
113
+ tcbService.region = region;
114
+ return region;
128
115
  }
129
116
  exports.getSelectRegion = getSelectRegion;
130
- function checkTcbService() {
131
- return __awaiter(this, void 0, void 0, function* () {
132
- const app = yield (0, net_1.getMangerService)();
133
- let Initialized;
134
- try {
135
- Initialized = (yield app.env.checkTcbService()).Initialized;
117
+ async function checkTcbService() {
118
+ const app = await (0, net_1.getMangerService)();
119
+ let Initialized;
120
+ try {
121
+ Initialized = (await app.env.checkTcbService()).Initialized;
122
+ }
123
+ catch (e) {
124
+ if (!(0, toolbox_1.isCamRefused)(e)) {
125
+ throw e;
136
126
  }
137
- catch (e) {
138
- if (!(0, toolbox_1.isCamRefused)(e)) {
139
- throw e;
140
- }
141
- }
142
- if (!Initialized) {
143
- const { jump } = yield (0, enquirer_1.prompt)({
144
- type: 'confirm',
145
- name: 'jump',
146
- message: (0, i18n_1.t)('你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)'),
147
- initial: true
148
- });
149
- if (!jump) {
150
- throw new error_1.CloudBaseError((0, i18n_1.t)('init 操作终止,请开通云开发服务后再进行操作!'));
151
- }
152
- (0, open_1.default)(consoleUrl);
153
- log_1.logger.success((0, i18n_1.t)('已打开云开发控制台,请登录并在云开发控制台中开通服务!'));
154
- yield (0, output_1.execWithLoading)(() => waitForServiceEnable(), {
155
- startTip: (0, i18n_1.t)('等待云开发服务开通中'),
156
- successTip: (0, i18n_1.t)('云开发服务开通成功!')
157
- });
158
- return true;
127
+ }
128
+ if (!Initialized) {
129
+ const { jump } = await (0, enquirer_1.prompt)({
130
+ type: 'confirm',
131
+ name: 'jump',
132
+ message: (0, i18n_1.t)('你还没有开通云开发服务,是否跳转到控制台开通云开发服务?(取消将无法继续操作)'),
133
+ initial: true
134
+ });
135
+ if (!jump) {
136
+ throw new error_1.CloudBaseError((0, i18n_1.t)('init 操作终止,请开通云开发服务后再进行操作!'));
159
137
  }
160
- return false;
161
- });
138
+ (0, open_1.default)(consoleUrl);
139
+ log_1.logger.success((0, i18n_1.t)('已打开云开发控制台,请登录并在云开发控制台中开通服务!'));
140
+ await (0, output_1.execWithLoading)(() => waitForServiceEnable(), {
141
+ startTip: (0, i18n_1.t)('等待云开发服务开通中'),
142
+ successTip: (0, i18n_1.t)('云开发服务开通成功!')
143
+ });
144
+ return true;
145
+ }
146
+ return false;
162
147
  }
163
148
  exports.checkTcbService = checkTcbService;
164
- function checkEnvStatus(envId) {
165
- return __awaiter(this, void 0, void 0, function* () {
166
- const env = yield (0, env_1.getEnvInfo)(envId);
167
- if (env.Status === "UNAVAILABLE") {
168
- yield checkEnvAvaliable(envId);
169
- }
170
- else if (env.Status !== "NORMAL") {
171
- throw new error_1.CloudBaseError((0, i18n_1.t)('所有环境状态异常'));
172
- }
173
- });
149
+ async function checkEnvStatus(envId) {
150
+ const env = await (0, env_1.getEnvInfo)(envId);
151
+ if (env.Status === "UNAVAILABLE") {
152
+ await checkEnvAvaliable(envId);
153
+ }
154
+ else if (env.Status !== "NORMAL") {
155
+ throw new error_1.CloudBaseError((0, i18n_1.t)('所有环境状态异常'));
156
+ }
174
157
  }
175
158
  exports.checkEnvStatus = checkEnvStatus;
176
- function checkEnvAvaliable(envId) {
177
- return __awaiter(this, void 0, void 0, function* () {
178
- let count = 0;
179
- yield (0, output_1.execWithLoading)((flush) => {
180
- const increase = setInterval(() => {
181
- flush(`${ENV_INIT_TIP} ${++count}S`);
182
- }, 1000);
183
- return new Promise((resolve) => {
184
- const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
185
- const env = yield (0, env_1.getEnvInfo)(envId);
186
- if (env.Status === "NORMAL") {
187
- clearInterval(timer);
188
- clearInterval(increase);
189
- resolve();
190
- }
191
- }), 3000);
192
- });
193
- }, {
194
- startTip: ENV_INIT_TIP,
195
- successTip: (0, i18n_1.t)('环境 {{envId}} 初始化成功', { envId })
159
+ async function checkEnvAvaliable(envId) {
160
+ let count = 0;
161
+ await (0, output_1.execWithLoading)((flush) => {
162
+ const increase = setInterval(() => {
163
+ flush(`${ENV_INIT_TIP} ${++count}S`);
164
+ }, 1000);
165
+ return new Promise((resolve) => {
166
+ const timer = setInterval(async () => {
167
+ const env = await (0, env_1.getEnvInfo)(envId);
168
+ if (env.Status === "NORMAL") {
169
+ clearInterval(timer);
170
+ clearInterval(increase);
171
+ resolve();
172
+ }
173
+ }, 3000);
196
174
  });
175
+ }, {
176
+ startTip: ENV_INIT_TIP,
177
+ successTip: (0, i18n_1.t)('环境 {{envId}} 初始化成功', { envId })
197
178
  });
198
179
  }
199
180
  exports.checkEnvAvaliable = checkEnvAvaliable;
200
- function waitForServiceEnable() {
201
- return __awaiter(this, void 0, void 0, function* () {
202
- return new Promise((resolve) => {
203
- const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
204
- const app = yield (0, net_1.getMangerService)();
205
- try {
206
- const { Initialized } = yield app.env.checkTcbService();
207
- if (Initialized) {
208
- clearInterval(timer);
209
- setTimeout(() => {
210
- resolve();
211
- }, 5000);
212
- }
181
+ async function waitForServiceEnable() {
182
+ return new Promise((resolve) => {
183
+ const timer = setInterval(async () => {
184
+ const app = await (0, net_1.getMangerService)();
185
+ try {
186
+ const { Initialized } = await app.env.checkTcbService();
187
+ if (Initialized) {
188
+ clearInterval(timer);
189
+ setTimeout(() => {
190
+ resolve();
191
+ }, 5000);
213
192
  }
214
- catch (e) {
215
- if (!(0, toolbox_1.isCamRefused)(e)) {
216
- throw e;
217
- }
193
+ }
194
+ catch (e) {
195
+ if (!(0, toolbox_1.isCamRefused)(e)) {
196
+ throw e;
218
197
  }
219
- }), 3000);
220
- });
198
+ }
199
+ }, 3000);
221
200
  });
222
201
  }
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -32,18 +23,16 @@ class FunctionPacker {
32
23
  this.ignore = ignore;
33
24
  this.funcPath = path_1.default.join(root, name);
34
25
  }
35
- getFileCode() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- (0, toolbox_1.checkFullAccess)(this.funcPath, true);
38
- this.tmpPath = path_1.default.join(this.root, `.cloudbase_tmp_${(0, tools_1.random)()}`);
39
- this.funcDistPath = path_1.default.join(this.tmpPath, this.name);
40
- yield (0, make_dir_1.default)(this.funcDistPath);
41
- const zipPath = path_1.default.resolve(this.funcDistPath, 'dist.zip');
42
- yield (0, toolbox_1.zipDir)(this.funcPath, zipPath, this.ignore);
43
- const base64 = fs_1.default.readFileSync(zipPath).toString('base64');
44
- this.clean();
45
- return base64;
46
- });
26
+ async getFileCode() {
27
+ (0, toolbox_1.checkFullAccess)(this.funcPath, true);
28
+ this.tmpPath = path_1.default.join(this.root, `.cloudbase_tmp_${(0, tools_1.random)()}`);
29
+ this.funcDistPath = path_1.default.join(this.tmpPath, this.name);
30
+ await (0, make_dir_1.default)(this.funcDistPath);
31
+ const zipPath = path_1.default.resolve(this.funcDistPath, 'dist.zip');
32
+ await (0, toolbox_1.zipDir)(this.funcPath, zipPath, this.ignore);
33
+ const base64 = fs_1.default.readFileSync(zipPath).toString('base64');
34
+ this.clean();
35
+ return base64;
47
36
  }
48
37
  getJavaFileCode() {
49
38
  const { funcPath } = this;
@@ -55,29 +44,27 @@ class FunctionPacker {
55
44
  const packagePath = jarExist ? `${funcPath}.jar` : `${funcPath}.zip`;
56
45
  return fs_1.default.readFileSync(packagePath).toString('base64');
57
46
  }
58
- build(type) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- if (type === CodeType.JavaFile) {
61
- try {
62
- const code = yield this.getJavaFileCode();
63
- return code;
64
- }
65
- catch (error) {
66
- this.clean();
67
- throw new toolbox_1.CloudBaseError((0, i18n_1.t)('函数代码打包失败:\n {{error}}', { error: error.message }));
68
- }
47
+ async build(type) {
48
+ if (type === CodeType.JavaFile) {
49
+ try {
50
+ const code = await this.getJavaFileCode();
51
+ return code;
52
+ }
53
+ catch (error) {
54
+ this.clean();
55
+ throw new toolbox_1.CloudBaseError((0, i18n_1.t)('函数代码打包失败:\n {{error}}', { error: error.message }));
69
56
  }
70
- if (type === CodeType.File) {
71
- try {
72
- const code = yield this.getFileCode();
73
- return code;
74
- }
75
- catch (error) {
76
- this.clean();
77
- throw new toolbox_1.CloudBaseError((0, i18n_1.t)('函数代码打包失败:\n {{error}}', { error: error.message }));
78
- }
57
+ }
58
+ if (type === CodeType.File) {
59
+ try {
60
+ const code = await this.getFileCode();
61
+ return code;
79
62
  }
80
- });
63
+ catch (error) {
64
+ this.clean();
65
+ throw new toolbox_1.CloudBaseError((0, i18n_1.t)('函数代码打包失败:\n {{error}}', { error: error.message }));
66
+ }
67
+ }
81
68
  }
82
69
  clean() {
83
70
  this.funcDistPath && del_1.default.sync([this.funcDistPath], { force: true });
package/lib/utils/log.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -67,18 +58,16 @@ class Logger {
67
58
  const clickLink = this.genClickableLink(link);
68
59
  this.info(clickLink);
69
60
  }
70
- time(label, fn) {
71
- return __awaiter(this, void 0, void 0, function* () {
72
- const promise = typeof fn === 'function' ? fn() : fn;
73
- if (this.verboseEnabled) {
74
- this.c.log(label);
75
- console_1.Console.prototype.time.call(this.c, label);
76
- const r = yield promise;
77
- console_1.Console.prototype.timeEnd.call(this.c, label);
78
- return r;
79
- }
80
- return promise;
81
- });
61
+ async time(label, fn) {
62
+ const promise = typeof fn === 'function' ? fn() : fn;
63
+ if (this.verboseEnabled) {
64
+ this.c.log(label);
65
+ console_1.Console.prototype.time.call(this.c, label);
66
+ const r = await promise;
67
+ console_1.Console.prototype.timeEnd.call(this.c, label);
68
+ return r;
69
+ }
70
+ return promise;
82
71
  }
83
72
  }
84
73
  exports.Logger = Logger;