architecture-harness 0.18.1 → 0.18.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "architecture-harness",
3
- "version": "0.18.1",
3
+ "version": "0.18.2",
4
4
  "type": "module",
5
5
  "description": "Architecture gates, lint rules and scaffolding for the bounded-vertical-slice architecture",
6
6
  "license": "MIT",
@@ -2,7 +2,7 @@
2
2
  // run.mjs for exactly that reason: the parent process must not need the loader to decide anything.
3
3
 
4
4
  import process from "node:process";
5
- import { pathToFileURL } from "node:url";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
6
6
  import { parseInput } from "./run.mjs";
7
7
 
8
8
  /** Every command the registry publishes, sorted, one per line — what `qc run` with no name prints. */
@@ -41,7 +41,7 @@ export async function dispatch(registry, name, argv) {
41
41
  }
42
42
 
43
43
  // Spawned by run.mjs under the repository's loader: argv is [registry, name?, ...rest].
44
- if (process.argv[1] === new URL(import.meta.url).pathname) {
44
+ if (process.argv[1] !== undefined && fileURLToPath(import.meta.url) === process.argv[1]) {
45
45
  const [registry, name, ...rest] = process.argv.slice(2);
46
46
  try {
47
47
  process.exit(await dispatch(registry, name, rest));
@@ -3,6 +3,8 @@ import assert from "node:assert/strict";
3
3
  import { mkdtemp, writeFile } from "node:fs/promises";
4
4
  import { tmpdir } from "node:os";
5
5
  import path from "node:path";
6
+ import { spawnSync } from "node:child_process";
7
+ import { fileURLToPath } from "node:url";
6
8
  import { needsLoader, parseInput, runRun } from "./run.mjs";
7
9
  import { listing } from "./run-dispatch.mjs";
8
10
 
@@ -69,3 +71,25 @@ test("an unknown command fails and does not run anything", async () => {
69
71
  const code = await runRun({ root: dir, cli: { registry, loader: [] } }, ["tasks.nope"]);
70
72
  assert.equal(code, 1);
71
73
  });
74
+
75
+ const SHIM = fileURLToPath(new URL("./run-dispatch.mjs", import.meta.url));
76
+
77
+ /** Spawns the shim as run.mjs does, against a one-command javascript registry. */
78
+ async function spawnShim(...args) {
79
+ const dir = await mkdtemp(path.join(tmpdir(), "qc-run-"));
80
+ const registry = path.join(dir, "commands.generated.mjs");
81
+ await writeFile(registry, 'export const commands = { "tasks.kanban": { run: (input) => ({ seen: input }) } };');
82
+ return spawnSync(process.execPath, [SHIM, registry, ...args], { encoding: "utf8" });
83
+ }
84
+
85
+ test("the spawned shim fails an unknown command and names it", async () => {
86
+ const child = await spawnShim("tasks.nope");
87
+ assert.equal(child.status, 1);
88
+ assert.match(child.stderr, /no command `tasks\.nope`/);
89
+ });
90
+
91
+ test("the spawned shim runs a declared command and prints its result", async () => {
92
+ const child = await spawnShim("tasks.kanban", "--project", "P3");
93
+ assert.equal(child.status, 0);
94
+ assert.deepEqual(JSON.parse(child.stdout), { seen: { project: "P3" } });
95
+ });