@volter/world-core 3.0.165 → 3.0.166
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/attach.cjs +7 -3
- package/dist/attach.cjs +7 -3
- package/dist/src/checkout.d.ts +4 -0
- package/dist/src/checkout.js +13 -0
- package/package.json +5 -1
- package/src/checkout.ts +12 -0
package/attach.cjs
CHANGED
|
@@ -63,12 +63,16 @@ if (ref) {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
// what this attach sets from the manifest: a stream's transport templates replace these below (a pack's declared
|
|
67
|
+
// transport templates win over its primary-name HTTP URL, on every path that installs a twin's environment), and
|
|
68
|
+
// never a value the caller set itself
|
|
69
|
+
const fromManifest = new Set();
|
|
66
70
|
for (const [vendor, origin] of Object.entries(manifest.vendors ?? {})) {
|
|
67
71
|
const key = `${vendor.toUpperCase()}_TWIN_URL`;
|
|
68
|
-
if (process.env[key] === undefined) process.env[key] = origin;
|
|
72
|
+
if (process.env[key] === undefined) { process.env[key] = origin; fromManifest.add(key); }
|
|
69
73
|
}
|
|
70
74
|
for (const [key, value] of Object.entries(manifest.env ?? {})) {
|
|
71
|
-
if (process.env[key] === undefined) process.env[key] = value;
|
|
75
|
+
if (process.env[key] === undefined) { process.env[key] = value; fromManifest.add(key); }
|
|
72
76
|
}
|
|
73
77
|
// a World's byte-stream doors (a hosted World's smtp, planetscale's mysql): loopback listeners in
|
|
74
78
|
// this process, bridged over WebSocket (./stream-bridge.cjs). The env names the listener now, so the
|
|
@@ -87,7 +91,7 @@ if (ref) {
|
|
|
87
91
|
const streamToken = manifest.env?.VOLTER_TWINS_KEY ?? token ?? '';
|
|
88
92
|
streams.forEach((stream, i) => {
|
|
89
93
|
for (const [key, value] of Object.entries(streamEnv(stream.env, ports[i]))) {
|
|
90
|
-
if (process.env[key] === undefined) process.env[key] = value;
|
|
94
|
+
if (process.env[key] === undefined || fromManifest.has(key)) process.env[key] = value;
|
|
91
95
|
}
|
|
92
96
|
bridgeStream(stream.url, streamToken, ports[i]).then((server) => server.unref(), (error) => {
|
|
93
97
|
process.stderr.write(`[twin-attach] ${stream.url}: could not listen on 127.0.0.1:${ports[i]}: ${error.message}\n`);
|
package/dist/attach.cjs
CHANGED
|
@@ -63,12 +63,16 @@ if (ref) {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
|
+
// what this attach sets from the manifest: a stream's transport templates replace these below (a pack's declared
|
|
67
|
+
// transport templates win over its primary-name HTTP URL, on every path that installs a twin's environment), and
|
|
68
|
+
// never a value the caller set itself
|
|
69
|
+
const fromManifest = new Set();
|
|
66
70
|
for (const [vendor, origin] of Object.entries(manifest.vendors ?? {})) {
|
|
67
71
|
const key = `${vendor.toUpperCase()}_TWIN_URL`;
|
|
68
|
-
if (process.env[key] === undefined) process.env[key] = origin;
|
|
72
|
+
if (process.env[key] === undefined) { process.env[key] = origin; fromManifest.add(key); }
|
|
69
73
|
}
|
|
70
74
|
for (const [key, value] of Object.entries(manifest.env ?? {})) {
|
|
71
|
-
if (process.env[key] === undefined) process.env[key] = value;
|
|
75
|
+
if (process.env[key] === undefined) { process.env[key] = value; fromManifest.add(key); }
|
|
72
76
|
}
|
|
73
77
|
// a World's byte-stream doors (a hosted World's smtp, planetscale's mysql): loopback listeners in
|
|
74
78
|
// this process, bridged over WebSocket (./stream-bridge.cjs). The env names the listener now, so the
|
|
@@ -87,7 +91,7 @@ if (ref) {
|
|
|
87
91
|
const streamToken = manifest.env?.VOLTER_TWINS_KEY ?? token ?? '';
|
|
88
92
|
streams.forEach((stream, i) => {
|
|
89
93
|
for (const [key, value] of Object.entries(streamEnv(stream.env, ports[i]))) {
|
|
90
|
-
if (process.env[key] === undefined) process.env[key] = value;
|
|
94
|
+
if (process.env[key] === undefined || fromManifest.has(key)) process.env[key] = value;
|
|
91
95
|
}
|
|
92
96
|
bridgeStream(stream.url, streamToken, ports[i]).then((server) => server.unref(), (error) => {
|
|
93
97
|
process.stderr.write(`[twin-attach] ${stream.url}: could not listen on 127.0.0.1:${ports[i]}: ${error.message}\n`);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The checkout a directory is in: the nearest ancestor of the path as given that holds `.git` (a directory, or a
|
|
2
|
+
* worktree's file), or undefined outside every checkout. It walks the spelling it is handed; a caller whose base may
|
|
3
|
+
* be a symlink passes its physical path. What a checkout tracks, and what a failed Git query means, is each caller's. */
|
|
4
|
+
export declare function checkoutOf(dir: string): string | undefined;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
/** The checkout a directory is in: the nearest ancestor of the path as given that holds `.git` (a directory, or a
|
|
4
|
+
* worktree's file), or undefined outside every checkout. It walks the spelling it is handed; a caller whose base may
|
|
5
|
+
* be a symlink passes its physical path. What a checkout tracks, and what a failed Git query means, is each caller's. */
|
|
6
|
+
export function checkoutOf(dir) {
|
|
7
|
+
for (let d = resolve(dir);; d = dirname(d)) {
|
|
8
|
+
if (existsSync(join(d, '.git')))
|
|
9
|
+
return d;
|
|
10
|
+
if (dirname(d) === d)
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volter/world-core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.166",
|
|
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",
|
|
@@ -88,6 +88,10 @@
|
|
|
88
88
|
"types": "./dist/src/exact-json.d.ts",
|
|
89
89
|
"default": "./dist/src/exact-json.js"
|
|
90
90
|
},
|
|
91
|
+
"./checkout": {
|
|
92
|
+
"types": "./dist/src/checkout.d.ts",
|
|
93
|
+
"default": "./dist/src/checkout.js"
|
|
94
|
+
},
|
|
91
95
|
"./inject": "./inject.cjs",
|
|
92
96
|
"./attach": "./attach.cjs",
|
|
93
97
|
"./stream-bridge": "./stream-bridge.cjs",
|
package/src/checkout.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, resolve } from 'node:path';
|
|
3
|
+
|
|
4
|
+
/** The checkout a directory is in: the nearest ancestor of the path as given that holds `.git` (a directory, or a
|
|
5
|
+
* worktree's file), or undefined outside every checkout. It walks the spelling it is handed; a caller whose base may
|
|
6
|
+
* be a symlink passes its physical path. What a checkout tracks, and what a failed Git query means, is each caller's. */
|
|
7
|
+
export function checkoutOf(dir: string): string | undefined {
|
|
8
|
+
for (let d = resolve(dir); ; d = dirname(d)) {
|
|
9
|
+
if (existsSync(join(d, '.git'))) return d;
|
|
10
|
+
if (dirname(d) === d) return undefined;
|
|
11
|
+
}
|
|
12
|
+
}
|