@cloudbase/cli 1.12.7-alpha.4 → 2.0.2
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/bin/tcb.js +6 -4
- package/lib/commands/run/create.js +6 -1
- package/lib/commands/run/delete.js +6 -1
- package/lib/commands/run/image/common.js +1 -1
- package/lib/commands/run/image/delete.js +5 -0
- package/lib/commands/run/image/download.js +5 -0
- package/lib/commands/run/image/list.js +5 -0
- package/lib/commands/run/image/upload.js +5 -0
- package/lib/commands/run/index.js +1 -0
- package/lib/commands/run/list.js +7 -1
- package/lib/commands/run/service/config.js +112 -0
- package/lib/commands/run/service/create.js +140 -0
- package/lib/commands/run/service/deploy.js +145 -0
- package/lib/commands/run/service/index.js +21 -0
- package/lib/commands/run/service/list.js +115 -0
- package/lib/commands/run/service/update.js +132 -0
- package/lib/commands/run/version/common.js +1 -1
- package/lib/commands/run/version/create.js +5 -0
- package/lib/commands/run/version/delete.js +5 -0
- package/lib/commands/run/version/list.js +5 -0
- package/lib/commands/run/version/modify.js +5 -0
- package/lib/commands/run/version/update.js +5 -0
- package/lib/constant.js +20 -1
- package/lib/help.js +40 -38
- package/lib/run/index.js +1 -0
- package/lib/run/service/common.js +163 -0
- package/lib/run/service/config.js +70 -0
- package/lib/run/service/create.js +67 -0
- package/lib/run/service/deployPackage.js +89 -0
- package/lib/run/service/index.js +23 -0
- package/lib/run/service/list.js +31 -0
- package/lib/run/service/showLogs.js +116 -0
- package/lib/run/service/update.js +83 -0
- package/lib/utils/checkTcbrEnv.js +74 -0
- package/lib/utils/commonParamsCheck.js +48 -0
- package/lib/utils/index.js +3 -0
- package/lib/utils/net/http-request.js +4 -4
- package/lib/utils/tcbrApi/callTcbrApi.js +38 -0
- package/lib/utils/tcbrApi/index.js +17 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.js +268 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/error.js +17 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/index.js +17 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api/request.js +40 -0
- package/lib/utils/tcbrApi/tcbr-cloud-api-request.js +61 -0
- package/lib/utils/validator.js +32 -1
- package/package.json +88 -88
- package/src/commands/run/create.ts +9 -2
- package/src/commands/run/delete.ts +8 -2
- package/src/commands/run/image/common.ts +1 -1
- package/src/commands/run/image/delete.ts +8 -1
- package/src/commands/run/image/download.ts +7 -1
- package/src/commands/run/image/list.ts +7 -2
- package/src/commands/run/image/upload.ts +8 -1
- package/src/commands/run/index.ts +2 -1
- package/src/commands/run/list.ts +11 -3
- package/src/commands/run/service/config.ts +81 -0
- package/src/commands/run/service/create.ts +118 -0
- package/src/commands/run/service/deploy.ts +121 -0
- package/src/commands/run/service/index.ts +5 -0
- package/src/commands/run/service/list.ts +94 -0
- package/src/commands/run/service/update.ts +104 -0
- package/src/commands/run/version/common.ts +1 -1
- package/src/commands/run/version/create.ts +8 -1
- package/src/commands/run/version/delete.ts +8 -2
- package/src/commands/run/version/list.ts +7 -1
- package/src/commands/run/version/modify.ts +8 -1
- package/src/commands/run/version/update.ts +8 -1
- package/src/constant.ts +35 -1
- package/src/help.ts +50 -48
- package/src/run/index.ts +2 -1
- package/src/run/service/common.ts +206 -0
- package/src/run/service/config.ts +77 -0
- package/src/run/service/create.ts +52 -0
- package/src/run/service/deployPackage.ts +65 -0
- package/src/run/service/index.ts +7 -0
- package/src/run/service/list.ts +29 -0
- package/src/run/service/showLogs.ts +98 -0
- package/src/run/service/update.ts +81 -0
- package/src/types.ts +128 -2
- package/src/utils/checkTcbrEnv.ts +67 -0
- package/src/utils/commonParamsCheck.ts +65 -0
- package/src/utils/index.ts +5 -1
- package/src/utils/net/http-request.ts +1 -1
- package/src/utils/tcbrApi/callTcbrApi.ts +28 -0
- package/src/utils/tcbrApi/index.ts +1 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.ts +363 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/error.ts +30 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/index.ts +1 -0
- package/src/utils/tcbrApi/tcbr-cloud-api/request.ts +28 -0
- package/src/utils/tcbrApi/tcbr-cloud-api-request.ts +66 -0
- package/src/utils/validator.ts +64 -32
- package/types/commands/run/index.d.ts +1 -0
- package/types/commands/run/service/config.d.ts +14 -0
- package/types/commands/run/service/create.d.ts +13 -0
- package/types/commands/run/service/deploy.d.ts +13 -0
- package/types/commands/run/service/index.d.ts +5 -0
- package/types/commands/run/service/list.d.ts +13 -0
- package/types/commands/run/service/update.d.ts +13 -0
- package/types/constant.d.ts +18 -0
- package/types/run/index.d.ts +1 -0
- package/types/run/service/common.d.ts +32 -0
- package/types/run/service/config.d.ts +23 -0
- package/types/run/service/create.d.ts +7 -0
- package/types/run/service/deployPackage.d.ts +11 -0
- package/types/run/service/index.d.ts +7 -0
- package/types/run/service/list.d.ts +2 -0
- package/types/run/service/showLogs.d.ts +2 -0
- package/types/run/service/update.d.ts +2 -0
- package/types/types.d.ts +116 -2
- package/types/utils/checkTcbrEnv.d.ts +3 -0
- package/types/utils/commonParamsCheck.d.ts +3 -0
- package/types/utils/index.d.ts +3 -0
- package/types/utils/tcbrApi/callTcbrApi.d.ts +1 -0
- package/types/utils/tcbrApi/index.d.ts +1 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/cloud-api-service.d.ts +51 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/error.d.ts +20 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/index.d.ts +1 -0
- package/types/utils/tcbrApi/tcbr-cloud-api/request.d.ts +4 -0
- package/types/utils/tcbrApi/tcbr-cloud-api-request.d.ts +9 -0
- package/types/utils/validator.d.ts +4 -0
|
@@ -0,0 +1,70 @@
|
|
|
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.updateCloudRunServerConfig = exports.tcbrServiceConfigOptions = void 0;
|
|
13
|
+
const create_1 = require("./create");
|
|
14
|
+
const toolbox_1 = require("@cloudbase/toolbox");
|
|
15
|
+
const common_1 = require("./common");
|
|
16
|
+
const utils_1 = require("../../utils");
|
|
17
|
+
function tcbrServiceConfigOptions(options) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
let { serviceName, envId, cpu, mem, minNum, maxNum, policyDetails, customLogs, envParams, } = options;
|
|
20
|
+
if (!envId) {
|
|
21
|
+
throw new toolbox_1.CloudBaseError('必须使用 -e 或 --envId 指定环境ID');
|
|
22
|
+
}
|
|
23
|
+
if (!serviceName) {
|
|
24
|
+
throw new toolbox_1.CloudBaseError('必须使用 -s 或 --serviceName 指定服务名');
|
|
25
|
+
}
|
|
26
|
+
let { cpuConverted, memConverted, maxNumConverted, minNumConverted } = (0, utils_1.parseOptionalParams)({
|
|
27
|
+
cpu,
|
|
28
|
+
mem,
|
|
29
|
+
maxNum,
|
|
30
|
+
minNum
|
|
31
|
+
});
|
|
32
|
+
const serviceInfo = yield (0, create_1.describeCloudRunServerDetail)({
|
|
33
|
+
envId,
|
|
34
|
+
serviceName
|
|
35
|
+
});
|
|
36
|
+
if (serviceInfo instanceof Error && serviceInfo['code'] === 'InvalidParameter') {
|
|
37
|
+
throw new toolbox_1.CloudBaseError('服务不存在,请检查服务名是否正确或用 tcb run service:create 创建服务');
|
|
38
|
+
}
|
|
39
|
+
const { ServerConfig: previousServerConfig } = serviceInfo.data;
|
|
40
|
+
const newServiceOptions = {
|
|
41
|
+
EnvId: envId,
|
|
42
|
+
ServerName: serviceName,
|
|
43
|
+
OpenAccessTypes: previousServerConfig.OpenAccessTypes,
|
|
44
|
+
Cpu: cpuConverted || previousServerConfig.Cpu,
|
|
45
|
+
Mem: memConverted || previousServerConfig.Mem,
|
|
46
|
+
MinNum: minNumConverted || previousServerConfig.MinNum,
|
|
47
|
+
MaxNum: maxNumConverted || previousServerConfig.MaxNum,
|
|
48
|
+
PolicyDetails: policyDetails ? (0, common_1.extractPolicyDetails)(policyDetails) : previousServerConfig.PolicyDetails,
|
|
49
|
+
CustomLogs: customLogs || previousServerConfig.CustomLogs,
|
|
50
|
+
EnvParams: envParams ? (0, common_1.mergeEnvParams)(envParams, previousServerConfig === null || previousServerConfig === void 0 ? void 0 : previousServerConfig.EnvParams) : previousServerConfig.EnvParams,
|
|
51
|
+
InitialDelaySeconds: 2,
|
|
52
|
+
CreateTime: previousServerConfig.CreateTime,
|
|
53
|
+
Port: previousServerConfig.Port,
|
|
54
|
+
HasDockerfile: true,
|
|
55
|
+
Dockerfile: previousServerConfig.Dockerfile,
|
|
56
|
+
BuildDir: previousServerConfig.BuildDir,
|
|
57
|
+
};
|
|
58
|
+
return newServiceOptions;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
exports.tcbrServiceConfigOptions = tcbrServiceConfigOptions;
|
|
62
|
+
function updateCloudRunServerConfig(options) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
return yield (0, utils_1.callTcbrApi)('UpdateCloudRunServerConfig', {
|
|
65
|
+
EnvId: options.envId,
|
|
66
|
+
ServerBaseConfig: options.ServerBaseConfig,
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
exports.updateCloudRunServerConfig = updateCloudRunServerConfig;
|
|
@@ -0,0 +1,67 @@
|
|
|
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;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
+
};
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.packageDeploy = void 0;
|
|
39
|
+
const path_1 = __importDefault(require("path"));
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
42
|
+
const __1 = require("..");
|
|
43
|
+
const toolbox_1 = require("@cloudbase/toolbox");
|
|
44
|
+
function packageDeploy(options) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
let { envId, serviceName, filePath, fileToIgnore } = options;
|
|
47
|
+
let { PackageName, PackageVersion, UploadUrl } = yield (0, __1.createBuild)({
|
|
48
|
+
envId,
|
|
49
|
+
serviceName
|
|
50
|
+
});
|
|
51
|
+
const loading = (0, toolbox_1.loadingFactory)();
|
|
52
|
+
const zipFile = `.tcbr_${serviceName}_${Date.now()}.zip`;
|
|
53
|
+
const dstPath = path_1.default.join(process.cwd(), zipFile);
|
|
54
|
+
try {
|
|
55
|
+
if (fs.statSync(filePath).isDirectory()) {
|
|
56
|
+
loading.start('正在压缩文件…');
|
|
57
|
+
yield (0, toolbox_1.zipDir)(filePath, dstPath, fileToIgnore);
|
|
58
|
+
loading.succeed('压缩文件完成');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
if (error.code === 'ENOENT') {
|
|
63
|
+
throw new toolbox_1.CloudBaseError('找不到指定文件夹,请检查文件路径是否正确');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
throw new toolbox_1.CloudBaseError(error.message);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
return yield (0, toolbox_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
yield (0, node_fetch_1.default)(UploadUrl, {
|
|
72
|
+
method: 'PUT',
|
|
73
|
+
body: fs.createReadStream(zipFile),
|
|
74
|
+
headers: {
|
|
75
|
+
'content-type': 'application/zip'
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return { PackageName, PackageVersion };
|
|
79
|
+
}), {
|
|
80
|
+
startTip: '\n正在上传代码包...',
|
|
81
|
+
failTip: '上传代码包失败,请稍后重试'
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
yield fs.promises.unlink(dstPath);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
exports.packageDeploy = packageDeploy;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./list"), exports);
|
|
18
|
+
__exportStar(require("./create"), exports);
|
|
19
|
+
__exportStar(require("./showLogs"), exports);
|
|
20
|
+
__exportStar(require("./deployPackage"), exports);
|
|
21
|
+
__exportStar(require("./common"), exports);
|
|
22
|
+
__exportStar(require("./update"), exports);
|
|
23
|
+
__exportStar(require("./config"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
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.listService = void 0;
|
|
13
|
+
const utils_1 = require("../../utils");
|
|
14
|
+
const tcbService = utils_1.CloudApiService.getInstance('tcb');
|
|
15
|
+
const listService = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const { data: { ServerList: serverList } } = yield (0, utils_1.callTcbrApi)('DescribeCloudRunServers', {
|
|
17
|
+
EnvId: options.envId,
|
|
18
|
+
});
|
|
19
|
+
const { CloudBaseRunServerSet: serverSet } = yield tcbService.request('DescribeCloudBaseRunServers', {
|
|
20
|
+
EnvId: options.envId,
|
|
21
|
+
Offset: 0,
|
|
22
|
+
Limit: options.limit || 100
|
|
23
|
+
});
|
|
24
|
+
if (!serverList.length)
|
|
25
|
+
return [];
|
|
26
|
+
const serverInfo = serverList.map(serverItem => {
|
|
27
|
+
return Object.assign(Object.assign({}, serverItem), { CreatedTime: serverSet.find((item) => item.ServerName === serverItem.ServerName).CreatedTime });
|
|
28
|
+
});
|
|
29
|
+
return serverInfo;
|
|
30
|
+
});
|
|
31
|
+
exports.listService = listService;
|
|
@@ -0,0 +1,116 @@
|
|
|
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.getLogs = exports.getBuildStatus = void 0;
|
|
16
|
+
const utils_1 = require("../../utils");
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
function getBuildStatus(envId, serviceName) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
const { data: deployRes } = yield (0, utils_1.callTcbrApi)('DescribeCloudRunDeployRecord', {
|
|
21
|
+
EnvId: envId,
|
|
22
|
+
ServerName: serviceName,
|
|
23
|
+
});
|
|
24
|
+
if (deployRes === null || deployRes === void 0 ? void 0 : deployRes.DeployRecords) {
|
|
25
|
+
if ((deployRes === null || deployRes === void 0 ? void 0 : deployRes.DeployRecords[0].Status) === "deploying") {
|
|
26
|
+
return Promise.resolve('pending');
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return Promise.resolve('completed');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return Promise.resolve('pending');
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.getBuildStatus = getBuildStatus;
|
|
38
|
+
function getBuildId(envId, serviceName) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
const { data: deployRes } = yield (0, utils_1.callTcbrApi)('DescribeCloudRunDeployRecord', {
|
|
41
|
+
EnvId: envId,
|
|
42
|
+
ServerName: serviceName,
|
|
43
|
+
});
|
|
44
|
+
if (deployRes === null || deployRes === void 0 ? void 0 : deployRes.DeployRecords) {
|
|
45
|
+
if (deployRes.DeployRecords[0].Status !== 'deploying') {
|
|
46
|
+
return Promise.resolve(deployRes.DeployRecords[0].BuildId);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function getRunId(envId, serviceName) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
return new Promise((resolve) => {
|
|
54
|
+
const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
const { data: deployRes } = yield (0, utils_1.callTcbrApi)('DescribeCloudRunDeployRecord', {
|
|
56
|
+
EnvId: envId,
|
|
57
|
+
ServerName: serviceName,
|
|
58
|
+
});
|
|
59
|
+
if (deployRes === null || deployRes === void 0 ? void 0 : deployRes.DeployRecords) {
|
|
60
|
+
clearInterval(timer);
|
|
61
|
+
resolve(deployRes.DeployRecords[0].RunId);
|
|
62
|
+
}
|
|
63
|
+
}), 3000);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function showProcessLogs(envId, runId, serviceName) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return new Promise(resolve => {
|
|
70
|
+
const timer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
if ((yield getBuildStatus(envId, serviceName)) === 'completed') {
|
|
72
|
+
clearInterval(timer);
|
|
73
|
+
resolve();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const { data: processLogs } = yield (0, utils_1.callTcbrApi)('DescribeCloudRunProcessLog', {
|
|
77
|
+
EnvId: envId,
|
|
78
|
+
RunId: runId,
|
|
79
|
+
});
|
|
80
|
+
if (processLogs === null || processLogs === void 0 ? void 0 : processLogs.Logs) {
|
|
81
|
+
console.log(processLogs === null || processLogs === void 0 ? void 0 : processLogs.Logs.join('\n'));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}), 5000);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function showBuildLogs(envId, serviceName, serverVersion = '', offset = 0) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const buildId = yield getBuildId(envId, serviceName);
|
|
92
|
+
const { data } = yield (0, utils_1.callTcbrApi)('DescribeCloudRunBuildLog', {
|
|
93
|
+
EnvId: envId,
|
|
94
|
+
BuildId: buildId,
|
|
95
|
+
ServerName: serviceName,
|
|
96
|
+
ServerVersion: serverVersion || '',
|
|
97
|
+
Offset: offset || 0,
|
|
98
|
+
});
|
|
99
|
+
if ((_a = data === null || data === void 0 ? void 0 : data.Log) === null || _a === void 0 ? void 0 : _a.Text) {
|
|
100
|
+
console.log((_b = data === null || data === void 0 ? void 0 : data.Log) === null || _b === void 0 ? void 0 : _b.Text);
|
|
101
|
+
}
|
|
102
|
+
return Promise.resolve();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function getLogs(options) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
const runId = yield getRunId(options.envId, options.serviceName);
|
|
108
|
+
console.log(chalk_1.default.blue('============ 日志开始 ==============='));
|
|
109
|
+
yield showProcessLogs(options.envId, runId, options.serviceName);
|
|
110
|
+
if ((yield getBuildStatus(options.envId, options.serviceName)) === 'completed') {
|
|
111
|
+
yield showBuildLogs(options.envId, options.serviceName);
|
|
112
|
+
}
|
|
113
|
+
console.log(chalk_1.default.blue('============ 日志结束 ==============='));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
exports.getLogs = getLogs;
|
|
@@ -0,0 +1,83 @@
|
|
|
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.updateTcbrService = exports.updateCloudRunServer = void 0;
|
|
16
|
+
const toolbox_1 = require("@cloudbase/toolbox");
|
|
17
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
18
|
+
const __1 = require("..");
|
|
19
|
+
const utils_1 = require("../../utils");
|
|
20
|
+
const common_1 = require("./common");
|
|
21
|
+
const showLogs_1 = require("./showLogs");
|
|
22
|
+
function updateCloudRunServer(serviceConfigOptions) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
try {
|
|
25
|
+
const res = yield (0, utils_1.callTcbrApi)('UpdateCloudRunServer', serviceConfigOptions);
|
|
26
|
+
return res;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.log(error);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.updateCloudRunServer = updateCloudRunServer;
|
|
34
|
+
function updateTcbrService(options) {
|
|
35
|
+
var _a;
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const { data: serviceDetail } = yield (0, __1.describeCloudRunServerDetail)({
|
|
38
|
+
envId: options.envId,
|
|
39
|
+
serviceName: options.serviceName
|
|
40
|
+
});
|
|
41
|
+
if (serviceDetail === undefined) {
|
|
42
|
+
throw new toolbox_1.CloudBaseError('当前服务不存在,请使用 tcb run service:create 创建服务');
|
|
43
|
+
}
|
|
44
|
+
const status = yield (0, showLogs_1.getBuildStatus)(options.envId, options.serviceName);
|
|
45
|
+
if (status === 'pending') {
|
|
46
|
+
throw new toolbox_1.CloudBaseError('服务正在更新部署,请稍后再试,或查看实时部署日志');
|
|
47
|
+
}
|
|
48
|
+
const previousServerConfig = serviceDetail === null || serviceDetail === void 0 ? void 0 : serviceDetail.ServerConfig;
|
|
49
|
+
const newServiceOptions = yield (0, common_1.tcbrServiceOptions)(options, true, true, previousServerConfig);
|
|
50
|
+
if (!options.noConfirm) {
|
|
51
|
+
const { confirm } = yield inquirer_1.default.prompt([
|
|
52
|
+
{
|
|
53
|
+
type: 'confirm',
|
|
54
|
+
name: 'confirm',
|
|
55
|
+
message: '确定要更新服务吗?',
|
|
56
|
+
}
|
|
57
|
+
]);
|
|
58
|
+
if (!confirm) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const updateRes = yield updateCloudRunServer(newServiceOptions);
|
|
63
|
+
if (updateRes instanceof Error) {
|
|
64
|
+
throw new toolbox_1.CloudBaseError('当前已有部署发布任务运行中,请稍后再试,或查看实时部署日志');
|
|
65
|
+
}
|
|
66
|
+
const taskId = (_a = updateRes.data) === null || _a === void 0 ? void 0 : _a.TaskId;
|
|
67
|
+
if (options.json) {
|
|
68
|
+
console.log(JSON.stringify(updateRes, null, 2));
|
|
69
|
+
}
|
|
70
|
+
if (process.argv.includes('--verbose')) {
|
|
71
|
+
yield (0, showLogs_1.getLogs)({
|
|
72
|
+
envId: options.envId,
|
|
73
|
+
taskId,
|
|
74
|
+
serviceName: options.serviceName
|
|
75
|
+
});
|
|
76
|
+
console.log(`本次任务的 TaskID: ${taskId}`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
toolbox_1.logger.success('更新服务成功, 本次任务的 TaskID: ' + taskId);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.updateTcbrService = updateTcbrService;
|
|
@@ -0,0 +1,74 @@
|
|
|
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.logEnvCheck = exports.checkTcbrEnv = void 0;
|
|
16
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
+
const error_1 = require("../error");
|
|
18
|
+
const net_1 = require("./net");
|
|
19
|
+
const tcbService = net_1.CloudApiService.getInstance('tcb');
|
|
20
|
+
const oldCmdSet = `
|
|
21
|
+
服务列表:tcb run:deprecated list --envId <envId>
|
|
22
|
+
创建服务:tcb run:deprecated create --envId <envId> --name <name>
|
|
23
|
+
删除服务:tcb run:deprecated delete --envId <envId> --serviceName <serviceName>
|
|
24
|
+
|
|
25
|
+
版本列表:tcb run:deprecated version list --envId <envId> --serviceName <serviceName>
|
|
26
|
+
创建版本:tcb run:deprecated version create --envId <envId> --serviceName <serviceName>
|
|
27
|
+
分配流量:tcb run:deprecated version modify --envId <envId> --serviceName <serviceName>
|
|
28
|
+
滚动更新:tcb run:deprecated version update --envId <envId> --serviceName <serviceName> --versionName <versionName>
|
|
29
|
+
删除版本:tcb run:deprecated version delete --envId <envId> --serviceName <serviceName> --versionName <versionName>
|
|
30
|
+
|
|
31
|
+
查看镜像:tcb run:deprecated image list --envId <envId> --serviceName <serviceName>
|
|
32
|
+
上传镜像:tcb run:deprecated image upload --envId <envId> --serviceName <serviceName> --imageId <imageId> --imageTag <imageTag>
|
|
33
|
+
下载镜像:tcb run:deprecated image download --envId <envId> --serviceName <serviceName> --imageTag <imageTag>
|
|
34
|
+
删除镜像:tcb run:deprecated image delete --envId <envId> --serviceName <serviceName> --imageTag <imageTag>
|
|
35
|
+
`;
|
|
36
|
+
const newCmdSet = `
|
|
37
|
+
查看环境下服务:tcb run service:list --envId <envId>
|
|
38
|
+
创建云托管服务:tcb run service:create --envId <envId> --serviceName <serviceName> --containerPort <containerPort>
|
|
39
|
+
更新云托管服务:tcb run service:update --envId <envId> --serviceName <serviceName> --containerPort <containerPort>
|
|
40
|
+
部署云托管服务:tcb run deploy --envId <envId> --serviceName <serviceName> --containerPort <containerPort>
|
|
41
|
+
更新服务基础配置:tcb run service:config --envId <envId> --serviceName <serviceName>
|
|
42
|
+
`;
|
|
43
|
+
function checkTcbrEnv(envId, isTcbr) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
if (envId === undefined) {
|
|
46
|
+
throw new error_1.CloudBaseError('请使用 -e 或 --envId 指定环境 ID');
|
|
47
|
+
}
|
|
48
|
+
const { EnvList: [envInfo] } = yield tcbService.request('DescribeEnvs', {
|
|
49
|
+
EnvId: envId
|
|
50
|
+
});
|
|
51
|
+
if (envInfo === undefined) {
|
|
52
|
+
throw new error_1.CloudBaseError('无法读取到有效的环境信息,请检查环境 ID 是否正确');
|
|
53
|
+
}
|
|
54
|
+
if ((envInfo.EnvType === 'tcbr' && isTcbr) || (envInfo.EnvType !== 'tcbr' && !isTcbr)) {
|
|
55
|
+
return 0;
|
|
56
|
+
}
|
|
57
|
+
else if (envInfo.EnvType === 'tcbr' && !isTcbr) {
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
else if (envInfo.EnvType !== 'tcbr' && isTcbr) {
|
|
61
|
+
return 2;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.checkTcbrEnv = checkTcbrEnv;
|
|
66
|
+
function logEnvCheck(envId, warningType) {
|
|
67
|
+
if (warningType === 1) {
|
|
68
|
+
throw new error_1.CloudBaseError(`当前能力不支持 ${envId} 环境,请使用如下操作集:${chalk_1.default.grey(newCmdSet)}`);
|
|
69
|
+
}
|
|
70
|
+
else if (warningType === 2) {
|
|
71
|
+
throw new error_1.CloudBaseError(`当前能力不支持 ${envId} 环境,请使用如下操作集:${chalk_1.default.grey(oldCmdSet)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.logEnvCheck = logEnvCheck;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseInputParam = exports.parseOptionalParams = void 0;
|
|
4
|
+
const error_1 = require("../error");
|
|
5
|
+
const run_1 = require("../run");
|
|
6
|
+
const validator_1 = require("./validator");
|
|
7
|
+
function parseOptionalParams(options) {
|
|
8
|
+
let cpuConverted;
|
|
9
|
+
let memConverted;
|
|
10
|
+
if (options.cpu || options.mem) {
|
|
11
|
+
let data = (0, validator_1.validateCpuMem)(options.cpu, options.mem);
|
|
12
|
+
[cpuConverted, memConverted] = [data.cpuOutput, data.memOutput];
|
|
13
|
+
}
|
|
14
|
+
let maxNumConverted;
|
|
15
|
+
if (options.maxNum) {
|
|
16
|
+
maxNumConverted = (0, run_1.convertNumber)(options.maxNum);
|
|
17
|
+
if (maxNumConverted < 0 || maxNumConverted > 50) {
|
|
18
|
+
throw new error_1.CloudBaseError('最大副本数必须大于等于0且小于等于50');
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
let minNumConverted;
|
|
22
|
+
if (options.minNum) {
|
|
23
|
+
minNumConverted = (0, run_1.convertNumber)(options.minNum);
|
|
24
|
+
if (minNumConverted < 0 || minNumConverted > 50) {
|
|
25
|
+
throw new error_1.CloudBaseError('最小副本数必须大于等于0且小于等于50');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (minNumConverted > maxNumConverted) {
|
|
29
|
+
throw new error_1.CloudBaseError('最小副本数不能大于最大副本数');
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
cpuConverted,
|
|
33
|
+
memConverted,
|
|
34
|
+
maxNumConverted,
|
|
35
|
+
minNumConverted
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.parseOptionalParams = parseOptionalParams;
|
|
39
|
+
function parseInputParam(originalParam, override, handler, overrideVal, defaultVal, ...args) {
|
|
40
|
+
return originalParam
|
|
41
|
+
? (typeof handler === 'function')
|
|
42
|
+
? handler(originalParam, ...args)
|
|
43
|
+
: originalParam
|
|
44
|
+
: override
|
|
45
|
+
? overrideVal
|
|
46
|
+
: defaultVal;
|
|
47
|
+
}
|
|
48
|
+
exports.parseInputParam = parseInputParam;
|
package/lib/utils/index.js
CHANGED
|
@@ -32,3 +32,6 @@ __exportStar(require("./auth"), exports);
|
|
|
32
32
|
__exportStar(require("./store"), exports);
|
|
33
33
|
__exportStar(require("./notice"), exports);
|
|
34
34
|
__exportStar(require("./parallel"), exports);
|
|
35
|
+
__exportStar(require("./tcbrApi"), exports);
|
|
36
|
+
__exportStar(require("./checkTcbrEnv"), exports);
|
|
37
|
+
__exportStar(require("./commonParamsCheck"), exports);
|
|
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.fetchStream = exports.postFetch = exports.fetch = void 0;
|
|
16
16
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
17
|
-
const https_proxy_agent_1 =
|
|
17
|
+
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
18
18
|
const constant_1 = require("../../constant");
|
|
19
19
|
const error_1 = require("../../error");
|
|
20
20
|
const proxy_1 = require("./proxy");
|
|
@@ -30,7 +30,7 @@ function fetch(url, config = {}) {
|
|
|
30
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
31
|
const proxy = (0, proxy_1.getProxy)();
|
|
32
32
|
if (proxy) {
|
|
33
|
-
config.agent = new https_proxy_agent_1.
|
|
33
|
+
config.agent = new https_proxy_agent_1.HttpsProxyAgent(proxy);
|
|
34
34
|
}
|
|
35
35
|
config.timeout = constant_1.REQUEST_TIMEOUT;
|
|
36
36
|
let json;
|
|
@@ -59,7 +59,7 @@ function postFetch(url, data) {
|
|
|
59
59
|
body: JSON.stringify(data)
|
|
60
60
|
};
|
|
61
61
|
if (proxy) {
|
|
62
|
-
config.agent = new https_proxy_agent_1.
|
|
62
|
+
config.agent = new https_proxy_agent_1.HttpsProxyAgent(proxy);
|
|
63
63
|
}
|
|
64
64
|
config.timeout = constant_1.REQUEST_TIMEOUT;
|
|
65
65
|
let json;
|
|
@@ -81,7 +81,7 @@ function fetchStream(url, config = {}) {
|
|
|
81
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
82
|
const proxy = (0, proxy_1.getProxy)();
|
|
83
83
|
if (proxy) {
|
|
84
|
-
config.agent = new https_proxy_agent_1.
|
|
84
|
+
config.agent = new https_proxy_agent_1.HttpsProxyAgent(proxy);
|
|
85
85
|
}
|
|
86
86
|
config.timeout = constant_1.REQUEST_TIMEOUT;
|
|
87
87
|
try {
|