@cloudbase/cli 2.2.0-alpha.7 → 2.2.0-alpha.9
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 +16 -9
- package/lib/commands/common.js +6 -8
- package/lib/commands/lowcode/app.js +24 -17
- package/lib/commands/lowcode/comps.js +23 -20
- package/lib/commands/lowcode/utils.js +18 -7
- package/lib/utils/config.js +11 -5
- package/package.json +2 -2
- package/types/commands/lowcode/app.d.ts +4 -1
- package/types/commands/lowcode/utils.d.ts +5 -0
- package/types/utils/config.d.ts +7 -6
package/bin/tcb.js
CHANGED
|
@@ -14,7 +14,7 @@ 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,
|
|
17
|
+
const { getCloudBaseConfig, getPrivateSettings } = require('../lib/utils/config')
|
|
18
18
|
const {registerCommands} = require('../lib')
|
|
19
19
|
|
|
20
20
|
async function main() {
|
|
@@ -53,14 +53,14 @@ console.log(chalk.gray(`CloudBase Framework ${frameworkPkg.version}`))
|
|
|
53
53
|
|
|
54
54
|
const yargsParsedResult = yargsParser(process.argv.slice(2));
|
|
55
55
|
const config = await getCloudBaseConfig(yargsParsedResult.configFile);
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const privateSettings = getPrivateSettings(config, yargsParsedResult._?.[0])
|
|
57
|
+
|
|
58
|
+
if (privateSettings) {
|
|
58
59
|
console.log(chalk.gray(`检测到私有化配置`))
|
|
59
60
|
// 初始化 lowcode 服务cliapi入口
|
|
60
|
-
process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL =
|
|
61
|
+
process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL = privateSettings.endpoints.cliApi;
|
|
61
62
|
|
|
62
63
|
}
|
|
63
|
-
|
|
64
64
|
// 注册命令
|
|
65
65
|
await registerCommands()
|
|
66
66
|
|
|
@@ -84,7 +84,7 @@ program.option('--mode <mode>', '指定加载 env 文件的环境')
|
|
|
84
84
|
program.option('--config-file <path>', '设置配置文件,默认为 cloudbaserc.json')
|
|
85
85
|
program.option('-r, --region <region>', '指定环境地域')
|
|
86
86
|
|
|
87
|
-
if(!
|
|
87
|
+
if(!privateSettings) {
|
|
88
88
|
// HACK: 隐藏自动生成的 help 信息
|
|
89
89
|
program.helpOption(false)
|
|
90
90
|
}
|
|
@@ -118,7 +118,7 @@ program.action(() => {
|
|
|
118
118
|
|
|
119
119
|
// 没有使用命令
|
|
120
120
|
if (isCommandEmpty) {
|
|
121
|
-
if(
|
|
121
|
+
if(privateSettings) {
|
|
122
122
|
program.outputHelp()
|
|
123
123
|
} else {
|
|
124
124
|
if (['-h', '--help'].includes(processArgv[2])) {
|
|
@@ -207,5 +207,12 @@ notifier.notify({
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
if(require.main === module) {
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
try {
|
|
211
|
+
main()
|
|
212
|
+
} catch (error) {
|
|
213
|
+
console.log(error)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
process.on('unhandledRejection', (err) => {
|
|
217
|
+
console.log('unhandledRejection', err)
|
|
218
|
+
})
|
package/lib/commands/common.js
CHANGED
|
@@ -55,10 +55,11 @@ function ICommand(options = defaultCmdDecoratorOpts) {
|
|
|
55
55
|
}
|
|
56
56
|
exports.ICommand = ICommand;
|
|
57
57
|
function registerCommands() {
|
|
58
|
+
var _a;
|
|
58
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
59
60
|
const args = (0, yargs_parser_1.default)(process.argv.slice(2));
|
|
60
61
|
const config = yield (0, utils_1.getCloudBaseConfig)(args.configFile);
|
|
61
|
-
const isPrivate = (0, utils_1.
|
|
62
|
+
const isPrivate = (0, utils_1.getPrivateSettings)(config, ((_a = args === null || args === void 0 ? void 0 : args._) === null || _a === void 0 ? void 0 : _a[0]) || undefined);
|
|
62
63
|
registrableCommands.forEach(({ Command, decoratorOptions }) => {
|
|
63
64
|
if (isPrivate) {
|
|
64
65
|
if (decoratorOptions.supportPrivate) {
|
|
@@ -151,13 +152,10 @@ class Command extends events_1.EventEmitter {
|
|
|
151
152
|
const parentOptions = commander_1.program.opts();
|
|
152
153
|
const config = yield (0, utils_1.getCloudBaseConfig)(parentOptions === null || parentOptions === void 0 ? void 0 : parentOptions.configFile);
|
|
153
154
|
const envId = (cmdOptions === null || cmdOptions === void 0 ? void 0 : cmdOptions.envId) || (config === null || config === void 0 ? void 0 : config.envId);
|
|
154
|
-
const
|
|
155
|
+
const privateSettings = (0, utils_1.getPrivateSettings)(config, cmd);
|
|
155
156
|
let loginState;
|
|
156
|
-
if (
|
|
157
|
-
loginState =
|
|
158
|
-
secretId: config.privateSettings.secretID,
|
|
159
|
-
secretKey: config.privateSettings.secretKey
|
|
160
|
-
};
|
|
157
|
+
if (privateSettings) {
|
|
158
|
+
loginState = privateSettings.credential;
|
|
161
159
|
}
|
|
162
160
|
else {
|
|
163
161
|
loginState = (yield utils_1.authSupevisor.getLoginState());
|
|
@@ -174,7 +172,7 @@ class Command extends events_1.EventEmitter {
|
|
|
174
172
|
config,
|
|
175
173
|
params,
|
|
176
174
|
options: cmdOptions,
|
|
177
|
-
hasPrivateSettings
|
|
175
|
+
hasPrivateSettings: Boolean(privateSettings)
|
|
178
176
|
};
|
|
179
177
|
this.emit('preHandle', ctx, args.slice(0, -1));
|
|
180
178
|
yield this.preHandle();
|
|
@@ -54,12 +54,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
54
54
|
}
|
|
55
55
|
return t;
|
|
56
56
|
};
|
|
57
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
-
};
|
|
60
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
58
|
exports.LowCodeDeployApp = exports.LowCodeBuildApp = exports.LowCodeWatch = void 0;
|
|
62
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
63
59
|
const common_1 = require("../common");
|
|
64
60
|
const decorators_1 = require("../../decorators");
|
|
65
61
|
const utils_1 = require("./utils");
|
|
@@ -89,10 +85,12 @@ let LowCodeWatch = class LowCodeWatch extends common_1.Command {
|
|
|
89
85
|
}
|
|
90
86
|
execute(ctx, options) {
|
|
91
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
|
|
89
|
+
const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
|
|
92
90
|
Promise.resolve().then(() => __importStar(require('@cloudbase/lowcode-cli'))).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
93
91
|
yield res.watchApp({
|
|
94
92
|
watchPort: 8288,
|
|
95
|
-
wxDevtoolPath:
|
|
93
|
+
wxDevtoolPath: mergesOptions === null || mergesOptions === void 0 ? void 0 : mergesOptions.wxDevtoolPath
|
|
96
94
|
});
|
|
97
95
|
}));
|
|
98
96
|
});
|
|
@@ -117,19 +115,30 @@ let LowCodeBuildApp = class LowCodeBuildApp extends common_1.Command {
|
|
|
117
115
|
return {
|
|
118
116
|
cmd: 'lowcode',
|
|
119
117
|
childCmd: 'build:app',
|
|
120
|
-
options: [
|
|
118
|
+
options: [
|
|
119
|
+
{
|
|
120
|
+
flags: '--clean',
|
|
121
|
+
desc: '清理构建目录'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
flags: '--out <out>',
|
|
125
|
+
desc: '输出目录'
|
|
126
|
+
}
|
|
127
|
+
],
|
|
121
128
|
desc: '构建应用',
|
|
122
129
|
requiredEnvId: false
|
|
123
130
|
};
|
|
124
131
|
}
|
|
125
132
|
execute(ctx, log, options) {
|
|
126
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
|
|
135
|
+
const mergesOptions = (0, utils_1.getMergedOptions)(config, options);
|
|
127
136
|
yield lowcodeCli.buildApp({
|
|
128
|
-
envId: ctx.envId,
|
|
137
|
+
envId: ctx.envId || ctx.config.envId,
|
|
129
138
|
projectPath: process.cwd(),
|
|
130
139
|
logger: log,
|
|
131
|
-
privateSettings:
|
|
132
|
-
},
|
|
140
|
+
privateSettings: (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd)
|
|
141
|
+
}, mergesOptions);
|
|
133
142
|
});
|
|
134
143
|
}
|
|
135
144
|
};
|
|
@@ -163,15 +172,13 @@ let LowCodeDeployApp = class LowCodeDeployApp extends common_1.Command {
|
|
|
163
172
|
}
|
|
164
173
|
execute(ctx, log, options) {
|
|
165
174
|
return __awaiter(this, void 0, void 0, function* () {
|
|
166
|
-
const { src } = options, restOptions = __rest(options, ["src"]);
|
|
167
175
|
let credential;
|
|
168
|
-
const privateSettings =
|
|
176
|
+
const privateSettings = (0, utils_2.getPrivateSettings)(ctx.config, this.options.cmd);
|
|
177
|
+
const config = (0, utils_1.getCmdConfig)(ctx.config, this.options);
|
|
178
|
+
const _a = (0, utils_1.getMergedOptions)(config, options), { src } = _a, restMergedOptions = __rest(_a, ["src"]);
|
|
169
179
|
if (ctx.hasPrivateSettings) {
|
|
170
180
|
process.env.IS_PRIVATE = 'true';
|
|
171
|
-
credential =
|
|
172
|
-
secretId: privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.secretID,
|
|
173
|
-
secretKey: privateSettings === null || privateSettings === void 0 ? void 0 : privateSettings.secretKey
|
|
174
|
-
};
|
|
181
|
+
credential = privateSettings.credential;
|
|
175
182
|
}
|
|
176
183
|
else {
|
|
177
184
|
credential = yield utils_2.authSupevisor.getLoginState();
|
|
@@ -180,8 +187,8 @@ let LowCodeDeployApp = class LowCodeDeployApp extends common_1.Command {
|
|
|
180
187
|
envId: ctx.envId || ctx.config.envId,
|
|
181
188
|
projectPath: process.cwd(),
|
|
182
189
|
logger: log,
|
|
183
|
-
privateSettings
|
|
184
|
-
}, Object.assign(Object.assign({ credential },
|
|
190
|
+
privateSettings
|
|
191
|
+
}, Object.assign(Object.assign({ credential }, restMergedOptions), { projectPath: src }));
|
|
185
192
|
});
|
|
186
193
|
}
|
|
187
194
|
};
|
|
@@ -43,12 +43,8 @@ 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
|
-
};
|
|
49
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
47
|
exports.LowCodePublishVersionComps = exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
|
|
51
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
52
48
|
const common_1 = require("../common");
|
|
53
49
|
const decorators_1 = require("../../decorators");
|
|
54
50
|
const enquirer_1 = require("enquirer");
|
|
@@ -59,7 +55,7 @@ const error_1 = require("../../error");
|
|
|
59
55
|
const utils_2 = require("./utils");
|
|
60
56
|
let lowcodeCli;
|
|
61
57
|
if (process.argv.includes('lowcode')) {
|
|
62
|
-
(0, utils_2.getLowcodeCli)().then(_ => lowcodeCli = _);
|
|
58
|
+
(0, utils_2.getLowcodeCli)().then((_) => (lowcodeCli = _));
|
|
63
59
|
}
|
|
64
60
|
let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
|
|
65
61
|
get options() {
|
|
@@ -82,32 +78,34 @@ let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
|
|
|
82
78
|
}
|
|
83
79
|
execute(opts, params, isPrivateEnv, config, log) {
|
|
84
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
|
|
81
|
+
const mergesOptions = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(config, this.options), opts);
|
|
82
|
+
if (mergesOptions.skipValidate) {
|
|
86
83
|
if (!(params === null || params === void 0 ? void 0 : params[0])) {
|
|
87
84
|
throw new error_1.CloudBaseError('skip validate 需要指定组件库名 eg: `tcb lowcode create mydemo`');
|
|
88
85
|
}
|
|
89
86
|
yield lowcodeCli.bootstrap(params === null || params === void 0 ? void 0 : params[0], log);
|
|
90
87
|
return;
|
|
91
88
|
}
|
|
89
|
+
const privateSettings = (0, utils_1.getPrivateSettings)(config, this.options.cmd);
|
|
92
90
|
if (process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL === undefined) {
|
|
93
|
-
process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL =
|
|
91
|
+
process.env.CLOUDBASE_LOWCODE_CLOUDAPI_URL =
|
|
92
|
+
'https://lcap.cloud.tencent.com/api/v1/cliapi';
|
|
94
93
|
}
|
|
95
94
|
let cloudService;
|
|
96
95
|
if (isPrivateEnv) {
|
|
97
96
|
cloudService = cloud_api_1.CloudApiService.getInstance({
|
|
98
97
|
service: 'lowcode',
|
|
99
|
-
credential:
|
|
100
|
-
secretId: config.privateSettings.secretID,
|
|
101
|
-
secretKey: config.privateSettings.secretKey
|
|
102
|
-
}
|
|
98
|
+
credential: privateSettings.credential
|
|
103
99
|
});
|
|
104
100
|
}
|
|
105
101
|
else {
|
|
106
102
|
cloudService = utils_1.CloudApiService.getInstance('lowcode');
|
|
107
103
|
}
|
|
108
|
-
const res = yield cloudService.request('ListUserCompositeGroups', isPrivateEnv
|
|
109
|
-
|
|
110
|
-
|
|
104
|
+
const res = yield cloudService.request('ListUserCompositeGroups', isPrivateEnv
|
|
105
|
+
? {
|
|
106
|
+
privateUin: privateSettings.privateUin
|
|
107
|
+
}
|
|
108
|
+
: undefined);
|
|
111
109
|
const comps = res === null || res === void 0 ? void 0 : res.data;
|
|
112
110
|
if (!(comps === null || comps === void 0 ? void 0 : comps.count)) {
|
|
113
111
|
throw new error_1.CloudBaseError('没有可关联的云端组件库,请到低码控制台新建组件库!');
|
|
@@ -168,7 +166,7 @@ class LowCodeBuildComps extends common_1.Command {
|
|
|
168
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
167
|
const config = ctx.config.lowcodeCustomComponents;
|
|
170
168
|
if (config) {
|
|
171
|
-
yield lowcodeCli.graceBuildComps(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, privateSettings:
|
|
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) }));
|
|
172
170
|
return;
|
|
173
171
|
}
|
|
174
172
|
throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
|
|
@@ -208,10 +206,14 @@ let LowCodeDebugComps = class LowCodeDebugComps extends common_1.Command {
|
|
|
208
206
|
};
|
|
209
207
|
}
|
|
210
208
|
execute(ctx, options, log) {
|
|
209
|
+
var _a;
|
|
211
210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
212
211
|
const config = ctx.config.lowcodeCustomComponents;
|
|
212
|
+
const privateSettings = (0, utils_1.getPrivateSettings)(ctx.config, this.options.cmd);
|
|
213
213
|
if (config) {
|
|
214
|
-
|
|
214
|
+
const cmdConfig = (0, utils_2.getCmdConfig)(ctx.config, this.options);
|
|
215
|
+
const mergesOptions = (0, utils_2.getMergedOptions)(cmdConfig, options);
|
|
216
|
+
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 }));
|
|
215
217
|
return;
|
|
216
218
|
}
|
|
217
219
|
throw new error_1.CloudBaseError('请参考文档填写 cloudbaserc 配置: https://docs.cloudbase.net/lowcode/custom-components/config/config-comps');
|
|
@@ -255,7 +257,8 @@ let LowCodePublishComps = class LowCodePublishComps extends common_1.Command {
|
|
|
255
257
|
return __awaiter(this, void 0, void 0, function* () {
|
|
256
258
|
const config = ctx.config.lowcodeCustomComponents;
|
|
257
259
|
if (config) {
|
|
258
|
-
|
|
260
|
+
const mergesOptions = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(ctx.config, this.options), options);
|
|
261
|
+
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) }));
|
|
259
262
|
log.success('组件库 - 已同步到云端,请到低码控制台发布该组件库!');
|
|
260
263
|
return;
|
|
261
264
|
}
|
|
@@ -288,7 +291,7 @@ let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common
|
|
|
288
291
|
},
|
|
289
292
|
{
|
|
290
293
|
flags: '--comment <comment>',
|
|
291
|
-
desc: '版本备注'
|
|
294
|
+
desc: '版本备注'
|
|
292
295
|
},
|
|
293
296
|
{
|
|
294
297
|
flags: '--tag <version>',
|
|
@@ -306,7 +309,7 @@ let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common
|
|
|
306
309
|
}
|
|
307
310
|
execute(ctx, options, log) {
|
|
308
311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
309
|
-
const { tag, comment, admin } = options;
|
|
312
|
+
const { tag, comment, admin } = (0, utils_2.getMergedOptions)((0, utils_2.getCmdConfig)(ctx.config, this.options), options) || {};
|
|
310
313
|
if (!comment) {
|
|
311
314
|
throw new error_1.CloudBaseError('请使用 --comment 填写版本注释');
|
|
312
315
|
}
|
|
@@ -321,7 +324,7 @@ let LowCodePublishVersionComps = class LowCodePublishVersionComps extends common
|
|
|
321
324
|
if (!config) {
|
|
322
325
|
throw new error_1.CloudBaseError('组件库 - 请添加组件库配置到cloudbaserc.json 以使用该命令');
|
|
323
326
|
}
|
|
324
|
-
const res = yield lowcodeCli.publishVersion(Object.assign(Object.assign({}, config), { context: config.context || process.cwd(), logger: log, isAdmin: options.admin, privateSettings:
|
|
327
|
+
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);
|
|
325
328
|
if (res.data.code === 200) {
|
|
326
329
|
log.success('组件库 - 已发布新版本!');
|
|
327
330
|
return;
|
|
@@ -32,21 +32,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.getLowcodeCli = exports.promisifyProcess = void 0;
|
|
35
|
+
exports.getMergedOptions = exports.getCmdConfig = exports.getLowcodeCli = exports.promisifyProcess = void 0;
|
|
36
|
+
const lodash_1 = require("lodash");
|
|
36
37
|
const toolbox_1 = require("@cloudbase/toolbox");
|
|
37
38
|
function promisifyProcess(p, pipe = false) {
|
|
38
39
|
return new Promise((resolve, reject) => {
|
|
39
40
|
let stdout = '';
|
|
40
41
|
let stderr = '';
|
|
41
|
-
p.stdout.on('data', (data => {
|
|
42
|
+
p.stdout.on('data', (data) => {
|
|
42
43
|
stdout += String(data);
|
|
43
|
-
})
|
|
44
|
-
p.stderr.on('data', (data => {
|
|
44
|
+
});
|
|
45
|
+
p.stderr.on('data', (data) => {
|
|
45
46
|
stderr += String(data);
|
|
46
|
-
})
|
|
47
|
+
});
|
|
47
48
|
p.on('error', reject);
|
|
48
|
-
p.on('exit', exitCode => {
|
|
49
|
-
exitCode === 0
|
|
49
|
+
p.on('exit', (exitCode) => {
|
|
50
|
+
exitCode === 0
|
|
51
|
+
? resolve(stdout)
|
|
52
|
+
: reject(new toolbox_1.CloudBaseError(stderr || String(exitCode)));
|
|
50
53
|
});
|
|
51
54
|
if (pipe) {
|
|
52
55
|
p.stdout.pipe(process.stdout);
|
|
@@ -69,3 +72,11 @@ function getLowcodeCli() {
|
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
exports.getLowcodeCli = getLowcodeCli;
|
|
75
|
+
function getCmdConfig(config, options) {
|
|
76
|
+
return (0, lodash_1.get)(config, `${options.cmd}["${options.childCmd}"]`);
|
|
77
|
+
}
|
|
78
|
+
exports.getCmdConfig = getCmdConfig;
|
|
79
|
+
function getMergedOptions(config = {}, argOptions = {}) {
|
|
80
|
+
return (0, lodash_1.merge)({}, config.inputs || {}, argOptions);
|
|
81
|
+
}
|
|
82
|
+
exports.getMergedOptions = getMergedOptions;
|
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.
|
|
15
|
+
exports.getCloudBaseConfig = exports.getPrivateSettings = 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"));
|
|
@@ -22,12 +22,18 @@ const getArgs = () => {
|
|
|
22
22
|
};
|
|
23
23
|
exports.getArgs = getArgs;
|
|
24
24
|
const hasOwn = (obj, name) => {
|
|
25
|
-
return Object.prototype.hasOwnProperty.call(obj, name);
|
|
25
|
+
return Object.prototype.hasOwnProperty.call(obj !== null && obj !== void 0 ? obj : {}, name);
|
|
26
26
|
};
|
|
27
|
-
function
|
|
28
|
-
|
|
27
|
+
function getPrivateSettings(config, cmd) {
|
|
28
|
+
const commonConfig = config;
|
|
29
|
+
const currentConfig = cmd ? config === null || config === void 0 ? void 0 : config[cmd] : config;
|
|
30
|
+
if (hasOwn(currentConfig || {}, 'privateSettings') ||
|
|
31
|
+
hasOwn(commonConfig || {}, 'privateSettings')) {
|
|
32
|
+
return Object.assign(Object.assign({}, commonConfig.privateSettings), currentConfig.privateSettings);
|
|
33
|
+
}
|
|
34
|
+
return undefined;
|
|
29
35
|
}
|
|
30
|
-
exports.
|
|
36
|
+
exports.getPrivateSettings = getPrivateSettings;
|
|
31
37
|
const getCloudBaseConfig = (configPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
32
38
|
var _a;
|
|
33
39
|
const args = (0, exports.getArgs)();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "2.2.0-alpha.
|
|
3
|
+
"version": "2.2.0-alpha.9",
|
|
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": "0.17.0-alpha.
|
|
35
|
+
"@cloudbase/lowcode-cli": "0.17.0-alpha.9",
|
|
36
36
|
"@cloudbase/manager-node": "4.0.1",
|
|
37
37
|
"@cloudbase/toolbox": "^0.7.3",
|
|
38
38
|
"@sentry/node": "^5.10.2",
|
|
@@ -2,3 +2,8 @@
|
|
|
2
2
|
import { ChildProcess } from 'child_process';
|
|
3
3
|
export declare function promisifyProcess(p: ChildProcess, pipe?: boolean): Promise<unknown>;
|
|
4
4
|
export declare function getLowcodeCli(): Promise<typeof import('@cloudbase/lowcode-cli')>;
|
|
5
|
+
export declare function getCmdConfig(config: any, options: {
|
|
6
|
+
cmd: string;
|
|
7
|
+
childCmd: string;
|
|
8
|
+
}): any;
|
|
9
|
+
export declare function getMergedOptions(config?: {}, argOptions?: {}): any;
|
package/types/utils/config.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Arguments } from 'yargs';
|
|
2
2
|
import { ICloudBaseConfig } from '@cloudbase/toolbox';
|
|
3
|
+
import { Credential } from '../types';
|
|
3
4
|
export interface IArgs {
|
|
4
5
|
envId: string;
|
|
5
6
|
region: string;
|
|
@@ -8,14 +9,14 @@ export interface IArgs {
|
|
|
8
9
|
[x: string]: unknown;
|
|
9
10
|
}
|
|
10
11
|
export declare const getArgs: () => Arguments<IArgs>;
|
|
11
|
-
declare
|
|
12
|
-
export declare function checkPrivateSettingsExisted(config: ICloudBaseRcSettings): config is IPrivateCloudBaseRcSettings;
|
|
12
|
+
export declare function getPrivateSettings(config: ICloudBaseRcSettings, cmd?: string): undefined | IPrivateSettings;
|
|
13
13
|
declare type IAbsUrl = `http://${string}` | `https://${string}`;
|
|
14
14
|
export interface IPrivateSettings {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
credential: Credential;
|
|
16
|
+
endpoints: {
|
|
17
|
+
editor: IAbsUrl;
|
|
18
|
+
cliApi: IAbsUrl;
|
|
19
|
+
};
|
|
19
20
|
privateUin: string;
|
|
20
21
|
}
|
|
21
22
|
export interface ICloudBaseRcSettings extends ICloudBaseConfig {
|