@nocobase/cli 1.9.0-beta.7 → 1.9.0-beta.9

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.9.0-beta.7",
3
+ "version": "1.9.0-beta.9",
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.9.0-beta.7",
11
+ "@nocobase/app": "1.9.0-beta.9",
12
12
  "@nocobase/license-kit": "^0.2.17",
13
13
  "@types/fs-extra": "^11.0.1",
14
14
  "@umijs/utils": "3.5.20",
@@ -27,12 +27,12 @@
27
27
  "tsx": "^4.19.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@nocobase/devtools": "1.9.0-beta.7"
30
+ "@nocobase/devtools": "1.9.0-beta.9"
31
31
  },
32
32
  "repository": {
33
33
  "type": "git",
34
34
  "url": "git+https://github.com/nocobase/nocobase.git",
35
35
  "directory": "packages/core/cli"
36
36
  },
37
- "gitHead": "4a5055c973b51611d5db1604aaaf6c1b73b4733c"
37
+ "gitHead": "b44464f1d1bbc96022d0f622e0a2f1d7e8d7142f"
38
38
  }
@@ -24,6 +24,7 @@ module.exports = (cli) => {
24
24
  require('./dev')(cli);
25
25
  require('./start')(cli);
26
26
  require('./e2e')(cli);
27
+ require('./perf')(cli);
27
28
  require('./clean')(cli);
28
29
  require('./doc')(cli);
29
30
  require('./pm2')(cli);
@@ -0,0 +1,63 @@
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 path = require('path');
11
+ const fs = require('fs');
12
+ // const init = require('@nocobase/server/__perf__/init');
13
+ const { Command } = require('commander');
14
+ const dotenv = require('dotenv');
15
+ const { run } = require('../util');
16
+
17
+ /**
18
+ * Performance testing command
19
+ * @param {Command} cli
20
+ */
21
+ module.exports = (cli) => {
22
+ const perf = cli.command('perf');
23
+ perf
24
+ .command('init')
25
+ .arguments('<file>')
26
+ .description('Initialize performance testing app')
27
+ .action(async (file, options) => {
28
+ if (!file) {
29
+ throw new Error('Please provide the path to the init script');
30
+ }
31
+ const f = path.isAbsolute(file) ? file : path.join(process.cwd(), file);
32
+ if (!fs.statSync(file).isFile()) {
33
+ throw new Error(`Init script file not found: ${file}`);
34
+ }
35
+ // const envFile = fs.existsSync(path.resolve(process.cwd(), '.env.test')) ? '.env.test' : '.env';
36
+ // const cliArgs = ['--max_old_space_size=4096'];
37
+ await run(`tsx`, [f]);
38
+ });
39
+ perf
40
+ .command('run')
41
+ .arguments('<file>')
42
+ .description('Run performance testing script')
43
+ .option('-e, --env-file <env>', 'Environment file to load', '.env.perf')
44
+ .allowUnknownOption(true)
45
+ .action(async (file, options, command) => {
46
+ const f = path.isAbsolute(file) ? file : path.join(process.cwd(), file);
47
+ if (!fs.statSync(f).isFile()) {
48
+ throw new Error(`Performance testing script file not found: ${f}`);
49
+ }
50
+ if (options.envFile) {
51
+ const envFilePath = path.resolve(process.cwd(), options.envFile);
52
+ if (fs.statSync(envFilePath).isFile()) {
53
+ dotenv.config({ path: envFilePath, override: true });
54
+ }
55
+ }
56
+ if (!process.env.API_BASE_URL) {
57
+ throw new Error('Please set API_BASE_URL in environment variables or in .env.perf file');
58
+ }
59
+ const args = command.args.filter((arg) => arg !== file);
60
+ await run(`k6`, ['run', f, ...(args.length ? ['--', ...args] : [])]);
61
+ });
62
+ return perf;
63
+ };
@@ -93,6 +93,11 @@ class Package {
93
93
  if (await fs.exists(file)) {
94
94
  return true;
95
95
  }
96
+ file = path.resolve(process.cwd(), 'node_modules', this.packageName, 'package.json');
97
+ if (await fs.exists(file)) {
98
+ console.log(chalk.yellowBright(`Skipped: ${this.packageName} is in node_modules`));
99
+ return true;
100
+ }
96
101
  return false;
97
102
  }
98
103
 
package/src/util.js CHANGED
@@ -392,7 +392,7 @@ exports.initEnv = function initEnv() {
392
392
  if (
393
393
  !process.env.APP_ENV_PATH &&
394
394
  process.argv[2] &&
395
- ['test', 'test:client', 'test:server', 'benchmark'].includes(process.argv[2])
395
+ ['test', 'test:client', 'test:server', 'benchmark', 'perf'].includes(process.argv[2])
396
396
  ) {
397
397
  if (fs.existsSync(resolve(process.cwd(), '.env.test'))) {
398
398
  process.env.APP_ENV_PATH = '.env.test';