@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.
- package/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- 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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
104
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
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
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
-
|
|
240
|
-
|
|
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) =>
|
|
16
|
-
const { Result } =
|
|
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;
|
package/lib/run/image/build.js
CHANGED
|
@@ -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) =>
|
|
17
|
-
const { PackageName, PackageVersion, UploadHeaders, UploadUrl } =
|
|
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) =>
|
|
15
|
+
const uploadZip = async (path, url, headers) => {
|
|
25
16
|
let body = (0, fs_1.createReadStream)(path);
|
|
26
|
-
|
|
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;
|
package/lib/run/image/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.deleteImage = void 0;
|
|
13
4
|
const utils_1 = require("../../utils");
|
|
14
5
|
const tcbService = utils_1.CloudApiService.getInstance('tcb');
|
|
15
|
-
const deleteImage = (options) =>
|
|
16
|
-
const { Result } =
|
|
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;
|
package/lib/run/image/info.js
CHANGED
|
@@ -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 = () =>
|
|
6
|
+
const getAuthFlag = async () => {
|
|
16
7
|
const USER_HOME = process.env.HOME || process.env.USERPROFILE;
|
|
17
8
|
try {
|
|
18
|
-
|
|
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;
|
package/lib/run/image/list.js
CHANGED
|
@@ -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 = () =>
|
|
17
|
-
const { Data: { RepoInfo } } =
|
|
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) =>
|
|
22
|
-
const { Images } =
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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;
|