@nocobase/cli 0.9.4-alpha.2 → 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.9.4-alpha.2",
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.9.4-alpha.2"
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": "2bc19a85bf9425aa220b6c467315c8087f333a7e"
30
+ "gitHead": "85028ae1733fcbd46ecd5d291dacbdc175f7f073"
28
31
  }
@@ -14,6 +14,7 @@ module.exports = (cli) => {
14
14
  if (!isDev()) {
15
15
  return;
16
16
  }
17
- run('rimraf', ['-rf', 'packages/*/*/{lib,esm,es,dist}']);
17
+ run('rimraf', ['-rf', './**/{.umi,.umi-production}']);
18
+ run('rimraf', ['-rf', 'packages/*/*/{lib,esm,es,dist,node_modules}']);
18
19
  });
19
20
  };
@@ -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
- process.env.DOC_LANG = options.lang || 'en-US';
19
- const docThemePath = process.env.DOC_THEME_PATH;
20
- if (!docThemePath) {
21
- process.env.DUMI_THEME = resolve(process.cwd(), 'packages/core/dumi-theme-nocobase/src');
22
- } else {
23
- process.env.DUMI_THEME = isAbsolute(docThemePath) ? docThemePath : resolve(process.cwd(), docThemePath);
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
- // TODO(bug): space replace = not work
26
- const index = process.argv.indexOf(`--lang=${options.lang}`);
27
- if (index > 0) {
28
- process.argv.splice(index, 1);
32
+ if (pkg !== undefined) {
33
+ process.env.APP_ROOT = `packages/${pkg}`;
29
34
  }
30
- const argv = process.argv.slice(3);
31
- const argument = argv.shift() || 'dev';
32
- if (argument === 'serve') {
33
- run('serve', [`${resolve(process.cwd(), 'docs/dist', process.env.DOC_LANG)}`, ...argv]);
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', [argument, ...argv]);
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
  };
@@ -1,5 +1,8 @@
1
1
  import React from 'react';
2
2
 
3
- export default React.memo((props) => {
3
+ const CommonMemo = React.memo((props) => {
4
4
  return <>{props.children}</>;
5
5
  });
6
+ CommonMemo.displayName = 'CommonMemo';
7
+
8
+ export default CommonMemo;