@cloudbase/cli 2.6.0-alpha.7 → 2.6.0-pre-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.yarn/cache/@cloudbase-functions-framework-npm-1.0.0-beta.11-9bbeceb6ff-3aa0efd307.zip +0 -0
- package/.yarn/cache/@cloudbase-functions-typings-npm-1.0.0-beta.3-0b2fc0975b-ebe46cc101.zip +0 -0
- package/.yarn/cache/ajv-npm-8.17.1-12ade7edc6-1797bf242c.zip +0 -0
- package/.yarn/cache/fast-uri-npm-3.0.1-20477a5d16-106143ff83.zip +0 -0
- package/.yarn/cache/radix3-npm-1.1.2-bf27d7ceee-c4d49a3f60.zip +0 -0
- package/.yarn/install-state.gz +0 -0
- package/lib/commands/fun/base.js +43 -10
- package/lib/commands/index.js +1 -0
- package/lib/commands/lowcode/comps.js +4 -4
- package/lib/commands/lowcode/utils.js +2 -1
- package/lib/commands/run/index.js +0 -1
- package/lib/commands/runf/base.js +536 -0
- package/lib/commands/runf/index.js +17 -0
- package/lib/help.js +2 -1
- package/lib/utils/net/cloud-api-request.js +9 -9
- package/package.json +5 -3
- package/types/commands/index.d.ts +1 -0
- package/types/commands/run/index.d.ts +0 -1
- package/types/commands/runf/base.d.ts +57 -0
- package/types/commands/runf/index.d.ts +1 -0
- package/types/decorators/params/common.d.ts +1 -1
- package/types/types.d.ts +2 -2
- package/types/utils/config.d.ts +1 -1
- package/types/utils/fs/index.d.ts +1 -1
- package/types/utils/net/http-request.d.ts +3 -3
- package/types/utils/output/loading.d.ts +1 -1
- package/types/utils/parallel.d.ts +1 -1
- package/types/utils/validator.d.ts +1 -1
- package/.history/src/commands/lowcode/app_20220728111717.ts +0 -52
- package/.history/src/commands/lowcode/app_20220728112031.ts +0 -34
- package/.history/src/commands/lowcode/app_20220729172854.ts +0 -34
- package/.history/src/index_20220624162613.ts +0 -13
- package/.history/src/index_20220627113609.ts +0 -15
- package/.history/src/index_20220627114102.ts +0 -13
- package/.yarn/cache/@cloudbase-functions-framework-npm-1.0.0-beta.3-68c4d9136e-3d11f97edc.zip +0 -0
- package/.yarn/cache/@koa-router-npm-12.0.1-6a9764e4df-4b8d3940cb.zip +0 -0
- package/.yarn/cache/path-to-regexp-npm-6.2.2-0bf7f6805c-b7b0005c36.zip +0 -0
package/.yarn/cache/@cloudbase-functions-framework-npm-1.0.0-beta.11-9bbeceb6ff-3aa0efd307.zip
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/.yarn/install-state.gz
CHANGED
|
Binary file
|
package/lib/commands/fun/base.js
CHANGED
|
@@ -125,6 +125,10 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
125
125
|
{
|
|
126
126
|
flags: '--includeNodeModules',
|
|
127
127
|
desc: '包含本地 node_modules 目录,默认为 false 不包含'
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
flags: '--functionsConfigFile <functionsConfigFile>',
|
|
131
|
+
desc: '多函数定义配置文件,默认为 ./cloudbase-functions.json'
|
|
128
132
|
}
|
|
129
133
|
],
|
|
130
134
|
requiredEnvId: false,
|
|
@@ -137,18 +141,44 @@ let FunDeployCommand = class FunDeployCommand extends common_1.Command {
|
|
|
137
141
|
let { serviceName, appId, source, includeNodeModules = false } = options;
|
|
138
142
|
const target = 'main';
|
|
139
143
|
source = path_1.default.resolve(source || process.cwd());
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
const functionsConfigFile = options.functionsConfigFile || 'cloudbase-functions.json';
|
|
145
|
+
let multiFunctionsConfig = null;
|
|
146
|
+
if (functionsConfigFile && (yield fs_extra_1.default.exists(path_1.default.resolve(source, functionsConfigFile)))) {
|
|
147
|
+
try {
|
|
148
|
+
multiFunctionsConfig = (0, functions_framework_1.loadFunctionsConfig)(functionsConfigFile);
|
|
144
149
|
}
|
|
145
|
-
|
|
146
|
-
log.error(
|
|
150
|
+
catch (err) {
|
|
151
|
+
log.error(`多函数定义配置文件 ${functionsConfigFile} 配置文件有误,请检查`);
|
|
152
|
+
log.error(err);
|
|
153
|
+
return;
|
|
147
154
|
}
|
|
148
|
-
|
|
149
|
-
|
|
155
|
+
}
|
|
156
|
+
const loadResult = yield (0, functions_framework_1.loadFunctions)({
|
|
157
|
+
target,
|
|
158
|
+
sourceLocation: source,
|
|
159
|
+
multiFunctionsConfig
|
|
160
|
+
});
|
|
161
|
+
if (Array.isArray(loadResult)) {
|
|
162
|
+
for (const loadItem of loadResult) {
|
|
163
|
+
if (!(loadItem === null || loadItem === void 0 ? void 0 : loadItem.userFunction)) {
|
|
164
|
+
log.error(`加载函数 ${loadItem === null || loadItem === void 0 ? void 0 : loadItem.name} 失败: "${loadItem === null || loadItem === void 0 ? void 0 : loadItem.reason}"`);
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (!(loadResult === null || loadResult === void 0 ? void 0 : loadResult.userFunction)) {
|
|
171
|
+
if (loadResult.reason.includes('is not a loadable module')) {
|
|
172
|
+
log.error(`${source} 不是一个有效的函数式托管代码目录,可以通过 --source <source> 指定代码目录路径`);
|
|
173
|
+
}
|
|
174
|
+
else if (loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason.includes('is not defined in the provided module')) {
|
|
175
|
+
log.error(`主文件并未导出目标函数 ${target},请导出 ${target} 目标函数`);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
log.error(loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason);
|
|
179
|
+
}
|
|
180
|
+
return;
|
|
150
181
|
}
|
|
151
|
-
return;
|
|
152
182
|
}
|
|
153
183
|
if (!envId) {
|
|
154
184
|
envId = yield _selectEnv();
|
|
@@ -309,6 +339,10 @@ let FunRunCommand = class FunRunCommand extends common_1.Command {
|
|
|
309
339
|
{
|
|
310
340
|
flags: '--logDirname <logDirname>',
|
|
311
341
|
desc: '日志文件目录,默认为 ./logs'
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
flags: '--functionsConfigFile <functionsConfigFile>',
|
|
345
|
+
desc: '多函数定义配置文件,默认为 ./cloudbase-functions.json'
|
|
312
346
|
}
|
|
313
347
|
],
|
|
314
348
|
requiredEnvId: false,
|
|
@@ -321,7 +355,6 @@ let FunRunCommand = class FunRunCommand extends common_1.Command {
|
|
|
321
355
|
const watchFlag = ['--watch', '-w'];
|
|
322
356
|
const defaultIgnoreFiles = ['logs/*.*'];
|
|
323
357
|
if (watchFlag.some((flag) => args.includes(flag))) {
|
|
324
|
-
debugger;
|
|
325
358
|
const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
|
|
326
359
|
(0, nodemon_1.default)({
|
|
327
360
|
script: '',
|
package/lib/commands/index.js
CHANGED
|
@@ -166,7 +166,7 @@ let LowCodeBuildComps = class LowCodeBuildComps extends common_1.Command {
|
|
|
166
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
167
167
|
const config = ctx.config.lowcodeCustomComponents;
|
|
168
168
|
if (config) {
|
|
169
|
-
yield lowcodeCli.graceBuildComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd) }));
|
|
169
|
+
yield lowcodeCli.graceBuildComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd), envId: ctx.envId || ctx.config.envId }));
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
172
|
throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
|
|
@@ -218,7 +218,7 @@ let LowCodeDebugComps = class LowCodeDebugComps extends common_1.Command {
|
|
|
218
218
|
if (config) {
|
|
219
219
|
const cmdConfig = (0, utils_2.getCmdConfig)(ctx.config, this.options);
|
|
220
220
|
const mergesOptions = (0, utils_2.getMergedOptions)(cmdConfig, options);
|
|
221
|
-
yield lowcodeCli.graceDebugComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), debugPort: (mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.debugPort) || 8388, logger: log, wxDevtoolPath: mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.wxDevtoolPath, debugBaseUrl: (_a = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.endpoints) === null || _a === void 0 ? void 0 : _a.editor }));
|
|
221
|
+
yield lowcodeCli.graceDebugComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), debugPort: (mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.debugPort) || 8388, logger: log, wxDevtoolPath: mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.wxDevtoolPath, debugBaseUrl: (_a = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.endpoints) === null || _a === void 0 ? void 0 : _a.editor, envId: ctx.envId || ctx.config.envId }));
|
|
222
222
|
return;
|
|
223
223
|
}
|
|
224
224
|
throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
|
|
@@ -265,7 +265,7 @@ let LowCodePublishComps = class LowCodePublishComps extends common_1.Command {
|
|
|
265
265
|
const config = ctx.config.lowcodeCustomComponents;
|
|
266
266
|
if (config) {
|
|
267
267
|
const mergesOptions = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(ctx.config, this.options), options);
|
|
268
|
-
yield lowcodeCli.gracePublishComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd), isAdmin: Boolean(mergesOptions.admin) }));
|
|
268
|
+
yield lowcodeCli.gracePublishComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd), isAdmin: Boolean(mergesOptions.admin), envId: ctx.envId || ctx.config.envId }));
|
|
269
269
|
log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!');
|
|
270
270
|
return;
|
|
271
271
|
}
|
|
@@ -331,7 +331,7 @@ let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common
|
|
|
331
331
|
if (!config) {
|
|
332
332
|
throw new error_1.CloudBaseError('组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令');
|
|
333
333
|
}
|
|
334
|
-
const res = yield lowcodeCli.publishVersion(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: options.admin, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd) }), comment, tag);
|
|
334
|
+
const res = yield lowcodeCli.publishVersion(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: options.admin, privateSettings: (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd), envId: ctx.envId || ctx.config.envId }), comment, tag);
|
|
335
335
|
if (res.data.code === 200) {
|
|
336
336
|
log.success('组件库 - 已发布新版本!');
|
|
337
337
|
return;
|
|
@@ -60,11 +60,12 @@ function promisifyProcess(p, pipe = false) {
|
|
|
60
60
|
exports.promisifyProcess = promisifyProcess;
|
|
61
61
|
function getLowcodeCli() {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
var _a;
|
|
63
64
|
const key = '@cloudbase/lowcode-cli';
|
|
64
65
|
const cache = new Map();
|
|
65
66
|
let result;
|
|
66
67
|
if (!cache.get(key)) {
|
|
67
|
-
const module = yield Promise.resolve().then(() => __importStar(require(
|
|
68
|
+
const module = yield (_a = key, Promise.resolve().then(() => __importStar(require(_a))));
|
|
68
69
|
cache.set(key, module);
|
|
69
70
|
}
|
|
70
71
|
result = cache.get(key);
|
|
@@ -18,5 +18,4 @@ __exportStar(require("./list"), exports);
|
|
|
18
18
|
__exportStar(require("./version"), exports);
|
|
19
19
|
__exportStar(require("./delete"), exports);
|
|
20
20
|
__exportStar(require("./image"), exports);
|
|
21
|
-
__exportStar(require("./standalonegateway"), exports);
|
|
22
21
|
__exportStar(require("./service"), exports);
|
|
@@ -0,0 +1,536 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.RunfRunCommand = exports.RunfDownloadCommand = exports.RunfDeployCommand = exports.RunfListCommand = void 0;
|
|
28
|
+
const functions_framework_1 = require("@cloudbase/functions-framework");
|
|
29
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
30
|
+
const camelcase_keys_1 = __importDefault(require("camelcase-keys"));
|
|
31
|
+
const iac_core_1 = require("@cloudbase/iac-core");
|
|
32
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
33
|
+
const path_1 = __importDefault(require("path"));
|
|
34
|
+
const decorators_1 = require("../../decorators");
|
|
35
|
+
const utils_1 = require("../../utils");
|
|
36
|
+
const common_1 = require("../common");
|
|
37
|
+
const constants_1 = require("../constants");
|
|
38
|
+
const utils_2 = require("../utils");
|
|
39
|
+
const nodemon_1 = __importDefault(require("nodemon"));
|
|
40
|
+
const { CloudAPI } = iac_core_1.CloudAPI;
|
|
41
|
+
const scfService = utils_1.CloudApiService.getInstance('tcb');
|
|
42
|
+
class RunfListCommand extends common_1.Command {
|
|
43
|
+
get options() {
|
|
44
|
+
return {
|
|
45
|
+
cmd: 'runf',
|
|
46
|
+
childCmd: 'list',
|
|
47
|
+
options: [
|
|
48
|
+
{
|
|
49
|
+
flags: '-e, --envId <envId>',
|
|
50
|
+
desc: '环境 Id'
|
|
51
|
+
}
|
|
52
|
+
],
|
|
53
|
+
requiredEnvId: false,
|
|
54
|
+
autoRunLogin: true,
|
|
55
|
+
desc: '查看函数式托管服务列表'
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
execute(envId, log) {
|
|
59
|
+
var _a;
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const loading = (0, utils_1.loadingFactory)();
|
|
62
|
+
if (!envId) {
|
|
63
|
+
envId = yield _selectEnv();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
log.info(`当前环境 Id:${envId}`);
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
loading.start('获取函数式托管服务列表中…');
|
|
70
|
+
let serverListRes = yield scfService
|
|
71
|
+
.request('DescribeCloudBaseRunServers', {
|
|
72
|
+
EnvId: envId,
|
|
73
|
+
Limit: 100,
|
|
74
|
+
Offset: 0
|
|
75
|
+
})
|
|
76
|
+
.finally(() => loading.stop());
|
|
77
|
+
const serverList = (_a = serverListRes.CloudBaseRunServerSet) === null || _a === void 0 ? void 0 : _a.filter((item) => item.Tag === 'function');
|
|
78
|
+
const head = ['服务名称', '状态', '创建时间', '更新时间'];
|
|
79
|
+
const tableData = serverList.map((serverItem) => [
|
|
80
|
+
serverItem.ServerName,
|
|
81
|
+
serverItem.Status,
|
|
82
|
+
serverItem.CreatedTime,
|
|
83
|
+
serverItem.UpdatedTime
|
|
84
|
+
]);
|
|
85
|
+
(0, utils_1.printHorizontalTable)(head, tableData);
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
log.error('获取函数式托管服务列表失败:' + e.message);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
__decorate([
|
|
94
|
+
(0, decorators_1.InjectParams)(),
|
|
95
|
+
__param(0, (0, decorators_1.EnvId)()),
|
|
96
|
+
__param(1, (0, decorators_1.Log)()),
|
|
97
|
+
__metadata("design:type", Function),
|
|
98
|
+
__metadata("design:paramtypes", [Object, decorators_1.Logger]),
|
|
99
|
+
__metadata("design:returntype", Promise)
|
|
100
|
+
], RunfListCommand.prototype, "execute", null);
|
|
101
|
+
exports.RunfListCommand = RunfListCommand;
|
|
102
|
+
let RunfDeployCommand = class RunfDeployCommand extends common_1.Command {
|
|
103
|
+
get options() {
|
|
104
|
+
return {
|
|
105
|
+
cmd: 'runf',
|
|
106
|
+
childCmd: 'deploy',
|
|
107
|
+
options: [
|
|
108
|
+
{
|
|
109
|
+
flags: '-e, --envId <envId>',
|
|
110
|
+
desc: '环境 Id'
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
flags: '-s, --serviceName <serviceName>',
|
|
114
|
+
desc: '服务名称'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
flags: '--source <source>',
|
|
118
|
+
desc: '目标函数文件所在目录路径。默认为当前路径'
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
requiredEnvId: false,
|
|
122
|
+
autoRunLogin: true,
|
|
123
|
+
desc: '部署云函数 2.0 服务'
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
execute(ctx, envId, log, options) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
let { serviceName, source } = options;
|
|
129
|
+
const targetDir = path_1.default.resolve(source || process.cwd());
|
|
130
|
+
debugger;
|
|
131
|
+
const target = 'main';
|
|
132
|
+
const functionsConfigFile = path_1.default.resolve(targetDir, options.functionsConfigFile || 'cloudbase-functions.json');
|
|
133
|
+
let multiFunctionsConfig = null;
|
|
134
|
+
if (yield fs_extra_1.default.exists(functionsConfigFile)) {
|
|
135
|
+
try {
|
|
136
|
+
multiFunctionsConfig = (0, functions_framework_1.loadFunctionsConfig)(functionsConfigFile);
|
|
137
|
+
}
|
|
138
|
+
catch (err) {
|
|
139
|
+
log.error(`多函数定义配置文件 ${functionsConfigFile} 配置文件有误,请检查`);
|
|
140
|
+
log.error(err);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
const loadResult = yield (0, functions_framework_1.loadFunctions)({
|
|
145
|
+
target,
|
|
146
|
+
sourceLocation: targetDir,
|
|
147
|
+
multiFunctionsConfig
|
|
148
|
+
});
|
|
149
|
+
if (Array.isArray(loadResult)) {
|
|
150
|
+
for (const loadItem of loadResult) {
|
|
151
|
+
if (!(loadItem === null || loadItem === void 0 ? void 0 : loadItem.userFunction)) {
|
|
152
|
+
log.error(`加载函数 ${loadItem === null || loadItem === void 0 ? void 0 : loadItem.name} 失败: "${loadItem === null || loadItem === void 0 ? void 0 : loadItem.reason}"`);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
if (!(loadResult === null || loadResult === void 0 ? void 0 : loadResult.userFunction)) {
|
|
159
|
+
if (loadResult.reason.includes('is not a loadable module')) {
|
|
160
|
+
log.error(`${targetDir} 不是一个有效的函数式托管代码目录,可以通过 --source <source> 指定代码目录路径`);
|
|
161
|
+
}
|
|
162
|
+
else if (loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason.includes('is not defined in the provided module')) {
|
|
163
|
+
log.error(`主文件并未导出目标函数 ${target},请导出 ${target} 目标函数`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
log.error(loadResult === null || loadResult === void 0 ? void 0 : loadResult.reason);
|
|
167
|
+
}
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!envId) {
|
|
172
|
+
const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
|
|
173
|
+
if (envConfig.envId) {
|
|
174
|
+
envId = envConfig.envId;
|
|
175
|
+
log.info(`当前环境 Id:${envId}`);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
envId = yield _selectEnv();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
log.info(`当前环境 Id:${envId}`);
|
|
183
|
+
}
|
|
184
|
+
if (!serviceName) {
|
|
185
|
+
let pkgName = '';
|
|
186
|
+
try {
|
|
187
|
+
const pkg = yield fs_extra_1.default.readJSON(path_1.default.join(targetDir, 'package.json'));
|
|
188
|
+
pkgName = pkg.name;
|
|
189
|
+
}
|
|
190
|
+
catch (e) { }
|
|
191
|
+
serviceName = yield _inputServiceName(pkgName);
|
|
192
|
+
}
|
|
193
|
+
const answers = yield inquirer_1.default.prompt([
|
|
194
|
+
{
|
|
195
|
+
type: 'confirm',
|
|
196
|
+
name: 'confirm',
|
|
197
|
+
message: `即将开始部署,是否确认继续?`,
|
|
198
|
+
default: true
|
|
199
|
+
}
|
|
200
|
+
]);
|
|
201
|
+
if (!answers.confirm) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
yield iac_core_1.IAC.init({
|
|
205
|
+
cwd: targetDir,
|
|
206
|
+
getCredential: () => {
|
|
207
|
+
return getCredential(ctx, options);
|
|
208
|
+
},
|
|
209
|
+
polyRepoMode: true
|
|
210
|
+
});
|
|
211
|
+
yield _runDeploy();
|
|
212
|
+
function _runDeploy() {
|
|
213
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
214
|
+
try {
|
|
215
|
+
yield iac_core_1.IAC.FunctionV2.apply({
|
|
216
|
+
cwd: targetDir,
|
|
217
|
+
envId: envId,
|
|
218
|
+
name: serviceName
|
|
219
|
+
}, function (message) {
|
|
220
|
+
trackCallback(message, log);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
catch (e) {
|
|
224
|
+
if ((e === null || e === void 0 ? void 0 : e.action) === 'UpdateCloudRunServer' && (e === null || e === void 0 ? void 0 : e.code) === 'ResourceInUse') {
|
|
225
|
+
inquirer_1.default
|
|
226
|
+
.prompt([
|
|
227
|
+
{
|
|
228
|
+
type: 'confirm',
|
|
229
|
+
name: 'confirm',
|
|
230
|
+
message: `平台当前有部署发布任务正在运行中。确认继续部署,正在执行的部署任务将被取消,并立即部署最新的代码`,
|
|
231
|
+
default: true
|
|
232
|
+
}
|
|
233
|
+
])
|
|
234
|
+
.then((answers) => __awaiter(this, void 0, void 0, function* () {
|
|
235
|
+
if (answers.confirm) {
|
|
236
|
+
try {
|
|
237
|
+
const { task } = yield CloudAPI.tcbrServiceRequest('DescribeServerManageTask', {
|
|
238
|
+
envId,
|
|
239
|
+
serverName: serviceName,
|
|
240
|
+
taskId: 0
|
|
241
|
+
});
|
|
242
|
+
const id = task === null || task === void 0 ? void 0 : task.id;
|
|
243
|
+
yield CloudAPI.tcbrServiceRequest('OperateServerManage', {
|
|
244
|
+
envId,
|
|
245
|
+
operateType: 'cancel',
|
|
246
|
+
serverName: serviceName,
|
|
247
|
+
taskId: id
|
|
248
|
+
});
|
|
249
|
+
yield _runDeploy();
|
|
250
|
+
}
|
|
251
|
+
catch (e) {
|
|
252
|
+
trackCallback({
|
|
253
|
+
type: 'error',
|
|
254
|
+
details: e.message
|
|
255
|
+
}, log);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}));
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
trackCallback({
|
|
262
|
+
type: 'error',
|
|
263
|
+
details: `${e.message}`,
|
|
264
|
+
originalError: e
|
|
265
|
+
}, log);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
__decorate([
|
|
274
|
+
(0, decorators_1.InjectParams)(),
|
|
275
|
+
__param(0, (0, decorators_1.CmdContext)()),
|
|
276
|
+
__param(1, (0, decorators_1.EnvId)()),
|
|
277
|
+
__param(2, (0, decorators_1.Log)()),
|
|
278
|
+
__param(3, (0, decorators_1.ArgsOptions)()),
|
|
279
|
+
__metadata("design:type", Function),
|
|
280
|
+
__metadata("design:paramtypes", [Object, Object, decorators_1.Logger, Object]),
|
|
281
|
+
__metadata("design:returntype", Promise)
|
|
282
|
+
], RunfDeployCommand.prototype, "execute", null);
|
|
283
|
+
RunfDeployCommand = __decorate([
|
|
284
|
+
(0, common_1.ICommand)()
|
|
285
|
+
], RunfDeployCommand);
|
|
286
|
+
exports.RunfDeployCommand = RunfDeployCommand;
|
|
287
|
+
let RunfDownloadCommand = class RunfDownloadCommand extends common_1.Command {
|
|
288
|
+
get options() {
|
|
289
|
+
return {
|
|
290
|
+
cmd: 'runf',
|
|
291
|
+
childCmd: 'download',
|
|
292
|
+
options: [
|
|
293
|
+
{
|
|
294
|
+
flags: '-e, --envId <envId>',
|
|
295
|
+
desc: '环境 Id'
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
flags: '-s, --serviceName <serviceName>',
|
|
299
|
+
desc: '服务名称'
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
flags: '--source <source>',
|
|
303
|
+
desc: '目标函数文件所在目录路径。默认为当前路径'
|
|
304
|
+
}
|
|
305
|
+
],
|
|
306
|
+
requiredEnvId: false,
|
|
307
|
+
autoRunLogin: true,
|
|
308
|
+
desc: '下载云函数 2.0 服务代码'
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
execute(ctx, envId, log, options) {
|
|
312
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
313
|
+
let { serviceName, source } = options;
|
|
314
|
+
let targetDir = path_1.default.resolve(source || process.cwd());
|
|
315
|
+
if (!envId) {
|
|
316
|
+
const envConfig = (0, camelcase_keys_1.default)(yield iac_core_1.utils.loadEnv(targetDir));
|
|
317
|
+
envId = envConfig.envId || (yield _selectEnv());
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
log.info(`当前环境 Id:${envId}`);
|
|
321
|
+
}
|
|
322
|
+
if (!serviceName) {
|
|
323
|
+
let pkgName = '';
|
|
324
|
+
try {
|
|
325
|
+
const pkg = yield fs_extra_1.default.readJSON(path_1.default.join(targetDir, 'package.json'));
|
|
326
|
+
pkgName = pkg.name;
|
|
327
|
+
}
|
|
328
|
+
catch (e) { }
|
|
329
|
+
serviceName = yield _inputServiceName(pkgName);
|
|
330
|
+
if (serviceName !== pkgName) {
|
|
331
|
+
targetDir = path_1.default.join(targetDir, serviceName);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
const needTips = !(yield isDirectoryEmptyOrNotExists(targetDir));
|
|
335
|
+
if (needTips) {
|
|
336
|
+
const answers = yield inquirer_1.default.prompt([
|
|
337
|
+
{
|
|
338
|
+
type: 'confirm',
|
|
339
|
+
name: 'confirm',
|
|
340
|
+
message: `下载将覆盖 ${targetDir} 目录下的代码,是否继续?`,
|
|
341
|
+
default: true
|
|
342
|
+
}
|
|
343
|
+
]);
|
|
344
|
+
if (!answers.confirm) {
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
yield iac_core_1.IAC.init({
|
|
349
|
+
cwd: targetDir,
|
|
350
|
+
getCredential: () => {
|
|
351
|
+
return getCredential(ctx, options);
|
|
352
|
+
},
|
|
353
|
+
polyRepoMode: true
|
|
354
|
+
});
|
|
355
|
+
try {
|
|
356
|
+
yield iac_core_1.IAC.FunctionV2.pull({
|
|
357
|
+
cwd: targetDir,
|
|
358
|
+
envId: envId,
|
|
359
|
+
name: serviceName
|
|
360
|
+
}, function (message) {
|
|
361
|
+
trackCallback(message, log);
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
catch (e) {
|
|
365
|
+
trackCallback({
|
|
366
|
+
type: 'error',
|
|
367
|
+
details: `${e.message}`,
|
|
368
|
+
originalError: e
|
|
369
|
+
}, log);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
__decorate([
|
|
375
|
+
(0, decorators_1.InjectParams)(),
|
|
376
|
+
__param(0, (0, decorators_1.CmdContext)()),
|
|
377
|
+
__param(1, (0, decorators_1.EnvId)()),
|
|
378
|
+
__param(2, (0, decorators_1.Log)()),
|
|
379
|
+
__param(3, (0, decorators_1.ArgsOptions)()),
|
|
380
|
+
__metadata("design:type", Function),
|
|
381
|
+
__metadata("design:paramtypes", [Object, Object, decorators_1.Logger, Object]),
|
|
382
|
+
__metadata("design:returntype", Promise)
|
|
383
|
+
], RunfDownloadCommand.prototype, "execute", null);
|
|
384
|
+
RunfDownloadCommand = __decorate([
|
|
385
|
+
(0, common_1.ICommand)()
|
|
386
|
+
], RunfDownloadCommand);
|
|
387
|
+
exports.RunfDownloadCommand = RunfDownloadCommand;
|
|
388
|
+
class RunfRunCommand extends common_1.Command {
|
|
389
|
+
get options() {
|
|
390
|
+
return {
|
|
391
|
+
cmd: 'runf',
|
|
392
|
+
childCmd: 'run',
|
|
393
|
+
options: [
|
|
394
|
+
{
|
|
395
|
+
flags: '--source <source>',
|
|
396
|
+
desc: '目标函数文件所在目录路径,默认为当前路径'
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
flags: '--port <port>',
|
|
400
|
+
desc: '监听的端口,默认为 3000'
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
flags: '-w, --watch',
|
|
404
|
+
desc: '是否启用热重启模式,如启用,将会在文件变更时自动重启服务,默认为 false'
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
flags: '--dry-run',
|
|
408
|
+
desc: '是否不启动服务,只验证代码可以正常加载,默认为 false'
|
|
409
|
+
},
|
|
410
|
+
{
|
|
411
|
+
flags: '--logDirname <logDirname>',
|
|
412
|
+
desc: '日志文件目录,默认为 ./logs'
|
|
413
|
+
},
|
|
414
|
+
{
|
|
415
|
+
flags: '--functionsConfigFile <functionsConfigFile>',
|
|
416
|
+
desc: '多函数定义配置文件,默认为 ./cloudbase-functions.json'
|
|
417
|
+
}
|
|
418
|
+
],
|
|
419
|
+
requiredEnvId: false,
|
|
420
|
+
desc: '本地运行函数式托管代码'
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
execute(logger) {
|
|
424
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
425
|
+
const args = process.argv.slice(2);
|
|
426
|
+
const watchFlag = ['--watch', '-w'];
|
|
427
|
+
const defaultIgnoreFiles = ['logs/*.*'];
|
|
428
|
+
if (watchFlag.some((flag) => args.includes(flag))) {
|
|
429
|
+
debugger;
|
|
430
|
+
const cmd = args.filter((arg) => !watchFlag.includes(arg)).join(' ');
|
|
431
|
+
(0, nodemon_1.default)({
|
|
432
|
+
script: '',
|
|
433
|
+
exec: `${process.argv[1]} ${cmd}`,
|
|
434
|
+
watchOptions: {
|
|
435
|
+
usePolling: true,
|
|
436
|
+
ignorePermissionErrors: true,
|
|
437
|
+
ignored: defaultIgnoreFiles.join(','),
|
|
438
|
+
persistent: true,
|
|
439
|
+
interval: 500
|
|
440
|
+
}
|
|
441
|
+
})
|
|
442
|
+
.on('start', () => {
|
|
443
|
+
logger.info('Initializing server in watch mode. Changes in source files will trigger a restart.');
|
|
444
|
+
})
|
|
445
|
+
.on('quit', (e) => {
|
|
446
|
+
logger.info(`Nodemon quit with code ${e}.`);
|
|
447
|
+
process.exit(0);
|
|
448
|
+
})
|
|
449
|
+
.on('restart', (e) => {
|
|
450
|
+
var _a, _b;
|
|
451
|
+
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(', ')}`);
|
|
452
|
+
})
|
|
453
|
+
.on('log', (e) => {
|
|
454
|
+
logger.info(`[nodemon ${e.type}] ${e.message}`);
|
|
455
|
+
})
|
|
456
|
+
.on('crash', () => {
|
|
457
|
+
logger.error(`Server crashed.`);
|
|
458
|
+
process.exit(1);
|
|
459
|
+
})
|
|
460
|
+
.on('exit', (e) => {
|
|
461
|
+
logger.info(`Server exited with code ${e}.`);
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
(0, functions_framework_1.runCLI)();
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
__decorate([
|
|
471
|
+
(0, decorators_1.InjectParams)(),
|
|
472
|
+
__param(0, (0, decorators_1.Log)()),
|
|
473
|
+
__metadata("design:type", Function),
|
|
474
|
+
__metadata("design:paramtypes", [decorators_1.Logger]),
|
|
475
|
+
__metadata("design:returntype", Promise)
|
|
476
|
+
], RunfRunCommand.prototype, "execute", null);
|
|
477
|
+
exports.RunfRunCommand = RunfRunCommand;
|
|
478
|
+
function _selectEnv() {
|
|
479
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
480
|
+
return (0, utils_2.selectEnv)({ source: [constants_1.EnvSource.MINIAPP, constants_1.EnvSource.QCLOUD] });
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
function _inputServiceName(defaultVal = '') {
|
|
484
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
485
|
+
const questions = [
|
|
486
|
+
{
|
|
487
|
+
type: 'input',
|
|
488
|
+
name: 'serviceName',
|
|
489
|
+
message: '请输入服务名称(只能包含数字、小写字母和-,只能以小写字母开头,最多 20字符)',
|
|
490
|
+
default: defaultVal,
|
|
491
|
+
validate: (val) => {
|
|
492
|
+
return /^[a-z][a-z0-9-]{0,19}$/.test(val) ? true : '请输入正确的服务名称';
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
];
|
|
496
|
+
const answers = yield inquirer_1.default.prompt(questions);
|
|
497
|
+
return answers['serviceName'];
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
function getCredential(ctx, options) {
|
|
501
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
502
|
+
let credential;
|
|
503
|
+
if (ctx.hasPrivateSettings) {
|
|
504
|
+
process.env.IS_PRIVATE = 'true';
|
|
505
|
+
const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, options.cmd);
|
|
506
|
+
credential = privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.credential;
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
credential = yield utils_1.authSupevisor.getLoginState();
|
|
510
|
+
}
|
|
511
|
+
return credential;
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
function isDirectoryEmptyOrNotExists(dirPath) {
|
|
515
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
516
|
+
try {
|
|
517
|
+
const exists = yield fs_extra_1.default.pathExists(dirPath);
|
|
518
|
+
if (!exists) {
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
const files = yield fs_extra_1.default.readdir(dirPath);
|
|
522
|
+
return files.length === 0;
|
|
523
|
+
}
|
|
524
|
+
catch (error) {
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
function trackCallback(message, log) {
|
|
530
|
+
if (message.type === 'error') {
|
|
531
|
+
log.error(message.details);
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
log.info(message.details);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./base"), exports);
|
package/lib/help.js
CHANGED
|
@@ -20,7 +20,8 @@ const outputHelpInfo = () => {
|
|
|
20
20
|
storage [cmd] 云存储资源管理操作
|
|
21
21
|
service [cmd] HTTP 访问服务管理操作
|
|
22
22
|
run:deprecated [cmd] 云托管环境管理操作 (BAAS 或 RUN 类型环境)
|
|
23
|
-
run [cmd] 云托管环境管理操作 (TCBR 类型环境)
|
|
23
|
+
run [cmd] 云托管环境管理操作 (TCBR 类型环境)
|
|
24
|
+
runf [cmd] 云函数 2.0 服务管理操作`;
|
|
24
25
|
const options = `
|
|
25
26
|
选项
|
|
26
27
|
|
|
@@ -18,6 +18,15 @@ const debug_logger_1 = require("../debug-logger");
|
|
|
18
18
|
let commonCredential;
|
|
19
19
|
const isTokenExpired = (credential, gap = 120) => credential.accessTokenExpired && Number(credential.accessTokenExpired) < Date.now() + gap * 1000;
|
|
20
20
|
class CloudApiService {
|
|
21
|
+
static getInstance(service) {
|
|
22
|
+
var _a;
|
|
23
|
+
if ((_a = CloudApiService.serviceCacheMap) === null || _a === void 0 ? void 0 : _a[service]) {
|
|
24
|
+
return CloudApiService.serviceCacheMap[service];
|
|
25
|
+
}
|
|
26
|
+
const apiService = new CloudApiService(service);
|
|
27
|
+
CloudApiService.serviceCacheMap[service] = apiService;
|
|
28
|
+
return apiService;
|
|
29
|
+
}
|
|
21
30
|
constructor(service, baseParams, version = '') {
|
|
22
31
|
this.apiService = new cloud_api_1.CloudApiService({
|
|
23
32
|
service,
|
|
@@ -38,15 +47,6 @@ class CloudApiService {
|
|
|
38
47
|
})
|
|
39
48
|
});
|
|
40
49
|
}
|
|
41
|
-
static getInstance(service) {
|
|
42
|
-
var _a;
|
|
43
|
-
if ((_a = CloudApiService.serviceCacheMap) === null || _a === void 0 ? void 0 : _a[service]) {
|
|
44
|
-
return CloudApiService.serviceCacheMap[service];
|
|
45
|
-
}
|
|
46
|
-
const apiService = new CloudApiService(service);
|
|
47
|
-
CloudApiService.serviceCacheMap[service] = apiService;
|
|
48
|
-
return apiService;
|
|
49
|
-
}
|
|
50
50
|
request(action, data = {}, method = 'POST') {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
52
|
const region = this.region || (yield (0, toolbox_1.getRegion)());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.6.0-alpha.
|
|
3
|
+
"version": "2.6.0-pre-alpha.0",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,12 +33,14 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@cloudbase/cloud-api": "^0.5.5",
|
|
35
35
|
"@cloudbase/framework-core": "^1.9.7",
|
|
36
|
-
"@cloudbase/functions-framework": "^1.
|
|
37
|
-
"@cloudbase/
|
|
36
|
+
"@cloudbase/functions-framework": "^1.5.0",
|
|
37
|
+
"@cloudbase/iac-core": "^0.0.3-alpha.1",
|
|
38
|
+
"@cloudbase/lowcode-cli": "^0.22.0",
|
|
38
39
|
"@cloudbase/manager-node": "4.2.8",
|
|
39
40
|
"@cloudbase/toolbox": "^0.7.5",
|
|
40
41
|
"@sentry/node": "^5.10.2",
|
|
41
42
|
"address": "^1.1.2",
|
|
43
|
+
"camelcase-keys": "^7.0.2",
|
|
42
44
|
"chalk": "^2.4.2",
|
|
43
45
|
"cli-table3": "^0.5.1",
|
|
44
46
|
"commander": "7",
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Logger } from '../../decorators';
|
|
2
|
+
import { Command } from '../common';
|
|
3
|
+
export declare class RunfListCommand extends Command {
|
|
4
|
+
get options(): {
|
|
5
|
+
cmd: string;
|
|
6
|
+
childCmd: string;
|
|
7
|
+
options: {
|
|
8
|
+
flags: string;
|
|
9
|
+
desc: string;
|
|
10
|
+
}[];
|
|
11
|
+
requiredEnvId: boolean;
|
|
12
|
+
autoRunLogin: boolean;
|
|
13
|
+
desc: string;
|
|
14
|
+
};
|
|
15
|
+
execute(envId: any, log: Logger): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare class RunfDeployCommand extends Command {
|
|
18
|
+
get options(): {
|
|
19
|
+
cmd: string;
|
|
20
|
+
childCmd: string;
|
|
21
|
+
options: {
|
|
22
|
+
flags: string;
|
|
23
|
+
desc: string;
|
|
24
|
+
}[];
|
|
25
|
+
requiredEnvId: boolean;
|
|
26
|
+
autoRunLogin: boolean;
|
|
27
|
+
desc: string;
|
|
28
|
+
};
|
|
29
|
+
execute(ctx: any, envId: any, log: Logger, options: any): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare class RunfDownloadCommand extends Command {
|
|
32
|
+
get options(): {
|
|
33
|
+
cmd: string;
|
|
34
|
+
childCmd: string;
|
|
35
|
+
options: {
|
|
36
|
+
flags: string;
|
|
37
|
+
desc: string;
|
|
38
|
+
}[];
|
|
39
|
+
requiredEnvId: boolean;
|
|
40
|
+
autoRunLogin: boolean;
|
|
41
|
+
desc: string;
|
|
42
|
+
};
|
|
43
|
+
execute(ctx: any, envId: any, log: Logger, options: any): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export declare class RunfRunCommand extends Command {
|
|
46
|
+
get options(): {
|
|
47
|
+
cmd: string;
|
|
48
|
+
childCmd: string;
|
|
49
|
+
options: {
|
|
50
|
+
flags: string;
|
|
51
|
+
desc: string;
|
|
52
|
+
}[];
|
|
53
|
+
requiredEnvId: boolean;
|
|
54
|
+
desc: string;
|
|
55
|
+
};
|
|
56
|
+
execute(logger: Logger): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './base';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ParamTypes } from '../constants';
|
|
2
|
-
|
|
2
|
+
type GetterFunction = (target: any) => Promise<any> | any;
|
|
3
3
|
export declare const createParamDecorator: (paramtype: ParamTypes, getter: GetterFunction) => () => (target: any, key: string | symbol, index: number) => void;
|
|
4
4
|
export {};
|
package/types/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
export
|
|
2
|
+
export type CustomEvent = 'logout';
|
|
3
3
|
export interface ICommandContext {
|
|
4
4
|
cmd: string;
|
|
5
5
|
envId: string;
|
|
@@ -33,7 +33,7 @@ export interface TmpCredential {
|
|
|
33
33
|
uin?: string;
|
|
34
34
|
hash?: string;
|
|
35
35
|
}
|
|
36
|
-
export
|
|
36
|
+
export type Credential = TmpCredential & PermanentCredential;
|
|
37
37
|
export interface AuthSecret {
|
|
38
38
|
secretId: string;
|
|
39
39
|
secretKey: string;
|
package/types/utils/config.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export interface IArgs {
|
|
|
10
10
|
}
|
|
11
11
|
export declare const getArgs: () => Arguments<IArgs>;
|
|
12
12
|
export declare function getPrivateSettings(config: ICloudBaseRcSettings, cmd?: string): undefined | IPrivateSettings;
|
|
13
|
-
|
|
13
|
+
type IAbsUrl = `http://${string}` | `https://${string}`;
|
|
14
14
|
export interface IPrivateSettings {
|
|
15
15
|
credential: Credential;
|
|
16
16
|
endpoints: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './del';
|
|
2
|
-
export
|
|
2
|
+
export type SizeUnit = 'KB' | 'MB' | 'GB';
|
|
3
3
|
export declare function checkFullAccess(dest: string, throwError?: boolean): boolean;
|
|
4
4
|
export declare function checkWritable(dest: string, throwError?: boolean): boolean;
|
|
5
5
|
export declare function checkReadable(dest: string, throwError?: boolean): boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _fetch, { RequestInit } from 'node-fetch';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
type fetchReturnType = ReturnType<typeof _fetch>;
|
|
3
|
+
type UnPromisify<T> = T extends PromiseLike<infer U> ? U : T;
|
|
4
|
+
type fetchReturnTypeExtracted = UnPromisify<fetchReturnType>;
|
|
5
5
|
export declare function fetch(url: string, config?: RequestInit): Promise<any>;
|
|
6
6
|
export declare function postFetch(url: string, data?: Record<string, any>): Promise<any>;
|
|
7
7
|
export declare function fetchStream(url: any, config?: Record<string, any>): Promise<fetchReturnTypeExtracted>;
|
|
@@ -8,7 +8,7 @@ declare class Loading {
|
|
|
8
8
|
fail(text: string): void;
|
|
9
9
|
}
|
|
10
10
|
export declare const loadingFactory: () => Loading;
|
|
11
|
-
|
|
11
|
+
type Task<T> = (flush: (text: string) => void, ...args: any[]) => Promise<T>;
|
|
12
12
|
export interface ILoadingOptions {
|
|
13
13
|
startTip?: string;
|
|
14
14
|
successTip?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type SimpleValue = number | string | boolean;
|
|
2
2
|
export declare function assertTruthy(val: SimpleValue | SimpleValue[], errMsg: string): void;
|
|
3
3
|
export declare function assertHas(obj: any, prop: string, errMsg: any): void;
|
|
4
4
|
export declare const validateIp: (ip: string) => boolean;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
import { Command, ICommand } from '../common'
|
|
3
|
-
import { watchApp } from '@cloudbase/lowcode-cli'
|
|
4
|
-
import { InjectParams, Log, Logger, CmdContext, ArgsOptions } from '../../decorators'
|
|
5
|
-
|
|
6
|
-
@ICommand()
|
|
7
|
-
export class LowCodeWatch extends Command {
|
|
8
|
-
get options() {
|
|
9
|
-
return {
|
|
10
|
-
cmd: 'lowcode',
|
|
11
|
-
childCmd: 'watch',
|
|
12
|
-
options: [
|
|
13
|
-
{
|
|
14
|
-
flags: '--verbose',
|
|
15
|
-
desc: '是否打印详细日志'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
flags: '--wx-devtool-path <wxDevtoolPath>',
|
|
19
|
-
desc: '微信开发者工具的安装路径'
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
desc: '开启云开发低码的本地构建模式',
|
|
23
|
-
requiredEnvId: false
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@InjectParams()
|
|
28
|
-
async execute(@CmdContext() ctx, @ArgsOptions() options) {
|
|
29
|
-
await watchApp({
|
|
30
|
-
watchPort: 8288,
|
|
31
|
-
wxDevtoolPath: options?.wxDevtoolPath
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@ICommand()
|
|
37
|
-
export class DanielWatch extends Command {
|
|
38
|
-
get options() {
|
|
39
|
-
return {
|
|
40
|
-
cmd: 'lowcode',
|
|
41
|
-
childCmd: 'watch-ws',
|
|
42
|
-
options: [],
|
|
43
|
-
desc: '开启云开发低码的本地开发模式',
|
|
44
|
-
requiredEnvId: false
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
@InjectParams()
|
|
49
|
-
async execute(@CmdContext() ctx, @ArgsOptions() options) {
|
|
50
|
-
console.log('>>> 启动啦')
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
import { Command, ICommand } from '../common'
|
|
3
|
-
import { watchApp } from '@cloudbase/lowcode-cli'
|
|
4
|
-
import { InjectParams, Log, Logger, CmdContext, ArgsOptions } from '../../decorators'
|
|
5
|
-
|
|
6
|
-
@ICommand()
|
|
7
|
-
export class LowCodeWatch extends Command {
|
|
8
|
-
get options() {
|
|
9
|
-
return {
|
|
10
|
-
cmd: 'lowcode',
|
|
11
|
-
childCmd: 'watch',
|
|
12
|
-
options: [
|
|
13
|
-
{
|
|
14
|
-
flags: '--verbose',
|
|
15
|
-
desc: '是否打印详细日志'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
flags: '--wx-devtool-path <wxDevtoolPath>',
|
|
19
|
-
desc: '微信开发者工具的安装路径'
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
desc: '开启云开发低码的本地构建模式',
|
|
23
|
-
requiredEnvId: false
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@InjectParams()
|
|
28
|
-
async execute(@CmdContext() ctx, @ArgsOptions() options) {
|
|
29
|
-
await watchApp({
|
|
30
|
-
watchPort: 8288,
|
|
31
|
-
wxDevtoolPath: options?.wxDevtoolPath
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import _ from 'lodash'
|
|
2
|
-
import { Command, ICommand } from '../common'
|
|
3
|
-
import { watchApp } from '@cloudbase/lowcode-cli'
|
|
4
|
-
import { InjectParams, Log, Logger, CmdContext, ArgsOptions } from '../../decorators'
|
|
5
|
-
|
|
6
|
-
@ICommand()
|
|
7
|
-
export class LowCodeWatch extends Command {
|
|
8
|
-
get options() {
|
|
9
|
-
return {
|
|
10
|
-
cmd: 'lowcode',
|
|
11
|
-
childCmd: 'watch',
|
|
12
|
-
options: [
|
|
13
|
-
{
|
|
14
|
-
flags: '--verbose',
|
|
15
|
-
desc: '是否打印详细日志'
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
flags: '--wx-devtool-path <wxDevtoolPath>',
|
|
19
|
-
desc: '微信开发者工具的安装路径'
|
|
20
|
-
}
|
|
21
|
-
],
|
|
22
|
-
desc: '开启微搭低代码的本地构建模式',
|
|
23
|
-
requiredEnvId: false
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@InjectParams()
|
|
28
|
-
async execute(@CmdContext() ctx, @ArgsOptions() options) {
|
|
29
|
-
await watchApp({
|
|
30
|
-
watchPort: 8288,
|
|
31
|
-
wxDevtoolPath: options?.wxDevtoolPath
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata'
|
|
2
|
-
import { registerCommands } from './commands/common'
|
|
3
|
-
import './commands'
|
|
4
|
-
|
|
5
|
-
export { smartDeploy } from './commands'
|
|
6
|
-
|
|
7
|
-
registerCommands()
|
|
8
|
-
|
|
9
|
-
// HACK: 部分依赖使用了 globalThis,会在 Node12 以下的版本报错
|
|
10
|
-
if (typeof globalThis === undefined) {
|
|
11
|
-
// eslint-disable-next-line no-undef
|
|
12
|
-
;(globalThis as any) = global
|
|
13
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata'
|
|
2
|
-
import { registerCommands } from './commands/common'
|
|
3
|
-
import './commands'
|
|
4
|
-
|
|
5
|
-
export { smartDeploy } from './commands'
|
|
6
|
-
|
|
7
|
-
registerCommands()
|
|
8
|
-
|
|
9
|
-
// HACK: 部分依赖使用了 globalThis,会在 Node12 以下的版本报错
|
|
10
|
-
if (typeof globalThis === undefined) {
|
|
11
|
-
// eslint-disable-next-line no-undef
|
|
12
|
-
;(globalThis as any) = global
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
console.log("daniel tcb")
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import 'reflect-metadata'
|
|
2
|
-
import { registerCommands } from './commands/common'
|
|
3
|
-
import './commands'
|
|
4
|
-
|
|
5
|
-
export { smartDeploy } from './commands'
|
|
6
|
-
|
|
7
|
-
registerCommands()
|
|
8
|
-
|
|
9
|
-
// HACK: 部分依赖使用了 globalThis,会在 Node12 以下的版本报错
|
|
10
|
-
if (typeof globalThis === undefined) {
|
|
11
|
-
// eslint-disable-next-line no-undef
|
|
12
|
-
;(globalThis as any) = global
|
|
13
|
-
}
|
package/.yarn/cache/@cloudbase-functions-framework-npm-1.0.0-beta.3-68c4d9136e-3d11f97edc.zip
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|