@nocobase/cli 1.6.25 → 1.6.26

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": "1.6.25",
3
+ "version": "1.6.26",
4
4
  "description": "",
5
5
  "license": "AGPL-3.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": "1.6.25",
11
+ "@nocobase/app": "1.6.26",
12
12
  "@types/fs-extra": "^11.0.1",
13
13
  "@umijs/utils": "3.5.20",
14
14
  "chalk": "^4.1.1",
@@ -26,12 +26,12 @@
26
26
  "tsx": "^4.19.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@nocobase/devtools": "1.6.25"
29
+ "@nocobase/devtools": "1.6.26"
30
30
  },
31
31
  "repository": {
32
32
  "type": "git",
33
33
  "url": "git+https://github.com/nocobase/nocobase.git",
34
34
  "directory": "packages/core/cli"
35
35
  },
36
- "gitHead": "569e5ab32f72a9876408ff2bc37fc8a2a307f237"
36
+ "gitHead": "dc7085b4f453983c6398a5b33011a8fb6dfc59ae"
37
37
  }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ const glob = require('fast-glob');
11
+ const { Command } = require('commander');
12
+ const { run } = require('../util');
13
+
14
+ /**
15
+ *
16
+ * @param {Command} cli
17
+ */
18
+ module.exports = (cli) => {
19
+ return (
20
+ cli
21
+ .command('benchmark')
22
+ .description('Run benchmark tests')
23
+ // .option('--single-thread [singleThread]')
24
+ .option('-a, --all [all]', 'Run all benchmark files which ends with .benchmark.{js,ts}')
25
+ .arguments('[paths...]')
26
+ .allowUnknownOption()
27
+ .action(async (paths, opts) => {
28
+ process.env.NODE_ENV = 'test';
29
+ process.env.LOGGER_LEVEL = 'error';
30
+
31
+ const cliArgs = ['--max_old_space_size=14096'];
32
+
33
+ // if (process.argv.includes('-h') || process.argv.includes('--help')) {
34
+ // await run('node', cliArgs);
35
+ // return;
36
+ // }
37
+
38
+ // if (!opts.singleThread) {
39
+ // process.argv.splice(process.argv.indexOf('--single-thread=false'), 1);
40
+ // } else {
41
+ // process.argv.push('--poolOptions.threads.singleThread=true');
42
+ // }
43
+
44
+ if (!paths.length) {
45
+ if (opts.all) {
46
+ paths.push('**/*.benchmark.ts');
47
+ } else {
48
+ console.warn(
49
+ 'No benchmark files specified. Please provide at least 1 benchmark file or path to run. Or use --all to run all "*.benchmark.ts".',
50
+ );
51
+ return;
52
+ }
53
+ }
54
+
55
+ const files = [];
56
+
57
+ for (const pattern of paths) {
58
+ for (const file of glob.sync(pattern)) {
59
+ files.push(file);
60
+ }
61
+ }
62
+
63
+ if (!files.length) {
64
+ console.log('No benchmark files found');
65
+ return;
66
+ }
67
+
68
+ for (const file of files) {
69
+ await run('tsx', [...cliArgs, file]);
70
+ }
71
+ })
72
+ );
73
+ };
@@ -29,6 +29,7 @@ module.exports = (cli) => {
29
29
  require('./pm2')(cli);
30
30
  require('./test')(cli);
31
31
  require('./test-coverage')(cli);
32
+ require('./benchmark')(cli);
32
33
  require('./umi')(cli);
33
34
  require('./update-deps')(cli);
34
35
  require('./upgrade')(cli);
package/src/util.js CHANGED
@@ -389,7 +389,7 @@ exports.initEnv = function initEnv() {
389
389
  if (
390
390
  !process.env.APP_ENV_PATH &&
391
391
  process.argv[2] &&
392
- ['test', 'test:client', 'test:server'].includes(process.argv[2])
392
+ ['test', 'test:client', 'test:server', 'benchmark'].includes(process.argv[2])
393
393
  ) {
394
394
  if (fs.existsSync(resolve(process.cwd(), '.env.test'))) {
395
395
  process.env.APP_ENV_PATH = '.env.test';