@cloudbase/cli 2.10.0-beta.0 → 2.11.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth/login.js +51 -65
- package/lib/auth/logout.js +3 -14
- package/lib/commands/account/login.js +136 -149
- package/lib/commands/account/logout.js +3 -14
- package/lib/commands/ag/base.js +203 -0
- package/lib/commands/ag/create.js +301 -0
- package/lib/commands/ag/debug/index.html +699 -0
- package/lib/commands/ag/delete.js +200 -0
- package/lib/commands/ag/deploy.js +185 -0
- package/lib/commands/ag/detail.js +113 -0
- package/lib/commands/ag/index.js +22 -0
- package/lib/commands/ag/list.js +155 -0
- package/lib/commands/ag/run.js +644 -0
- package/lib/commands/ai/index.js +76 -95
- package/lib/commands/cloudfunction/base.js +182 -203
- package/lib/commands/cloudrun/base.js +578 -603
- package/lib/commands/common.js +48 -63
- package/lib/commands/config/delete.js +16 -27
- package/lib/commands/config/get.js +13 -24
- package/lib/commands/config/list.js +16 -27
- package/lib/commands/config/set.js +33 -44
- package/lib/commands/db/base.js +221 -240
- package/lib/commands/env/base.js +36 -49
- package/lib/commands/env/domain.js +79 -94
- package/lib/commands/env/login.js +120 -135
- package/lib/commands/framework/index.js +32 -49
- package/lib/commands/fun/base.js +223 -244
- package/lib/commands/functions/alias/getRoute.js +33 -44
- package/lib/commands/functions/alias/setRoute.js +36 -47
- package/lib/commands/functions/code-download.js +43 -54
- package/lib/commands/functions/code-update.js +23 -34
- package/lib/commands/functions/concurrency/delete.js +11 -22
- package/lib/commands/functions/concurrency/list.js +20 -31
- package/lib/commands/functions/concurrency/set.js +13 -24
- package/lib/commands/functions/config-update.js +30 -41
- package/lib/commands/functions/copy.js +12 -23
- package/lib/commands/functions/delete.js +30 -41
- package/lib/commands/functions/deploy.js +184 -202
- package/lib/commands/functions/detail.js +23 -34
- package/lib/commands/functions/invoke.js +69 -75
- package/lib/commands/functions/layer/bind.js +102 -105
- package/lib/commands/functions/layer/create.js +29 -35
- package/lib/commands/functions/layer/delete.js +42 -48
- package/lib/commands/functions/layer/download.js +52 -58
- package/lib/commands/functions/layer/list.js +44 -50
- package/lib/commands/functions/layer/sort.js +39 -45
- package/lib/commands/functions/list.js +25 -36
- package/lib/commands/functions/log.js +65 -73
- package/lib/commands/functions/run.js +118 -116
- package/lib/commands/functions/trigger-create.js +32 -43
- package/lib/commands/functions/trigger-delete.js +50 -61
- package/lib/commands/functions/version/list.js +29 -40
- package/lib/commands/functions/version/publish.js +11 -22
- package/lib/commands/gateway/create.js +50 -61
- package/lib/commands/gateway/delete.js +38 -49
- package/lib/commands/gateway/domain.js +65 -80
- package/lib/commands/gateway/list.js +31 -42
- package/lib/commands/gateway/switch.js +48 -61
- package/lib/commands/helpers/init.js +226 -249
- package/lib/commands/helpers/new.js +35 -46
- package/lib/commands/helpers/open.js +22 -33
- package/lib/commands/hosting/hosting.js +157 -178
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/app.js +114 -144
- package/lib/commands/lowcode/comps.js +136 -127
- package/lib/commands/lowcode/utils.js +11 -22
- package/lib/commands/pull/pull.js +33 -46
- package/lib/commands/run/delete.js +35 -46
- package/lib/commands/run/image/delete.js +32 -39
- package/lib/commands/run/image/download.js +26 -33
- package/lib/commands/run/image/list.js +41 -48
- package/lib/commands/run/image/upload.js +26 -33
- package/lib/commands/run/list.js +32 -43
- package/lib/commands/run/service/config.js +17 -28
- package/lib/commands/run/service/deploy.js +15 -26
- package/lib/commands/run/service/list.js +48 -59
- package/lib/commands/run/service/update.js +7 -18
- package/lib/commands/run/standalonegateway/create.js +35 -42
- package/lib/commands/run/standalonegateway/destroy.js +23 -30
- package/lib/commands/run/standalonegateway/list.js +19 -26
- package/lib/commands/run/standalonegateway/package.js +31 -38
- package/lib/commands/run/standalonegateway/turn.js +27 -34
- package/lib/commands/run/version/create.js +198 -205
- package/lib/commands/run/version/delete.js +31 -38
- package/lib/commands/run/version/list.js +42 -49
- package/lib/commands/run/version/modify.js +27 -34
- package/lib/commands/run/version/update.js +201 -208
- package/lib/commands/runf/base.js +216 -237
- package/lib/commands/self-update.js +59 -72
- package/lib/commands/smart.js +66 -79
- package/lib/commands/storage/storage.js +192 -219
- package/lib/commands/third/thirdAttach.js +16 -27
- package/lib/commands/utils.js +119 -149
- package/lib/db/index.js +48 -67
- package/lib/decorators/captureError.js +10 -21
- package/lib/decorators/guard.js +11 -22
- package/lib/decorators/injectParams.js +29 -40
- package/lib/decorators/params/common.js +5 -2
- package/lib/decorators/params/index.js +3 -12
- package/lib/env/domain.js +13 -28
- package/lib/env/index.js +25 -44
- package/lib/env/login.js +30 -45
- package/lib/function/alias.js +31 -44
- package/lib/function/base.js +187 -215
- package/lib/function/code.js +8 -19
- package/lib/function/concurrency.js +43 -58
- package/lib/function/create.js +43 -53
- package/lib/function/delete.js +22 -35
- package/lib/function/layer/attach.js +33 -46
- package/lib/function/layer/create.js +34 -45
- package/lib/function/layer/delete.js +5 -16
- package/lib/function/layer/download.js +11 -22
- package/lib/function/layer/list.js +12 -25
- package/lib/function/layer/sort.js +6 -17
- package/lib/function/trigger.js +65 -82
- package/lib/function/update.js +24 -32
- package/lib/function/version.js +29 -42
- package/lib/function/vpc.js +12 -25
- package/lib/gateway/index.js +77 -104
- package/lib/hosting.js +157 -188
- package/lib/run/delete.js +3 -12
- package/lib/run/image/build.js +6 -15
- package/lib/run/image/delete.js +3 -12
- package/lib/run/image/info.js +3 -12
- package/lib/run/image/list.js +6 -15
- package/lib/run/list.js +19 -30
- package/lib/run/repo.js +6 -15
- package/lib/run/service/common.js +160 -173
- package/lib/run/service/config.js +44 -57
- package/lib/run/service/deployPackage.js +33 -44
- package/lib/run/service/list.js +8 -14
- package/lib/run/service/showLogs.js +69 -90
- package/lib/run/service/update.js +50 -63
- package/lib/run/standalonegateway/create.js +3 -12
- package/lib/run/standalonegateway/destroy.js +3 -12
- package/lib/run/standalonegateway/list.js +3 -12
- package/lib/run/standalonegateway/package/list.js +3 -12
- package/lib/run/standalonegateway/turn/off.js +3 -12
- package/lib/run/standalonegateway/turn/on.js +3 -12
- package/lib/run/version/create.js +41 -31
- package/lib/run/version/delete.js +3 -12
- package/lib/run/version/list.js +3 -12
- package/lib/run/version/modify.js +3 -12
- package/lib/run/version/repo.js +6 -15
- package/lib/run/version/update.js +37 -26
- package/lib/storage.js +62 -93
- package/lib/third/index.js +6 -17
- package/lib/utils/ai/banner.js +49 -60
- package/lib/utils/ai/claudeWindows.js +2 -2
- package/lib/utils/ai/config.js +169 -206
- package/lib/utils/ai/ensureFiles.js +6 -17
- package/lib/utils/ai/env.js +16 -27
- package/lib/utils/ai/envLocalManager.js +35 -52
- package/lib/utils/ai/router.js +927 -1005
- package/lib/utils/ai/setup.js +527 -563
- package/lib/utils/auth.js +3 -14
- package/lib/utils/checkTcbrEnv.js +20 -31
- package/lib/utils/cli-table.js +6 -1
- package/lib/utils/config.js +4 -13
- package/lib/utils/dts.js +98 -113
- package/lib/utils/env.js +154 -175
- package/lib/utils/function-packer.js +29 -42
- package/lib/utils/log.js +10 -21
- package/lib/utils/mcp-config-modifier.js +105 -120
- package/lib/utils/net/cloud-api-request.js +15 -23
- package/lib/utils/net/credential.js +26 -39
- package/lib/utils/net/http-request.js +63 -80
- package/lib/utils/net/manager-service.js +22 -35
- package/lib/utils/notice.js +16 -27
- package/lib/utils/output/loading.js +3 -12
- package/lib/utils/parallel.js +32 -43
- package/lib/utils/platform/mac.js +4 -15
- package/lib/utils/platform/port.js +4 -15
- package/lib/utils/prompt/select.js +6 -15
- package/lib/utils/report.js +28 -33
- package/lib/utils/reporter/agree.js +11 -22
- package/lib/utils/reporter/download.js +17 -28
- package/lib/utils/reporter/usage.js +12 -23
- package/lib/utils/store/auth.js +17 -30
- package/lib/utils/store/config.js +11 -25
- package/lib/utils/store/db.js +17 -36
- package/lib/utils/tcbrApi/callTcbrApi.js +19 -28
- package/lib/utils/template-manager.js +215 -242
- package/lib/utils/template.js +81 -96
- package/lib/utils/tools/common.js +45 -56
- package/lib/utils/tools/time.js +5 -16
- package/lib/utils/url.js +10 -4
- package/package.json +2 -2
- package/specs/ag-command/design.md +421 -0
- package/specs/ag-command/doc.md +204 -0
- package/specs/ag-command/requirements.md +173 -0
- package/specs/ag-command/summary.md +174 -0
- package/specs/ag-command/tasks.md +197 -0
- package/specs/ag-command/usage-guide.md +420 -0
- package/tsconfig.json +1 -1
- package/types/commands/ag/base.d.ts +44 -0
- package/types/commands/ag/create.d.ts +25 -0
- package/types/commands/ag/delete.d.ts +32 -0
- package/types/commands/ag/deploy.d.ts +31 -0
- package/types/commands/ag/detail.d.ts +28 -0
- package/types/commands/ag/index.d.ts +6 -0
- package/types/commands/ag/list.d.ts +35 -0
- package/types/commands/ag/run.d.ts +52 -0
- package/types/commands/cloudrun/base.d.ts +10 -0
- package/types/commands/index.d.ts +1 -0
package/lib/commands/ai/index.js
CHANGED
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
15
|
exports.AICommand = void 0;
|
|
25
16
|
const common_1 = require("../common");
|
|
@@ -77,74 +68,68 @@ let AICommand = class AICommand extends common_1.Command {
|
|
|
77
68
|
allowUnknownOption: true
|
|
78
69
|
};
|
|
79
70
|
}
|
|
80
|
-
execute(options, ctx, log) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return yield this.resetConfig(configManager, log);
|
|
91
|
-
}
|
|
92
|
-
if (setup) {
|
|
93
|
-
const wizard = new setup_1.AISetupWizard(envId);
|
|
94
|
-
return yield wizard.setUp(log);
|
|
95
|
-
}
|
|
96
|
-
if (config) {
|
|
97
|
-
return yield this.showConfig(configManager, log);
|
|
98
|
-
}
|
|
99
|
-
if (!(yield configManager.isConfigured())) {
|
|
100
|
-
const wizard = new setup_1.AISetupWizard(envId);
|
|
101
|
-
const { defaultAgent } = yield wizard.setUpDefault(log, agent);
|
|
102
|
-
agent = defaultAgent;
|
|
103
|
-
}
|
|
104
|
-
const args = this.parseArgs();
|
|
105
|
-
const router = new router_1.AICommandRouter();
|
|
106
|
-
yield router.execute({
|
|
107
|
-
addtionalArgs: args,
|
|
108
|
-
log,
|
|
109
|
-
agent: agent || (yield configManager.loadConfig()).defaultAgent,
|
|
110
|
-
envId,
|
|
111
|
-
template,
|
|
112
|
-
useDefaultConfig
|
|
113
|
-
});
|
|
71
|
+
async execute(options, ctx, log) {
|
|
72
|
+
await (0, ensureFiles_1.ensureFiles)();
|
|
73
|
+
const { envId, setup, config, reset, template, yes: useDefaultConfig } = options;
|
|
74
|
+
let { agent } = options;
|
|
75
|
+
try {
|
|
76
|
+
await (0, banner_1.showBanner)(log);
|
|
77
|
+
await reportAIUsage(agent, Boolean(envId), this.getSubCommand(ctx.params));
|
|
78
|
+
const configManager = new config_1.AIConfigManager();
|
|
79
|
+
if (reset) {
|
|
80
|
+
return await this.resetConfig(configManager, log);
|
|
114
81
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
82
|
+
if (setup) {
|
|
83
|
+
const wizard = new setup_1.AISetupWizard(envId);
|
|
84
|
+
return await wizard.setUp(log);
|
|
118
85
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
resetConfig(configManager, log) {
|
|
122
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
-
try {
|
|
124
|
-
yield configManager.resetConfig();
|
|
125
|
-
log.info((0, i18n_1.t)('✅ AI 配置已重置'));
|
|
86
|
+
if (config) {
|
|
87
|
+
return await this.showConfig(configManager, log);
|
|
126
88
|
}
|
|
127
|
-
|
|
128
|
-
|
|
89
|
+
if (!(await configManager.isConfigured())) {
|
|
90
|
+
const wizard = new setup_1.AISetupWizard(envId);
|
|
91
|
+
const { defaultAgent } = await wizard.setUpDefault(log, agent);
|
|
92
|
+
agent = defaultAgent;
|
|
129
93
|
}
|
|
130
|
-
|
|
94
|
+
const args = this.parseArgs();
|
|
95
|
+
const router = new router_1.AICommandRouter();
|
|
96
|
+
await router.execute({
|
|
97
|
+
addtionalArgs: args,
|
|
98
|
+
log,
|
|
99
|
+
agent: agent || (await configManager.loadConfig()).defaultAgent,
|
|
100
|
+
envId,
|
|
101
|
+
template,
|
|
102
|
+
useDefaultConfig
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
await reportAIError(agent, error.message);
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async resetConfig(configManager, log) {
|
|
111
|
+
try {
|
|
112
|
+
await configManager.resetConfig();
|
|
113
|
+
log.info((0, i18n_1.t)('✅ AI 配置已重置'));
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('重置配置失败'), { original: error });
|
|
117
|
+
}
|
|
131
118
|
}
|
|
132
|
-
showConfig(configManager, log) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
async showConfig(configManager, log) {
|
|
120
|
+
try {
|
|
121
|
+
const aiConfig = await configManager.loadConfig();
|
|
122
|
+
log.info((0, i18n_1.t)('当前 AI 配置:'));
|
|
123
|
+
log.info(JSON.stringify(aiConfig, null, 2));
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
if (error instanceof error_1.CloudBaseError && error.code === config_1.CONFIG_NOT_FOUND) {
|
|
127
|
+
log.error(error.message);
|
|
138
128
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
log.error(error.message);
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('读取配置失败'), { original: error });
|
|
145
|
-
}
|
|
129
|
+
else {
|
|
130
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('读取配置失败'), { original: error });
|
|
146
131
|
}
|
|
147
|
-
}
|
|
132
|
+
}
|
|
148
133
|
}
|
|
149
134
|
parseArgs() {
|
|
150
135
|
const args = process.argv.slice(2);
|
|
@@ -171,30 +156,26 @@ AICommand = __decorate([
|
|
|
171
156
|
(0, common_1.ICommand)()
|
|
172
157
|
], AICommand);
|
|
173
158
|
exports.AICommand = AICommand;
|
|
174
|
-
function reportAIUsage(agent, hasEnvId, subCommand) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
});
|
|
159
|
+
async function reportAIUsage(agent, hasEnvId, subCommand) {
|
|
160
|
+
try {
|
|
161
|
+
return await report_1.beaconAction.report('ai_command_usage', {
|
|
162
|
+
agent,
|
|
163
|
+
hasEnvId,
|
|
164
|
+
subCommand
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
187
170
|
}
|
|
188
|
-
function reportAIError(agent, error) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
});
|
|
171
|
+
async function reportAIError(agent, error) {
|
|
172
|
+
try {
|
|
173
|
+
return await report_1.beaconAction.report('ai_command_error', {
|
|
174
|
+
agent,
|
|
175
|
+
error
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
return null;
|
|
180
|
+
}
|
|
200
181
|
}
|
|
@@ -11,15 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
14
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
15
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
16
|
};
|
|
@@ -32,7 +23,7 @@ const inquirer_1 = __importDefault(require("inquirer"));
|
|
|
32
23
|
const nodemon = (() => { try {
|
|
33
24
|
return require('nodemon');
|
|
34
25
|
}
|
|
35
|
-
catch
|
|
26
|
+
catch {
|
|
36
27
|
return null;
|
|
37
28
|
} })();
|
|
38
29
|
const path_1 = __importDefault(require("path"));
|
|
@@ -65,78 +56,74 @@ let CloudFunctionDeployCommand = class CloudFunctionDeployCommand extends common
|
|
|
65
56
|
desc: (0, i18n_1.t)('部署云函数服务')
|
|
66
57
|
};
|
|
67
58
|
}
|
|
68
|
-
execute(ctx, envId, log, options) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
envId = envConfig.envId;
|
|
76
|
-
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
envId = yield _selectEnv();
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
59
|
+
async execute(ctx, envId, log, options) {
|
|
60
|
+
let { serviceName, source } = options;
|
|
61
|
+
const targetDir = path_1.default.resolve(source || process.cwd());
|
|
62
|
+
if (!envId) {
|
|
63
|
+
const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(targetDir));
|
|
64
|
+
if (envConfig.envId) {
|
|
65
|
+
envId = envConfig.envId;
|
|
83
66
|
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
84
67
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
serviceName = yield _inputServiceName(shortName);
|
|
68
|
+
else {
|
|
69
|
+
envId = await _selectEnv();
|
|
88
70
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
74
|
+
}
|
|
75
|
+
if (!serviceName) {
|
|
76
|
+
const { shortName } = await (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
|
|
77
|
+
serviceName = await _inputServiceName(shortName);
|
|
78
|
+
}
|
|
79
|
+
const answers = await inquirer_1.default.prompt([
|
|
80
|
+
{
|
|
81
|
+
type: 'confirm',
|
|
82
|
+
name: 'confirm',
|
|
83
|
+
message: (0, i18n_1.t)('即将开始部署,是否确认继续?'),
|
|
84
|
+
default: true
|
|
99
85
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateFunctionConfiguration' &&
|
|
122
|
-
((_a = e === null || e === void 0 ? void 0 : e.message) === null || _a === void 0 ? void 0 : _a.includes((0, i18n_1.t)('当前函数处于Updating状态,无法进行此操作,请稍后重试')))) {
|
|
123
|
-
(0, utils_1.trackCallback)({
|
|
124
|
-
type: 'error',
|
|
125
|
-
details: (0, i18n_1.t)('当前函数处于更新状态,无法进行此操作,请稍后重试'),
|
|
126
|
-
originalError: e
|
|
127
|
-
}, log);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
(0, utils_1.trackCallback)({
|
|
131
|
-
type: 'error',
|
|
132
|
-
details: `${e.message}`,
|
|
133
|
-
originalError: e
|
|
134
|
-
}, log);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
86
|
+
]);
|
|
87
|
+
if (!answers.confirm) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
await iac_core_1.IAC.init({
|
|
91
|
+
cwd: targetDir,
|
|
92
|
+
getCredential: () => {
|
|
93
|
+
return (0, utils_1.getCredential)(ctx, options);
|
|
94
|
+
},
|
|
95
|
+
polyRepoMode: true
|
|
96
|
+
});
|
|
97
|
+
await _runDeploy();
|
|
98
|
+
async function _runDeploy() {
|
|
99
|
+
var _a;
|
|
100
|
+
try {
|
|
101
|
+
await iac_core_1.IAC.Function.apply({
|
|
102
|
+
cwd: targetDir,
|
|
103
|
+
envId: envId,
|
|
104
|
+
name: serviceName
|
|
105
|
+
}, function (message) {
|
|
106
|
+
(0, utils_1.trackCallback)(message, log);
|
|
137
107
|
});
|
|
138
108
|
}
|
|
139
|
-
|
|
109
|
+
catch (e) {
|
|
110
|
+
if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateFunctionConfiguration' &&
|
|
111
|
+
((_a = e === null || e === void 0 ? void 0 : e.message) === null || _a === void 0 ? void 0 : _a.includes((0, i18n_1.t)('当前函数处于Updating状态,无法进行此操作,请稍后重试')))) {
|
|
112
|
+
(0, utils_1.trackCallback)({
|
|
113
|
+
type: 'error',
|
|
114
|
+
details: (0, i18n_1.t)('当前函数处于更新状态,无法进行此操作,请稍后重试'),
|
|
115
|
+
originalError: e
|
|
116
|
+
}, log);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
(0, utils_1.trackCallback)({
|
|
120
|
+
type: 'error',
|
|
121
|
+
details: `${e.message}`,
|
|
122
|
+
originalError: e
|
|
123
|
+
}, log);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
140
127
|
}
|
|
141
128
|
};
|
|
142
129
|
__decorate([
|
|
@@ -177,62 +164,60 @@ let CloudFunctionDownloadCommand = class CloudFunctionDownloadCommand extends co
|
|
|
177
164
|
desc: (0, i18n_1.t)('下载云函数服务代码')
|
|
178
165
|
};
|
|
179
166
|
}
|
|
180
|
-
execute(ctx, envId, log, options) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
167
|
+
async execute(ctx, envId, log, options) {
|
|
168
|
+
let { serviceName, source } = options;
|
|
169
|
+
let targetDir = path_1.default.resolve(source || process.cwd());
|
|
170
|
+
if (!envId) {
|
|
171
|
+
const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(targetDir));
|
|
172
|
+
envId = envConfig.envId || (await _selectEnv());
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
log.info((0, i18n_1.t)('当前环境 Id:{{envId}}', { envId }));
|
|
176
|
+
}
|
|
177
|
+
if (!serviceName) {
|
|
178
|
+
const { shortName } = await (0, utils_1.getPackageJsonName)(path_1.default.join(targetDir, 'package.json'));
|
|
179
|
+
serviceName = await _inputServiceName(shortName);
|
|
180
|
+
if (serviceName !== shortName) {
|
|
181
|
+
targetDir = path_1.default.join(targetDir, serviceName);
|
|
190
182
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
const answers = yield inquirer_1.default.prompt([
|
|
201
|
-
{
|
|
202
|
-
type: 'confirm',
|
|
203
|
-
name: 'confirm',
|
|
204
|
-
message: (0, i18n_1.t)('下载将覆盖 {{targetDir}} 目录下的代码,是否继续?', { targetDir }),
|
|
205
|
-
default: true
|
|
206
|
-
}
|
|
207
|
-
]);
|
|
208
|
-
if (!answers.confirm) {
|
|
209
|
-
return;
|
|
183
|
+
}
|
|
184
|
+
const needTips = !(await (0, utils_1.isDirectoryEmptyOrNotExists)(targetDir));
|
|
185
|
+
if (needTips) {
|
|
186
|
+
const answers = await inquirer_1.default.prompt([
|
|
187
|
+
{
|
|
188
|
+
type: 'confirm',
|
|
189
|
+
name: 'confirm',
|
|
190
|
+
message: (0, i18n_1.t)('下载将覆盖 {{targetDir}} 目录下的代码,是否继续?', { targetDir }),
|
|
191
|
+
default: true
|
|
210
192
|
}
|
|
193
|
+
]);
|
|
194
|
+
if (!answers.confirm) {
|
|
195
|
+
return;
|
|
211
196
|
}
|
|
212
|
-
|
|
197
|
+
}
|
|
198
|
+
await iac_core_1.IAC.init({
|
|
199
|
+
cwd: targetDir,
|
|
200
|
+
getCredential: () => {
|
|
201
|
+
return (0, utils_1.getCredential)(ctx, options);
|
|
202
|
+
},
|
|
203
|
+
polyRepoMode: true
|
|
204
|
+
});
|
|
205
|
+
try {
|
|
206
|
+
await iac_core_1.IAC.Function.pull({
|
|
213
207
|
cwd: targetDir,
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
envId: envId,
|
|
209
|
+
name: serviceName
|
|
210
|
+
}, function (message) {
|
|
211
|
+
(0, utils_1.trackCallback)(message, log);
|
|
218
212
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
catch (e) {
|
|
229
|
-
(0, utils_1.trackCallback)({
|
|
230
|
-
type: 'error',
|
|
231
|
-
details: `${e.message}`,
|
|
232
|
-
originalError: e
|
|
233
|
-
}, log);
|
|
234
|
-
}
|
|
235
|
-
});
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
(0, utils_1.trackCallback)({
|
|
216
|
+
type: 'error',
|
|
217
|
+
details: `${e.message}`,
|
|
218
|
+
originalError: e
|
|
219
|
+
}, log);
|
|
220
|
+
}
|
|
236
221
|
}
|
|
237
222
|
};
|
|
238
223
|
__decorate([
|
|
@@ -272,59 +257,57 @@ let CloudFunctionRunCommand = class CloudFunctionRunCommand extends common_1.Com
|
|
|
272
257
|
desc: (0, i18n_1.t)('本地运行云函数代码')
|
|
273
258
|
};
|
|
274
259
|
}
|
|
275
|
-
execute(logger, ctx, options) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
throw new Error((0, i18n_1.t)('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。'));
|
|
290
|
-
}
|
|
291
|
-
nodemon({
|
|
292
|
-
script: '',
|
|
293
|
-
exec: `${process.argv[1]} ${cmd}`,
|
|
294
|
-
watchOptions: {
|
|
295
|
-
usePolling: true,
|
|
296
|
-
ignorePermissionErrors: true,
|
|
297
|
-
ignored: defaultIgnoreFiles.join(','),
|
|
298
|
-
persistent: true,
|
|
299
|
-
interval: 500
|
|
300
|
-
}
|
|
301
|
-
})
|
|
302
|
-
.on('start', () => {
|
|
303
|
-
logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
|
|
304
|
-
})
|
|
305
|
-
.on('quit', (e) => {
|
|
306
|
-
logger.info(`Nodemon quit with code ${e}.`);
|
|
307
|
-
process.exit(0);
|
|
308
|
-
})
|
|
309
|
-
.on('restart', (e) => {
|
|
310
|
-
var _a, _b;
|
|
311
|
-
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(', ')}`);
|
|
312
|
-
})
|
|
313
|
-
.on('log', (e) => {
|
|
314
|
-
logger.info(`[nodemon ${e.type}] ${e.message}`);
|
|
315
|
-
})
|
|
316
|
-
.on('crash', () => {
|
|
317
|
-
logger.error('Server crashed.');
|
|
318
|
-
process.exit(1);
|
|
319
|
-
})
|
|
320
|
-
.on('exit', (e) => {
|
|
321
|
-
logger.info(`Server exited with code ${e}.`);
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
else {
|
|
325
|
-
(0, functions_framework_1.runCLI)();
|
|
260
|
+
async execute(logger, ctx, options) {
|
|
261
|
+
const args = process.argv.slice(2);
|
|
262
|
+
const watchFlag = ['--watch', '-w'];
|
|
263
|
+
const defaultIgnoreFiles = ['logs/*.*'];
|
|
264
|
+
const envConfig = (0, camelcase_keys_1.default)(await iac_core_1.utils.loadEnv(process.cwd()));
|
|
265
|
+
const credential = await (0, utils_1.getCredential)(ctx, options);
|
|
266
|
+
process.env.TCB_ENV = envConfig.envId;
|
|
267
|
+
process.env.TENCENTCLOUD_SECRETID = credential.secretId;
|
|
268
|
+
process.env.TENCENTCLOUD_SECRETKEY = credential.secretKey;
|
|
269
|
+
process.env.TENCENTCLOUD_SESSIONTOKEN = credential.token;
|
|
270
|
+
if (watchFlag.some((flag) => args.includes(flag))) {
|
|
271
|
+
const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
|
|
272
|
+
if (!nodemon) {
|
|
273
|
+
throw new Error((0, i18n_1.t)('缺少开发依赖 nodemon,独立发行版已不内置。请在本地开发环境中安装再使用该命令。'));
|
|
326
274
|
}
|
|
327
|
-
|
|
275
|
+
nodemon({
|
|
276
|
+
script: '',
|
|
277
|
+
exec: `${process.argv[1]} ${cmd}`,
|
|
278
|
+
watchOptions: {
|
|
279
|
+
usePolling: true,
|
|
280
|
+
ignorePermissionErrors: true,
|
|
281
|
+
ignored: defaultIgnoreFiles.join(','),
|
|
282
|
+
persistent: true,
|
|
283
|
+
interval: 500
|
|
284
|
+
}
|
|
285
|
+
})
|
|
286
|
+
.on('start', () => {
|
|
287
|
+
logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
|
|
288
|
+
})
|
|
289
|
+
.on('quit', (e) => {
|
|
290
|
+
logger.info(`Nodemon quit with code ${e}.`);
|
|
291
|
+
process.exit(0);
|
|
292
|
+
})
|
|
293
|
+
.on('restart', (e) => {
|
|
294
|
+
var _a, _b;
|
|
295
|
+
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(', ')}`);
|
|
296
|
+
})
|
|
297
|
+
.on('log', (e) => {
|
|
298
|
+
logger.info(`[nodemon ${e.type}] ${e.message}`);
|
|
299
|
+
})
|
|
300
|
+
.on('crash', () => {
|
|
301
|
+
logger.error('Server crashed.');
|
|
302
|
+
process.exit(1);
|
|
303
|
+
})
|
|
304
|
+
.on('exit', (e) => {
|
|
305
|
+
logger.info(`Server exited with code ${e}.`);
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
(0, functions_framework_1.runCLI)();
|
|
310
|
+
}
|
|
328
311
|
}
|
|
329
312
|
};
|
|
330
313
|
__decorate([
|
|
@@ -340,30 +323,26 @@ CloudFunctionRunCommand = __decorate([
|
|
|
340
323
|
(0, common_1.ICommand)()
|
|
341
324
|
], CloudFunctionRunCommand);
|
|
342
325
|
exports.CloudFunctionRunCommand = CloudFunctionRunCommand;
|
|
343
|
-
function _selectEnv() {
|
|
344
|
-
return
|
|
345
|
-
return (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
346
|
-
});
|
|
326
|
+
async function _selectEnv() {
|
|
327
|
+
return (0, utils_1.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
347
328
|
}
|
|
348
|
-
function _inputServiceName(defaultVal = '') {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
: (0, i18n_1.t)('支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符');
|
|
363
|
-
}
|
|
329
|
+
async function _inputServiceName(defaultVal = '') {
|
|
330
|
+
const questions = [
|
|
331
|
+
{
|
|
332
|
+
type: 'input',
|
|
333
|
+
name: 'serviceName',
|
|
334
|
+
message: (0, i18n_1.t)('请输入服务名称'),
|
|
335
|
+
default: defaultVal,
|
|
336
|
+
validate: (val) => {
|
|
337
|
+
const isValid = !val.startsWith('lcap') &&
|
|
338
|
+
!val.startsWith('lowcode') &&
|
|
339
|
+
/^[A-Za-z][\w-_]{0,43}[A-Za-z0-9]$/.test(val);
|
|
340
|
+
return isValid
|
|
341
|
+
? true
|
|
342
|
+
: (0, i18n_1.t)('支持大小写字母、数字、-和_,但必须以字母开头、以字母和数字结尾,不支持以lcap、lowcode开头,最长45个字符');
|
|
364
343
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
344
|
+
}
|
|
345
|
+
];
|
|
346
|
+
const answers = await inquirer_1.default.prompt(questions);
|
|
347
|
+
return answers['serviceName'];
|
|
369
348
|
}
|