decklight 0.8.1 → 0.9.0
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/PLATFORM.md +666 -0
- package/README.md +224 -150
- package/SPEC.md +732 -886
- package/cli/agent-review.mjs +245 -0
- package/cli/agents.mjs +25 -5
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +183 -0
- package/cli/bundle.mjs +383 -31
- package/cli/cast.mjs +7 -7
- package/cli/check.mjs +961 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +44 -19
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +59 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +409 -0
- package/cli/design-system.mjs +429 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +445 -0
- package/cli/edit-look.mjs +388 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2126 -842
- package/cli/enhance.mjs +483 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +65 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +400 -234
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace.mjs +215 -21
- package/cli/narrate.mjs +176 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +943 -0
- package/cli/pdf.mjs +41 -13
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +57 -24
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +14 -12
- package/cli/remote.mjs +11 -11
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +235 -44
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +190 -33
- package/cli/skills.mjs +107 -24
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +515 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +39 -42
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1126 -49
- package/dist/decklight.js +212 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +753 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +1 -1
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +196 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +17 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +461 -48
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
package/cli/units.mjs
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
* distributes that is not a theme or a plugin (MARKETPLACE.md `UNITS`).
|
|
7
7
|
*
|
|
8
8
|
* `MARKETPLACES#CORE` registers catalogs and resolves a name to an entry;
|
|
9
|
-
* `THEME_BROWSE#UI` and `
|
|
10
|
-
* top of it. This is the rest —
|
|
11
|
-
* — and it is deliberately ONE implementation with a type table rather
|
|
12
|
-
*
|
|
13
|
-
* `decklight
|
|
14
|
-
* with a different row.
|
|
9
|
+
* `THEME_BROWSE#UI` and `NO_TRUST#PLUGINS` each installed one kind of thing on
|
|
10
|
+
* top of it. This is the rest — agent skills, import adapters, engines, agents,
|
|
11
|
+
* voices — and it is deliberately ONE implementation with a type table rather
|
|
12
|
+
* than a command per kind that each grew its own copy of
|
|
13
|
+
* resolve-fetch-validate-write. `decklight library add skill` and `decklight library
|
|
14
|
+
* add importer` are the same function with a different row.
|
|
15
15
|
*
|
|
16
16
|
* THE INVARIANT THAT OUTRANKS CONVENIENCE (SPEC MARKETPLACE_REGISTRY):
|
|
17
17
|
* registering is not fetching. Everything here reads the catalog CACHE; the
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
* cannot reach the network at all, so a deck on a plane behaves exactly like a
|
|
21
21
|
* deck at a desk.
|
|
22
22
|
*
|
|
23
|
-
* WHAT IS DELIBERATELY NOT HERE: running an installed unit. A
|
|
24
|
-
*
|
|
23
|
+
* WHAT IS DELIBERATELY NOT HERE: running an installed unit. A skill is
|
|
24
|
+
* Markdown, so it is just files. An import adapter and
|
|
25
25
|
* a build-time transform are both **Node code**, and executing either is one
|
|
26
26
|
* shared capability rather than two copies of resolve-fetch-validate-load —
|
|
27
27
|
* `cli/loader.mjs` (`EXTENSIONS#LOADER`) is that shared loader. `bundle
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
35
35
|
import { createHash } from 'node:crypto';
|
|
36
36
|
import { join, resolve } from 'node:path';
|
|
37
|
-
import { configHome, loadRegistry, loadCatalog, resolveEntry, MarketplaceError } from './marketplace.mjs';
|
|
37
|
+
import { configHome, loadRegistry, loadCatalog, resolveEntry, MarketplaceError, recordInstall, forgetInstall } from './marketplace.mjs';
|
|
38
38
|
|
|
39
39
|
/** A failure with a message for a human — the mains print it, never a stack. */
|
|
40
40
|
export class UnitError extends Error {}
|
|
@@ -50,20 +50,12 @@ export class UnitError extends Error {}
|
|
|
50
50
|
* the adapter for a `.marp` file **offline**, from the cache alone.
|
|
51
51
|
*/
|
|
52
52
|
export const UNIT_TYPES = {
|
|
53
|
-
template: {
|
|
54
|
-
dir: 'templates',
|
|
55
|
-
single: 'html',
|
|
56
|
-
label: 'deck template',
|
|
57
|
-
use: 'decklight init --from <name>',
|
|
58
|
-
example: 'startup-pitch',
|
|
59
|
-
required: [],
|
|
60
|
-
},
|
|
61
53
|
skill: {
|
|
62
54
|
dir: 'skills',
|
|
63
55
|
files: ['SKILL.md'],
|
|
64
56
|
optional: ['reference.md'],
|
|
65
57
|
label: 'agent skill',
|
|
66
|
-
use: 'decklight
|
|
58
|
+
use: 'decklight library add skill <name>',
|
|
67
59
|
example: 'conference-cfp',
|
|
68
60
|
required: [],
|
|
69
61
|
},
|
|
@@ -74,8 +66,8 @@ export const UNIT_TYPES = {
|
|
|
74
66
|
// the code — so an entry installs only against the `sha256` its catalog
|
|
75
67
|
// admitted: refused before any read without one, refused before any write on
|
|
76
68
|
// a mismatch (SPEC UNIT_PINNING). Data kinds stay unpinned: a theme
|
|
77
|
-
// re-passes its whole contract at `theme add`, and nothing in a
|
|
78
|
-
//
|
|
69
|
+
// re-passes its whole contract at `theme add`, and nothing in a skill
|
|
70
|
+
// executes.
|
|
79
71
|
importer: {
|
|
80
72
|
dir: 'importers',
|
|
81
73
|
files: ['importer.mjs'],
|
|
@@ -111,7 +103,7 @@ export const UNIT_TYPES = {
|
|
|
111
103
|
dir: 'engines',
|
|
112
104
|
single: 'mjs',
|
|
113
105
|
label: 'speech engine',
|
|
114
|
-
use: 'decklight
|
|
106
|
+
use: 'decklight setup voice (or decklight <deck> --tts-engine <name>), then the V picker',
|
|
115
107
|
example: 'azure-tts',
|
|
116
108
|
required: ['apiVersion', 'capability'],
|
|
117
109
|
pinned: true,
|
|
@@ -127,7 +119,7 @@ export const UNIT_TYPES = {
|
|
|
127
119
|
single: 'json',
|
|
128
120
|
reference: true,
|
|
129
121
|
label: 'AI agent',
|
|
130
|
-
use: 'A,
|
|
122
|
+
use: 'A, write mode',
|
|
131
123
|
example: 'my-agent',
|
|
132
124
|
note: 'An agent unit is a DESCRIPTOR — which command to run and how to run it\n headlessly. Installing one fetches nothing; you install the agent itself the\n way its own docs say, and this only teaches decklight how to call it.',
|
|
133
125
|
required: ['bin', 'args'],
|
|
@@ -144,7 +136,7 @@ export const UNIT_TYPES = {
|
|
|
144
136
|
single: 'json',
|
|
145
137
|
reference: true,
|
|
146
138
|
label: 'voice',
|
|
147
|
-
use: 'the V picker,
|
|
139
|
+
use: 'the V picker, write mode',
|
|
148
140
|
example: 'narrator-anna',
|
|
149
141
|
note: 'A voice is a REFERENCE — which engine, which of its voices. Installing\n one writes a pointer and fetches nothing, so this is the one add that works\n offline; speaking through it still needs that engine and your own credential.',
|
|
150
142
|
required: ['engine', 'voiceId'],
|
|
@@ -157,7 +149,7 @@ const typeOf = (type) => {
|
|
|
157
149
|
return t;
|
|
158
150
|
};
|
|
159
151
|
|
|
160
|
-
/** Where a type's units live: `~/.decklight/
|
|
152
|
+
/** Where a type's units live: `~/.decklight/skills/`, `…/importers/`, … */
|
|
161
153
|
export const unitDir = (type, home = configHome()) => join(home, typeOf(type).dir);
|
|
162
154
|
|
|
163
155
|
/** Where ONE unit lives — a file for a single-file type, a directory otherwise. */
|
|
@@ -213,7 +205,7 @@ export function catalogEntries(home = configHome()) {
|
|
|
213
205
|
return out;
|
|
214
206
|
}
|
|
215
207
|
|
|
216
|
-
/** Catalog entries of one type, cache-only — "what
|
|
208
|
+
/** Catalog entries of one type, cache-only — "what skills could I install?" */
|
|
217
209
|
export const catalogEntriesOfType = (type, home = configHome()) =>
|
|
218
210
|
catalogEntries(home).filter((e) => e.type === type);
|
|
219
211
|
|
|
@@ -307,7 +299,7 @@ export async function installUnit(type, ref, home = configHome(), { fetchImpl =
|
|
|
307
299
|
}
|
|
308
300
|
if (hit.entry.type !== type) {
|
|
309
301
|
throw new UnitError(`${hit.qualified} is a ${hit.entry.type}, not a ${type}`
|
|
310
|
-
+ `${UNIT_TYPES[hit.entry.type] ? ` — try: decklight ${hit.entry.type}
|
|
302
|
+
+ `${UNIT_TYPES[hit.entry.type] ? ` — try: decklight library add ${hit.entry.type} ${ref}` : ''}`);
|
|
311
303
|
}
|
|
312
304
|
|
|
313
305
|
// A reference-only kind is fully installed by the catalog entry it resolved
|
|
@@ -317,6 +309,7 @@ export async function installUnit(type, ref, home = configHome(), { fetchImpl =
|
|
|
317
309
|
const { name, type: _t, source: _s, ...rest } = hit.entry;
|
|
318
310
|
mkdirSync(unitDir(type, home), { recursive: true });
|
|
319
311
|
writeFileSync(dest, `${JSON.stringify({ name, ...rest, marketplace: hit.marketplace }, null, 2)}\n`);
|
|
312
|
+
recordInstall({ type, name, marketplace: hit.marketplace, version: hit.entry.version, commit: reg.marketplaces[hit.marketplace]?.commit }, home);
|
|
320
313
|
return { name, qualified: hit.qualified, entry: hit.entry, path: dest, files: [] };
|
|
321
314
|
}
|
|
322
315
|
|
|
@@ -326,7 +319,7 @@ export async function installUnit(type, ref, home = configHome(), { fetchImpl =
|
|
|
326
319
|
if (t.pinned && !hit.entry.sha256) {
|
|
327
320
|
throw new UnitError(`${hit.qualified} carries no sha256 — a ${t.label} is Node code decklight`
|
|
328
321
|
+ ` runs unsandboxed, so it installs only pinned to the digest its catalog admitted`
|
|
329
|
-
+ ` (SPEC UNIT_PINNING). Ask the marketplace to pin the entry; decklight
|
|
322
|
+
+ ` (SPEC UNIT_PINNING). Ask the marketplace to pin the entry; decklight library gate transform`
|
|
330
323
|
+ ` prints the digest to use`);
|
|
331
324
|
}
|
|
332
325
|
|
|
@@ -394,14 +387,18 @@ export async function installUnit(type, ref, home = configHome(), { fetchImpl =
|
|
|
394
387
|
mkdirSync(dest, { recursive: true });
|
|
395
388
|
for (const [file, text] of fetched) writeFileSync(join(dest, file), text);
|
|
396
389
|
}
|
|
390
|
+
// what was taken, at which version and commit — what `marketplace update`
|
|
391
|
+
// later compares the catalog against (#616)
|
|
392
|
+
recordInstall({ type, name: hit.entry.name, marketplace: hit.marketplace, version: hit.entry.version, commit: reg.marketplaces[hit.marketplace]?.commit }, home);
|
|
397
393
|
return { name: hit.entry.name, qualified: hit.qualified, entry: hit.entry, path: dest, files: fetched.map(([f]) => f).filter(Boolean) };
|
|
398
394
|
}
|
|
399
395
|
|
|
400
396
|
/** Delete an installed unit. */
|
|
401
397
|
export function removeUnit(type, name, home = configHome()) {
|
|
402
398
|
const p = unitPath(type, name, home);
|
|
403
|
-
if (!existsSync(p)) throw new UnitError(`no ${type} "${name}" installed (decklight ${type}
|
|
399
|
+
if (!existsSync(p)) throw new UnitError(`no ${type} "${name}" installed (decklight library list ${type})`);
|
|
404
400
|
rmSync(p, { recursive: true, force: true });
|
|
401
|
+
forgetInstall({ type, name }, home);
|
|
405
402
|
return p;
|
|
406
403
|
}
|
|
407
404
|
|
|
@@ -409,16 +406,16 @@ export function removeUnit(type, name, home = configHome()) {
|
|
|
409
406
|
|
|
410
407
|
export const unitUsage = (type) => {
|
|
411
408
|
const t = typeOf(type);
|
|
412
|
-
return `usage: decklight
|
|
409
|
+
return `usage: decklight library <add|list|remove> ${type} …
|
|
413
410
|
|
|
414
|
-
decklight ${type}
|
|
411
|
+
decklight library add ${type} <name[@marketplace]>
|
|
415
412
|
install a ${t.label} from a registered marketplace into ~/.decklight/${t.dir}/
|
|
416
|
-
EXAMPLE: decklight ${type}
|
|
413
|
+
EXAMPLE: decklight library add ${type} ${t.example}${t.note ? `\n\n ${t.note}` : ''}
|
|
417
414
|
|
|
418
|
-
decklight ${type}
|
|
415
|
+
decklight library list ${type}
|
|
419
416
|
what is installed, and what the registered catalogs offer that is not
|
|
420
417
|
|
|
421
|
-
decklight ${type}
|
|
418
|
+
decklight library remove ${type} <name>
|
|
422
419
|
delete it from your library
|
|
423
420
|
|
|
424
421
|
used by: ${t.use}
|
|
@@ -430,14 +427,14 @@ export const unitUsage = (type) => {
|
|
|
430
427
|
|
|
431
428
|
async function addMain(type, args, home) {
|
|
432
429
|
const [ref] = args.filter((a) => !a.startsWith('-'));
|
|
433
|
-
if (!ref) { console.error(`decklight ${type}
|
|
430
|
+
if (!ref) { console.error(`decklight library add ${type}: needs a name\n\n${unitUsage(type)}`); return 1; }
|
|
434
431
|
let done;
|
|
435
432
|
try { done = await installUnit(type, ref, home); } catch (e) {
|
|
436
433
|
if (!(e instanceof UnitError)) throw e;
|
|
437
|
-
console.error(`decklight ${type}
|
|
434
|
+
console.error(`decklight library add ${type}: ${e.message}`);
|
|
438
435
|
return 1;
|
|
439
436
|
}
|
|
440
|
-
console.log(`installed ${done.name} from ${done.qualified} — ${UNIT_TYPES[type].use}`);
|
|
437
|
+
console.log(`installed ${done.name}${done.entry.version ? ` ${done.entry.version}` : ''} from ${done.qualified} — ${UNIT_TYPES[type].use}`);
|
|
441
438
|
if (done.entry.description) console.log(` ${done.entry.description}`);
|
|
442
439
|
return 0;
|
|
443
440
|
}
|
|
@@ -459,7 +456,7 @@ function listMain(type, home) {
|
|
|
459
456
|
}
|
|
460
457
|
const rest = offered.filter((e) => !have.has(e.name));
|
|
461
458
|
if (rest.length) {
|
|
462
|
-
console.log(installed.length ? `\navailable (decklight ${type}
|
|
459
|
+
console.log(installed.length ? `\navailable (decklight library add ${type} <name>):` : `available (decklight library add ${type} <name>):`);
|
|
463
460
|
for (const e of rest) console.log(` ${e.qualified}${e.description ? ` — ${e.description}` : ''}`);
|
|
464
461
|
}
|
|
465
462
|
return 0;
|
|
@@ -467,17 +464,17 @@ function listMain(type, home) {
|
|
|
467
464
|
|
|
468
465
|
function removeMain(type, args, home) {
|
|
469
466
|
const [name] = args.filter((a) => !a.startsWith('-'));
|
|
470
|
-
if (!name) { console.error(`decklight ${type}
|
|
467
|
+
if (!name) { console.error(`decklight library remove ${type}: which one?\n\n${unitUsage(type)}`); return 1; }
|
|
471
468
|
try { removeUnit(type, name, home); } catch (e) {
|
|
472
469
|
if (!(e instanceof UnitError)) throw e;
|
|
473
|
-
console.error(`decklight ${type}
|
|
470
|
+
console.error(`decklight library remove ${type}: ${e.message}`);
|
|
474
471
|
return 1;
|
|
475
472
|
}
|
|
476
473
|
console.log(`removed ${name}`);
|
|
477
474
|
return 0;
|
|
478
475
|
}
|
|
479
476
|
|
|
480
|
-
/** `decklight
|
|
477
|
+
/** `decklight library <add|list|remove> <type>` — one implementation for every unit kind. */
|
|
481
478
|
export async function unitMain(type, args = []) {
|
|
482
479
|
const sub = args[0];
|
|
483
480
|
if (!sub || sub === '--help' || sub === '-h' || sub === 'help') { console.log(unitUsage(type)); return sub ? 0 : 1; }
|
|
@@ -490,11 +487,11 @@ export async function unitMain(type, args = []) {
|
|
|
490
487
|
if (sub === 'remove') return removeMain(type, rest, home);
|
|
491
488
|
} catch (e) {
|
|
492
489
|
if (e instanceof UnitError || e instanceof MarketplaceError) {
|
|
493
|
-
console.error(`decklight ${
|
|
490
|
+
console.error(`decklight library ${sub} ${type}: ${e.message}`);
|
|
494
491
|
return 1;
|
|
495
492
|
}
|
|
496
493
|
throw e;
|
|
497
494
|
}
|
|
498
|
-
console.error(`decklight
|
|
495
|
+
console.error(`decklight library: unknown verb "${sub}" for a ${type}\n\n${unitUsage(type)}`);
|
|
499
496
|
return 1;
|
|
500
497
|
}
|
package/cli/update-check.mjs
CHANGED
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { spawn } from 'node:child_process';
|
|
28
|
-
import {
|
|
28
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
29
29
|
import { join } from 'node:path';
|
|
30
30
|
import { fileURLToPath } from 'node:url';
|
|
31
31
|
import { configHome } from './marketplace.mjs';
|
|
@@ -150,7 +150,3 @@ if (isMain(import.meta.url)) {
|
|
|
150
150
|
await refreshMain();
|
|
151
151
|
process.exit(0);
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
// `existsSync` is imported for the cache-dir check callers may want; keep the
|
|
155
|
-
// surface honest if it stops being used.
|
|
156
|
-
export const cacheExists = (home = configHome()) => existsSync(cachePath(home));
|
package/cli/upgrade.mjs
CHANGED
|
@@ -22,14 +22,16 @@
|
|
|
22
22
|
*
|
|
23
23
|
* In place, with <deck>.html.bak written first; --dry-run prints what would
|
|
24
24
|
* change and touches nothing; a second run reports "already current". A file
|
|
25
|
-
* with no Decklight.init call
|
|
26
|
-
*
|
|
25
|
+
* with no Decklight.init call is refused. A multi-module deck (the kind
|
|
26
|
+
* bundle --all writes) is upgraded like any other deck, with a note that a later
|
|
27
|
+
* re-merge would overwrite it (#483).
|
|
27
28
|
*/
|
|
28
29
|
|
|
29
30
|
import fs from 'node:fs';
|
|
30
31
|
import path from 'node:path';
|
|
31
32
|
import { makeFail, runMain } from './util.mjs';
|
|
32
33
|
import { PKG, PKG_ROOT, runtimeCss, runtimeJs } from './pkg.mjs';
|
|
34
|
+
import { bootCall, configBlock, configBlockHtml, configVersion, hasEmbeddedRuntime, isDeck, lineSpan, parseLiteral, withConfigVersion } from './runtime-link.mjs';
|
|
33
35
|
import { isMain } from '../tools/args.mjs';
|
|
34
36
|
|
|
35
37
|
|
|
@@ -54,15 +56,19 @@ const kb = (s) => `${(Buffer.byteLength(s) / 1024).toFixed(1)} KB`;
|
|
|
54
56
|
*/
|
|
55
57
|
const maskComments = (html) => html.replace(/<!--[\s\S]*?-->/g, (m) => m.replace(/[^\n]/g, ' '));
|
|
56
58
|
|
|
57
|
-
// Exported because the ingredients label (cli/audit.mjs,
|
|
59
|
+
// Exported because the ingredients label (cli/audit.mjs, NO_TRUST#AUDIT) has to
|
|
58
60
|
// enumerate exactly the blocks this command knows how to find. Two scanners
|
|
59
61
|
// that drift apart would mean upgrade rewriting a block the audit calls
|
|
60
62
|
// unaccounted, or the reverse — so there is one of each.
|
|
61
63
|
export function headStyles(html) {
|
|
62
|
-
const
|
|
64
|
+
const masked = maskComments(html);
|
|
65
|
+
// The boundary comes from the MASKED copy too: read from the raw html, a
|
|
66
|
+
// `</head>` mentioned in a comment ended the head early and dropped every
|
|
67
|
+
// real style below it — upgrade then warned "no runtime <style> block" and
|
|
68
|
+
// left the css at the old version while reporting the js upgraded.
|
|
69
|
+
const headEnd = masked.search(/<\/head>/i);
|
|
63
70
|
const out = [];
|
|
64
71
|
const re = /<style\b([^>]*)>([\s\S]*?)<\/style>/gi;
|
|
65
|
-
const masked = maskComments(html);
|
|
66
72
|
let m;
|
|
67
73
|
while ((m = re.exec(masked))) {
|
|
68
74
|
if (headEnd !== -1 && m.index >= headEnd) break;
|
|
@@ -99,14 +105,30 @@ tool (and init) writes and older unmarked init/bundle output are recognized.
|
|
|
99
105
|
|
|
100
106
|
Options:
|
|
101
107
|
--dry-run print what would change; write nothing
|
|
108
|
+
--link the reverse of bundle: the deck becomes slides plus a JSON
|
|
109
|
+
configuration block (the shape init writes). The embedded — or
|
|
110
|
+
referenced — runtime, stylesheet and shipped themes go; the
|
|
111
|
+
server in either mode and every render add the installed ones
|
|
112
|
+
as they serve it, and the active theme is named in the block. The
|
|
113
|
+
Decklight.init(…) argument becomes the block when it is plain
|
|
114
|
+
data; a call whose argument is code stays, as the JS API's
|
|
115
|
+
escape hatch. Everything the author wrote survives
|
|
116
|
+
byte-for-byte; a theme added from outside decklight stays
|
|
117
|
+
embedded.
|
|
118
|
+
|
|
119
|
+
A deck that is data, or that links the runtime, is always current — it runs
|
|
120
|
+
whatever is installed — so upgrade only refreshes the version it records
|
|
121
|
+
itself as written for (the block's "decklight", or data-decklight-version on
|
|
122
|
+
the <script src>), which is what --no-trust --audit compares.
|
|
102
123
|
`);
|
|
103
124
|
return 0;
|
|
104
125
|
}
|
|
105
126
|
|
|
106
|
-
let file = null, dryRun = false;
|
|
127
|
+
let file = null, dryRun = false, link = false;
|
|
107
128
|
for (const a of argv) {
|
|
108
129
|
if (a === '--dry-run') dryRun = true;
|
|
109
|
-
else if (a === '--
|
|
130
|
+
else if (a === '--link') link = true;
|
|
131
|
+
else if (a === '--all') fail('--all is bundle\'s merge flag, not an upgrade flag — upgrade takes one deck');
|
|
110
132
|
else if (!a.startsWith('-')) file = file ?? a;
|
|
111
133
|
else fail(`unknown argument: ${a}`);
|
|
112
134
|
}
|
|
@@ -116,41 +138,113 @@ Options:
|
|
|
116
138
|
const html = fs.readFileSync(deckPath, 'utf8');
|
|
117
139
|
const rel = path.relative('.', deckPath) || file;
|
|
118
140
|
|
|
119
|
-
if (
|
|
120
|
-
fail(`${rel} is not a Decklight deck (no
|
|
141
|
+
if (!isDeck(html)) {
|
|
142
|
+
fail(`${rel} is not a Decklight deck (no <div class="decklight"> found) — nothing to upgrade`);
|
|
121
143
|
}
|
|
144
|
+
// A multi-module deck upgrades like any other deck (#483).
|
|
145
|
+
//
|
|
146
|
+
// It used to be refused, and the reasoning was sound as far as it went: the
|
|
147
|
+
// per-module sources are the real deck, so upgrade those and re-merge, or a
|
|
148
|
+
// later `bundle --all` overwrites whatever was done here. What the refusal
|
|
149
|
+
// assumed is that those files still exist. A multi-module deck that has been
|
|
150
|
+
// hand-edited ever since, with the sources long gone, IS the source of
|
|
151
|
+
// truth — and there the refusal protected a workflow nobody had, leaving
|
|
152
|
+
// commenting out this block as the only way through.
|
|
153
|
+
//
|
|
154
|
+
// So it is a note, not a wall. Said once, below, with the other warnings.
|
|
155
|
+
//
|
|
122
156
|
// "data-module" alone also appears inside the runtime js; requiring the
|
|
123
157
|
// literal "<section" prefix (absent from the runtime) keeps this precise.
|
|
124
|
-
|
|
125
|
-
fail(`${rel} is a merged multi-module bundle (bundle --all) — upgrade works on single decks; upgrade the source modules, then re-merge`);
|
|
126
|
-
}
|
|
158
|
+
const multiModule = /<section\b[^>]*\bdata-module\s*=/i.test(html);
|
|
127
159
|
|
|
128
160
|
// ------------------------------------------------------ runtime js block
|
|
129
161
|
|
|
130
162
|
const allScripts = scripts(html);
|
|
131
|
-
|
|
132
|
-
|
|
163
|
+
const styles = headStyles(html);
|
|
164
|
+
const isSrc = (s) => /\bsrc\s*=/i.test(s.attrs);
|
|
165
|
+
const definesRuntime = (s) => /(?:\bvar\s+|\bwindow\.)Decklight\s*=/.test(s.inner);
|
|
166
|
+
const linked = allScripts.find((s) => /\bsrc\s*=\s*["'][^"']*decklight[^"']*\.js["']/i.test(s.attrs)) ?? null;
|
|
167
|
+
|
|
168
|
+
// ------------------------------------------------- a deck that is data
|
|
169
|
+
|
|
170
|
+
// Slides plus a configuration block, no runtime in the file (#520): it runs
|
|
171
|
+
// whatever is installed, so it is always current. What it can be behind on
|
|
172
|
+
// is its own record of the version it was written for — the block's
|
|
173
|
+
// `decklight` key, which --no-trust --audit compares — and that is what is
|
|
174
|
+
// refreshed. --link asks for the shape it already has.
|
|
175
|
+
if (!linked && !hasEmbeddedRuntime(html)) {
|
|
176
|
+
const block = configBlock(html);
|
|
177
|
+
if (link) { process.stdout.write(`${rel} is already slides and a configuration block — no runtime in the file\n`); return; }
|
|
178
|
+
if (!block) {
|
|
179
|
+
process.stdout.write(`${rel} carries no runtime and no configuration block — it plays with whatever is installed; nothing to record\n`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (block.error) fail(`${rel}: ${block.error}`);
|
|
183
|
+
const was = configVersion(html);
|
|
184
|
+
if (was === PKG.version) {
|
|
185
|
+
process.stdout.write(`${rel} is slides and a configuration block, written for decklight ${PKG.version} — already current\n`);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const next = withConfigVersion(html, PKG.version);
|
|
189
|
+
if (next === null) fail(`${rel}: could not record the version in the configuration block`);
|
|
190
|
+
if (dryRun) {
|
|
191
|
+
process.stdout.write(`${rel} — would record it as written for decklight ${PKG.version}${was ? ` (was ${was})` : ''}; nothing else changes (dry run)\n`);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
fs.writeFileSync(`${deckPath}.bak`, html);
|
|
195
|
+
fs.writeFileSync(deckPath, next);
|
|
196
|
+
process.stdout.write(`${rel} — now recorded as written for decklight ${PKG.version}${was ? ` (was ${was})` : ''}; backup: ${rel}.bak\n`);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// ------------------------------------------- a deck that links the runtime
|
|
201
|
+
|
|
202
|
+
// The referenced shape (#517), always current for the same reason; without
|
|
203
|
+
// --link, only its record on the <script src> is refreshed.
|
|
204
|
+
if (linked && !link) {
|
|
205
|
+
const wasM = /\bdata-decklight-version\s*=\s*["']([^"']*)["']/i.exec(linked.attrs);
|
|
206
|
+
const was = wasM?.[1] ?? null;
|
|
207
|
+
if (was === PKG.version) {
|
|
208
|
+
process.stdout.write(`${rel} links the runtime and is written for decklight ${PKG.version} — already current\n`);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
const attrs = wasM
|
|
212
|
+
? linked.attrs.replace(wasM[0], `data-decklight-version="${PKG.version}"`)
|
|
213
|
+
: `${linked.attrs} data-decklight-version="${PKG.version}"`;
|
|
214
|
+
const next = `${html.slice(0, linked.start)}<script${attrs}>${linked.inner}</script>${html.slice(linked.end)}`;
|
|
215
|
+
if (dryRun) {
|
|
216
|
+
process.stdout.write(`${rel} links the runtime — would record it as written for decklight ${PKG.version}${was ? ` (was ${was})` : ''}; nothing else changes (dry run)\n`);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
fs.writeFileSync(`${deckPath}.bak`, html);
|
|
220
|
+
fs.writeFileSync(deckPath, next);
|
|
221
|
+
process.stdout.write(`${rel} links the runtime — now recorded as written for decklight ${PKG.version}${was ? ` (was ${was})` : ''}; backup: ${rel}.bak\n`);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ------------------------------------------------------ runtime js block
|
|
226
|
+
|
|
227
|
+
let jsBlock = linked ? null
|
|
228
|
+
: allScripts.find((s) => /\bdata-decklight-runtime\b/i.test(s.attrs) && !isSrc(s)) ?? null;
|
|
229
|
+
if (!jsBlock && !linked) {
|
|
133
230
|
// Unmarked deck: the runtime is the <script> defining Decklight, before
|
|
134
231
|
// the <script>Decklight.init(...) call (init and bundle both write them
|
|
135
232
|
// adjacent; scanning back tolerates an author script slipped between).
|
|
136
|
-
const definesRuntime = (s) => /(?:\bvar\s+|\bwindow\.)Decklight\s*=/.test(s.inner);
|
|
137
233
|
const initAt = allScripts.findIndex((s) =>
|
|
138
|
-
|
|
234
|
+
!isSrc(s) && /Decklight\.init\s*\(/.test(s.inner) && !definesRuntime(s));
|
|
139
235
|
for (let i = initAt - 1; i >= 0; i--) {
|
|
140
236
|
const s = allScripts[i];
|
|
141
|
-
if (
|
|
237
|
+
if (!isSrc(s) && definesRuntime(s)) { jsBlock = s; break; }
|
|
142
238
|
}
|
|
239
|
+
// no init call: a bundle of a deck that boots from its configuration block
|
|
240
|
+
if (!jsBlock && initAt === -1) jsBlock = allScripts.find((s) => !isSrc(s) && definesRuntime(s)) ?? null;
|
|
143
241
|
if (!jsBlock) {
|
|
144
|
-
if (allScripts.some((s) => /\bsrc\s*=\s*["'][^"']*decklight[^"']*\.js["']/i.test(s.attrs))) {
|
|
145
|
-
fail(`${rel} references the runtime by src= — it is not self-contained, so there is nothing inlined to upgrade (its decklight.{js,css} files are the thing to update; decklight bundle produces a self-contained file)`);
|
|
146
|
-
}
|
|
147
242
|
fail(`${rel}: could not find the inlined runtime (no <script> defining Decklight before the Decklight.init call)`);
|
|
148
243
|
}
|
|
149
244
|
}
|
|
150
245
|
|
|
151
246
|
// ----------------------------------------------------- runtime css block
|
|
152
247
|
|
|
153
|
-
const styles = headStyles(html);
|
|
154
248
|
const cssBlock =
|
|
155
249
|
styles.find((s) => /\bdata-decklight-runtime\b/i.test(s.attrs))
|
|
156
250
|
// unmarked: the first head style that is not a theme block and carries
|
|
@@ -166,26 +260,96 @@ Options:
|
|
|
166
260
|
const edits = []; // { start, end, text }
|
|
167
261
|
const changed = [];
|
|
168
262
|
const warnings = [];
|
|
263
|
+
if (multiModule) {
|
|
264
|
+
warnings.push('this is a multi-module deck (bundle --all). If the per-module'
|
|
265
|
+
+ ' sources still exist, upgrading those and re-merging keeps the merge reproducible —'
|
|
266
|
+
+ ' a later `bundle --all` overwrites this file');
|
|
267
|
+
}
|
|
169
268
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
269
|
+
if (link) {
|
|
270
|
+
// The reverse of bundle (#520): the deck becomes slides plus a
|
|
271
|
+
// configuration block. The runtime — embedded, or referenced (#517) —
|
|
272
|
+
// and its stylesheet go; the ACTIVE theme becomes the block's `theme`
|
|
273
|
+
// and the other shipped themes go too, since the servers link any of
|
|
274
|
+
// them from the package; a theme that is not decklight's stays embedded.
|
|
275
|
+
// The Decklight.init(…) argument becomes the block when it is data; a
|
|
276
|
+
// call that is code stays, as the JS API's escape hatch, and the servers
|
|
277
|
+
// put the engine in front of it.
|
|
278
|
+
const drop = (s) => { const span = lineSpan(html, s.start, s.end); edits.push({ ...span, text: '' }); };
|
|
279
|
+
const kb_ = (s) => (s.inner ? kb(s.inner) : 'a link');
|
|
280
|
+
const rtTag = linked ?? jsBlock;
|
|
281
|
+
drop(rtTag);
|
|
282
|
+
changed.push(`runtime js (${kb_(rtTag)} → gone; the servers add it)`);
|
|
283
|
+
const cssLink = [...html.matchAll(/<link\b[^>]*\bhref\s*=\s*["'][^"']*decklight(?:\.min)?\.css(?:[?#][^"']*)?["'][^>]*>/gi)][0];
|
|
284
|
+
if (cssBlock) { drop(cssBlock); changed.push(`runtime css (${kb(cssBlock.inner)} → gone)`); }
|
|
285
|
+
else if (cssLink) { drop({ start: cssLink.index, end: cssLink.index + cssLink[0].length }); changed.push('runtime css (a link → gone)'); }
|
|
286
|
+
let active = null; let dropped = 0; let kept = 0;
|
|
287
|
+
const themeBlocks = styles.filter((s) => s !== cssBlock && /\bdata-theme\s*=\s*["'][\w-]+["']/i.test(s.attrs));
|
|
288
|
+
for (const s of themeBlocks) {
|
|
289
|
+
const name = s.attrs.match(/\bdata-theme\s*=\s*["']([\w-]+)["']/i)[1];
|
|
290
|
+
const shipped = fs.existsSync(path.join(PKG_ROOT, 'themes', `${name}.css`)) && !/\bdata-theme-added\b/i.test(s.attrs);
|
|
291
|
+
if (!shipped) { kept++; continue; }
|
|
292
|
+
const isActive = !/\bmedia\s*=\s*["']not all["']/i.test(s.attrs);
|
|
293
|
+
if (isActive && !active) active = name;
|
|
294
|
+
else dropped++;
|
|
295
|
+
drop(s);
|
|
296
|
+
}
|
|
297
|
+
const themeLink = [...html.matchAll(/<link\b[^>]*\bhref\s*=\s*["'][^"']*themes\/([\w-]+)\.css(?:[?#][^"']*)?["'][^>]*>/gi)][0];
|
|
298
|
+
if (themeLink && !active) {
|
|
299
|
+
active = themeLink[1];
|
|
300
|
+
drop({ start: themeLink.index, end: themeLink.index + themeLink[0].length });
|
|
301
|
+
}
|
|
302
|
+
if (active) changed.push(`theme ${active} → the configuration block${dropped ? `, ${dropped} embedded theme${dropped === 1 ? '' : 's'} dropped (the picker fetches any shipped theme)` : ''}`);
|
|
303
|
+
if (kept) warnings.push(`${kept} theme${kept === 1 ? '' : 's'} not decklight's stay embedded`);
|
|
304
|
+
|
|
305
|
+
// the configuration: the block the deck has, or the init call as data
|
|
306
|
+
const boot = bootCall(html);
|
|
307
|
+
const existing = configBlock(html);
|
|
308
|
+
let config = existing?.config ?? null;
|
|
309
|
+
if (existing?.error) fail(`${rel}: ${existing.error}`);
|
|
310
|
+
if (boot) {
|
|
311
|
+
const parsed = parseLiteral(boot.arg);
|
|
312
|
+
if (parsed) {
|
|
313
|
+
config = { ...(config ?? {}), ...parsed.value };
|
|
314
|
+
drop(boot);
|
|
315
|
+
changed.push('the Decklight.init call → the configuration block');
|
|
316
|
+
} else {
|
|
317
|
+
warnings.push('the Decklight.init argument is code, not data — the call stays as the JS API\'s escape hatch, and the servers put the engine in front of it');
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (active && !kept) config = { ...(config ?? {}), theme: active };
|
|
321
|
+
if (existing) {
|
|
322
|
+
const inner = `\n${configBlockHtml(config ?? {}).split('\n').slice(1, -1).join('\n')}\n${' '.repeat(2)}`;
|
|
323
|
+
edits.push({ start: existing.innerStart, end: existing.innerEnd, text: inner });
|
|
324
|
+
} else if (config !== null || boot === null) {
|
|
325
|
+
// before </head>, on its own line, where init writes it
|
|
326
|
+
const headEnd = html.search(/<\/head>/i);
|
|
327
|
+
const at = headEnd !== -1 ? headEnd : (boot ? boot.start : html.search(/<body\b/i));
|
|
328
|
+
if (at === -1) fail(`${rel}: no <head> to hold the configuration block`);
|
|
329
|
+
edits.push({ start: at, end: at, text: `${configBlockHtml(config ?? {})}\n` });
|
|
330
|
+
if (!boot) changed.push('a configuration block added');
|
|
331
|
+
}
|
|
332
|
+
} else {
|
|
333
|
+
edits.push({ start: jsBlock.start, end: jsBlock.end,
|
|
334
|
+
text: `<script data-decklight-runtime="js">${distJs}</script>` });
|
|
335
|
+
if (edits[0].text !== jsBlock.tag) changed.push(`runtime js (${kb(jsBlock.inner)} → ${kb(distJs)})`);
|
|
336
|
+
}
|
|
173
337
|
|
|
174
|
-
if (cssBlock) {
|
|
338
|
+
if (cssBlock && !link) {
|
|
175
339
|
// Keep the closing tag's own indentation so a marked, current deck
|
|
176
340
|
// round-trips byte-identical (init writes "\n<css>\n </style>").
|
|
177
341
|
const closeIndent = (cssBlock.inner.match(/\n([ \t]*)$/) || [, ''])[1];
|
|
178
342
|
const text = `<style data-decklight-runtime="css">\n${distCss}\n${closeIndent}</style>`;
|
|
179
343
|
edits.push({ start: cssBlock.start, end: cssBlock.end, text });
|
|
180
344
|
if (text !== cssBlock.tag) changed.push(`runtime css (${kb(cssBlock.inner)} → ${kb(distCss)})`);
|
|
181
|
-
} else {
|
|
345
|
+
} else if (!cssBlock) {
|
|
182
346
|
warnings.push('no runtime <style> block found in <head> — css left alone');
|
|
183
347
|
}
|
|
184
348
|
|
|
185
349
|
// ----------------------------------------------------------- theme blocks
|
|
186
350
|
|
|
187
351
|
let themesRefreshed = 0, themesCurrent = 0;
|
|
188
|
-
for (const s of styles) {
|
|
352
|
+
for (const s of link ? [] : styles) {
|
|
189
353
|
if (s === cssBlock) continue;
|
|
190
354
|
const nameM = s.attrs.match(/\bdata-theme\s*=\s*["']([\w-]+)["']/i);
|
|
191
355
|
if (!nameM) continue; // generated blocks (valueless data-theme) stay the author's
|
|
@@ -244,7 +408,9 @@ Options:
|
|
|
244
408
|
|
|
245
409
|
fs.writeFileSync(`${deckPath}.bak`, html);
|
|
246
410
|
fs.writeFileSync(deckPath, next);
|
|
247
|
-
process.stdout.write(
|
|
411
|
+
process.stdout.write(link
|
|
412
|
+
? `${rel} is now slides and a configuration block, written for decklight ${PKG.version} (${changed.join(', ')}; backup: ${rel}.bak)\n`
|
|
413
|
+
: `upgraded ${rel} to decklight ${PKG.version} (${changed.join(', ')}; backup: ${rel}.bak)\n`);
|
|
248
414
|
}
|
|
249
415
|
|
|
250
416
|
if (isMain(import.meta.url)) process.exitCode = await runMain('upgrade', upgradeMain);
|
package/cli/upstream.mjs
CHANGED
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* the no-trust mode's upstream check — SPEC PRESENTING (`NO_TRUST#UPSTREAM`).
|
|
6
6
|
*
|
|
7
|
-
* A deck cloned before a talk goes stale silently:
|
|
7
|
+
* A deck cloned before a talk goes stale silently: the no-trust mode reads the file
|
|
8
8
|
* once and serves those bytes, so a fix the author pushed an hour ago is
|
|
9
9
|
* invisible. This asks the upstream, and — with `--upstream-pull` — lets the
|
|
10
10
|
* deck fast-forward to it.
|
|
11
11
|
*
|
|
12
12
|
* ## What makes this safe, in one place
|
|
13
13
|
*
|
|
14
|
-
* The feature is UNREACHABLE for the deck the rest of `
|
|
14
|
+
* The feature is UNREACHABLE for the deck the rest of `--no-trust` is written
|
|
15
15
|
* against. A deck you were emailed is a single file with no repository, no
|
|
16
16
|
* remote and no upstream, so `resolveUpstream` returns `no-repo` and nothing —
|
|
17
17
|
* not the routes, not the timer — is ever registered.
|
|
@@ -228,6 +228,7 @@ export function canPull(status, { offered = false } = {}) {
|
|
|
228
228
|
*/
|
|
229
229
|
export function upstreamSuppressed({ args = [], env = process.env } = {}) {
|
|
230
230
|
if (args.includes('--no-upstream')) return '--no-upstream';
|
|
231
|
+
if (args.includes('--audit')) return '--audit';
|
|
231
232
|
if (args.includes('--check')) return '--check';
|
|
232
233
|
if (env.DECKLIGHT_NO_UPSTREAM_CHECK) return 'DECKLIGHT_NO_UPSTREAM_CHECK is set';
|
|
233
234
|
if (env.CI) return 'CI';
|
package/cli/util.mjs
CHANGED
|
@@ -93,7 +93,7 @@ export async function runMain(cmd, fn) {
|
|
|
93
93
|
* differ by two letters and both mean "record".
|
|
94
94
|
*
|
|
95
95
|
* Getting it wrong used to be silent in the direction that mattered.
|
|
96
|
-
* `decklight
|
|
96
|
+
* `decklight narrate --mic demo.term.yaml` started a server, printed a URL and opened
|
|
97
97
|
* a browser on a YAML file: no error anywhere, just a page that would never be
|
|
98
98
|
* a deck. (The other way at least failed, if unhelpfully — `script has no
|
|
99
99
|
* steps`, said of a perfectly good deck.)
|
|
@@ -106,7 +106,7 @@ export function wrongRecorder(cmd, file) {
|
|
|
106
106
|
const name = String(file ?? '');
|
|
107
107
|
const isScript = /\.ya?ml$/i.test(name);
|
|
108
108
|
const isDeck = /\.(html?|decklight)$/i.test(name);
|
|
109
|
-
const wrong = (cmd === '
|
|
109
|
+
const wrong = (cmd === 'narrate' && isScript) || (cmd === 'cast' && isDeck);
|
|
110
110
|
if (!wrong) return null;
|
|
111
111
|
const what = isScript ? 'a terminal script, not a deck' : 'a deck, not a terminal script';
|
|
112
112
|
// Both are named, because the whole reason this is worth refusing is that
|
|
@@ -114,8 +114,8 @@ export function wrongRecorder(cmd, file) {
|
|
|
114
114
|
// typed, repaired, so it can be copied rather than reconstructed.
|
|
115
115
|
return `${name} is ${what}.\n`
|
|
116
116
|
+ ' decklight cast records a TERMINAL — a YAML command script, replayed in the deck\n'
|
|
117
|
-
+ " decklight
|
|
118
|
-
+ ` did you mean: decklight ${isScript ? 'cast' : '
|
|
117
|
+
+ " decklight narrate --mic records YOU — your voice narrating a deck's notes\n\n"
|
|
118
|
+
+ ` did you mean: decklight ${isScript ? 'cast' : 'narrate'} ${name}${isScript ? '' : ' --mic'}`;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
export const scriptSafe = (s) => s.replace(/<\/script/gi, '<\\/script').replace(/<!--/g, '<\\u0021--');
|