@nervur.org/installer-node 0.0.0-stage → 0.37.1
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/LICENSE +105 -0
- package/README.md +158 -2
- package/SECURITY.md +8 -0
- package/bin/nervur.js +5 -0
- package/cargo/emscripten-module.wasm +0 -0
- package/cargo/manifest.json +1 -0
- package/cargo/sqlite3.wasm +0 -0
- package/cargo/table-i-i.wasm +0 -0
- package/cargo/table-i-ii.wasm +0 -0
- package/cargo/table-i-iii.wasm +0 -0
- package/cargo/table-i-iiii.wasm +0 -0
- package/cargo/table-i-iiiii.wasm +0 -0
- package/cargo/table-i-iiij.wasm +0 -0
- package/cargo/table-i-ij.wasm +0 -0
- package/cargo/table-v-ii.wasm +0 -0
- package/cargo/table-v-iii.wasm +0 -0
- package/cargo/worker.js +30756 -0
- package/organs/console/node/guard.d.ts +10 -0
- package/organs/console/node/guard.js +52 -0
- package/organs/console/node/index.d.ts +4 -0
- package/organs/console/node/index.js +5 -0
- package/organs/console/node/line.d.ts +16 -0
- package/organs/console/node/line.js +150 -0
- package/organs/console/node/main.js +51 -0
- package/organs/console/node/program.d.ts +1 -0
- package/organs/console/node/program.js +5 -0
- package/organs/console/node/proof.d.ts +15 -0
- package/organs/console/node/proof.js +84 -0
- package/organs/console/node/socket.d.ts +15 -0
- package/organs/console/node/socket.js +99 -0
- package/organs/disk/index.d.ts +1 -0
- package/organs/disk/index.js +2 -0
- package/organs/disk/node/files.js +162 -0
- package/organs/disk/node/main.js +20 -0
- package/organs/disk/node/program.d.ts +1 -0
- package/organs/disk/node/program.js +5 -0
- package/organs/disk/organ.d.ts +5 -0
- package/organs/disk/organ.js +69 -0
- package/organs/network/node/fill.d.ts +21 -0
- package/organs/network/node/fill.js +195 -0
- package/organs/network/node/flows.js +66 -0
- package/organs/network/node/half.js +260 -0
- package/organs/network/node/lines.d.ts +29 -0
- package/organs/network/node/lines.js +236 -0
- package/organs/network/node/link.d.ts +24 -0
- package/organs/network/node/link.js +215 -0
- package/organs/network/node/main.js +41 -0
- package/organs/network/node/moved.d.ts +2 -0
- package/organs/network/node/moved.js +20 -0
- package/organs/network/node/near.d.ts +63 -0
- package/organs/network/node/near.js +263 -0
- package/organs/network/node/program.d.ts +1 -0
- package/organs/network/node/program.js +5 -0
- package/organs/network/node/schemes.d.ts +1 -0
- package/organs/network/node/schemes.js +2 -0
- package/organs/network/node/sent.d.ts +13 -0
- package/organs/network/node/sent.js +101 -0
- package/organs/network/node/served.d.ts +19 -0
- package/organs/network/node/served.js +237 -0
- package/organs/screen/node/client.js +3 -0
- package/organs/screen/node/follow.js +266 -0
- package/organs/screen/node/frames.js +26 -0
- package/organs/screen/node/held.js +27 -0
- package/organs/screen/node/http.js +179 -0
- package/organs/screen/node/lay.js +116 -0
- package/organs/screen/node/leave.js +27 -0
- package/organs/screen/node/linked.js +69 -0
- package/organs/screen/node/listen.js +61 -0
- package/organs/screen/node/look.js +121 -0
- package/organs/screen/node/loop.js +154 -0
- package/organs/screen/node/main.js +74 -0
- package/organs/screen/node/mirror.js +112 -0
- package/organs/screen/node/notice.js +44 -0
- package/organs/screen/node/presser.js +11 -0
- package/organs/screen/node/presses.js +108 -0
- package/organs/screen/node/program.d.ts +1 -0
- package/organs/screen/node/program.js +5 -0
- package/organs/screen/node/shown.js +205 -0
- package/organs/screen/node/standing.js +29 -0
- package/organs/screen/node/state.js +80 -0
- package/organs/screen/node/tell.js +47 -0
- package/organs/screen/node/uid.js +65 -0
- package/organs/screen/node/worn.js +23 -0
- package/organs/shell/index.d.ts +1 -0
- package/organs/shell/index.js +2 -0
- package/organs/shell/node/main.js +26 -0
- package/organs/shell/node/output.js +70 -0
- package/organs/shell/node/pressure.js +14 -0
- package/organs/shell/node/program.d.ts +1 -0
- package/organs/shell/node/program.js +5 -0
- package/organs/shell/node/runs.js +220 -0
- package/organs/shell/node/told.js +70 -0
- package/organs/shell/organ.d.ts +5 -0
- package/organs/shell/organ.js +59 -0
- package/package.json +43 -4
- package/src/command/act.d.ts +31 -0
- package/src/command/act.js +256 -0
- package/src/command/answers.d.ts +3 -0
- package/src/command/answers.js +232 -0
- package/src/command/args.d.ts +14 -0
- package/src/command/args.js +220 -0
- package/src/command/arrive.d.ts +2 -0
- package/src/command/arrive.js +21 -0
- package/src/command/asked.d.ts +18 -0
- package/src/command/asked.js +49 -0
- package/src/command/backup.d.ts +18 -0
- package/src/command/backup.js +261 -0
- package/src/command/before.d.ts +41 -0
- package/src/command/before.js +237 -0
- package/src/command/born.d.ts +27 -0
- package/src/command/born.js +103 -0
- package/src/command/bridge.d.ts +19 -0
- package/src/command/bridge.js +152 -0
- package/src/command/chain.d.ts +9 -0
- package/src/command/chain.js +48 -0
- package/src/command/channel.d.ts +29 -0
- package/src/command/channel.js +263 -0
- package/src/command/choices.d.ts +35 -0
- package/src/command/choices.js +173 -0
- package/src/command/claim.d.ts +12 -0
- package/src/command/claim.js +46 -0
- package/src/command/commands.d.ts +16 -0
- package/src/command/commands.js +257 -0
- package/src/command/ends.d.ts +16 -0
- package/src/command/ends.js +78 -0
- package/src/command/follow.d.ts +12 -0
- package/src/command/follow.js +66 -0
- package/src/command/given.d.ts +39 -0
- package/src/command/given.js +53 -0
- package/src/command/held.d.ts +15 -0
- package/src/command/held.js +56 -0
- package/src/command/index.d.ts +1 -0
- package/src/command/index.js +203 -0
- package/src/command/jailer.d.ts +28 -0
- package/src/command/jailer.js +135 -0
- package/src/command/laid.d.ts +6 -0
- package/src/command/laid.js +31 -0
- package/src/command/left.d.ts +9 -0
- package/src/command/left.js +34 -0
- package/src/command/line.d.ts +7 -0
- package/src/command/line.js +39 -0
- package/src/command/link.d.ts +30 -0
- package/src/command/link.js +123 -0
- package/src/command/lobes.d.ts +1 -0
- package/src/command/lobes.js +10 -0
- package/src/command/locks.d.ts +17 -0
- package/src/command/locks.js +76 -0
- package/src/command/mcp/calls.d.ts +27 -0
- package/src/command/mcp/calls.js +155 -0
- package/src/command/mcp/notices.d.ts +22 -0
- package/src/command/mcp/notices.js +203 -0
- package/src/command/mcp/resources.d.ts +31 -0
- package/src/command/mcp/resources.js +108 -0
- package/src/command/mcp/server.d.ts +19 -0
- package/src/command/mcp/server.js +149 -0
- package/src/command/mcp/tools.d.ts +39 -0
- package/src/command/mcp/tools.js +131 -0
- package/src/command/mcp.d.ts +8 -0
- package/src/command/mcp.js +39 -0
- package/src/command/noticed.d.ts +11 -0
- package/src/command/noticed.js +55 -0
- package/src/command/older.d.ts +11 -0
- package/src/command/older.js +45 -0
- package/src/command/open.d.ts +24 -0
- package/src/command/open.js +107 -0
- package/src/command/passphrase.d.ts +6 -0
- package/src/command/passphrase.js +82 -0
- package/src/command/reclaim.d.ts +7 -0
- package/src/command/reclaim.js +47 -0
- package/src/command/refused.d.ts +4 -0
- package/src/command/refused.js +27 -0
- package/src/command/release.d.ts +27 -0
- package/src/command/release.js +153 -0
- package/src/command/repo.d.ts +31 -0
- package/src/command/repo.js +133 -0
- package/src/command/rewrap.d.ts +16 -0
- package/src/command/rewrap.js +175 -0
- package/src/command/runtime.d.ts +25 -0
- package/src/command/runtime.js +175 -0
- package/src/command/salvage.d.ts +4 -0
- package/src/command/salvage.js +42 -0
- package/src/command/screen.d.ts +14 -0
- package/src/command/screen.js +62 -0
- package/src/command/spawn.d.ts +23 -0
- package/src/command/spawn.js +213 -0
- package/src/command/start.d.ts +34 -0
- package/src/command/start.js +246 -0
- package/src/command/state.d.ts +5 -0
- package/src/command/state.js +39 -0
- package/src/command/token.d.ts +1 -0
- package/src/command/token.js +9 -0
- package/src/command/trial.d.ts +17 -0
- package/src/command/trial.js +92 -0
- package/src/command/vouch.d.ts +1 -0
- package/src/command/vouch.js +15 -0
- package/src/command/windows-processes.d.ts +2 -0
- package/src/command/windows-processes.js +22 -0
- package/src/command/wipe.d.ts +9 -0
- package/src/command/wipe.js +105 -0
- package/src/command/words.d.ts +5 -0
- package/src/command/words.js +53 -0
- package/src/door/claim.d.ts +5 -0
- package/src/door/claim.js +21 -0
- package/src/door/claimed.d.ts +7 -0
- package/src/door/claimed.js +110 -0
- package/src/door/configuration.d.ts +40 -0
- package/src/door/configuration.js +206 -0
- package/src/door/design.d.ts +13 -0
- package/src/door/design.js +71 -0
- package/src/door/digests.d.ts +7 -0
- package/src/door/digests.js +36 -0
- package/src/door/distribution.d.ts +25 -0
- package/src/door/distribution.js +88 -0
- package/src/door/door.d.ts +41 -0
- package/src/door/door.js +219 -0
- package/src/door/dressed.d.ts +34 -0
- package/src/door/dressed.js +182 -0
- package/src/door/faculties.d.ts +29 -0
- package/src/door/faculties.js +88 -0
- package/src/door/longest.d.ts +6 -0
- package/src/door/longest.js +25 -0
- package/src/fills/account-only.d.ts +3 -0
- package/src/fills/account-only.js +24 -0
- package/src/fills/boot-key.d.ts +21 -0
- package/src/fills/boot-key.js +70 -0
- package/src/fills/boot-move.d.ts +25 -0
- package/src/fills/boot-move.js +86 -0
- package/src/fills/bridge.d.ts +13 -0
- package/src/fills/bridge.js +86 -0
- package/src/fills/chance.d.ts +2 -0
- package/src/fills/chance.js +7 -0
- package/src/fills/crypto.d.ts +2 -0
- package/src/fills/crypto.js +94 -0
- package/src/fills/flushed.d.ts +9 -0
- package/src/fills/flushed.js +80 -0
- package/src/fills/hardware.d.ts +18 -0
- package/src/fills/hardware.js +70 -0
- package/src/fills/held.d.ts +31 -0
- package/src/fills/held.js +171 -0
- package/src/fills/keepers.d.ts +23 -0
- package/src/fills/keepers.js +151 -0
- package/src/fills/keyring.d.ts +19 -0
- package/src/fills/keyring.js +131 -0
- package/src/fills/pages.d.ts +3 -0
- package/src/fills/pages.js +260 -0
- package/src/fills/reserve.d.ts +11 -0
- package/src/fills/reserve.js +72 -0
- package/src/fills/time.d.ts +2 -0
- package/src/fills/time.js +29 -0
- package/src/fills/unlocker.d.ts +6 -0
- package/src/fills/unlocker.js +26 -0
- package/src/fills/vitals.d.ts +8 -0
- package/src/fills/vitals.js +100 -0
- package/src/fills/windows-start.d.ts +2 -0
- package/src/fills/windows-start.js +21 -0
- package/src/halves/build.d.ts +10 -0
- package/src/halves/build.js +219 -0
- package/src/halves/end.d.ts +17 -0
- package/src/halves/end.js +157 -0
- package/src/halves/genome.d.ts +3 -0
- package/src/halves/genome.js +21 -0
- package/src/halves/handler.d.ts +8 -0
- package/src/halves/handler.js +40 -0
- package/src/halves/index.d.ts +5 -0
- package/src/halves/index.js +6 -0
- package/src/halves/laid.d.ts +12 -0
- package/src/halves/laid.js +103 -0
- package/src/halves/lent.d.ts +6 -0
- package/src/halves/lent.js +147 -0
- package/src/halves/native.d.ts +12 -0
- package/src/halves/native.js +53 -0
- package/src/halves/statements.d.ts +23 -0
- package/src/halves/statements.js +165 -0
- package/src/halves/tokens.d.ts +22 -0
- package/src/halves/tokens.js +135 -0
- package/src/link/link.d.ts +4 -0
- package/src/link/link.js +4 -0
- package/src/link/placeholder.d.ts +1 -0
- package/src/link/placeholder.js +21 -0
- package/src/link/steps.d.ts +52 -0
- package/src/link/steps.js +118 -0
- package/src/lobes/calls.d.ts +76 -0
- package/src/lobes/calls.js +61 -0
- package/src/lobes/channel.d.ts +76 -0
- package/src/lobes/channel.js +202 -0
- package/src/lobes/index.d.ts +1 -0
- package/src/lobes/index.js +2 -0
- package/src/lobes/lobes.d.ts +15 -0
- package/src/lobes/lobes.js +244 -0
- package/src/lobes/main.js +107 -0
- package/src/lobes/thread.d.ts +22 -0
- package/src/lobes/thread.js +270 -0
- package/src/organism/act.d.ts +8 -0
- package/src/organism/act.js +63 -0
- package/src/organism/beat.d.ts +5 -0
- package/src/organism/beat.js +45 -0
- package/src/organism/compiled.d.ts +2 -0
- package/src/organism/compiled.js +24 -0
- package/src/organism/folder.d.ts +88 -0
- package/src/organism/folder.js +259 -0
- package/src/organism/main.d.ts +1 -0
- package/src/organism/main.js +11 -0
- package/src/organism/organism.d.ts +1 -0
- package/src/organism/organism.js +219 -0
- package/src/organism/said.d.ts +12 -0
- package/src/organism/said.js +30 -0
- package/src/organism/told.d.ts +5 -0
- package/src/organism/told.js +110 -0
- package/src/organism/unlock.d.ts +8 -0
- package/src/organism/unlock.js +95 -0
- package/src/organism/upgrade.d.ts +24 -0
- package/src/organism/upgrade.js +145 -0
- package/src/organism/via.d.ts +7 -0
- package/src/organism/via.js +20 -0
- package/src/service/body.d.ts +8 -0
- package/src/service/body.js +34 -0
- package/src/service/handler.d.ts +20 -0
- package/src/service/handler.js +128 -0
- package/src/service/index.d.ts +4 -0
- package/src/service/index.js +16 -0
- package/src/service/manager.d.ts +18 -0
- package/src/service/manager.js +185 -0
- package/src/service/service.d.ts +24 -0
- package/src/service/service.js +200 -0
- package/src/service/swap.d.ts +12 -0
- package/src/service/swap.js +74 -0
- package/src/service/watchdog.d.ts +6 -0
- package/src/service/watchdog.js +31 -0
- package/src/tcp/crowd.d.ts +18 -0
- package/src/tcp/crowd.js +85 -0
- package/src/tcp/dial.d.ts +23 -0
- package/src/tcp/dial.js +102 -0
- package/src/tcp/frame.d.ts +23 -0
- package/src/tcp/frame.js +159 -0
- package/src/tcp/listen.d.ts +50 -0
- package/src/tcp/listen.js +207 -0
- package/src/tcp/source.d.ts +2 -0
- package/src/tcp/source.js +26 -0
- package/src/version/index.d.ts +1 -0
- package/src/version/index.js +2 -0
- package/src/version/version.d.ts +1 -0
- package/src/version/version.js +2 -0
- package/src/work/first.d.ts +11 -0
- package/src/work/first.js +91 -0
- package/src/work/index.d.ts +2 -0
- package/src/work/index.js +15 -0
- package/src/work/work.d.ts +20 -0
- package/src/work/work.js +136 -0
- package/src/ws/dial.d.ts +7 -0
- package/src/ws/dial.js +252 -0
- package/src/ws/dialing.d.ts +50 -0
- package/src/ws/dialing.js +72 -0
- package/src/ws/frame.d.ts +32 -0
- package/src/ws/frame.js +124 -0
- package/src/ws/handshake.d.ts +4 -0
- package/src/ws/handshake.js +27 -0
- package/src/ws/line.d.ts +45 -0
- package/src/ws/line.js +250 -0
- package/src/ws/listen.d.ts +42 -0
- package/src/ws/listen.js +272 -0
- package/src/ws/rfc6455.d.ts +18 -0
- package/src/ws/rfc6455.js +187 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { cpSync, existsSync, readdirSync, readFileSync, rmdirSync, rmSync, statfsSync, statSync } from 'node:fs';
|
|
3
|
+
import { execFileSync, spawn } from 'node:child_process';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { storeOf } from '../door/door.js';
|
|
6
|
+
import { foldersLaid, laidWhole, movedWhole, removedWhole, treeFlushed } from '../fills/flushed.js';
|
|
7
|
+
import { halvesOf, laidHalves, pruneHalves } from '../halves/index.js';
|
|
8
|
+
import { stoppedOf } from '../organism/folder.js';
|
|
9
|
+
import { workHalvesOf } from '../work/index.js';
|
|
10
|
+
import { standingCommand } from './channel.js';
|
|
11
|
+
import { heldBy, madeToHold, reachedBy, releasesPruned, scriptOf, } from './release.js';
|
|
12
|
+
import { alive, HOST_PROCESSES } from './spawn.js';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export const beforeOf = (home ) => join(home, 'before');
|
|
17
|
+
export const keptStoreOf = (home ) => join(beforeOf(home), 'store');
|
|
18
|
+
const keptCommand = (home ) => join(beforeOf(home), 'command');
|
|
19
|
+
const movedWord = (home ) => join(beforeOf(home), 'moved');
|
|
20
|
+
|
|
21
|
+
const halfFolders = (home ) => [
|
|
22
|
+
[halvesOf(home), join(beforeOf(home), 'halves')],
|
|
23
|
+
[workHalvesOf(home), join(beforeOf(home), 'work')],
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
export const arrivalIn = (home ) => `${home}.arrival`;
|
|
27
|
+
|
|
28
|
+
export const backupIn = (home ) => join(storeOf(home), 'primordial.backup');
|
|
29
|
+
|
|
30
|
+
export const storeFileIn = (home ) => join(storeOf(home), 'primordial');
|
|
31
|
+
|
|
32
|
+
export const stayOf = (home ) => join(home, 'stay');
|
|
33
|
+
|
|
34
|
+
export const floorOf = (home ) => join(home, 'floor');
|
|
35
|
+
|
|
36
|
+
export const bootOf = (
|
|
37
|
+
home ,
|
|
38
|
+
trial ,
|
|
39
|
+
) =>
|
|
40
|
+
trial
|
|
41
|
+
? { kind: 'boot', trial: true }
|
|
42
|
+
: {
|
|
43
|
+
kind: 'boot',
|
|
44
|
+
...(existsSync(stayOf(home)) ? { stay: true } : {}),
|
|
45
|
+
...(existsSync(floorOf(home)) ? { skins: true } : {}),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const leftOf = (home ) => join(home, 'update.left');
|
|
49
|
+
|
|
50
|
+
export const leftAt = (home , refused ) => {
|
|
51
|
+
if (refused.length === 0) rmSync(leftOf(home), { force: true });
|
|
52
|
+
else laidWhole(leftOf(home), `${refused.join('\n')}\n`, 0o600);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const leftIn = (home ) => {
|
|
56
|
+
try {
|
|
57
|
+
return readFileSync(leftOf(home), 'utf8')
|
|
58
|
+
.split('\n')
|
|
59
|
+
.filter((line) => line !== '');
|
|
60
|
+
} catch {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const lockAt = (home ) => join(home, 'update.lock');
|
|
66
|
+
|
|
67
|
+
export const lockPid = (file ) => {
|
|
68
|
+
try {
|
|
69
|
+
const pid = Number(readFileSync(file, 'utf8').trim());
|
|
70
|
+
return Number.isInteger(pid) && pid > 0 ? pid : null;
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const actLives = (home ) => {
|
|
77
|
+
const pid = lockPid(lockAt(home));
|
|
78
|
+
return pid !== null && alive(pid);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const sizeOf = (path ) => {
|
|
82
|
+
const stat = statSync(path, { throwIfNoEntry: false });
|
|
83
|
+
if (stat === undefined) return 0;
|
|
84
|
+
if (!stat.isDirectory()) return stat.size;
|
|
85
|
+
return readdirSync(path).reduce((sum, name) => sum + sizeOf(join(path, name)), 0);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const roomFor = (home , bytes ) => {
|
|
89
|
+
const { bavail, bsize } = statfsSync(home);
|
|
90
|
+
const free = bavail * bsize;
|
|
91
|
+
return free > bytes
|
|
92
|
+
? null
|
|
93
|
+
: { why: `the way back needs ${bytes} bytes, and the disk holds ${free}: the update is refused, nothing changed` };
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const wayBackBytes = (command ) => (command === null ? 0 : sizeOf(command.root));
|
|
97
|
+
|
|
98
|
+
export const keptAside = (home , command ) => {
|
|
99
|
+
const room = roomFor(home, wayBackBytes(command));
|
|
100
|
+
if (room !== null) return room;
|
|
101
|
+
rmSync(beforeOf(home), { recursive: true, force: true });
|
|
102
|
+
foldersLaid(beforeOf(home), 0o700);
|
|
103
|
+
for (const [folder, named] of halfFolders(home)) laidWhole(named, laidHalves(folder).join('\n'), 0o600);
|
|
104
|
+
if (command !== null) laidWhole(keptCommand(home), `${command.bin}\n${command.held}`, 0o600);
|
|
105
|
+
return null;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const keptOld = async (
|
|
109
|
+
home ,
|
|
110
|
+
standing = standingCommand,
|
|
111
|
+
) => {
|
|
112
|
+
const command = await standing();
|
|
113
|
+
if ('why' in command) return { why: `the package that runs is not found, so no way back stands: ${command.why}` };
|
|
114
|
+
return keptAside(home, command);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const sealing = (home ) => laidWhole(movedWord(home), '', 0o600);
|
|
118
|
+
|
|
119
|
+
export const storeAside = (home ) => movedWhole(storeOf(home), keptStoreOf(home));
|
|
120
|
+
|
|
121
|
+
const CLONE = {
|
|
122
|
+
darwin: ['-c', '-R', '-p'],
|
|
123
|
+
linux: ['-R', '-p', '--reflink=auto'],
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export const storeCopied = (home ) => {
|
|
127
|
+
const kept = keptStoreOf(home);
|
|
128
|
+
const store = storeOf(home);
|
|
129
|
+
if (existsSync(store)) return { why: `a store stands at ${store}, where the trial's copy goes` };
|
|
130
|
+
const room = roomFor(home, sizeOf(kept));
|
|
131
|
+
if (room !== null) return room;
|
|
132
|
+
const clone = CLONE[process.platform];
|
|
133
|
+
try {
|
|
134
|
+
if (clone !== undefined) execFileSync('cp', [...clone, kept, store], { stdio: 'ignore' });
|
|
135
|
+
} catch {
|
|
136
|
+
rmSync(store, { recursive: true, force: true });
|
|
137
|
+
}
|
|
138
|
+
try {
|
|
139
|
+
if (!existsSync(store)) cpSync(kept, store, { recursive: true, errorOnExist: true, force: false });
|
|
140
|
+
} catch (thrown) {
|
|
141
|
+
rmSync(store, { recursive: true, force: true });
|
|
142
|
+
return {
|
|
143
|
+
why: `the store is not copied for the trial: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
treeFlushed(store);
|
|
147
|
+
return null;
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const letGo = (home ) => {
|
|
151
|
+
const going = `${beforeOf(home)}.gone`;
|
|
152
|
+
rmSync(going, { recursive: true, force: true });
|
|
153
|
+
if (existsSync(beforeOf(home))) movedWhole(beforeOf(home), going);
|
|
154
|
+
rmSync(going, { recursive: true, force: true });
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const commandKept = (home ) => {
|
|
158
|
+
try {
|
|
159
|
+
const kept = readFileSync(keptCommand(home), 'utf8');
|
|
160
|
+
const at = kept.indexOf('\n');
|
|
161
|
+
return at <= 0 || at === kept.length - 1 ? null : { bin: kept.slice(0, at), held: kept.slice(at + 1) };
|
|
162
|
+
} catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const startedBy = async (bin , words ) => {
|
|
168
|
+
const { NERVUR_HANDED: _handed, ...env } = process.env;
|
|
169
|
+
const script = scriptOf(bin);
|
|
170
|
+
if (typeof script !== 'string') return script;
|
|
171
|
+
const code = await new Promise ((done) => {
|
|
172
|
+
const child = spawn(process.execPath, [script, ...words], { stdio: 'inherit', env });
|
|
173
|
+
child.on('error', (failed) => done({ why: `its command did not start: ${failed.message}` }));
|
|
174
|
+
child.on('close', (ended) => done(ended ?? 1));
|
|
175
|
+
});
|
|
176
|
+
if (typeof code === 'object') return code;
|
|
177
|
+
return code === 0 ? null : { why: `its start ended ${code}` };
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const committed = (home , processes = HOST_PROCESSES) => {
|
|
181
|
+
const command = commandKept(home);
|
|
182
|
+
letGo(home);
|
|
183
|
+
if (command !== null) releasesPruned(command.bin, processes);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const wentBack = (
|
|
187
|
+
home ,
|
|
188
|
+
) => {
|
|
189
|
+
const store = existsSync(keptStoreOf(home));
|
|
190
|
+
const named = existsSync(keptCommand(home));
|
|
191
|
+
const command = named ? commandKept(home) : null;
|
|
192
|
+
storeBack(home);
|
|
193
|
+
const reached = command === null ? null : reachedBy(command.bin, command.held);
|
|
194
|
+
const gone = reached !== null && !existsSync(reached);
|
|
195
|
+
const moved = command !== null && !gone && heldBy(command.bin) !== command.held;
|
|
196
|
+
if (moved) madeToHold(command.bin, command.held);
|
|
197
|
+
halvesBack(home);
|
|
198
|
+
letGo(home);
|
|
199
|
+
if (gone)
|
|
200
|
+
return {
|
|
201
|
+
store,
|
|
202
|
+
package: false,
|
|
203
|
+
why: `the release the command ran before, ${reached}, is gone: the store went back, the package that stands stays`,
|
|
204
|
+
};
|
|
205
|
+
if (named && command === null)
|
|
206
|
+
return {
|
|
207
|
+
store,
|
|
208
|
+
package: false,
|
|
209
|
+
why: `the way back of an update named no place for its package: the store went back, the package that stands stays`,
|
|
210
|
+
};
|
|
211
|
+
return { store, package: moved };
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export const storeBack = (home ) => {
|
|
215
|
+
const moved = existsSync(movedWord(home));
|
|
216
|
+
if (moved) laidWhole(stayOf(home), '', 0o600);
|
|
217
|
+
if (existsSync(keptStoreOf(home))) {
|
|
218
|
+
rmSync(storeOf(home), { recursive: true, force: true });
|
|
219
|
+
movedWhole(keptStoreOf(home), storeOf(home));
|
|
220
|
+
rmSync(leftOf(home), { force: true });
|
|
221
|
+
}
|
|
222
|
+
if (!moved) return;
|
|
223
|
+
removedWhole(stoppedOf(home));
|
|
224
|
+
removedWhole(movedWord(home));
|
|
225
|
+
rmSync(arrivalIn(home), { force: true });
|
|
226
|
+
rmSync(backupIn(home), { force: true });
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const halvesBack = (home ) => {
|
|
230
|
+
for (const [folder, named] of halfFolders(home))
|
|
231
|
+
if (existsSync(named)) pruneHalves(folder, new Set(readFileSync(named, 'utf8').split('\n')));
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export const freed = (file , home , laid ) => {
|
|
235
|
+
rmSync(file, { force: true });
|
|
236
|
+
if (laid !== undefined && existsSync(home) && readdirSync(home).length === 0) rmdirSync(home);
|
|
237
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Laid } from '../organism/folder.js';
|
|
2
|
+
import type { Work } from '../work/index.js';
|
|
3
|
+
import type { BootMode } from '../door/configuration.js';
|
|
4
|
+
import type { Given } from './given.js';
|
|
5
|
+
type Chosen = Given & {
|
|
6
|
+
readonly port: number;
|
|
7
|
+
readonly bootMode: BootMode;
|
|
8
|
+
};
|
|
9
|
+
type Reached = {
|
|
10
|
+
readonly publicHost?: string;
|
|
11
|
+
readonly ws?: string;
|
|
12
|
+
readonly work?: Work;
|
|
13
|
+
readonly screen?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare const bornHeld: (given: Chosen, home: string, reached: Reached) => Promise<{
|
|
16
|
+
readonly key: Uint8Array | null;
|
|
17
|
+
} | {
|
|
18
|
+
readonly why: string;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const keptHeld: (given: Given, home: string, laid: Exclude<Laid, {
|
|
21
|
+
readonly bootMode: 'file' | 'present';
|
|
22
|
+
}>) => Promise<{
|
|
23
|
+
readonly key: Uint8Array | null;
|
|
24
|
+
} | {
|
|
25
|
+
readonly why: string;
|
|
26
|
+
}>;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { drawnBootKey } from '../fills/boot-key.js';
|
|
3
|
+
import {
|
|
4
|
+
custodyOf,
|
|
5
|
+
endCustodyOf,
|
|
6
|
+
fingerprintHere,
|
|
7
|
+
hostHands,
|
|
8
|
+
layFingerprint,
|
|
9
|
+
priceOf,
|
|
10
|
+
terminalOf,
|
|
11
|
+
|
|
12
|
+
} from '../fills/held.js';
|
|
13
|
+
import { KEEPER_SPAN } from '../fills/keepers.js';
|
|
14
|
+
import { bootKeyOf, saltOf } from '../fills/unlocker.js';
|
|
15
|
+
import { layFolder, } from '../organism/folder.js';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
import { passphraseTwice } from './commands.js';
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const keyPlaced = async (
|
|
25
|
+
named ,
|
|
26
|
+
home ,
|
|
27
|
+
laid ,
|
|
28
|
+
key ,
|
|
29
|
+
hands ,
|
|
30
|
+
) => {
|
|
31
|
+
const kept = await endCustodyOf(home, laid, hands).keep(key);
|
|
32
|
+
if (kept !== null) return kept;
|
|
33
|
+
if (laid.bootMode !== 'remote') return null;
|
|
34
|
+
const fingerprint = fingerprintHere(laid, home);
|
|
35
|
+
const keepers = hands.keepers(home, laid.keeperSpan ?? KEEPER_SPAN);
|
|
36
|
+
for (const invitation of named) {
|
|
37
|
+
const added = await keepers.added(invitation, key, fingerprint);
|
|
38
|
+
if (added !== null) return added;
|
|
39
|
+
}
|
|
40
|
+
layFingerprint(home, fingerprint);
|
|
41
|
+
return null;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const bornHeld = async (
|
|
45
|
+
given ,
|
|
46
|
+
home ,
|
|
47
|
+
reached ,
|
|
48
|
+
) => {
|
|
49
|
+
const hands = given.hands ?? hostHands();
|
|
50
|
+
const held = heldLaid(given, reached);
|
|
51
|
+
if ('why' in held) return held;
|
|
52
|
+
const refused = refusalOf(held, hands);
|
|
53
|
+
if (refused !== null) return refused;
|
|
54
|
+
const end = terminalOf(held);
|
|
55
|
+
const typed = end === 'present' ? await passphraseTwice(given.asker, given.short) : null;
|
|
56
|
+
if (typed !== null && typeof typed !== 'string') return typed;
|
|
57
|
+
const salt = typed === null ? null : saltOf();
|
|
58
|
+
const laid = salt === null ? held : { ...held, salt };
|
|
59
|
+
const folder = layFolder(home, laid);
|
|
60
|
+
if (folder !== null) return folder;
|
|
61
|
+
const key = typed === null || salt === null ? drawnBootKey() : await bootKeyOf(typed, salt);
|
|
62
|
+
const placed = await keyPlaced(given.keepers, home, laid, key, hands);
|
|
63
|
+
if (placed !== null) return placed;
|
|
64
|
+
given.print(priceOf(home, laid));
|
|
65
|
+
return { key: end === 'present' ? key : null };
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const heldLaid = (given , reached ) => {
|
|
69
|
+
if (given.bootMode === 'keyring' || given.bootMode === 'hardware')
|
|
70
|
+
return { port: given.port, bootMode: given.bootMode, ...reached };
|
|
71
|
+
if (given.keepers.length === 0) return { why: '--boot remote names at least one --keeper <invitation-file>' };
|
|
72
|
+
return { port: given.port, bootMode: 'remote', end: given.end ?? 'present', ...reached };
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const refusalOf = (laid , hands ) => {
|
|
76
|
+
const end = terminalOf(laid);
|
|
77
|
+
if (end === 'keyring' && 'why' in hands.keyring) return hands.keyring;
|
|
78
|
+
if (end === 'hardware' && 'why' in hands.board) return hands.board;
|
|
79
|
+
return null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const keptHeld = async (
|
|
83
|
+
given ,
|
|
84
|
+
home ,
|
|
85
|
+
laid ,
|
|
86
|
+
) => {
|
|
87
|
+
const hands = given.hands ?? hostHands();
|
|
88
|
+
const opened = await custodyOf(home, laid, hands).open();
|
|
89
|
+
if (opened !== null && 'why' in opened) return opened;
|
|
90
|
+
if (opened !== null) return { key: null };
|
|
91
|
+
if (laid.bootMode === 'remote' && given.keepers.length === 0)
|
|
92
|
+
return { why: '--boot remote names at least one --keeper <invitation-file>' };
|
|
93
|
+
const present = laid.bootMode === 'remote' && terminalOf(laid) === 'present';
|
|
94
|
+
const typed = present ? await passphraseTwice(given.asker, given.short) : null;
|
|
95
|
+
if (typed !== null && typeof typed !== 'string') return typed;
|
|
96
|
+
const salt = laid.bootMode === 'remote' ? laid.salt : undefined;
|
|
97
|
+
if (present && salt === undefined) return { why: 'the folder holds no salt for its passphrase' };
|
|
98
|
+
const key = typed === null || salt === undefined ? drawnBootKey() : await bootKeyOf(typed, salt);
|
|
99
|
+
const placed = await keyPlaced(given.keepers, home, laid, key, hands);
|
|
100
|
+
if (placed !== null) return placed;
|
|
101
|
+
given.print(priceOf(home, laid));
|
|
102
|
+
return { key: present ? key : null };
|
|
103
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Reaches } from './act.js';
|
|
2
|
+
import { type Found, type Taking } from './channel.js';
|
|
3
|
+
import type { Given } from './given.js';
|
|
4
|
+
type Why = {
|
|
5
|
+
readonly why: string;
|
|
6
|
+
};
|
|
7
|
+
export type Bridging = {
|
|
8
|
+
readonly last: (home: string) => string | null;
|
|
9
|
+
readonly aside: (version: string, taking: Taking) => Promise<null | Why>;
|
|
10
|
+
readonly floorOf: (version: string) => Promise<string | null | Why>;
|
|
11
|
+
readonly hold: (version: string) => Promise<(() => void) | Why>;
|
|
12
|
+
readonly open: (given: Given, home: string) => Promise<null | Why>;
|
|
13
|
+
readonly stop: (home: string) => Promise<null | Why>;
|
|
14
|
+
};
|
|
15
|
+
export declare const floorCarried: (folder: string) => Promise<string | null | Why>;
|
|
16
|
+
export declare const BRIDGING: Bridging;
|
|
17
|
+
export declare const floorsAside: (given: Given, reaches: Reaches, home: string, taking: Taking) => Promise<readonly Found[] | Why>;
|
|
18
|
+
export declare const floored: (given: Given, reaches: Reaches, home: string, floors: readonly Found[]) => Promise<null | Why>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { FLOOR } from '@nervur.org/genome';
|
|
3
|
+
import { ranOn } from '../organism/folder.js';
|
|
4
|
+
|
|
5
|
+
import { rmSync, writeFileSync } from 'node:fs';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { join } from 'node:path';
|
|
8
|
+
import { pathToFileURL } from 'node:url';
|
|
9
|
+
import { lockAt, startedBy } from './before.js';
|
|
10
|
+
import { commanded, takenAside, } from './channel.js';
|
|
11
|
+
|
|
12
|
+
import { isOlder } from './lobes.js';
|
|
13
|
+
import { releaseHeld, releasePackage } from './release.js';
|
|
14
|
+
import { runningOf } from './spawn.js';
|
|
15
|
+
import { stopped } from './start.js';
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const VERSION = /^\d+\.\d+\.\d+$/;
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export const floorCarried = async (folder ) => {
|
|
37
|
+
try {
|
|
38
|
+
const entry = createRequire(join(folder, 'node_modules', '@nervur.org', 'installer-node', 'package.json')).resolve(
|
|
39
|
+
'@nervur.org/genome',
|
|
40
|
+
);
|
|
41
|
+
const exported = await import(pathToFileURL(entry).href);
|
|
42
|
+
const floor = typeof exported === 'object' && exported !== null && 'FLOOR' in exported ? exported.FLOOR : undefined;
|
|
43
|
+
if (floor === undefined) return null;
|
|
44
|
+
return typeof floor === 'string' && VERSION.test(floor)
|
|
45
|
+
? floor
|
|
46
|
+
: { why: 'its genome exports a floor that is no version' };
|
|
47
|
+
} catch (thrown) {
|
|
48
|
+
return { why: `its genome reads not: ${thrown instanceof Error ? thrown.message : String(thrown)}` };
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const BRIDGING = {
|
|
53
|
+
last: ranOn,
|
|
54
|
+
aside: takenAside,
|
|
55
|
+
floorOf: async (version) => {
|
|
56
|
+
const bin = await commanded();
|
|
57
|
+
if (typeof bin !== 'string') return bin;
|
|
58
|
+
const folder = releasePackage(bin, version);
|
|
59
|
+
return folder === null ? { why: `the release ${version} is not laid beside the command` } : floorCarried(folder);
|
|
60
|
+
},
|
|
61
|
+
hold: async (version) => {
|
|
62
|
+
const bin = await commanded();
|
|
63
|
+
return typeof bin === 'string' ? releaseHeld(bin, version) : bin;
|
|
64
|
+
},
|
|
65
|
+
open: async (given) => {
|
|
66
|
+
const bin = await commanded();
|
|
67
|
+
if (typeof bin !== 'string') return bin;
|
|
68
|
+
return startedBy(bin, ['start', ...(given.served ? [] : ['--home', given.home])]);
|
|
69
|
+
},
|
|
70
|
+
stop: (home) => {
|
|
71
|
+
const running = runningOf(home);
|
|
72
|
+
return running === null ? Promise.resolve(null) : stopped(home, running);
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const floorsAside = async (
|
|
77
|
+
given ,
|
|
78
|
+
reaches ,
|
|
79
|
+
home ,
|
|
80
|
+
taking ,
|
|
81
|
+
) => {
|
|
82
|
+
const last = reaches.last(home);
|
|
83
|
+
if (last === null || !isOlder(last, FLOOR)) return [];
|
|
84
|
+
if (!given.served && !given.take)
|
|
85
|
+
return {
|
|
86
|
+
why: `the organism last ran installer-node ${last}, below ${FLOOR}, the floor, and a home of its own takes no package to open it: name --take`,
|
|
87
|
+
};
|
|
88
|
+
const { digest: _this, ...plain } = taking;
|
|
89
|
+
const laid = [];
|
|
90
|
+
let floor = FLOOR;
|
|
91
|
+
let above = null;
|
|
92
|
+
while (floor !== null && isOlder(last, floor)) {
|
|
93
|
+
const of = above === null ? '' : ` of nervur@${above.version}`;
|
|
94
|
+
const found = await reaches.view(`nervur@${floor}`, plain);
|
|
95
|
+
if ('why' in found)
|
|
96
|
+
return {
|
|
97
|
+
why: `the organism last ran installer-node ${last}, below ${floor}, the floor${of}, which nervur@${floor} opens first, and that is not found: ${found.why}`,
|
|
98
|
+
};
|
|
99
|
+
given.print(
|
|
100
|
+
above === null
|
|
101
|
+
? `The organism last ran installer-node ${last}, below the floor: nervur@${found.version} opens it first.`
|
|
102
|
+
: `The floor nervur@${above.version} carries forward from is ${found.version}: nervur@${found.version} opens it before.`,
|
|
103
|
+
);
|
|
104
|
+
const put = await reaches.aside(found.version, plain);
|
|
105
|
+
if (put !== null) return { why: `nervur@${found.version}, the floor${of}, could not be laid: ${put.why}` };
|
|
106
|
+
laid.push(found);
|
|
107
|
+
const next = await reaches.floorOf(found.version);
|
|
108
|
+
if (next !== null && typeof next === 'object')
|
|
109
|
+
return { why: `nervur@${found.version}, the floor${of}, tells no floor it carries forward from: ${next.why}` };
|
|
110
|
+
if (next !== null && !isOlder(next, found.version))
|
|
111
|
+
return {
|
|
112
|
+
why: `nervur@${found.version}, the floor${of}, names ${next} as its floor, which is no release below it`,
|
|
113
|
+
};
|
|
114
|
+
above = found;
|
|
115
|
+
floor = next;
|
|
116
|
+
}
|
|
117
|
+
return laid.toReversed();
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const crossed = async (given , reaches , home , floor ) => {
|
|
121
|
+
const back = await reaches.hold(floor.version);
|
|
122
|
+
if (typeof back !== 'function')
|
|
123
|
+
return { why: `nervur@${floor.version}, the floor, did not open the organism: ${back.why}` };
|
|
124
|
+
const named = lockAt(home);
|
|
125
|
+
let opened ;
|
|
126
|
+
let at ;
|
|
127
|
+
let down ;
|
|
128
|
+
try {
|
|
129
|
+
writeFileSync(named, `${reaches.pid}\n`, { mode: 0o600 });
|
|
130
|
+
opened = await reaches.open(given, home).finally(() => rmSync(named, { force: true }));
|
|
131
|
+
at = reaches.last(home);
|
|
132
|
+
down = await reaches.stop(home);
|
|
133
|
+
} finally {
|
|
134
|
+
back();
|
|
135
|
+
}
|
|
136
|
+
const ran = at === floor.installer ? null : { why: `it runs on installer-node ${at ?? 'none'}` };
|
|
137
|
+
const why = opened ?? ran ?? down;
|
|
138
|
+
return why === null ? null : { why: `nervur@${floor.version}, the floor, did not open the organism: ${why.why}` };
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const floored = async (
|
|
142
|
+
given ,
|
|
143
|
+
reaches ,
|
|
144
|
+
home ,
|
|
145
|
+
floors ,
|
|
146
|
+
) => {
|
|
147
|
+
for (const floor of floors) {
|
|
148
|
+
const why = await crossed(given, reaches, home, floor);
|
|
149
|
+
if (why !== null) return why;
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
152
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BootMode } from '../door/configuration.js';
|
|
2
|
+
import type { Given } from './given.js';
|
|
3
|
+
export declare const chainOf: (keeper: readonly string[] | undefined, ending: string | undefined, boot: string | undefined) => {
|
|
4
|
+
readonly bootMode: BootMode | null;
|
|
5
|
+
readonly end: Given['end'];
|
|
6
|
+
readonly keepers: readonly string[];
|
|
7
|
+
} | {
|
|
8
|
+
readonly why: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const BOOT_MODES = new Map([
|
|
7
|
+
['present', 'present'],
|
|
8
|
+
['keyring', 'keyring'],
|
|
9
|
+
['remote', 'remote'],
|
|
10
|
+
['file', 'file'],
|
|
11
|
+
['hardware', 'hardware'],
|
|
12
|
+
]);
|
|
13
|
+
const MODES = new Map([
|
|
14
|
+
['present', 'present'],
|
|
15
|
+
['keyring', 'keyring'],
|
|
16
|
+
['file', 'file'],
|
|
17
|
+
['hardware', 'hardware'],
|
|
18
|
+
]);
|
|
19
|
+
|
|
20
|
+
export const chainOf = (
|
|
21
|
+
keeper ,
|
|
22
|
+
ending ,
|
|
23
|
+
boot ,
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
) => {
|
|
27
|
+
const bootMode = boot === undefined ? null : BOOT_MODES.get(boot);
|
|
28
|
+
if (bootMode === undefined) return { why: `--boot is present, keyring, remote, file or hardware, not ${boot ?? ''}` };
|
|
29
|
+
const end = ending === undefined ? null : MODES.get(ending);
|
|
30
|
+
if (end === undefined)
|
|
31
|
+
return {
|
|
32
|
+
why: `--end is present, keyring, file or hardware: a chain of keepers ends at another mode, not ${ending ?? ''}`,
|
|
33
|
+
};
|
|
34
|
+
const files = keeper ?? [];
|
|
35
|
+
if (bootMode !== 'remote' && (files.length > 0 || end !== null))
|
|
36
|
+
return { why: '--keeper and --end name a chain of keepers, which --boot remote lays' };
|
|
37
|
+
if (bootMode === 'remote' && files.length === 0)
|
|
38
|
+
return { why: '--boot remote names at least one --keeper <invitation-file>' };
|
|
39
|
+
const keepers = [];
|
|
40
|
+
for (const file of files) {
|
|
41
|
+
try {
|
|
42
|
+
keepers.push(readFileSync(file, 'utf8'));
|
|
43
|
+
} catch (thrown) {
|
|
44
|
+
return { why: `--keeper reads no file at ${file}: ${thrown instanceof Error ? thrown.message : String(thrown)}` };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { bootMode, end, keepers };
|
|
48
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Distribution } from '../door/distribution.js';
|
|
2
|
+
import { type Standing } from './release.js';
|
|
3
|
+
type Why = {
|
|
4
|
+
readonly why: string;
|
|
5
|
+
};
|
|
6
|
+
export type Found = {
|
|
7
|
+
readonly version: string;
|
|
8
|
+
readonly installer: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const channelOf: (said: string) => string | null;
|
|
11
|
+
export declare const startedBy: (program: string, args: readonly string[], platform: NodeJS.Platform, node: string) => readonly [string, readonly string[]];
|
|
12
|
+
export declare const floorTaken: (spec: string, named: string | null) => Promise<Distribution | Why>;
|
|
13
|
+
export declare const viewed: (spec: string, named?: string | null) => Promise<Found | Why>;
|
|
14
|
+
export declare const digestOn: (version: string, named?: string | null) => Promise<string | Why>;
|
|
15
|
+
export type Taking = {
|
|
16
|
+
readonly digest?: string;
|
|
17
|
+
readonly channel?: string;
|
|
18
|
+
readonly package?: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const taken: (version: string, taking?: Taking) => Promise<null | Why>;
|
|
21
|
+
export declare const takenAside: (version: string, taking?: Taking) => Promise<null | Why>;
|
|
22
|
+
export declare const atHand: (folder: string) => Found | Why;
|
|
23
|
+
export declare const standingCommand: () => Promise<Standing | Why>;
|
|
24
|
+
export declare const commanded: () => Promise<string | Why>;
|
|
25
|
+
export declare const packageRoot: () => Promise<string | Why>;
|
|
26
|
+
export declare const handedOver: (installer: string, words?: readonly string[]) => Promise<number | Why>;
|
|
27
|
+
export declare const commandScript: () => Promise<string | Why>;
|
|
28
|
+
export declare const globalPrefix: () => Promise<string | Why>;
|
|
29
|
+
export {};
|