@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
|
@@ -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
|
};
|
|
@@ -61,7 +52,10 @@ function spawnNodeProcess(args, options) {
|
|
|
61
52
|
cwd: path_1.default.dirname(bootstrapFilePath),
|
|
62
53
|
windowsHide: true
|
|
63
54
|
};
|
|
64
|
-
const exec = (0, child_process_1.spawn)('node', args,
|
|
55
|
+
const exec = (0, child_process_1.spawn)('node', args, {
|
|
56
|
+
...commonOptions,
|
|
57
|
+
...options
|
|
58
|
+
});
|
|
65
59
|
exec.on('error', (e) => {
|
|
66
60
|
console.log((0, i18n_1.t)('进程执行异常:{{message}}', { message: e.message }));
|
|
67
61
|
setTimeout(() => { }, 100);
|
|
@@ -78,110 +72,120 @@ function spawnNodeProcess(args, options) {
|
|
|
78
72
|
}
|
|
79
73
|
});
|
|
80
74
|
}
|
|
81
|
-
function getSecret() {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
};
|
|
94
|
-
});
|
|
75
|
+
async function getSecret() {
|
|
76
|
+
const credential = await (0, utils_1.checkAndGetCredential)();
|
|
77
|
+
if (lodash_1.default.isEmpty(credential)) {
|
|
78
|
+
console.log((0, i18n_1.t)('未登录,无法直接调用 Node SDK'));
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
const { secretId, secretKey, token } = credential;
|
|
82
|
+
return {
|
|
83
|
+
TENCENTCLOUD_SECRETID: secretId,
|
|
84
|
+
TENCENTCLOUD_SECRETKEY: secretKey,
|
|
85
|
+
TENCENTCLOUD_SESSIONTOKEN: token
|
|
86
|
+
};
|
|
95
87
|
}
|
|
96
|
-
function debugFunctionByPath(functionPath, options) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
|
|
108
|
-
}
|
|
109
|
-
debugDirname = filePath;
|
|
88
|
+
async function debugFunctionByPath(functionPath, options) {
|
|
89
|
+
const { params, debug, port } = options;
|
|
90
|
+
params && checkJSON(params);
|
|
91
|
+
const filePath = path_1.default.resolve(functionPath);
|
|
92
|
+
(0, utils_1.checkFullAccess)(filePath);
|
|
93
|
+
let debugDirname;
|
|
94
|
+
const isDir = (0, utils_1.isDirectory)(filePath);
|
|
95
|
+
if (isDir) {
|
|
96
|
+
const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, 'index.js'));
|
|
97
|
+
if (!exists) {
|
|
98
|
+
errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
|
|
110
99
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
100
|
+
debugDirname = filePath;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const { base, dir } = path_1.default.parse(filePath);
|
|
104
|
+
if (base !== 'index.js') {
|
|
105
|
+
errorLog((0, i18n_1.t)('index.js 文件不存在!'), debug);
|
|
117
106
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
107
|
+
debugDirname = dir;
|
|
108
|
+
}
|
|
109
|
+
try {
|
|
110
|
+
const fileExports = require(path_1.default.join(debugDirname, 'index.js'));
|
|
111
|
+
if (!fileExports.main) {
|
|
112
|
+
errorLog((0, i18n_1.t)('main 方法不存在!'), debug);
|
|
123
113
|
}
|
|
124
|
-
|
|
125
|
-
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
|
|
117
|
+
}
|
|
118
|
+
const secret = await getSecret();
|
|
119
|
+
const debugArgs = getDebugArgs(port);
|
|
120
|
+
const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
|
|
121
|
+
console.log((0, i18n_1.t)('> 以默认配置启动 Node 云函数调试'));
|
|
122
|
+
spawnNodeProcess(args, {
|
|
123
|
+
env: {
|
|
124
|
+
...process.env,
|
|
125
|
+
SCF_FUNCTION_HANDLER: 'index.main',
|
|
126
|
+
SCF_FUNCTION_NAME: 'main',
|
|
127
|
+
GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep),
|
|
128
|
+
SCF_EVENT_BODY: params || '{}',
|
|
129
|
+
...secret
|
|
126
130
|
}
|
|
127
|
-
const secret = yield getSecret();
|
|
128
|
-
const debugArgs = getDebugArgs(port);
|
|
129
|
-
const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
|
|
130
|
-
console.log((0, i18n_1.t)('> 以默认配置启动 Node 云函数调试'));
|
|
131
|
-
spawnNodeProcess(args, {
|
|
132
|
-
env: Object.assign(Object.assign(Object.assign({}, process.env), { SCF_FUNCTION_HANDLER: 'index.main', SCF_FUNCTION_NAME: 'main', GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep), SCF_EVENT_BODY: params || '{}' }), secret)
|
|
133
|
-
});
|
|
134
131
|
});
|
|
135
132
|
}
|
|
136
133
|
exports.debugFunctionByPath = debugFunctionByPath;
|
|
137
|
-
function debugByConfig(ctx, name) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
|
|
156
|
-
}
|
|
157
|
-
debugDirname = filePath;
|
|
134
|
+
async function debugByConfig(ctx, name) {
|
|
135
|
+
const { config, options, envId } = ctx;
|
|
136
|
+
const { params, debug, port } = options;
|
|
137
|
+
params && checkJSON(params);
|
|
138
|
+
let functionPath = path_1.default.resolve(config.functionRoot, name);
|
|
139
|
+
const filePath = path_1.default.resolve(functionPath);
|
|
140
|
+
(0, utils_1.checkFullAccess)(filePath, !debug);
|
|
141
|
+
let debugDirname;
|
|
142
|
+
const funcConfig = config.functions.find((item) => item.name === name);
|
|
143
|
+
const handlers = ((funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.handler) || 'index.main').split('.');
|
|
144
|
+
const indexFileName = handlers[0];
|
|
145
|
+
const indexFile = `${indexFileName}.js`;
|
|
146
|
+
const mainFunction = handlers[1];
|
|
147
|
+
const isDir = (0, utils_1.isDirectory)(filePath);
|
|
148
|
+
if (isDir) {
|
|
149
|
+
const exists = (0, utils_1.checkFullAccess)(path_1.default.join(filePath, indexFile));
|
|
150
|
+
if (!exists) {
|
|
151
|
+
errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
|
|
158
152
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
153
|
+
debugDirname = filePath;
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
const { base, dir } = path_1.default.parse(filePath);
|
|
157
|
+
if (base !== indexFile) {
|
|
158
|
+
errorLog((0, i18n_1.t)('{{indexFile}} 文件不存在!', { indexFile }), debug);
|
|
165
159
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
160
|
+
debugDirname = dir;
|
|
161
|
+
}
|
|
162
|
+
try {
|
|
163
|
+
const finalPath = path_1.default.join(debugDirname, indexFile);
|
|
164
|
+
const requirePath = process.platform === 'win32'
|
|
165
|
+
? finalPath.replace(/\\/g, '\\\\')
|
|
166
|
+
: finalPath;
|
|
167
|
+
const fileExports = require(requirePath);
|
|
168
|
+
if (!fileExports[mainFunction]) {
|
|
169
|
+
errorLog((0, i18n_1.t)('handler 中的 {{mainFunction}} 方法不存在,请检查你的配置!', { mainFunction }), debug);
|
|
175
170
|
}
|
|
176
|
-
|
|
177
|
-
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
errorLog((0, i18n_1.t)('导入云函数异常:{{message}}', { message: e.message }), debug);
|
|
174
|
+
}
|
|
175
|
+
const secret = await getSecret();
|
|
176
|
+
const debugArgs = getDebugArgs(port);
|
|
177
|
+
const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
|
|
178
|
+
spawnNodeProcess(args, {
|
|
179
|
+
env: {
|
|
180
|
+
...process.env,
|
|
181
|
+
SCF_NAMESPACE: envId,
|
|
182
|
+
SCF_FUNCTION_HANDLER: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.handler) || 'index.main',
|
|
183
|
+
SCF_FUNCTION_NAME: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.name) || 'main',
|
|
184
|
+
GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep),
|
|
185
|
+
SCF_EVENT_BODY: params || JSON.stringify((funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.params) || {}),
|
|
186
|
+
...funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.envVariables,
|
|
187
|
+
...secret
|
|
178
188
|
}
|
|
179
|
-
const secret = yield getSecret();
|
|
180
|
-
const debugArgs = getDebugArgs(port);
|
|
181
|
-
const args = debug ? [...debugArgs, bootstrapFilePath] : [bootstrapFilePath];
|
|
182
|
-
spawnNodeProcess(args, {
|
|
183
|
-
env: Object.assign(Object.assign(Object.assign(Object.assign({}, process.env), { SCF_NAMESPACE: envId, SCF_FUNCTION_HANDLER: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.handler) || 'index.main', SCF_FUNCTION_NAME: (funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.name) || 'main', GLOBAL_USER_FILE_PATH: path_1.default.join(debugDirname, path_1.default.sep), SCF_EVENT_BODY: params || JSON.stringify((funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.params) || {}) }), funcConfig === null || funcConfig === void 0 ? void 0 : funcConfig.envVariables), secret)
|
|
184
|
-
});
|
|
185
189
|
});
|
|
186
190
|
}
|
|
187
191
|
exports.debugByConfig = debugByConfig;
|
|
@@ -216,20 +220,18 @@ let FunctionDebug = class FunctionDebug extends common_1.Command {
|
|
|
216
220
|
desc: (0, i18n_1.t)('本地运行云函数(当前仅支持 Node)')
|
|
217
221
|
};
|
|
218
222
|
}
|
|
219
|
-
execute(ctx) {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
}
|
|
232
|
-
});
|
|
223
|
+
async execute(ctx) {
|
|
224
|
+
const { options } = ctx;
|
|
225
|
+
const { path, name } = options;
|
|
226
|
+
if (path) {
|
|
227
|
+
await debugFunctionByPath(path, options);
|
|
228
|
+
}
|
|
229
|
+
else if (typeof name === 'string') {
|
|
230
|
+
await debugByConfig(ctx, name);
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定运行函数的名称或函数的路径\n\n例如 cloudbase functions:run --name app'));
|
|
234
|
+
}
|
|
233
235
|
}
|
|
234
236
|
};
|
|
235
237
|
__decorate([
|
|
@@ -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
|
};
|
|
@@ -48,41 +39,39 @@ let CreateTrigger = class CreateTrigger extends common_1.Command {
|
|
|
48
39
|
desc: (0, i18n_1.t)('创建云函数触发器')
|
|
49
40
|
};
|
|
50
41
|
}
|
|
51
|
-
execute(ctx, params) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
if (isBatchCreateTrigger) {
|
|
70
|
-
return functionService.batchCreateTriggers({
|
|
71
|
-
envId,
|
|
72
|
-
functions
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const functionItem = functions.find((item) => item.name === name);
|
|
76
|
-
if (!functionItem) {
|
|
77
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('未找到相关函数配置,请检查函数名是否正确'));
|
|
78
|
-
}
|
|
79
|
-
const { triggers } = functionItem;
|
|
80
|
-
if (!triggers || !triggers.length) {
|
|
81
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('触发器配置不能为空'));
|
|
42
|
+
async execute(ctx, params) {
|
|
43
|
+
const { envId, config: { functions } } = ctx;
|
|
44
|
+
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
45
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
46
|
+
let isBatchCreateTrigger = false;
|
|
47
|
+
if (!name) {
|
|
48
|
+
const { isBatch } = await inquirer_1.default.prompt({
|
|
49
|
+
type: 'confirm',
|
|
50
|
+
name: 'isBatch',
|
|
51
|
+
message: (0, i18n_1.t)('无云函数名称,是否需要部署配置文件中的【全部云函数】的全部触发器?'),
|
|
52
|
+
default: false
|
|
53
|
+
});
|
|
54
|
+
isBatchCreateTrigger = isBatch;
|
|
55
|
+
if (!isBatchCreateTrigger) {
|
|
56
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称!'));
|
|
82
57
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
58
|
+
}
|
|
59
|
+
if (isBatchCreateTrigger) {
|
|
60
|
+
return functionService.batchCreateTriggers({
|
|
61
|
+
envId,
|
|
62
|
+
functions
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
const functionItem = functions.find((item) => item.name === name);
|
|
66
|
+
if (!functionItem) {
|
|
67
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('未找到相关函数配置,请检查函数名是否正确'));
|
|
68
|
+
}
|
|
69
|
+
const { triggers } = functionItem;
|
|
70
|
+
if (!triggers || !triggers.length) {
|
|
71
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('触发器配置不能为空'));
|
|
72
|
+
}
|
|
73
|
+
await functionService.createFunctionTriggers(name, triggers);
|
|
74
|
+
(0, logger_1.successLog)((0, i18n_1.t)('[{{name}}] 创建云函数触发器成功!', { name }));
|
|
86
75
|
}
|
|
87
76
|
};
|
|
88
77
|
__decorate([
|
|
@@ -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
|
};
|
|
@@ -47,64 +38,62 @@ let DeleteTrigger = class DeleteTrigger extends common_1.Command {
|
|
|
47
38
|
desc: (0, i18n_1.t)('删除云函数触发器')
|
|
48
39
|
};
|
|
49
40
|
}
|
|
50
|
-
execute(ctx, params) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
41
|
+
async execute(ctx, params) {
|
|
42
|
+
const { envId, config: { functions } } = ctx;
|
|
43
|
+
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
44
|
+
const triggerName = params === null || params === void 0 ? void 0 : params[1];
|
|
45
|
+
const functionService = await (0, function_1.getFunctionService)(envId);
|
|
46
|
+
let isBatchDeleteTriggers;
|
|
47
|
+
let isBatchDeleteFunctionTriggers = false;
|
|
48
|
+
if (!name) {
|
|
49
|
+
const answer = await inquirer_1.default.prompt({
|
|
50
|
+
type: 'confirm',
|
|
51
|
+
name: 'isBatch',
|
|
52
|
+
message: (0, i18n_1.t)('无云函数名称,是否需要删除配置文件中的【全部云函数】的全部触发器?'),
|
|
53
|
+
default: false
|
|
54
|
+
});
|
|
55
|
+
if (answer.isBatch) {
|
|
56
|
+
const { reConfirm } = await inquirer_1.default.prompt({
|
|
60
57
|
type: 'confirm',
|
|
61
|
-
name: '
|
|
62
|
-
message: (0, i18n_1.t)('
|
|
58
|
+
name: 'reConfirm',
|
|
59
|
+
message: (0, i18n_1.t)('确定要删除配置文件中的【全部云函数】的全部触发器?'),
|
|
63
60
|
default: false
|
|
64
61
|
});
|
|
65
|
-
|
|
66
|
-
const { reConfirm } = yield inquirer_1.default.prompt({
|
|
67
|
-
type: 'confirm',
|
|
68
|
-
name: 'reConfirm',
|
|
69
|
-
message: (0, i18n_1.t)('确定要删除配置文件中的【全部云函数】的全部触发器?'),
|
|
70
|
-
default: false
|
|
71
|
-
});
|
|
72
|
-
isBatchDeleteTriggers = reConfirm;
|
|
73
|
-
}
|
|
74
|
-
if (!isBatchDeleteTriggers) {
|
|
75
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
if (isBatchDeleteTriggers) {
|
|
79
|
-
return functionService.batchDeleteTriggers({
|
|
80
|
-
envId,
|
|
81
|
-
functions
|
|
82
|
-
});
|
|
62
|
+
isBatchDeleteTriggers = reConfirm;
|
|
83
63
|
}
|
|
84
|
-
if (!
|
|
85
|
-
|
|
86
|
-
type: 'confirm',
|
|
87
|
-
name: 'isBatch',
|
|
88
|
-
message: (0, i18n_1.t)('没有指定触发器名称,是否需要此云函数的全部触发器?'),
|
|
89
|
-
default: false
|
|
90
|
-
});
|
|
91
|
-
isBatchDeleteFunctionTriggers = isBatch;
|
|
92
|
-
if (!isBatchDeleteFunctionTriggers) {
|
|
93
|
-
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (isBatchDeleteFunctionTriggers) {
|
|
97
|
-
const func = functions.find((item) => item.name === name);
|
|
98
|
-
return functionService.batchDeleteTriggers({
|
|
99
|
-
envId,
|
|
100
|
-
functions: [func]
|
|
101
|
-
});
|
|
64
|
+
if (!isBatchDeleteTriggers) {
|
|
65
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
|
|
102
66
|
}
|
|
103
|
-
|
|
104
|
-
|
|
67
|
+
}
|
|
68
|
+
if (isBatchDeleteTriggers) {
|
|
69
|
+
return functionService.batchDeleteTriggers({
|
|
70
|
+
envId,
|
|
71
|
+
functions
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (!triggerName && name) {
|
|
75
|
+
const { isBatch } = await inquirer_1.default.prompt({
|
|
76
|
+
type: 'confirm',
|
|
77
|
+
name: 'isBatch',
|
|
78
|
+
message: (0, i18n_1.t)('没有指定触发器名称,是否需要此云函数的全部触发器?'),
|
|
79
|
+
default: false
|
|
80
|
+
});
|
|
81
|
+
isBatchDeleteFunctionTriggers = isBatch;
|
|
82
|
+
if (!isBatchDeleteFunctionTriggers) {
|
|
83
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('请指定云函数名称以及触发器名称!'));
|
|
105
84
|
}
|
|
106
|
-
|
|
107
|
-
|
|
85
|
+
}
|
|
86
|
+
if (isBatchDeleteFunctionTriggers) {
|
|
87
|
+
const func = functions.find((item) => item.name === name);
|
|
88
|
+
return functionService.batchDeleteTriggers({
|
|
89
|
+
envId,
|
|
90
|
+
functions: [func]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
if (!triggerName) {
|
|
94
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('触发器名称不能为空'));
|
|
95
|
+
}
|
|
96
|
+
await functionService.deleteFunctionTrigger(name, triggerName);
|
|
108
97
|
}
|
|
109
98
|
};
|
|
110
99
|
__decorate([
|
|
@@ -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.ListFunctionVersion = void 0;
|
|
25
16
|
const common_1 = require("../../common");
|
|
@@ -48,38 +39,36 @@ let ListFunctionVersion = class ListFunctionVersion extends common_1.Command {
|
|
|
48
39
|
desc: (0, i18n_1.t)('展示函数版本列表')
|
|
49
40
|
};
|
|
50
41
|
}
|
|
51
|
-
execute(ctx, params, options) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
limit
|
|
71
|
-
});
|
|
72
|
-
loading.stop();
|
|
73
|
-
const head = [(0, i18n_1.t)('版本'), (0, i18n_1.t)('描述'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('修改时间'), (0, i18n_1.t)('状态')];
|
|
74
|
-
const tableData = res.Versions.map((item) => [
|
|
75
|
-
item.Version,
|
|
76
|
-
item.Description,
|
|
77
|
-
item.AddTime,
|
|
78
|
-
item.ModTime,
|
|
79
|
-
constant_1.StatusMap[item.Status]
|
|
80
|
-
]);
|
|
81
|
-
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
42
|
+
async execute(ctx, params, options) {
|
|
43
|
+
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
44
|
+
let { limit = 20, offset = 0 } = options;
|
|
45
|
+
limit = Number(limit);
|
|
46
|
+
offset = Number(offset);
|
|
47
|
+
if (!Number.isInteger(limit) || !Number.isInteger(offset)) {
|
|
48
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为整数'));
|
|
49
|
+
}
|
|
50
|
+
if (limit < 0 || offset < 0) {
|
|
51
|
+
throw new error_1.CloudBaseError((0, i18n_1.t)('limit 和 offset 必须为大于 0 的整数'));
|
|
52
|
+
}
|
|
53
|
+
const { envId } = ctx;
|
|
54
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
55
|
+
loading.start((0, i18n_1.t)('拉取函数 [{{name}}] 版本列表中...', { name }));
|
|
56
|
+
const res = await (0, function_1.listFunctionVersions)({
|
|
57
|
+
envId,
|
|
58
|
+
functionName: name,
|
|
59
|
+
offset,
|
|
60
|
+
limit
|
|
82
61
|
});
|
|
62
|
+
loading.stop();
|
|
63
|
+
const head = [(0, i18n_1.t)('版本'), (0, i18n_1.t)('描述'), (0, i18n_1.t)('创建时间'), (0, i18n_1.t)('修改时间'), (0, i18n_1.t)('状态')];
|
|
64
|
+
const tableData = res.Versions.map((item) => [
|
|
65
|
+
item.Version,
|
|
66
|
+
item.Description,
|
|
67
|
+
item.AddTime,
|
|
68
|
+
item.ModTime,
|
|
69
|
+
constant_1.StatusMap[item.Status]
|
|
70
|
+
]);
|
|
71
|
+
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
83
72
|
}
|
|
84
73
|
};
|
|
85
74
|
__decorate([
|
|
@@ -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.PublishFunctionVersion = void 0;
|
|
25
16
|
const common_1 = require("../../common");
|
|
@@ -41,20 +32,18 @@ let PublishFunctionVersion = class PublishFunctionVersion extends common_1.Comma
|
|
|
41
32
|
desc: (0, i18n_1.t)('发布函数新版本')
|
|
42
33
|
};
|
|
43
34
|
}
|
|
44
|
-
execute(ctx, params) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
description
|
|
55
|
-
});
|
|
56
|
-
loading.succeed((0, i18n_1.t)('发布函数 [{{name}}] 新版本成功!', { name }));
|
|
35
|
+
async execute(ctx, params) {
|
|
36
|
+
const name = params === null || params === void 0 ? void 0 : params[0];
|
|
37
|
+
const description = params === null || params === void 0 ? void 0 : params[1];
|
|
38
|
+
const { envId } = ctx;
|
|
39
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
40
|
+
loading.start((0, i18n_1.t)('发布函数 [{{name}}] 新版本中...', { name }));
|
|
41
|
+
await (0, function_1.publishVersion)({
|
|
42
|
+
envId,
|
|
43
|
+
functionName: name,
|
|
44
|
+
description
|
|
57
45
|
});
|
|
46
|
+
loading.succeed((0, i18n_1.t)('发布函数 [{{name}}] 新版本成功!', { name }));
|
|
58
47
|
}
|
|
59
48
|
};
|
|
60
49
|
__decorate([
|