@cloudbase/cli 1.12.2-beta → 1.12.4-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 +1 -1
- package/lib/commands/lowcode/comps.js +1 -77
- package/package.json +3 -3
- package/src/commands/lowcode/comps.ts +4 -88
- package/tsconfig.json +1 -0
package/bin/tcb.js
CHANGED
|
@@ -146,7 +146,7 @@ function errorHandler(err) {
|
|
|
146
146
|
if (errMsg.includes('Environment') && errMsg.includes('not found')) {
|
|
147
147
|
console.log(
|
|
148
148
|
chalk.yellow.bold(
|
|
149
|
-
'\n
|
|
149
|
+
'\n此环境可能不属于当前账号,或为非上海地域环境,如需切换地域请追加参数(例:-r gz),请检查环境归属,参考多地域使用方法:https://docs.cloudbase.net/cli-v1/region.html'
|
|
150
150
|
)
|
|
151
151
|
)
|
|
152
152
|
}
|
|
@@ -44,19 +44,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
44
44
|
};
|
|
45
45
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
46
|
exports.LowCodePublishVersionComps = exports.LowCodePublishComps = exports.LowCodeDebugComps = exports.LowCodeBuildComps = exports.LowCodeCreateComps = void 0;
|
|
47
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
48
47
|
const path_1 = __importDefault(require("path"));
|
|
49
48
|
const common_1 = require("../common");
|
|
50
49
|
const decorators_1 = require("../../decorators");
|
|
51
50
|
const utils_1 = require("../../utils");
|
|
52
51
|
const error_1 = require("../../error");
|
|
53
|
-
const toolbox_1 = require("@cloudbase/toolbox");
|
|
54
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
55
52
|
const lowcode_cli_1 = require("@cloudbase/lowcode-cli");
|
|
56
|
-
const child_process_1 = require("child_process");
|
|
57
53
|
const enquirer_1 = require("enquirer");
|
|
58
54
|
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
59
|
-
const util_1 = require("util");
|
|
60
55
|
const semver = __importStar(require("semver"));
|
|
61
56
|
const cloudService = utils_1.CloudApiService.getInstance('lowcode');
|
|
62
57
|
const DEFAULE_TEMPLATE_PATH = 'https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/lcc/template.zip';
|
|
@@ -98,19 +93,7 @@ let LowCodeCreateComps = class LowCodeCreateComps extends common_1.Command {
|
|
|
98
93
|
throw new error_1.CloudBaseError(`云端不存在组件库 ${compsName},请到低码控制台新建该组件库!`);
|
|
99
94
|
}
|
|
100
95
|
}
|
|
101
|
-
|
|
102
|
-
if (fs_extra_1.default.pathExistsSync(compsPath)) {
|
|
103
|
-
throw new error_1.CloudBaseError(`当前目录下已存在组件库 ${compsName} !`);
|
|
104
|
-
}
|
|
105
|
-
yield _download(compsPath, compsName);
|
|
106
|
-
const installed = yield _install(compsPath);
|
|
107
|
-
log.success('组件库 - 创建成功\n');
|
|
108
|
-
log.info(`👉 执行命令 ${chalk_1.default.bold.cyan(`cd ${compsName}`)} 进入文件夹`);
|
|
109
|
-
if (!installed) {
|
|
110
|
-
log.info(`👉 执行命令 ${chalk_1.default.bold.cyan('npm install')} 手动安装依赖`);
|
|
111
|
-
}
|
|
112
|
-
log.info(`👉 执行命令 ${chalk_1.default.bold.cyan('tcb lowcode debug')} 调试组件库`);
|
|
113
|
-
log.info(`👉 执行命令 ${chalk_1.default.bold.cyan('tcb lowcode publish')} 发布组件库`);
|
|
96
|
+
yield (0, lowcode_cli_1.bootstrap)(compsName, log);
|
|
114
97
|
});
|
|
115
98
|
}
|
|
116
99
|
};
|
|
@@ -361,65 +344,6 @@ LowCodePublishVersionComps = __decorate([
|
|
|
361
344
|
(0, common_1.ICommand)()
|
|
362
345
|
], LowCodePublishVersionComps);
|
|
363
346
|
exports.LowCodePublishVersionComps = LowCodePublishVersionComps;
|
|
364
|
-
function _download(compsPath, compsName) {
|
|
365
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
-
yield (0, utils_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
|
|
367
|
-
yield (0, utils_1.fetchStream)(DEFAULE_TEMPLATE_PATH).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
368
|
-
if (!res) {
|
|
369
|
-
throw new error_1.CloudBaseError('请求异常');
|
|
370
|
-
}
|
|
371
|
-
if (res.status !== 200) {
|
|
372
|
-
throw new error_1.CloudBaseError('未找到组件库模板');
|
|
373
|
-
}
|
|
374
|
-
yield (0, toolbox_1.unzipStream)(res.body, compsPath);
|
|
375
|
-
_renamePackage(path_1.default.resolve(compsPath, 'cloudbaserc.json'), compsName);
|
|
376
|
-
}));
|
|
377
|
-
}), {
|
|
378
|
-
startTip: '组件库 - 下载模板中',
|
|
379
|
-
successTip: '组件库 - 下载模板成功'
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
function _renamePackage(configPath, name) {
|
|
384
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
385
|
-
if (!fs_extra_1.default.existsSync(configPath)) {
|
|
386
|
-
throw new error_1.CloudBaseError(`组件库缺少配置文件: ${configPath}`);
|
|
387
|
-
}
|
|
388
|
-
const rcJson = fs_extra_1.default.readJSONSync(configPath);
|
|
389
|
-
const newPackageJson = lodash_1.default.merge({}, rcJson, {
|
|
390
|
-
lowcodeCustomComponents: {
|
|
391
|
-
name
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
fs_extra_1.default.writeJSONSync(configPath, newPackageJson, { spaces: 2 });
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
function _install(compsPath) {
|
|
398
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
399
|
-
const res = yield (0, utils_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
|
|
400
|
-
const npmOptions = [
|
|
401
|
-
'--prefer-offline',
|
|
402
|
-
'--no-audit',
|
|
403
|
-
'--progress=false',
|
|
404
|
-
'--registry=https://mirrors.tencent.com/npm/',
|
|
405
|
-
'--legacy-peer-deps',
|
|
406
|
-
];
|
|
407
|
-
yield (0, util_1.promisify)(child_process_1.exec)(['npm install', ...npmOptions].join(' '), {
|
|
408
|
-
cwd: compsPath,
|
|
409
|
-
env: process.env,
|
|
410
|
-
});
|
|
411
|
-
}), {
|
|
412
|
-
startTip: '组件库 - 依赖安装中',
|
|
413
|
-
successTip: '组件库 - 依赖安装成功',
|
|
414
|
-
failTip: '组件库 - 依赖安装失败, 请手动安装依赖'
|
|
415
|
-
}).then(() => {
|
|
416
|
-
return true;
|
|
417
|
-
}).catch(() => {
|
|
418
|
-
return false;
|
|
419
|
-
});
|
|
420
|
-
return res;
|
|
421
|
-
});
|
|
422
|
-
}
|
|
423
347
|
function _build(compsPath) {
|
|
424
348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
425
349
|
yield (0, utils_1.execWithLoading)(() => __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cli",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.4-alpha.0",
|
|
4
4
|
"description": "cli tool for cloudbase",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@cloudbase/cloud-api": "^0.4.0",
|
|
33
33
|
"@cloudbase/framework-core": "^1.6.1",
|
|
34
|
-
"@cloudbase/lowcode-cli": "^0.12.
|
|
35
|
-
"@cloudbase/manager-node": "3.
|
|
34
|
+
"@cloudbase/lowcode-cli": "^0.12.11-alpha.1",
|
|
35
|
+
"@cloudbase/manager-node": "3.12.1",
|
|
36
36
|
"@cloudbase/toolbox": "^0.7.2",
|
|
37
37
|
"@sentry/node": "^5.10.2",
|
|
38
38
|
"address": "^1.1.2",
|
|
@@ -4,7 +4,6 @@ import { Command, ICommand } from '../common'
|
|
|
4
4
|
import { InjectParams, Log, Logger, ArgsParams, ArgsOptions, CmdContext } from '../../decorators'
|
|
5
5
|
import { CloudApiService, execWithLoading, fetchStream } from '../../utils'
|
|
6
6
|
import { CloudBaseError } from '../../error'
|
|
7
|
-
import { unzipStream } from '@cloudbase/toolbox'
|
|
8
7
|
import chalk from 'chalk'
|
|
9
8
|
import {
|
|
10
9
|
build as buildComps,
|
|
@@ -14,12 +13,11 @@ import {
|
|
|
14
13
|
graceDebugComps,
|
|
15
14
|
gracePublishComps,
|
|
16
15
|
IPublishCompsInfo,
|
|
17
|
-
publishVersion
|
|
16
|
+
publishVersion,
|
|
17
|
+
bootstrap,
|
|
18
18
|
} from '@cloudbase/lowcode-cli'
|
|
19
|
-
import { exec } from 'child_process'
|
|
20
19
|
import { prompt } from 'enquirer'
|
|
21
20
|
import fse from 'fs-extra'
|
|
22
|
-
import { promisify } from 'util'
|
|
23
21
|
import * as semver from 'semver'
|
|
24
22
|
|
|
25
23
|
const cloudService = CloudApiService.getInstance('lowcode')
|
|
@@ -67,24 +65,9 @@ export class LowCodeCreateComps extends Command {
|
|
|
67
65
|
}
|
|
68
66
|
}
|
|
69
67
|
|
|
70
|
-
//
|
|
71
|
-
|
|
72
|
-
if (fse.pathExistsSync(compsPath)) {
|
|
73
|
-
throw new CloudBaseError(`当前目录下已存在组件库 ${compsName} !`)
|
|
74
|
-
}
|
|
68
|
+
// TODO: 逻辑迁移到 lowcode-cli
|
|
69
|
+
await bootstrap(compsName, log);
|
|
75
70
|
|
|
76
|
-
// 下载模板
|
|
77
|
-
await _download(compsPath, compsName)
|
|
78
|
-
// 安装依赖
|
|
79
|
-
const installed = await _install(compsPath)
|
|
80
|
-
// 用户提示
|
|
81
|
-
log.success('组件库 - 创建成功\n')
|
|
82
|
-
log.info(`👉 执行命令 ${chalk.bold.cyan(`cd ${compsName}`)} 进入文件夹`)
|
|
83
|
-
if (!installed) {
|
|
84
|
-
log.info(`👉 执行命令 ${chalk.bold.cyan('npm install')} 手动安装依赖`)
|
|
85
|
-
}
|
|
86
|
-
log.info(`👉 执行命令 ${chalk.bold.cyan('tcb lowcode debug')} 调试组件库`)
|
|
87
|
-
log.info(`👉 执行命令 ${chalk.bold.cyan('tcb lowcode publish')} 发布组件库`)
|
|
88
71
|
}
|
|
89
72
|
}
|
|
90
73
|
|
|
@@ -313,73 +296,6 @@ export class LowCodePublishVersionComps extends Command {
|
|
|
313
296
|
}
|
|
314
297
|
}
|
|
315
298
|
|
|
316
|
-
async function _download(compsPath, compsName) {
|
|
317
|
-
await execWithLoading(
|
|
318
|
-
async () => {
|
|
319
|
-
await fetchStream(DEFAULE_TEMPLATE_PATH).then(async (res) => {
|
|
320
|
-
if (!res) {
|
|
321
|
-
throw new CloudBaseError('请求异常')
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
if (res.status !== 200) {
|
|
325
|
-
throw new CloudBaseError('未找到组件库模板')
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
// 解压缩文件
|
|
329
|
-
await unzipStream(res.body, compsPath)
|
|
330
|
-
|
|
331
|
-
// 修改cloudbaserc.json
|
|
332
|
-
_renamePackage(path.resolve(compsPath, 'cloudbaserc.json'), compsName)
|
|
333
|
-
})
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
startTip: '组件库 - 下载模板中',
|
|
337
|
-
successTip: '组件库 - 下载模板成功'
|
|
338
|
-
}
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
async function _renamePackage(configPath, name) {
|
|
343
|
-
if (!fse.existsSync(configPath)) {
|
|
344
|
-
throw new CloudBaseError(`组件库缺少配置文件: ${configPath}`)
|
|
345
|
-
}
|
|
346
|
-
const rcJson = fse.readJSONSync(configPath)
|
|
347
|
-
const newPackageJson = _.merge({}, rcJson, {
|
|
348
|
-
lowcodeCustomComponents: {
|
|
349
|
-
name
|
|
350
|
-
}
|
|
351
|
-
})
|
|
352
|
-
fse.writeJSONSync(configPath, newPackageJson, { spaces: 2 })
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
async function _install(compsPath): Promise<boolean> {
|
|
356
|
-
const res = await execWithLoading(
|
|
357
|
-
async () => {
|
|
358
|
-
const npmOptions = [
|
|
359
|
-
'--prefer-offline',
|
|
360
|
-
'--no-audit',
|
|
361
|
-
'--progress=false',
|
|
362
|
-
'--registry=https://mirrors.tencent.com/npm/',
|
|
363
|
-
'--legacy-peer-deps',
|
|
364
|
-
]
|
|
365
|
-
await promisify(exec)(['npm install', ...npmOptions].join(' '), {
|
|
366
|
-
cwd: compsPath,
|
|
367
|
-
env: process.env,
|
|
368
|
-
})
|
|
369
|
-
},
|
|
370
|
-
{
|
|
371
|
-
startTip: '组件库 - 依赖安装中',
|
|
372
|
-
successTip: '组件库 - 依赖安装成功',
|
|
373
|
-
failTip: '组件库 - 依赖安装失败, 请手动安装依赖'
|
|
374
|
-
}
|
|
375
|
-
).then(() => {
|
|
376
|
-
return true
|
|
377
|
-
}).catch(() => {
|
|
378
|
-
return false
|
|
379
|
-
})
|
|
380
|
-
|
|
381
|
-
return res
|
|
382
|
-
}
|
|
383
299
|
|
|
384
300
|
async function _build(compsPath) {
|
|
385
301
|
await execWithLoading(
|