@nocobase/cli 0.9.4-alpha.1 → 0.10.0-alpha.2
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -8,21 +8,24 @@
|
|
|
8
8
|
"nocobase": "./bin/index.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@types/fs-extra": "^11.0.1",
|
|
11
12
|
"chalk": "^4.1.1",
|
|
12
13
|
"commander": "^9.2.0",
|
|
13
14
|
"dotenv": "^10.0.0",
|
|
14
15
|
"execa": "^5.1.1",
|
|
16
|
+
"fast-glob": "^3.2.12",
|
|
17
|
+
"fs-extra": "^11.1.1",
|
|
15
18
|
"pm2": "^5.2.0",
|
|
16
19
|
"portfinder": "^1.0.28",
|
|
17
20
|
"serve": "^13.0.2"
|
|
18
21
|
},
|
|
19
22
|
"devDependencies": {
|
|
20
|
-
"@nocobase/devtools": "0.
|
|
23
|
+
"@nocobase/devtools": "0.10.0-alpha.2"
|
|
21
24
|
},
|
|
22
25
|
"repository": {
|
|
23
26
|
"type": "git",
|
|
24
27
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
25
28
|
"directory": "packages/core/cli"
|
|
26
29
|
},
|
|
27
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "85028ae1733fcbd46ecd5d291dacbdc175f7f073"
|
|
28
31
|
}
|
package/src/commands/clean.js
CHANGED
|
@@ -14,6 +14,7 @@ module.exports = (cli) => {
|
|
|
14
14
|
if (!isDev()) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
run('rimraf', ['-rf', '
|
|
17
|
+
run('rimraf', ['-rf', './**/{.umi,.umi-production}']);
|
|
18
|
+
run('rimraf', ['-rf', 'packages/*/*/{lib,esm,es,dist,node_modules}']);
|
|
18
19
|
});
|
|
19
20
|
};
|
package/src/commands/doc.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const { Command } = require('commander');
|
|
2
2
|
const { resolve, isAbsolute } = require('path');
|
|
3
3
|
const { run, isDev } = require('../util');
|
|
4
|
+
const fs = require('fs-extra');
|
|
5
|
+
const glob = require('fast-glob');
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
*
|
|
@@ -9,30 +11,57 @@ const { run, isDev } = require('../util');
|
|
|
9
11
|
module.exports = (cli) => {
|
|
10
12
|
cli
|
|
11
13
|
.command('doc')
|
|
14
|
+
.argument('[dev|build|serve]')
|
|
15
|
+
.argument('[packages]')
|
|
12
16
|
.option('--lang [lang]')
|
|
13
17
|
.allowUnknownOption()
|
|
14
|
-
.action((options) => {
|
|
18
|
+
.action((command, pkg, options) => {
|
|
15
19
|
if (!isDev()) {
|
|
16
20
|
return;
|
|
17
21
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
|
|
23
|
+
// 指定项目目录
|
|
24
|
+
let cwd = process.cwd();
|
|
25
|
+
if (command === undefined && pkg === undefined) {
|
|
26
|
+
command = 'dev';
|
|
27
|
+
} else if (!['dev', 'build', 'serve'].includes(command) && pkg === undefined) {
|
|
28
|
+
pkg = command;
|
|
29
|
+
command = 'dev';
|
|
30
|
+
cwd = resolve(process.cwd(), 'packages', pkg);
|
|
24
31
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (index > 0) {
|
|
28
|
-
process.argv.splice(index, 1);
|
|
32
|
+
if (pkg !== undefined) {
|
|
33
|
+
process.env.APP_ROOT = `packages/${pkg}`;
|
|
29
34
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
|
|
36
|
+
// 删除 tmp 目录
|
|
37
|
+
const tmpDir = glob.sync(
|
|
38
|
+
['.dumi/tmp', '.dumi/tmp-production', 'packages/*/*/.dumi/tmp', 'packages/*/*.dumi/tmp-production'],
|
|
39
|
+
{
|
|
40
|
+
cwd: process.cwd(),
|
|
41
|
+
onlyDirectories: true,
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
tmpDir.forEach((dir) => {
|
|
45
|
+
fs.removeSync(dir);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// 设置语言
|
|
49
|
+
process.env.DOC_LANG = options.lang || 'en-US';
|
|
50
|
+
|
|
51
|
+
if (command === 'serve') {
|
|
52
|
+
// 如果是多语言,则需要进入内部,如果不是多语言,则直接进入 docs/dist
|
|
53
|
+
let dir = resolve(cwd, 'docs/dist', process.env.DOC_LANG);
|
|
54
|
+
if (!existsSync(dir)) {
|
|
55
|
+
dir = resolve(cwd, 'docs/dist');
|
|
56
|
+
}
|
|
57
|
+
run('serve', [dir]);
|
|
34
58
|
} else {
|
|
35
|
-
run('dumi', [
|
|
59
|
+
run('dumi', [command], {
|
|
60
|
+
env: {
|
|
61
|
+
APP_ROOT: process.env.APP_ROOT,
|
|
62
|
+
DOC_LANG: process.env.DOC_LANG,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
36
65
|
}
|
|
37
66
|
});
|
|
38
67
|
};
|