@nocobase/cli 0.18.0-alpha.8 → 0.18.0-alpha.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 +4 -4
- package/src/commands/dev.js +8 -2
- package/src/commands/p-test.js +13 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/cli",
|
|
3
|
-
"version": "0.18.0-alpha.
|
|
3
|
+
"version": "0.18.0-alpha.9",
|
|
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.18.0-alpha.
|
|
11
|
+
"@nocobase/app": "0.18.0-alpha.9",
|
|
12
12
|
"@types/fs-extra": "^11.0.1",
|
|
13
13
|
"@umijs/utils": "3.5.20",
|
|
14
14
|
"chalk": "^4.1.1",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"tsx": "^4.6.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@nocobase/devtools": "0.18.0-alpha.
|
|
27
|
+
"@nocobase/devtools": "0.18.0-alpha.9"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
31
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
32
32
|
"directory": "packages/core/cli"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "34ca0df4eede2e83fc86297b0fe19eba970e2b1b"
|
|
35
35
|
}
|
package/src/commands/dev.js
CHANGED
|
@@ -15,6 +15,7 @@ module.exports = (cli) => {
|
|
|
15
15
|
.option('--client')
|
|
16
16
|
.option('--server')
|
|
17
17
|
.option('--db-sync')
|
|
18
|
+
.option('--inspect [port]')
|
|
18
19
|
.allowUnknownOption()
|
|
19
20
|
.action(async (opts) => {
|
|
20
21
|
promptForTs();
|
|
@@ -33,7 +34,7 @@ module.exports = (cli) => {
|
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
const { port, client, server } = opts;
|
|
37
|
+
const { port, client, server, inspect } = opts;
|
|
37
38
|
|
|
38
39
|
if (port) {
|
|
39
40
|
process.env.APP_PORT = opts.port;
|
|
@@ -59,8 +60,13 @@ module.exports = (cli) => {
|
|
|
59
60
|
if (server || !client) {
|
|
60
61
|
console.log('starting server', serverPort);
|
|
61
62
|
|
|
63
|
+
const filteredArgs = process.argv.filter(
|
|
64
|
+
(item, i) => !item.startsWith('--inspect') && !(process.argv[i - 1] === '--inspect' && Number.parseInt(item)),
|
|
65
|
+
);
|
|
66
|
+
|
|
62
67
|
const argv = [
|
|
63
68
|
'watch',
|
|
69
|
+
...(inspect ? [`--inspect=${inspect === true ? 9229 : inspect}`] : []),
|
|
64
70
|
'--ignore=./storage/plugins/**',
|
|
65
71
|
'--tsconfig',
|
|
66
72
|
SERVER_TSCONFIG_PATH,
|
|
@@ -68,7 +74,7 @@ module.exports = (cli) => {
|
|
|
68
74
|
'tsconfig-paths/register',
|
|
69
75
|
`${APP_PACKAGE_ROOT}/src/index.ts`,
|
|
70
76
|
'start',
|
|
71
|
-
...
|
|
77
|
+
...filteredArgs.slice(3),
|
|
72
78
|
`--port=${serverPort}`,
|
|
73
79
|
];
|
|
74
80
|
|
package/src/commands/p-test.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const execa = require('execa');
|
|
2
|
-
const { resolve
|
|
2
|
+
const { resolve } = require('path');
|
|
3
3
|
const pAll = require('p-all');
|
|
4
4
|
const dotenv = require('dotenv');
|
|
5
5
|
const fs = require('fs');
|
|
6
6
|
const { Client } = require('pg');
|
|
7
7
|
const glob = require('glob');
|
|
8
|
+
const _ = require('lodash');
|
|
8
9
|
|
|
9
10
|
let ENV_FILE = resolve(process.cwd(), '.env.e2e');
|
|
10
11
|
|
|
@@ -18,7 +19,10 @@ const config = {
|
|
|
18
19
|
...process.env,
|
|
19
20
|
};
|
|
20
21
|
|
|
21
|
-
async function runApp(index =
|
|
22
|
+
async function runApp(dir, index = 0) {
|
|
23
|
+
// 一个进程需要占用两个端口? (一个是应用端口,一个是 socket 端口)
|
|
24
|
+
index = index * 2;
|
|
25
|
+
|
|
22
26
|
const database = `nocobase${index}`;
|
|
23
27
|
const client = new Client({
|
|
24
28
|
host: config['DB_HOST'],
|
|
@@ -54,15 +58,15 @@ exports.pTest = async (options) => {
|
|
|
54
58
|
const files = glob.sync('packages/**/__e2e__/**/*.test.ts', {
|
|
55
59
|
root: process.cwd(),
|
|
56
60
|
});
|
|
57
|
-
const fileSet = new Set();
|
|
58
|
-
|
|
59
|
-
for (const file of files) {
|
|
60
|
-
fileSet.add(dirname(file));
|
|
61
|
-
}
|
|
62
61
|
|
|
63
|
-
const commands =
|
|
64
|
-
return () => runApp(
|
|
62
|
+
const commands = splitArrayIntoParts(files, options.concurrency || 3).map((v, i) => {
|
|
63
|
+
return () => runApp(v.join(' '), i);
|
|
65
64
|
});
|
|
66
65
|
|
|
67
66
|
await pAll(commands, { concurrency: 3, stopOnError: false, ...options });
|
|
68
67
|
};
|
|
68
|
+
|
|
69
|
+
function splitArrayIntoParts(array, parts) {
|
|
70
|
+
let chunkSize = Math.ceil(array.length / parts);
|
|
71
|
+
return _.chunk(array, chunkSize);
|
|
72
|
+
}
|