castle-web-cli 0.4.229 → 0.4.231
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/dist/agent-prompts.d.ts +2 -0
- package/dist/agent-prompts.js +16 -8
- package/dist/agent.d.ts +2 -0
- package/dist/agent.js +21 -21
- package/dist/api.d.ts +28 -2
- package/dist/api.js +74 -16
- package/dist/castle-host/host.d.ts +91 -0
- package/dist/castle-host/host.js +860 -3
- package/dist/castleJson.d.ts +44 -0
- package/dist/castleJson.js +131 -0
- package/dist/check.js +27 -1
- package/dist/contentPack.d.ts +49 -0
- package/dist/contentPack.js +273 -0
- package/dist/devExperiments.d.ts +21 -0
- package/dist/devExperiments.js +139 -0
- package/dist/devHub.d.ts +55 -0
- package/dist/devHub.js +187 -0
- package/dist/devSaveStorage.d.ts +36 -0
- package/dist/devSaveStorage.js +469 -0
- package/dist/devSessionChild.js +25 -13
- package/dist/devSessionServer.d.ts +14 -1
- package/dist/devSessionServer.js +237 -46
- package/dist/devSessionStorage.d.ts +9 -0
- package/dist/devSessionStorage.js +66 -1
- package/dist/experimentAssignment.d.ts +15 -0
- package/dist/experimentAssignment.js +41 -0
- package/dist/importCheckHook.d.ts +40 -0
- package/dist/importCheckHook.js +171 -0
- package/dist/importRegression.d.ts +15 -0
- package/dist/importRegression.js +100 -0
- package/dist/importTrust.d.ts +2 -0
- package/dist/importTrust.js +27 -0
- package/dist/importUpdateHook.d.ts +18 -0
- package/dist/importUpdateHook.js +31 -8
- package/dist/importUpdateHookRunner.js +19 -7
- package/dist/imports.d.ts +16 -0
- package/dist/imports.js +141 -31
- package/dist/index.js +3 -1
- package/dist/init.d.ts +3 -0
- package/dist/init.js +126 -9
- package/dist/install.js +4 -1
- package/dist/localPaths.js +4 -0
- package/dist/login.js +2 -2
- package/dist/platformDoc.js +3 -8
- package/dist/playPagePolicy.js +3 -1
- package/dist/remix.js +5 -0
- package/dist/routerTaskReport.d.ts +28 -0
- package/dist/routerTaskReport.js +56 -0
- package/dist/save-deck.d.ts +18 -0
- package/dist/save-deck.js +142 -6
- package/dist/serve.d.ts +8 -0
- package/dist/serve.js +99 -14
- package/dist/serverBundle.d.ts +1 -1
- package/dist/serverBundle.js +5 -1
- package/dist/webSourceSync.d.ts +2 -0
- package/dist/webSourceSync.js +2 -0
- package/kits/base/CLAUDE.md +2 -3
- package/kits/base/castle.json +1 -1
- package/kits/base/sdk/README.md +406 -53
- package/kits/base/sdk/agent.js +4 -4
- package/kits/base/sdk/avatar.d.ts +12 -0
- package/kits/base/sdk/avatar.js +23 -0
- package/kits/base/sdk/castle.d.ts +9 -0
- package/kits/base/sdk/castle.js +5 -0
- package/kits/base/sdk/commands.d.ts +223 -0
- package/kits/base/sdk/commands.js +16 -0
- package/kits/base/sdk/context.d.ts +6 -0
- package/kits/base/sdk/experiments.d.ts +15 -0
- package/kits/base/sdk/experiments.js +83 -0
- package/kits/base/sdk/hub.d.ts +85 -0
- package/kits/base/sdk/hub.js +107 -0
- package/kits/base/sdk/multiplayer.d.ts +45 -1
- package/kits/base/sdk/multiplayer.js +158 -8
- package/kits/base/sdk/save.d.ts +197 -0
- package/kits/base/sdk/save.js +525 -0
- package/kits/base/sdk/saveCoordinator.d.ts +39 -0
- package/kits/base/sdk/saveCoordinator.js +252 -0
- package/kits/base/sdk/server/hub.d.ts +169 -0
- package/kits/base/sdk/server/hub.js +125 -0
- package/kits/base/sdk/server/platformHandle.d.ts +42 -1
- package/kits/base/sdk/server/storage.d.ts +58 -4
- package/kits/base/sdk/server/storage.js +25 -5
- package/kits/base/sdk/server/wrapper.d.ts +36 -2
- package/kits/base/sdk/server/wrapper.js +92 -11
- package/kits/base/sdk/store.d.ts +3 -2
- package/kits/base/sdk/store.js +5 -0
- package/kits/base/sdk/transport.d.ts +2 -1
- package/kits/base/sdk/transport.js +13 -1
- package/kits/hub-game/.prettierrc +5 -0
- package/kits/hub-game/CLAUDE.md +149 -0
- package/kits/hub-game/blueprints/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/avatar-3.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/bean/avatar-3.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/blocky/avatar-3.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-0.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-1.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-2.scene +28 -0
- package/kits/hub-game/blueprints/pixel/avatar-3.scene +28 -0
- package/kits/hub-game/castle.json +96 -0
- package/kits/hub-game/code/client/attention.js +133 -0
- package/kits/hub-game/code/client/avatar.js +288 -0
- package/kits/hub-game/code/client/cabinets.js +90 -0
- package/kits/hub-game/code/client/chat.js +135 -0
- package/kits/hub-game/code/client/chrome.js +1035 -0
- package/kits/hub-game/code/client/doorFrame.js +15 -0
- package/kits/hub-game/code/client/firstJoin.js +14 -0
- package/kits/hub-game/code/client/grab.js +376 -0
- package/kits/hub-game/code/client/hookLayer.js +236 -0
- package/kits/hub-game/code/client/idle.js +326 -0
- package/kits/hub-game/code/client/keys.js +48 -0
- package/kits/hub-game/code/client/pack.js +232 -0
- package/kits/hub-game/code/client/packFormat.js +397 -0
- package/kits/hub-game/code/client/say.js +127 -0
- package/kits/hub-game/code/client/sha256.js +80 -0
- package/kits/hub-game/code/client/sound.js +147 -0
- package/kits/hub-game/code/client/state.js +143 -0
- package/kits/hub-game/code/client/talk.js +233 -0
- package/kits/hub-game/code/client/tiers.js +480 -0
- package/kits/hub-game/code/client/together.js +440 -0
- package/kits/hub-game/code/client/wear.js +149 -0
- package/kits/hub-game/code/server/actors.js +627 -0
- package/kits/hub-game/code/server/blocks.js +103 -0
- package/kits/hub-game/code/server/cabinets.js +309 -0
- package/kits/hub-game/code/server/game.js +137 -0
- package/kits/hub-game/code/server/grab.js +248 -0
- package/kits/hub-game/code/server/history.js +96 -0
- package/kits/hub-game/code/server/hub.js +1998 -0
- package/kits/hub-game/code/server/idle.js +412 -0
- package/kits/hub-game/code/server/index.js +64 -0
- package/kits/hub-game/code/server/labels.js +59 -0
- package/kits/hub-game/code/server/manifest.js +554 -0
- package/kits/hub-game/code/server/npcs.js +733 -0
- package/kits/hub-game/code/server/party.js +439 -0
- package/kits/hub-game/code/server/place.js +43 -0
- package/kits/hub-game/code/server/say.js +83 -0
- package/kits/hub-game/code/server/wear.js +142 -0
- package/kits/hub-game/code/systems/hub.js +2347 -0
- package/kits/hub-game/docs/content-pack.md +151 -0
- package/kits/hub-game/docs/contract.md +1209 -0
- package/kits/hub-game/docs/style.md +137 -0
- package/kits/hub-game/drawings/blocky/castle-eye.sprite +58 -0
- package/kits/hub-game/drawings/blocky/dash.sprite +59 -0
- package/kits/hub-game/drawings/blocky/pom.sprite +59 -0
- package/kits/hub-game/drawings/blocky/tabby.sprite +59 -0
- package/kits/hub-game/drawings/pixel/castle-arm.sprite +13 -0
- package/kits/hub-game/drawings/pixel/castle-body.sprite +23 -0
- package/kits/hub-game/drawings/pixel/castle-leg.sprite +12 -0
- package/kits/hub-game/drawings/pixel/kai-arm.sprite +14 -0
- package/kits/hub-game/drawings/pixel/kai-head.sprite +24 -0
- package/kits/hub-game/drawings/pixel/kai-leg.sprite +15 -0
- package/kits/hub-game/drawings/pixel/kai-torso.sprite +18 -0
- package/kits/hub-game/drawings/pixel/mimi-arm.sprite +13 -0
- package/kits/hub-game/drawings/pixel/mimi-head.sprite +23 -0
- package/kits/hub-game/drawings/pixel/mimi-leg.sprite +15 -0
- package/kits/hub-game/drawings/pixel/mimi-torso.sprite +18 -0
- package/kits/hub-game/drawings/pixel/nox-arm.sprite +13 -0
- package/kits/hub-game/drawings/pixel/nox-head.sprite +21 -0
- package/kits/hub-game/drawings/pixel/nox-leg.sprite +14 -0
- package/kits/hub-game/drawings/pixel/nox-torso.sprite +18 -0
- package/kits/hub-game/eslint.config.js +20 -0
- package/kits/hub-game/fonts.generated.js +9 -0
- package/kits/hub-game/index.html +22 -0
- package/kits/hub-game/main.jsx +6 -0
- package/kits/hub-game/models/avatar-0.pxmodel +21 -0
- package/kits/hub-game/models/avatar-1.pxmodel +24 -0
- package/kits/hub-game/models/avatar-2.pxmodel +27 -0
- package/kits/hub-game/models/avatar-3.pxmodel +22 -0
- package/kits/hub-game/models/bean/avatar-0.pxmodel +19 -0
- package/kits/hub-game/models/bean/avatar-1.pxmodel +24 -0
- package/kits/hub-game/models/bean/avatar-2.pxmodel +22 -0
- package/kits/hub-game/models/bean/avatar-3.pxmodel +24 -0
- package/kits/hub-game/models/blocky/avatar-0.pxmodel +21 -0
- package/kits/hub-game/models/blocky/avatar-1.pxmodel +30 -0
- package/kits/hub-game/models/blocky/avatar-2.pxmodel +28 -0
- package/kits/hub-game/models/blocky/avatar-3.pxmodel +27 -0
- package/kits/hub-game/models/pixel/avatar-0.pxmodel +24 -0
- package/kits/hub-game/models/pixel/avatar-1.pxmodel +16 -0
- package/kits/hub-game/models/pixel/avatar-2.pxmodel +19 -0
- package/kits/hub-game/models/pixel/avatar-3.pxmodel +23 -0
- package/kits/hub-game/package-lock.json +365 -0
- package/kits/hub-game/package.json +32 -0
- package/kits/hub-game/scenes/main.scene +318 -0
- package/kits/hub-game/scripts/check.mjs +339 -0
- package/kits/hub-game/scripts/fixtures/sdk-stub.mjs +3 -0
- package/kits/hub-game/scripts/gen-avatars-bean.mjs +748 -0
- package/kits/hub-game/scripts/gen-avatars-blocky.mjs +607 -0
- package/kits/hub-game/scripts/gen-avatars-pixel.mjs +771 -0
- package/kits/hub-game/scripts/gen-avatars.mjs +621 -0
- package/kits/hub-game/scripts/pack.mjs +192 -0
- package/kits/hub-game/scripts/test-actors.mjs +666 -0
- package/kits/hub-game/scripts/test-attention.mjs +103 -0
- package/kits/hub-game/scripts/test-avatar.mjs +472 -0
- package/kits/hub-game/scripts/test-ban-join.mjs +194 -0
- package/kits/hub-game/scripts/test-blocks.mjs +351 -0
- package/kits/hub-game/scripts/test-chat.mjs +98 -0
- package/kits/hub-game/scripts/test-classic.mjs +590 -0
- package/kits/hub-game/scripts/test-door-jump.mjs +131 -0
- package/kits/hub-game/scripts/test-door.mjs +56 -0
- package/kits/hub-game/scripts/test-grab-client.mjs +328 -0
- package/kits/hub-game/scripts/test-grab.mjs +331 -0
- package/kits/hub-game/scripts/test-hub-ops.mjs +835 -0
- package/kits/hub-game/scripts/test-hub-trip.mjs +1518 -0
- package/kits/hub-game/scripts/test-idle.mjs +518 -0
- package/kits/hub-game/scripts/test-interest.mjs +413 -0
- package/kits/hub-game/scripts/test-keys.mjs +50 -0
- package/kits/hub-game/scripts/test-manifest.mjs +270 -0
- package/kits/hub-game/scripts/test-no-forms.mjs +16 -0
- package/kits/hub-game/scripts/test-npcs.mjs +724 -0
- package/kits/hub-game/scripts/test-pack.mjs +424 -0
- package/kits/hub-game/scripts/test-party.mjs +369 -0
- package/kits/hub-game/scripts/test-say.mjs +149 -0
- package/kits/hub-game/scripts/test-tiers.mjs +666 -0
- package/kits/hub-game/scripts/test-together.mjs +215 -0
- package/kits/hub-game/theme.style +3 -0
- package/kits/multiplayer-3d/castle.json +5 -5
- package/kits/multiplayer-3d/code/client/avatars.js +101 -1
- package/kits/multiplayer-3d/code/server/players.js +4 -1
- package/kits/multiplayer-3d/code/server/sceneBodies.js +27 -6
- package/kits/multiplayer-3d/code/server/world.js +20 -7
- package/kits/multiplayer-3d/code/systems/multiplayer.js +222 -11
- package/kits/physics-2d/CLAUDE.md +2 -0
- package/kits/physics-2d/castle.json +2 -2
- package/kits/physics-2d/engine/art.js +13 -0
- package/kits/physics-2d/engine/assets.js +4 -2
- package/kits/physics-2d/engine/scene.js +117 -5
- package/kits/physics-2d/package.json +1 -1
- package/kits/physics-2d/scripts/test-skip-unchanged.mjs +254 -0
- package/kits/physics-3d/CLAUDE.md +285 -1
- package/kits/physics-3d/behaviors/Player.jsx +74 -1
- package/kits/physics-3d/castle.json +3 -3
- package/kits/physics-3d/engine3d/Scene3DPlayer.jsx +33 -5
- package/kits/physics-3d/engine3d/actornode.js +253 -0
- package/kits/physics-3d/engine3d/artobjects.js +2 -2
- package/kits/physics-3d/engine3d/materials.js +29 -1
- package/kits/physics-3d/engine3d/nearshadows.js +600 -0
- package/kits/physics-3d/engine3d/unchanged.js +153 -0
- package/kits/physics-3d/engine3d/world3d.js +527 -5
- package/kits/physics-3d/package.json +1 -1
- package/kits/physics-3d/scripts/test-camera-follow.mjs +533 -0
- package/kits/physics-3d/scripts/test-near-shadows.mjs +1073 -0
- package/kits/physics-3d/scripts/test-static-actors.mjs +662 -0
- package/kits/physics-3d/scripts/test-static-passes.mjs +459 -0
- package/kits/physics-3d/scripts/test-static-physics.mjs +128 -0
- package/kits/physics-3d/systems/physics3d.js +187 -5
- package/kits/real-time/castle.json +2 -2
- package/kits/real-time/code/client/connection.js +77 -7
- package/kits/real-time/code/client/gameHooks.js +63 -3
- package/kits/real-time/code/client/messages.js +7 -0
- package/kits/real-time/code/server/gameHooks.js +24 -0
- package/kits/real-time/code/server/session.js +390 -22
- package/package.json +2 -2
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Running every import's `onCheck`: the gate a kit adds to `castle-web check`
|
|
2
|
+
// and `save-deck` for the decks built on it.
|
|
3
|
+
//
|
|
4
|
+
// The CLI knows nothing about what a check looks at. An import names a module of
|
|
5
|
+
// its own (castle.json `onCheck`, see castleJson.ts for the contract); the CLI
|
|
6
|
+
// runs it in a child, collects the errors and warnings it returns, and refuses
|
|
7
|
+
// the build when there is an error. Whatever a check knows about scenes,
|
|
8
|
+
// blueprints or a server's shape stays on the other side of that boundary.
|
|
9
|
+
//
|
|
10
|
+
// Unlike `onUpdate` there is no version saved first and nothing to roll back: a
|
|
11
|
+
// check is READ-ONLY by contract. It is still somebody else's code with the
|
|
12
|
+
// deck's files in reach, so it answers to the same account gate an update hook
|
|
13
|
+
// does (importTrust.ts).
|
|
14
|
+
import * as fs from 'fs';
|
|
15
|
+
import * as path from 'path';
|
|
16
|
+
import { IMPORTS_DIR, readCastleJson } from './castleJson.js';
|
|
17
|
+
import { getKitsDir } from './localPaths.js';
|
|
18
|
+
import { execHookModule, failureDetail, HOOK_RESULT_PREFIX, outputLines, resolveFileInside, } from './importUpdateHook.js';
|
|
19
|
+
import { importIsOnTrustedAccount, TRUSTED_IMPORT_ACCOUNT } from './importTrust.js';
|
|
20
|
+
/** The alias a deck's OWN `onCheck` is reported under. */
|
|
21
|
+
export const SELF_CHECK_ALIAS = 'self';
|
|
22
|
+
// Whether `dir` is one of the kits this CLI ships, checked as itself.
|
|
23
|
+
function isShippedKitDir(dir) {
|
|
24
|
+
const kits = path.resolve(getKitsDir());
|
|
25
|
+
const rel = path.relative(kits, path.resolve(dir));
|
|
26
|
+
return !!rel && !rel.startsWith('..') && !path.isAbsolute(rel) && !rel.includes(path.sep);
|
|
27
|
+
}
|
|
28
|
+
// The module a target runs, or null when there is none it may run. A builtin
|
|
29
|
+
// pin says "the CLI's own copy of this kit", so the module is taken from that
|
|
30
|
+
// copy -- never from the files in `imports/`, which a pin can name `builtin`
|
|
31
|
+
// while they came from anywhere. The deck's own check runs only for a kit this
|
|
32
|
+
// CLI ships, checked as itself (its `npm run check`): any other deck's own
|
|
33
|
+
// module is code nobody has vouched for.
|
|
34
|
+
function targetModule(target, deckDir, field) {
|
|
35
|
+
if (target.pin === null) {
|
|
36
|
+
return isShippedKitDir(deckDir) ? resolveFileInside(target.importDir, target.declared) : null;
|
|
37
|
+
}
|
|
38
|
+
if (target.pin.source === 'builtin') {
|
|
39
|
+
const kit = typeof target.pin.kit === 'string' ? target.pin.kit : '';
|
|
40
|
+
const kitDir = path.join(getKitsDir(), kit);
|
|
41
|
+
if (!kit || !isShippedKitDir(kitDir) || !fs.existsSync(path.join(kitDir, 'castle.json')))
|
|
42
|
+
return null;
|
|
43
|
+
const declared = readCastleJson(kitDir)?.[field];
|
|
44
|
+
return typeof declared === 'string' && declared.trim() ? resolveFileInside(kitDir, declared) : null;
|
|
45
|
+
}
|
|
46
|
+
return resolveFileInside(target.importDir, target.declared);
|
|
47
|
+
}
|
|
48
|
+
// Every check that applies to this deck: each import that declares one, then
|
|
49
|
+
// the deck's own. The deck's own runs with itself as `importDir` -- that is how
|
|
50
|
+
// a kit's `npm run check` exercises the check it ships, against its own tree.
|
|
51
|
+
function checkTargets(deckDir, field) {
|
|
52
|
+
const config = readCastleJson(deckDir);
|
|
53
|
+
const targets = [];
|
|
54
|
+
for (const [alias, pin] of Object.entries(config?.imports ?? {})) {
|
|
55
|
+
const importDir = path.join(deckDir, IMPORTS_DIR, alias);
|
|
56
|
+
const declared = readCastleJson(importDir)?.[field];
|
|
57
|
+
if (pin && typeof declared === 'string' && declared.trim()) {
|
|
58
|
+
targets.push({ alias, importDir, declared, pin });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
const own = config?.[field];
|
|
62
|
+
if (typeof own === 'string' && own.trim()) {
|
|
63
|
+
targets.push({ alias: SELF_CHECK_ALIAS, importDir: deckDir, declared: own, pin: null });
|
|
64
|
+
}
|
|
65
|
+
return targets;
|
|
66
|
+
}
|
|
67
|
+
// A builtin pin is the CLI's own copy of one of its kits, so it is exactly as
|
|
68
|
+
// trusted as the CLI running it. A fetched one asks the account gate, lazily --
|
|
69
|
+
// only an import that actually ships a check pays for the lookup. The deck's
|
|
70
|
+
// own check is the deck's own code, which `check` is already running.
|
|
71
|
+
async function targetIsTrusted(target) {
|
|
72
|
+
if (target.pin === null || target.pin.source === 'builtin')
|
|
73
|
+
return true;
|
|
74
|
+
if (!target.pin.deckId)
|
|
75
|
+
return false;
|
|
76
|
+
return importIsOnTrustedAccount(target.pin.deckId);
|
|
77
|
+
}
|
|
78
|
+
function stringList(value) {
|
|
79
|
+
if (value === undefined)
|
|
80
|
+
return [];
|
|
81
|
+
if (!Array.isArray(value) || value.some((v) => typeof v !== 'string'))
|
|
82
|
+
return null;
|
|
83
|
+
return value;
|
|
84
|
+
}
|
|
85
|
+
// The verdict the runner printed last. Anything that is not the declared shape
|
|
86
|
+
// is an error in the check itself, reported as one -- a check that cannot say
|
|
87
|
+
// what it found has not passed.
|
|
88
|
+
function parseVerdict(stdout) {
|
|
89
|
+
const line = outputLines(stdout)
|
|
90
|
+
.reverse()
|
|
91
|
+
.find((l) => l.startsWith(HOOK_RESULT_PREFIX));
|
|
92
|
+
let result = null;
|
|
93
|
+
try {
|
|
94
|
+
result = line ? JSON.parse(line.slice(HOOK_RESULT_PREFIX.length)) : null;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
result = null;
|
|
98
|
+
}
|
|
99
|
+
const shape = result && typeof result === 'object' ? result : null;
|
|
100
|
+
const errors = stringList(shape?.errors);
|
|
101
|
+
const warnings = stringList(shape?.warnings);
|
|
102
|
+
if (!shape || !errors || !warnings) {
|
|
103
|
+
return {
|
|
104
|
+
errors: ['its check did not return { errors: string[], warnings: string[] }.'],
|
|
105
|
+
warnings: [],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return { errors, warnings };
|
|
109
|
+
}
|
|
110
|
+
async function runOneCheck(deckDir, target, modulePath, log) {
|
|
111
|
+
// `self` is decided here, not from the alias: an import may be added under any
|
|
112
|
+
// name, `self` included.
|
|
113
|
+
const context = { deckDir, importDir: target.importDir, alias: target.alias, self: target.pin === null };
|
|
114
|
+
let output;
|
|
115
|
+
try {
|
|
116
|
+
output = await execHookModule(modulePath, context, deckDir, { reportResult: true });
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
// A throw, a non-zero exit and the clock running out all land here.
|
|
120
|
+
return { alias: target.alias, errors: [`its check failed: ${failureDetail(e)}`], warnings: [] };
|
|
121
|
+
}
|
|
122
|
+
const chatter = [...outputLines(output.stdout), ...outputLines(output.stderr)].filter((line) => !line.startsWith(HOOK_RESULT_PREFIX));
|
|
123
|
+
for (const line of chatter)
|
|
124
|
+
log(`${target.alias} check: ${line}`);
|
|
125
|
+
return { alias: target.alias, ...parseVerdict(output.stdout) };
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Run every applicable `onCheck`, one at a time, and collect what they found.
|
|
129
|
+
* Warnings are logged here; errors are returned for the caller to refuse on --
|
|
130
|
+
* `check` exits non-zero, `save-deck` publishes nothing.
|
|
131
|
+
*/
|
|
132
|
+
export async function runImportChecks(deckDir, log = (message) => console.log(message)) {
|
|
133
|
+
const outcomes = [];
|
|
134
|
+
for (const { target, modulePath } of await runnableImportHooks(deckDir, 'onCheck', log)) {
|
|
135
|
+
const outcome = await runOneCheck(deckDir, target, modulePath, log);
|
|
136
|
+
for (const warning of outcome.warnings)
|
|
137
|
+
log(`Warning (${target.alias}): ${warning}`);
|
|
138
|
+
outcomes.push(outcome);
|
|
139
|
+
}
|
|
140
|
+
const errors = outcomes.flatMap((o) => o.errors.map((error) => `${o.alias}: ${error}`));
|
|
141
|
+
return { outcomes, errors };
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Every `field` hook that applies to this deck and may run here, in order: each
|
|
145
|
+
* import's, then the deck's own. One that cannot be run from where its pin says
|
|
146
|
+
* it comes from, or is not on the trusted account, is logged and left out.
|
|
147
|
+
*/
|
|
148
|
+
export async function runnableImportHooks(deckDir, field, log) {
|
|
149
|
+
const runnable = [];
|
|
150
|
+
const noun = field === 'onCheck' ? 'check' : 'content pack exporter';
|
|
151
|
+
for (const target of checkTargets(deckDir, field)) {
|
|
152
|
+
const modulePath = targetModule(target, deckDir, field);
|
|
153
|
+
if (!modulePath) {
|
|
154
|
+
log(target.pin === null
|
|
155
|
+
? `Warning: this deck declares its own ${noun}, which runs only for a kit the CLI ships -- skipped.`
|
|
156
|
+
: `Warning: "${target.alias}" declares a ${noun} at "${target.declared}" that cannot be run from where its pin says it comes from -- skipping it.`);
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (!(await targetIsTrusted(target))) {
|
|
160
|
+
log(`Warning: ${target.alias} ships a ${noun}, which only runs for imports on the ` +
|
|
161
|
+
`${TRUSTED_IMPORT_ACCOUNT} account -- skipped.`);
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
runnable.push({ target, modulePath });
|
|
165
|
+
}
|
|
166
|
+
return runnable;
|
|
167
|
+
}
|
|
168
|
+
/** The message `check` and `save-deck` refuse with. */
|
|
169
|
+
export function importChecksFailedMessage(errors) {
|
|
170
|
+
return [`Deck check failed:`, ...errors.map((error) => ` - ${error}`)].join('\n');
|
|
171
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DeckImport } from './castleJson.js';
|
|
2
|
+
export interface ImportRegression {
|
|
3
|
+
alias: string;
|
|
4
|
+
/** The version this folder would save: its files' marker, else its pin. */
|
|
5
|
+
have: string;
|
|
6
|
+
/** The saved deck's pin. */
|
|
7
|
+
saved: string;
|
|
8
|
+
}
|
|
9
|
+
/** The import pins in the saved deck's castle.json, or null when it can't be read. */
|
|
10
|
+
export declare function savedDeckImportPins(deckId: string, fetchArchive?: (url: string) => Promise<Buffer>): Promise<Record<string, DeckImport> | null>;
|
|
11
|
+
/** One regular file's text from an uncompressed tar (ustar, pax `path`), or null. */
|
|
12
|
+
export declare function tarFileText(tar: Buffer, want: string): string | null;
|
|
13
|
+
/** Imports this folder would save at an older version than the saved deck has. */
|
|
14
|
+
export declare function importRegressions(deckDir: string, local: Record<string, DeckImport>, saved: Record<string, DeckImport>): ImportRegression[];
|
|
15
|
+
export declare function importRegressionMessage(dir: string, regressions: ImportRegression[]): string;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as zlib from 'zlib';
|
|
2
|
+
import * as api from './api.js';
|
|
3
|
+
import { readImportVersion } from './imports.js';
|
|
4
|
+
/** The import pins in the saved deck's castle.json, or null when it can't be read. */
|
|
5
|
+
export async function savedDeckImportPins(deckId, fetchArchive = fetchBytes) {
|
|
6
|
+
const source = await api.webDeckSource(deckId);
|
|
7
|
+
if (!source?.archiveUrl)
|
|
8
|
+
return null;
|
|
9
|
+
const text = tarFileText(zlib.gunzipSync(await fetchArchive(source.archiveUrl)), 'castle.json');
|
|
10
|
+
if (text === null)
|
|
11
|
+
return null;
|
|
12
|
+
const imports = JSON.parse(text).imports;
|
|
13
|
+
return imports && typeof imports === 'object' ? imports : {};
|
|
14
|
+
}
|
|
15
|
+
async function fetchBytes(url) {
|
|
16
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(20000) });
|
|
17
|
+
if (!res.ok)
|
|
18
|
+
throw new Error(`archive fetch failed: HTTP ${res.status}`);
|
|
19
|
+
return Buffer.from(await res.arrayBuffer());
|
|
20
|
+
}
|
|
21
|
+
/** One regular file's text from an uncompressed tar (ustar, pax `path`), or null. */
|
|
22
|
+
export function tarFileText(tar, want) {
|
|
23
|
+
let offset = 0;
|
|
24
|
+
let paxName;
|
|
25
|
+
while (offset + 512 <= tar.length) {
|
|
26
|
+
const header = tar.subarray(offset, offset + 512);
|
|
27
|
+
if (header.every((b) => b === 0))
|
|
28
|
+
return null;
|
|
29
|
+
const field = (start, length) => {
|
|
30
|
+
const raw = header.subarray(start, start + length);
|
|
31
|
+
const end = raw.indexOf(0);
|
|
32
|
+
return raw.subarray(0, end === -1 ? length : end).toString('utf-8');
|
|
33
|
+
};
|
|
34
|
+
const size = parseInt(field(124, 12).trim() || '0', 8);
|
|
35
|
+
const type = field(156, 1);
|
|
36
|
+
const prefix = field(345, 155);
|
|
37
|
+
const name = paxName ?? (prefix ? `${prefix}/${field(0, 100)}` : field(0, 100));
|
|
38
|
+
const body = tar.subarray(offset + 512, offset + 512 + size);
|
|
39
|
+
paxName = undefined;
|
|
40
|
+
if (type === 'x') {
|
|
41
|
+
const match = /\d+ path=([^\n]*)\n/.exec(body.toString('utf-8'));
|
|
42
|
+
if (match)
|
|
43
|
+
paxName = match[1];
|
|
44
|
+
}
|
|
45
|
+
else if ((type === '0' || type === '') && name.replace(/^(\.\/)+/, '') === want) {
|
|
46
|
+
return body.toString('utf-8');
|
|
47
|
+
}
|
|
48
|
+
offset += 512 + Math.ceil(size / 512) * 512;
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function semverParts(version) {
|
|
53
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version);
|
|
54
|
+
return match ? match.slice(1, 4).map(Number) : null;
|
|
55
|
+
}
|
|
56
|
+
/** Whether `a` is an older version than `b` of the same kind of pin; false when unsure. */
|
|
57
|
+
function older(a, aVersion, b) {
|
|
58
|
+
if (a.source === 'builtin' && b.source === 'builtin') {
|
|
59
|
+
const x = semverParts(aVersion);
|
|
60
|
+
const y = semverParts(b.version);
|
|
61
|
+
if (!x || !y)
|
|
62
|
+
return false;
|
|
63
|
+
for (let i = 0; i < 3; i += 1)
|
|
64
|
+
if (x[i] !== y[i])
|
|
65
|
+
return x[i] < y[i];
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (a.deckId && a.deckId === b.deckId) {
|
|
69
|
+
const x = Date.parse(aVersion);
|
|
70
|
+
const y = Date.parse(b.version);
|
|
71
|
+
return Number.isFinite(x) && Number.isFinite(y) && x < y;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
/** Imports this folder would save at an older version than the saved deck has. */
|
|
76
|
+
export function importRegressions(deckDir, local, saved) {
|
|
77
|
+
const out = [];
|
|
78
|
+
for (const [alias, pin] of Object.entries(local)) {
|
|
79
|
+
const savedPin = saved[alias];
|
|
80
|
+
if (!pin || !savedPin || typeof pin.version !== 'string' || typeof savedPin.version !== 'string')
|
|
81
|
+
continue;
|
|
82
|
+
// A fetched kit's marker says which files are really here (get-deck moves
|
|
83
|
+
// the pin and leaves imports/ alone); a builtin copy is its pin's.
|
|
84
|
+
const marker = pin.deckId ? readImportVersion(deckDir, alias) : null;
|
|
85
|
+
const have = marker && marker.deckId === pin.deckId ? marker.version : pin.version;
|
|
86
|
+
if (older(pin, have, savedPin))
|
|
87
|
+
out.push({ alias, have, saved: savedPin.version });
|
|
88
|
+
}
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
export function importRegressionMessage(dir, regressions) {
|
|
92
|
+
return [
|
|
93
|
+
'Not saved: this folder has never synced with the saved deck, and saving it would move imports back:',
|
|
94
|
+
...regressions.map((r) => ` ${r.alias}: this folder ${r.have}, the saved deck ${r.saved}`),
|
|
95
|
+
'Either:',
|
|
96
|
+
` castle-web get-deck ${dir} --side fetch the saved copy beside this one to work from`,
|
|
97
|
+
` castle-web update-import <alias> ${dir} move an import forward, then save`,
|
|
98
|
+
` castle-web save-deck ${dir} --force save anyway, rolling those imports back`,
|
|
99
|
+
].join('\n');
|
|
100
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as api from './api.js';
|
|
2
|
+
// The account gate on another deck's code running against THIS deck: an
|
|
3
|
+
// import's `onUpdate` migration, its `onCheck`, and serve-start auto-update all
|
|
4
|
+
// answer to it. Its own module because both imports.ts and the check path need
|
|
5
|
+
// it, and imports.ts already imports save-deck.ts, which runs the checks --
|
|
6
|
+
// living in either would close a cycle.
|
|
7
|
+
//
|
|
8
|
+
// Honored only for decks on the castle account. A deck that pushes new code to
|
|
9
|
+
// everyone who imported it, or runs its code against their files, is asking for
|
|
10
|
+
// a lot of trust, and until decks carry some other signal of it, the only ones
|
|
11
|
+
// that get it are the ones we publish (the framework kits -- the same account
|
|
12
|
+
// `init` qualifies their aliases with).
|
|
13
|
+
//
|
|
14
|
+
// Deliberately not a deck setting: nothing in castle.json a person can flip,
|
|
15
|
+
// since that would be the leash undoing itself. CASTLE_AUTO_UPDATE_TRUSTED_ACCOUNT
|
|
16
|
+
// is the escape hatch for local kit work and tests: which username counts as
|
|
17
|
+
// trusted (default `castle`). Tests set it to exercise both branches; setting
|
|
18
|
+
// it to a non-matching name also disables updates as a side effect.
|
|
19
|
+
export const TRUSTED_IMPORT_ACCOUNT = process.env.CASTLE_AUTO_UPDATE_TRUSTED_ACCOUNT ?? 'castle';
|
|
20
|
+
// Who published a deck. Readable without auth for the same decks webDeckSource
|
|
21
|
+
// is, so this answers in a sandbox with no login. A lookup that fails answers
|
|
22
|
+
// "not trusted": the failure direction has to be the one that leaves an import
|
|
23
|
+
// where its deck's author pinned it, and its code not run.
|
|
24
|
+
export async function importIsOnTrustedAccount(deckId) {
|
|
25
|
+
const meta = await api.deckMeta(deckId).catch(() => null);
|
|
26
|
+
return meta?.creator?.username === TRUSTED_IMPORT_ACCOUNT;
|
|
27
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare function hookTimeoutMs(): number;
|
|
1
2
|
/** What a hook is handed, plus the module to run. */
|
|
2
3
|
export interface ImportUpdateHook {
|
|
3
4
|
/** The declared module, resolved to an absolute path. */
|
|
@@ -9,6 +10,7 @@ export interface ImportUpdateHook {
|
|
|
9
10
|
from: string;
|
|
10
11
|
to: string;
|
|
11
12
|
}
|
|
13
|
+
export declare function resolveFileInside(importDir: string, declared: string): string | null;
|
|
12
14
|
/**
|
|
13
15
|
* The hook module `imports/<alias>` declares, or null when it declares none or
|
|
14
16
|
* the path it names is not usable. Read from the copy ON DISK, which is the
|
|
@@ -16,6 +18,22 @@ export interface ImportUpdateHook {
|
|
|
16
18
|
* has to be the new copy's.
|
|
17
19
|
*/
|
|
18
20
|
export declare function findImportUpdateHook(deckDir: string, alias: string): string | null;
|
|
21
|
+
export declare function outputLines(text: string): string[];
|
|
22
|
+
export declare function failureDetail(e: unknown): string;
|
|
23
|
+
/**
|
|
24
|
+
* Run a hook module in the runner child, under the hook clock. `reportResult`
|
|
25
|
+
* asks the runner to print what the hook returned on a line of its own
|
|
26
|
+
* (HOOK_RESULT_PREFIX) -- an `onUpdate` hook returns nothing, an `onCheck` hook
|
|
27
|
+
* returns its verdict.
|
|
28
|
+
*/
|
|
29
|
+
export declare function execHookModule(modulePath: string, context: Record<string, string | boolean>, cwd: string, options?: {
|
|
30
|
+
reportResult?: boolean;
|
|
31
|
+
}): Promise<{
|
|
32
|
+
stdout: string;
|
|
33
|
+
stderr: string;
|
|
34
|
+
}>;
|
|
35
|
+
/** The line the runner prints a hook's return value on, as JSON. */
|
|
36
|
+
export declare const HOOK_RESULT_PREFIX = "CASTLE_HOOK_RESULT ";
|
|
19
37
|
/**
|
|
20
38
|
* Save a version, run the hook, and put the deck's files back if it fails.
|
|
21
39
|
*
|
package/dist/importUpdateHook.js
CHANGED
|
@@ -19,9 +19,10 @@ const DIST_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
|
19
19
|
const RUNNER = path.join(DIST_DIR, 'importUpdateHookRunner.js');
|
|
20
20
|
// A hook is somebody else's code with the deck's files in front of it, so it
|
|
21
21
|
// gets a wall clock rather than the chance to hang a serve start forever. The
|
|
22
|
-
// env override exists for the
|
|
23
|
-
// (scripts/tests/import-update-hook.mjs); nothing else
|
|
24
|
-
|
|
22
|
+
// env override exists for the tests that prove the clock works
|
|
23
|
+
// (scripts/tests/import-update-hook.mjs, import-check-hook.mjs); nothing else
|
|
24
|
+
// should set it. `onCheck` hooks share it (importCheckHook.ts).
|
|
25
|
+
export function hookTimeoutMs() {
|
|
25
26
|
const raw = Number(process.env.CASTLE_IMPORT_HOOK_TIMEOUT_MS);
|
|
26
27
|
return Number.isFinite(raw) && raw > 0 ? raw : 120_000;
|
|
27
28
|
}
|
|
@@ -44,7 +45,11 @@ function childContext(hook) {
|
|
|
44
45
|
// deck's files in reach, so `../../…` or an absolute path would be a way to run
|
|
45
46
|
// code from anywhere on the machine. POSIX-relative because that is how every
|
|
46
47
|
// other path in a castle.json is written.
|
|
47
|
-
|
|
48
|
+
//
|
|
49
|
+
// Exported because the same rule guards every path a kit's castle.json names
|
|
50
|
+
// for the CLI to act on: `onCheck` (importCheckHook.ts) and `starterFiles`
|
|
51
|
+
// (init.ts `writeStarterFiles`).
|
|
52
|
+
export function resolveFileInside(importDir, declared) {
|
|
48
53
|
const rel = declared.trim();
|
|
49
54
|
if (!rel || rel.startsWith('/') || /^[a-zA-Z]:[\\/]/.test(rel) || rel.includes('\\'))
|
|
50
55
|
return null;
|
|
@@ -72,18 +77,18 @@ export function findImportUpdateHook(deckDir, alias) {
|
|
|
72
77
|
const declared = readCastleJson(importDir)?.onUpdate;
|
|
73
78
|
if (typeof declared !== 'string' || !declared.trim())
|
|
74
79
|
return null;
|
|
75
|
-
const resolved =
|
|
80
|
+
const resolved = resolveFileInside(importDir, declared);
|
|
76
81
|
if (!resolved) {
|
|
77
82
|
console.warn(`"${alias}" declares an update hook at "${declared}", which is not a file inside it -- skipping it.`);
|
|
78
83
|
}
|
|
79
84
|
return resolved;
|
|
80
85
|
}
|
|
81
|
-
function outputLines(text) {
|
|
86
|
+
export function outputLines(text) {
|
|
82
87
|
return text.split('\n').map((line) => line.trimEnd()).filter(Boolean);
|
|
83
88
|
}
|
|
84
89
|
// The last few lines of stderr are what says WHY a hook failed; the whole stack
|
|
85
90
|
// of a 200-line module is not.
|
|
86
|
-
function failureDetail(e) {
|
|
91
|
+
export function failureDetail(e) {
|
|
87
92
|
const stderr = e?.stderr ?? '';
|
|
88
93
|
const tail = outputLines(stderr).slice(-8).join('\n');
|
|
89
94
|
if (tail)
|
|
@@ -92,6 +97,24 @@ function failureDetail(e) {
|
|
|
92
97
|
return `it did not finish in ${hookTimeoutMs()}ms`;
|
|
93
98
|
return e instanceof Error ? e.message : String(e);
|
|
94
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Run a hook module in the runner child, under the hook clock. `reportResult`
|
|
102
|
+
* asks the runner to print what the hook returned on a line of its own
|
|
103
|
+
* (HOOK_RESULT_PREFIX) -- an `onUpdate` hook returns nothing, an `onCheck` hook
|
|
104
|
+
* returns its verdict.
|
|
105
|
+
*/
|
|
106
|
+
export async function execHookModule(modulePath, context, cwd, options = {}) {
|
|
107
|
+
const args = [RUNNER, modulePath, JSON.stringify(context)];
|
|
108
|
+
if (options.reportResult)
|
|
109
|
+
args.push('--report-result');
|
|
110
|
+
return execFileAsync(process.execPath, args, {
|
|
111
|
+
cwd,
|
|
112
|
+
timeout: hookTimeoutMs(),
|
|
113
|
+
maxBuffer: MAX_HOOK_OUTPUT,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/** The line the runner prints a hook's return value on, as JSON. */
|
|
117
|
+
export const HOOK_RESULT_PREFIX = 'CASTLE_HOOK_RESULT ';
|
|
95
118
|
/**
|
|
96
119
|
* Save a version, run the hook, and put the deck's files back if it fails.
|
|
97
120
|
*
|
|
@@ -120,7 +143,7 @@ export async function runImportUpdateHook(hook, log) {
|
|
|
120
143
|
`(\`castle-web restore-version ${restorePoint}\` puts them back).`);
|
|
121
144
|
}
|
|
122
145
|
try {
|
|
123
|
-
const { stdout, stderr } = await
|
|
146
|
+
const { stdout, stderr } = await execHookModule(hook.modulePath, childContext(hook), hook.deckDir);
|
|
124
147
|
for (const line of [...outputLines(stdout), ...outputLines(stderr)]) {
|
|
125
148
|
log(`${hook.alias} hook: ${line}`);
|
|
126
149
|
}
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// The child process one import's `onUpdate` hook runs in. Why a
|
|
3
|
-
// in importUpdateHook.ts; this is only the entry point.
|
|
2
|
+
// The child process one import's `onUpdate` or `onCheck` hook runs in. Why a
|
|
3
|
+
// child at all is in importUpdateHook.ts; this is only the entry point.
|
|
4
4
|
//
|
|
5
|
-
// argv: the hook module's absolute path, then its context as JSON
|
|
6
|
-
// supplied here rather than serialized,
|
|
7
|
-
// process boundary -- the parent reads
|
|
5
|
+
// argv: the hook module's absolute path, then its context as JSON, then
|
|
6
|
+
// optionally `--report-result`. `log` is supplied here rather than serialized,
|
|
7
|
+
// because a function cannot cross the process boundary -- the parent reads
|
|
8
|
+
// stdout back and labels it. For the same reason a hook's return value comes
|
|
9
|
+
// back as one prefixed JSON line on stdout, printed last.
|
|
10
|
+
//
|
|
11
|
+
// The prefix is spelled out rather than imported from importUpdateHook.ts: this
|
|
12
|
+
// entry point stays free of the CLI's module graph, so a hook runs against a
|
|
13
|
+
// fresh process with nothing of ours loaded.
|
|
8
14
|
import { pathToFileURL } from 'url';
|
|
9
15
|
async function main() {
|
|
10
|
-
const [modulePath, contextJson] = process.argv.slice(2);
|
|
16
|
+
const [modulePath, contextJson, flag] = process.argv.slice(2);
|
|
11
17
|
if (!modulePath || !contextJson) {
|
|
12
18
|
throw new Error('usage: importUpdateHookRunner <module> <contextJson>');
|
|
13
19
|
}
|
|
@@ -16,7 +22,13 @@ async function main() {
|
|
|
16
22
|
throw new Error(`${modulePath} does not default-export a function.`);
|
|
17
23
|
}
|
|
18
24
|
const hook = mod.default;
|
|
19
|
-
await hook({
|
|
25
|
+
const result = await hook({
|
|
26
|
+
...JSON.parse(contextJson),
|
|
27
|
+
log: (message) => console.log(message),
|
|
28
|
+
});
|
|
29
|
+
if (flag === '--report-result') {
|
|
30
|
+
console.log(`CASTLE_HOOK_RESULT ${JSON.stringify(result ?? null)}`);
|
|
31
|
+
}
|
|
20
32
|
}
|
|
21
33
|
main().catch((e) => {
|
|
22
34
|
console.error(e instanceof Error ? (e.stack ?? e.message) : String(e));
|
package/dist/imports.d.ts
CHANGED
|
@@ -6,6 +6,22 @@ export interface ImportVersion {
|
|
|
6
6
|
}
|
|
7
7
|
export declare function writeImportVersion(importDir: string, value: ImportVersion): void;
|
|
8
8
|
export declare function readImportVersion(deckDir: string, alias: string): ImportVersion | null;
|
|
9
|
+
export interface BuiltinImportStamp {
|
|
10
|
+
source: 'builtin';
|
|
11
|
+
kit: string;
|
|
12
|
+
version: string;
|
|
13
|
+
digest: string;
|
|
14
|
+
}
|
|
15
|
+
/** A kit tree's files, as a builtin copy takes them: relative path and bytes, hashed. */
|
|
16
|
+
export declare function builtinKitDigest(kitDir: string): string;
|
|
17
|
+
export declare function writeBuiltinStamp(importDir: string, stamp: BuiltinImportStamp): void;
|
|
18
|
+
/** A builtin kit copied into a deck, stamped. `destDir` must not exist. */
|
|
19
|
+
export declare function copyBuiltinKit(kitDir: string, destDir: string, kit: string, version: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* Builtin imports whose copy differs from this CLI's kit of the same version,
|
|
22
|
+
* replaced with this CLI's. Returns the aliases replaced.
|
|
23
|
+
*/
|
|
24
|
+
export declare function refreshStaleBuiltinImports(deckDir: string, log?: (message: string) => void): Promise<string[]>;
|
|
9
25
|
export type ImportErrorCode = 'no-deck-ref' | 'bad-deck-ref' | 'not-a-deck-link' | 'link-unreachable' | 'no-such-dir' | 'self-import' | 'classic-deck' | 'no-source' | 'bad-alias' | 'already-imported';
|
|
10
26
|
export declare class ImportError extends Error {
|
|
11
27
|
code: ImportErrorCode;
|