@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
package/lib/hosting.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
  };
@@ -29,216 +20,194 @@ const HostingStatusMap = {
29
20
  destroy_fail: (0, i18n_1.t)('销毁失败')
30
21
  };
31
22
  const tcbService = utils_1.CloudApiService.getInstance('tcb');
32
- function getHostingInfo(options) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const { envId } = options;
35
- const res = yield tcbService.request('DescribeStaticStore', {
36
- EnvId: envId
37
- });
38
- const data = (0, utils_1.firstLetterToLowerCase)(res);
39
- return data;
23
+ async function getHostingInfo(options) {
24
+ const { envId } = options;
25
+ const res = await tcbService.request('DescribeStaticStore', {
26
+ EnvId: envId
40
27
  });
28
+ const data = (0, utils_1.firstLetterToLowerCase)(res);
29
+ return data;
41
30
  }
42
31
  exports.getHostingInfo = getHostingInfo;
43
- function initHosting(options) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const { envId } = options;
46
- const envInfo = yield getEnvInfoByEnvId({ envId });
47
- if (envInfo.EnvType === constant_1.EnvType.BAAS) {
48
- const { confirm } = yield inquirer_1.default.prompt({
49
- type: 'confirm',
50
- name: 'confirm',
51
- message: (0, i18n_1.t)('您还未开通静态托管,是否立即开通?')
52
- });
53
- if (confirm) {
54
- const res = yield subscribeHosting({ envId });
55
- if (!res.code) {
56
- utils_1.logger.success((0, i18n_1.t)('开通静态托管成功!资源正在初始化中,请稍候3~5分钟再试...'));
57
- return;
58
- }
59
- else {
60
- throw new error_1.CloudBaseError((0, i18n_1.t)('开通静态托管失败\n request id: {{requestId}}', { requestId: res.requestId }));
61
- }
62
- }
63
- else
32
+ async function initHosting(options) {
33
+ const { envId } = options;
34
+ const envInfo = await getEnvInfoByEnvId({ envId });
35
+ if (envInfo.EnvType === constant_1.EnvType.BAAS) {
36
+ const { confirm } = await inquirer_1.default.prompt({
37
+ type: 'confirm',
38
+ name: 'confirm',
39
+ message: (0, i18n_1.t)('您还未开通静态托管,是否立即开通?')
40
+ });
41
+ if (confirm) {
42
+ const res = await subscribeHosting({ envId });
43
+ if (!res.code) {
44
+ utils_1.logger.success((0, i18n_1.t)('开通静态托管成功!资源正在初始化中,请稍候3~5分钟再试...'));
64
45
  return;
46
+ }
47
+ else {
48
+ throw new error_1.CloudBaseError((0, i18n_1.t)('开通静态托管失败\n request id: {{requestId}}', { requestId: res.requestId }));
49
+ }
65
50
  }
66
- else {
67
- const link = (0, utils_1.genClickableLink)(utils_1.EUrl.TcbConsole);
68
- throw new error_1.CloudBaseError((0, i18n_1.t)('您还没有开启静态网站服务,请先到云开发控制台开启静态网站服务!\n👉 {{link}}', { link }), {
69
- code: 'INVALID_OPERATION'
70
- });
71
- }
72
- });
51
+ else
52
+ return;
53
+ }
54
+ else {
55
+ const link = (0, utils_1.genClickableLink)(utils_1.EUrl.TcbConsole);
56
+ throw new error_1.CloudBaseError((0, i18n_1.t)('您还没有开启静态网站服务,请先到云开发控制台开启静态网站服务!\n👉 {{link}}', { link }), {
57
+ code: 'INVALID_OPERATION'
58
+ });
59
+ }
73
60
  }
74
61
  exports.initHosting = initHosting;
75
- function checkHostingStatus(envId) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const hostings = yield getHostingInfo({ envId });
78
- if (!hostings.data || !hostings.data.length) {
79
- yield initHosting({ envId });
80
- return;
81
- }
82
- const website = hostings.data[0];
83
- if (website.status !== 'online') {
84
- throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务【{{status}}】,无法进行此操作!', { status: HostingStatusMap[website.status] }), {
85
- code: 'INVALID_OPERATION'
86
- });
87
- }
88
- return website;
89
- });
62
+ async function checkHostingStatus(envId) {
63
+ const hostings = await getHostingInfo({ envId });
64
+ if (!hostings.data || !hostings.data.length) {
65
+ await initHosting({ envId });
66
+ return;
67
+ }
68
+ const website = hostings.data[0];
69
+ if (website.status !== 'online') {
70
+ throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务【{{status}}】,无法进行此操作!', { status: HostingStatusMap[website.status] }), {
71
+ code: 'INVALID_OPERATION'
72
+ });
73
+ }
74
+ return website;
90
75
  }
