@joystick.js/cli-canary 0.0.0-canary.88 → 0.0.0-canary.89

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 CHANGED
@@ -53,6 +53,13 @@ if (functionsCalled.includes("start")) {
53
53
  functions.start.function(args, options);
54
54
  }
55
55
  }
56
+ if (functionsCalled.includes("test")) {
57
+ const args = getArgs(functions.test.args);
58
+ const options = getOptions(functions.test.options);
59
+ if (functions.test.function && typeof functions.test.function === "function") {
60
+ functions.test.function(args, options);
61
+ }
62
+ }
56
63
  if (functionsCalled.includes("update")) {
57
64
  const args = getArgs(functions.update.args);
58
65
  const options = getOptions(functions.update.options);
@@ -4,6 +4,7 @@ import logout from "./logout/index.js";
4
4
  import start from "./start/index.js";
5
5
  import update from "./update/index.js";
6
6
  import use from "./use/index.js";
7
+ import test from "./test/index.js";
7
8
  const [_node, _bin, ...rawArgs] = process.argv;
8
9
  var functions_default = {
9
10
  build: {
@@ -216,6 +217,26 @@ var functions_default = {
216
217
  },
217
218
  function: start
218
219
  },
220
+ test: {
221
+ set: !!rawArgs.includes("test"),
222
+ description: "Start an existing Joystick app and run its tests.",
223
+ args: {
224
+ w: {
225
+ set: !!rawArgs.includes("w") && !!rawArgs[rawArgs.indexOf("w") + 1],
226
+ parent: "w",
227
+ value: !!rawArgs.includes("w") && rawArgs[rawArgs.indexOf("w") + 1],
228
+ description: "Run joystick test in watch mode."
229
+ },
230
+ watch: {
231
+ set: !!rawArgs.includes("watch") && !!rawArgs[rawArgs.indexOf("watch") + 1],
232
+ parent: "watch",
233
+ value: !!rawArgs.includes("watch") && rawArgs[rawArgs.indexOf("watch") + 1],
234
+ description: "Run joystick test in watch mode."
235
+ }
236
+ },
237
+ options: {},
238
+ function: test()
239
+ },
219
240
  update: {
220
241
  set: !!rawArgs.includes("update"),
221
242
  description: "Update all Joystick packages to their latest version.",
@@ -1,30 +1,11 @@
1
- const actionMethod = () => {
2
- try {
3
- } catch (exception) {
4
- throw new Error(`[test.actionMethod] ${exception.message}`);
5
- }
1
+ import dev from "../../lib/dev/index.js";
2
+ var test_default = async (args = {}, options = {}) => {
3
+ await dev({
4
+ environment: "test",
5
+ process,
6
+ port: 1977
7
+ });
6
8
  };
7
- const validateOptions = (options) => {
8
- try {
9
- if (!options)
10
- throw new Error("options object is required.");
11
- if (!options.someOption)
12
- throw new Error("options.someOption is required.");
13
- } catch (exception) {
14
- throw new Error(`[test.validateOptions] ${exception.message}`);
15
- }
16
- };
17
- const test = (options, { resolve, reject }) => {
18
- try {
19
- validateOptions(options);
20
- resolve();
21
- } catch (exception) {
22
- reject(`[test] ${exception.message}`);
23
- }
24
- };
25
- var test_default = (options) => new Promise((resolve, reject) => {
26
- test(options, { resolve, reject });
27
- });
28
9
  export {
29
10
  test_default as default
30
11
  };
@@ -437,6 +437,9 @@ const dev = async (options, { resolve, reject }) => {
437
437
  nodeMajorVersion,
438
438
  __dirname
439
439
  );
440
+ if (options?.environment === "test") {
441
+ process.loader.text("Running tests...");
442
+ }
440
443
  resolve();
441
444
  } catch (exception) {
442
445
  console.warn(exception);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joystick.js/cli-canary",
3
- "version": "0.0.0-canary.88",
3
+ "version": "0.0.0-canary.89",
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.',
@@ -1,34 +1,9 @@
1
- /* eslint-disable consistent-return */
1
+ import dev from "../../lib/dev/index.js";
2
2
 
3
- const actionMethod = () => {
4
- try {
5
- // Perform a single step in your action here.
6
- } catch (exception) {
7
- throw new Error(`[test.actionMethod] ${exception.message}`);
8
- }
9
- };
10
-
11
- const validateOptions = (options) => {
12
- try {
13
- if (!options) throw new Error('options object is required.');
14
- if (!options.someOption) throw new Error('options.someOption is required.');
15
- } catch (exception) {
16
- throw new Error(`[test.validateOptions] ${exception.message}`);
17
- }
18
- };
19
-
20
- const test = (options, { resolve, reject }) => {
21
- try {
22
- validateOptions(options);
23
- // Call action methods in sequence here.
24
- resolve();
25
- } catch (exception) {
26
- reject(`[test] ${exception.message}`);
27
- }
28
- };
29
-
30
- export default (options) =>
31
- new Promise((resolve, reject) => {
32
- test(options, { resolve, reject });
3
+ export default async (args = {}, options = {}) => {
4
+ await dev({
5
+ environment: 'test',
6
+ process,
7
+ port: 1977,
33
8
  });
34
-
9
+ };
@@ -267,7 +267,6 @@ const getWatchChangeContext = (event = '', path = '') => {
267
267
  try {
268
268
  const isHTMLUpdate = path === "index.html";
269
269
  const isUIPath = path?.includes("ui/") || path === 'index.css' || isHTMLUpdate;
270
- // TODO: Flimsy. May want to wait until HMR and server are up to do the builds/watching.
271
270
  const isUIUpdate = (process.hmrProcess && process.hmrProcess.hasConnections && isUIPath) || false;
272
271
  const isSettingsUpdate = path?.match(SETTINGS_FILE_NAME_REGEX)?.length > 0;
273
272
  const isDirectory = fs.statSync(path).isDirectory();
@@ -525,10 +524,11 @@ const dev = async (options, { resolve, reject }) => {
525
524
  __dirname
526
525
  );
527
526
 
528
- //
529
- // if (options?.environment === 'test') {
530
- // await runTests(options);
531
- // }
527
+
528
+ if (options?.environment === 'test') {
529
+ process.loader.text('Running tests...');
530
+ // await runTests(options);
531
+ }
532
532
 
533
533
  /*
534
534
  TODO:
@@ -540,7 +540,7 @@ const dev = async (options, { resolve, reject }) => {
540
540
  - [x] Start databases relative to options.environment (development|test) from settings.<environment>.json.
541
541
  - [x] Run the initial build
542
542
  - [x] Start the file watcher
543
- - [ ] Start the app as normal from the build directory.
543
+ - [x] Start the app as normal from the build directory.
544
544
  - [ ] If environment === 'test', run the tests.
545
545
  - [ ] If environment === 'test', after tests, run process.exit(0).
546
546
  */