@joystick.js/cli-canary 0.0.0-canary.9 → 0.0.0-canary.91

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.
Files changed (45) hide show
  1. package/dist/cli.js +7 -0
  2. package/dist/functions/index.js +21 -0
  3. package/dist/functions/start/index.js +3 -489
  4. package/dist/functions/start/onWarn.js +1 -1
  5. package/dist/functions/start/setComponentId.js +1 -1
  6. package/dist/functions/test/index.js +7 -26
  7. package/dist/lib/build/buildFiles.js +63 -7
  8. package/dist/lib/build/buildPlugins.js +18 -15
  9. package/dist/lib/build/getCodeFrame.js +3 -4
  10. package/dist/lib/build/onWarn.js +1 -1
  11. package/dist/lib/dev/cleanup.js +15 -27
  12. package/dist/lib/dev/databases/mongodb/index.js +1 -1
  13. package/dist/lib/dev/databases/postgresql/index.js +2 -2
  14. package/dist/lib/dev/databases/providerMap.js +1 -1
  15. package/dist/lib/dev/index.js +104 -28
  16. package/dist/lib/dev/isWindows.js +5 -0
  17. package/dist/lib/dev/loadSettings.js +1 -3
  18. package/dist/lib/dev/startApp.js +43 -3
  19. package/dist/lib/dev/startDatabases.js +12 -5
  20. package/dist/lib/dev/startHMR.js +30 -5
  21. package/dist/lib/getProcessIdFromPort.js +60 -0
  22. package/dist/lib/types.js +6 -0
  23. package/package.json +1 -1
  24. package/src/cli.js +9 -0
  25. package/src/functions/index.js +21 -0
  26. package/src/functions/start/index.js +2 -691
  27. package/src/functions/start/onWarn.js +1 -1
  28. package/src/functions/start/setComponentId.js +1 -1
  29. package/src/functions/test/index.js +7 -32
  30. package/src/lib/build/buildFiles.js +74 -8
  31. package/src/lib/build/buildPlugins.js +29 -22
  32. package/src/lib/build/getCodeFrame.js +3 -4
  33. package/src/lib/build/onWarn.js +1 -1
  34. package/src/lib/dev/cleanup.js +20 -28
  35. package/src/lib/dev/databases/mongodb/index.js +1 -1
  36. package/src/lib/dev/databases/postgresql/index.js +2 -2
  37. package/src/lib/dev/databases/providerMap.js +1 -1
  38. package/src/lib/dev/index.js +124 -41
  39. package/src/lib/dev/isWindows.js +3 -0
  40. package/src/lib/dev/loadSettings.js +1 -3
  41. package/src/lib/dev/startApp.js +52 -6
  42. package/src/lib/dev/startDatabases.js +12 -6
  43. package/src/lib/dev/startHMR.js +36 -7
  44. package/src/lib/getProcessIdFromPort.js +92 -0
  45. 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
+ };
@@ -0,0 +1,6 @@
1
+ const isObject = (value) => {
2
+ return value !== null && !Array.isArray(value) && typeof value === "object";
3
+ };
4
+ export {
5
+ isObject
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joystick.js/cli-canary",
3
- "version": "0.0.0-canary.9",
3
+ "version": "0.0.0-canary.91",
4
4
  "type": "module",
5
5
  "description": "CLI for the Joystick JavaScript framework.",
6
6
  "main": "development.js",
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);
@@ -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.',