@nervur.org/installer-node 0.37.1 → 0.37.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nervur.org/installer-node",
3
- "version": "0.37.1",
3
+ "version": "0.37.2",
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.1",
40
- "@nervur.org/genome": "0.37.1"
39
+ "@nervur.org/floor": "0.37.2",
40
+ "@nervur.org/genome": "0.37.2"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=22.23.5"
@@ -9,7 +9,7 @@ export type Reaches = {
9
9
  readonly take: (version: string, taking: Taking) => Promise<null | Why>;
10
10
  readonly keep: (home: string) => Promise<null | Why>;
11
11
  readonly moves: (home: string, installer: string) => boolean;
12
- readonly tried: (given: Given, home: string, installer: string, floor: (given: Given, home: string) => Promise<null | Why>) => Promise<Outcome>;
12
+ readonly tried: (given: Given, home: string, installer: string, floor: ((given: Given, home: string) => Promise<null | Why>) | null) => Promise<Outcome>;
13
13
  readonly back: (given: Given, home: string) => Promise<boolean | Why>;
14
14
  readonly handOver: (installer: string, words?: readonly string[]) => Promise<number | Why>;
15
15
  readonly sealed: (given: Given, home: string, genome: string) => Promise<string | Why>;
@@ -3,7 +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, leftIn, wentBack } from './before.js';
6
+ import { beforeOf, committed, keptOld, wentBack } from './before.js';
7
+ import { leftIn } from './undone.js';
7
8
  import { BRIDGING, floorsAside, floored, } from './bridge.js';
8
9
  import { atHand, handedOver, taken, viewed, } from './channel.js';
9
10
  import { accountHeld, locked } from './locks.js';
@@ -30,12 +31,12 @@ import { moves, tried, TRYING } from './trial.js';
30
31
 
31
32
 
32
33
 
33
-
34
+
34
35
 
35
36
 
36
37
 
37
38
 
38
-
39
+
39
40
 
40
41
 
41
42
 
