@nocobase/cli 0.21.0-alpha.1 → 0.21.0-alpha.10

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/nocobase.conf.tpl CHANGED
@@ -23,19 +23,6 @@ server {
23
23
  gzip on;
24
24
  gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
25
25
 
26
- # 不缓存 HTML 文件
27
- # location ~ \.html$ {
28
- # if_modified_since off;
29
- # expires off;
30
- # etag off;
31
- # }
32
-
33
- # # 缓存 JavaScript 和 CSS 文件
34
- # location ~* \.(js|css)$ {
35
- # expires 365d;
36
- # add_header Cache-Control "public";
37
- # }
38
-
39
26
  location {{publicPath}}storage/uploads/ {
40
27
  alias {{cwd}}/storage/uploads/;
41
28
  add_header Cache-Control "public";
@@ -51,6 +38,10 @@ server {
51
38
  if_modified_since off;
52
39
  expires off;
53
40
  etag off;
41
+ location ~* \.(js|css)$ {
42
+ expires 365d;
43
+ add_header Cache-Control "public";
44
+ }
54
45
  }
55
46
 
56
47
  location ^~ {{publicPath}}api/ {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/cli",
3
- "version": "0.21.0-alpha.1",
3
+ "version": "0.21.0-alpha.10",
4
4
  "description": "",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./src/index.js",
@@ -8,7 +8,7 @@
8
8
  "nocobase": "./bin/index.js"
9
9
  },
10
10
  "dependencies": {
11
- "@nocobase/app": "0.21.0-alpha.1",
11
+ "@nocobase/app": "0.21.0-alpha.10",
12
12
  "@types/fs-extra": "^11.0.1",
13
13
  "@umijs/utils": "3.5.20",
14
14
  "chalk": "^4.1.1",
@@ -25,12 +25,12 @@
25
25
  "tsx": "^4.6.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@nocobase/devtools": "0.21.0-alpha.1"
28
+ "@nocobase/devtools": "0.21.0-alpha.10"
29
29
  },
30
30
  "repository": {
31
31
  "type": "git",
32
32
  "url": "git+https://github.com/nocobase/nocobase.git",
33
33
  "directory": "packages/core/cli"
34
34
  },
35
- "gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff"
35
+ "gitHead": "98adf5ec996a4f359c6ca1c4a6ac837c43b6e268"
36
36
  }
@@ -85,6 +85,7 @@ async function appReady() {
85
85
  async function runApp(options = {}) {
86
86
  console.log('installing...');
87
87
  await run('nocobase', ['install', '-f']);
88
+ await run('nocobase', ['pm', 'enable-all']);
88
89
  if (await isPortReachable(process.env.APP_PORT)) {
89
90
  console.log('app started');
90
91
  return;
@@ -232,6 +233,7 @@ module.exports = (cli) => {
232
233
 
233
234
  e2e.command('reinstall-app').action(async (options) => {
234
235
  await run('nocobase', ['install', '-f'], options);
236
+ await run('nocobase', ['pm2', 'enable-all']);
235
237
  });
236
238
 
237
239
  e2e.command('install-deps').action(async () => {
@@ -18,6 +18,7 @@ module.exports = (cli) => {
18
18
  require('./doc')(cli);
19
19
  require('./pm2')(cli);
20
20
  require('./test')(cli);
21
+ require('./test-coverage')(cli);
21
22
  require('./umi')(cli);
22
23
  require('./upgrade')(cli);
23
24
  require('./postinstall')(cli);
@@ -0,0 +1,44 @@
1
+ const { run } = require('../util');
2
+ const fg = require('fast-glob');
3
+
4
+ const coreClientPackages = ['packages/core/client', 'packages/core/sdk'];
5
+ const isCore = (dir) => dir.startsWith('packages/core');
6
+
7
+ const getPackagesDir = (isClient) => {
8
+ if (process.argv.length > 3 && !process.argv[3].startsWith('-')) {
9
+ return [process.argv[3]];
10
+ }
11
+
12
+ const allPackageJson = fg.sync(['packages/*/*/package.json', 'packages/*/*/*/package.json'], {
13
+ cwd: process.cwd(),
14
+ onlyFiles: true,
15
+ });
16
+ const res = allPackageJson.map((pkg) => pkg.replace('/package.json', ''));
17
+ return isClient
18
+ ? res.filter((dir) => (isCore(dir) ? coreClientPackages.includes(dir) : true))
19
+ : res.filter((dir) => (isCore(dir) ? !coreClientPackages.includes(dir) : true));
20
+ };
21
+
22
+ module.exports = (cli) => {
23
+ cli.command('test-coverage:server').action(async () => {
24
+ const packageRoots = getPackagesDir(false);
25
+ for (const dir of packageRoots) {
26
+ try {
27
+ await run('yarn', ['test:server', dir, '--coverage']);
28
+ } catch (e) {
29
+ continue;
30
+ }
31
+ }
32
+ });
33
+
34
+ cli.command('test-coverage:client').action(async () => {
35
+ const packageRoots = getPackagesDir(true);
36
+ for (const dir of packageRoots) {
37
+ try {
38
+ await run('yarn', ['test:client', dir, '--coverage']);
39
+ } catch (e) {
40
+ continue;
41
+ }
42
+ }
43
+ });
44
+ };
@@ -14,12 +14,12 @@ function addTestCommand(name, cli) {
14
14
  .option('--run')
15
15
  .option('--allowOnly')
16
16
  .option('--bail')
17
+ .option('--coverage')
17
18
  .option('-h, --help')
18
19
  .option('--single-thread [singleThread]')
19
20
  .arguments('[paths...]')
20
21
  .allowUnknownOption()
21
22
  .action(async (paths, opts) => {
22
- process.argv.push('--disable-console-intercept');
23
23
  if (name === 'test:server') {
24
24
  process.env.TEST_ENV = 'server-side';
25
25
  } else if (name === 'test:client') {
@@ -29,14 +29,18 @@ function addTestCommand(name, cli) {
29
29
  process.env.TEST_ENV = 'server-side';
30
30
  process.argv.splice(process.argv.indexOf('--server'), 1);
31
31
  }
32
+
32
33
  if (opts.client) {
33
34
  process.env.TEST_ENV = 'client-side';
34
35
  process.argv.splice(process.argv.indexOf('--client'), 1);
35
36
  }
37
+
36
38
  process.env.NODE_ENV = 'test';
39
+
37
40
  if (!opts.watch && !opts.run) {
38
41
  process.argv.push('--run');
39
42
  }
43
+
40
44
  const first = paths?.[0];
41
45
  if (!process.env.TEST_ENV && first) {
42
46
  const key = first.split(path.sep).join('/');
@@ -46,17 +50,22 @@ function addTestCommand(name, cli) {
46
50
  process.env.TEST_ENV = 'server-side';
47
51
  }
48
52
  }
53
+
49
54
  if (process.env.TEST_ENV === 'server-side' && opts.singleThread !== 'false') {
50
55
  process.argv.push('--poolOptions.threads.singleThread=true');
51
56
  }
57
+
52
58
  if (opts.singleThread === 'false') {
53
59
  process.argv.splice(process.argv.indexOf('--single-thread=false'), 1);
54
60
  }
61
+
55
62
  const cliArgs = ['--max_old_space_size=14096', './node_modules/.bin/vitest', ...process.argv.slice(3)];
63
+
56
64
  if (process.argv.includes('-h') || process.argv.includes('--help')) {
57
65
  await run('node', cliArgs);
58
66
  return;
59
67
  }
68
+
60
69
  if (process.env.TEST_ENV) {
61
70
  console.log('process.env.TEST_ENV', process.env.TEST_ENV, cliArgs);
62
71
  await run('node', cliArgs);