@norskvideo/ctl-test-harness 0.1.10 → 0.1.11

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/launch.d.ts +10 -8
  2. package/launch.js +22 -19
  3. package/package.json +1 -1
package/launch.d.ts CHANGED
@@ -12,13 +12,15 @@ export declare function withContainerUser<T>(opts: T & {
12
12
  }): T & {
13
13
  containerUser?: string;
14
14
  };
15
- /** True when the resolved norsk-ctl CLI understands `--no-publish`. Memoised. */
15
+ /** True when the resolved norsk-ctl CLI understands `--internal-only`. Memoised. */
16
16
  export declare function ctlSupportsNoPublish(): Promise<boolean>;
17
- /** In `direct` reach mode, ask the daemon to bind no host ports (`noPublish`) so
18
- * concurrent instances on a shared runner can't collide on the product's
17
+ /** In `direct` reach mode, ask the daemon to bind no host ports (`internalOnly`)
18
+ * so concurrent instances on a shared runner can't collide on the product's
19
19
  * host-port bands — but only when the resolved ctl supports the flag (see
20
- * {@link ctlSupportsNoPublish}). `publish` mode and an explicit `noPublish` pass
21
- * through untouched. Async because the capability probe is. */
22
- export declare function withNoPublish<T extends {
23
- noPublish?: boolean;
24
- }>(opts: T): Promise<T>;
20
+ * {@link ctlSupportsNoPublish}). `publish` mode and an explicit `internalOnly`
21
+ * pass through untouched. Async because the capability probe is. */
22
+ export declare function withNoPublish<T>(opts: T & {
23
+ internalOnly?: boolean;
24
+ }): Promise<T & {
25
+ internalOnly?: boolean;
26
+ }>;
package/launch.js CHANGED
@@ -32,15 +32,18 @@ export function withContainerUser(opts) {
32
32
  const user = runnerContainerUser();
33
33
  return user === undefined ? opts : { ...opts, containerUser: user };
34
34
  }
35
- // The CLI is `.strict()`, so passing `--no-publish` to a norsk-ctl that predates
36
- // the flag aborts the launch with "Unknown argument". A newer product must still
37
- // launch on an older ctl (the contract's whole additive rule), so we probe the
38
- // resolved binary once and only emit the flag when it advertises it. On an old
39
- // ctl this silently no-ops (publish as today); when `latest` catches up the same
40
- // harness starts binding no host ports no cross-repo release ordering to get
41
- // right. Cached: one `--help` spawn per process.
42
- let noPublishSupport;
43
- async function probeNoPublishSupport() {
35
+ // The launch flag is `--internal-only`, NOT `--no-publish`: yargs reads a `--no-`
36
+ // prefix as boolean negation of a `publish` option and, under `.strict()`, aborts
37
+ // with "Unknown argument: publish". The CLI is also `.strict()` about unknown
38
+ // flags, so a ctl that predates `--internal-only` would reject it too a newer
39
+ // product must still launch on an older ctl (the contract's whole additive rule).
40
+ // So we probe the resolved binary once and only emit the flag when it advertises
41
+ // it: a no-op on an old ctl (publish as today), self-upgrading when `latest`
42
+ // catches up — no cross-repo release ordering to get right. Cached: one `--help`
43
+ // spawn per process.
44
+ const INTERNAL_ONLY_FLAG = "--internal-only";
45
+ let internalOnlySupport;
46
+ async function probeInternalOnlySupport() {
44
47
  try {
45
48
  const proc = Bun.spawn([...cliCommand, "instance", "launch-template", "--help"], {
46
49
  stdout: "pipe",
@@ -48,24 +51,24 @@ async function probeNoPublishSupport() {
48
51
  });
49
52
  const [out, errText] = await Promise.all([new Response(proc.stdout).text(), new Response(proc.stderr).text()]);
50
53
  await proc.exited;
51
- return `${out}${errText}`.includes("--no-publish");
54
+ return `${out}${errText}`.includes(INTERNAL_ONLY_FLAG);
52
55
  }
53
56
  catch {
54
57
  return false;
55
58
  }
56
59
  }
57
- /** True when the resolved norsk-ctl CLI understands `--no-publish`. Memoised. */
60
+ /** True when the resolved norsk-ctl CLI understands `--internal-only`. Memoised. */
58
61
  export function ctlSupportsNoPublish() {
59
- noPublishSupport ??= probeNoPublishSupport();
60
- return noPublishSupport;
62
+ internalOnlySupport ??= probeInternalOnlySupport();
63
+ return internalOnlySupport;
61
64
  }
62
- /** In `direct` reach mode, ask the daemon to bind no host ports (`noPublish`) so
63
- * concurrent instances on a shared runner can't collide on the product's
65
+ /** In `direct` reach mode, ask the daemon to bind no host ports (`internalOnly`)
66
+ * so concurrent instances on a shared runner can't collide on the product's
64
67
  * host-port bands — but only when the resolved ctl supports the flag (see
65
- * {@link ctlSupportsNoPublish}). `publish` mode and an explicit `noPublish` pass
66
- * through untouched. Async because the capability probe is. */
68
+ * {@link ctlSupportsNoPublish}). `publish` mode and an explicit `internalOnly`
69
+ * pass through untouched. Async because the capability probe is. */
67
70
  export async function withNoPublish(opts) {
68
- if (opts.noPublish !== undefined || netReachMode() !== "direct")
71
+ if (opts.internalOnly !== undefined || netReachMode() !== "direct")
69
72
  return opts;
70
- return (await ctlSupportsNoPublish()) ? { ...opts, noPublish: true } : opts;
73
+ return (await ctlSupportsNoPublish()) ? { ...opts, internalOnly: true } : opts;
71
74
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@norskvideo/ctl-test-harness",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./daemon": {