@@ -123,7 +124,11 @@ const finished = async (given , reaches , installer , takin
123
124
  if (reaches.moves(home, installer)) {
124
125
  const floors = await floorsAside(once, reaches, home, taking);
125
126
  if ('why' in floors) return floors;
126
- const trial = await reaches.tried(once, home, installer, (asked, at) => floored(asked, reaches, at, floors));
127
+ const floor =
128
+ floors.length === 0
129
+ ? null
130
+ : (asked , at ) => floored(asked, reaches, at, floors);
131
+ const trial = await reaches.tried(once, home, installer, floor);
127
132
  if (trial !== null) return trial;
128
133
  }
129
134
  const done = await reaches.install(once);
@@ -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,6 +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;
28
+ export declare const logAside: (home: string) => null | Why;
30
29
  export declare const storeCopied: (home: string) => null | Why;
31
30
  export declare const startedBy: (bin: string, words: readonly string[]) => Promise<null | Why>;
32
31
  export declare const committed: (home: string, processes?: Processes) => void;
@@ -8,6 +8,7 @@ import { halvesOf, laidHalves, pruneHalves } from '../halves/index.js';
8
8
  import { stoppedOf } from '../organism/folder.js';
9
9
  import { workHalvesOf } from '../work/index.js';
10
10
  import { standingCommand } from './channel.js';
11
+ import { leftOf } from './undone.js';
11
12
  import { heldBy, madeToHold, reachedBy, releasesPruned, scriptOf, } from './release.js';
12
13
  import { alive, HOST_PROCESSES } from './spawn.js';
13
14
 
@@ -15,6 +16,9 @@ import { alive, HOST_PROCESSES } from './spawn.js';
15
16
 
16
17
  export const beforeOf = (home ) => join(home, 'before');
17
18
  export const keptStoreOf = (home ) => join(beforeOf(home), 'store');
19
+ export const logOf = (home ) => join(storeOf(home), 'primordial-wal');
20
+ const keptLogOf = (home ) => join(beforeOf(home), 'log');
21
+ const noLogOf = (home ) => join(beforeOf(home), 'log.none');
18
22
  const keptCommand = (home ) => join(beforeOf(home), 'command');
19
23
  const movedWord = (home ) => join(beforeOf(home), 'moved');
20
24
 
@@ -45,23 +49,6 @@ export const bootOf = (
45
49
  ...(existsSync(floorOf(home)) ? { skins: true } : {}),
46
50
  };
47
51
 
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
52
  export const lockAt = (home ) => join(home, 'update.lock');
66
53
 
67
54
  export const lockPid = (file ) => {
@@ -118,6 +105,30 @@ export const sealing = (home ) => laidWhole(movedWord(home), '', 0o
118
105
 
119
106
  export const storeAside = (home ) => movedWhole(storeOf(home), keptStoreOf(home));
120
107
 
108
+ export const logAside = (home ) => {
109
+ const log = logOf(home);
110
+ if (!existsSync(log)) {
111
+ laidWhole(noLogOf(home), '', 0o600);
112
+ return null;
113
+ }
114
+ const room = roomFor(home, sizeOf(log));
115
+ if (room !== null) return room;
116
+ laidWhole(keptLogOf(home), readFileSync(log), 0o600);
117
+ return null;
118
+ };
119
+
120
+ const logBack = (home ) => {
121
+ if (existsSync(keptLogOf(home))) {
122
+ laidWhole(logOf(home), readFileSync(keptLogOf(home)), 0o600);
123
+ removedWhole(keptLogOf(home));
124
+ return true;
125
+ }
126
+ if (!existsSync(noLogOf(home))) return false;
127
+ removedWhole(logOf(home));
128
+ removedWhole(noLogOf(home));
129
+ return true;
130
+ };
131
+
121
132
  const CLONE = {
122
133
  darwin: ['-c', '-R', '-p'],
123
134
  linux: ['-R', '-p', '--reflink=auto'],
@@ -186,7 +197,7 @@ export const committed = (home , processes = HOST_PROCESSES)
186
197
  export const wentBack = (
187
198
  home ,
188
199
  ) => {
189
- const store = existsSync(keptStoreOf(home));
200
+ const store = existsSync(keptStoreOf(home)) || existsSync(keptLogOf(home)) || existsSync(noLogOf(home));
190
201
  const named = existsSync(keptCommand(home));
191
202
  const command = named ? commandKept(home) : null;
192
203
  storeBack(home);
@@ -214,11 +225,12 @@ export const wentBack = (
214
225
  export const storeBack = (home ) => {
215
226
  const moved = existsSync(movedWord(home));
216
227
  if (moved) laidWhole(stayOf(home), '', 0o600);
217
- if (existsSync(keptStoreOf(home))) {
228
+ const laidAside = existsSync(keptStoreOf(home));
229
+ if (laidAside) {
218
230
  rmSync(storeOf(home), { recursive: true, force: true });
219
231
  movedWhole(keptStoreOf(home), storeOf(home));
220
- rmSync(leftOf(home), { force: true });
221
232
  }
233
+ if (logBack(home) || laidAside) rmSync(leftOf(home), { force: true });
222
234
  if (!moved) return;
223
235
  removedWhole(stoppedOf(home));
224
236
  removedWhole(movedWord(home));
@@ -24,7 +24,7 @@ import { organismOf, } from './given.js';
24
24
  import { runningOf, startOrganism } from './spawn.js';
25
25
  import { gone, keptAtBoot, signalled, startedAgain, stopped } from './start.js';
26
26
  import { bodyOf, removedLaid } from './wipe.js';
27
- import { leftIn } from './before.js';
27
+ import { leftIn } from './undone.js';
28
28
  import { claimSaid } from './claim.js';
29
29
 
30
30
  const SHORTEST = 8;
@@ -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, lays its store aside untouched and a copy of it beside, a clone
14
- where the disk gives one, then boots the new version on the copy as a
15
- trial that touches nothing of the world, which moves the
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
@@ -7,8 +7,9 @@ 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 log: (home: string) => null | Why;
10
11
  readonly copy: (home: string) => null | Why;
11
- readonly floor: (given: Given, home: string) => Promise<null | Why>;
12
+ readonly floor: ((given: Given, home: string) => Promise<null | Why>) | null;
12
13
  readonly start: (home: string, key: Uint8Array | null, moves: (said: Moves) => void) => Promise<null | Why>;
13
14
  };
14
15
  export declare const TRYING: Trying;
@@ -3,7 +3,17 @@ import { existsSync } from 'node:fs';
3
3
  import { storeOf } from '../door/door.js';
4
4
  import { ranOn, } from '../organism/folder.js';
5
5
 
6
- import { beforeOf, committed, halvesBack, keptAside, storeAside, storeBack, storeCopied, wentBack } from './before.js';
6
+ import {
7
+ beforeOf,
8
+ committed,
9
+ halvesBack,
10
+ keptAside,
11
+ logAside,
12
+ storeAside,
13
+ storeBack,
14
+ storeCopied,
15
+ wentBack,
16
+ } from './before.js';
7
17
 
8
18
  import { laidHalves } from './laid.js';
9
19
  import { runningOf, startOrganism } from './spawn.js';
@@ -22,10 +32,12 @@ const checkOf = (home , installer , reaches ) =
22
32
 
23
33
 
24
34
 
25
-
35
+
36
+
37
+
26
38
 
27
-
28
-
39
+
40
+
29
41
 
30
42
 
31
43
 
@@ -38,11 +50,18 @@ const ended = async (home ) => {
38
50
  export const TRYING = {
39
51
  ran: ranOn,
40
52
  stop: ended,
53
+ log: logAside,
41
54
  copy: storeCopied,
42
- floor: () => Promise.resolve(null),
55
+ floor: null,
43
56
  start: (home, key, moves) => startOrganism(home, 'trial', key, moves),
44
57
  };
45
58
 
59
+ const keptFor = async (given , home , reaches ) => {
60
+ if (reaches.floor === null) return reaches.log(home);
61
+ if (existsSync(storeOf(home))) storeAside(home);
62
+ return reaches.copy(home) ?? (await reaches.floor(given, home));
63
+ };
64
+
46
65
  export const tried = async (
47
66
  given ,
48
67
  home ,
@@ -69,11 +88,8 @@ export const tried = async (
69
88
  if (halves !== null) return back(halves);
70
89
  const down = await reaches.stop(home);
71
90
  if (down !== null) return back({ why: `the organism did not stop for the trial: ${down.why}` });
72
- if (existsSync(storeOf(home))) storeAside(home);
73
- const copied = reaches.copy(home);
74
- if (copied !== null) return back(copied);
75
- const floor = await reaches.floor(given, home);
76
- if (floor !== null) return back(floor);
91
+ const kept = await keptFor(given, home, reaches);
92
+ if (kept !== null) return back(kept);
77
93
  let moves = { moved: [], refused: [] };
78
94
  const started = await reaches.start(home, key, (said) => {
79
95
  moves = said;
@@ -0,0 +1,3 @@
1
+ export declare const leftOf: (home: string) => string;
2
+ export declare const leftAt: (home: string, refused: readonly string[]) => void;
3
+ export declare const leftIn: (home: string) => readonly string[];
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: FSL-1.1-ALv2
2
+ import { readFileSync, rmSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { laidWhole } from '../fills/flushed.js';
5
+
6
+ export const leftOf = (home ) => join(home, 'update.left');
7
+
8
+ export const leftAt = (home , refused ) => {
9
+ if (refused.length === 0) rmSync(leftOf(home), { force: true });
10
+ else laidWhole(leftOf(home), `${refused.join('\n')}\n`, 0o600);
11
+ };
12
+
13
+ export const leftIn = (home ) => {
14
+ try {
15
+ return readFileSync(leftOf(home), 'utf8')
16
+ .split('\n')
17
+ .filter((line) => line !== '');
18
+ } catch {
19
+ return [];
20
+ }
21
+ };
@@ -19,7 +19,8 @@ import { beginBeat, endBeat } from './beat.js';
19
19
  import { lineOf, STOPPED, } from './said.js';
20
20
  import { keyAtSocket } from './unlock.js';
21
21
  import { checking, upgradeOf } from './upgrade.js';
22
- import { actLives, beforeOf, bootOf, floorOf, leftAt, leftOf, stayOf, wentBack } from '../command/before.js';
22
+ import { actLives, beforeOf, bootOf, floorOf, stayOf, wentBack } from '../command/before.js';
23
+ import { leftAt, leftOf } from '../command/undone.js';
23
24
  import { prunedBeside } from '../command/laid.js';
24
25
 
25
26
  const KEY = 32;
@@ -1,2 +1,2 @@
1
1
  // SPDX-License-Identifier: FSL-1.1-ALv2
2
- export const INSTALLER_VERSION = '0.37.1';
2
+ export const INSTALLER_VERSION = '0.37.2';