@norskvideo/ctl-dev-kit 0.1.70 → 0.1.72
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.
|
@@ -114,8 +114,11 @@ jobs:
|
|
|
114
114
|
- name: Open (or update) the pin-freshness PR
|
|
115
115
|
if: steps.bump.outputs.changed == '1'
|
|
116
116
|
env:
|
|
117
|
-
|
|
117
|
+
API_TOKEN: ${{ secrets.CI_DISPATCH_TOKEN }}
|
|
118
118
|
GATE: ${{ steps.gate.outcome }}
|
|
119
|
+
# Through the env, never interpolated into the script below: see the
|
|
120
|
+
# heredoc comment for what happens when it is.
|
|
121
|
+
MOVED: ${{ steps.bump.outputs.moved }}
|
|
119
122
|
run: |
|
|
120
123
|
set -euo pipefail
|
|
121
124
|
branch="chore/sync-ctl-packages"
|
|
@@ -130,18 +133,24 @@ jobs:
|
|
|
130
133
|
|
|
131
134
|
if [ "$GATE" = "success" ]; then
|
|
132
135
|
verdict="Gate green: check:drift, lint, typecheck and unit tests all pass on the new pins."
|
|
133
|
-
draft=
|
|
136
|
+
draft=false
|
|
134
137
|
else
|
|
135
138
|
verdict="**Gate red** — the new pins do not fit this product as-is. Adopting them is real engineering, not a merge."
|
|
136
|
-
draft=
|
|
139
|
+
draft=true
|
|
137
140
|
fi
|
|
138
141
|
|
|
142
|
+
# $MOVED, not the expression that produced it. This heredoc is unquoted
|
|
143
|
+
# so $verdict expands, which means its literal text is scanned for
|
|
144
|
+
# command substitution too -- and the moved-pin list names every package
|
|
145
|
+
# in backticks. Pasted in directly, each name RAN (exit 127, no PR,
|
|
146
|
+
# every morning since this workflow shipped). Bash does not rescan an
|
|
147
|
+
# expansion's result, so through the env the same backticks are inert.
|
|
139
148
|
body="$(cat <<EOF
|
|
140
149
|
Automated by \`sync-ctl-packages\`.
|
|
141
150
|
|
|
142
151
|
## Pins moved
|
|
143
152
|
|
|
144
|
-
$
|
|
153
|
+
$MOVED
|
|
145
154
|
|
|
146
155
|
## What the gate proved
|
|
147
156
|
|
|
@@ -153,10 +162,24 @@ jobs:
|
|
|
153
162
|
EOF
|
|
154
163
|
)"
|
|
155
164
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
165
|
+
# gh is not on the self-hosted runner PATH -- it lives only inside
|
|
166
|
+
# `nix develop`, and this step runs outside it -- so create/update the
|
|
167
|
+
# PR straight against the REST API with the same PAT that pushed the
|
|
168
|
+
# branch. This is the identical fix sync-dev-kit already carries and
|
|
169
|
+
# documents; it was applied to one sibling convention and not its twin,
|
|
170
|
+
# so this step failed with exit 127 in every product repo. curl and jq
|
|
171
|
+
# ARE on the host PATH (the pin-resolve step above uses them).
|
|
172
|
+
title="chore: sync the ctl-* pins to their newest published versions"
|
|
173
|
+
repo="${{ github.repository }}"; owner="${repo%%/*}"
|
|
174
|
+
api="https://api.github.com/repos/$repo/pulls"
|
|
175
|
+
curl_api=(--fail-with-body -sS -H "Authorization: Bearer $API_TOKEN" -H "Accept: application/vnd.github+json")
|
|
176
|
+
existing="$(curl "${curl_api[@]}" "$api?head=$owner:$branch&state=open" | jq -r '.[0].number // empty')"
|
|
177
|
+
if [ -n "$existing" ]; then
|
|
178
|
+
# draft is not settable by PATCH; the standing PR keeps whichever
|
|
179
|
+
# state it opened in and the refreshed body carries the verdict.
|
|
180
|
+
curl "${curl_api[@]}" -X PATCH "$api/$existing" \
|
|
181
|
+
--data "$(jq -nc --arg t "$title" --arg b "$body" '{title:$t, body:$b}')" >/dev/null
|
|
160
182
|
else
|
|
161
|
-
|
|
183
|
+
curl "${curl_api[@]}" -X POST "$api" \
|
|
184
|
+
--data "$(jq -nc --arg t "$title" --arg b "$body" --arg h "$branch" --argjson d "$draft" '{title:$t, body:$b, head:$h, base:"main", draft:$d}')" >/dev/null
|
|
162
185
|
fi
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Convention workflows carry real shell scripts inside YAML, and the two live in
|
|
2
|
+
// different worlds: the runner's bare PATH outside `nix develop`, a single-quoted
|
|
3
|
+
// word inside `bash -c '...'`. The guards over those hazards all need the same
|
|
4
|
+
// question answered first — is this line inside a quoted block or not — so it is
|
|
5
|
+
// asked in one place.
|
|
6
|
+
|
|
7
|
+
/** 1-indexed line numbers inside a multi-line `bash -c '` block, which ends at a
|
|
8
|
+
* line that is just `'`. A one-liner closing its own quote (`bash -c 'a; b'`)
|
|
9
|
+
* opens no block — it is already balanced. */
|
|
10
|
+
export function bashBlockLines(yaml: string): Set<number> {
|
|
11
|
+
const OPEN = "bash -c '";
|
|
12
|
+
const inside = new Set<number>();
|
|
13
|
+
let open = false;
|
|
14
|
+
yaml.split("\n").forEach((text, i) => {
|
|
15
|
+
if (!open) {
|
|
16
|
+
const at = text.indexOf(OPEN);
|
|
17
|
+
if (at >= 0 && !text.slice(at + OPEN.length).includes("'")) open = true;
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (text.trim() === "'") {
|
|
21
|
+
open = false;
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
inside.add(i + 1);
|
|
25
|
+
});
|
|
26
|
+
return inside;
|
|
27
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Lint that a product's compose actually DECLARES the product to Studio.
|
|
2
|
+
//
|
|
3
|
+
// Studio names a product to the engine at the V2 licence handshake. Given no
|
|
4
|
+
// NORSK_PRODUCT_NAME it falls back to its baked default, "norsk-studio", and so
|
|
5
|
+
// demands a Studio entitlement rather than the product's own. A repo whose
|
|
6
|
+
// licence is cut for its own product then launches instances that are refused:
|
|
7
|
+
// Studio still serves its API, but every media node is refused, so SRT
|
|
8
|
+
// listeners never bind and the graph produces nothing.
|
|
9
|
+
//
|
|
10
|
+
// That failure is nearly unreadable from outside. It is not a crash and not a
|
|
11
|
+
// timeout at launch — the instance comes up "healthy" and only the media-
|
|
12
|
+
// dependent assertions fail, which reads as a broken workflow rather than a
|
|
13
|
+
// missing declaration. funke-pegasus shipped mis-declared from the day it was
|
|
14
|
+
// created and only surfaced when a licence re-mint stopped carrying a
|
|
15
|
+
// norsk-studio entry; reuters had declared its own name since 2026-07-28.
|
|
16
|
+
//
|
|
17
|
+
// check-template.ts is this lint's other half: it asserts the repo RECORDS the
|
|
18
|
+
// entitlement it needs, and this asserts the repo ASKS for the one it records.
|
|
19
|
+
// Either alone leaves the pair free to drift, which is exactly what happened.
|
|
20
|
+
import { readFileSync } from "node:fs";
|
|
21
|
+
|
|
22
|
+
/** Source with comments blanked out, so a mention of the key in prose cannot
|
|
23
|
+
* satisfy the lint. Walks the text rather than regex-replacing, so a `//`
|
|
24
|
+
* inside a string literal (a URL) is not mistaken for a comment. */
|
|
25
|
+
export function stripComments(source: string): string {
|
|
26
|
+
let out = "";
|
|
27
|
+
let i = 0;
|
|
28
|
+
while (i < source.length) {
|
|
29
|
+
const c = source[i];
|
|
30
|
+
const next = source[i + 1];
|
|
31
|
+
if (c === "/" && next === "/") {
|
|
32
|
+
while (i < source.length && source[i] !== "\n") i++;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (c === "/" && next === "*") {
|
|
36
|
+
i += 2;
|
|
37
|
+
while (i < source.length && !(source[i] === "*" && source[i + 1] === "/")) i++;
|
|
38
|
+
i += 2;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
42
|
+
const quote = c;
|
|
43
|
+
out += c;
|
|
44
|
+
i++;
|
|
45
|
+
while (i < source.length && source[i] !== quote) {
|
|
46
|
+
if (source[i] === "\\") {
|
|
47
|
+
out += source[i];
|
|
48
|
+
i++;
|
|
49
|
+
}
|
|
50
|
+
if (i < source.length) {
|
|
51
|
+
out += source[i];
|
|
52
|
+
i++;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
out += quote;
|
|
56
|
+
i++;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
out += c;
|
|
60
|
+
i++;
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const DECLARATION = /NORSK_PRODUCT_NAME\s*[:=]\s*(PRODUCT_NAME\b|"([^"]*)"|'([^']*)')/;
|
|
66
|
+
|
|
67
|
+
/** `templateSource` is the repo's product-template module — the one that builds
|
|
68
|
+
* the studio service's environment. `product` is the repo's PRODUCT_NAME. */
|
|
69
|
+
export function productNameProblems(templateSource: string, product: string): string[] {
|
|
70
|
+
const match = DECLARATION.exec(stripComments(templateSource));
|
|
71
|
+
if (!match) {
|
|
72
|
+
return [
|
|
73
|
+
`the studio service does not declare NORSK_PRODUCT_NAME, so Studio will ask for "norsk-studio" at the licence handshake instead of "${product}" — set NORSK_PRODUCT_NAME: PRODUCT_NAME in its environment`,
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
const declared = match[2] ?? match[3];
|
|
77
|
+
// The PRODUCT_NAME constant is correct by construction; only a literal can
|
|
78
|
+
// name the wrong thing.
|
|
79
|
+
if (declared !== undefined && declared !== product) {
|
|
80
|
+
return [`NORSK_PRODUCT_NAME is declared as "${declared}" but this repo's product is "${product}"`];
|
|
81
|
+
}
|
|
82
|
+
return [];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (import.meta.main) {
|
|
86
|
+
const [file, product] = process.argv.slice(2);
|
|
87
|
+
if (!file || !product) {
|
|
88
|
+
console.error("usage: check-product-name.ts <product-template-source> <product-name>");
|
|
89
|
+
process.exit(2);
|
|
90
|
+
}
|
|
91
|
+
let contents: string;
|
|
92
|
+
try {
|
|
93
|
+
contents = readFileSync(file, "utf8");
|
|
94
|
+
} catch {
|
|
95
|
+
console.error(`product-name: cannot read ${file}`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
const problems = productNameProblems(contents, product);
|
|
99
|
+
if (problems.length) {
|
|
100
|
+
for (const p of problems) console.error(`product-name: ${p}`);
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
console.log(`product-name: ${file} declares ${product} to Studio`);
|
|
104
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@norskvideo/ctl-dev-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.72",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./create-product": "./create-product/create-product.ts",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"./doc-guide/prose-bundle": "./doc-guide/prose-bundle.js",
|
|
14
14
|
"./docs/path-existence": "./docs/path-existence.ts",
|
|
15
15
|
"./docs/splice-generated": "./docs/splice-generated.ts",
|
|
16
|
+
"./licence/check-product-name": "./licence/check-product-name.ts",
|
|
16
17
|
"./licence/check-template": "./licence/check-template.ts",
|
|
17
18
|
"./package.json": "./package.json",
|
|
18
19
|
"./testing/byte-snapshot": "./testing/byte-snapshot.ts",
|