@cloudbase/cli 2.0.13 → 2.1.1-alpha.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/package_20220729165237.json +89 -0
- package/.history/package_20220729165240.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 +6 -1
- package/lib/commands/run/service/index.js +0 -1
- package/lib/commands/run/service/update.js +4 -0
- 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 +20 -7
- 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 +8 -1
- package/types/run/service/index.d.ts +0 -1
- package/types/types.d.ts +4 -0
- 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 -144
- 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/types/types.d.ts
CHANGED
|
@@ -490,6 +490,9 @@ export interface IDescribeCloudRunServerDetail {
|
|
|
490
490
|
ServerConfig: ITcbrServerBaseConfig;
|
|
491
491
|
RequestId: string;
|
|
492
492
|
}
|
|
493
|
+
export declare const enum TCBR_LOG_TYPE {
|
|
494
|
+
NONE = "none"
|
|
495
|
+
}
|
|
493
496
|
export interface ITcbrServiceOptions {
|
|
494
497
|
noConfirm: boolean;
|
|
495
498
|
override: boolean;
|
|
@@ -511,6 +514,7 @@ export interface ITcbrServiceOptions {
|
|
|
511
514
|
image: string;
|
|
512
515
|
custom_image: string;
|
|
513
516
|
library_image: string;
|
|
517
|
+
log_type: TCBR_LOG_TYPE;
|
|
514
518
|
json: boolean;
|
|
515
519
|
}
|
|
516
520
|
export interface ICloudRunProcessLog {
|
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;
|
|
@@ -1,144 +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.CreateServiceTcbr = void 0;
|
|
25
|
-
const common_1 = require("../../common");
|
|
26
|
-
const decorators_1 = require("../../../decorators");
|
|
27
|
-
const error_1 = require("../../../error");
|
|
28
|
-
const run_1 = require("../../../run");
|
|
29
|
-
const utils_1 = require("../../../utils");
|
|
30
|
-
let CreateServiceTcbr = class CreateServiceTcbr extends common_1.Command {
|
|
31
|
-
get options() {
|
|
32
|
-
return {
|
|
33
|
-
cmd: 'run',
|
|
34
|
-
childCmd: 'service:create',
|
|
35
|
-
options: [
|
|
36
|
-
{
|
|
37
|
-
flags: '--noConfirm',
|
|
38
|
-
desc: '发布前是否跳过二次确认'
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
flags: '--override',
|
|
42
|
-
desc: '缺省的参数是否沿用旧版本配置'
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
flags: '-e, --envId <envId>',
|
|
46
|
-
desc: '环境 Id,必填'
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
flags: '-s, --serviceName <serviceName>',
|
|
50
|
-
desc: '服务名,必填'
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
flags: '--path <path>',
|
|
54
|
-
desc: '本地代码根目录'
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
flags: '--cpu <cpu>',
|
|
58
|
-
desc: '单一实例cpu规格,默认0.5'
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
flags: '--mem <mem>',
|
|
62
|
-
desc: '单一实例内存规格,默认1'
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
flags: '--minNum <minNum>',
|
|
66
|
-
desc: '最小副本数,默认0'
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
flags: '--maxNum <maxNum>',
|
|
70
|
-
desc: '最大副本数,默认50,不能大于50'
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
flags: '--policyDetails <policyDetails>',
|
|
74
|
-
desc: '扩缩容配置,格式为条件类型=条件比例(%),多个条件之间用&隔开,内存条件为mem,cpu条件为cpu,默认内存>60% 或 CPU>60%,即cpu=60&mem=60'
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
flags: '--customLogs <customLogs>',
|
|
78
|
-
desc: '日志采集路径,默认stdout'
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
flags: '--envParams <envParams>',
|
|
82
|
-
desc: '环境变量,格式为xx=a&yy=b,默认为空'
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
flags: '--containerPort <containerPort>',
|
|
86
|
-
desc: '监听端口,必填'
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
flags: '--remark <remark>',
|
|
90
|
-
desc: '版本备注,默认为空'
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
flags: '--targetDir <targetDir>',
|
|
94
|
-
desc: '目标目录'
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
flags: '--dockerfile <dockerfile>',
|
|
98
|
-
desc: 'Dockerfile文件名,默认为 Dockerfile'
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
flags: '--custom_image <custom_image>',
|
|
102
|
-
desc: 'TCR 仓库镜像 URL'
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
flags: '--image <image>',
|
|
106
|
-
desc: '镜像标签或ID'
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
flags: '--json',
|
|
110
|
-
desc: '以 JSON 形式展示结果'
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
desc: '在指定环境下创建服务'
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
execute(options) {
|
|
117
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
-
let envCheckType = yield (0, utils_1.checkTcbrEnv)(options.envId, true);
|
|
119
|
-
if (envCheckType !== 0) {
|
|
120
|
-
(0, utils_1.logEnvCheck)(options.envId, envCheckType);
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
const { data: serviceDetail } = yield (0, run_1.describeCloudRunServerDetail)({
|
|
124
|
-
envId: options.envId,
|
|
125
|
-
serviceName: options.serviceName
|
|
126
|
-
});
|
|
127
|
-
if (serviceDetail !== undefined) {
|
|
128
|
-
throw new error_1.CloudBaseError('当前服务已存在,请使用 tcb run service:deploy 更新服务');
|
|
129
|
-
}
|
|
130
|
-
yield (0, run_1.createTcbrService)(options);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
__decorate([
|
|
135
|
-
(0, decorators_1.InjectParams)(),
|
|
136
|
-
__param(0, (0, decorators_1.ArgsOptions)()),
|
|
137
|
-
__metadata("design:type", Function),
|
|
138
|
-
__metadata("design:paramtypes", [Object]),
|
|
139
|
-
__metadata("design:returntype", Promise)
|
|
140
|
-
], CreateServiceTcbr.prototype, "execute", null);
|
|
141
|
-
CreateServiceTcbr = __decorate([
|
|
142
|
-
(0, common_1.ICommand)()
|
|
143
|
-
], CreateServiceTcbr);
|
|
144
|
-
exports.CreateServiceTcbr = CreateServiceTcbr;
|
package/lib/run/create.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.createRun = void 0;
|
|
13
|
-
const utils_1 = require("../utils");
|
|
14
|
-
const tcbService = utils_1.CloudApiService.getInstance('tcb');
|
|
15
|
-
const createRun = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
-
const { Result } = yield tcbService.request('EstablishCloudBaseRunServer', Object.assign(Object.assign({ EnvId: options.envId, ServiceName: options.name, Remark: options.remark, VpcInfo: options.vpcInfo, LogType: options.logType, IsPublic: options.isPublic }, (options.imageRepo ? { ImageRepo: options.imageRepo } : {})), (options.logType === 'es' ? { EsInfo: options.esInfo } : {})));
|
|
17
|
-
return Result;
|
|
18
|
-
});
|
|
19
|
-
exports.createRun = createRun;
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.createTcbrService = exports.createCloudRunServer = exports.describeCloudRunServerDetail = void 0;
|
|
16
|
-
const utils_1 = require("../../utils");
|
|
17
|
-
const _1 = require(".");
|
|
18
|
-
const inquirer_1 = __importDefault(require("inquirer"));
|
|
19
|
-
const toolbox_1 = require("@cloudbase/toolbox");
|
|
20
|
-
const describeCloudRunServerDetail = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
-
return yield (0, utils_1.callTcbrApi)('DescribeCloudRunServerDetail', {
|
|
22
|
-
EnvId: options.envId,
|
|
23
|
-
ServerName: options.serviceName,
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
exports.describeCloudRunServerDetail = describeCloudRunServerDetail;
|
|
27
|
-
function createCloudRunServer(serviceConfigOptions) {
|
|
28
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
return (0, utils_1.callTcbrApi)('CreateCloudRunServer', serviceConfigOptions);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
exports.createCloudRunServer = createCloudRunServer;
|
|
33
|
-
function createTcbrService(options) {
|
|
34
|
-
var _a;
|
|
35
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
const newServiceOptions = yield (0, _1.tcbrServiceOptions)(options, false, false);
|
|
37
|
-
if (!options.noConfirm) {
|
|
38
|
-
const { confirm } = yield inquirer_1.default.prompt([
|
|
39
|
-
{
|
|
40
|
-
type: 'confirm',
|
|
41
|
-
name: 'confirm',
|
|
42
|
-
message: '确定要创建服务吗?',
|
|
43
|
-
}
|
|
44
|
-
]);
|
|
45
|
-
if (!confirm) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
const createRes = yield createCloudRunServer(newServiceOptions);
|
|
50
|
-
const taskId = (_a = createRes.data) === null || _a === void 0 ? void 0 : _a.TaskId;
|
|
51
|
-
if (options.json) {
|
|
52
|
-
console.log(JSON.stringify(createRes, null, 2));
|
|
53
|
-
}
|
|
54
|
-
if (process.argv.includes('--verbose')) {
|
|
55
|
-
yield (0, _1.getLogs)({
|
|
56
|
-
envId: options.envId,
|
|
57
|
-
taskId,
|
|
58
|
-
serviceName: options.serviceName
|
|
59
|
-
});
|
|
60
|
-
console.log(`本次任务的 TaskID: ${taskId}`);
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
toolbox_1.logger.success('创建服务成功, 本次任务的 TaskID: ' + taskId);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
exports.createTcbrService = createTcbrService;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Command } from '../common';
|
|
2
|
-
export declare class CreateCommand extends Command {
|
|
3
|
-
get options(): {
|
|
4
|
-
cmd: string;
|
|
5
|
-
childCmd: string;
|
|
6
|
-
deprecateCmd: string;
|
|
7
|
-
options: any[];
|
|
8
|
-
desc: string;
|
|
9
|
-
requiredEnvId: boolean;
|
|
10
|
-
};
|
|
11
|
-
execute(params: any): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Command } from '../common';
|
|
2
|
-
export declare class CreateRun extends Command {
|
|
3
|
-
get options(): {
|
|
4
|
-
cmd: string;
|
|
5
|
-
childCmd: string;
|
|
6
|
-
options: {
|
|
7
|
-
flags: string;
|
|
8
|
-
desc: string;
|
|
9
|
-
}[];
|
|
10
|
-
desc: string;
|
|
11
|
-
};
|
|
12
|
-
execute(envId: any, options: any): Promise<void>;
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Command } from '../../common';
|
|
2
|
-
export declare class CreateServiceTcbr extends Command {
|
|
3
|
-
get options(): {
|
|
4
|
-
cmd: string;
|
|
5
|
-
childCmd: string;
|
|
6
|
-
options: {
|
|
7
|
-
flags: string;
|
|
8
|
-
desc: string;
|
|
9
|
-
}[];
|
|
10
|
-
desc: string;
|
|
11
|
-
};
|
|
12
|
-
execute(options: any): Promise<void>;
|
|
13
|
-
}
|
package/types/run/create.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ITcbrServiceOptions } from '../../types';
|
|
2
|
-
export declare const describeCloudRunServerDetail: (options: {
|
|
3
|
-
envId: string;
|
|
4
|
-
serviceName: string;
|
|
5
|
-
}) => Promise<any>;
|
|
6
|
-
export declare function createCloudRunServer(serviceConfigOptions: Record<string, any>): Promise<any>;
|
|
7
|
-
export declare function createTcbrService(options: ITcbrServiceOptions): Promise<void>;
|