@joystick.js/cli-canary 0.0.0-canary.9 → 0.0.0-canary.90
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/dist/cli.js +7 -0
- package/dist/functions/index.js +21 -0
- package/dist/functions/start/index.js +3 -489
- package/dist/functions/start/onWarn.js +1 -1
- package/dist/functions/start/setComponentId.js +1 -1
- package/dist/functions/test/index.js +7 -26
- package/dist/lib/build/buildFiles.js +63 -7
- package/dist/lib/build/buildPlugins.js +18 -15
- package/dist/lib/build/getCodeFrame.js +3 -4
- package/dist/lib/build/onWarn.js +1 -1
- package/dist/lib/dev/cleanup.js +15 -27
- package/dist/lib/dev/databases/mongodb/index.js +1 -1
- package/dist/lib/dev/databases/postgresql/index.js +2 -2
- package/dist/lib/dev/databases/providerMap.js +1 -1
- package/dist/lib/dev/index.js +104 -28
- package/dist/lib/dev/isWindows.js +5 -0
- package/dist/lib/dev/loadSettings.js +1 -3
- package/dist/lib/dev/startApp.js +43 -3
- package/dist/lib/dev/startDatabases.js +12 -5
- package/dist/lib/dev/startHMR.js +30 -5
- package/dist/lib/getProcessIdFromPort.js +60 -0
- package/dist/lib/types.js +6 -0
- package/package.json +1 -1
- package/src/cli.js +9 -0
- package/src/functions/index.js +21 -0
- package/src/functions/start/index.js +2 -691
- package/src/functions/start/onWarn.js +1 -1
- package/src/functions/start/setComponentId.js +1 -1
- package/src/functions/test/index.js +7 -32
- package/src/lib/build/buildFiles.js +74 -8
- package/src/lib/build/buildPlugins.js +29 -22
- package/src/lib/build/getCodeFrame.js +3 -4
- package/src/lib/build/onWarn.js +1 -1
- package/src/lib/dev/cleanup.js +20 -28
- package/src/lib/dev/databases/mongodb/index.js +1 -1
- package/src/lib/dev/databases/postgresql/index.js +2 -2
- package/src/lib/dev/databases/providerMap.js +1 -1
- package/src/lib/dev/index.js +124 -41
- package/src/lib/dev/isWindows.js +3 -0
- package/src/lib/dev/loadSettings.js +1 -3
- package/src/lib/dev/startApp.js +52 -6
- package/src/lib/dev/startDatabases.js +12 -6
- package/src/lib/dev/startHMR.js +36 -7
- package/src/lib/getProcessIdFromPort.js +92 -0
- package/src/lib/types.js +3 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import condense from "selective-whitespace";
|
|
2
|
+
import netstats from "netstats";
|
|
3
|
+
const platform = process.platform;
|
|
4
|
+
function pushTo(target, item) {
|
|
5
|
+
if (item !== "" && typeof item === "number" && item !== 0 && target.indexOf(item) === -1) {
|
|
6
|
+
target.push(item);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
async function processNetStats(arr) {
|
|
10
|
+
const pidindex = 1;
|
|
11
|
+
let items = arr.slice(1);
|
|
12
|
+
if (platform === "win32") {
|
|
13
|
+
items = arr;
|
|
14
|
+
}
|
|
15
|
+
const pids = {
|
|
16
|
+
all: [],
|
|
17
|
+
tcp: [],
|
|
18
|
+
udp: []
|
|
19
|
+
};
|
|
20
|
+
await Promise.all(items.map((item) => {
|
|
21
|
+
const values = condense(item).split(" ");
|
|
22
|
+
let pid = parseInt(values[pidindex], 10);
|
|
23
|
+
if (platform === "win32") {
|
|
24
|
+
pid = parseInt(values.pop(), 10);
|
|
25
|
+
}
|
|
26
|
+
if (values.length > 1) {
|
|
27
|
+
if (values.indexOf("TCP") !== -1) {
|
|
28
|
+
pushTo(pids.tcp, pid);
|
|
29
|
+
pushTo(pids.all, pid);
|
|
30
|
+
} else if (values.indexOf("UDP") !== -1) {
|
|
31
|
+
pushTo(pids.udp, pid);
|
|
32
|
+
pushTo(pids.all, pid);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
}));
|
|
37
|
+
return pids;
|
|
38
|
+
}
|
|
39
|
+
function getProcessIdFromPort(port) {
|
|
40
|
+
if (typeof port !== "number") {
|
|
41
|
+
throw new TypeError("Expected a port number");
|
|
42
|
+
}
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
netstats(port).then((stats) => {
|
|
45
|
+
processNetStats(stats).then((ps) => {
|
|
46
|
+
resolve(ps);
|
|
47
|
+
});
|
|
48
|
+
}).catch(() => {
|
|
49
|
+
resolve({
|
|
50
|
+
all: [],
|
|
51
|
+
tcp: [],
|
|
52
|
+
udp: []
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
var getProcessIdFromPort_default = getProcessIdFromPort;
|
|
58
|
+
export {
|
|
59
|
+
getProcessIdFromPort_default as default
|
|
60
|
+
};
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -69,6 +69,15 @@ if (functionsCalled.includes('start')) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
if (functionsCalled.includes('test')) {
|
|
73
|
+
const args = getArgs(functions.test.args);
|
|
74
|
+
const options = getOptions(functions.test.options);
|
|
75
|
+
|
|
76
|
+
if (functions.test.function && typeof functions.test.function === 'function') {
|
|
77
|
+
functions.test.function(args, options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
72
81
|
if (functionsCalled.includes('update')) {
|
|
73
82
|
const args = getArgs(functions.update.args);
|
|
74
83
|
const options = getOptions(functions.update.options);
|
package/src/functions/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import logout from './logout/index.js';
|
|
|
5
5
|
import start from './start/index.js';
|
|
6
6
|
import update from './update/index.js';
|
|
7
7
|
import use from "./use/index.js";
|
|
8
|
+
import test from "./test/index.js";
|
|
8
9
|
|
|
9
10
|
const [_node, _bin, ...rawArgs] = process.argv;
|
|
10
11
|
|
|
@@ -219,6 +220,26 @@ export default {
|
|
|
219
220
|
},
|
|
220
221
|
function: start,
|
|
221
222
|
},
|
|
223
|
+
test: {
|
|
224
|
+
set: !!rawArgs.includes('test'),
|
|
225
|
+
description: 'Start an existing Joystick app and run its tests.',
|
|
226
|
+
args: {
|
|
227
|
+
w: {
|
|
228
|
+
set: !!rawArgs.includes('w') && !!rawArgs[rawArgs.indexOf('w') + 1],
|
|
229
|
+
parent: 'w',
|
|
230
|
+
value: !!rawArgs.includes('w') && rawArgs[rawArgs.indexOf('w') + 1],
|
|
231
|
+
description: 'Run joystick test in watch mode.',
|
|
232
|
+
},
|
|
233
|
+
watch: {
|
|
234
|
+
set: !!rawArgs.includes('watch') && !!rawArgs[rawArgs.indexOf('watch') + 1],
|
|
235
|
+
parent: 'watch',
|
|
236
|
+
value: !!rawArgs.includes('watch') && rawArgs[rawArgs.indexOf('watch') + 1],
|
|
237
|
+
description: 'Run joystick test in watch mode.',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
options: {},
|
|
241
|
+
function: test(),
|
|
242
|
+
},
|
|
222
243
|
update: {
|
|
223
244
|
set: !!rawArgs.includes('update'),
|
|
224
245
|
description: 'Update all Joystick packages to their latest version.',
|