@cloudbase/cli 2.0.14 → 2.1.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/.history/.gitignore_20220624162613 +84 -0
- package/.history/.gitignore_20220627114054 +86 -0
- package/.history/package_20220711204706.json +88 -0
- package/.history/package_20220711204818.json +88 -0
- package/.history/package_20220712151717.json +88 -0
- package/.history/package_20220712212537.json +88 -0
- package/.history/package_20220722205058.json +88 -0
- package/.history/package_20220726110155.json +88 -0
- package/.history/package_20220726110201.json +88 -0
- package/.history/package_20220728110905.json +88 -0
- package/.history/package_20220728110936.json +88 -0
- package/.history/package_20220728111531.json +89 -0
- package/.history/package_20220728111810.json +89 -0
- package/.history/src/commands/lowcode/app_20220728111717.ts +52 -0
- package/.history/src/commands/lowcode/app_20220728112031.ts +34 -0
- package/.history/src/index_20220624162613.ts +13 -0
- package/.history/src/index_20220627113609.ts +15 -0
- package/.history/src/index_20220627114102.ts +13 -0
- package/.vscode/launch.json +10 -0
- package/bin/cloudbase.js +0 -0
- package/bin/tcb.js +5 -5
- package/lib/commands/account/login.js +3 -6
- package/lib/commands/env/index.js +0 -1
- package/lib/commands/lowcode/app.js +1 -1
- package/lib/commands/run/index.js +0 -1
- package/lib/commands/run/service/deploy.js +2 -1
- package/lib/commands/run/service/index.js +0 -1
- package/lib/constant.js +15 -1
- package/lib/env/index.js +1 -11
- package/lib/run/index.js +0 -1
- package/lib/run/service/common.js +11 -4
- package/lib/run/service/config.js +2 -3
- package/lib/run/service/index.js +0 -1
- package/lib/run/service/update.js +1 -1
- package/package.json +2 -2
- package/types/commands/env/index.d.ts +0 -1
- package/types/commands/run/index.d.ts +0 -1
- package/types/commands/run/service/index.d.ts +0 -1
- package/types/env/index.d.ts +0 -6
- package/types/run/index.d.ts +0 -1
- package/types/run/service/common.d.ts +4 -0
- package/types/run/service/index.d.ts +0 -1
- package/.vscode/settings.json +0 -3
- package/lib/commands/env/create.js +0 -115
- package/lib/commands/run/create.js +0 -162
- package/lib/commands/run/service/create.js +0 -148
- package/lib/run/create.js +0 -19
- package/lib/run/service/create.js +0 -67
- package/types/commands/env/create.d.ts +0 -12
- package/types/commands/run/create.d.ts +0 -13
- package/types/commands/run/service/create.d.ts +0 -13
- package/types/run/create.d.ts +0 -2
- package/types/run/service/create.d.ts +0 -7
package/.vscode/launch.json
CHANGED
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
5
|
"version": "0.2.0",
|
|
6
6
|
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"name": "Debug: lowcode watch",
|
|
9
|
+
"program": "${workspaceFolder}/bin/tcb.js",
|
|
10
|
+
"request": "launch",
|
|
11
|
+
"skipFiles": [
|
|
12
|
+
"<node_internals>/**"
|
|
13
|
+
],
|
|
14
|
+
"args": ["lowcode", "watch"],
|
|
15
|
+
"type": "node"
|
|
16
|
+
},
|
|
7
17
|
{
|
|
8
18
|
"type": "node",
|
|
9
19
|
"request": "launch",
|
package/bin/cloudbase.js
CHANGED
|
File without changes
|
package/bin/tcb.js
CHANGED
|
@@ -84,20 +84,20 @@ if (isCommandEmpty) {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
// 处理无效命令
|
|
87
|
-
program.action((
|
|
88
|
-
const args =
|
|
87
|
+
program.action(() => {
|
|
88
|
+
const args = program.args
|
|
89
89
|
if (!Array.isArray(args) || !args.length) {
|
|
90
90
|
return
|
|
91
91
|
}
|
|
92
92
|
const cmd = args.join(' ')
|
|
93
|
-
console.log(chalk.bold.red('Error: ') + `${cmd}
|
|
93
|
+
console.log(chalk.bold.red('Error: ') + `${cmd} 不是有效的命令`)
|
|
94
94
|
didYouMean.threshold = 0.5
|
|
95
95
|
didYouMean.caseSensitive = false
|
|
96
96
|
const suggest = didYouMean(cmd, ALL_COMMANDS)
|
|
97
97
|
if (suggest) {
|
|
98
|
-
console.log(chalk.bold(`\n您是不是想使用命令:
|
|
98
|
+
console.log(chalk.bold(`\n您是不是想使用命令:tcb ${suggest}\n`))
|
|
99
99
|
}
|
|
100
|
-
console.log(
|
|
100
|
+
console.log(`💡使用 ${chalk.bold('tcb -h')} 查看所有命令`)
|
|
101
101
|
})
|
|
102
102
|
|
|
103
103
|
// 没有使用命令
|
|
@@ -37,10 +37,6 @@ const utils_1 = require("../../utils");
|
|
|
37
37
|
function printSuggestion() {
|
|
38
38
|
const tips = `可使用下面命令继续操作:
|
|
39
39
|
|
|
40
|
-
${chalk_1.default.gray('–')} 创建免费环境
|
|
41
|
-
|
|
42
|
-
${chalk_1.default.cyan('$ tcb env create envName')}
|
|
43
|
-
|
|
44
40
|
${chalk_1.default.gray('–')} 初始化云开发项目
|
|
45
41
|
|
|
46
42
|
${chalk_1.default.cyan('$ tcb new')}
|
|
@@ -177,15 +173,16 @@ let LoginCommand = class LoginCommand extends common_1.Command {
|
|
|
177
173
|
return process.exit(1);
|
|
178
174
|
}
|
|
179
175
|
}
|
|
176
|
+
const consoleUrl = 'https://console.cloud.tencent.com/tcb/env/index?action=CreateEnv&from=cli';
|
|
180
177
|
try {
|
|
181
178
|
const envs = yield (0, env_1.listEnvs)();
|
|
182
179
|
if (!envs.length) {
|
|
183
|
-
log.warn(
|
|
180
|
+
log.warn(`您还没有可用的环境,请前往控制台 ${(0, utils_1.genClickableLink)(consoleUrl)} 创建环境`);
|
|
184
181
|
}
|
|
185
182
|
}
|
|
186
183
|
catch (e) {
|
|
187
184
|
if (e.code === 'ResourceNotFound.UserNotExists') {
|
|
188
|
-
log.error(
|
|
185
|
+
log.error(`您还没有可用的环境,请前往控制台 ${(0, utils_1.genClickableLink)(consoleUrl)} 创建环境`);
|
|
189
186
|
}
|
|
190
187
|
else {
|
|
191
188
|
console.error(e);
|
|
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./base"), exports);
|
|
18
|
-
__exportStar(require("./create"), exports);
|
|
19
18
|
__exportStar(require("./domain"), exports);
|
|
20
19
|
__exportStar(require("./login"), exports);
|
|
@@ -48,7 +48,7 @@ let LowCodeWatch = class LowCodeWatch extends common_1.Command {
|
|
|
48
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
49
49
|
yield (0, lowcode_cli_1.watchApp)({
|
|
50
50
|
watchPort: 8288,
|
|
51
|
-
wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath
|
|
51
|
+
wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
}
|
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./list"), exports);
|
|
18
|
-
__exportStar(require("./create"), exports);
|
|
19
18
|
__exportStar(require("./version"), exports);
|
|
20
19
|
__exportStar(require("./delete"), exports);
|
|
21
20
|
__exportStar(require("./image"), exports);
|
|
@@ -26,6 +26,7 @@ const common_1 = require("../../common");
|
|
|
26
26
|
const decorators_1 = require("../../../decorators");
|
|
27
27
|
const run_1 = require("../../../run");
|
|
28
28
|
const utils_1 = require("../../../utils");
|
|
29
|
+
const toolbox_1 = require("@cloudbase/toolbox");
|
|
29
30
|
let DeployServiceTcbr = class DeployServiceTcbr extends common_1.Command {
|
|
30
31
|
get options() {
|
|
31
32
|
return {
|
|
@@ -132,7 +133,7 @@ let DeployServiceTcbr = class DeployServiceTcbr extends common_1.Command {
|
|
|
132
133
|
serviceName: options.serviceName
|
|
133
134
|
});
|
|
134
135
|
if (serviceDetail === undefined) {
|
|
135
|
-
|
|
136
|
+
throw new toolbox_1.CloudBaseError(`当前服务不存在,请前往控制台 ${(0, utils_1.genClickableLink)('https://console.cloud.tencent.com/tcbr')} 创建服务`);
|
|
136
137
|
}
|
|
137
138
|
else {
|
|
138
139
|
yield (0, run_1.updateTcbrService)(options);
|
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./list"), exports);
|
|
18
|
-
__exportStar(require("./create"), exports);
|
|
19
18
|
__exportStar(require("./update"), exports);
|
|
20
19
|
__exportStar(require("./deploy"), exports);
|
|
21
20
|
__exportStar(require("./config"), exports);
|
package/lib/constant.js
CHANGED
|
@@ -32,7 +32,6 @@ exports.ALL_COMMANDS = [
|
|
|
32
32
|
'open',
|
|
33
33
|
'env list',
|
|
34
34
|
'env rename',
|
|
35
|
-
'env create',
|
|
36
35
|
'env domain list',
|
|
37
36
|
'env domain create',
|
|
38
37
|
'env domain delete',
|
|
@@ -82,6 +81,21 @@ exports.ALL_COMMANDS = [
|
|
|
82
81
|
'run standalonegateway package list',
|
|
83
82
|
'run standalonegateway turn on',
|
|
84
83
|
'run standalonegateway turn off',
|
|
84
|
+
'run:deprecated list',
|
|
85
|
+
'run:deprecated delete',
|
|
86
|
+
'run:deprecated version list',
|
|
87
|
+
'run:deprecated version create',
|
|
88
|
+
'run:deprecated version modify',
|
|
89
|
+
'run:deprecated version delete',
|
|
90
|
+
'run:deprecated version update',
|
|
91
|
+
'run:deprecated image list',
|
|
92
|
+
'run:deprecated image upload',
|
|
93
|
+
'run:deprecated image download',
|
|
94
|
+
'run:deprecated image delete',
|
|
95
|
+
'run service:list',
|
|
96
|
+
'run service:deploy',
|
|
97
|
+
'run deploy',
|
|
98
|
+
'run service:config'
|
|
85
99
|
];
|
|
86
100
|
exports.StatusMap = {
|
|
87
101
|
Active: '部署完成',
|
package/lib/env/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getEnvLimit = exports.updateEnvInfo = exports.listEnvs = exports.getEnvInfo = exports.
|
|
26
|
+
exports.getEnvLimit = exports.updateEnvInfo = exports.listEnvs = exports.getEnvInfo = exports.initTcb = void 0;
|
|
27
27
|
const net_1 = require("../utils/net");
|
|
28
28
|
__exportStar(require("./domain"), exports);
|
|
29
29
|
__exportStar(require("./login"), exports);
|
|
@@ -37,16 +37,6 @@ function initTcb(skey) {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
exports.initTcb = initTcb;
|
|
40
|
-
function createEnv({ alias, paymentMode }) {
|
|
41
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const { env } = yield (0, net_1.getMangerService)();
|
|
43
|
-
return env.createEnv({
|
|
44
|
-
paymentMode,
|
|
45
|
-
name: alias
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
exports.createEnv = createEnv;
|
|
50
40
|
function getEnvInfo(envId) {
|
|
51
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
42
|
const { EnvList } = yield tcbService.request('DescribeEnvs', {
|
package/lib/run/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./list"), exports);
|
|
18
|
-
__exportStar(require("./create"), exports);
|
|
19
18
|
__exportStar(require("./version"), exports);
|
|
20
19
|
__exportStar(require("./image"), exports);
|
|
21
20
|
__exportStar(require("./delete"), exports);
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.validateTcrImageURL = exports.getAuthorizedTcrInstance = exports.tcbrServiceOptions = exports.mergeEnvParams = exports.parseEnvParams = exports.extractPolicyDetails = exports.convertNumber = exports.describeWxCloudBaseRunReleaseOrder = void 0;
|
|
12
|
+
exports.validateTcrImageURL = exports.getAuthorizedTcrInstance = exports.tcbrServiceOptions = exports.mergeEnvParams = exports.parseEnvParams = exports.extractPolicyDetails = exports.convertNumber = exports.describeWxCloudBaseRunReleaseOrder = exports.describeCloudRunServerDetail = void 0;
|
|
13
13
|
const utils_1 = require("../../utils");
|
|
14
14
|
const types_1 = require("../../types");
|
|
15
15
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
@@ -18,6 +18,13 @@ const __1 = require("..");
|
|
|
18
18
|
const constant_1 = require("../../constant");
|
|
19
19
|
const tcbService = utils_1.CloudApiService.getInstance('tcb');
|
|
20
20
|
const tcrCloudApiService = new utils_1.CloudApiService('tcr', {}, '2019-09-24');
|
|
21
|
+
const describeCloudRunServerDetail = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
return yield (0, utils_1.callTcbrApi)('DescribeCloudRunServerDetail', {
|
|
23
|
+
EnvId: options.envId,
|
|
24
|
+
ServerName: options.serviceName,
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
exports.describeCloudRunServerDetail = describeCloudRunServerDetail;
|
|
21
28
|
function describeWxCloudBaseRunReleaseOrder(options) {
|
|
22
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
30
|
const res = yield tcbService.request('DescribeWxCloudBaseRunReleaseOrder', {
|
|
@@ -70,13 +77,13 @@ const mergeEnvParams = (curEnvParams, preEnvParams) => {
|
|
|
70
77
|
exports.mergeEnvParams = mergeEnvParams;
|
|
71
78
|
function checkRequiredParams(options) {
|
|
72
79
|
if (!options.envId) {
|
|
73
|
-
throw new toolbox_1.CloudBaseError('
|
|
80
|
+
throw new toolbox_1.CloudBaseError('请使用 -e 或 --envId 指定环境ID');
|
|
74
81
|
}
|
|
75
82
|
if (!options.serviceName) {
|
|
76
|
-
throw new toolbox_1.CloudBaseError('
|
|
83
|
+
throw new toolbox_1.CloudBaseError('请使用 -s 或 --serviceName 指定服务名');
|
|
77
84
|
}
|
|
78
85
|
if (!options.containerPort) {
|
|
79
|
-
throw new toolbox_1.CloudBaseError('
|
|
86
|
+
throw new toolbox_1.CloudBaseError('请使用 --containerPort 指定监听端口号');
|
|
80
87
|
}
|
|
81
88
|
if (!options.isCreated && !options.path && !options.custom_image) {
|
|
82
89
|
throw new toolbox_1.CloudBaseError('请使用 --path 指定代码根目录或 --custom_image 指定 TCR 镜像 URL');
|
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.updateCloudRunServerConfig = exports.tcbrServiceConfigOptions = void 0;
|
|
13
|
-
const create_1 = require("./create");
|
|
14
13
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
15
14
|
const common_1 = require("./common");
|
|
16
15
|
const utils_1 = require("../../utils");
|
|
@@ -29,12 +28,12 @@ function tcbrServiceConfigOptions(options) {
|
|
|
29
28
|
maxNum,
|
|
30
29
|
minNum
|
|
31
30
|
});
|
|
32
|
-
const serviceInfo = yield (0,
|
|
31
|
+
const serviceInfo = yield (0, common_1.describeCloudRunServerDetail)({
|
|
33
32
|
envId,
|
|
34
33
|
serviceName
|
|
35
34
|
});
|
|
36
35
|
if (serviceInfo instanceof Error && serviceInfo['code'] === 'InvalidParameter') {
|
|
37
|
-
throw new toolbox_1.CloudBaseError(
|
|
36
|
+
throw new toolbox_1.CloudBaseError(`服务不存在,请检查服务名是否正确或到控制台 ${(0, utils_1.genClickableLink)('https://console.cloud.tencent.com/tcbr')} 创建服务`);
|
|
38
37
|
}
|
|
39
38
|
const { ServerConfig: previousServerConfig } = serviceInfo.data;
|
|
40
39
|
const newServiceOptions = {
|
package/lib/run/service/index.js
CHANGED
|
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./list"), exports);
|
|
18
|
-
__exportStar(require("./create"), exports);
|
|
19
18
|
__exportStar(require("./showLogs"), exports);
|
|
20
19
|
__exportStar(require("./deployPackage"), exports);
|
|
21
20
|
__exportStar(require("./common"), exports);
|
|
@@ -39,7 +39,7 @@ function updateTcbrService(options) {
|
|
|
39
39
|
serviceName: options.serviceName
|
|
40
40
|
});
|
|
41
41
|
if (serviceDetail === undefined) {
|
|
42
|
-
throw new toolbox_1.CloudBaseError(
|
|
42
|
+
throw new toolbox_1.CloudBaseError(`当前服务不存在,请前往控制台 ${(0, utils_1.genClickableLink)('https://console.cloud.tencent.com/tcbr')} 创建服务`);
|
|
43
43
|
}
|
|
44
44
|
const status = yield (0, showLogs_1.getBuildStatus)(options.envId, options.serviceName);
|
|
45
45
|
if (status === 'pending') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@cloudbase/cloud-api": "^0.5.5",
|
|
34
34
|
"@cloudbase/framework-core": "^1.6.1",
|
|
35
|
-
"@cloudbase/lowcode-cli": "^0.
|
|
35
|
+
"@cloudbase/lowcode-cli": "^0.15.0",
|
|
36
36
|
"@cloudbase/manager-node": "4.0.1",
|
|
37
37
|
"@cloudbase/toolbox": "^0.7.3",
|
|
38
38
|
"@sentry/node": "^5.10.2",
|
package/types/env/index.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
export * from './domain';
|
|
2
2
|
export * from './login';
|
|
3
3
|
export declare function initTcb(skey: string): Promise<any>;
|
|
4
|
-
export declare function createEnv({ alias, paymentMode }: {
|
|
5
|
-
alias: any;
|
|
6
|
-
paymentMode: any;
|
|
7
|
-
}): Promise<{
|
|
8
|
-
envId: string;
|
|
9
|
-
}>;
|
|
10
4
|
export declare function getEnvInfo(envId: string): Promise<any>;
|
|
11
5
|
export declare function listEnvs(options?: {
|
|
12
6
|
source?: string[];
|
package/types/run/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { ITcbrServiceOptions, IDescribeWxCloudBaseRunReleaseOrder, IAuthorizedTcrInstance } from '../../types';
|
|
2
|
+
export declare const describeCloudRunServerDetail: (options: {
|
|
3
|
+
envId: string;
|
|
4
|
+
serviceName: string;
|
|
5
|
+
}) => Promise<any>;
|
|
2
6
|
export declare function describeWxCloudBaseRunReleaseOrder(options: IDescribeWxCloudBaseRunReleaseOrder): Promise<any>;
|
|
3
7
|
export declare const convertNumber: (item: any) => number;
|
|
4
8
|
export declare const extractPolicyDetails: (policyDetails: string) => {
|
package/.vscode/settings.json
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.CreateCommand = void 0;
|
|
28
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
29
|
-
const env_1 = require("../../env");
|
|
30
|
-
const utils_1 = require("../../utils");
|
|
31
|
-
const error_1 = require("../../error");
|
|
32
|
-
const common_1 = require("../common");
|
|
33
|
-
const decorators_1 = require("../../decorators");
|
|
34
|
-
let CreateCommand = class CreateCommand extends common_1.Command {
|
|
35
|
-
get options() {
|
|
36
|
-
return {
|
|
37
|
-
cmd: 'env',
|
|
38
|
-
childCmd: 'create <alias>',
|
|
39
|
-
deprecateCmd: 'env:create <alias>',
|
|
40
|
-
options: [],
|
|
41
|
-
desc: '创建云开发免费环境',
|
|
42
|
-
requiredEnvId: false
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
execute(params) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const alias = params === null || params === void 0 ? void 0 : params[0];
|
|
48
|
-
if (!alias) {
|
|
49
|
-
throw new error_1.CloudBaseError('环境名称不能为空!');
|
|
50
|
-
}
|
|
51
|
-
const loading = (0, utils_1.loadingFactory)();
|
|
52
|
-
loading.start('检查中...');
|
|
53
|
-
const { CurrentFreeEnvNum, MaxFreeEnvNum, CurrentEnvNum, MaxEnvNum } = yield (0, env_1.getEnvLimit)();
|
|
54
|
-
loading.stop();
|
|
55
|
-
if (+CurrentFreeEnvNum >= +MaxFreeEnvNum) {
|
|
56
|
-
const link = (0, utils_1.genClickableLink)('https://console.cloud.tencent.com/tcb');
|
|
57
|
-
throw new error_1.CloudBaseError(`免费环境数量已达上限,无法创建免费的环境,请到云开发-控制台中创建付费环境\n👉 ${link}`);
|
|
58
|
-
}
|
|
59
|
-
if (+CurrentEnvNum >= +MaxEnvNum) {
|
|
60
|
-
throw new error_1.CloudBaseError('环境数量已达上限,无法创建新的环境!');
|
|
61
|
-
}
|
|
62
|
-
const { payment } = yield inquirer_1.default.prompt({
|
|
63
|
-
type: 'list',
|
|
64
|
-
name: 'payment',
|
|
65
|
-
choices: [
|
|
66
|
-
{
|
|
67
|
-
name: '按量计费(免费配额)',
|
|
68
|
-
value: 'postpay'
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: '包年包月(免费版本)',
|
|
72
|
-
value: 'prepay'
|
|
73
|
-
}
|
|
74
|
-
],
|
|
75
|
-
message: '请选择环境计费模式:',
|
|
76
|
-
default: 'postpay'
|
|
77
|
-
});
|
|
78
|
-
const { confirm } = yield inquirer_1.default.prompt({
|
|
79
|
-
type: 'confirm',
|
|
80
|
-
name: 'confirm',
|
|
81
|
-
message: '因支付权限问题,仅支持通过 API 秘钥登录的主账户使用 CLI 创建包年包月免费环境,其他用户需要登录控制台支付相关订单才能完成环境创建,是否继续?',
|
|
82
|
-
default: false
|
|
83
|
-
});
|
|
84
|
-
if (!confirm) {
|
|
85
|
-
throw new error_1.CloudBaseError('创建环境流程终止');
|
|
86
|
-
}
|
|
87
|
-
loading.start('环境创建中...');
|
|
88
|
-
try {
|
|
89
|
-
const res = yield (0, env_1.createEnv)({
|
|
90
|
-
alias,
|
|
91
|
-
paymentMode: payment
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
catch (e) {
|
|
95
|
-
if (e.code === 'ResourceInsufficient') {
|
|
96
|
-
throw new error_1.CloudBaseError('环境数量已达上限,无法创建新的环境!');
|
|
97
|
-
}
|
|
98
|
-
throw e;
|
|
99
|
-
}
|
|
100
|
-
loading.succeed('创建环境成功,初始化预计需要花费 3 分钟');
|
|
101
|
-
console.log('你可以使用 cloudbase init 创建云开发项目');
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
__decorate([
|
|
106
|
-
(0, decorators_1.InjectParams)(),
|
|
107
|
-
__param(0, (0, decorators_1.ArgsParams)()),
|
|
108
|
-
__metadata("design:type", Function),
|
|
109
|
-
__metadata("design:paramtypes", [Object]),
|
|
110
|
-
__metadata("design:returntype", Promise)
|
|
111
|
-
], CreateCommand.prototype, "execute", null);
|
|
112
|
-
CreateCommand = __decorate([
|
|
113
|
-
(0, common_1.ICommand)()
|
|
114
|
-
], CreateCommand);
|
|
115
|
-
exports.CreateCommand = CreateCommand;
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
exports.CreateRun = void 0;
|
|
25
|
-
const common_1 = require("../common");
|
|
26
|
-
const error_1 = require("../../error");
|
|
27
|
-
const run_1 = require("../../run");
|
|
28
|
-
const utils_1 = require("../../utils");
|
|
29
|
-
const decorators_1 = require("../../decorators");
|
|
30
|
-
const ZoneMap = {
|
|
31
|
-
shanghai: '上海',
|
|
32
|
-
guangzhou: '广州'
|
|
33
|
-
};
|
|
34
|
-
let CreateRun = class CreateRun extends common_1.Command {
|
|
35
|
-
get options() {
|
|
36
|
-
return {
|
|
37
|
-
cmd: 'run:deprecated',
|
|
38
|
-
childCmd: 'create',
|
|
39
|
-
options: [
|
|
40
|
-
{
|
|
41
|
-
flags: '-e, --envId <envId>',
|
|
42
|
-
desc: '环境 Id'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
flags: '-n, --name <name>',
|
|
46
|
-
desc: '服务名称,必填'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
flags: '-c, --vpc <vpc>',
|
|
50
|
-
desc: '云托管网络设置,默认系统创建,选择已有私有网络则填入格式为私有网络Id|子网Id1,...,子网Idn'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
flags: '-p, --repo <repo>',
|
|
54
|
-
desc: '镜像仓库名,默认系统创建'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
flags: '-m, --remark <remark>',
|
|
58
|
-
desc: '备注,默认为空'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
flags: '-a, --publicAccess <publicAccess>',
|
|
62
|
-
desc: '是否允许公网访问(Y/N),默认为允许'
|
|
63
|
-
}
|
|
64
|
-
],
|
|
65
|
-
desc: '创建云托管服务'
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
execute(envId, options) {
|
|
69
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, false);
|
|
71
|
-
if (envCheckType !== 0) {
|
|
72
|
-
(0, utils_1.logEnvCheck)(envId, envCheckType);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
let { name: _name = '', vpc: _vpc = '', repo: _repo = '', log: _log = '', remark: _remark = '', publicAccess: _publicAccess = '' } = options;
|
|
76
|
-
let name;
|
|
77
|
-
let remark;
|
|
78
|
-
let vpcInfo;
|
|
79
|
-
let imageRepo;
|
|
80
|
-
let logType;
|
|
81
|
-
let esInfo;
|
|
82
|
-
let publicAccess;
|
|
83
|
-
const loading = (0, utils_1.loadingFactory)();
|
|
84
|
-
if (!_name) {
|
|
85
|
-
throw new error_1.CloudBaseError('请填入服务名');
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
name = _name;
|
|
89
|
-
}
|
|
90
|
-
remark = _remark;
|
|
91
|
-
if (!_vpc) {
|
|
92
|
-
vpcInfo = {
|
|
93
|
-
VpcId: '',
|
|
94
|
-
SubnetIds: [],
|
|
95
|
-
CreateType: 1
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
vpcInfo = {
|
|
100
|
-
VpcId: _vpc.split('|')[0],
|
|
101
|
-
SubnetIds: _vpc.split('|')[1].split(','),
|
|
102
|
-
CreateType: 2
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
if (!_repo) {
|
|
106
|
-
imageRepo = undefined;
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
imageRepo = _repo;
|
|
110
|
-
}
|
|
111
|
-
if (!_log) {
|
|
112
|
-
logType = 'cls';
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
logType = 'es';
|
|
116
|
-
esInfo = _log.split('&').reduce((pre, item) => {
|
|
117
|
-
pre[item.split('=')[0]] = item.split('=')[0] === 'Port' ? Number(item.split('=')[1]) : item.split('=')[1];
|
|
118
|
-
return pre;
|
|
119
|
-
}, {});
|
|
120
|
-
}
|
|
121
|
-
if (!_publicAccess) {
|
|
122
|
-
publicAccess = 1;
|
|
123
|
-
}
|
|
124
|
-
else if (/[^nNyY]/.test(_publicAccess) || _publicAccess.length !== 1) {
|
|
125
|
-
throw new error_1.CloudBaseError('请输入符合规范的公网访问服务设置');
|
|
126
|
-
}
|
|
127
|
-
else if (_publicAccess === 'N' || _publicAccess === 'n') {
|
|
128
|
-
publicAccess = 2;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
publicAccess = 1;
|
|
132
|
-
}
|
|
133
|
-
const res = yield (0, run_1.createRun)({
|
|
134
|
-
envId,
|
|
135
|
-
name,
|
|
136
|
-
remark,
|
|
137
|
-
vpcInfo,
|
|
138
|
-
imageRepo,
|
|
139
|
-
logType,
|
|
140
|
-
esInfo,
|
|
141
|
-
publicAccess,
|
|
142
|
-
isPublic: true
|
|
143
|
-
});
|
|
144
|
-
if (res === 'succ')
|
|
145
|
-
loading.succeed(`云托管服务 ${name} 创建成功!`);
|
|
146
|
-
else
|
|
147
|
-
throw new error_1.CloudBaseError('创建失败,请查看是否已经有同名服务');
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
__decorate([
|
|
152
|
-
(0, decorators_1.InjectParams)(),
|
|
153
|
-
__param(0, (0, decorators_1.EnvId)()),
|
|
154
|
-
__param(1, (0, decorators_1.ArgsOptions)()),
|
|
155
|
-
__metadata("design:type", Function),
|
|
156
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
157
|
-
__metadata("design:returntype", Promise)
|
|
158
|
-
], CreateRun.prototype, "execute", null);
|
|
159
|
-
CreateRun = __decorate([
|
|
160
|
-
(0, common_1.ICommand)()
|
|
161
|
-
], CreateRun);
|
|
162
|
-
exports.CreateRun = CreateRun;
|