@cloudbase/cli 2.1.6 → 2.2.0-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/bin/tcb.js +45 -19
- package/lib/commands/common.js +37 -7
- package/lib/commands/lowcode/app.js +110 -3
- package/lib/commands/lowcode/comps.js +57 -25
- package/lib/decorators/constants.js +1 -0
- package/lib/decorators/injectParams.js +3 -0
- package/lib/decorators/params/index.js +2 -1
- package/lib/index.js +3 -3
- package/lib/utils/auth.js +2 -1
- package/lib/utils/config.js +8 -1
- package/lib/utils/log.js +3 -0
- package/package.json +2 -2
- package/types/commands/common.d.ts +5 -2
- package/types/commands/lowcode/app.d.ts +25 -0
- package/types/commands/lowcode/comps.d.ts +1 -1
- package/types/decorators/constants.d.ts +2 -1
- package/types/decorators/params/index.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/types.d.ts +1 -0
- package/types/utils/config.d.ts +15 -1
- package/types/utils/log.d.ts +1 -0
- package/.history/.gitignore_20220624162613 +0 -84
- package/.history/.gitignore_20220627114054 +0 -86
- package/.history/package_20220922143103.json +0 -93
- package/.history/package_20220922143115.json +0 -89
- package/.history/package_20220922202714.json +0 -89
- package/.history/package_20220922202748.json +0 -89
- 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/bin/tcb.js
CHANGED
|
@@ -14,7 +14,10 @@ const pkg = require('../package.json')
|
|
|
14
14
|
const store = require('../lib/utils/store')
|
|
15
15
|
const { ALL_COMMANDS } = require('../lib/constant')
|
|
16
16
|
const { getProxy } = require('../lib/utils/net')
|
|
17
|
+
const { getCloudBaseConfig, checkPrivateSettingsExisted } = require('../lib/utils/config')
|
|
18
|
+
const {registerCommands} = require('../lib')
|
|
17
19
|
|
|
20
|
+
async function main() {
|
|
18
21
|
let processArgv = process.argv
|
|
19
22
|
const isBeta = pkg.version.indexOf('-') > -1
|
|
20
23
|
process.CLI_VERSION = pkg.version
|
|
@@ -47,8 +50,19 @@ Sentry.init({
|
|
|
47
50
|
console.log(chalk.gray(`CloudBase CLI ${pkg.version}`))
|
|
48
51
|
console.log(chalk.gray(`CloudBase Framework ${frameworkPkg.version}`))
|
|
49
52
|
|
|
53
|
+
|
|
54
|
+
const yargsParsedResult = yargsParser(process.argv.slice(2));
|
|
55
|
+
const config = await getCloudBaseConfig(yargsParsedResult.configFile);
|
|
56
|
+
const isPrivateEnv = checkPrivateSettingsExisted(config)
|
|
57
|
+
if (isPrivateEnv) {
|
|
58
|
+
console.log(chalk.gray(`检测到私有化配置`))
|
|
59
|
+
// 初始化 lowcode 服务cliapi入口
|
|
60
|
+
process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL = config.privateSettings.cliApiEntrypoint;
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
50
64
|
// 注册命令
|
|
51
|
-
|
|
65
|
+
await registerCommands()
|
|
52
66
|
|
|
53
67
|
// 设置 Sentry 上报的用户 uin
|
|
54
68
|
Sentry.configureScope((scope) => {
|
|
@@ -70,9 +84,11 @@ program.option('--mode <mode>', '指定加载 env 文件的环境')
|
|
|
70
84
|
program.option('--config-file <path>', '设置配置文件,默认为 cloudbaserc.json')
|
|
71
85
|
program.option('-r, --region <region>', '指定环境地域')
|
|
72
86
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
if(!isPrivateEnv) {
|
|
88
|
+
// HACK: 隐藏自动生成的 help 信息
|
|
89
|
+
program.helpOption(false)
|
|
90
|
+
}
|
|
91
|
+
const isCommandEmpty = yargsParsedResult._.length === 0;
|
|
76
92
|
|
|
77
93
|
// -v 时输出的版本信息,设置时避免影响其他命令使用 -v
|
|
78
94
|
if (isCommandEmpty) {
|
|
@@ -102,21 +118,25 @@ program.action(() => {
|
|
|
102
118
|
|
|
103
119
|
// 没有使用命令
|
|
104
120
|
if (isCommandEmpty) {
|
|
105
|
-
if
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
if(isPrivateEnv) {
|
|
122
|
+
program.outputHelp()
|
|
123
|
+
} else {
|
|
124
|
+
if (['-h', '--help'].includes(processArgv[2])) {
|
|
125
|
+
// 需要隐藏的选项
|
|
126
|
+
const hideArgs = ['-h', '--help']
|
|
127
|
+
hideArgs.forEach((arg) => {
|
|
128
|
+
const index = processArgv.indexOf(arg)
|
|
129
|
+
if (index > -1) {
|
|
130
|
+
processArgv.splice(index, 1)
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
const { outputHelpInfo } = require('../lib/help')
|
|
134
|
+
outputHelpInfo()
|
|
135
|
+
} else if (!['-v', '--version'].includes(processArgv[2])) {
|
|
136
|
+
// HACK: framework 智能命令
|
|
137
|
+
const { smartDeploy } = require('../lib')
|
|
138
|
+
smartDeploy()
|
|
139
|
+
}
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
142
|
|
|
@@ -183,3 +203,9 @@ const notifier = updateNotifier({
|
|
|
183
203
|
notifier.notify({
|
|
184
204
|
isGlobal: true
|
|
185
205
|
})
|
|
206
|
+
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if(require.main === module) {
|
|
210
|
+
main()
|
|
211
|
+
}
|
package/lib/commands/common.js
CHANGED
|
@@ -40,20 +40,39 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
40
40
|
const Sentry = __importStar(require("@sentry/node"));
|
|
41
41
|
const events_1 = require("events");
|
|
42
42
|
const commander_1 = require("commander");
|
|
43
|
+
const yargs_parser_1 = __importDefault(require("yargs-parser"));
|
|
43
44
|
const error_1 = require("../error");
|
|
44
45
|
const utils_1 = require("../utils");
|
|
45
46
|
const registrableCommands = [];
|
|
46
47
|
const cmdMap = new Map();
|
|
47
|
-
|
|
48
|
+
const defaultCmdDecoratorOpts = {
|
|
49
|
+
supportPrivate: false
|
|
50
|
+
};
|
|
51
|
+
function ICommand(options = defaultCmdDecoratorOpts) {
|
|
48
52
|
return (target) => {
|
|
49
|
-
registrableCommands.push(target);
|
|
53
|
+
registrableCommands.push({ Command: target, decoratorOptions: options });
|
|
50
54
|
};
|
|
51
55
|
}
|
|
52
56
|
exports.ICommand = ICommand;
|
|
53
57
|
function registerCommands() {
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const args = (0, yargs_parser_1.default)(process.argv.slice(2));
|
|
60
|
+
const config = yield (0, utils_1.getCloudBaseConfig)(args.configFile);
|
|
61
|
+
const isPrivate = (0, utils_1.checkPrivateSettingsExisted)(config);
|
|
62
|
+
registrableCommands.forEach(({ Command, decoratorOptions }) => {
|
|
63
|
+
if (isPrivate) {
|
|
64
|
+
if (decoratorOptions.supportPrivate) {
|
|
65
|
+
const command = new Command();
|
|
66
|
+
command.init();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
if (decoratorOptions.supportPrivate !== 'only') {
|
|
71
|
+
const command = new Command();
|
|
72
|
+
command.init();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
57
76
|
});
|
|
58
77
|
}
|
|
59
78
|
exports.registerCommands = registerCommands;
|
|
@@ -132,7 +151,17 @@ class Command extends events_1.EventEmitter {
|
|
|
132
151
|
const parentOptions = commander_1.program.opts();
|
|
133
152
|
const config = yield (0, utils_1.getCloudBaseConfig)(parentOptions === null || parentOptions === void 0 ? void 0 : parentOptions.configFile);
|
|
134
153
|
const envId = (cmdOptions === null || cmdOptions === void 0 ? void 0 : cmdOptions.envId) || (config === null || config === void 0 ? void 0 : config.envId);
|
|
135
|
-
const
|
|
154
|
+
const hasPrivateSettings = (0, utils_1.checkPrivateSettingsExisted)(config);
|
|
155
|
+
let loginState;
|
|
156
|
+
if (hasPrivateSettings) {
|
|
157
|
+
loginState = {
|
|
158
|
+
secretId: config.privateSettings.secretID,
|
|
159
|
+
secretKey: config.privateSettings.secretKey
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
loginState = (yield utils_1.authSupevisor.getLoginState());
|
|
164
|
+
}
|
|
136
165
|
if (!withoutAuth && !loginState) {
|
|
137
166
|
throw new error_1.CloudBaseError('无有效身份信息,请使用 cloudbase login 登录');
|
|
138
167
|
}
|
|
@@ -144,7 +173,8 @@ class Command extends events_1.EventEmitter {
|
|
|
144
173
|
envId,
|
|
145
174
|
config,
|
|
146
175
|
params,
|
|
147
|
-
options: cmdOptions
|
|
176
|
+
options: cmdOptions,
|
|
177
|
+
hasPrivateSettings
|
|
148
178
|
};
|
|
149
179
|
this.emit('preHandle', ctx, args.slice(0, -1));
|
|
150
180
|
yield this.preHandle();
|
|
@@ -43,10 +43,31 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
43
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
47
|
+
var t = {};
|
|
48
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
49
|
+
t[p] = s[p];
|
|
50
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
51
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
52
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
53
|
+
t[p[i]] = s[p[i]];
|
|
54
|
+
}
|
|
55
|
+
return t;
|
|
56
|
+
};
|
|
57
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
+
};
|
|
46
60
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
exports.LowCodeWatch = void 0;
|
|
61
|
+
exports.LowCodeDeployApp = exports.LowCodeBuildApp = exports.LowCodeWatch = void 0;
|
|
62
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
48
63
|
const common_1 = require("../common");
|
|
49
64
|
const decorators_1 = require("../../decorators");
|
|
65
|
+
const utils_1 = require("./utils");
|
|
66
|
+
const utils_2 = require("../../utils");
|
|
67
|
+
let lowcodeCli;
|
|
68
|
+
if (process.argv.includes('lowcode')) {
|
|
69
|
+
(0, utils_1.getLowcodeCli)().then((_) => (lowcodeCli = _));
|
|
70
|
+
}
|
|
50
71
|
let LowCodeWatch = class LowCodeWatch extends common_1.Command {
|
|
51
72
|
get options() {
|
|
52
73
|
return {
|
|
@@ -71,7 +92,7 @@ let LowCodeWatch = class LowCodeWatch extends common_1.Command {
|
|
|
71
92
|
Promise.resolve().then(() => __importStar(require('@cloudbase/lowcode-cli'))).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
72
93
|
yield res.watchApp({
|
|
73
94
|
watchPort: 8288,
|
|
74
|
-
wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath
|
|
95
|
+
wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath
|
|
75
96
|
});
|
|
76
97
|
}));
|
|
77
98
|
});
|
|
@@ -86,6 +107,92 @@ __decorate([
|
|
|
86
107
|
__metadata("design:returntype", Promise)
|
|
87
108
|
], LowCodeWatch.prototype, "execute", null);
|
|
88
109
|
LowCodeWatch = __decorate([
|
|
89
|
-
(0, common_1.ICommand)(
|
|
110
|
+
(0, common_1.ICommand)({
|
|
111
|
+
supportPrivate: true
|
|
112
|
+
})
|
|
90
113
|
], LowCodeWatch);
|
|
91
114
|
exports.LowCodeWatch = LowCodeWatch;
|
|
115
|
+
let LowCodeBuildApp = class LowCodeBuildApp extends common_1.Command {
|
|
116
|
+
get options() {
|
|
117
|
+
return {
|
|
118
|
+
cmd: 'lowcode',
|
|
119
|
+
childCmd: 'build:app',
|
|
120
|
+
options: [],
|
|
121
|
+
desc: '构建应用',
|
|
122
|
+
requiredEnvId: false
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
execute(ctx, log, options) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
yield lowcodeCli.buildApp({
|
|
128
|
+
envId: ctx.envId,
|
|
129
|
+
projectPath: process.cwd(),
|
|
130
|
+
logger: log,
|
|
131
|
+
privateSettings: lodash_1.default.get(ctx, 'config.privateSettings')
|
|
132
|
+
}, options);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
__decorate([
|
|
137
|
+
(0, decorators_1.InjectParams)(),
|
|
138
|
+
__param(0, (0, decorators_1.CmdContext)()),
|
|
139
|
+
__param(1, (0, decorators_1.Log)()),
|
|
140
|
+
__param(2, (0, decorators_1.ArgsOptions)()),
|
|
141
|
+
__metadata("design:type", Function),
|
|
142
|
+
__metadata("design:paramtypes", [Object, decorators_1.Logger, Object]),
|
|
143
|
+
__metadata("design:returntype", Promise)
|
|
144
|
+
], LowCodeBuildApp.prototype, "execute", null);
|
|
145
|
+
LowCodeBuildApp = __decorate([
|
|
146
|
+
(0, common_1.ICommand)({ supportPrivate: true })
|
|
147
|
+
], LowCodeBuildApp);
|
|
148
|
+
exports.LowCodeBuildApp = LowCodeBuildApp;
|
|
149
|
+
let LowCodeDeployApp = class LowCodeDeployApp extends common_1.Command {
|
|
150
|
+
get options() {
|
|
151
|
+
return {
|
|
152
|
+
cmd: 'lowcode',
|
|
153
|
+
childCmd: 'publish:app',
|
|
154
|
+
options: [
|
|
155
|
+
{
|
|
156
|
+
flags: '--src <src>',
|
|
157
|
+
desc: '部署目录'
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
desc: '发布应用',
|
|
161
|
+
requiredEnvId: false
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
execute(ctx, log, options) {
|
|
165
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
const { src } = options, restOptions = __rest(options, ["src"]);
|
|
167
|
+
if (ctx.hasPrivateSettings) {
|
|
168
|
+
process.env.IS_PRIVATE = 'true';
|
|
169
|
+
}
|
|
170
|
+
yield lowcodeCli.deployApp({
|
|
171
|
+
envId: ctx.envId,
|
|
172
|
+
projectPath: process.cwd(),
|
|
173
|
+
logger: log,
|
|
174
|
+
privateSettings: lodash_1.default.get(ctx, 'config.privateSettings')
|
|
175
|
+
}, Object.assign(Object.assign({ credential: yield utils_2.authSupevisor.getLoginState(), webOptions: {
|
|
176
|
+
endpoint: 'http://oss-csp1.rgw.infra.tce.io',
|
|
177
|
+
bucket: 'weda-system-ci-source',
|
|
178
|
+
credential: {
|
|
179
|
+
secretId: 'DLV8AX0LSRZHJHG4C64Q',
|
|
180
|
+
secretKey: 'fztbf1CEMSOXXhH9XzRJP0D7TLh7M7A8ZxHItjpG'
|
|
181
|
+
}
|
|
182
|
+
} }, restOptions), { projectPath: src }));
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
__decorate([
|
|
187
|
+
(0, decorators_1.InjectParams)(),
|
|
188
|
+
__param(0, (0, decorators_1.CmdContext)()),
|
|
189
|
+
__param(1, (0, decorators_1.Log)()),
|
|
190
|
+
__param(2, (0, decorators_1.ArgsOptions)()),
|
|
191
|
+
__metadata("design:type", Function),
|
|
192
|
+
__metadata("design:paramtypes", [Object, decorators_1.Logger, Object]),
|
|
193
|
+
__metadata("design:returntype", Promise)
|
|
194
|
+
], LowCodeDeployApp.prototype, "execute", null);
|
|
195
|
+
LowCodeDeployApp = __decorate([
|
|
196
|
+
(0, common_1.ICommand)({ supportPrivate: true })
|
|
197
|
+
], LowCodeDeployApp);
|
|
198
|
+
exports.LowCodeDeployApp = LowCodeDeployApp;
|
|
@@ -43,16 +43,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
43
43
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
46
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
50
|
exports.LowCodePublishVersionComps = exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
|
|
51
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
48
52
|
const common_1 = require("../common");
|
|
49
53
|
const decorators_1 = require("../../decorators");
|
|
50
|
-
const utils_1 = require("../../utils");
|
|
51
|
-
const error_1 = require("../../error");
|
|
52
54
|
const enquirer_1 = require("enquirer");
|
|
53
55
|
const semver = __importStar(require("semver"));
|
|
56
|
+
const utils_1 = require("../../utils");
|
|
57
|
+
const cloud_api_1 = require("@cloudbase/cloud-api");
|
|
58
|
+
const error_1 = require("../../error");
|
|
54
59
|
const utils_2 = require("./utils");
|
|
55
|
-
const cloudService = utils_1.CloudApiService.getInstance('lowcode');
|
|
56
60
|
let lowcodeCli;
|
|
57
61
|
if (process.argv.includes('lowcode')) {
|
|
58
62
|
(0, utils_2.getLowcodeCli)().then(_ => lowcodeCli = _);
|
|
@@ -66,18 +70,44 @@ let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
|
|
|
66
70
|
{
|
|
67
71
|
flags: '--verbose',
|
|
68
72
|
desc: '是否打印详细日志'
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
flags: '--skip-validate',
|
|
76
|
+
desc: '是否跳过组件存在性检查'
|
|
69
77
|
}
|
|
70
78
|
],
|
|
71
79
|
desc: '创建组件库',
|
|
72
80
|
requiredEnvId: false
|
|
73
81
|
};
|
|
74
82
|
}
|
|
75
|
-
execute(params, log) {
|
|
83
|
+
execute(opts, params, isPrivateEnv, config, log) {
|
|
76
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
if (opts.skipValidate) {
|
|
86
|
+
if (!(params === null || params === void 0 ? void 0 : params[0])) {
|
|
87
|
+
throw new error_1.CloudBaseError('skip validate 需要指定组件库名 eg: `tcb lowcode create mydemo`');
|
|
88
|
+
}
|
|
89
|
+
yield lowcodeCli.bootstrap(params === null || params === void 0 ? void 0 : params[0], log);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
77
92
|
if (process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL === undefined) {
|
|
78
93
|
process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL = 'https://lcap.cloud.tencent.com/api/v1/cliapi';
|
|
79
94
|
}
|
|
80
|
-
|
|
95
|
+
let cloudService;
|
|
96
|
+
if (isPrivateEnv) {
|
|
97
|
+
cloudService = cloud_api_1.CloudApiService.getInstance({
|
|
98
|
+
service: 'lowcode',
|
|
99
|
+
credential: {
|
|
100
|
+
secretId: config.privateSettings.secretID,
|
|
101
|
+
secretKey: config.privateSettings.secretKey
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
cloudService = utils_1.CloudApiService.getInstance('lowcode');
|
|
107
|
+
}
|
|
108
|
+
const res = yield cloudService.request('ListUserCompositeGroups', isPrivateEnv ? {
|
|
109
|
+
privateUin: config.privateSettings.privateUin
|
|
110
|
+
} : undefined);
|
|
81
111
|
const comps = res === null || res === void 0 ? void 0 : res.data;
|
|
82
112
|
if (!(comps === null || comps === void 0 ? void 0 : comps.count)) {
|
|
83
113
|
throw new error_1.CloudBaseError('没有可关联的云端组件库,请到低码控制台新建组件库!');
|
|
@@ -104,17 +134,22 @@ let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
|
|
|
104
134
|
};
|
|
105
135
|
__decorate([
|
|
106
136
|
(0, decorators_1.InjectParams)(),
|
|
107
|
-
__param(0, (0, decorators_1.
|
|
108
|
-
__param(1, (0, decorators_1.
|
|
137
|
+
__param(0, (0, decorators_1.ArgsOptions)()),
|
|
138
|
+
__param(1, (0, decorators_1.ArgsParams)()),
|
|
139
|
+
__param(2, (0, decorators_1.IsPrivateEnv)()),
|
|
140
|
+
__param(3, (0, decorators_1.Config)()),
|
|
141
|
+
__param(4, (0, decorators_1.Log)()),
|
|
109
142
|
__metadata("design:type", Function),
|
|
110
|
-
__metadata("design:paramtypes", [Object, decorators_1.Logger]),
|
|
143
|
+
__metadata("design:paramtypes", [Object, Object, Boolean, Object, decorators_1.Logger]),
|
|
111
144
|
__metadata("design:returntype", Promise)
|
|
112
145
|
], LowCodeCreateComps.prototype, "execute", null);
|
|
113
146
|
LowCodeCreateComps = __decorate([
|
|
114
|
-
(0, common_1.ICommand)(
|
|
147
|
+
(0, common_1.ICommand)({
|
|
148
|
+
supportPrivate: true
|
|
149
|
+
})
|
|
115
150
|
], LowCodeCreateComps);
|
|
116
151
|
exports.LowCodeCreateComps = LowCodeCreateComps;
|
|
117
|
-
|
|
152
|
+
class LowCodeBuildComps extends common_1.Command {
|
|
118
153
|
get options() {
|
|
119
154
|
return {
|
|
120
155
|
cmd: 'lowcode',
|
|
@@ -133,13 +168,13 @@ let LowCodeBuildComps = class LowCodeBuildComps extends common_1.Command {
|
|
|
133
168
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
169
|
const config = ctx.config.lowcodeCustomComponents;
|
|
135
170
|
if (config) {
|
|
136
|
-
yield lowcodeCli.graceBuildComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log }));
|
|
171
|
+
yield lowcodeCli.graceBuildComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: lodash_1.default.get(ctx, 'config.privateSettings') }));
|
|
137
172
|
return;
|
|
138
173
|
}
|
|
139
174
|
throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
|
|
140
175
|
});
|
|
141
176
|
}
|
|
142
|
-
}
|
|
177
|
+
}
|
|
143
178
|
__decorate([
|
|
144
179
|
(0, decorators_1.InjectParams)(),
|
|
145
180
|
__param(0, (0, decorators_1.CmdContext)()),
|
|
@@ -148,9 +183,6 @@ __decorate([
|
|
|
148
183
|
__metadata("design:paramtypes", [Object, Object]),
|
|
149
184
|
__metadata("design:returntype", Promise)
|
|
150
185
|
], LowCodeBuildComps.prototype, "execute", null);
|
|
151
|
-
LowCodeBuildComps = __decorate([
|
|
152
|
-
(0, common_1.ICommand)()
|
|
153
|
-
], LowCodeBuildComps);
|
|
154
186
|
exports.LowCodeBuildComps = LowCodeBuildComps;
|
|
155
187
|
let LowCodeDebugComps = class LowCodeDebugComps extends common_1.Command {
|
|
156
188
|
get options() {
|
|
@@ -179,7 +211,7 @@ let LowCodeDebugComps = class LowCodeDebugComps extends common_1.Command {
|
|
|
179
211
|
return __awaiter(this, void 0, void 0, function* () {
|
|
180
212
|
const config = ctx.config.lowcodeCustomComponents;
|
|
181
213
|
if (config) {
|
|
182
|
-
yield lowcodeCli.graceDebugComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), debugPort: (options === null || options === void 0 ? void 0 : options.debugPort) || 8388, logger: log, wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath }));
|
|
214
|
+
yield lowcodeCli.graceDebugComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), debugPort: (options === null || options === void 0 ? void 0 : options.debugPort) || 8388, logger: log, wxDevtoolPath: options === null || options === void 0 ? void 0 : options.wxDevtoolPath, debugBaseUrl: lodash_1.default.get(ctx, 'config.privateSettings.editorEntrypoint') }));
|
|
183
215
|
return;
|
|
184
216
|
}
|
|
185
217
|
throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
|
|
@@ -223,7 +255,7 @@ let LowCodePublishComps = class LowCodePublishComps extends common_1.Command {
|
|
|
223
255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
256
|
const config = ctx.config.lowcodeCustomComponents;
|
|
225
257
|
if (config) {
|
|
226
|
-
yield lowcodeCli.gracePublishComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: Boolean(options.admin) }));
|
|
258
|
+
yield lowcodeCli.gracePublishComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings: lodash_1.default.get(ctx, 'config.privateSettings'), isAdmin: Boolean(options.admin) }));
|
|
227
259
|
log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!');
|
|
228
260
|
return;
|
|
229
261
|
}
|
|
@@ -241,7 +273,7 @@ __decorate([
|
|
|
241
273
|
__metadata("design:returntype", Promise)
|
|
242
274
|
], LowCodePublishComps.prototype, "execute", null);
|
|
243
275
|
LowCodePublishComps = __decorate([
|
|
244
|
-
(0, common_1.ICommand)()
|
|
276
|
+
(0, common_1.ICommand)({ supportPrivate: true })
|
|
245
277
|
], LowCodePublishComps);
|
|
246
278
|
exports.LowCodePublishComps = LowCodePublishComps;
|
|
247
279
|
let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common_1.Command {
|
|
@@ -276,12 +308,10 @@ let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common
|
|
|
276
308
|
return __awaiter(this, void 0, void 0, function* () {
|
|
277
309
|
const { tag, comment, admin } = options;
|
|
278
310
|
if (!comment) {
|
|
279
|
-
|
|
280
|
-
return;
|
|
311
|
+
throw new error_1.CloudBaseError('请使用 --comment 填写版本注释');
|
|
281
312
|
}
|
|
282
313
|
if (!tag) {
|
|
283
|
-
|
|
284
|
-
return;
|
|
314
|
+
throw new error_1.CloudBaseError('请使用 --tag 填写符合semver的版本号');
|
|
285
315
|
}
|
|
286
316
|
if (!semver.valid(tag)) {
|
|
287
317
|
log.error('组件库版本不符合semver标准');
|
|
@@ -289,9 +319,9 @@ let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common
|
|
|
289
319
|
}
|
|
290
320
|
const config = ctx.config.lowcodeCustomComponents;
|
|
291
321
|
if (!config) {
|
|
292
|
-
|
|
322
|
+
throw new error_1.CloudBaseError('组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令');
|
|
293
323
|
}
|
|
294
|
-
const res = yield lowcodeCli.publishVersion(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: options.admin }), comment, tag);
|
|
324
|
+
const res = yield lowcodeCli.publishVersion(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: options.admin, privateSettings: lodash_1.default.get(ctx, 'config.privateSettings') }), comment, tag);
|
|
295
325
|
if (res.data.code === 200) {
|
|
296
326
|
log.success('组件库 - 已发布新版本!');
|
|
297
327
|
return;
|
|
@@ -326,6 +356,8 @@ __decorate([
|
|
|
326
356
|
__metadata("design:returntype", Promise)
|
|
327
357
|
], LowCodePublishVersionComps.prototype, "execute", null);
|
|
328
358
|
LowCodePublishVersionComps = __decorate([
|
|
329
|
-
(0, common_1.ICommand)(
|
|
359
|
+
(0, common_1.ICommand)({
|
|
360
|
+
supportPrivate: true
|
|
361
|
+
})
|
|
330
362
|
], LowCodePublishVersionComps);
|
|
331
363
|
exports.LowCodePublishVersionComps = LowCodePublishVersionComps;
|
|
@@ -11,4 +11,5 @@ var ParamTypes;
|
|
|
11
11
|
ParamTypes["Config"] = "__Config__";
|
|
12
12
|
ParamTypes["ArgsOptions"] = "__ArgsOptions__";
|
|
13
13
|
ParamTypes["ArgsParams"] = "__ArgsParams__";
|
|
14
|
+
ParamTypes["IsPrivateEnv"] = "__ISPrivateEnv__";
|
|
14
15
|
})(ParamTypes = exports.ParamTypes || (exports.ParamTypes = {}));
|
|
@@ -38,6 +38,9 @@ function InjectParams() {
|
|
|
38
38
|
case constants_1.ParamTypes.EnvId:
|
|
39
39
|
args[index] = ctx.envId;
|
|
40
40
|
break;
|
|
41
|
+
case constants_1.ParamTypes.IsPrivateEnv:
|
|
42
|
+
args[index] = ctx.hasPrivateSettings;
|
|
43
|
+
break;
|
|
41
44
|
default: {
|
|
42
45
|
const injectValue = yield getter(target);
|
|
43
46
|
args[index] = injectValue;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.Config = exports.EnvId = exports.ArgsParams = exports.ArgsOptions = exports.CmdContext = exports.Log = exports.Credential = void 0;
|
|
12
|
+
exports.IsPrivateEnv = exports.Config = exports.EnvId = exports.ArgsParams = exports.ArgsOptions = exports.CmdContext = exports.Log = exports.Credential = void 0;
|
|
13
13
|
const common_1 = require("./common");
|
|
14
14
|
const constants_1 = require("../constants");
|
|
15
15
|
const utils_1 = require("../../utils");
|
|
@@ -31,3 +31,4 @@ exports.ArgsOptions = (0, common_1.createParamDecorator)(constants_1.ParamTypes.
|
|
|
31
31
|
exports.ArgsParams = (0, common_1.createParamDecorator)(constants_1.ParamTypes.ArgsParams, EmptyValue);
|
|
32
32
|
exports.EnvId = (0, common_1.createParamDecorator)(constants_1.ParamTypes.EnvId, EmptyValue);
|
|
33
33
|
exports.Config = (0, common_1.createParamDecorator)(constants_1.ParamTypes.Config, EmptyValue);
|
|
34
|
+
exports.IsPrivateEnv = (0, common_1.createParamDecorator)(constants_1.ParamTypes.IsPrivateEnv, EmptyValue);
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.smartDeploy = void 0;
|
|
3
|
+
exports.registerCommands = exports.smartDeploy = void 0;
|
|
4
4
|
require("reflect-metadata");
|
|
5
|
-
const common_1 = require("./commands/common");
|
|
6
5
|
require("./commands");
|
|
7
6
|
var commands_1 = require("./commands");
|
|
8
7
|
Object.defineProperty(exports, "smartDeploy", { enumerable: true, get: function () { return commands_1.smartDeploy; } });
|
|
9
|
-
(0, common_1.registerCommands)();
|
|
10
8
|
if (typeof globalThis === undefined) {
|
|
11
9
|
;
|
|
12
10
|
globalThis = global;
|
|
13
11
|
}
|
|
12
|
+
var common_1 = require("./commands/common");
|
|
13
|
+
Object.defineProperty(exports, "registerCommands", { enumerable: true, get: function () { return common_1.registerCommands; } });
|
package/lib/utils/auth.js
CHANGED
|
@@ -21,7 +21,8 @@ exports.authSupevisor = toolbox_1.AuthSupevisor.getInstance({
|
|
|
21
21
|
});
|
|
22
22
|
function getLoginState() {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
|
|
24
|
+
const state = exports.authSupevisor.getLoginState();
|
|
25
|
+
return state;
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
28
|
exports.getLoginState = getLoginState;
|
package/lib/utils/config.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getCloudBaseConfig = exports.getArgs = void 0;
|
|
15
|
+
exports.getCloudBaseConfig = exports.checkPrivateSettingsExisted = exports.getArgs = void 0;
|
|
16
16
|
const lodash_1 = __importDefault(require("lodash"));
|
|
17
17
|
const path_1 = __importDefault(require("path"));
|
|
18
18
|
const yargs_1 = __importDefault(require("yargs"));
|
|
@@ -21,6 +21,13 @@ const getArgs = () => {
|
|
|
21
21
|
return yargs_1.default.alias('e', 'envId').alias('r', 'region').argv;
|
|
22
22
|
};
|
|
23
23
|
exports.getArgs = getArgs;
|
|
24
|
+
const hasOwn = (obj, name) => {
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(obj, name);
|
|
26
|
+
};
|
|
27
|
+
function checkPrivateSettingsExisted(config) {
|
|
28
|
+
return hasOwn(config, 'privateSettings');
|
|
29
|
+
}
|
|
30
|
+
exports.checkPrivateSettingsExisted = checkPrivateSettingsExisted;
|
|
24
31
|
const getCloudBaseConfig = (configPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
32
|
var _a;
|
|
26
33
|
const args = (0, exports.getArgs)();
|
package/lib/utils/log.js
CHANGED
|
@@ -53,6 +53,9 @@ class Logger {
|
|
|
53
53
|
console.log(`${chalk_1.default.bold('[debug]')} ${chalk_1.default.gray(`[${new Date().toISOString()}]`)} ${msg}`);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
+
debug(...args) {
|
|
57
|
+
return this.verbose(...args);
|
|
58
|
+
}
|
|
56
59
|
genClickableLink(link) {
|
|
57
60
|
if (terminal_link_1.default.isSupported) {
|
|
58
61
|
const clickablelink = (0, terminal_link_1.default)(link, link);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha.0",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@cloudbase/cloud-api": "^0.5.5",
|
|
34
34
|
"@cloudbase/framework-core": "^1.9.6",
|
|
35
|
-
"@cloudbase/lowcode-cli": "
|
|
35
|
+
"@cloudbase/lowcode-cli": "0.17.0-alpha.0",
|
|
36
36
|
"@cloudbase/manager-node": "4.0.1",
|
|
37
37
|
"@cloudbase/toolbox": "^0.7.3",
|
|
38
38
|
"@sentry/node": "^5.10.2",
|
|
@@ -19,8 +19,11 @@ export interface ICommandOptions {
|
|
|
19
19
|
requiredEnvId?: boolean;
|
|
20
20
|
withoutAuth?: boolean;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
interface ICommandDecoratorOptions {
|
|
23
|
+
supportPrivate: boolean | 'only';
|
|
24
|
+
}
|
|
25
|
+
export declare function ICommand(options?: ICommandDecoratorOptions): ClassDecorator;
|
|
26
|
+
export declare function registerCommands(): Promise<void>;
|
|
24
27
|
export declare abstract class Command extends EventEmitter {
|
|
25
28
|
on(event: 'preHandle' | 'afterHandle', listener: (ctx: ICommandContext, args: any[]) => void): this;
|
|
26
29
|
init(): void;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { Command } from '../common';
|
|
2
|
+
import { Logger } from '../../decorators';
|
|
3
|
+
import { ICommandContext } from '../../types';
|
|
2
4
|
export declare class LowCodeWatch extends Command {
|
|
3
5
|
get options(): {
|
|
4
6
|
cmd: string;
|
|
@@ -12,3 +14,26 @@ export declare class LowCodeWatch extends Command {
|
|
|
12
14
|
};
|
|
13
15
|
execute(ctx: any, options: any): Promise<void>;
|
|
14
16
|
}
|
|
17
|
+
export declare class LowCodeBuildApp extends Command {
|
|
18
|
+
get options(): {
|
|
19
|
+
cmd: string;
|
|
20
|
+
childCmd: string;
|
|
21
|
+
options: any[];
|
|
22
|
+
desc: string;
|
|
23
|
+
requiredEnvId: boolean;
|
|
24
|
+
};
|
|
25
|
+
execute(ctx: ICommandContext, log: Logger, options: any): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
export declare class LowCodeDeployApp extends Command {
|
|
28
|
+
get options(): {
|
|
29
|
+
cmd: string;
|
|
30
|
+
childCmd: string;
|
|
31
|
+
options: {
|
|
32
|
+
flags: string;
|
|
33
|
+
desc: string;
|
|
34
|
+
}[];
|
|
35
|
+
desc: string;
|
|
36
|
+
requiredEnvId: boolean;
|
|
37
|
+
};
|
|
38
|
+
execute(ctx: ICommandContext, log: Logger, options: any): Promise<void>;
|
|
39
|
+
}
|