91
76
  exports.checkHostingStatus = checkHostingStatus;
92
- function enableHosting(options) {
77
+ async function enableHosting(options) {
93
78
  var _a;
94
- return __awaiter(this, void 0, void 0, function* () {
95
- const { envId } = options;
96
- const hostings = yield getHostingInfo(options);
97
- if ((_a = hostings === null || hostings === void 0 ? void 0 : hostings.data) === null || _a === void 0 ? void 0 : _a.length) {
98
- const website = hostings.data[0];
99
- if (website.status !== 'offline') {
100
- throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务已开启,请勿重复操作!'));
101
- }
79
+ const { envId } = options;
80
+ const hostings = await getHostingInfo(options);
81
+ if ((_a = hostings === null || hostings === void 0 ? void 0 : hostings.data) === null || _a === void 0 ? void 0 : _a.length) {
82
+ const website = hostings.data[0];
83
+ if (website.status !== 'offline') {
84
+ throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务已开启,请勿重复操作!'));
102
85
  }
103
- const res = yield tcbService.request('CreateStaticStore', {
104
- EnvId: envId
105
- });
106
- const code = res.Result === 'succ' ? 0 : -1;
107
- return {
108
- code,
109
- requestId: res.RequestId
110
- };
86
+ }
87
+ const res = await tcbService.request('CreateStaticStore', {
88
+ EnvId: envId
111
89
  });
90
+ const code = res.Result === 'succ' ? 0 : -1;
91
+ return {
92
+ code,
93
+ requestId: res.RequestId
94
+ };
112
95
  }
113
96
  exports.enableHosting = enableHosting;
114
- function getEnvInfoByEnvId(options) {
97
+ async function getEnvInfoByEnvId(options) {
115
98
  var _a;
116
- return __awaiter(this, void 0, void 0, function* () {
117
- const { envId } = options;
118
- const res = yield tcbService.request('DescribeEnvs', {
119
- EnvId: envId
120
- });
121
- return (_a = res === null || res === void 0 ? void 0 : res.EnvList) === null || _a === void 0 ? void 0 : _a.filter(item => item.EnvId === envId)[0];
99
+ const { envId } = options;
100
+ const res = await tcbService.request('DescribeEnvs', {
101
+ EnvId: envId
122
102
  });
103
+ return (_a = res === null || res === void 0 ? void 0 : res.EnvList) === null || _a === void 0 ? void 0 : _a.filter(item => item.EnvId === envId)[0];
123
104
  }
124
105
  exports.getEnvInfoByEnvId = getEnvInfoByEnvId;
125
- function subscribeHosting(options) {
126
- return __awaiter(this, void 0, void 0, function* () {
127
- const { envId } = options;
128
- const res = yield tcbService.request('DescribeStaticStore', {
129
- EnvId: envId
130
- });
131
- const code = res.Result === 'succ' ? 0 : -1;
132
- return {
133
- code,
134
- requestId: res.RequestId
135
- };
106
+ async function subscribeHosting(options) {
107
+ const { envId } = options;
108
+ const res = await tcbService.request('DescribeStaticStore', {
109
+ EnvId: envId
136
110
  });
111
+ const code = res.Result === 'succ' ? 0 : -1;
112
+ return {
113
+ code,
114
+ requestId: res.RequestId
115
+ };
137
116
  }
138
117
  exports.subscribeHosting = subscribeHosting;
139
- function hostingList(options) {
140
- return __awaiter(this, void 0, void 0, function* () {
141
- const { envId } = options;
142
- const hosting = yield checkHostingStatus(envId);
143
- const { bucket, regoin } = hosting;
144
- const storageService = yield (0, utils_1.getStorageService)(envId);
145
- const list = yield storageService.walkCloudDirCustom({
146
- prefix: '',
147
- bucket,
148
- region: regoin
149
- });
150
- return list;
118
+ async function hostingList(options) {
119
+ const { envId } = options;
120
+ const hosting = await checkHostingStatus(envId);
121
+ const { bucket, regoin } = hosting;
122
+ const storageService = await (0, utils_1.getStorageService)(envId);
123
+ const list = await storageService.walkCloudDirCustom({
124
+ prefix: '',
125
+ bucket,
126
+ region: regoin
151
127
  });
128
+ return list;
152
129
  }
153
130
  exports.hostingList = hostingList;
154
- function destroyHosting(options) {
155
- return __awaiter(this, void 0, void 0, function* () {
156
- const { envId } = options;
157
- const files = yield hostingList(options);
158
- if (files === null || files === void 0 ? void 0 : files.length) {
159
- throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站文件不为空,无法销毁!'), {
160
- code: 'INVALID_OPERATION'
161
- });
162
- }
163
- const hostings = yield getHostingInfo(options);
164
- if (!hostings.data || !hostings.data.length) {
165
- throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务未开启!'), {
166
- code: 'INVALID_OPERATION'
167
- });
168
- }
169
- const website = hostings.data[0];
170
- if (website.status !== 'online' && website.status !== 'destroy_fail') {
171
- throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务【{{status}}】,无法进行此操作!', { status: HostingStatusMap[website.status] }), {
172
- code: 'INVALID_OPERATION'
173
- });
174
- }
175
- const res = yield tcbService.request('DestroyStaticStore', {
176
- EnvId: envId
131
+ async function destroyHosting(options) {
132
+ const { envId } = options;
133
+ const files = await hostingList(options);
134
+ if (files === null || files === void 0 ? void 0 : files.length) {
135
+ throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站文件不为空,无法销毁!'), {
136
+ code: 'INVALID_OPERATION'
177
137
  });
178
- const code = res.Result === 'succ' ? 0 : -1;
179
- return {
180
- code,
181
- requestId: res.RequestId
182
- };
138
+ }
139
+ const hostings = await getHostingInfo(options);
140
+ if (!hostings.data || !hostings.data.length) {
141
+ throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务未开启!'), {
142
+ code: 'INVALID_OPERATION'
143
+ });
144
+ }
145
+ const website = hostings.data[0];
146
+ if (website.status !== 'online' && website.status !== 'destroy_fail') {
147
+ throw new error_1.CloudBaseError((0, i18n_1.t)('静态网站服务【{{status}}】,无法进行此操作!', { status: HostingStatusMap[website.status] }), {
148
+ code: 'INVALID_OPERATION'
149
+ });
150
+ }
151
+ const res = await tcbService.request('DestroyStaticStore', {
152
+ EnvId: envId
183
153
  });
154
+ const code = res.Result === 'succ' ? 0 : -1;
155
+ return {
156
+ code,
157
+ requestId: res.RequestId
158
+ };
184
159
  }
185
160
  exports.destroyHosting = destroyHosting;
186
- function hostingDeploy(options) {
187
- return __awaiter(this, void 0, void 0, function* () {
188
- const { envId, filePath, cloudPath, onProgress, onFileFinish } = options;
189
- const resolvePath = path_1.default.resolve(filePath);
190
- (0, utils_1.checkReadable)(resolvePath, true);
191
- const hosting = yield checkHostingStatus(envId);
192
- const { bucket, regoin } = hosting;
193
- const storageService = yield (0, utils_1.getStorageService)(envId);
194
- if ((0, utils_1.isDirectory)(resolvePath)) {
195
- yield storageService.uploadDirectoryCustom({
196
- localPath: resolvePath,
197
- cloudPath,
198
- bucket,
199
- region: regoin,
200
- onProgress,
201
- onFileFinish,
202
- fileId: false
203
- });
204
- }
205
- else {
206
- const assignCloudPath = cloudPath || path_1.default.parse(resolvePath).base;
207
- yield storageService.uploadFileCustom({
208
- localPath: resolvePath,
209
- cloudPath: assignCloudPath,
210
- bucket,
211
- region: regoin,
212
- onProgress,
213
- fileId: false
214
- });
215
- }
216
- });
161
+ async function hostingDeploy(options) {
162
+ const { envId, filePath, cloudPath, onProgress, onFileFinish } = options;
163
+ const resolvePath = path_1.default.resolve(filePath);
164
+ (0, utils_1.checkReadable)(resolvePath, true);
165
+ const hosting = await checkHostingStatus(envId);
166
+ const { bucket, regoin } = hosting;
167
+ const storageService = await (0, utils_1.getStorageService)(envId);
168
+ if ((0, utils_1.isDirectory)(resolvePath)) {
169
+ await storageService.uploadDirectoryCustom({
170
+ localPath: resolvePath,
171
+ cloudPath,
172
+ bucket,
173
+ region: regoin,
174
+ onProgress,
175
+ onFileFinish,
176
+ fileId: false
177
+ });
178
+ }
179
+ else {
180
+ const assignCloudPath = cloudPath || path_1.default.parse(resolvePath).base;
181
+ await storageService.uploadFileCustom({
182
+ localPath: resolvePath,
183
+ cloudPath: assignCloudPath,
184
+ bucket,
185
+ region: regoin,
186
+ onProgress,
187
+ fileId: false
188
+ });
189
+ }
217
190
  }
218
191
  exports.hostingDeploy = hostingDeploy;
219
- function hostingDelete(options) {
220
- return __awaiter(this, void 0, void 0, function* () {
221
- const { envId, cloudPath, isDir } = options;
222
- const hosting = yield checkHostingStatus(envId);
223
- const { bucket, regoin } = hosting;
224
- const storageService = yield (0, utils_1.getStorageService)(envId);
225
- if (isDir) {
226
- yield storageService.deleteDirectoryCustom({
227
- cloudPath,
228
- bucket,
229
- region: regoin
230
- });
231
- }
232
- else {
233
- yield storageService.deleteFileCustom([cloudPath], bucket, regoin);
234
- }
235
- });
192
+ async function hostingDelete(options) {
193
+ const { envId, cloudPath, isDir } = options;
194
+ const hosting = await checkHostingStatus(envId);
195
+ const { bucket, regoin } = hosting;
196
+ const storageService = await (0, utils_1.getStorageService)(envId);
197
+ if (isDir) {
198
+ await storageService.deleteDirectoryCustom({
199
+ cloudPath,
200
+ bucket,
201
+ region: regoin
202
+ });
203
+ }
204
+ else {
205
+ await storageService.deleteFileCustom([cloudPath], bucket, regoin);
206
+ }
236
207
  }
237
208
  exports.hostingDelete = hostingDelete;
238
- function walkLocalDir(envId, dir) {
239
- return __awaiter(this, void 0, void 0, function* () {
240
- const storageService = yield (0, utils_1.getStorageService)(envId);
241
- return storageService.walkLocalDir(dir);
242
- });
209
+ async function walkLocalDir(envId, dir) {
210
+ const storageService = await (0, utils_1.getStorageService)(envId);
211
+ return storageService.walkLocalDir(dir);
243
212
  }
244
213
  exports.walkLocalDir = walkLocalDir;
package/lib/run/delete.js CHANGED
@@ -1,22 +1,13 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.deleteRun = void 0;
13
4
  const utils_1 = require("../utils");
14
5
  const tcbService = utils_1.CloudApiService.getInstance('tcb');
15
- const deleteRun = (options) => __awaiter(void 0, void 0, void 0, function* () {
16
- const { Result } = yield tcbService.request('DeleteCloudBaseRunServer', {
6
+ const deleteRun = async (options) => {
7
+ const { Result } = await tcbService.request('DeleteCloudBaseRunServer', {
17
8
  EnvId: options.envId,
18
9
  ServerName: options.serverName
19
10
  });
20
11
  return Result;
21
- });
12
+ };
22
13
  exports.deleteRun = deleteRun;
@@ -1,29 +1,20 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.uploadZip = exports.createBuild = void 0;
13
4
  const fs_1 = require("fs");
14
5
  const utils_1 = require("../../utils");
15
6
  const tcbService = utils_1.CloudApiService.getInstance('tcb');
16
- const createBuild = (options) => __awaiter(void 0, void 0, void 0, function* () {
17
- const { PackageName, PackageVersion, UploadHeaders, UploadUrl } = yield tcbService.request('DescribeCloudBaseBuildService', {
7
+ const createBuild = async (options) => {
8
+ const { PackageName, PackageVersion, UploadHeaders, UploadUrl } = await tcbService.request('DescribeCloudBaseBuildService', {
18
9
  EnvId: options.envId,
19
10
  ServiceName: options.serviceName,
20
11
  });
21
12
  return { PackageName, PackageVersion, UploadHeaders, UploadUrl };
22
- });
13
+ };
23
14
  exports.createBuild = createBuild;
24
- const uploadZip = (path, url, headers) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const uploadZip = async (path, url, headers) => {
25
16
  let body = (0, fs_1.createReadStream)(path);
26
- yield (0, utils_1.fetchStream)(url, {
17
+ await (0, utils_1.fetchStream)(url, {
27
18
  method: 'PUT',
28
19
  headers: {
29
20
  Accept: '*/*',
@@ -33,5 +24,5 @@ const uploadZip = (path, url, headers) => __awaiter(void 0, void 0, void 0, func
33
24
  },
34
25
  body
35
26
  });
36
- });
27
+ };
37
28
  exports.uploadZip = uploadZip;
@@ -1,22 +1,13 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.deleteImage = void 0;
13
4
  const utils_1 = require("../../utils");
14
5
  const tcbService = utils_1.CloudApiService.getInstance('tcb');
15
- const deleteImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
16
- const { Result } = yield tcbService.request('DeleteCloudBaseRunImage', {
6
+ const deleteImage = async (options) => {
7
+ const { Result } = await tcbService.request('DeleteCloudBaseRunImage', {
17
8
  EnvId: options.envId,
18
9
  ImageUrl: options.imageUrl
19
10
  });
20
11
  return Result;
21
- });
12
+ };
22
13
  exports.deleteImage = deleteImage;
@@ -1,21 +1,12 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.getAuthFlag = void 0;
13
4
  const fs_1 = require("fs");
14
5
  const path_1 = require("path");
15
- const getAuthFlag = () => __awaiter(void 0, void 0, void 0, function* () {
6
+ const getAuthFlag = async () => {
16
7
  const USER_HOME = process.env.HOME || process.env.USERPROFILE;
17
8
  try {
18
- yield (new Promise((resolve, reject) => {
9
+ await (new Promise((resolve, reject) => {
19
10
  (0, fs_1.access)((0, path_1.join)(USER_HOME, '.docker/config.json'), fs_1.constants.F_OK, err => err ? reject(err) : resolve(true));
20
11
  }));
21
12
  }
@@ -25,5 +16,5 @@ const getAuthFlag = () => __awaiter(void 0, void 0, void 0, function* () {
25
16
  const data = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(USER_HOME, '.docker/config.json')).toString());
26
17
  console.log();
27
18
  return Boolean(data['auths']['ccr.ccs.tencentyun.com']);
28
- });
19
+ };
29
20
  exports.getAuthFlag = getAuthFlag;
@@ -1,30 +1,21 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.listImage = exports.getImageRepo = void 0;
13
4
  const utils_1 = require("../../utils");
14
5
  const tcrService = utils_1.CloudApiService.getInstance('tcr');
15
6
  const tcbService = utils_1.CloudApiService.getInstance('tcb');
16
- const getImageRepo = () => __awaiter(void 0, void 0, void 0, function* () {
17
- const { Data: { RepoInfo } } = yield tcrService.request('DescribeRepositoryFilterPersonal');
7
+ const getImageRepo = async () => {
8
+ const { Data: { RepoInfo } } = await tcrService.request('DescribeRepositoryFilterPersonal');
18
9
  return RepoInfo;
19
- });
10
+ };
20
11
  exports.getImageRepo = getImageRepo;
21
- const listImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
22
- const { Images } = yield tcbService.request('DescribeCloudBaseRunImages', {
12
+ const listImage = async (options) => {
13
+ const { Images } = await tcbService.request('DescribeCloudBaseRunImages', {
23
14
  EnvId: options.envId,
24
15
  ServiceName: options.serviceName,
25
16
  Limit: options.limit,
26
17
  Offset: options.offset
27
18
  });
28
19
  return Images;
29
- });
20
+ };
30
21
  exports.listImage = listImage;
package/lib/run/list.js CHANGED
@@ -1,39 +1,28 @@
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
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.listRun = void 0;
13
4
  const utils_1 = require("../utils");
14
5
  const scfService = utils_1.CloudApiService.getInstance('tcb');
15
- function listRun(options) {
16
- return __awaiter(this, void 0, void 0, function* () {
17
- const { limit = 20, offset = 0, envId } = options;
18
- const res = yield scfService.request('DescribeCloudBaseRunServers', {
19
- EnvId: envId,
20
- Limit: limit,
21
- Offset: offset
22
- });
23
- const { CloudBaseRunServerSet = [] } = res;
24
- const data = [];
25
- CloudBaseRunServerSet.forEach(run => {
26
- const { ServerName, CreatedTime, UpdatedTime, Status, VpcId, ServiceRemark } = run;
27
- data.push({
28
- ServerName,
29
- ServiceRemark,
30
- CreatedTime,
31
- UpdatedTime,
32
- VpcId,
33
- Status,
34
- });
6
+ async function listRun(options) {
7
+ const { limit = 20, offset = 0, envId } = options;
8
+ const res = await scfService.request('DescribeCloudBaseRunServers', {
9
+ EnvId: envId,
10
+ Limit: limit,
11
+ Offset: offset
12
+ });
13
+ const { CloudBaseRunServerSet = [] } = res;
14
+ const data = [];
15
+ CloudBaseRunServerSet.forEach(run => {
16
+ const { ServerName, CreatedTime, UpdatedTime, Status, VpcId, ServiceRemark } = run;
17
+ data.push({
18
+ ServerName,
19
+ ServiceRemark,
20
+ CreatedTime,
21
+ UpdatedTime,
22
+ VpcId,
23
+ Status,
35
24
  });
36
- return data;
37
25
  });
26
+ return data;
38
27
  }
39
28
  exports.listRun = listRun;