@nervur.org/installer-node 0.37.1 → 0.37.3
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/README.md +12 -5
- package/cargo/worker.js +275 -231
- package/package.json +3 -3
- package/src/command/act.d.ts +3 -3
- package/src/command/act.js +21 -21
- package/src/command/args.js +5 -3
- package/src/command/before.d.ts +2 -5
- package/src/command/before.js +30 -61
- package/src/command/channel.d.ts +0 -1
- package/src/command/channel.js +7 -12
- package/src/command/commands.js +1 -3
- package/src/command/home.d.ts +8 -0
- package/src/command/home.js +39 -0
- package/src/command/index.js +7 -6
- package/src/command/release.d.ts +0 -2
- package/src/command/release.js +0 -14
- package/src/command/trial.d.ts +1 -2
- package/src/command/trial.js +6 -12
- package/src/command/undone.d.ts +3 -0
- package/src/command/undone.js +21 -0
- package/src/organism/organism.js +3 -3
- package/src/organism/upgrade.d.ts +1 -11
- package/src/organism/upgrade.js +3 -62
- package/src/service/manager.js +1 -1
- package/src/version/version.js +1 -1
- package/src/command/bridge.d.ts +0 -19
- package/src/command/bridge.js +0 -152
- package/src/organism/via.d.ts +0 -7
- package/src/organism/via.js +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nervur.org/installer-node",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.3",
|
|
4
4
|
"description": "Nervur's installer for Node: the nervur command, the door, the host's organs (console, shell, disk, network) with their blueprints. 0.x, unstable.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@nervur.org/floor": "0.37.
|
|
40
|
-
"@nervur.org/genome": "0.37.
|
|
39
|
+
"@nervur.org/floor": "0.37.3",
|
|
40
|
+
"@nervur.org/genome": "0.37.3"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=22.23.5"
|
package/src/command/act.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type Bridging } from './bridge.js';
|
|
2
1
|
import { type Found, type Taking } from './channel.js';
|
|
3
2
|
import { type Given, type Outcome } from './given.js';
|
|
4
3
|
type Why = {
|
|
@@ -9,13 +8,14 @@ export type Reaches = {
|
|
|
9
8
|
readonly take: (version: string, taking: Taking) => Promise<null | Why>;
|
|
10
9
|
readonly keep: (home: string) => Promise<null | Why>;
|
|
11
10
|
readonly moves: (home: string, installer: string) => boolean;
|
|
12
|
-
readonly tried: (given: Given, home: string, installer: string
|
|
11
|
+
readonly tried: (given: Given, home: string, installer: string) => Promise<Outcome>;
|
|
13
12
|
readonly back: (given: Given, home: string) => Promise<boolean | Why>;
|
|
14
13
|
readonly handOver: (installer: string, words?: readonly string[]) => Promise<number | Why>;
|
|
15
14
|
readonly sealed: (given: Given, home: string, genome: string) => Promise<string | Why>;
|
|
16
15
|
readonly commit: (home: string) => void;
|
|
17
16
|
readonly left: (home: string) => readonly string[];
|
|
18
17
|
readonly ran: (home: string) => string | null;
|
|
18
|
+
readonly last: (home: string) => string | null;
|
|
19
19
|
readonly install: (given: Given) => Promise<Outcome>;
|
|
20
20
|
readonly account: (print: (line: string) => void) => Promise<{
|
|
21
21
|
readonly free: () => void;
|
|
@@ -25,7 +25,7 @@ export type Reaches = {
|
|
|
25
25
|
readonly alive: (pid: number) => boolean;
|
|
26
26
|
readonly pid: number;
|
|
27
27
|
readonly parent: number;
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
export declare const REAL: Reaches;
|
|
30
30
|
export declare const act: (given: Given, reaches?: Reaches) => Promise<Outcome>;
|
|
31
31
|
export {};
|
package/src/command/act.js
CHANGED
|
@@ -3,8 +3,8 @@ import { existsSync } from 'node:fs';
|
|
|
3
3
|
import { FLOOR } from '@nervur.org/genome';
|
|
4
4
|
import { socketOf, socketTooLong } from '../../organs/console/node/index.js';
|
|
5
5
|
import { INSTALLER_VERSION, ranOn, readFolder } from '../organism/folder.js';
|
|
6
|
-
import { beforeOf, committed, keptOld,
|
|
7
|
-
import {
|
|
6
|
+
import { beforeOf, committed, keptOld, wentBack } from './before.js';
|
|
7
|
+
import { leftIn } from './undone.js';
|
|
8
8
|
import { atHand, handedOver, taken, viewed, } from './channel.js';
|
|
9
9
|
import { accountHeld, locked } from './locks.js';
|
|
10
10
|
import { designWordOf, floorWordOf } from './choices.js';
|
|
@@ -30,13 +30,8 @@ import { moves, tried, TRYING } from './trial.js';
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
|
|
34
|
+
|
|
40
35
|
|
|
41
36
|
|
|
42
37
|
|
|
@@ -49,6 +44,8 @@ import { moves, tried, TRYING } from './trial.js';
|
|
|
49
44
|
|
|
50
45
|
|
|
51
46
|
|
|
47
|
+
|
|
48
|
+
|
|
52
49
|
|
|
53
50
|
|
|
54
51
|
|
|
@@ -60,7 +57,7 @@ import { moves, tried, TRYING } from './trial.js';
|
|
|
60
57
|
|
|
61
58
|
|
|
62
59
|
|
|
63
|
-
|
|
60
|
+
|
|
64
61
|
|
|
65
62
|
const VERSION = /^\d+\.\d+\.\d+$/;
|
|
66
63
|
const DIGEST = /^[0-9a-f]{64}$/;
|
|
@@ -82,18 +79,18 @@ export const REAL = {
|
|
|
82
79
|
take: taken,
|
|
83
80
|
keep: keptOld,
|
|
84
81
|
moves,
|
|
85
|
-
tried: (given, home, installer
|
|
82
|
+
tried: (given, home, installer) => {
|
|
86
83
|
const folder = readFolder(home);
|
|
87
84
|
if ('why' in folder) return Promise.resolve(folder);
|
|
88
|
-
return tried(given, home, folder.laid, installer,
|
|
85
|
+
return tried(given, home, folder.laid, installer, TRYING);
|
|
89
86
|
},
|
|
90
|
-
...BRIDGING,
|
|
91
87
|
back: goneBack,
|
|
92
88
|
handOver: handedOver,
|
|
93
89
|
sealed: (_given, home, genome) => sealedBack(home, genome),
|
|
94
90
|
commit: committed,
|
|
95
91
|
left: leftIn,
|
|
96
92
|
ran: (home) => (runningOf(home) === null ? null : (ranOn(home) ?? '0.0.0')),
|
|
93
|
+
last: ranOn,
|
|
97
94
|
install,
|
|
98
95
|
account: (print) => accountHeld(print),
|
|
99
96
|
node: () => nodeFinished(),
|
|
@@ -110,7 +107,7 @@ const checked = (home , installer , reaches ) =>
|
|
|
110
107
|
return null;
|
|
111
108
|
};
|
|
112
109
|
|
|
113
|
-
const finished = async (given , reaches , installer
|
|
110
|
+
const finished = async (given , reaches , installer ) => {
|
|
114
111
|
const home = organismOf(given.home);
|
|
115
112
|
if (installer !== INSTALLER_VERSION)
|
|
116
113
|
return { why: `installer-node ${installer} was asked, and the command that runs carries ${INSTALLER_VERSION}` };
|
|
@@ -119,11 +116,14 @@ const finished = async (given , reaches , installer , takin
|
|
|
119
116
|
return {
|
|
120
117
|
why: `installer-node ${installer} is older than ${ran}, which the organism runs: a genome never carries memory backwards`,
|
|
121
118
|
};
|
|
119
|
+
const last = reaches.last(home);
|
|
120
|
+
if (last !== null && isOlder(last, FLOOR))
|
|
121
|
+
return {
|
|
122
|
+
why: `the organism last ran installer-node ${last}, below ${FLOOR}, the oldest this release carries forward: update it to nervur@${FLOOR} first, then to this release`,
|
|
123
|
+
};
|
|
122
124
|
const once = { ...given, asker: askedOnce(given.asker) };
|
|
123
125
|
if (reaches.moves(home, installer)) {
|
|
124
|
-
const
|
|
125
|
-
if ('why' in floors) return floors;
|
|
126
|
-
const trial = await reaches.tried(once, home, installer, (asked, at) => floored(asked, reaches, at, floors));
|
|
126
|
+
const trial = await reaches.tried(once, home, installer);
|
|
127
127
|
if (trial !== null) return trial;
|
|
128
128
|
}
|
|
129
129
|
const done = await reaches.install(once);
|
|
@@ -208,7 +208,7 @@ const byChannel = async (given , reaches , asked , t
|
|
|
208
208
|
if ('why' in found) {
|
|
209
209
|
if (ran !== null || (asked !== null && asked !== INSTALLER_VERSION)) return found;
|
|
210
210
|
given.print(`${found.why}: the installer at hand, ${INSTALLER_VERSION}, goes on.`);
|
|
211
|
-
return finished(given, reaches, INSTALLER_VERSION
|
|
211
|
+
return finished(given, reaches, INSTALLER_VERSION);
|
|
212
212
|
}
|
|
213
213
|
if (ran !== null && isOlder(found.installer, ran)) {
|
|
214
214
|
if (asked === null)
|
|
@@ -222,7 +222,7 @@ const byChannel = async (given , reaches , asked , t
|
|
|
222
222
|
return null;
|
|
223
223
|
}
|
|
224
224
|
if (found.installer === INSTALLER_VERSION && taking.digest === undefined)
|
|
225
|
-
return finished(given, reaches, found.installer
|
|
225
|
+
return finished(given, reaches, found.installer);
|
|
226
226
|
return handedTo(given, reaches, found, taking);
|
|
227
227
|
};
|
|
228
228
|
|
|
@@ -241,8 +241,8 @@ export const act = async (given , reaches = REAL)
|
|
|
241
241
|
const lock = locked(given.home, reaches);
|
|
242
242
|
if ('why' in lock) return lock;
|
|
243
243
|
try {
|
|
244
|
-
if (reaches.handed !== null) return await finished(given, reaches, reaches.handed
|
|
245
|
-
if (!channel) return await finished(given, reaches, INSTALLER_VERSION
|
|
244
|
+
if (reaches.handed !== null) return await finished(given, reaches, reaches.handed);
|
|
245
|
+
if (!channel) return await finished(given, reaches, INSTALLER_VERSION);
|
|
246
246
|
const account = await reaches.account(given.print);
|
|
247
247
|
if ('why' in account) return account;
|
|
248
248
|
try {
|
package/src/command/args.js
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
import { parseArgs } from 'node:util';
|
|
3
3
|
import { CIPHERS } from '@nervur.org/genome';
|
|
4
4
|
import { PORT } from '../door/configuration.js';
|
|
5
|
-
import { INSTALLER_VERSION,
|
|
5
|
+
import { INSTALLER_VERSION, ranOn, wsAddressOf } from '../organism/folder.js';
|
|
6
6
|
import { addressAt } from '../tcp/frame.js';
|
|
7
7
|
import { act } from './act.js';
|
|
8
8
|
import { claimIn } from './claim.js';
|
|
9
9
|
import { chainOf } from './chain.js';
|
|
10
|
+
import { homeOf } from './home.js';
|
|
10
11
|
import { start, stop, } from './commands.js';
|
|
11
12
|
import { line } from './line.js';
|
|
12
13
|
import { accept, offer } from './link.js';
|
|
@@ -192,6 +193,8 @@ export const readArgs = (argv )
|
|
|
192
193
|
if (name === undefined) return { why: '' };
|
|
193
194
|
const command = COMMANDS.get(name);
|
|
194
195
|
if (command === undefined) return { why: `no command ${name}` };
|
|
196
|
+
const home = homeOf(values.home);
|
|
197
|
+
if ('why' in home) return home;
|
|
195
198
|
const choices = choicesOf(values);
|
|
196
199
|
if ('why' in choices) return choices;
|
|
197
200
|
if (choices.cipher !== null && name !== 'rekey') return { why: '--cipher is for rekey' };
|
|
@@ -207,8 +210,7 @@ export const readArgs = (argv )
|
|
|
207
210
|
return {
|
|
208
211
|
command: command.run,
|
|
209
212
|
given: {
|
|
210
|
-
home
|
|
211
|
-
served: values.home === undefined,
|
|
213
|
+
...home,
|
|
212
214
|
...choices,
|
|
213
215
|
...claim,
|
|
214
216
|
words,
|
package/src/command/before.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type Why = {
|
|
|
4
4
|
};
|
|
5
5
|
export declare const beforeOf: (home: string) => string;
|
|
6
6
|
export declare const keptStoreOf: (home: string) => string;
|
|
7
|
+
export declare const logOf: (home: string) => string;
|
|
7
8
|
export declare const arrivalIn: (home: string) => string;
|
|
8
9
|
export declare const backupIn: (home: string) => string;
|
|
9
10
|
export declare const storeFileIn: (home: string) => string;
|
|
@@ -15,9 +16,6 @@ export declare const bootOf: (home: string, trial: boolean) => {
|
|
|
15
16
|
readonly stay?: true;
|
|
16
17
|
readonly skins?: true;
|
|
17
18
|
};
|
|
18
|
-
export declare const leftOf: (home: string) => string;
|
|
19
|
-
export declare const leftAt: (home: string, refused: readonly string[]) => void;
|
|
20
|
-
export declare const leftIn: (home: string) => readonly string[];
|
|
21
19
|
export declare const lockAt: (home: string) => string;
|
|
22
20
|
export declare const lockPid: (file: string) => number | null;
|
|
23
21
|
export declare const actLives: (home: string) => boolean;
|
|
@@ -27,8 +25,7 @@ export declare const keptAside: (home: string, command: Standing | null) => null
|
|
|
27
25
|
export declare const keptOld: (home: string, standing?: () => Promise<Standing | Why>) => Promise<null | Why>;
|
|
28
26
|
export declare const sealing: (home: string) => void;
|
|
29
27
|
export declare const storeAside: (home: string) => void;
|
|
30
|
-
export declare const
|
|
31
|
-
export declare const startedBy: (bin: string, words: readonly string[]) => Promise<null | Why>;
|
|
28
|
+
export declare const logAside: (home: string) => null | Why;
|
|
32
29
|
export declare const committed: (home: string, processes?: Processes) => void;
|
|
33
30
|
export declare const wentBack: (home: string) => {
|
|
34
31
|
readonly store: boolean;
|
package/src/command/before.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
-
import {
|
|
3
|
-
import { execFileSync, spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync, statfsSync, statSync } from 'node:fs';
|
|
4
3
|
import { join } from 'node:path';
|
|
5
4
|
import { storeOf } from '../door/door.js';
|
|
6
|
-
import { foldersLaid, laidWhole, movedWhole, removedWhole
|
|
5
|
+
import { foldersLaid, laidWhole, movedWhole, removedWhole } from '../fills/flushed.js';
|
|
7
6
|
import { halvesOf, laidHalves, pruneHalves } from '../halves/index.js';
|
|
8
7
|
import { stoppedOf } from '../organism/folder.js';
|
|
9
8
|
import { workHalvesOf } from '../work/index.js';
|
|
10
9
|
import { standingCommand } from './channel.js';
|
|
11
|
-
import {
|
|
10
|
+
import { leftOf } from './undone.js';
|
|
11
|
+
import { heldBy, madeToHold, reachedBy, releasesPruned, } from './release.js';
|
|
12
12
|
import { alive, HOST_PROCESSES } from './spawn.js';
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
export const beforeOf = (home ) => join(home, 'before');
|
|
17
17
|
export const keptStoreOf = (home ) => join(beforeOf(home), 'store');
|
|
18
|
+
export const logOf = (home ) => join(storeOf(home), 'primordial-wal');
|
|
19
|
+
const keptLogOf = (home ) => join(beforeOf(home), 'log');
|
|
20
|
+
const noLogOf = (home ) => join(beforeOf(home), 'log.none');
|
|
18
21
|
const keptCommand = (home ) => join(beforeOf(home), 'command');
|
|
19
22
|
const movedWord = (home ) => join(beforeOf(home), 'moved');
|
|
20
23
|
|
|
@@ -45,23 +48,6 @@ export const bootOf = (
|
|
|
45
48
|
...(existsSync(floorOf(home)) ? { skins: true } : {}),
|
|
46
49
|
};
|
|
47
50
|
|
|
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
51
|
export const lockAt = (home ) => join(home, 'update.lock');
|
|
66
52
|
|
|
67
53
|
export const lockPid = (file ) => {
|
|
@@ -118,33 +104,28 @@ export const sealing = (home ) => laidWhole(movedWord(home), '', 0o
|
|
|
118
104
|
|
|
119
105
|
export const storeAside = (home ) => movedWhole(storeOf(home), keptStoreOf(home));
|
|
120
106
|
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
107
|
+
export const logAside = (home ) => {
|
|
108
|
+
const log = logOf(home);
|
|
109
|
+
if (!existsSync(log)) {
|
|
110
|
+
laidWhole(noLogOf(home), '', 0o600);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
const room = roomFor(home, sizeOf(log));
|
|
114
|
+
if (room !== null) return room;
|
|
115
|
+
laidWhole(keptLogOf(home), readFileSync(log), 0o600);
|
|
116
|
+
return null;
|
|
124
117
|
};
|
|
125
118
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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 });
|
|
119
|
+
const logBack = (home ) => {
|
|
120
|
+
if (existsSync(keptLogOf(home))) {
|
|
121
|
+
laidWhole(logOf(home), readFileSync(keptLogOf(home)), 0o600);
|
|
122
|
+
removedWhole(keptLogOf(home));
|
|
123
|
+
return true;
|
|
137
124
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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;
|
|
125
|
+
if (!existsSync(noLogOf(home))) return false;
|
|
126
|
+
removedWhole(logOf(home));
|
|
127
|
+
removedWhole(noLogOf(home));
|
|
128
|
+
return true;
|
|
148
129
|
};
|
|
149
130
|
|
|
150
131
|
const letGo = (home ) => {
|
|
@@ -164,19 +145,6 @@ const commandKept = (home )
|
|
|
164
145
|
}
|
|
165
146
|
};
|
|
166
147
|
|
|
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
148
|
export const committed = (home , processes = HOST_PROCESSES) => {
|
|
181
149
|
const command = commandKept(home);
|
|
182
150
|
letGo(home);
|
|
@@ -186,7 +154,7 @@ export const committed = (home , processes = HOST_PROCESSES)
|
|
|
186
154
|
export const wentBack = (
|
|
187
155
|
home ,
|
|
188
156
|
) => {
|
|
189
|
-
const store = existsSync(keptStoreOf(home));
|
|
157
|
+
const store = existsSync(keptStoreOf(home)) || existsSync(keptLogOf(home)) || existsSync(noLogOf(home));
|
|
190
158
|
const named = existsSync(keptCommand(home));
|
|
191
159
|
const command = named ? commandKept(home) : null;
|
|
192
160
|
storeBack(home);
|
|
@@ -214,11 +182,12 @@ export const wentBack = (
|
|
|
214
182
|
export const storeBack = (home ) => {
|
|
215
183
|
const moved = existsSync(movedWord(home));
|
|
216
184
|
if (moved) laidWhole(stayOf(home), '', 0o600);
|
|
217
|
-
|
|
185
|
+
const laidAside = existsSync(keptStoreOf(home));
|
|
186
|
+
if (laidAside) {
|
|
218
187
|
rmSync(storeOf(home), { recursive: true, force: true });
|
|
219
188
|
movedWhole(keptStoreOf(home), storeOf(home));
|
|
220
|
-
rmSync(leftOf(home), { force: true });
|
|
221
189
|
}
|
|
190
|
+
if (logBack(home) || laidAside) rmSync(leftOf(home), { force: true });
|
|
222
191
|
if (!moved) return;
|
|
223
192
|
removedWhole(stoppedOf(home));
|
|
224
193
|
removedWhole(movedWord(home));
|
package/src/command/channel.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export type Taking = {
|
|
|
18
18
|
readonly package?: string;
|
|
19
19
|
};
|
|
20
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
21
|
export declare const atHand: (folder: string) => Found | Why;
|
|
23
22
|
export declare const standingCommand: () => Promise<Standing | Why>;
|
|
24
23
|
export declare const commanded: () => Promise<string | Why>;
|
package/src/command/channel.js
CHANGED
|
@@ -148,25 +148,23 @@ const laidBeside = async (
|
|
|
148
148
|
spec ,
|
|
149
149
|
words ,
|
|
150
150
|
registry = null,
|
|
151
|
-
hold = true,
|
|
152
151
|
) => {
|
|
153
152
|
const prefix = await run('npm', ['prefix', '-g']);
|
|
154
153
|
if (prefix.code !== 0) return { why: 'npm tells no global prefix to lay the package in' };
|
|
155
154
|
const global = prefix.out.trim();
|
|
156
155
|
const beside = join(global, STAGED);
|
|
157
|
-
|
|
158
|
-
else rmSync(beside, { recursive: true, force: true });
|
|
156
|
+
leftGone(global, HOST_PROCESSES);
|
|
159
157
|
try {
|
|
160
158
|
const ran = await run('npm', ['install', '-g', '--prefix', beside, ...words], registry);
|
|
161
159
|
if (ran.code !== 0) return { why: await refusedWhy(spec, ran, registry) };
|
|
162
|
-
const node =
|
|
163
|
-
return node ?? releaseLaid(global, beside
|
|
160
|
+
const node = await nodeLaid(stagedPackage(beside));
|
|
161
|
+
return node ?? releaseLaid(global, beside);
|
|
164
162
|
} finally {
|
|
165
163
|
rmSync(beside, { recursive: true, force: true });
|
|
166
164
|
}
|
|
167
165
|
};
|
|
168
166
|
|
|
169
|
-
const fromChannel = async (version , taking
|
|
167
|
+
const fromChannel = async (version , taking ) => {
|
|
170
168
|
const spec = `nervur@${version}`;
|
|
171
169
|
const registry = await channel(taking.channel ?? null);
|
|
172
170
|
const folder = mkdtempSync(join(tmpdir(), 'nervur-'));
|
|
@@ -175,7 +173,7 @@ const fromChannel = async (version , taking , hold = true
|
|
|
175
173
|
if (typeof file !== 'string') return file;
|
|
176
174
|
const held = sha256(file);
|
|
177
175
|
if (taking.digest !== undefined && held !== taking.digest) return refusedDigest(spec, held, taking.digest);
|
|
178
|
-
return await laidBeside(spec, [file, ...scoped(registry)], registry
|
|
176
|
+
return await laidBeside(spec, [file, ...scoped(registry)], registry);
|
|
179
177
|
} finally {
|
|
180
178
|
rmSync(folder, { recursive: true, force: true });
|
|
181
179
|
}
|
|
@@ -186,21 +184,18 @@ const packagesIn = (folder ) =>
|
|
|
186
184
|
.filter((name) => name.endsWith('.tgz'))
|
|
187
185
|
.map((name) => join(folder, name));
|
|
188
186
|
|
|
189
|
-
const fromHand = async (version , taking , folder
|
|
187
|
+
const fromHand = async (version , taking , folder ) => {
|
|
190
188
|
const spec = `nervur@${version}`;
|
|
191
189
|
const file = join(folder, `nervur-${version}.tgz`);
|
|
192
190
|
if (!existsSync(file)) return { why: `${folder} holds no ${spec}` };
|
|
193
191
|
const held = sha256(file);
|
|
194
192
|
if (taking.digest !== undefined && held !== taking.digest) return refusedDigest(spec, held, taking.digest);
|
|
195
|
-
return laidBeside(spec, [...packagesIn(folder)], null
|
|
193
|
+
return laidBeside(spec, [...packagesIn(folder)], null);
|
|
196
194
|
};
|
|
197
195
|
|
|
198
196
|
export const taken = (version , taking = {}) =>
|
|
199
197
|
taking.package === undefined ? fromChannel(version, taking) : fromHand(version, taking, taking.package);
|
|
200
198
|
|
|
201
|
-
export const takenAside = (version , taking = {}) =>
|
|
202
|
-
taking.package === undefined ? fromChannel(version, taking, false) : fromHand(version, taking, taking.package, false);
|
|
203
|
-
|
|
204
199
|
export const atHand = (folder ) => {
|
|
205
200
|
const named = readdirSync(folder).flatMap((name) => /^nervur-(\d+\.\d+\.\d+)\.tgz$/.exec(name)?.[1] ?? []);
|
|
206
201
|
const version = named.toSorted((one, other) => one.localeCompare(other, undefined, { numeric: true })).at(-1);
|
package/src/command/commands.js
CHANGED
|
@@ -13,7 +13,6 @@ import { costOf, homeOpened, recoveryCostOf, networkStarts, workHalvesOf, workOf
|
|
|
13
13
|
import { RECOVERY_KEY_DELAY } from '../door/configuration.js';
|
|
14
14
|
import { chosenOf, wordsOf, } from './choices.js';
|
|
15
15
|
import { INSTALLER_VERSION, layFolder, ranOn, readFolder, typedFor, } from '../organism/folder.js';
|
|
16
|
-
import { keepChannel } from '../organism/via.js';
|
|
17
16
|
import { removeService, serviceFor, swapSaid, unitsOf } from '../service/index.js';
|
|
18
17
|
import { laidHalves } from './laid.js';
|
|
19
18
|
import { floorTaken } from './channel.js';
|
|
@@ -24,7 +23,7 @@ import { organismOf, } from './given.js';
|
|
|
24
23
|
import { runningOf, startOrganism } from './spawn.js';
|
|
25
24
|
import { gone, keptAtBoot, signalled, startedAgain, stopped } from './start.js';
|
|
26
25
|
import { bodyOf, removedLaid } from './wipe.js';
|
|
27
|
-
import { leftIn } from './
|
|
26
|
+
import { leftIn } from './undone.js';
|
|
28
27
|
import { claimSaid } from './claim.js';
|
|
29
28
|
|
|
30
29
|
const SHORTEST = 8;
|
|
@@ -237,7 +236,6 @@ export const install = async (given ) => {
|
|
|
237
236
|
if ('why' in first) return first;
|
|
238
237
|
({ key, laid } = first);
|
|
239
238
|
}
|
|
240
|
-
keepChannel(home, given.package === null && (given.served || given.take) ? { named: given.channel } : false);
|
|
241
239
|
if (given.served) {
|
|
242
240
|
const served = await keptAtBoot(given, home, key);
|
|
243
241
|
if (served !== null) return 'laid' in folder ? served : undone(home, served);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
5
|
+
import { ownHome } from '../organism/folder.js';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
const realOf = (path ) => {
|
|
10
|
+
const whole = resolve(path);
|
|
11
|
+
const unmade = [];
|
|
12
|
+
let at = whole;
|
|
13
|
+
for (;;) {
|
|
14
|
+
try {
|
|
15
|
+
return join(realpathSync.native(at), ...unmade);
|
|
16
|
+
} catch {
|
|
17
|
+
const up = dirname(at);
|
|
18
|
+
if (up === at) return whole;
|
|
19
|
+
unmade.unshift(basename(at));
|
|
20
|
+
at = up;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const within = (path , folder ) => {
|
|
26
|
+
const way = relative(folder, path);
|
|
27
|
+
return way !== '' && way !== '..' && !way.startsWith(`..${sep}`) && !isAbsolute(way);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const homeOf = (named ) => {
|
|
31
|
+
const own = ownHome();
|
|
32
|
+
if (named === undefined) return { home: own, served: true };
|
|
33
|
+
const real = realOf(named);
|
|
34
|
+
if (real === realOf(own)) return { home: own, served: true };
|
|
35
|
+
if (within(real, realOf(tmpdir()))) return { home: named, served: false };
|
|
36
|
+
return {
|
|
37
|
+
why: `--home ${named} is refused: an account holds one organism, in ${own}, and a folder of your own is for a test, kept under the temporary folder, ${tmpdir()}. Another organism takes another account.`,
|
|
38
|
+
};
|
|
39
|
+
};
|
package/src/command/index.js
CHANGED
|
@@ -10,14 +10,14 @@ const USAGE = `nervur <command> [--home <folder>] [--port <port>] [--reserve <by
|
|
|
10
10
|
channel your npm config names, and the command it installed finishes:
|
|
11
11
|
it lays the organism where none stands, else keeps the old package,
|
|
12
12
|
stops the organism as it stands, a run going lost to it as to a
|
|
13
|
-
crash,
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
crash, keeps its store's log aside, then boots the new version on the
|
|
14
|
+
store itself as a trial that writes nothing of it but its log and
|
|
15
|
+
touches nothing of the world, which moves the
|
|
16
16
|
installer's organs and the lobes on its faculties: passed, the
|
|
17
17
|
organism starts on it, and what moved is said; failed, the old
|
|
18
18
|
comes back by itself. A digest named, the SHA-256 of the package, is
|
|
19
19
|
the only bytes laid. It does nothing where that version runs already,
|
|
20
|
-
refuses an update with no room for the copy, and a second while
|
|
20
|
+
refuses an update with no room for the log's copy, and a second while
|
|
21
21
|
one runs. With the channel silent and no organism running, the
|
|
22
22
|
installer at hand lays or starts it. It runs by its service, at boot
|
|
23
23
|
from then on, and whoever is present at this account owns it, at its
|
|
@@ -111,8 +111,9 @@ const USAGE = `nervur <command> [--home <folder>] [--port <port>] [--reserve <by
|
|
|
111
111
|
for accept, invitation=<file> or link=<file> in place of the invitation or the link
|
|
112
112
|
--follow for ask and lobe: a job the answer names waited on to its end, as the organism tells it,
|
|
113
113
|
printed whole, the command exiting on its code
|
|
114
|
-
--home the folder of your organism, ~/.nervur by default
|
|
115
|
-
|
|
114
|
+
--home the folder of your organism, ~/.nervur by default: an account holds one organism, so another
|
|
115
|
+
folder is a test's, refused outside the temporary folder, and an install lays it no service
|
|
116
|
+
and takes no package
|
|
116
117
|
--port the port the organism listens on, ${PORT} by default
|
|
117
118
|
--reserve the bytes kept so a full disk still lets the organism answer you, 67108864 by default, 0 for none
|
|
118
119
|
--boot how the organism gets its boot key at every boot: present, a passphrase
|
package/src/command/release.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ type Why = {
|
|
|
3
3
|
};
|
|
4
4
|
export declare const STAGED = ".nervur-taking";
|
|
5
5
|
export declare const commandIn: (prefix: string) => string;
|
|
6
|
-
export declare const releasePackage: (bin: string, version: string) => string | null;
|
|
7
6
|
export type Standing = {
|
|
8
7
|
readonly bin: string;
|
|
9
8
|
readonly held: string;
|
|
@@ -13,7 +12,6 @@ export declare const heldBy: (bin: string) => string | null;
|
|
|
13
12
|
export declare const madeToHold: (bin: string, held: string) => void;
|
|
14
13
|
export declare const stagedPackage: (staged: string) => string;
|
|
15
14
|
export declare const releaseLaid: (prefix: string, staged: string, hold?: boolean) => null | Why;
|
|
16
|
-
export declare const releaseHeld: (bin: string, version: string) => (() => void) | Why;
|
|
17
15
|
export declare const reachedBy: (bin: string, held: string) => string | null;
|
|
18
16
|
export declare const scriptOf: (bin: string) => string | Why;
|
|
19
17
|
export type Told = readonly [number, readonly string[] | string];
|
package/src/command/release.js
CHANGED
|
@@ -19,11 +19,6 @@ const prefixOf = (bin ) => (WINDOWS ? dirname(bin) : dirname(dirn
|
|
|
19
19
|
|
|
20
20
|
const releasesIn = (prefix ) => join(modulesIn(prefix), 'nervur', '.releases');
|
|
21
21
|
|
|
22
|
-
export const releasePackage = (bin , version ) => {
|
|
23
|
-
const release = join(releasesIn(prefixOf(bin)), version);
|
|
24
|
-
return existsSync(release) ? join(modulesIn(release), 'nervur') : null;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
22
|
|
|
28
23
|
|
|
29
24
|
export const heldBy = (bin ) => {
|
|
@@ -69,15 +64,6 @@ export const releaseLaid = (prefix , staged , hold = true
|
|
|
69
64
|
return null;
|
|
70
65
|
};
|
|
71
66
|
|
|
72
|
-
export const releaseHeld = (bin , version ) => {
|
|
73
|
-
const release = join(releasesIn(prefixOf(bin)), version);
|
|
74
|
-
if (!existsSync(release)) return { why: `the release ${version} is not laid beside the command` };
|
|
75
|
-
const before = heldBy(bin);
|
|
76
|
-
if (before === null) return { why: `the command's name at ${bin} holds no release` };
|
|
77
|
-
madeToHold(bin, heldFor(bin, release));
|
|
78
|
-
return () => madeToHold(bin, before);
|
|
79
|
-
};
|
|
80
|
-
|
|
81
67
|
export const reachedBy = (bin , held ) => {
|
|
82
68
|
if (!WINDOWS) return resolve(dirname(bin), held);
|
|
83
69
|
const named = /%~?dp0%?\\([^"]+)"/u.exec(held)?.[1];
|
package/src/command/trial.d.ts
CHANGED
|
@@ -7,8 +7,7 @@ type Why = {
|
|
|
7
7
|
export type Trying = {
|
|
8
8
|
readonly ran: (home: string) => string | null;
|
|
9
9
|
readonly stop: (home: string) => Promise<null | Why>;
|
|
10
|
-
readonly
|
|
11
|
-
readonly floor: (given: Given, home: string) => Promise<null | Why>;
|
|
10
|
+
readonly log: (home: string) => null | Why;
|
|
12
11
|
readonly start: (home: string, key: Uint8Array | null, moves: (said: Moves) => void) => Promise<null | Why>;
|
|
13
12
|
};
|
|
14
13
|
export declare const TRYING: Trying;
|