@cloudbase/cli 2.10.0-beta.0 → 2.11.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- package/types/commands/index.d.ts +1 -0
|
@@ -34,20 +34,11 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
34
34
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
35
35
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
36
36
|
};
|
|
37
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
38
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
39
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
40
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
41
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
42
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
43
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
37
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
39
|
};
|
|
49
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.CloudRunRunCommand = exports.CloudRunDeployCommand = exports.CloudRunDeleteCommand = exports.CloudRunDownloadCommand = exports.CloudRunListCommand = exports.CloudRunInitCommand = exports.getAgentService = exports.getCloudrunService = void 0;
|
|
41
|
+
exports.CloudRunRunCommand = exports.CloudRunDeployCommand = exports.CloudRunDeleteCommand = exports.CloudRunDownloadCommand = exports.CloudRunListCommand = exports.CloudRunInitCommand = exports.cloudRunDeploy = exports.getAgentService = exports.getCloudrunService = void 0;
|
|
51
42
|
const functions_framework_1 = require("@cloudbase/functions-framework");
|
|
52
43
|
const iac_core_1 = require("@cloudbase/iac-core");
|
|
53
44
|
const manager_node_1 = __importDefault(require("@cloudbase/manager-node"));
|
|
@@ -61,7 +52,7 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
61
52
|
const nodemon = (() => { try {
|
|
62
53
|
return require('nodemon');
|
|
63
54
|
}
|
|
64
|
-
catch
|
|
55
|
+
catch {
|
|
65
56
|
return null;
|
|
66
57
|
} })();
|
|
67
58
|
const open_1 = __importDefault(require("open"));
|
|
@@ -84,38 +75,112 @@ const ResourceTitle = {
|
|
|
84
75
|
container: (0, i18n_1.t)('容器型云托管'),
|
|
85
76
|
function: (0, i18n_1.t)('函数型云托管')
|
|
86
77
|
};
|
|
87
|
-
function getCloudrunService(envId) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
proxy: (0, utils_1.getProxy)()
|
|
98
|
-
});
|
|
99
|
-
return app.cloudrun;
|
|
78
|
+
async function getCloudrunService(envId) {
|
|
79
|
+
const region = await (0, toolbox_1.getRegion)();
|
|
80
|
+
const { secretId, secretKey, token } = await (0, utils_1.checkAndGetCredential)(true);
|
|
81
|
+
const app = new manager_node_1.default({
|
|
82
|
+
region,
|
|
83
|
+
token,
|
|
84
|
+
envId,
|
|
85
|
+
secretId,
|
|
86
|
+
secretKey,
|
|
87
|
+
proxy: (0, utils_1.getProxy)()
|
|
100
88
|
});
|
|
89
|
+
return app.cloudrun;
|
|
101
90
|
}
|
|
102
91
|
exports.getCloudrunService = getCloudrunService;
|
|
103
|
-
function getAgentService(envId) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
proxy: (0, utils_1.getProxy)()
|
|
114
|
-
});
|
|
115
|
-
return app.agent;
|
|
92
|
+
async function getAgentService(envId) {
|
|
93
|
+
const region = await (0, toolbox_1.getRegion)();
|
|
94
|
+
const { secretId, secretKey, token } = await (0, utils_1.checkAndGetCredential)(true);
|
|
95
|
+
const app = new manager_node_1.default({
|
|
96
|
+
region,
|
|
97
|
+
token,
|
|
98
|
+
envId,
|
|
99
|
+
secretId,
|
|
100
|
+
secretKey,
|
|
101
|
+
proxy: (0, utils_1.getProxy)()
|
|
116
102
|
});
|
|
103
|
+
return app.agent;
|
|
117
104
|
}
|
|
118
105
|
exports.getAgentService = getAgentService;
|
|
106
|
+
async function cloudRunDeploy(deployOptions) {
|
|
107
|
+
const { envId, serviceName, targetDir, serverType, port, installDependency, log } = deployOptions;
|
|
108
|
+
try {
|
|
109
|
+
const cloudrunService = await getCloudrunService(envId);
|
|
110
|
+
utils_2.trackCallback === null || utils_2.trackCallback === void 0 ? void 0 : (0, utils_2.trackCallback)({
|
|
111
|
+
details: (0, i18n_1.t)('正在提交{{serverType}} {{serviceName}} 中,请稍候...', { serverType: ResourceTitle[serverType], serviceName }),
|
|
112
|
+
status: 'progress'
|
|
113
|
+
}, log);
|
|
114
|
+
await cloudrunService.deploy({
|
|
115
|
+
serverName: serviceName,
|
|
116
|
+
targetPath: targetDir,
|
|
117
|
+
serverConfig: {
|
|
118
|
+
...(port ? { Port: Number(port) } : {}),
|
|
119
|
+
InstallDependency: installDependency !== 'false'
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
utils_2.trackCallback === null || utils_2.trackCallback === void 0 ? void 0 : (0, utils_2.trackCallback)({
|
|
123
|
+
details: (0, i18n_1.t)('提交{{serverType}} {{serviceName}} 已完成!', { serverType: ResourceTitle[serverType], serviceName }),
|
|
124
|
+
status: 'done'
|
|
125
|
+
}, log);
|
|
126
|
+
await (0, utils_2.upsertCloudbaserc)(targetDir, {
|
|
127
|
+
envId,
|
|
128
|
+
cloudrun: { name: serviceName }
|
|
129
|
+
});
|
|
130
|
+
(0, utils_2.trackCallback)({
|
|
131
|
+
details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_1.EUrl.DevPlatform}?envId=${envId}#/platform-run/service/detail?serverName=${serviceName}&tabId=deploy&envId=${envId}` })
|
|
132
|
+
}, log);
|
|
133
|
+
}
|
|
134
|
+
catch (e) {
|
|
135
|
+
if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateCloudRunServer' && (e === null || e === void 0 ? void 0 : e.code) === 'ResourceInUse') {
|
|
136
|
+
inquirer_1.default
|
|
137
|
+
.prompt([
|
|
138
|
+
{
|
|
139
|
+
type: 'confirm',
|
|
140
|
+
name: 'confirm',
|
|
141
|
+
message: (0, i18n_1.t)('平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码'),
|
|
142
|
+
default: true
|
|
143
|
+
}
|
|
144
|
+
])
|
|
145
|
+
.then(async (answers) => {
|
|
146
|
+
if (answers.confirm) {
|
|
147
|
+
try {
|
|
148
|
+
const { task } = await CloudAPI.tcbrServiceRequest('DescribeServerManageTask', {
|
|
149
|
+
envId,
|
|
150
|
+
serverName: serviceName,
|
|
151
|
+
taskId: 0
|
|
152
|
+
});
|
|
153
|
+
const id = task === null || task === void 0 ? void 0 : task.id;
|
|
154
|
+
await CloudAPI.tcbrServiceRequest('OperateServerManage', {
|
|
155
|
+
envId,
|
|
156
|
+
operateType: 'cancel',
|
|
157
|
+
serverName: serviceName,
|
|
158
|
+
taskId: id
|
|
159
|
+
});
|
|
160
|
+
await cloudRunDeploy(deployOptions);
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
164
|
+
(0, utils_2.trackCallback)({
|
|
165
|
+
type: 'error',
|
|
166
|
+
details: error.message,
|
|
167
|
+
originalError: error
|
|
168
|
+
}, log);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
(0, utils_2.trackCallback)({
|
|
175
|
+
type: 'error',
|
|
176
|
+
details: `${e.message}`,
|
|
177
|
+
originalError: e
|
|
178
|
+
}, log);
|
|
179
|
+
throw e;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.cloudRunDeploy = cloudRunDeploy;
|
|
119
184
|
let CloudRunInitCommand = class CloudRunInitCommand extends common_1.Command {
|
|
120
185
|
get options() {
|
|
121
186
|
return {
|
|
@@ -144,55 +209,53 @@ let CloudRunInitCommand = class CloudRunInitCommand extends common_1.Command {
|
|
|
144
209
|
desc: (0, i18n_1.t)('初始化云托管服务代码项目')
|
|
145
210
|
};
|
|
146
211
|
}
|
|
147
|
-
execute(ctx, envId, log, options) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
});
|
|
212
|
+
async execute(ctx, envId, log, options) {
|
|
213
|
+
let { serviceName, targetPath, template } = options;
|
|
214
|
+
const targetDir = path_1.default.resolve(targetPath || process.cwd());
|
|
215
|
+
if (!envId) {
|
|
216
|
+
envId = await _selectEnv();
|
|
217
|
+
}
|
|
218
|
+
const cloudrunService = await getCloudrunService(envId);
|
|
219
|
+
if (!serviceName) {
|
|
220
|
+
serviceName = await _inputServiceName();
|
|
221
|
+
}
|
|
222
|
+
if (!template) {
|
|
223
|
+
const templates = await cloudrunService.getTemplates();
|
|
224
|
+
const { templateId } = await inquirer_1.default.prompt([
|
|
225
|
+
{
|
|
226
|
+
type: 'list',
|
|
227
|
+
name: 'templateId',
|
|
228
|
+
message: (0, i18n_1.t)('请选择模板'),
|
|
229
|
+
choices: templates.map((t) => ({
|
|
230
|
+
name: `${t.title}(${t.identifier})`,
|
|
231
|
+
value: t.identifier
|
|
232
|
+
}))
|
|
233
|
+
}
|
|
234
|
+
]);
|
|
235
|
+
template = templateId;
|
|
236
|
+
}
|
|
237
|
+
const spinner = (0, ora_1.default)({
|
|
238
|
+
text: (0, i18n_1.t)('正在初始化项目代码...'),
|
|
239
|
+
color: 'blue'
|
|
240
|
+
}).start();
|
|
241
|
+
try {
|
|
242
|
+
const { projectDir } = await cloudrunService.init({
|
|
243
|
+
serverName: serviceName,
|
|
244
|
+
template,
|
|
245
|
+
targetPath: targetDir
|
|
246
|
+
});
|
|
247
|
+
await (0, utils_2.upsertCloudbaserc)(path_1.default.resolve(targetDir, serviceName), {
|
|
248
|
+
envId,
|
|
249
|
+
cloudrun: { name: serviceName }
|
|
250
|
+
});
|
|
251
|
+
spinner.succeed((0, i18n_1.t)('项目初始化成功'));
|
|
252
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('项目路径:{{projectDir}}', { projectDir })));
|
|
253
|
+
}
|
|
254
|
+
catch (e) {
|
|
255
|
+
spinner.fail((0, i18n_1.t)('项目初始化失败'));
|
|
256
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
257
|
+
log.error(error.message);
|
|
258
|
+
}
|
|
196
259
|
}
|
|
197
260
|
};
|
|
198
261
|
__decorate([
|
|
@@ -244,44 +307,42 @@ let CloudRunListCommand = class CloudRunListCommand extends common_1.Command {
|
|
|
244
307
|
desc: (0, i18n_1.t)('查看云托管服务列表')
|
|
245
308
|
};
|
|
246
309
|
}
|
|
247
|
-
execute(ctx, envId, log, options) {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
head: ['green']
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
const serverTypeTitleMap = {
|
|
268
|
-
function: (0, i18n_1.t)('函数型服务'),
|
|
269
|
-
container: (0, i18n_1.t)('容器型服务')
|
|
270
|
-
};
|
|
271
|
-
services.ServerList.forEach((service) => {
|
|
272
|
-
table.push([
|
|
273
|
-
service.ServerName,
|
|
274
|
-
serverTypeTitleMap[service.ServerType] || service.ServerType,
|
|
275
|
-
service.UpdateTime,
|
|
276
|
-
service.Status,
|
|
277
|
-
isPublicAccessOpen(service.AccessTypes) ? (0, i18n_1.t)('允许') : (0, i18n_1.t)('不允许')
|
|
278
|
-
]);
|
|
279
|
-
});
|
|
280
|
-
console.log(table.toString());
|
|
281
|
-
function isPublicAccessOpen(accessTypes) {
|
|
282
|
-
return (accessTypes === null || accessTypes === void 0 ? void 0 : accessTypes.includes(AccessType.PUBLIC)) || false;
|
|
310
|
+
async execute(ctx, envId, log, options) {
|
|
311
|
+
const { pageSize, pageNum, serviceName, serverType } = options;
|
|
312
|
+
if (!envId) {
|
|
313
|
+
envId = await _selectEnv();
|
|
314
|
+
}
|
|
315
|
+
log.info((0, i18n_1.t)('当前环境:{{envId}}', { envId }));
|
|
316
|
+
const cloudrunService = await getCloudrunService(envId);
|
|
317
|
+
const services = await cloudrunService.list({
|
|
318
|
+
pageSize: parseInt(pageSize),
|
|
319
|
+
pageNum: parseInt(pageNum),
|
|
320
|
+
serverName: serviceName,
|
|
321
|
+
serverType: serverType
|
|
322
|
+
});
|
|
323
|
+
const table = new cli_table3_1.default({
|
|
324
|
+
head: [(0, i18n_1.t)('服务名称'), (0, i18n_1.t)('类型'), (0, i18n_1.t)('更新时间'), (0, i18n_1.t)('运行状态'), (0, i18n_1.t)('公网访问')],
|
|
325
|
+
style: {
|
|
326
|
+
head: ['green']
|
|
283
327
|
}
|
|
284
328
|
});
|
|
329
|
+
const serverTypeTitleMap = {
|
|
330
|
+
function: (0, i18n_1.t)('函数型服务'),
|
|
331
|
+
container: (0, i18n_1.t)('容器型服务')
|
|
332
|
+
};
|
|
333
|
+
services.ServerList.forEach((service) => {
|
|
334
|
+
table.push([
|
|
335
|
+
service.ServerName,
|
|
336
|
+
serverTypeTitleMap[service.ServerType] || service.ServerType,
|
|
337
|
+
service.UpdateTime,
|
|
338
|
+
service.Status,
|
|
339
|
+
isPublicAccessOpen(service.AccessTypes) ? (0, i18n_1.t)('允许') : (0, i18n_1.t)('不允许')
|
|
340
|
+
]);
|
|
341
|
+
});
|
|
342
|
+
console.log(table.toString());
|
|
343
|
+
function isPublicAccessOpen(accessTypes) {
|
|
344
|
+
return (accessTypes === null || accessTypes === void 0 ? void 0 : accessTypes.includes(AccessType.PUBLIC)) || false;
|
|
345
|
+
}
|
|
285
346
|
}
|
|
286
347
|
};
|
|
287
348
|
__decorate([
|
|
@@ -329,75 +390,73 @@ let CloudRunDownloadCommand = class CloudRunDownloadCommand extends common_1.Com
|
|
|
329
390
|
desc: (0, i18n_1.t)('下载云托管服务代码')
|
|
330
391
|
};
|
|
331
392
|
}
|
|
332
|
-
execute(ctx, envId, log, options) {
|
|
393
|
+
async execute(ctx, envId, log, options) {
|
|
333
394
|
var _a;
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
395
|
+
let { serviceName, targetPath, force } = options;
|
|
396
|
+
let targetDir = path_1.default.resolve(targetPath || process.cwd());
|
|
397
|
+
if (!envId) {
|
|
398
|
+
envId = await _selectEnv();
|
|
399
|
+
}
|
|
400
|
+
log.info((0, i18n_1.t)('当前环境:{{envId}}', { envId }));
|
|
401
|
+
const cloudrunService = await getCloudrunService(envId);
|
|
402
|
+
const maybeInProject = await fs_extra_1.default.pathExists(path_1.default.join(targetDir, 'README.md'));
|
|
403
|
+
if (!serviceName) {
|
|
404
|
+
let defaultName = '';
|
|
405
|
+
if (maybeInProject) {
|
|
406
|
+
const config = await (0, utils_2.getCloudbaserc)(targetDir);
|
|
407
|
+
if ((_a = config === null || config === void 0 ? void 0 : config['cloudrun']) === null || _a === void 0 ? void 0 : _a['name']) {
|
|
408
|
+
defaultName = config['cloudrun']['name'];
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
const { shortName } = await (0, utils_2.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
|
|
412
|
+
if (shortName) {
|
|
413
|
+
defaultName = shortName;
|
|
349
414
|
}
|
|
350
415
|
else {
|
|
351
|
-
|
|
352
|
-
if (shortName) {
|
|
353
|
-
defaultName = shortName;
|
|
354
|
-
}
|
|
355
|
-
else {
|
|
356
|
-
defaultName = path_1.default.basename(targetDir);
|
|
357
|
-
}
|
|
416
|
+
defaultName = path_1.default.basename(targetDir);
|
|
358
417
|
}
|
|
359
418
|
}
|
|
360
|
-
serviceName = yield _inputServiceName(defaultName);
|
|
361
419
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
if (!answers.confirm) {
|
|
377
|
-
log.info((0, i18n_1.t)('用户已取消下载操作'));
|
|
378
|
-
return;
|
|
420
|
+
serviceName = await _inputServiceName(defaultName);
|
|
421
|
+
}
|
|
422
|
+
if (!targetPath) {
|
|
423
|
+
targetPath = await _inputTargetPath(maybeInProject ? targetDir : path_1.default.resolve(targetDir, serviceName));
|
|
424
|
+
targetDir = path_1.default.resolve(targetPath);
|
|
425
|
+
}
|
|
426
|
+
const needTips = !force && !(await (0, utils_2.isDirectoryEmptyOrNotExists)(targetDir));
|
|
427
|
+
if (needTips) {
|
|
428
|
+
const answers = await inquirer_1.default.prompt([
|
|
429
|
+
{
|
|
430
|
+
type: 'confirm',
|
|
431
|
+
name: 'confirm',
|
|
432
|
+
message: (0, i18n_1.t)('下载将覆盖 {{targetDir}} 目录下的代码,是否继续?', { targetDir }),
|
|
433
|
+
default: true
|
|
379
434
|
}
|
|
435
|
+
]);
|
|
436
|
+
if (!answers.confirm) {
|
|
437
|
+
log.info((0, i18n_1.t)('用户已取消下载操作'));
|
|
438
|
+
return;
|
|
380
439
|
}
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
}
|
|
400
|
-
}
|
|
440
|
+
}
|
|
441
|
+
try {
|
|
442
|
+
await cloudrunService.download({
|
|
443
|
+
serverName: serviceName,
|
|
444
|
+
targetPath: targetDir
|
|
445
|
+
});
|
|
446
|
+
await (0, utils_2.upsertCloudbaserc)(targetDir, {
|
|
447
|
+
envId,
|
|
448
|
+
cloudrun: { name: serviceName }
|
|
449
|
+
});
|
|
450
|
+
log.success((0, i18n_1.t)('云托管服务 {{serviceName}} 代码已成功下载到: {{targetDir}}', { serviceName, targetDir }));
|
|
451
|
+
}
|
|
452
|
+
catch (e) {
|
|
453
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
454
|
+
(0, utils_2.trackCallback)({
|
|
455
|
+
type: 'error',
|
|
456
|
+
details: error.message,
|
|
457
|
+
originalError: error
|
|
458
|
+
}, log);
|
|
459
|
+
}
|
|
401
460
|
}
|
|
402
461
|
};
|
|
403
462
|
__decorate([
|
|
@@ -440,52 +499,50 @@ let CloudRunDeleteCommand = class CloudRunDeleteCommand extends common_1.Command
|
|
|
440
499
|
desc: (0, i18n_1.t)('删除云托管服务')
|
|
441
500
|
};
|
|
442
501
|
}
|
|
443
|
-
execute(ctx, envId, log, options) {
|
|
502
|
+
async execute(ctx, envId, log, options) {
|
|
444
503
|
var _a;
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
default: false
|
|
467
|
-
}
|
|
468
|
-
]);
|
|
469
|
-
if (!answers.confirm) {
|
|
470
|
-
log.info((0, i18n_1.t)('已取消删除操作'));
|
|
471
|
-
return;
|
|
504
|
+
let { serviceName, force } = options;
|
|
505
|
+
if (!envId) {
|
|
506
|
+
envId = await _selectEnv();
|
|
507
|
+
}
|
|
508
|
+
log.info((0, i18n_1.t)('当前环境:{{envId}}', { envId }));
|
|
509
|
+
const cloudrunService = await getCloudrunService(envId);
|
|
510
|
+
if (!serviceName) {
|
|
511
|
+
const config = await (0, utils_2.getCloudbaserc)(process.cwd());
|
|
512
|
+
let detaultName = '';
|
|
513
|
+
if ((_a = config === null || config === void 0 ? void 0 : config['cloudrun']) === null || _a === void 0 ? void 0 : _a['name']) {
|
|
514
|
+
detaultName = config['cloudrun']['name'];
|
|
515
|
+
}
|
|
516
|
+
serviceName = await _inputServiceName(detaultName);
|
|
517
|
+
}
|
|
518
|
+
if (!force) {
|
|
519
|
+
const answers = await inquirer_1.default.prompt([
|
|
520
|
+
{
|
|
521
|
+
type: 'confirm',
|
|
522
|
+
name: 'confirm',
|
|
523
|
+
message: (0, i18n_1.t)('确定要删除云托管服务 {{serviceName}} 吗?', { serviceName }),
|
|
524
|
+
default: false
|
|
472
525
|
}
|
|
526
|
+
]);
|
|
527
|
+
if (!answers.confirm) {
|
|
528
|
+
log.info((0, i18n_1.t)('已取消删除操作'));
|
|
529
|
+
return;
|
|
473
530
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
}
|
|
488
|
-
}
|
|
531
|
+
}
|
|
532
|
+
try {
|
|
533
|
+
await cloudrunService.delete({
|
|
534
|
+
serverName: serviceName
|
|
535
|
+
});
|
|
536
|
+
log.success((0, i18n_1.t)('云托管服务 {{serviceName}} 删除成功', { serviceName }));
|
|
537
|
+
}
|
|
538
|
+
catch (e) {
|
|
539
|
+
const error = e instanceof Error ? e : new Error(String(e));
|
|
540
|
+
(0, utils_2.trackCallback)({
|
|
541
|
+
type: 'error',
|
|
542
|
+
details: error.message,
|
|
543
|
+
originalError: error
|
|
544
|
+
}, log);
|
|
545
|
+
}
|
|
489
546
|
}
|
|
490
547
|
};
|
|
491
548
|
__decorate([
|
|
@@ -544,191 +601,123 @@ let CloudRunDeployCommand = class CloudRunDeployCommand extends common_1.Command
|
|
|
544
601
|
desc: (0, i18n_1.t)('部署云托管服务')
|
|
545
602
|
};
|
|
546
603
|
}
|
|
547
|
-
execute(ctx, envId, log, options) {
|
|
604
|
+
async execute(ctx, envId, log, options) {
|
|
548
605
|
var _a, _b;
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
envId = envConfig.envId;
|
|
556
|
-
}
|
|
557
|
-
else {
|
|
558
|
-
envId = yield _selectEnv();
|
|
559
|
-
}
|
|
606
|
+
let { serviceName, source, force, port, createAgent, installDependency = 'true' } = options;
|
|
607
|
+
const targetDir = path_1.default.resolve(source || process.cwd());
|
|
608
|
+
if (!envId) {
|
|
609
|
+
const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(targetDir));
|
|
610
|
+
if (envConfig === null || envConfig === void 0 ? void 0 : envConfig.envId) {
|
|
611
|
+
envId = envConfig.envId;
|
|
560
612
|
}
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
{
|
|
576
|
-
type: 'input',
|
|
577
|
-
name: 'BotId',
|
|
578
|
-
message: (0, i18n_1.t)('请输入括号内的标识 ibot-(服务名-BotTag)。示例:agent-chat:'),
|
|
579
|
-
validate: (input) => {
|
|
580
|
-
if (!/^[a-z0-9_]+-[a-z0-9_]+$/.test(input)) {
|
|
581
|
-
return (0, i18n_1.t)('标识格式错误,应为"xxx-xxx"');
|
|
582
|
-
}
|
|
583
|
-
return true;
|
|
613
|
+
else {
|
|
614
|
+
envId = await _selectEnv();
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
618
|
+
if (createAgent) {
|
|
619
|
+
const questions = [
|
|
620
|
+
{
|
|
621
|
+
type: 'input',
|
|
622
|
+
name: 'Name',
|
|
623
|
+
message: (0, i18n_1.t)('请输入函数式 Agent 名称:'),
|
|
624
|
+
validate: (input) => {
|
|
625
|
+
if (!input.trim()) {
|
|
626
|
+
return (0, i18n_1.t)('名称不能为空');
|
|
584
627
|
}
|
|
628
|
+
return true;
|
|
585
629
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}, log);
|
|
597
|
-
return;
|
|
598
|
-
}
|
|
599
|
-
if (!serviceName) {
|
|
600
|
-
let defaultName = '';
|
|
601
|
-
const config = yield (0, utils_2.getCloudbaserc)(targetDir);
|
|
602
|
-
if ((_a = config === null || config === void 0 ? void 0 : config['cloudrun']) === null || _a === void 0 ? void 0 : _a['name']) {
|
|
603
|
-
defaultName = config['cloudrun']['name'];
|
|
604
|
-
}
|
|
605
|
-
else {
|
|
606
|
-
const { shortName } = yield (0, utils_2.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
|
|
607
|
-
defaultName = shortName;
|
|
608
|
-
}
|
|
609
|
-
serviceName = yield _inputServiceName(defaultName);
|
|
610
|
-
}
|
|
611
|
-
const containerConfigFile = 'container.config.json';
|
|
612
|
-
const containerConfigPath = path_1.default.join(targetDir, containerConfigFile);
|
|
613
|
-
if (yield fs_extra_1.default.pathExists(containerConfigPath)) {
|
|
614
|
-
log.warn((0, i18n_1.t)('CLI 中 {{containerConfigFile}} 文件将不会生效,请通过命令行参数进行配置!', { containerConfigFile }));
|
|
615
|
-
}
|
|
616
|
-
if (!force) {
|
|
617
|
-
const answers = yield inquirer_1.default.prompt([
|
|
618
|
-
{
|
|
619
|
-
type: 'confirm',
|
|
620
|
-
name: 'confirm',
|
|
621
|
-
message: (0, i18n_1.t)('即将开始部署,是否确认继续?'),
|
|
622
|
-
default: true
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
type: 'input',
|
|
633
|
+
name: 'BotId',
|
|
634
|
+
message: (0, i18n_1.t)('请输入括号内的标识 ibot-(服务名-BotTag)。示例:agent-chat:'),
|
|
635
|
+
validate: (input) => {
|
|
636
|
+
if (!/^[a-z0-9_]+-[a-z0-9_]+$/.test(input)) {
|
|
637
|
+
return (0, i18n_1.t)('标识格式错误,应为"xxx-xxx"');
|
|
638
|
+
}
|
|
639
|
+
return true;
|
|
623
640
|
}
|
|
624
|
-
]);
|
|
625
|
-
if (!answers.confirm) {
|
|
626
|
-
return;
|
|
627
641
|
}
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
642
|
+
];
|
|
643
|
+
const { Name, BotId } = await inquirer_1.default.prompt(questions);
|
|
644
|
+
const botId = `ibot-${BotId}`;
|
|
645
|
+
const agentService = await getAgentService(envId);
|
|
646
|
+
await agentService.createFunctionAgent(source, {
|
|
647
|
+
Name: Name,
|
|
648
|
+
BotId: botId
|
|
635
649
|
});
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
650
|
+
(0, utils_2.trackCallback)({
|
|
651
|
+
details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_1.EUrl.DevPlatform}?envId=${envId}#/ai?tab=agent&agent=${botId}` })
|
|
652
|
+
}, log);
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
if (!serviceName) {
|
|
656
|
+
let defaultName = '';
|
|
657
|
+
const config = await (0, utils_2.getCloudbaserc)(targetDir);
|
|
658
|
+
if ((_a = config === null || config === void 0 ? void 0 : config['cloudrun']) === null || _a === void 0 ? void 0 : _a['name']) {
|
|
659
|
+
defaultName = config['cloudrun']['name'];
|
|
641
660
|
}
|
|
642
|
-
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
661
|
+
else {
|
|
662
|
+
const { shortName } = await (0, utils_2.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
|
|
663
|
+
defaultName = shortName;
|
|
664
|
+
}
|
|
665
|
+
serviceName = await _inputServiceName(defaultName);
|
|
666
|
+
}
|
|
667
|
+
const containerConfigFile = 'container.config.json';
|
|
668
|
+
const containerConfigPath = path_1.default.join(targetDir, containerConfigFile);
|
|
669
|
+
if (await fs_extra_1.default.pathExists(containerConfigPath)) {
|
|
670
|
+
log.warn((0, i18n_1.t)('CLI 中 {{containerConfigFile}} 文件将不会生效,请通过命令行参数进行配置!', { containerConfigFile }));
|
|
671
|
+
}
|
|
672
|
+
if (!force) {
|
|
673
|
+
const answers = await inquirer_1.default.prompt([
|
|
674
|
+
{
|
|
675
|
+
type: 'confirm',
|
|
676
|
+
name: 'confirm',
|
|
677
|
+
message: (0, i18n_1.t)('即将开始部署,是否确认继续?'),
|
|
678
|
+
default: true
|
|
649
679
|
}
|
|
680
|
+
]);
|
|
681
|
+
if (!answers.confirm) {
|
|
682
|
+
return;
|
|
650
683
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
});
|
|
670
|
-
utils_2.trackCallback === null || utils_2.trackCallback === void 0 ? void 0 : (0, utils_2.trackCallback)({
|
|
671
|
-
details: (0, i18n_1.t)('提交{{serverType}} {{serviceName}} 已完成!', { serverType: ResourceTitle[serverType], serviceName }),
|
|
672
|
-
status: 'done'
|
|
673
|
-
}, log);
|
|
674
|
-
yield (0, utils_2.upsertCloudbaserc)(targetDir, {
|
|
675
|
-
envId,
|
|
676
|
-
cloudrun: { name: serviceName }
|
|
677
|
-
});
|
|
678
|
-
(0, utils_2.trackCallback)({
|
|
679
|
-
details: (0, i18n_1.t)('请打开链接查看部署状态: {{url}}', { url: `${utils_1.EUrl.DevPlatform}?envId=${envId}#/platform-run/service/detail?serverName=${serviceName}&tabId=deploy&envId=${envId}` })
|
|
680
|
-
}, log);
|
|
681
|
-
}
|
|
682
|
-
catch (e) {
|
|
683
|
-
if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateCloudRunServer' && (e === null || e === void 0 ? void 0 : e.code) === 'ResourceInUse') {
|
|
684
|
-
inquirer_1.default
|
|
685
|
-
.prompt([
|
|
686
|
-
{
|
|
687
|
-
type: 'confirm',
|
|
688
|
-
name: 'confirm',
|
|
689
|
-
message: (0, i18n_1.t)('平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码'),
|
|
690
|
-
default: true
|
|
691
|
-
}
|
|
692
|
-
])
|
|
693
|
-
.then((answers) => __awaiter(this, void 0, void 0, function* () {
|
|
694
|
-
if (answers.confirm) {
|
|
695
|
-
try {
|
|
696
|
-
const { task } = yield CloudAPI.tcbrServiceRequest('DescribeServerManageTask', {
|
|
697
|
-
envId,
|
|
698
|
-
serverName: serviceName,
|
|
699
|
-
taskId: 0
|
|
700
|
-
});
|
|
701
|
-
const id = task === null || task === void 0 ? void 0 : task.id;
|
|
702
|
-
yield CloudAPI.tcbrServiceRequest('OperateServerManage', {
|
|
703
|
-
envId,
|
|
704
|
-
operateType: 'cancel',
|
|
705
|
-
serverName: serviceName,
|
|
706
|
-
taskId: id
|
|
707
|
-
});
|
|
708
|
-
yield _runDeploy();
|
|
709
|
-
}
|
|
710
|
-
catch (e) {
|
|
711
|
-
const error = e instanceof Error ? e : new Error(String(e));
|
|
712
|
-
(0, utils_2.trackCallback)({
|
|
713
|
-
type: 'error',
|
|
714
|
-
details: error.message,
|
|
715
|
-
originalError: error
|
|
716
|
-
}, log);
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
}));
|
|
720
|
-
}
|
|
721
|
-
else {
|
|
722
|
-
(0, utils_2.trackCallback)({
|
|
723
|
-
type: 'error',
|
|
724
|
-
details: `${e.message}`,
|
|
725
|
-
originalError: e
|
|
726
|
-
}, log);
|
|
727
|
-
throw e;
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
});
|
|
684
|
+
}
|
|
685
|
+
await iac_core_1.IAC.init({
|
|
686
|
+
cwd: targetDir,
|
|
687
|
+
getCredential: () => {
|
|
688
|
+
return (0, utils_2.getCredential)(ctx, options);
|
|
689
|
+
},
|
|
690
|
+
polyRepoMode: true
|
|
691
|
+
});
|
|
692
|
+
const cloudrunService = await getCloudrunService(envId);
|
|
693
|
+
let serverType;
|
|
694
|
+
try {
|
|
695
|
+
const details = await cloudrunService.detail({ serverName: serviceName });
|
|
696
|
+
serverType = (_b = details.BaseInfo) === null || _b === void 0 ? void 0 : _b.ServerType;
|
|
697
|
+
}
|
|
698
|
+
catch (e) {
|
|
699
|
+
const dockerfilePath = path_1.default.join(targetDir, 'Dockerfile');
|
|
700
|
+
if (await fs_extra_1.default.pathExists(dockerfilePath)) {
|
|
701
|
+
serverType = 'container';
|
|
731
702
|
}
|
|
703
|
+
else {
|
|
704
|
+
serverType = 'function';
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
if (!serverType) {
|
|
708
|
+
throw new Error((0, i18n_1.t)('无法判断云托管服务类型'));
|
|
709
|
+
}
|
|
710
|
+
if (!['container', 'function'].includes(serverType)) {
|
|
711
|
+
throw new Error((0, i18n_1.t)('不支持的云托管服务类型:{{serverType}}', { serverType }));
|
|
712
|
+
}
|
|
713
|
+
await cloudRunDeploy({
|
|
714
|
+
envId,
|
|
715
|
+
serviceName,
|
|
716
|
+
targetDir,
|
|
717
|
+
serverType,
|
|
718
|
+
port,
|
|
719
|
+
installDependency,
|
|
720
|
+
log
|
|
732
721
|
});
|
|
733
722
|
}
|
|
734
723
|
};
|
|
@@ -802,173 +791,165 @@ let CloudRunRunCommand = class CloudRunRunCommand extends common_1.Command {
|
|
|
802
791
|
desc: (0, i18n_1.t)('本地运行函数型云托管服务(不支持容器型云托管服务)')
|
|
803
792
|
};
|
|
804
793
|
}
|
|
805
|
-
execute(envId, logger, ctx, options) {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
794
|
+
async execute(envId, logger, ctx, options) {
|
|
795
|
+
debugger;
|
|
796
|
+
let { runMode = 'normal', agentId, openDebugPanel = true } = options;
|
|
797
|
+
const type = runMode;
|
|
798
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('当前运行模式: {{type}}', { type })));
|
|
799
|
+
if (!process.argv.some((arg) => arg.includes('--dotEnvFilePath='))) {
|
|
800
|
+
process.argv.push('--dotEnvFilePath=.env.local');
|
|
801
|
+
}
|
|
802
|
+
const args = process.argv.slice(2);
|
|
803
|
+
const watchFlag = ['--watch', '-w'];
|
|
804
|
+
const defaultIgnoreFiles = ['logs/*.*'];
|
|
805
|
+
if (!envId) {
|
|
806
|
+
const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(process.cwd()));
|
|
807
|
+
if (envConfig === null || envConfig === void 0 ? void 0 : envConfig.envId) {
|
|
808
|
+
envId = envConfig.envId;
|
|
813
809
|
}
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
const defaultIgnoreFiles = ['logs/*.*'];
|
|
817
|
-
if (!envId) {
|
|
818
|
-
const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(process.cwd()));
|
|
819
|
-
if (envConfig === null || envConfig === void 0 ? void 0 : envConfig.envId) {
|
|
820
|
-
envId = envConfig.envId;
|
|
821
|
-
}
|
|
822
|
-
else {
|
|
823
|
-
envId = yield _selectEnv();
|
|
824
|
-
}
|
|
810
|
+
else {
|
|
811
|
+
envId = await _selectEnv();
|
|
825
812
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
813
|
+
}
|
|
814
|
+
logger.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
815
|
+
if (type === 'agent') {
|
|
816
|
+
if (!agentId) {
|
|
817
|
+
const answers = await inquirer_1.default.prompt([
|
|
818
|
+
{
|
|
819
|
+
type: 'input',
|
|
820
|
+
name: 'agentId',
|
|
821
|
+
message: (0, i18n_1.t)('请输入 Agent ID(如没有请填写任意值):'),
|
|
822
|
+
validate: (val) => {
|
|
823
|
+
return val.trim() ? true : (0, i18n_1.t)('Agent ID 不能为空');
|
|
837
824
|
}
|
|
838
|
-
]);
|
|
839
|
-
agentId = answers.agentId;
|
|
840
|
-
}
|
|
841
|
-
logger.info((0, i18n_1.t)('当前 Agent ID: {{agentId}}', { agentId }));
|
|
842
|
-
}
|
|
843
|
-
const credential = yield (0, utils_2.getCredential)(ctx, options);
|
|
844
|
-
process.env.EXTENDED_CONTEXT = JSON.stringify({
|
|
845
|
-
tmpSecret: {
|
|
846
|
-
secretId: credential.secretId,
|
|
847
|
-
secretKey: credential.secretKey,
|
|
848
|
-
token: credential.token
|
|
849
|
-
},
|
|
850
|
-
source: 'local_dev',
|
|
851
|
-
envId,
|
|
852
|
-
accessToken: `Bearer ${yield (0, utils_2.fetchAccessToken)({
|
|
853
|
-
envId,
|
|
854
|
-
secretId: credential.secretId,
|
|
855
|
-
secretKey: credential.secretKey,
|
|
856
|
-
token: credential.token
|
|
857
|
-
})}`
|
|
858
|
-
});
|
|
859
|
-
process.env.STATIC_SERVE_ROOT = __dirname;
|
|
860
|
-
process.env.ENABLE_CORS = 'true';
|
|
861
|
-
process.env.ALLOWED_ORIGINS = '*';
|
|
862
|
-
const port = options.port || process.env.PORT || 3000;
|
|
863
|
-
if (watchFlag.some((flag) => args.includes(flag))) {
|
|
864
|
-
const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
|
|
865
|
-
const nodemonInstance = nodemon({
|
|
866
|
-
script: '',
|
|
867
|
-
exec: `${process.argv[1]} ${cmd} --envId=${envId} --runMode=${type} --agentId=${agentId}`,
|
|
868
|
-
watchOptions: {
|
|
869
|
-
usePolling: true,
|
|
870
|
-
ignorePermissionErrors: true,
|
|
871
|
-
ignored: defaultIgnoreFiles.join(','),
|
|
872
|
-
persistent: true,
|
|
873
|
-
interval: 500
|
|
874
|
-
},
|
|
875
|
-
env: {
|
|
876
|
-
FROM_NODEMON: 'true'
|
|
877
|
-
},
|
|
878
|
-
ext: 'js,mjs,cjs,json,ts,yaml,yml'
|
|
879
|
-
})
|
|
880
|
-
.on('start', () => __awaiter(this, void 0, void 0, function* () {
|
|
881
|
-
logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
|
|
882
|
-
if (!process.env.NODEMON_FIRST_START) {
|
|
883
|
-
process.env.NODEMON_FIRST_START = 'true';
|
|
884
|
-
this.checkAndRunTsc();
|
|
885
|
-
this.openDebugApp(type, port, envId, agentId, openDebugPanel !== 'false');
|
|
886
825
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
826
|
+
]);
|
|
827
|
+
agentId = answers.agentId;
|
|
828
|
+
}
|
|
829
|
+
logger.info((0, i18n_1.t)('当前 Agent ID: {{agentId}}', { agentId }));
|
|
830
|
+
}
|
|
831
|
+
const credential = await (0, utils_2.getCredential)(ctx, options);
|
|
832
|
+
process.env.EXTENDED_CONTEXT = JSON.stringify({
|
|
833
|
+
tmpSecret: {
|
|
834
|
+
secretId: credential.secretId,
|
|
835
|
+
secretKey: credential.secretKey,
|
|
836
|
+
token: credential.token
|
|
837
|
+
},
|
|
838
|
+
source: 'local_dev',
|
|
839
|
+
envId,
|
|
840
|
+
accessToken: `Bearer ${await (0, utils_2.fetchAccessToken)({
|
|
841
|
+
envId,
|
|
842
|
+
secretId: credential.secretId,
|
|
843
|
+
secretKey: credential.secretKey,
|
|
844
|
+
token: credential.token
|
|
845
|
+
})}`
|
|
846
|
+
});
|
|
847
|
+
process.env.STATIC_SERVE_ROOT = __dirname;
|
|
848
|
+
process.env.ENABLE_CORS = 'true';
|
|
849
|
+
process.env.ALLOWED_ORIGINS = '*';
|
|
850
|
+
const port = options.port || process.env.PORT || 3000;
|
|
851
|
+
if (watchFlag.some((flag) => args.includes(flag))) {
|
|
852
|
+
const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
|
|
853
|
+
const nodemonInstance = nodemon({
|
|
854
|
+
script: '',
|
|
855
|
+
exec: `${process.argv[1]} ${cmd} --envId=${envId} --runMode=${type} --agentId=${agentId}`,
|
|
856
|
+
watchOptions: {
|
|
857
|
+
usePolling: true,
|
|
858
|
+
ignorePermissionErrors: true,
|
|
859
|
+
ignored: defaultIgnoreFiles.join(','),
|
|
860
|
+
persistent: true,
|
|
861
|
+
interval: 500
|
|
862
|
+
},
|
|
863
|
+
env: {
|
|
864
|
+
FROM_NODEMON: 'true'
|
|
865
|
+
},
|
|
866
|
+
ext: 'js,mjs,cjs,json,ts,yaml,yml'
|
|
867
|
+
})
|
|
868
|
+
.on('start', async () => {
|
|
869
|
+
logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
|
|
870
|
+
if (!process.env.NODEMON_FIRST_START) {
|
|
871
|
+
process.env.NODEMON_FIRST_START = 'true';
|
|
910
872
|
this.checkAndRunTsc();
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
873
|
+
this.openDebugApp(type, port, envId, agentId, openDebugPanel !== 'false');
|
|
874
|
+
}
|
|
875
|
+
})
|
|
876
|
+
.on('quit', (e) => {
|
|
877
|
+
logger.info(`Nodemon quit with code ${e}.`);
|
|
878
|
+
process.exit(0);
|
|
879
|
+
})
|
|
880
|
+
.on('restart', (e) => {
|
|
881
|
+
var _a, _b;
|
|
882
|
+
logger.info(`Server restarted due to changed files: ${(_b = (_a = e === null || e === void 0 ? void 0 : e.matched) === null || _a === void 0 ? void 0 : _a.result) === null || _b === void 0 ? void 0 : _b.join(', ')}`);
|
|
883
|
+
})
|
|
884
|
+
.on('log', (e) => {
|
|
885
|
+
logger.info(`[nodemon ${e.type}] ${e.message}`);
|
|
886
|
+
})
|
|
887
|
+
.on('crash', () => {
|
|
888
|
+
logger.error('Server crashed.');
|
|
889
|
+
process.exit(1);
|
|
890
|
+
})
|
|
891
|
+
.on('exit', (e) => {
|
|
892
|
+
logger.info(`Server exited with code ${e}.`);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
896
|
+
(0, functions_framework_1.runCLI)();
|
|
897
|
+
if (!process.env.FROM_NODEMON) {
|
|
898
|
+
this.checkAndRunTsc();
|
|
899
|
+
if (openDebugPanel) {
|
|
900
|
+
this.openDebugApp(type, port, envId, agentId, openDebugPanel !== 'false');
|
|
914
901
|
}
|
|
915
902
|
}
|
|
916
|
-
}
|
|
903
|
+
}
|
|
917
904
|
}
|
|
918
|
-
checkAndRunTsc() {
|
|
905
|
+
async checkAndRunTsc() {
|
|
919
906
|
var _a;
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
934
|
-
});
|
|
907
|
+
const tsConfigPath = path_1.default.join(process.cwd(), 'tsconfig.json');
|
|
908
|
+
if (await fs_extra_1.default.exists(tsConfigPath)) {
|
|
909
|
+
const child = (0, execa_1.default)('npx', ['tsc', '-w'], {
|
|
910
|
+
cwd: process.cwd(),
|
|
911
|
+
stdio: 'pipe'
|
|
912
|
+
});
|
|
913
|
+
(_a = child.stderr) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
914
|
+
console.log(data.toString());
|
|
915
|
+
});
|
|
916
|
+
child.on('exit', (code) => {
|
|
917
|
+
console.log((0, i18n_1.t)('子进程退出,退出码 {{code}}', { code }));
|
|
918
|
+
});
|
|
919
|
+
}
|
|
935
920
|
}
|
|
936
|
-
openDebugApp(type, port, envId, agentId, isOpen = true) {
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
});
|
|
921
|
+
async openDebugApp(type, port, envId, agentId, isOpen = true) {
|
|
922
|
+
let url = `http://127.0.0.1:${port}/cloudrun-run-ui/index.html?type=${type}&envId=${envId}&port=${port}`;
|
|
923
|
+
if (type === 'agent') {
|
|
924
|
+
url += `&agentId=${agentId}`;
|
|
925
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('点击 [{{url}}] 可以打开 Agent 调试应用', { url })));
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
console.log(chalk_1.default.green((0, i18n_1.t)('点击 [{{url}}] 可以打开函数调试面板', { url })));
|
|
929
|
+
}
|
|
930
|
+
if (isOpen) {
|
|
931
|
+
await this.waitForPort(url);
|
|
932
|
+
(0, open_1.default)(url, { wait: false });
|
|
933
|
+
}
|
|
951
934
|
}
|
|
952
|
-
waitForPort(url, timeout = 10000) {
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
return;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
catch (e) {
|
|
935
|
+
async waitForPort(url, timeout = 10000) {
|
|
936
|
+
const startTime = Date.now();
|
|
937
|
+
const { default: fetch } = await Promise.resolve().then(() => __importStar(require('node-fetch')));
|
|
938
|
+
while (Date.now() - startTime < timeout) {
|
|
939
|
+
try {
|
|
940
|
+
const response = await fetch(url, {
|
|
941
|
+
timeout: 1000,
|
|
942
|
+
method: 'HEAD'
|
|
943
|
+
});
|
|
944
|
+
if (response.ok) {
|
|
945
|
+
return;
|
|
967
946
|
}
|
|
968
|
-
yield new Promise((resolve) => setTimeout(resolve, 500));
|
|
969
947
|
}
|
|
970
|
-
|
|
971
|
-
|
|
948
|
+
catch (e) {
|
|
949
|
+
}
|
|
950
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
951
|
+
}
|
|
952
|
+
throw new Error((0, i18n_1.t)('等待服务{{url}}就绪超时', { url }));
|
|
972
953
|
}
|
|
973
954
|
};
|
|
974
955
|
__decorate([
|
|
@@ -985,56 +966,50 @@ CloudRunRunCommand = __decorate([
|
|
|
985
966
|
(0, common_1.ICommand)()
|
|
986
967
|
], CloudRunRunCommand);
|
|
987
968
|
exports.CloudRunRunCommand = CloudRunRunCommand;
|
|
988
|
-
function _selectEnv() {
|
|
989
|
-
return
|
|
990
|
-
return (0, utils_2.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
991
|
-
});
|
|
969
|
+
async function _selectEnv() {
|
|
970
|
+
return (0, utils_2.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
992
971
|
}
|
|
993
|
-
function _inputServiceName(defaultVal = '') {
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
return answers['serviceName'];
|
|
1013
|
-
});
|
|
972
|
+
async function _inputServiceName(defaultVal = '') {
|
|
973
|
+
const questions = [
|
|
974
|
+
{
|
|
975
|
+
type: 'input',
|
|
976
|
+
name: 'serviceName',
|
|
977
|
+
message: (0, i18n_1.t)('请输入服务名称'),
|
|
978
|
+
default: defaultVal,
|
|
979
|
+
validate: (val) => {
|
|
980
|
+
const isValid = !val.startsWith('lcap') &&
|
|
981
|
+
!val.startsWith('lowcode') &&
|
|
982
|
+
/^[A-Za-z][\w-_]{0,43}[A-Za-z0-9]$/.test(val);
|
|
983
|
+
return isValid
|
|
984
|
+
? true
|
|
985
|
+
: (0, i18n_1.t)('支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符');
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
];
|
|
989
|
+
const answers = await inquirer_1.default.prompt(questions);
|
|
990
|
+
return answers['serviceName'];
|
|
1014
991
|
}
|
|
1015
|
-
function _inputTargetPath(defaultVal = process.cwd()) {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
return true;
|
|
1027
|
-
}
|
|
1028
|
-
catch (e) {
|
|
1029
|
-
return (0, i18n_1.t)('请输入有效的路径');
|
|
1030
|
-
}
|
|
1031
|
-
},
|
|
1032
|
-
filter: (val) => {
|
|
1033
|
-
return path_1.default.normalize(val);
|
|
992
|
+
async function _inputTargetPath(defaultVal = process.cwd()) {
|
|
993
|
+
const questions = [
|
|
994
|
+
{
|
|
995
|
+
type: 'input',
|
|
996
|
+
name: 'targetPath',
|
|
997
|
+
message: (0, i18n_1.t)('请输入目标路径(目录名称或绝对路径)'),
|
|
998
|
+
default: defaultVal,
|
|
999
|
+
validate: (val) => {
|
|
1000
|
+
try {
|
|
1001
|
+
path_1.default.resolve(val);
|
|
1002
|
+
return true;
|
|
1034
1003
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1004
|
+
catch (e) {
|
|
1005
|
+
return (0, i18n_1.t)('请输入有效的路径');
|
|
1006
|
+
}
|
|
1007
|
+
},
|
|
1008
|
+
filter: (val) => {
|
|
1009
|
+
return path_1.default.normalize(val);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
];
|
|
1013
|
+
const answers = await inquirer_1.default.prompt(questions);
|
|
1014
|
+
return answers['targetPath'];
|
|
1040
1015
|
}
|