decklight 0.8.1 → 0.10.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 +707 -0
- package/README.md +226 -150
- package/SPEC.md +803 -888
- package/cli/agent-review.mjs +246 -0
- package/cli/agents.mjs +35 -9
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +190 -0
- package/cli/bundle-module.mjs +95 -0
- package/cli/bundle.mjs +439 -35
- package/cli/cast.mjs +48 -12
- package/cli/check-fixes.mjs +186 -0
- package/cli/check.mjs +988 -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 +51 -22
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +64 -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 +666 -0
- package/cli/design-system.mjs +497 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +551 -0
- package/cli/edit-look.mjs +631 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2585 -855
- package/cli/enhance.mjs +485 -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 +78 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +407 -236
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace-autocheck.mjs +200 -0
- package/cli/marketplace.mjs +460 -29
- package/cli/narrate.mjs +251 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +961 -0
- package/cli/pdf.mjs +64 -17
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +63 -27
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +85 -23
- package/cli/remote.mjs +43 -17
- 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 +236 -45
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +229 -35
- package/cli/skills.mjs +353 -26
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +527 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +112 -47
- 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 +1533 -59
- package/dist/decklight.js +258 -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 +778 -0
- package/tools/design-system-migrations.mjs +207 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +11 -3
- 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 +270 -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-clip.mjs +114 -0
- 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 +530 -54
- 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/marketplace.mjs
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
// decklight marketplace add <owner/repo | git url | path> [--name x]
|
|
8
8
|
// decklight marketplace list
|
|
9
9
|
// decklight marketplace update <name> [--branch <ref>]
|
|
10
|
+
// decklight marketplace outdated [<name>] [--json]
|
|
11
|
+
// decklight marketplace auto-check [on|off]
|
|
10
12
|
// decklight marketplace remove <name>
|
|
11
13
|
//
|
|
12
14
|
// A marketplace is a git repo (or a local directory) with
|
|
@@ -25,17 +27,22 @@
|
|
|
25
27
|
// offered them.
|
|
26
28
|
//
|
|
27
29
|
// The invariant this module exists to keep (SPEC MARKETPLACE_REGISTRY): the
|
|
28
|
-
// network is touched ONLY by an explicit `add` or `
|
|
29
|
-
// source
|
|
30
|
+
// network is touched ONLY by an explicit `add`, `update` or `outdated` of a
|
|
31
|
+
// remote source — and `outdated` only asks where a ref points (`git
|
|
32
|
+
// ls-remote`), it fetches no file. Registering is a filesystem write; `list` reads only the cache;
|
|
30
33
|
// installing an entry reads the checkout; nothing on the deck-load or
|
|
31
34
|
// presenting path imports this module at all. A deck on conference wifi, on a
|
|
32
35
|
// plane, or air-gapped behaves identically to one at a desk, marketplace or
|
|
33
36
|
// no marketplace.
|
|
34
37
|
|
|
35
38
|
import {
|
|
36
|
-
existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync,
|
|
39
|
+
existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, statSync, writeFileSync,
|
|
37
40
|
} from 'node:fs';
|
|
38
|
-
import { execFileSync } from 'node:child_process';
|
|
41
|
+
import { execFile, execFileSync } from 'node:child_process';
|
|
42
|
+
// The registry is the file that says which marketplaces exist at all. A
|
|
43
|
+
// truncate interrupted halfway leaves JSON that no longer parses, and
|
|
44
|
+
// loadRegistry rightly refuses to guess at it — so the write is a rename.
|
|
45
|
+
import { writeFileAtomic } from '../tools/atomic-write.mjs';
|
|
39
46
|
import { homedir } from 'node:os';
|
|
40
47
|
import { join, resolve } from 'node:path';
|
|
41
48
|
import { argReader, isMain } from '../tools/args.mjs';
|
|
@@ -57,16 +64,19 @@ export const NAME_RE = /^[A-Za-z0-9_-]+$/;
|
|
|
57
64
|
* "typo" must not look alike.
|
|
58
65
|
*/
|
|
59
66
|
export const INSTALL_HINT = {
|
|
60
|
-
theme: 'decklight theme add <
|
|
61
|
-
plugin: 'decklight
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
voice: 'decklight voice add <name>',
|
|
67
|
+
theme: 'decklight theme add <name@marketplace> <deck>',
|
|
68
|
+
plugin: 'decklight library add plugin <name>',
|
|
69
|
+
skill: 'decklight library add skill <name>',
|
|
70
|
+
importer: 'decklight library add importer <name>',
|
|
71
|
+
engine: 'decklight library add engine <name>', // ENGINE_UNITS — the wizard then configures it
|
|
72
|
+
agent: 'decklight library add agent <name>', // AGENT_UNITS — a descriptor, never code
|
|
73
|
+
transform: 'decklight library add transform <name>', // EXTENSIONS#LOADER — installs; bundle --transform <name> runs it
|
|
74
|
+
voice: 'decklight library add voice <name>',
|
|
69
75
|
'publish-target': null,
|
|
76
|
+
// DESIGN_SYSTEMS: a deck REFERENCES one — nothing is installed into the library
|
|
77
|
+
'design-system': 'decklight design-system add <name@marketplace> <deck>',
|
|
78
|
+
// FONTS: the same — a deck references a font, its faces stay in the marketplace
|
|
79
|
+
font: 'decklight font add <name@marketplace> <deck>',
|
|
70
80
|
};
|
|
71
81
|
|
|
72
82
|
export const KNOWN_TYPES = Object.keys(INSTALL_HINT);
|
|
@@ -105,6 +115,93 @@ const cachePath = (home, name) => join(home, 'marketplaces', `${name}.json`);
|
|
|
105
115
|
*/
|
|
106
116
|
export const checkoutPath = (home, name) => join(home, 'marketplaces', name);
|
|
107
117
|
|
|
118
|
+
// ── entry versions (#616) ──────────────────────────────────────────────────
|
|
119
|
+
//
|
|
120
|
+
// An entry may carry its own semver `version` — every kind, a theme or a skill
|
|
121
|
+
// with no code at all as much as a transform — the way a Claude Code plugin
|
|
122
|
+
// does. It is a CATALOG/INSTALL fact: what an install took, and whether the
|
|
123
|
+
// catalog now offers something newer. Not `apiVersion` (the calling
|
|
124
|
+
// convention a code entry needs, SPEC UNIT_COMPAT) and not decklight's own
|
|
125
|
+
// package version.
|
|
126
|
+
|
|
127
|
+
// SEMVER_RE and semverCompare live in tools/semver.mjs — pure, so the
|
|
128
|
+
// design-system format (tools/design-system-format.mjs) shares them without
|
|
129
|
+
// importing this module's filesystem and git — and are re-exported here.
|
|
130
|
+
export { SEMVER_RE, semverCompare } from '../tools/semver.mjs';
|
|
131
|
+
import { SEMVER_RE, semverCompare } from '../tools/semver.mjs';
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* What was installed from which catalog, at which version and commit:
|
|
135
|
+
* `~/.decklight/installed.json`, one record per `type:name@marketplace`.
|
|
136
|
+
* Written by every kind's `add` (themes included — `theme add` marks the
|
|
137
|
+
* theme in a deck, and the ledger is what remembers the version it marked);
|
|
138
|
+
* read by `marketplace list` and `update` to say what is newer. Decks are
|
|
139
|
+
* never read or written here: the update path is the installed unit.
|
|
140
|
+
*/
|
|
141
|
+
const ledgerPath = (home) => join(home, 'installed.json');
|
|
142
|
+
const ledgerKey = (type, name, marketplace) => `${type}:${name}@${marketplace}`;
|
|
143
|
+
|
|
144
|
+
/** The install ledger — `{ installs: { key: record } }`, empty when there is none. */
|
|
145
|
+
export function loadLedger(home = configHome()) {
|
|
146
|
+
try {
|
|
147
|
+
const j = JSON.parse(readFileSync(ledgerPath(home), 'utf8'));
|
|
148
|
+
return { installs: j && typeof j.installs === 'object' && j.installs ? j.installs : {} };
|
|
149
|
+
} catch { return { installs: {} }; }
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Record an install: the entry's catalog `version` (null when it carries
|
|
154
|
+
* none) and the marketplace `commit` its files came from. Re-running an
|
|
155
|
+
* `add` overwrites the record — that is how taking a newer version is noted.
|
|
156
|
+
*/
|
|
157
|
+
export function recordInstall({ type, name, marketplace, version = null, commit = null }, home = configHome(), now = Date.now()) {
|
|
158
|
+
const ledger = loadLedger(home);
|
|
159
|
+
ledger.installs[ledgerKey(type, name, marketplace)] = {
|
|
160
|
+
type, name, marketplace, version: version ?? null, commit: commit ?? null, at: new Date(now).toISOString(),
|
|
161
|
+
};
|
|
162
|
+
mkdirSync(home, { recursive: true });
|
|
163
|
+
writeFileAtomic(ledgerPath(home), `${JSON.stringify(ledger, null, 2)}\n`);
|
|
164
|
+
return ledger.installs[ledgerKey(type, name, marketplace)];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Drop an install's record — `remove` of the installed unit. */
|
|
168
|
+
export function forgetInstall({ type, name, marketplace = null }, home = configHome()) {
|
|
169
|
+
const ledger = loadLedger(home);
|
|
170
|
+
let dropped = 0;
|
|
171
|
+
for (const [k, r] of Object.entries(ledger.installs)) {
|
|
172
|
+
if (r.type === type && r.name === name && (!marketplace || r.marketplace === marketplace)) { delete ledger.installs[k]; dropped++; }
|
|
173
|
+
}
|
|
174
|
+
if (dropped) writeFileAtomic(ledgerPath(home), `${JSON.stringify(ledger, null, 2)}\n`);
|
|
175
|
+
return dropped;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** The command that takes `qualified` again, for its kind. */
|
|
179
|
+
export function reinstallHint(type, qualified) {
|
|
180
|
+
const how = INSTALL_HINT[type];
|
|
181
|
+
if (!how) return null;
|
|
182
|
+
return how.replace(/<name@marketplace>|<name>/, qualified);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Installed entries whose catalog now offers a NEWER version, from the cached
|
|
187
|
+
* catalogs alone: `[{ qualified, type, from, to, how }]` — `from` null for an
|
|
188
|
+
* install recorded before its entry carried a version. `only` narrows it to
|
|
189
|
+
* one marketplace.
|
|
190
|
+
*/
|
|
191
|
+
export function newerThanInstalled(home = configHome(), only = null) {
|
|
192
|
+
const out = [];
|
|
193
|
+
for (const r of Object.values(loadLedger(home).installs)) {
|
|
194
|
+
if (only && r.marketplace !== only) continue;
|
|
195
|
+
const cat = loadCatalog(r.marketplace, home);
|
|
196
|
+
const entry = cat?.ok ? cat.manifest.entries.find((e) => e.name === r.name && e.type === r.type) : null;
|
|
197
|
+
if (!entry?.version) continue;
|
|
198
|
+
if (r.version && !(semverCompare(entry.version, r.version) > 0)) continue;
|
|
199
|
+
const qualified = `${r.name}@${r.marketplace}`;
|
|
200
|
+
out.push({ qualified, type: r.type, from: r.version ?? null, to: entry.version, how: reinstallHint(r.type, qualified) });
|
|
201
|
+
}
|
|
202
|
+
return out.sort((a, b) => a.qualified.localeCompare(b.qualified));
|
|
203
|
+
}
|
|
204
|
+
|
|
108
205
|
export function loadRegistry(home = configHome()) {
|
|
109
206
|
const p = registryPath(home);
|
|
110
207
|
if (!existsSync(p)) return { version: 1, marketplaces: {} };
|
|
@@ -118,7 +215,7 @@ export function loadRegistry(home = configHome()) {
|
|
|
118
215
|
|
|
119
216
|
export function saveRegistry(reg, home = configHome()) {
|
|
120
217
|
mkdirSync(join(home, 'marketplaces'), { recursive: true });
|
|
121
|
-
|
|
218
|
+
writeFileAtomic(registryPath(home), JSON.stringify(reg, null, 2) + '\n');
|
|
122
219
|
}
|
|
123
220
|
|
|
124
221
|
/**
|
|
@@ -299,7 +396,7 @@ export const ENGINE_CAPABILITIES = ['tts', 'lipsync'];
|
|
|
299
396
|
/**
|
|
300
397
|
* The pin a code-carrying entry installs against (SPEC `UNIT_PINNING`): the
|
|
301
398
|
* SHA-256 of the module file's bytes, lowercase hex, as `sha256sum` prints it
|
|
302
|
-
* and `decklight
|
|
399
|
+
* and `decklight library gate transform` emits it on success.
|
|
303
400
|
*
|
|
304
401
|
* Validated for SHAPE when present, like everything else in `ENTRY_SHAPES` —
|
|
305
402
|
* but its ABSENCE is refused at install time (`cli/units.mjs`), not here.
|
|
@@ -313,9 +410,28 @@ const sha256Shape = (v) => (typeof v === 'string' && /^[0-9a-f]{64}$/.test(v)
|
|
|
313
410
|
? null
|
|
314
411
|
: 'must be 64 lowercase hex characters — the SHA-256 of the module file\'s bytes (SPEC UNIT_PINNING)');
|
|
315
412
|
|
|
413
|
+
/**
|
|
414
|
+
* A design system's `source` (SPEC DESIGN_SYSTEMS): a directory in the
|
|
415
|
+
* marketplace's own repo. Not a URL — v1's package is a directory of files,
|
|
416
|
+
* and the https escape hatch themes have (`theme-cache/`) caches one file —
|
|
417
|
+
* and never outside the checkout.
|
|
418
|
+
*/
|
|
419
|
+
const designSystemSource = (v) => {
|
|
420
|
+
if (typeof v !== 'string' || !v) return 'must be the package directory, relative to the marketplace, e.g. "systems/acme"';
|
|
421
|
+
if (/^[a-z][a-z0-9+.-]*:/i.test(v)) return `"${v}" is a URL — a design system is a directory in the marketplace's repo (v1 has no https source: the cache holds single files, a package is many)`;
|
|
422
|
+
if (v.startsWith('/') || v.startsWith('\\') || /^[A-Za-z]:/.test(v)) return `"${v}" is absolute — a source is relative to the marketplace`;
|
|
423
|
+
if (v.split(/[\\/]/).includes('..')) return `"${v}" climbs out with .. — a design system lives inside its marketplace`;
|
|
424
|
+
return null;
|
|
425
|
+
};
|
|
426
|
+
|
|
316
427
|
/** Fields a kind MAY carry, checked only when present — see `sha256Shape`. */
|
|
317
428
|
const ENTRY_SHAPES_OPTIONAL = {
|
|
318
429
|
importer: { sha256: sha256Shape },
|
|
430
|
+
// presence is the generic rule's ("missing — the repo-relative path…"); the
|
|
431
|
+
// shape is checked here, so a missing source is said once, not twice
|
|
432
|
+
'design-system': { source: designSystemSource },
|
|
433
|
+
// a font package is a directory too (SPEC FONTS) — held to the same rule
|
|
434
|
+
font: { source: (v) => designSystemSource(v)?.replace(/a design system/g, 'a font') ?? null },
|
|
319
435
|
transform: { sha256: sha256Shape },
|
|
320
436
|
// An engine entry wears one `type` for two jobs, and only one of them
|
|
321
437
|
// carries code. `{name, type: 'engine', source, wizard}` DECLARES a wizard
|
|
@@ -363,6 +479,20 @@ const ENTRY_SHAPES = {
|
|
|
363
479
|
? null
|
|
364
480
|
: 'must be a positive integer — the EXTENSIONS#TRANSFORMS contract version this transform needs, not a decklight version'),
|
|
365
481
|
},
|
|
482
|
+
// A design system names the format version it needs (SPEC DESIGN_SYSTEMS,
|
|
483
|
+
// DESIGN_SYSTEM_API_VERSION) — shape only here, like a transform's: a
|
|
484
|
+
// catalog written for a newer decklight still validates, and the entry is
|
|
485
|
+
// what says "needs a newer decklight" when a deck reaches for it.
|
|
486
|
+
'design-system': {
|
|
487
|
+
apiVersion: (v) => (Number.isInteger(v) && v >= 1
|
|
488
|
+
? null
|
|
489
|
+
: 'must be a positive integer — the design-system format version this package needs, not a decklight version'),
|
|
490
|
+
},
|
|
491
|
+
font: {
|
|
492
|
+
apiVersion: (v) => (Number.isInteger(v) && v >= 1
|
|
493
|
+
? null
|
|
494
|
+
: 'must be a positive integer — the font format version this package needs, not a decklight version'),
|
|
495
|
+
},
|
|
366
496
|
// An agent entry is a DESCRIPTOR (SPEC AGENT_UNITS): the binary you already
|
|
367
497
|
// installed, and the argv of its headless mode. Deliberately not code — the
|
|
368
498
|
// three shapes the built-in roster already covers (`-p …`, `exec
|
|
@@ -484,9 +614,9 @@ export function validateManifest(raw) {
|
|
|
484
614
|
} else if (seen.has(entry.name)) {
|
|
485
615
|
err(`${p}.name`, `"${entry.name}" already used by entries[${seen.get(entry.name)}] — entry names are unique within a marketplace`);
|
|
486
616
|
} else seen.set(entry.name, idx);
|
|
487
|
-
if (entry.type === undefined) err(`${p}.type`, 'missing — what kind of thing this is (theme,
|
|
617
|
+
if (entry.type === undefined) err(`${p}.type`, 'missing — what kind of thing this is (theme, skill, importer, engine, transform, …)');
|
|
488
618
|
else if (typeof entry.type !== 'string' || !/^[a-z][a-z0-9-]*$/.test(entry.type)) {
|
|
489
|
-
err(`${p}.type`, `${JSON.stringify(entry.type)} — a lowercase word (theme,
|
|
619
|
+
err(`${p}.type`, `${JSON.stringify(entry.type)} — a lowercase word (theme, skill, importer, engine, transform, …)`);
|
|
490
620
|
} else shapeErrors(entry, p, err);
|
|
491
621
|
if (REFERENCE_ONLY.has(entry.type)) {
|
|
492
622
|
// Refused, not ignored. A `source` on a reference-only entry is the one
|
|
@@ -502,6 +632,12 @@ export function validateManifest(raw) {
|
|
|
502
632
|
if (entry.description !== undefined && typeof entry.description !== 'string') {
|
|
503
633
|
err(`${p}.description`, 'must be a string');
|
|
504
634
|
}
|
|
635
|
+
// Optional — a catalog without versions is as valid as it always was —
|
|
636
|
+
// and never "close enough": `v1.1` and `1.1` are refused, because the
|
|
637
|
+
// answer to "is this newer than what I installed" needs real semver.
|
|
638
|
+
if (entry.version !== undefined && (typeof entry.version !== 'string' || !SEMVER_RE.test(entry.version))) {
|
|
639
|
+
err(`${p}.version`, `${JSON.stringify(entry.version)} — a semver version, major.minor.patch (e.g. "1.1.0"), no leading v`);
|
|
640
|
+
}
|
|
505
641
|
});
|
|
506
642
|
}
|
|
507
643
|
return { ok: errors.length === 0, manifest: errors.length ? null : data, errors };
|
|
@@ -530,6 +666,48 @@ export function classifySource(spec, { exists = existsSync } = {}) {
|
|
|
530
666
|
return { kind: 'local', root: resolve(spec), spec };
|
|
531
667
|
}
|
|
532
668
|
|
|
669
|
+
/**
|
|
670
|
+
* What `add <spec>` is about to do, said before it does it — the in-deck door's
|
|
671
|
+
* first ⏎ (SPEC DESIGN_SYSTEMS). Touches no network: it classifies the spec,
|
|
672
|
+
* and for a local directory checks that the manifest is there, since that much
|
|
673
|
+
* is free and saying it now beats saying it after a second ⏎.
|
|
674
|
+
*
|
|
675
|
+
* `base` is the directory a relative path is read against: the deck's, for
|
|
676
|
+
* the door, where the CLI uses its cwd. A local spec comes back ABSOLUTE in
|
|
677
|
+
* `spec`, because the registry keeps the source as given and a relative one
|
|
678
|
+
* would mean something else from the next directory `update` runs in.
|
|
679
|
+
* `registered` names the marketplace already registered from that source, if
|
|
680
|
+
* any: adding it again re-clones it, as `add` does at the command line.
|
|
681
|
+
* `ref` is `--branch`: held to the same rule as the command line's, and
|
|
682
|
+
* refused on a local directory now rather than after the second ⏎.
|
|
683
|
+
*/
|
|
684
|
+
export function planAdd(rawSpec, { ref = null, base = process.cwd(), home = configHome(), exists = existsSync } = {}) {
|
|
685
|
+
const raw = String(rawSpec ?? '').trim();
|
|
686
|
+
if (!raw) throw new MarketplaceError('needs an owner/repo, a git url, or a path');
|
|
687
|
+
const bad = ref === null ? null : refProblem(String(ref));
|
|
688
|
+
if (bad) throw new MarketplaceError(`--branch ${JSON.stringify(String(ref))} ${bad}`);
|
|
689
|
+
// it becomes one argument of `decklight marketplace add`: never an option,
|
|
690
|
+
// never more than one line
|
|
691
|
+
if (raw.startsWith('-') || /[\u0000-\u001f\u007f]/.test(raw) || raw.length > 2048) {
|
|
692
|
+
throw new MarketplaceError(`${JSON.stringify(raw.slice(0, 80))} is not an owner/repo, a git url, or a path`);
|
|
693
|
+
}
|
|
694
|
+
const src = classifySource(raw, { exists: (p) => exists(resolve(base, p)) });
|
|
695
|
+
let spec = raw, does;
|
|
696
|
+
if (src.kind === 'local') {
|
|
697
|
+
const root = resolve(base, raw);
|
|
698
|
+
if (!exists(root)) throw new MarketplaceError(`no such directory: ${root}`);
|
|
699
|
+
if (!exists(join(root, MANIFEST_PATH))) throw new MarketplaceError(`${root} has no ${MANIFEST_PATH} — is it a marketplace?`);
|
|
700
|
+
if (ref) throw new MarketplaceError(`${raw} is a local directory — --branch needs a repository to clone`);
|
|
701
|
+
spec = root;
|
|
702
|
+
does = `register ${root} — read in place, nothing is fetched`;
|
|
703
|
+
} else {
|
|
704
|
+
does = `clone ${cloneUrl(src)}${ref ? ` at ${ref}` : ''} with your git credentials on this machine`;
|
|
705
|
+
}
|
|
706
|
+
const reg = loadRegistry(home).marketplaces ?? {};
|
|
707
|
+
const registered = Object.keys(reg).find((n) => reg[n].source === spec) ?? null;
|
|
708
|
+
return { spec, ref: ref ?? null, kind: src.kind, url: src.kind === 'local' ? null : cloneUrl(src), path: src.kind === 'local' ? spec : null, does, registered };
|
|
709
|
+
}
|
|
710
|
+
|
|
533
711
|
/** The URL git is handed for a remote source. */
|
|
534
712
|
export const cloneUrl = (src) =>
|
|
535
713
|
(src.kind === 'github' ? `https://github.com/${src.owner}/${src.repo}.git` : src.url);
|
|
@@ -742,11 +920,37 @@ export function adoptCheckout(home, name, checkout) {
|
|
|
742
920
|
|
|
743
921
|
// ── the cache, and names ───────────────────────────────────────────────────
|
|
744
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Every validated catalog this process has already read, keyed by path.
|
|
925
|
+
*
|
|
926
|
+
* A catalog is a file on this machine that changes only when `marketplace
|
|
927
|
+
* update` fetches one — and `loadCatalog` is called in LOOPS: the theme
|
|
928
|
+
* browser, the design-system list and the engine-wizard roster each walk every
|
|
929
|
+
* registered marketplace, and the edit server calls all three to answer one
|
|
930
|
+
* `/deck/ping`. Every one of those calls re-read the JSON off disk and re-ran
|
|
931
|
+
* validateManifest over it, which walks every entry and every field. So the
|
|
932
|
+
* answer is remembered against the file's mtime and size: a catalog that has
|
|
933
|
+
* not moved is not read and not re-validated, and one that has is, on the next
|
|
934
|
+
* call, with nothing to remember to invalidate by hand.
|
|
935
|
+
*/
|
|
936
|
+
const catalogCache = new Map();
|
|
937
|
+
|
|
938
|
+
/** Forget every remembered catalog — for tests, and for nothing else. */
|
|
939
|
+
export function clearCatalogCache() { catalogCache.clear(); }
|
|
940
|
+
|
|
745
941
|
/** The cached manifest for `name`: null when never fetched, else a validation. */
|
|
746
942
|
export function loadCatalog(name, home = configHome()) {
|
|
747
943
|
const p = cachePath(home, name);
|
|
748
|
-
|
|
749
|
-
|
|
944
|
+
// stat, not existsSync: the question "is it there" and the question "is it
|
|
945
|
+
// the one I read" are the same syscall, and asking twice is how they end up
|
|
946
|
+
// disagreeing about a file that was removed in between.
|
|
947
|
+
let st;
|
|
948
|
+
try { st = statSync(p); } catch { catalogCache.delete(p); return null; }
|
|
949
|
+
const hit = catalogCache.get(p);
|
|
950
|
+
if (hit && hit.mtimeMs === st.mtimeMs && hit.size === st.size) return hit.value;
|
|
951
|
+
const value = validateManifest(readFileSync(p, 'utf8'));
|
|
952
|
+
catalogCache.set(p, { mtimeMs: st.mtimeMs, size: st.size, value });
|
|
953
|
+
return value;
|
|
750
954
|
}
|
|
751
955
|
|
|
752
956
|
/**
|
|
@@ -754,7 +958,7 @@ export function loadCatalog(name, home = configHome()) {
|
|
|
754
958
|
* is exact; a bare name resolves only when it exists in exactly ONE
|
|
755
959
|
* registered marketplace — two is reported as ambiguous with the qualified
|
|
756
960
|
* forms to say instead, never silently resolved to either. This is the seam
|
|
757
|
-
* every install surface (theme browse, engine wizard,
|
|
961
|
+
* every install surface (theme browse, engine wizard, the unit commands) goes
|
|
758
962
|
* through; nothing in THIS command installs anything.
|
|
759
963
|
*/
|
|
760
964
|
export function resolveEntry(ref, catalogs) {
|
|
@@ -781,9 +985,131 @@ export function resolveEntry(ref, catalogs) {
|
|
|
781
985
|
return hits[0];
|
|
782
986
|
}
|
|
783
987
|
|
|
988
|
+
// ── what changed, and what is behind ──────────────────────────────────────
|
|
989
|
+
|
|
990
|
+
const entryKey = (e) => `${e.type}:${e.name}`;
|
|
991
|
+
|
|
992
|
+
/**
|
|
993
|
+
* What one fetch of a catalog changed against the copy it replaced: entries
|
|
994
|
+
* `added` and `removed`, and entries whose `version` moved (`changed`, with
|
|
995
|
+
* `from` and `to`). `before` is null for a first fetch, when everything is
|
|
996
|
+
* new — said as `first`, so a reader does not call forty entries "news".
|
|
997
|
+
* Pure: two entry lists in, one record out.
|
|
998
|
+
*/
|
|
999
|
+
export function catalogChanges(before, after) {
|
|
1000
|
+
const was = new Map((before ?? []).map((e) => [entryKey(e), e]));
|
|
1001
|
+
const now = new Map((after ?? []).map((e) => [entryKey(e), e]));
|
|
1002
|
+
const brief = (e) => ({ type: e.type, name: e.name, version: e.version ?? null });
|
|
1003
|
+
const added = [...now.values()].filter((e) => !was.has(entryKey(e))).map(brief);
|
|
1004
|
+
const removed = [...was.values()].filter((e) => !now.has(entryKey(e))).map(brief);
|
|
1005
|
+
const changed = [...now.values()]
|
|
1006
|
+
.filter((e) => was.has(entryKey(e)) && (was.get(entryKey(e)).version ?? null) !== (e.version ?? null))
|
|
1007
|
+
.map((e) => ({ type: e.type, name: e.name, from: was.get(entryKey(e)).version ?? null, to: e.version ?? null }));
|
|
1008
|
+
const order = (a, b) => a.type.localeCompare(b.type) || a.name.localeCompare(b.name);
|
|
1009
|
+
return { first: before === null, added: added.sort(order), removed: removed.sort(order), changed: changed.sort(order) };
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
/**
|
|
1013
|
+
* Remember what a fetch changed on the marketplace's registry record, so the
|
|
1014
|
+
* "what's new" of its last update can be read again later — by `list`, by the
|
|
1015
|
+
* Marketplaces… screen — and not only in the moment it was printed.
|
|
1016
|
+
*/
|
|
1017
|
+
function noteChanges(record, beforeCat, afterManifest, { from = null, to = null, now = Date.now() } = {}) {
|
|
1018
|
+
const before = beforeCat?.ok ? beforeCat.manifest.entries : null;
|
|
1019
|
+
record.changes = { at: new Date(now).toISOString(), from: from ?? null, to: to ?? null, ...catalogChanges(before, afterManifest.entries) };
|
|
1020
|
+
return record.changes;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
/** The what's-new lines `update` prints: `+ new`, `− gone`, `↑ moved`. */
|
|
1024
|
+
function changeLines(name, c) {
|
|
1025
|
+
return [
|
|
1026
|
+
...c.added.map((e) => `+ ${e.name}@${name}${e.version ? ` ${e.version}` : ''} (${e.type})`),
|
|
1027
|
+
...c.removed.map((e) => `− ${e.name}@${name} (${e.type}) — no longer offered`),
|
|
1028
|
+
...c.changed.map((e) => `↑ ${e.name}@${name} ${e.from ?? 'unversioned'} → ${e.to ?? 'unversioned'}`),
|
|
1029
|
+
];
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
/** `git ls-remote`, asynchronously: several marketplaces are asked at once. */
|
|
1033
|
+
const lsRemote = (url, patterns, { timeoutMs }) => new Promise((done, fail) => {
|
|
1034
|
+
execFile('git', ['ls-remote', '--', url, ...patterns], {
|
|
1035
|
+
encoding: 'utf8', timeout: timeoutMs,
|
|
1036
|
+
// never a password prompt, as for a clone: an unreachable repo is an answer
|
|
1037
|
+
env: { ...process.env, GIT_TERMINAL_PROMPT: '0' },
|
|
1038
|
+
}, (err, stdout, stderr) => (err ? fail(Object.assign(err, { stderr })) : done(stdout)));
|
|
1039
|
+
});
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* The commit `ref` names in an `ls-remote` answer — the one `clone --branch`
|
|
1043
|
+
* would check out: a branch before a tag of the same name, and a tag PEELED
|
|
1044
|
+
* (`^{}`), since an annotated tag's own object is not the commit a clone lands
|
|
1045
|
+
* on. No ref is the remote's `HEAD`, as no `--branch` is.
|
|
1046
|
+
*/
|
|
1047
|
+
export function remoteCommit(lsRemoteOut, ref = null) {
|
|
1048
|
+
const rows = String(lsRemoteOut).split('\n').map((l) => l.trim().split(/\s+/))
|
|
1049
|
+
.filter(([sha, name]) => /^[0-9a-f]{40,64}$/.test(sha ?? '') && name);
|
|
1050
|
+
const at = (name) => rows.find(([, n]) => n === name)?.[0] ?? null;
|
|
1051
|
+
if (!ref) return at('HEAD');
|
|
1052
|
+
return at(`refs/heads/${ref}`) ?? at(`refs/tags/${ref}^{}`) ?? at(`refs/tags/${ref}`) ?? at(ref);
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* Is a marketplace behind its source? Asked, never fetched: a remote is asked
|
|
1057
|
+
* where its ref points now (`git ls-remote`, the caller's credentials, no
|
|
1058
|
+
* prompt) and that is held against the commit the cached catalog came from; a
|
|
1059
|
+
* local directory's manifest is compared with the cached copy, with no
|
|
1060
|
+
* network at all. Nothing on disk changes — `update` is what takes it.
|
|
1061
|
+
*
|
|
1062
|
+
* `state` is one of: `current`; `behind` (with `remote`, the commit an update
|
|
1063
|
+
* would bring); `unfetched` (never fetched, so `update` is its first fetch);
|
|
1064
|
+
* `unknown` (fetched before commits were recorded — an update records one);
|
|
1065
|
+
* `unreachable` (with `error`, the reason).
|
|
1066
|
+
*/
|
|
1067
|
+
export async function checkMarketplace(name, home = configHome(), { ask = lsRemote, timeoutMs = 15000 } = {}) {
|
|
1068
|
+
const m = loadRegistry(home).marketplaces?.[name];
|
|
1069
|
+
if (!m) throw new MarketplaceError(`no marketplace "${name}" (decklight marketplace list)`);
|
|
1070
|
+
const src = classifySource(m.source);
|
|
1071
|
+
const base = { name, source: m.source, ref: m.ref ?? null, local: src.kind === 'local', commit: m.commit ?? null, remote: null, error: null };
|
|
1072
|
+
if (loadCatalog(name, home) === null) return { ...base, state: 'unfetched' };
|
|
1073
|
+
if (src.kind === 'local') {
|
|
1074
|
+
let raw;
|
|
1075
|
+
try { raw = readFileSync(join(src.root, MANIFEST_PATH), 'utf8'); } catch {
|
|
1076
|
+
return { ...base, state: 'unreachable', error: `${m.source} has no ${MANIFEST_PATH} any more` };
|
|
1077
|
+
}
|
|
1078
|
+
let cached = null;
|
|
1079
|
+
try { cached = readFileSync(cachePath(home, name), 'utf8'); } catch { /* read just above; gone since */ }
|
|
1080
|
+
return { ...base, state: raw === cached ? 'current' : 'behind' };
|
|
1081
|
+
}
|
|
1082
|
+
let out;
|
|
1083
|
+
// a tag's peeled line answers only when asked for by name
|
|
1084
|
+
try { out = await ask(cloneUrl(src), m.ref ? [m.ref, `${m.ref}^{}`] : ['HEAD'], { timeoutMs }); } catch (e) {
|
|
1085
|
+
return { ...base, state: 'unreachable', error: `git ls-remote ${cloneUrl(src)} failed — ${e.killed ? `no answer in ${Math.round(timeoutMs / 1000)}s` : oneline(e)}` };
|
|
1086
|
+
}
|
|
1087
|
+
const remote = remoteCommit(out, m.ref ?? null);
|
|
1088
|
+
if (!remote) return { ...base, state: 'unreachable', error: m.ref ? `no branch or tag "${m.ref}" in ${m.source}` : `${m.source} has no HEAD` };
|
|
1089
|
+
if (!m.commit) return { ...base, remote, state: 'unknown' };
|
|
1090
|
+
return { ...base, remote, state: remote === m.commit ? 'current' : 'behind' };
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
/** `checkMarketplace` for every registered marketplace (or `only` one), asked at once. */
|
|
1094
|
+
export async function checkMarketplaces(home = configHome(), { only = null, ...opts } = {}) {
|
|
1095
|
+
const names = only ? [only] : Object.keys(loadRegistry(home).marketplaces ?? {}).sort();
|
|
1096
|
+
return Promise.all(names.map((n) => checkMarketplace(n, home, opts)));
|
|
1097
|
+
}
|
|
1098
|
+
|
|
1099
|
+
/** One line of `outdated`: the state, and the command that acts on it. */
|
|
1100
|
+
function outdatedLine(r) {
|
|
1101
|
+
const at = (c) => (c ? `@${c.slice(0, 7)}` : '');
|
|
1102
|
+
const fix = ` — decklight marketplace update ${r.name}`;
|
|
1103
|
+
if (r.state === 'current') return `${r.name} up to date${r.commit ? ` ${at(r.commit)}` : ''}`;
|
|
1104
|
+
if (r.state === 'behind') return r.local ? `${r.name} changed on disk${fix}` : `${r.name} behind ${at(r.commit)} → ${at(r.remote)}${fix}`;
|
|
1105
|
+
if (r.state === 'unfetched') return `${r.name} registered, not fetched${fix}`;
|
|
1106
|
+
if (r.state === 'unknown') return `${r.name} no commit recorded to compare (the source is at ${at(r.remote)})${fix}`;
|
|
1107
|
+
return `${r.name} could not ask — ${r.error}`;
|
|
1108
|
+
}
|
|
1109
|
+
|
|
784
1110
|
// ── the command ────────────────────────────────────────────────────────────
|
|
785
1111
|
|
|
786
|
-
const USAGE = `usage: decklight marketplace <add|list|update|remove> …
|
|
1112
|
+
const USAGE = `usage: decklight marketplace <add|list|update|outdated|auto-check|remove> …
|
|
787
1113
|
|
|
788
1114
|
decklight marketplace add <owner/repo | git url | path> [--name <name>]
|
|
789
1115
|
[--branch <ref>]
|
|
@@ -804,19 +1130,38 @@ const USAGE = `usage: decklight marketplace <add|list|update|remove> …
|
|
|
804
1130
|
|
|
805
1131
|
decklight marketplace list
|
|
806
1132
|
every registered marketplace and its cached entries (as name@marketplace),
|
|
807
|
-
read from the cache alone — list works on a plane
|
|
1133
|
+
read from the cache alone — list works on a plane. An entry's version is
|
|
1134
|
+
shown, and for one you installed, what you have against what the catalog
|
|
1135
|
+
offers: confluent-devrel@decklight-confluent 1.0.0 → 1.1.0
|
|
808
1136
|
|
|
809
1137
|
decklight marketplace update <name> [--branch <ref>]
|
|
810
1138
|
re-clone a marketplace, refreshing the cached manifest and the checkout
|
|
811
1139
|
(at the ref it was added with, unless --branch moves the pin)
|
|
812
1140
|
its entries install from; for a registered-not-fetched marketplace this is
|
|
813
|
-
the FIRST fetch it ever gets
|
|
1141
|
+
the FIRST fetch it ever gets. Then it says what's new in the catalog
|
|
1142
|
+
(entries added, gone, or at a new version — remembered, so the
|
|
1143
|
+
Marketplaces… screen shows it again), names every entry you installed
|
|
1144
|
+
from it that the catalog now has newer, and the command that takes it —
|
|
1145
|
+
it installs nothing itself
|
|
1146
|
+
|
|
1147
|
+
decklight marketplace outdated [<name>] [--json]
|
|
1148
|
+
which marketplaces are behind their source: a remote is ASKED where its
|
|
1149
|
+
ref points now (git ls-remote — no clone, nothing written), a local
|
|
1150
|
+
directory's manifest is compared with the cached copy. Each behind one is
|
|
1151
|
+
named with the update that takes it
|
|
1152
|
+
|
|
1153
|
+
decklight marketplace auto-check [on|off]
|
|
1154
|
+
whether an edit server that starts runs outdated by itself, in the
|
|
1155
|
+
background and at most once in 12 hours, and the deck offers to update
|
|
1156
|
+
what it found behind. Off until you turn it on; it only ever offers, an
|
|
1157
|
+
update is still yours. With no argument, says which it is
|
|
814
1158
|
|
|
815
1159
|
decklight marketplace remove <name>
|
|
816
1160
|
unregister a marketplace and drop its cached manifest and checkout
|
|
817
1161
|
|
|
818
|
-
registering is not fetching: the network is touched only by an explicit add
|
|
819
|
-
or
|
|
1162
|
+
registering is not fetching: the network is touched only by an explicit add,
|
|
1163
|
+
update or outdated (or the auto-check you turned on), never when a deck loads
|
|
1164
|
+
or presents (SPEC MARKETPLACE_REGISTRY).
|
|
820
1165
|
DECKLIGHT_HOME overrides ~/.decklight/.`;
|
|
821
1166
|
|
|
822
1167
|
const printManifestErrors = (cmd, spec, errors) => {
|
|
@@ -870,6 +1215,8 @@ async function addMain(args, home) {
|
|
|
870
1215
|
reg.marketplaces[name] = {
|
|
871
1216
|
...(existing ?? {}), source: spec, ref: ref ?? undefined, commit: got.commit ?? undefined,
|
|
872
1217
|
};
|
|
1218
|
+
// a re-add is a refresh, and says what it changed as `update` does
|
|
1219
|
+
if (existing) noteChanges(reg.marketplaces[name], loadCatalog(name, home), v.manifest, { from: existing.commit, to: got.commit });
|
|
873
1220
|
writeCache(home, name, got.raw);
|
|
874
1221
|
const at = adoptCheckout(home, name, got.checkout);
|
|
875
1222
|
got.checkout = null;
|
|
@@ -882,18 +1229,38 @@ async function addMain(args, home) {
|
|
|
882
1229
|
}
|
|
883
1230
|
}
|
|
884
1231
|
|
|
885
|
-
function writeCache(home, name, raw) {
|
|
1232
|
+
export function writeCache(home, name, raw) {
|
|
886
1233
|
mkdirSync(join(home, 'marketplaces'), { recursive: true });
|
|
887
1234
|
writeFileSync(cachePath(home, name), raw);
|
|
1235
|
+
// mtime has a resolution, and an update that lands in the same millisecond
|
|
1236
|
+
// as the read before it would otherwise be invisible to loadCatalog. The
|
|
1237
|
+
// writer knows what it just did, so it says so rather than leaving the
|
|
1238
|
+
// reader to notice.
|
|
1239
|
+
catalogCache.delete(cachePath(home, name));
|
|
888
1240
|
}
|
|
889
1241
|
|
|
890
|
-
|
|
1242
|
+
/**
|
|
1243
|
+
* What `list` says about an entry's version: the catalog's (`1.1.0`), and
|
|
1244
|
+
* for an installed one what you have — `1.0.0 → 1.1.0` when the catalog is
|
|
1245
|
+
* newer, `1.1.0 installed` when it is what you have.
|
|
1246
|
+
*/
|
|
1247
|
+
function versionNote(entry, installed) {
|
|
1248
|
+
if (!installed) return entry.version ? ` ${entry.version}` : '';
|
|
1249
|
+
const had = installed.version ?? 'unversioned';
|
|
1250
|
+
if (!entry.version || entry.version === installed.version) return ` ${installed.version ? `${installed.version} ` : ''}installed`;
|
|
1251
|
+
if (installed.version && !(semverCompare(entry.version, installed.version) > 0)) return ` ${had} installed (catalog: ${entry.version})`;
|
|
1252
|
+
return ` ${had} → ${entry.version}`;
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
async function listMain(home) {
|
|
1256
|
+
const installs = loadLedger(home).installs;
|
|
891
1257
|
const reg = loadRegistry(home);
|
|
892
1258
|
const names = Object.keys(reg.marketplaces).sort();
|
|
893
1259
|
if (!names.length) {
|
|
894
1260
|
console.log('no marketplaces registered — decklight marketplace add <owner/repo | git url | path>');
|
|
895
1261
|
return 0;
|
|
896
1262
|
}
|
|
1263
|
+
console.log(await autoCheckLine(reg, home));
|
|
897
1264
|
for (const name of names) {
|
|
898
1265
|
const m = reg.marketplaces[name];
|
|
899
1266
|
// The commit is what the manifest AND every entry's files came from — one
|
|
@@ -926,7 +1293,8 @@ function listMain(home) {
|
|
|
926
1293
|
console.log(` ${kind}${known ? '' : ' (this decklight does not install this kind)'}`
|
|
927
1294
|
+ `${how ? ` — ${how}` : ''}`);
|
|
928
1295
|
for (const e of entries.filter((x) => x.type === kind)) {
|
|
929
|
-
console.log(` ${e.name}@${name}${e.
|
|
1296
|
+
console.log(` ${e.name}@${name}${versionNote(e, installs[ledgerKey(e.type, e.name, name)])}`
|
|
1297
|
+
+ `${e.description ? ` — ${e.description}` : ''}`);
|
|
930
1298
|
}
|
|
931
1299
|
}
|
|
932
1300
|
}
|
|
@@ -934,6 +1302,30 @@ function listMain(home) {
|
|
|
934
1302
|
return 0;
|
|
935
1303
|
}
|
|
936
1304
|
|
|
1305
|
+
// The auto-check (cli/marketplace-autocheck.mjs) imports this module, so the
|
|
1306
|
+
// commands that use it load it when they run.
|
|
1307
|
+
let autoCheckModule = null;
|
|
1308
|
+
const loadAutoCheck = async () => (autoCheckModule ??= await import('./marketplace-autocheck.mjs'));
|
|
1309
|
+
|
|
1310
|
+
/** Whether an edit server checks for updates as it starts, and what it last found. */
|
|
1311
|
+
async function autoCheckLine(reg, home) {
|
|
1312
|
+
if (reg.autoCheck !== true) return 'auto-check: off — decklight marketplace auto-check on checks for updates when decklight starts';
|
|
1313
|
+
const { readCheckRecord, checkSummary } = await loadAutoCheck();
|
|
1314
|
+
const rec = readCheckRecord(home);
|
|
1315
|
+
return `auto-check: on — ${rec ? checkSummary(rec) : 'not checked yet: the next edit server to start asks'}`;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1318
|
+
async function autoCheckMain(args, home) {
|
|
1319
|
+
const [want] = args.filter((a) => !a.startsWith('-'));
|
|
1320
|
+
if (want === undefined) { console.log(await autoCheckLine(loadRegistry(home), home)); return 0; }
|
|
1321
|
+
if (want !== 'on' && want !== 'off') { console.error(`decklight marketplace auto-check: on or off, not "${want}"`); return 1; }
|
|
1322
|
+
(await loadAutoCheck()).setAutoCheck(want === 'on', home);
|
|
1323
|
+
console.log(want === 'on'
|
|
1324
|
+
? 'auto-check: on — an edit server that starts asks each source whether it has moved (nothing is fetched), at most once in 12 hours, and the deck offers what it finds'
|
|
1325
|
+
: 'auto-check: off — nothing is asked until you press C on Marketplaces… or run decklight marketplace outdated');
|
|
1326
|
+
return 0;
|
|
1327
|
+
}
|
|
1328
|
+
|
|
937
1329
|
async function updateMain(args, home) {
|
|
938
1330
|
const [name] = args.filter((a, i) => !a.startsWith('-') && args[i - 1] !== '--branch');
|
|
939
1331
|
if (!name) { console.error(`decklight marketplace update: which one?\n\n${USAGE}`); return 1; }
|
|
@@ -963,6 +1355,7 @@ async function updateMain(args, home) {
|
|
|
963
1355
|
try {
|
|
964
1356
|
const v = validateManifest(got.raw);
|
|
965
1357
|
if (!v.ok) { printManifestErrors('update', m.source, v.errors); return 1; }
|
|
1358
|
+
const before = loadCatalog(name, home);
|
|
966
1359
|
writeCache(home, name, got.raw);
|
|
967
1360
|
const at = adoptCheckout(home, name, got.checkout);
|
|
968
1361
|
got.checkout = null;
|
|
@@ -971,16 +1364,51 @@ async function updateMain(args, home) {
|
|
|
971
1364
|
reg2.marketplaces[name] = {
|
|
972
1365
|
...reg2.marketplaces[name], ref: ref ?? undefined, commit: got.commit ?? undefined,
|
|
973
1366
|
};
|
|
1367
|
+
noteChanges(reg2.marketplaces[name], before, v.manifest, { from: m.commit, to: got.commit });
|
|
974
1368
|
saveRegistry(reg2, home);
|
|
975
1369
|
}
|
|
1370
|
+
// the last check found this one behind: it no longer is, and nothing offers it
|
|
1371
|
+
(await loadAutoCheck()).noteUpdated(name, got.commit ?? null, home);
|
|
976
1372
|
console.log(`${first ? 'fetched' : 'updated'} ${name}${ref ? ` at ${ref}` : ''} — ${entriesSummary(name, v.manifest.entries)}`);
|
|
977
1373
|
if (at) console.log(` cloned to ${at}${got.commit ? ` (${got.commit.slice(0, 7)})` : ''}`);
|
|
1374
|
+
// What's new in the CATALOG — the first fetch has no "before" to hold it
|
|
1375
|
+
// against, so it is the entries line above and nothing more.
|
|
1376
|
+
if (!first && before?.ok) {
|
|
1377
|
+
const lines = changeLines(name, catalogChanges(before.manifest.entries, v.manifest.entries));
|
|
1378
|
+
console.log(lines.length ? ` what's new:\n${lines.map((l) => ` ${l}`).join('\n')}` : ' nothing in the catalog changed');
|
|
1379
|
+
}
|
|
1380
|
+
// What you installed from it that the catalog now has newer — and the
|
|
1381
|
+
// one command that takes each. Nothing is installed here: an update
|
|
1382
|
+
// refreshes the catalog, and taking a new version stays your call.
|
|
1383
|
+
// A design system whose new version declares migrations says what that
|
|
1384
|
+
// means for the decks on it, and what moves them, instead of a re-add.
|
|
1385
|
+
const { withMigrationHint } = await import('./design-system-refs.mjs');
|
|
1386
|
+
const newer = newerThanInstalled(home, name).map((n) => withMigrationHint(n, home));
|
|
1387
|
+
if (newer.length) {
|
|
1388
|
+
console.log(` newer than what you installed:`);
|
|
1389
|
+
for (const n of newer) {
|
|
1390
|
+
console.log(` ${n.qualified} ${n.from ?? 'unversioned'} → ${n.to}${n.note ? ` (${n.note})` : ''}${n.how ? ` — ${n.how}` : ''}`);
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
978
1393
|
return 0;
|
|
979
1394
|
} finally {
|
|
980
1395
|
if (got.checkout) rmSync(got.checkout, { recursive: true, force: true });
|
|
981
1396
|
}
|
|
982
1397
|
}
|
|
983
1398
|
|
|
1399
|
+
async function outdatedMain(args, home) {
|
|
1400
|
+
const [name] = args.filter((a) => !a.startsWith('-'));
|
|
1401
|
+
const reg = loadRegistry(home);
|
|
1402
|
+
if (name && !reg.marketplaces[name]) { console.error(`decklight marketplace outdated: no marketplace "${name}" (decklight marketplace list)`); return 1; }
|
|
1403
|
+
const results = await checkMarketplaces(home, { only: name ?? null });
|
|
1404
|
+
// the answer is kept: Marketplaces… starts from it, and the auto-check's window is measured from it
|
|
1405
|
+
(await loadAutoCheck()).recordCheck(results, home, { all: !name });
|
|
1406
|
+
if (args.includes('--json')) { console.log(JSON.stringify({ marketplaces: results }, null, 2)); return 0; }
|
|
1407
|
+
if (!results.length) { console.log('no marketplaces registered — decklight marketplace add <owner/repo | git url | path>'); return 0; }
|
|
1408
|
+
for (const r of results) console.log(outdatedLine(r));
|
|
1409
|
+
return 0;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
984
1412
|
function removeMain(args, home) {
|
|
985
1413
|
const [name] = args.filter((a) => !a.startsWith('-'));
|
|
986
1414
|
if (!name) { console.error(`decklight marketplace remove: which one?\n\n${USAGE}`); return 1; }
|
|
@@ -990,6 +1418,7 @@ function removeMain(args, home) {
|
|
|
990
1418
|
delete reg.marketplaces[name];
|
|
991
1419
|
saveRegistry(reg, home);
|
|
992
1420
|
rmSync(cachePath(home, name), { force: true });
|
|
1421
|
+
catalogCache.delete(cachePath(home, name));
|
|
993
1422
|
rmSync(checkoutPath(home, name), { recursive: true, force: true });
|
|
994
1423
|
console.log(`removed ${name} — re-add any time with: decklight marketplace add ${m.source}`);
|
|
995
1424
|
return 0;
|
|
@@ -1003,9 +1432,11 @@ export async function marketplaceMain(args = []) {
|
|
|
1003
1432
|
const home = configHome();
|
|
1004
1433
|
try {
|
|
1005
1434
|
if (sub === 'add') return await addMain(rest, home);
|
|
1006
|
-
if (sub === 'list') return listMain(home);
|
|
1435
|
+
if (sub === 'list') return await listMain(home);
|
|
1007
1436
|
if (sub === 'update') return await updateMain(rest, home);
|
|
1437
|
+
if (sub === 'outdated') return await outdatedMain(rest, home);
|
|
1008
1438
|
if (sub === 'remove') return removeMain(rest, home);
|
|
1439
|
+
if (sub === 'auto-check') return await autoCheckMain(rest, home);
|
|
1009
1440
|
} catch (e) {
|
|
1010
1441
|
if (e instanceof MarketplaceError) { console.error(`decklight marketplace ${sub}: ${e.message}`); return 1; }
|
|
1011
1442
|
throw e;
|