@norskvideo/ctl-test-harness 0.1.10 → 0.1.12
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/launch.d.ts +10 -8
- package/launch.js +22 -19
- 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 `--
|
|
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 (`
|
|
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 `
|
|
21
|
-
* through untouched. Async because the capability probe is. */
|
|
22
|
-
export declare function withNoPublish<T
|
|
23
|
-
|
|
24
|
-
}
|
|
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
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
//
|
|
40
|
-
//
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
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(
|
|
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 `--
|
|
60
|
+
/** True when the resolved norsk-ctl CLI understands `--internal-only`. Memoised. */
|
|
58
61
|
export function ctlSupportsNoPublish() {
|
|
59
|
-
|
|
60
|
-
return
|
|
62
|
+
internalOnlySupport ??= probeInternalOnlySupport();
|
|
63
|
+
return internalOnlySupport;
|
|
61
64
|
}
|
|
62
|
-
/** In `direct` reach mode, ask the daemon to bind no host ports (`
|
|
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 `
|
|
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.
|
|
71
|
+
if (opts.internalOnly !== undefined || netReachMode() !== "direct")
|
|
69
72
|
return opts;
|
|
70
|
-
return (await ctlSupportsNoPublish()) ? { ...opts,
|
|
73
|
+
return (await ctlSupportsNoPublish()) ? { ...opts, internalOnly: true } : opts;
|
|
71
74
|
}
|