@volter/world-core 3.0.62 → 3.0.64
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/pack-paths.d.ts +4 -1
- package/dist/src/pack-paths.js +20 -4
- package/package.json +1 -1
- package/src/pack-paths.ts +14 -4
package/dist/src/pack-paths.d.ts
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
export declare function packVendor(dir: string): string | undefined;
|
|
3
3
|
/** Nearest installed package wins only over another installation of the SAME package. A World's explicit
|
|
4
4
|
* package choice wins over a catalog recommendation; different publishers' versions never compete. */
|
|
5
|
-
export declare function installedVendorPacks(from: string
|
|
5
|
+
export declare function installedVendorPacks(from: string, options?: {
|
|
6
|
+
sources?: Readonly<Record<string, string>>;
|
|
7
|
+
vendors?: readonly string[];
|
|
8
|
+
}): Map<string, string>;
|
|
6
9
|
/** Node's nearest installed package, including linked packages and hoisted workspace dependencies. */
|
|
7
10
|
export declare function installedPackageDir(from: string, name: string): string | undefined;
|
|
8
11
|
/** A pack repository itself, or the P3 repository beside a platform checkout. Applications do not acquire a
|
package/dist/src/pack-paths.js
CHANGED
|
@@ -26,10 +26,11 @@ export function packVendor(dir) {
|
|
|
26
26
|
}
|
|
27
27
|
/** Nearest installed package wins only over another installation of the SAME package. A World's explicit
|
|
28
28
|
* package choice wins over a catalog recommendation; different publishers' versions never compete. */
|
|
29
|
-
export function installedVendorPacks(from) {
|
|
29
|
+
export function installedVendorPacks(from, options = {}) {
|
|
30
30
|
const packages = new Map();
|
|
31
31
|
const seen = new Set();
|
|
32
32
|
const pins = new Map();
|
|
33
|
+
const savedPins = new Set();
|
|
33
34
|
let at = resolve(from);
|
|
34
35
|
for (;;) {
|
|
35
36
|
const config = join(at, '.volter', 'world.json');
|
|
@@ -37,8 +38,10 @@ export function installedVendorPacks(from) {
|
|
|
37
38
|
const document = JSON.parse(readFileSync(config, 'utf8'));
|
|
38
39
|
for (const service of document.services ?? []) {
|
|
39
40
|
const name = service.source?.package ?? service.package;
|
|
40
|
-
if (name && !pins.has(service.id))
|
|
41
|
+
if (name && !pins.has(service.id)) {
|
|
41
42
|
pins.set(service.id, name);
|
|
43
|
+
savedPins.add(service.id);
|
|
44
|
+
}
|
|
42
45
|
}
|
|
43
46
|
}
|
|
44
47
|
const modules = join(at, 'node_modules');
|
|
@@ -74,16 +77,29 @@ export function installedVendorPacks(from) {
|
|
|
74
77
|
if (pins.has(vendor) && pins.get(vendor) !== name)
|
|
75
78
|
throw new Error(`${vendor}: a World must select one package implementation`);
|
|
76
79
|
pins.set(vendor, name);
|
|
80
|
+
savedPins.add(vendor);
|
|
77
81
|
}
|
|
78
82
|
}
|
|
83
|
+
for (const [vendor, name] of Object.entries(options.sources ?? {})) {
|
|
84
|
+
const candidate = packages.get(name);
|
|
85
|
+
if (!candidate)
|
|
86
|
+
throw new Error(`${vendor}: selected package ${name} is not installed; install its exact release before initializing`);
|
|
87
|
+
if (candidate.vendor !== vendor)
|
|
88
|
+
throw new Error(`${vendor}: selected package ${name} declares vendor ${candidate.vendor}`);
|
|
89
|
+
if (pins.has(vendor) && pins.get(vendor) !== name)
|
|
90
|
+
throw new Error(`${vendor}: saved World selects ${pins.get(vendor)}; trial ${name} in a separate app directory instead of replacing the saved pin`);
|
|
91
|
+
pins.set(vendor, name);
|
|
92
|
+
}
|
|
79
93
|
const result = new Map();
|
|
80
94
|
for (const vendor of new Set([...packages.values()].map((p) => p.vendor))) {
|
|
95
|
+
if (options.vendors && !options.vendors.includes(vendor))
|
|
96
|
+
continue;
|
|
81
97
|
const candidates = [...packages.entries()].filter(([, p]) => p.vendor === vendor);
|
|
82
98
|
const selected = pins.get(vendor) ?? recommendations[vendor];
|
|
83
99
|
const choice = selected ? candidates.find(([name]) => name === selected) : candidates.length === 1 ? candidates[0] : undefined;
|
|
84
100
|
if (!choice)
|
|
85
|
-
throw new Error(`${vendor}: ${selected ? `selected package ${selected} is not installed` : `multiple implementations installed (${candidates.map(([name]) => name).join(', ')})`}; name the chosen source.package in .volter/world.json`);
|
|
86
|
-
if (!
|
|
101
|
+
throw new Error(`${vendor}: ${selected ? `selected package ${selected} is not installed` : `multiple implementations installed (${candidates.map(([name]) => name).join(', ')})`}; initialize with --source ${vendor}=<package>, or name the chosen source.package in .volter/world.json`);
|
|
102
|
+
if (!savedPins.has(vendor)) {
|
|
87
103
|
const version = JSON.parse(readFileSync(join(choice[1].dir, 'package.json'), 'utf8')).version;
|
|
88
104
|
if (revocations.some((r) => r.package === choice[0] && r.version === version))
|
|
89
105
|
throw new Error(`${vendor}: installed ${choice[0]}@${version} is revoked; install an approved release or retain an existing explicit World pin`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/world-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.64",
|
|
4
4
|
"description": "The kernel of Volter World: one log per twin, branches as pointers, checkpoints, the fold that keeps a twin current, the head that performs a write against the vendor, references, and the git plane. A twin package builds on it; the runtime serves it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"twin",
|
package/src/pack-paths.ts
CHANGED
|
@@ -24,10 +24,11 @@ export function packVendor(dir: string): string | undefined {
|
|
|
24
24
|
|
|
25
25
|
/** Nearest installed package wins only over another installation of the SAME package. A World's explicit
|
|
26
26
|
* package choice wins over a catalog recommendation; different publishers' versions never compete. */
|
|
27
|
-
export function installedVendorPacks(from: string): Map<string, string> {
|
|
27
|
+
export function installedVendorPacks(from: string, options: { sources?: Readonly<Record<string, string>>; vendors?: readonly string[] } = {}): Map<string, string> {
|
|
28
28
|
const packages = new Map<string, { dir: string; vendor: string }>();
|
|
29
29
|
const seen = new Set<string>();
|
|
30
30
|
const pins = new Map<string, string>();
|
|
31
|
+
const savedPins = new Set<string>();
|
|
31
32
|
let at = resolve(from);
|
|
32
33
|
for (;;) {
|
|
33
34
|
const config = join(at, '.volter', 'world.json');
|
|
@@ -35,7 +36,7 @@ export function installedVendorPacks(from: string): Map<string, string> {
|
|
|
35
36
|
const document = JSON.parse(readFileSync(config, 'utf8')) as { services?: Array<{ id: string; source?: { package?: string }; package?: string }> };
|
|
36
37
|
for (const service of document.services ?? []) {
|
|
37
38
|
const name = service.source?.package ?? service.package;
|
|
38
|
-
if (name && !pins.has(service.id)) pins.set(service.id, name);
|
|
39
|
+
if (name && !pins.has(service.id)) { pins.set(service.id, name); savedPins.add(service.id); }
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
const modules = join(at, 'node_modules');
|
|
@@ -63,15 +64,24 @@ export function installedVendorPacks(from: string): Map<string, string> {
|
|
|
63
64
|
if (vendor && vendor !== id) {
|
|
64
65
|
if (pins.has(vendor) && pins.get(vendor) !== name) throw new Error(`${vendor}: a World must select one package implementation`);
|
|
65
66
|
pins.set(vendor, name);
|
|
67
|
+
savedPins.add(vendor);
|
|
66
68
|
}
|
|
67
69
|
}
|
|
70
|
+
for (const [vendor, name] of Object.entries(options.sources ?? {})) {
|
|
71
|
+
const candidate = packages.get(name);
|
|
72
|
+
if (!candidate) throw new Error(`${vendor}: selected package ${name} is not installed; install its exact release before initializing`);
|
|
73
|
+
if (candidate.vendor !== vendor) throw new Error(`${vendor}: selected package ${name} declares vendor ${candidate.vendor}`);
|
|
74
|
+
if (pins.has(vendor) && pins.get(vendor) !== name) throw new Error(`${vendor}: saved World selects ${pins.get(vendor)}; trial ${name} in a separate app directory instead of replacing the saved pin`);
|
|
75
|
+
pins.set(vendor, name);
|
|
76
|
+
}
|
|
68
77
|
const result = new Map<string, string>();
|
|
69
78
|
for (const vendor of new Set([...packages.values()].map((p) => p.vendor))) {
|
|
79
|
+
if (options.vendors && !options.vendors.includes(vendor)) continue;
|
|
70
80
|
const candidates = [...packages.entries()].filter(([, p]) => p.vendor === vendor);
|
|
71
81
|
const selected = pins.get(vendor) ?? recommendations[vendor];
|
|
72
82
|
const choice = selected ? candidates.find(([name]) => name === selected) : candidates.length === 1 ? candidates[0] : undefined;
|
|
73
|
-
if (!choice) throw new Error(`${vendor}: ${selected ? `selected package ${selected} is not installed` : `multiple implementations installed (${candidates.map(([name]) => name).join(', ')})`}; name the chosen source.package in .volter/world.json`);
|
|
74
|
-
if (!
|
|
83
|
+
if (!choice) throw new Error(`${vendor}: ${selected ? `selected package ${selected} is not installed` : `multiple implementations installed (${candidates.map(([name]) => name).join(', ')})`}; initialize with --source ${vendor}=<package>, or name the chosen source.package in .volter/world.json`);
|
|
84
|
+
if (!savedPins.has(vendor)) {
|
|
75
85
|
const version = (JSON.parse(readFileSync(join(choice[1].dir, 'package.json'), 'utf8')) as { version?: string }).version;
|
|
76
86
|
if (revocations.some((r) => r.package === choice[0] && r.version === version)) throw new Error(`${vendor}: installed ${choice[0]}@${version} is revoked; install an approved release or retain an existing explicit World pin`);
|
|
77
87
|
}
|