@nervur.org/installer-node 0.37.2 → 0.37.4
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 +7 -1
- package/cargo/worker.js +13 -21
- package/organs/shell/node/told.js +7 -4
- package/package.json +3 -3
- package/src/command/act.d.ts +3 -3
- package/src/command/act.js +19 -24
- package/src/command/args.js +5 -3
- package/src/command/before.d.ts +0 -2
- package/src/command/before.js +3 -46
- package/src/command/channel.d.ts +0 -1
- package/src/command/channel.js +7 -12
- package/src/command/commands.js +0 -2
- package/src/command/home.d.ts +8 -0
- package/src/command/home.js +39 -0
- package/src/command/index.js +3 -2
- package/src/command/release.d.ts +0 -2
- package/src/command/release.js +0 -14
- package/src/command/trial.d.ts +0 -2
- package/src/command/trial.js +2 -24
- package/src/organism/organism.js +1 -2
- 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/src/organism/upgrade.js
CHANGED
|
@@ -4,10 +4,7 @@ import { appendFileSync, openSync } from 'node:fs';
|
|
|
4
4
|
import { dirname, resolve } from 'node:path';
|
|
5
5
|
|
|
6
6
|
import { commandScript, digestOn, viewed } from '../command/channel.js';
|
|
7
|
-
import {
|
|
8
|
-
import { isOlder } from '../command/lobes.js';
|
|
9
|
-
import { INSTALLER_VERSION, logOf, ownHome } from './folder.js';
|
|
10
|
-
import { channelKept } from './via.js';
|
|
7
|
+
import { logOf, ownHome } from './folder.js';
|
|
11
8
|
|
|
12
9
|
|
|
13
10
|
|
|
@@ -63,15 +60,10 @@ const REAL = {
|
|
|
63
60
|
start: (script, args, log) => startApart(process.env, [process.execPath, script], args, log),
|
|
64
61
|
};
|
|
65
62
|
|
|
66
|
-
export const actWords = (
|
|
67
|
-
home ,
|
|
68
|
-
version ,
|
|
69
|
-
digest ,
|
|
70
|
-
channel ,
|
|
71
|
-
) => [
|
|
63
|
+
export const actWords = (home , version , digest , channel ) => [
|
|
72
64
|
'update',
|
|
73
65
|
version,
|
|
74
|
-
|
|
66
|
+
digest,
|
|
75
67
|
...(channel === null ? [] : ['--channel', channel]),
|
|
76
68
|
...(resolve(dirname(home)) === ownHome() ? [] : ['--home', dirname(home), '--take']),
|
|
77
69
|
];
|
|
@@ -92,54 +84,3 @@ export const upgradeOf =
|
|
|
92
84
|
restart: () => reaches.start(bin, actWords(home, found.version, digest, on), logOf(home)),
|
|
93
85
|
};
|
|
94
86
|
};
|
|
95
|
-
|
|
96
|
-
export const CHECK_EVERY = 3_600_000;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const REAL_CHECKS = {
|
|
111
|
-
view: viewed,
|
|
112
|
-
command: commandScript,
|
|
113
|
-
start: REAL.start,
|
|
114
|
-
kept: channelKept,
|
|
115
|
-
busy: actLives,
|
|
116
|
-
installer: INSTALLER_VERSION,
|
|
117
|
-
every: (ms, run) => {
|
|
118
|
-
run();
|
|
119
|
-
setInterval(run, ms).unref();
|
|
120
|
-
},
|
|
121
|
-
said: (line) => console.error(line),
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const looked = async (home , reaches ) => {
|
|
125
|
-
const kept = reaches.kept(home);
|
|
126
|
-
if (kept === null || reaches.busy(home)) return;
|
|
127
|
-
const found = await reaches.view('nervur@latest', kept.channel);
|
|
128
|
-
if ('why' in found) return reaches.said(`the organism asked its channel for a newer version and heard: ${found.why}`);
|
|
129
|
-
if (!isOlder(reaches.installer, found.installer)) return;
|
|
130
|
-
const bin = await reaches.command();
|
|
131
|
-
if (typeof bin !== 'string') return reaches.said(`the organism did not update to ${found.version}: ${bin.why}`);
|
|
132
|
-
reaches.said(
|
|
133
|
-
`nervur@${found.version} carries installer-node ${found.installer}, newer than ${reaches.installer}: the organism updates itself`,
|
|
134
|
-
);
|
|
135
|
-
reaches.start(bin, actWords(home, found.version, null, kept.channel), logOf(home));
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
export const checking = (home , reaches = REAL_CHECKS) =>
|
|
139
|
-
reaches.every(CHECK_EVERY, () => {
|
|
140
|
-
looked(home, reaches).catch((thrown ) =>
|
|
141
|
-
reaches.said(
|
|
142
|
-
`the organism's check of its channel failed: ${thrown instanceof Error ? thrown.message : String(thrown)}`,
|
|
143
|
-
),
|
|
144
|
-
);
|
|
145
|
-
});
|
package/src/service/manager.js
CHANGED
|
@@ -59,7 +59,7 @@ export const serviceFor = (folder ) => {
|
|
|
59
59
|
|
|
60
60
|
const noSystemctl = () => spawnSync('systemctl', ['--version'], { stdio: 'ignore' }).error !== undefined;
|
|
61
61
|
const NO_SYSTEMCTL = {
|
|
62
|
-
why: 'this machine has no systemctl, so nothing could start the organism at boot
|
|
62
|
+
why: 'this machine has no systemctl, so nothing could start the organism at boot',
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
const lingering = () => {
|
package/src/version/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// SPDX-License-Identifier: FSL-1.1-ALv2
|
|
2
|
-
export const INSTALLER_VERSION = '0.37.
|
|
2
|
+
export const INSTALLER_VERSION = '0.37.4';
|
package/src/command/bridge.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
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 {};
|
package/src/command/bridge.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
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
|
-
};
|
package/src/organism/via.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const channelFileOf: (home: string) => string;
|
|
2
|
-
export declare const channelKept: (home: string) => {
|
|
3
|
-
readonly channel: string | null;
|
|
4
|
-
} | null;
|
|
5
|
-
export declare const keepChannel: (home: string, channel: false | {
|
|
6
|
-
readonly named: string | null;
|
|
7
|
-
}) => void;
|
package/src/organism/via.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 channelFileOf = (home ) => join(home, 'organism.channel');
|
|
7
|
-
|
|
8
|
-
export const channelKept = (home ) => {
|
|
9
|
-
try {
|
|
10
|
-
const named = readFileSync(channelFileOf(home), 'utf8').trim();
|
|
11
|
-
return { channel: named === '' ? null : named };
|
|
12
|
-
} catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const keepChannel = (home , channel ) => {
|
|
18
|
-
if (channel === false) rmSync(channelFileOf(home), { force: true });
|
|
19
|
-
else laidWhole(channelFileOf(home), channel.named === null ? '' : `${channel.named}\n`, 0o600);
|
|
20
|
-
};
|