@norskvideo/ctl-dev-kit 0.2.107 → 0.2.109
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/conventions/DESIGN.family.md +73 -0
- package/conventions/check-drift.ts +100 -0
- package/conventions/sync-drift.ts +21 -1
- package/create-demo/create-demo.ts +191 -0
- package/create-demo/template/core/CLAUDE.md.tmpl +158 -0
- package/create-demo/template/core/README.md.tmpl +74 -0
- package/create-demo/template/core/ctl/install.sh +27 -0
- package/create-demo/template/core/ctl/lib.sh +146 -0
- package/create-demo/template/core/ctl/mode.sh +19 -0
- package/create-demo/template/core/ctl/push.sh +16 -0
- package/create-demo/template/core/ctl/site.example.env +30 -0
- package/create-demo/template/core/ctl/studio.example.env +12 -0
- package/create-demo/template/core/gitignore +18 -0
- package/create-demo/template/core/scripts/build.sh +30 -0
- package/create-demo/template/core/scripts/test-feed.sh +44 -0
- package/create-demo/template/dashboard/dashboard/index.html +13 -0
- package/create-demo/template/dashboard/dashboard/package.json +22 -0
- package/create-demo/template/dashboard/dashboard/src/App.tsx +61 -0
- package/create-demo/template/dashboard/dashboard/src/api/types.ts +38 -0
- package/create-demo/template/dashboard/dashboard/src/components/ImagePreview.tsx +23 -0
- package/create-demo/template/dashboard/dashboard/src/components/StatusPill.tsx +65 -0
- package/create-demo/template/dashboard/dashboard/src/hooks/useAlerts.ts +98 -0
- package/create-demo/template/dashboard/dashboard/src/hooks/useDiscovery.ts +88 -0
- package/create-demo/template/dashboard/dashboard/src/hooks/useEnv.ts +53 -0
- package/create-demo/template/dashboard/dashboard/src/hooks/useLiveComponent.ts +249 -0
- package/create-demo/template/dashboard/dashboard/src/lib/workflow.ts +11 -0
- package/create-demo/template/dashboard/dashboard/src/main.tsx +12 -0
- package/create-demo/template/dashboard/dashboard/src/styles.css +84 -0
- package/create-demo/template/dashboard/dashboard/src/vite-env.d.ts +1 -0
- package/create-demo/template/dashboard/dashboard/tsconfig.json +18 -0
- package/create-demo/template/dashboard/dashboard/vite.config.ts +35 -0
- package/create-product/cli.ts +39 -1
- package/create-product/features/components.ts +10 -1
- package/package.json +1 -1
package/create-product/cli.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// so the bin runs under bun (the fleet's only runtime).
|
|
6
6
|
import { existsSync, readdirSync } from "node:fs";
|
|
7
7
|
import { parseArgs } from "node:util";
|
|
8
|
+
import { createDemo, type DemoFeature } from "../create-demo/create-demo.ts";
|
|
8
9
|
import { createDashboard } from "../dashboard/create-dashboard.ts";
|
|
9
10
|
import { writeDashboardManifest } from "../dashboard/manifest.ts";
|
|
10
11
|
import { createProduct, type ProductFeature, type ProductShape, type StudioLibrary } from "./create-product.ts";
|
|
@@ -13,6 +14,8 @@ const SHAPES: ProductShape[] = ["backend-turnkey", "turnkey"];
|
|
|
13
14
|
|
|
14
15
|
const USAGE = `Usage:
|
|
15
16
|
ctl-dev-kit create-product --name <name> [options] <dir>
|
|
17
|
+
ctl-dev-kit create-demo --name <name> [--with dashboard,components] [--user <user>] <dir>
|
|
18
|
+
a customer demo: a Studio working dir installed into norsk-ctl
|
|
16
19
|
ctl-dev-kit create-dashboard --name <name> <dir> a fleet dashboard norsk-mgr hosts (a live runtime list)
|
|
17
20
|
ctl-dev-kit dashboard-manifest <src> <dist> write <dist>/dashboard.json from a fleet dashboard's calls
|
|
18
21
|
|
|
@@ -57,9 +60,13 @@ export function main(argv: string[]): void {
|
|
|
57
60
|
newDashboard(rest);
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
63
|
+
if (command === "create-demo") {
|
|
64
|
+
newDemo(rest);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
60
67
|
if (command !== "create-product") {
|
|
61
68
|
fail(
|
|
62
|
-
`unknown command ${JSON.stringify(command ?? "")} — the commands are create-product, create-dashboard and dashboard-manifest.`,
|
|
69
|
+
`unknown command ${JSON.stringify(command ?? "")} — the commands are create-product, create-demo, create-dashboard and dashboard-manifest.`,
|
|
63
70
|
);
|
|
64
71
|
}
|
|
65
72
|
const { values, positionals } = parseArgs({
|
|
@@ -172,3 +179,34 @@ Next steps (also in its README):
|
|
|
172
179
|
3. norsk-mgr dashboard register ${values.name} && norsk-mgr dashboard upload ${values.name} dashboard.tar
|
|
173
180
|
`);
|
|
174
181
|
}
|
|
182
|
+
|
|
183
|
+
function newDemo(args: string[]): void {
|
|
184
|
+
const { values, positionals } = parseArgs({
|
|
185
|
+
args,
|
|
186
|
+
allowPositionals: true,
|
|
187
|
+
options: { name: { type: "string" }, with: { type: "string" }, user: { type: "string" } },
|
|
188
|
+
});
|
|
189
|
+
const dir = positionals[0];
|
|
190
|
+
if (!dir) fail("missing <dir>.");
|
|
191
|
+
if (!values.name) fail("missing --name.");
|
|
192
|
+
if (existsSync(dir) && readdirSync(dir).length > 0) fail(`${dir} exists and is not empty — refusing to overwrite.`);
|
|
193
|
+
const withFeatures = values.with
|
|
194
|
+
?.split(",")
|
|
195
|
+
.map((f) => f.trim())
|
|
196
|
+
.filter(Boolean) as DemoFeature[] | undefined;
|
|
197
|
+
let files: string[];
|
|
198
|
+
try {
|
|
199
|
+
({ files } = createDemo({ dir, name: values.name, user: values.user ?? process.env.USER ?? "me", withFeatures }));
|
|
200
|
+
} catch (err) {
|
|
201
|
+
fail(err instanceof Error ? err.message : String(err));
|
|
202
|
+
}
|
|
203
|
+
console.log(`Generated ${files.length} files into ${dir}.
|
|
204
|
+
|
|
205
|
+
Next steps (also in the generated CLAUDE.md):
|
|
206
|
+
1. cd ${dir} && git init
|
|
207
|
+
2. cp ctl/site.example.env ctl/site.env && cp ctl/studio.example.env ctl/studio.env # then fill them in
|
|
208
|
+
3. ctl/install.sh # build, stage the working dir, launch instance ${values.name} in norsk-ctl
|
|
209
|
+
4. scripts/test-feed.sh up # a test picture into the SRT input
|
|
210
|
+
5. Replace the starter workflow in workdir/studio-save-files/${values.name}/ and ctl/push.sh after each change.
|
|
211
|
+
`);
|
|
212
|
+
}
|
|
@@ -608,7 +608,10 @@ export function exampleSidecar(args: ExampleArgs): WorkflowComponent<ExampleConf
|
|
|
608
608
|
`;
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
|
|
611
|
+
/** The components/ workspace alone — its build chain and the example node,
|
|
612
|
+
* without the product glue componentsFiles adds. create-demo uses this: a demo
|
|
613
|
+
* has no backend or shared/, and its build copies lib/ into the working dir. */
|
|
614
|
+
export function componentsWorkspaceFiles(ctx: ShapeContext): GeneratedFile[] {
|
|
612
615
|
return [
|
|
613
616
|
{ path: "components/package.json", content: packageJson(ctx) },
|
|
614
617
|
{ path: "components/tsconfig.json", content: TSCONFIG },
|
|
@@ -621,6 +624,12 @@ export function componentsFiles(ctx: ShapeContext): GeneratedFile[] {
|
|
|
621
624
|
{ path: "components/src/library/example/types.source.yaml", content: EXAMPLE_TYPES_YAML },
|
|
622
625
|
{ path: "components/src/library/example/info.ts", content: exampleInfoTs(ctx) },
|
|
623
626
|
{ path: "components/src/library/example/runtime.ts", content: EXAMPLE_RUNTIME_TS },
|
|
627
|
+
];
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
export function componentsFiles(ctx: ShapeContext): GeneratedFile[] {
|
|
631
|
+
return [
|
|
632
|
+
...componentsWorkspaceFiles(ctx),
|
|
624
633
|
{ path: "backend/src/lib/components.ts", content: BACKEND_LIB_COMPONENTS_TS },
|
|
625
634
|
{ path: "shared/src/workflow/example-config.ts", content: exampleConfigTs(ctx) },
|
|
626
635
|
];
|