@visualautomate/cli 0.5.0 → 0.5.1

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 (3) hide show
  1. package/README.md +6 -5
  2. package/dist/index.js +36 -18
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -79,16 +79,17 @@ my-app/ an app's repository
79
79
  …
80
80
  ```
81
81
 
82
- At the root of an app's repository every module runs, one after another;
83
- `--module send-message` runs one. `index.js` in a repository is run as written,
82
+ At the root of an app's repository every module runs, one after another. Name one
83
+ to run only that: `vsa test send-message`, or any short name that picks it out —
84
+ `vsa test send`. `--module <name>` is the same thing. `index.js` in a repository is run as written,
84
85
  unbundled, because that is the file the sandbox loads.
85
86
 
86
87
  ## `dev`
87
88
 
88
89
  ```bash
89
- vsa dev
90
- vsa dev --module send-message
91
- vsa dev --tier boosted
90
+ vsa dev # every module in modules/
91
+ vsa dev send-message # one of them; the shortest name that picks it will do
92
+ vsa dev --tier boosted # a bigger machine
92
93
  vsa dev --local # on this machine's Node, without the sandbox
93
94
  ```
94
95
 
package/dist/index.js CHANGED
@@ -1822,6 +1822,14 @@ var ENTRIES = ["plugin.ts", "plugin.js", "index.ts", "index.js"];
1822
1822
  function entryIn(dir) {
1823
1823
  return ENTRIES.map((file2) => join(dir, file2)).find((file2) => existsSync(file2)) ?? null;
1824
1824
  }
1825
+ function matchFolders(folders, name) {
1826
+ const wanted = name.trim().toLowerCase();
1827
+ const exact = folders.filter((folder) => folder.toLowerCase() === wanted);
1828
+ if (exact.length > 0) return exact;
1829
+ const prefix = folders.filter((folder) => folder.toLowerCase().startsWith(wanted));
1830
+ if (prefix.length > 0) return prefix;
1831
+ return folders.filter((folder) => folder.toLowerCase().includes(wanted));
1832
+ }
1825
1833
  function findTargets(cwd, only) {
1826
1834
  const dir = resolve(cwd);
1827
1835
  const modulesDir = join(dir, "modules");
@@ -1830,16 +1838,16 @@ function findTargets(cwd, only) {
1830
1838
  if (folders.length === 0) {
1831
1839
  throw new Error("There is a modules/ folder here, but none of its folders has a manifest.json.");
1832
1840
  }
1833
- const chosen = only ? folders.filter((f) => f === only) : folders;
1841
+ const chosen = only ? matchFolders(folders, only) : folders;
1834
1842
  if (only && chosen.length === 0) {
1835
- throw new Error(`No module "${only}" in modules/. There is: ${folders.join(", ")}.`);
1843
+ throw new Error(`No module matches "${only}". This repository has: ${folders.join(", ")}.`);
1836
1844
  }
1837
1845
  return chosen.map((folder) => targetIn(join(modulesDir, folder), `modules/${folder}`)).filter(Boolean);
1838
1846
  }
1839
1847
  const target = targetIn(dir, basename(dir));
1840
1848
  if (!target) {
1841
1849
  throw new Error(
1842
- "Nothing to test here: no plugin.ts, plugin.js or index.js, and no modules/ folder.\nRun this in a plugin's folder, at the root of its repository, or run `visualautomate init <name>`."
1850
+ "Nothing to test here: no plugin.ts, plugin.js or index.js, and no modules/ folder.\nRun this in a module's folder, at the root of its repository, or run `vsa init <name>`."
1843
1851
  );
1844
1852
  }
1845
1853
  return [target];
@@ -2177,7 +2185,7 @@ function runInDocker(run) {
2177
2185
  }
2178
2186
 
2179
2187
  // src/index.ts
2180
- var VERSION = true ? "0.5.0" : "0.0.0-dev";
2188
+ var VERSION = true ? "0.5.1" : "0.0.0-dev";
2181
2189
  var DEFAULT_API_URL = "https://visualautomate.com";
2182
2190
  function configPath() {
2183
2191
  return join3(homedir(), ".visualautomate", "config.json");
@@ -2538,22 +2546,31 @@ function runTargetsInDocker(targets, all, flags) {
2538
2546
  }
2539
2547
  return passed;
2540
2548
  }
2541
- function targetsOrFail(flags) {
2549
+ function targetsOrFail(args, flags) {
2542
2550
  try {
2543
- return findTargets(process.cwd(), flags.module);
2551
+ return findTargets(process.cwd(), args[0] ?? flags.module);
2544
2552
  } catch (error) {
2545
2553
  fail(error instanceof Error ? error.message : String(error));
2546
2554
  }
2547
2555
  }
2548
- async function cmdTest(flags) {
2549
- const targets = targetsOrFail(flags);
2556
+ function sayWhatRuns(targets, picked) {
2557
+ if (targets.length === 1) {
2558
+ ok(`Running ${targets[0].name}`);
2559
+ return;
2560
+ }
2561
+ ok(`Running ${targets.length} modules: ${targets.map((t) => t.name.replace(/^modules\//, "")).join(", ")}`);
2562
+ if (!picked) ok(`One of them: vsa dev ${targets[0].name.replace(/^modules\//, "")}`);
2563
+ }
2564
+ async function cmdTest(args, flags) {
2565
+ const targets = targetsOrFail(args, flags);
2550
2566
  if (flags.docker) prepareSandbox(flags);
2551
2567
  const passed = flags.docker ? runTargetsInDocker(targets, targets, flags) : await runTargets(targets, flags);
2552
2568
  if (!passed) process.exitCode = 1;
2553
2569
  }
2554
- async function cmdDev(flags) {
2570
+ async function cmdDev(args, flags) {
2555
2571
  const root = process.cwd();
2556
- let targets = targetsOrFail(flags);
2572
+ const picked = args[0] ?? flags.module;
2573
+ let targets = targetsOrFail(args, flags);
2557
2574
  const inSandbox = flags.local !== "true";
2558
2575
  if (inSandbox) prepareSandbox(flags);
2559
2576
  const header = () => {
@@ -2563,6 +2580,7 @@ async function cmdDev(flags) {
2563
2580
  const run = async (chosen) => inSandbox ? runTargetsInDocker(chosen, targets, flags) : runTargets(chosen, flags);
2564
2581
  header();
2565
2582
  ok(inSandbox ? `in ${imageFor(flags)}, tier ${flags.tier || "standard"}` : "on this machine, not in the sandbox");
2583
+ sayWhatRuns(targets, Boolean(picked));
2566
2584
  await run(targets);
2567
2585
  const ignored = [`${sep2}node_modules${sep2}`, `${sep2}.git${sep2}`, `${sep2}dist${sep2}`, `${sep2}.visualautomate${sep2}`];
2568
2586
  const pending = /* @__PURE__ */ new Set();
@@ -2577,7 +2595,7 @@ async function cmdDev(flags) {
2577
2595
  const changed = [...pending];
2578
2596
  pending.clear();
2579
2597
  try {
2580
- targets = findTargets(root, flags.module);
2598
+ targets = findTargets(root, picked);
2581
2599
  } catch (error) {
2582
2600
  header();
2583
2601
  ok(`\u2717 ${error instanceof Error ? error.message : String(error)}`);
@@ -2699,8 +2717,8 @@ vsa \u2014 build and publish VisualAutomate plugins
2699
2717
 
2700
2718
  vsa login sign this machine in
2701
2719
  vsa init <name> [--template] start a plugin
2702
- vsa dev [--module <name>] the sandbox, and a run again on every save
2703
- vsa test [--module <name>] run it once, as the platform's check does
2720
+ vsa dev [<module>] the sandbox, and a run again on every save
2721
+ vsa test [<module>] run it once, as the platform's check does
2704
2722
  vsa push publish it
2705
2723
  vsa whoami which account this is
2706
2724
  vsa logout forget the token
@@ -2712,11 +2730,11 @@ Templates: ${Object.keys(TEMPLATES).join(", ")}
2712
2730
 
2713
2731
  \`test\` and \`dev\` work in a plugin made with \`init\`, at the root of a plugin's
2714
2732
  GitHub repository, and at the root of an app's repository, where every folder
2715
- in modules/ is run (or the one named with --module). The run's settings come
2733
+ in modules/ is run (or the one you name: vsa dev send-message). The run's settings come
2716
2734
  from visualautomate.test.json, test.json, or --input <file>.
2717
2735
 
2718
2736
  Options for \`dev\` and \`test\`:
2719
- --module <name> one folder of modules/ instead of all of them
2737
+ --module <name> the same as naming it: vsa dev send-message
2720
2738
  --tier <name> the sandbox's size: standard, boosted, high or max
2721
2739
  --image <ref> a different sandbox image
2722
2740
  --persist keep storage and state in .visualautomate/ between runs
@@ -2761,17 +2779,17 @@ async function main() {
2761
2779
  case "new":
2762
2780
  return cmdInit(args, flags);
2763
2781
  case "test":
2764
- return cmdTest(flags);
2782
+ return cmdTest(args, flags);
2765
2783
  case "dev":
2766
2784
  case "watch":
2767
- return cmdDev(flags);
2785
+ return cmdDev(args, flags);
2768
2786
  case "push":
2769
2787
  case "publish":
2770
2788
  return cmdPush(flags);
2771
2789
  // `plugin test` and `plugin push` are accepted as aliases.
2772
2790
  case "plugin": {
2773
2791
  const sub = args.shift();
2774
- if (sub === "test") return cmdTest(flags);
2792
+ if (sub === "test") return cmdTest(args, flags);
2775
2793
  if (sub === "push") return cmdPush(flags);
2776
2794
  printHelp();
2777
2795
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visualautomate/cli",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "Build and publish VisualAutomate plugins.",
5
5
  "license": "MIT",
6
6
  "type": "module",