@jini-ai/devops 0.6.17 → 0.6.19
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/CHANGELOG.md +6 -0
- package/dist/local-dev/index.d.ts +3 -0
- package/dist/local-dev/index.js +3 -0
- package/dist/local-dev/node-runtime.d.ts +24 -0
- package/dist/local-dev/node-runtime.js +34 -0
- package/dist/local-dev/server-retirement.d.ts +20 -0
- package/dist/local-dev/server-retirement.js +50 -0
- package/dist/local-dev/source-tree-stamp.d.ts +9 -0
- package/dist/local-dev/source-tree-stamp.js +38 -0
- package/dist/packaging/electron/staged-closure.js +6 -2
- package/dist/packaging/electron/staging.d.ts +4 -2
- package/dist/packaging/electron/staging.js +101 -29
- package/dist/packaging/electron/typescript.js +6 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @jini-ai/devops
|
|
2
2
|
|
|
3
|
+
## 0.6.19
|
|
4
|
+
|
|
5
|
+
- Staged-closure audit: a nameless `package.json` (a dual build's `dist/cjs/package.json` = `{"type":"commonjs"}`) no longer hides the owning package's `jini.optionalPeers` opt-in, so a CommonJS entry's optional peer is classified the same as its ESM twin (`@jini-ai/sandbox/dist/cjs/e2b/provider.js` -> `@e2b/code-interpreter`).
|
|
6
|
+
- Import reader: a local `function require(...)` or `class require` declaration now shadows the module `require` in its scope, like a parameter or variable already did. `@jini-ai/db`'s kernel capability checks (`require("interactiveTransactions")`, `require("backup")`) no longer read as missing packages in the staged-closure audit (desktop release run 41494042238).
|
|
7
|
+
- Electron payload staging (`stageTransitiveDependencies`): a transitive package whose own nested dependency conflicts with the hoisted version now ships that version nested under itself, at npm's position, instead of failing with "Package version conflict while flattening <name>" (desktop release run 41398191741: nested debug 4 beside a top-level debug 2). Conflicts on the caller's own roots still refuse; the error now names the conflicting directory and its dependent.
|
|
8
|
+
|
|
3
9
|
## 0.6.17
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { ProcessRequest, ProcessRunnerPort } from '../checks/ports.js';
|
|
2
|
+
export { selectNodeRuntime } from './node-runtime.js';
|
|
3
|
+
export { sourceTreeStamp } from './source-tree-stamp.js';
|
|
4
|
+
export { createDevServerRetirement } from './server-retirement.js';
|
|
2
5
|
export interface EnvLoaderPort {
|
|
3
6
|
load(args: {
|
|
4
7
|
path: string;
|
package/dist/local-dev/index.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
export { selectNodeRuntime } from './node-runtime.js';
|
|
2
|
+
export { sourceTreeStamp } from './source-tree-stamp.js';
|
|
3
|
+
export { createDevServerRetirement } from './server-retirement.js';
|
|
1
4
|
/** Load the required environment-file path, if present. Loader errors propagate to the caller. */
|
|
2
5
|
export function loadRepoRootEnvFile({ environmentFile, fs, loader }) {
|
|
3
6
|
if (!fs.exists({ path: environmentFile }))
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
interface RuntimeInput {
|
|
2
|
+
searchFrom: readonly string[];
|
|
3
|
+
nodePath: string;
|
|
4
|
+
}
|
|
5
|
+
interface RuntimeOptions {
|
|
6
|
+
resolveBinary?: (input: {
|
|
7
|
+
directory: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
usable?: (input: {
|
|
10
|
+
command: string;
|
|
11
|
+
}) => boolean;
|
|
12
|
+
}
|
|
13
|
+
/** Select an installed desktop Node runtime, falling back without refusing boot.
|
|
14
|
+
* Executables are returned separately from arguments: paths with spaces work on Windows too.
|
|
15
|
+
* @returns Command and the minimal environment override; never mutates the caller's environment.
|
|
16
|
+
* @complexity O(search roots), with one bounded 5s native probe per discovered binary.
|
|
17
|
+
*/
|
|
18
|
+
export declare function selectNodeRuntime({ searchFrom, nodePath }: RuntimeInput, { resolveBinary, usable }?: RuntimeOptions): {
|
|
19
|
+
command: string;
|
|
20
|
+
env: Record<string, string>;
|
|
21
|
+
fallback: boolean;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=node-runtime.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { spawnSync } from 'node:child_process';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
function installedBinary({ directory }) {
|
|
5
|
+
const require = createRequire(path.join(directory, 'package.json'));
|
|
6
|
+
const binary = require('electron');
|
|
7
|
+
if (typeof binary !== 'string')
|
|
8
|
+
throw new Error('Desktop runtime binary missing');
|
|
9
|
+
return binary;
|
|
10
|
+
}
|
|
11
|
+
/** Probe without opening a window; a fused-off or incomplete installation is not usable as Node. */
|
|
12
|
+
function usableBinary({ command }) {
|
|
13
|
+
const result = spawnSync(command, ['-e', 'process.exit(process.versions.node ? 0 : 1)'], {
|
|
14
|
+
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' }, stdio: 'ignore', timeout: 5000, windowsHide: true,
|
|
15
|
+
});
|
|
16
|
+
return result.status === 0;
|
|
17
|
+
}
|
|
18
|
+
/** Select an installed desktop Node runtime, falling back without refusing boot.
|
|
19
|
+
* Executables are returned separately from arguments: paths with spaces work on Windows too.
|
|
20
|
+
* @returns Command and the minimal environment override; never mutates the caller's environment.
|
|
21
|
+
* @complexity O(search roots), with one bounded 5s native probe per discovered binary.
|
|
22
|
+
*/
|
|
23
|
+
export function selectNodeRuntime({ searchFrom, nodePath }, { resolveBinary = installedBinary, usable = usableBinary } = {}) {
|
|
24
|
+
for (const directory of searchFrom) {
|
|
25
|
+
try {
|
|
26
|
+
const command = resolveBinary({ directory });
|
|
27
|
+
if (usable({ command }))
|
|
28
|
+
return { command, env: { ELECTRON_RUN_AS_NODE: '1' }, fallback: false };
|
|
29
|
+
}
|
|
30
|
+
catch { /* An optional installation must never refuse local development. */ }
|
|
31
|
+
}
|
|
32
|
+
return { command: nodePath, env: {}, fallback: true };
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=node-runtime.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Fence local dev-server intake before asking an async activity owner whether eviction is safe.
|
|
2
|
+
* The activity owner reports outstanding work at retirement time. Failed/timed-out
|
|
3
|
+
* probes reopen intake; a successful retirement remains fenced until stop or explicit cancel.
|
|
4
|
+
* @returns Intake accounting and a cancellable retirement decision; releases are idempotent.
|
|
5
|
+
* @throws When begin is called after intake has been fenced.
|
|
6
|
+
* @complexity O(1) state per server and at most one bounded activity probe per retirement.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createDevServerRetirement({ hasWork }: {
|
|
9
|
+
hasWork: () => Promise<boolean>;
|
|
10
|
+
}, { activityTimeoutMs }?: {
|
|
11
|
+
activityTimeoutMs?: number | undefined;
|
|
12
|
+
}): {
|
|
13
|
+
accepting(_required?: {}, _options?: {}): boolean;
|
|
14
|
+
cancel(_required?: {}, _options?: {}): void;
|
|
15
|
+
begin(_required?: {}, _options?: {}): (_required?: {
|
|
16
|
+
background?: boolean;
|
|
17
|
+
}, _options?: {}) => void;
|
|
18
|
+
retire(_required?: {}, _options?: {}): Promise<boolean>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=server-retirement.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Fence local dev-server intake before asking an async activity owner whether eviction is safe.
|
|
2
|
+
* The activity owner reports outstanding work at retirement time. Failed/timed-out
|
|
3
|
+
* probes reopen intake; a successful retirement remains fenced until stop or explicit cancel.
|
|
4
|
+
* @returns Intake accounting and a cancellable retirement decision; releases are idempotent.
|
|
5
|
+
* @throws When begin is called after intake has been fenced.
|
|
6
|
+
* @complexity O(1) state per server and at most one bounded activity probe per retirement.
|
|
7
|
+
*/
|
|
8
|
+
export function createDevServerRetirement({ hasWork }, { activityTimeoutMs = 1000 } = {}) {
|
|
9
|
+
let fenced = false;
|
|
10
|
+
let active = 0;
|
|
11
|
+
let generation = 0;
|
|
12
|
+
return {
|
|
13
|
+
accepting(_required = {}, _options = {}) { return !fenced; },
|
|
14
|
+
cancel(_required = {}, _options = {}) { generation++; fenced = false; },
|
|
15
|
+
begin(_required = {}, _options = {}) {
|
|
16
|
+
if (fenced)
|
|
17
|
+
throw new Error('Dev server intake is fenced');
|
|
18
|
+
active++;
|
|
19
|
+
let released = false;
|
|
20
|
+
// Retain the old response hint as an input compatibility shim. A response's status cannot
|
|
21
|
+
// prove a job still runs: hasWork owns completion, including operations returning 202.
|
|
22
|
+
return (_required = {}, _options = {}) => {
|
|
23
|
+
if (released)
|
|
24
|
+
return;
|
|
25
|
+
released = true;
|
|
26
|
+
active--;
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
async retire(_required = {}, _options = {}) {
|
|
30
|
+
if (fenced || active > 0)
|
|
31
|
+
return false;
|
|
32
|
+
fenced = true;
|
|
33
|
+
const attempt = ++generation;
|
|
34
|
+
let timer;
|
|
35
|
+
const uncertain = new Promise(resolve => { timer = setTimeout(() => resolve(true), activityTimeoutMs); });
|
|
36
|
+
try {
|
|
37
|
+
if (!await Promise.race([hasWork(), uncertain]) && generation === attempt)
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch { /* Uncertainty preserves the server. */ }
|
|
41
|
+
finally {
|
|
42
|
+
clearTimeout(timer);
|
|
43
|
+
}
|
|
44
|
+
if (generation === attempt)
|
|
45
|
+
fenced = false;
|
|
46
|
+
return false;
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=server-retirement.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Hash source files and relative names, including additions/deletions. Does not traverse symlinks.
|
|
2
|
+
* Callers supply source roots; generated/dependency trees are skipped. Missing roots contribute
|
|
3
|
+
* their name so creating one invalidates a previous stamp. Filesystem errors otherwise propagate.
|
|
4
|
+
* @complexity O(source bytes + files log files) time, O(largest file + directory depth) space.
|
|
5
|
+
*/
|
|
6
|
+
export declare function sourceTreeStamp({ roots }: {
|
|
7
|
+
roots: readonly string[];
|
|
8
|
+
}, _options?: {}): Promise<string>;
|
|
9
|
+
//# sourceMappingURL=source-tree-stamp.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstat, readdir, readFile } from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
/** Hash source files and relative names, including additions/deletions. Does not traverse symlinks.
|
|
5
|
+
* Callers supply source roots; generated/dependency trees are skipped. Missing roots contribute
|
|
6
|
+
* their name so creating one invalidates a previous stamp. Filesystem errors otherwise propagate.
|
|
7
|
+
* @complexity O(source bytes + files log files) time, O(largest file + directory depth) space.
|
|
8
|
+
*/
|
|
9
|
+
export async function sourceTreeStamp({ roots }, _options = {}) {
|
|
10
|
+
const hash = createHash('sha256');
|
|
11
|
+
async function visit(file) {
|
|
12
|
+
hash.update(file);
|
|
13
|
+
let info;
|
|
14
|
+
try {
|
|
15
|
+
info = await lstat(file);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
if (error.code === 'ENOENT')
|
|
19
|
+
return;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
if (info.isFile()) {
|
|
23
|
+
hash.update(await readFile(file));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (!info.isDirectory())
|
|
27
|
+
return;
|
|
28
|
+
for (const name of (await readdir(file)).sort()) {
|
|
29
|
+
if (['node_modules', 'dist', '.git'].includes(name))
|
|
30
|
+
continue;
|
|
31
|
+
await visit(path.join(file, name));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
for (const root of roots)
|
|
35
|
+
await visit(root);
|
|
36
|
+
return hash.digest('hex');
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=source-tree-stamp.js.map
|
|
@@ -38,8 +38,12 @@ function manifestOwner(required) {
|
|
|
38
38
|
let directory = path.dirname(file);
|
|
39
39
|
while (inside(root, directory)) {
|
|
40
40
|
const manifest = path.join(directory, 'package.json');
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// A nameless manifest (dual builds' dist/cjs/package.json = {"type":"commonjs"}) only scopes the module type;
|
|
42
|
+
// the named manifest above it owns the optional-peer contract.
|
|
43
|
+
const parsed = fs.exists({ path: manifest })
|
|
44
|
+
? JSON.parse(Buffer.from(fs.read({ path: manifest })).toString('utf8')) : undefined;
|
|
45
|
+
if (parsed?.name)
|
|
46
|
+
return parsed;
|
|
43
47
|
if (directory === root)
|
|
44
48
|
break;
|
|
45
49
|
directory = path.dirname(directory);
|
|
@@ -22,9 +22,11 @@ interface DependencyOptions {
|
|
|
22
22
|
fs: PackagingFilesystemPort;
|
|
23
23
|
}) => readonly string[];
|
|
24
24
|
}
|
|
25
|
-
/** Plan selected runtime edges before copying; unresolved/
|
|
25
|
+
/** Plan selected runtime edges before copying; unresolved/irreconcilable versions throw atomically.
|
|
26
26
|
* Supplied roots are already owned by the caller and are never copied through a back edge.
|
|
27
|
-
*
|
|
27
|
+
* A version that conflicts with the hoisted copy is staged nested under its dependent, so every
|
|
28
|
+
* staged package still resolves its declared dependencies from where it sits.
|
|
29
|
+
* @complexity O(packages × nesting depth + edges × ancestor depth) filesystem reads, O(packages + edges × ancestor depth) plan memory.
|
|
28
30
|
* @example stageTransitiveDependencies({ roots, outDir, excluded, fs, resolver });
|
|
29
31
|
*/
|
|
30
32
|
export declare function stageTransitiveDependencies(required: {
|
|
@@ -26,56 +26,128 @@ function resolveDependency(required) {
|
|
|
26
26
|
throw new Error(`Unresolved production dependency: ${from} -> ${name}`);
|
|
27
27
|
return fs.realpath({ path: resolved });
|
|
28
28
|
}
|
|
29
|
+
/** Staged package directories from `destination` up to (excluding) the modules root, nearest first. */
|
|
30
|
+
function stagedAncestors(required) {
|
|
31
|
+
const { outDir, destination } = required;
|
|
32
|
+
const modulesDir = path.join(outDir, 'node_modules'), ancestors = [];
|
|
33
|
+
for (let current = destination ?? modulesDir; current.startsWith(modulesDir + path.sep); current = path.dirname(current)) {
|
|
34
|
+
if (path.basename(current) !== 'node_modules')
|
|
35
|
+
ancestors.push(current);
|
|
36
|
+
}
|
|
37
|
+
return ancestors;
|
|
38
|
+
}
|
|
39
|
+
/** Where Node looks for `name` from a package staged at `destination`, nearest first, ending at the top level. */
|
|
40
|
+
function resolutionPath(required) {
|
|
41
|
+
const { outDir, name, destination } = required;
|
|
42
|
+
return [...stagedAncestors({ outDir, destination }).map(directory => path.join(directory, 'node_modules', name)), stagedPath(outDir, name)];
|
|
43
|
+
}
|
|
44
|
+
/** A planned copy, or a destination already on disk (which carries no source directory). */
|
|
45
|
+
function occupantAt(plan, required) {
|
|
46
|
+
const { destination } = required;
|
|
47
|
+
const planned = plan.staged.get(destination);
|
|
48
|
+
if (planned || !plan.fs.exists({ path: destination }))
|
|
49
|
+
return planned;
|
|
50
|
+
return { directory: destination, version: plan.fs.exists({ path: path.join(destination, PACKAGE_JSON) }) ? manifest(destination, plan.fs).version : undefined };
|
|
51
|
+
}
|
|
29
52
|
/**
|
|
30
53
|
* Flattening `name` from `directory` conflicts with an already planned copy from another directory
|
|
31
54
|
* unless both carry the same known version, and with an already staged destination unless that
|
|
32
55
|
* destination carries the same known version. Unversioned packages never count as the same.
|
|
33
56
|
*/
|
|
34
|
-
function
|
|
35
|
-
const {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
57
|
+
function compatible(required) {
|
|
58
|
+
const { occupant, planned } = required;
|
|
59
|
+
return occupant.directory === planned.directory || (planned.version !== undefined && occupant.version === planned.version);
|
|
60
|
+
}
|
|
61
|
+
/** npm's own position for `directory`: inside the source tree of a package staged on the dependent's path. */
|
|
62
|
+
function sourceLayoutPosition(plan, required) {
|
|
63
|
+
for (const ancestor of stagedAncestors({ outDir: plan.outDir, destination: required.from.destination })) {
|
|
64
|
+
const source = plan.staged.get(ancestor)?.directory;
|
|
65
|
+
if (source && required.directory.startsWith(path.join(source, 'node_modules') + path.sep))
|
|
66
|
+
return ancestor + required.directory.slice(source.length);
|
|
67
|
+
}
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
function conflictError(required) {
|
|
71
|
+
const { name, planned, from } = required;
|
|
72
|
+
return new Error(`Package version conflict while flattening ${name}: ${planned.directory} (${planned.version ?? 'unversioned'}) needed by ${from.directory}`);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Choose where `planned` ships so Node resolves it from the dependent, or nothing when an existing
|
|
76
|
+
* copy already serves it. A version that conflicts with the hoisted copy stays nested under its
|
|
77
|
+
* dependent, preferring npm's own position, instead of failing or silently picking first-wins.
|
|
78
|
+
* Supplied roots have no known position, so a conflict on their edges still throws.
|
|
79
|
+
*/
|
|
80
|
+
function placeDependency(plan, required) {
|
|
81
|
+
const { from, name, planned } = required;
|
|
82
|
+
const candidates = resolutionPath({ outDir: plan.outDir, name, destination: from.destination });
|
|
83
|
+
const index = candidates.findIndex(candidate => occupantAt(plan, { destination: candidate }));
|
|
84
|
+
const occupant = index < 0 ? undefined : occupantAt(plan, { destination: candidates[index] });
|
|
85
|
+
if (occupant && compatible({ occupant, planned })) {
|
|
86
|
+
bindResolution(plan, { candidates, destination: candidates[index], planned });
|
|
87
|
+
return plan.staged.has(candidates[index]) ? undefined : candidates[index];
|
|
88
|
+
}
|
|
89
|
+
// Only positions nearer than the occupant are seen by Node; with no occupant, hoist like npm does.
|
|
90
|
+
const open = (index < 0 ? candidates : candidates.slice(0, index)).filter(candidate => {
|
|
91
|
+
const binding = plan.bindings.get(candidate);
|
|
92
|
+
return !binding || compatible({ occupant: binding, planned });
|
|
93
|
+
});
|
|
94
|
+
const position = openPosition({ open, layout: sourceLayoutPosition(plan, { from, directory: planned.directory }), hoist: index < 0 });
|
|
95
|
+
// A source already staged above the chosen spot means conflicting versions alternate down a cycle.
|
|
96
|
+
if (!position || stagedAncestors({ outDir: plan.outDir, destination: path.dirname(position) }).some(ancestor => plan.staged.get(ancestor)?.directory === planned.directory))
|
|
97
|
+
throw conflictError({ name, planned, from });
|
|
98
|
+
bindResolution(plan, { candidates, destination: position, planned });
|
|
99
|
+
return position;
|
|
100
|
+
}
|
|
101
|
+
/** Record the resolved edge before later siblings can fill an empty ancestor and shadow it. */
|
|
102
|
+
function bindResolution(plan, required) {
|
|
103
|
+
for (const candidate of required.candidates) {
|
|
104
|
+
plan.bindings.set(candidate, required.planned);
|
|
105
|
+
if (candidate === required.destination)
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/** npm's position when Node can see it from the dependent; otherwise the top level (`hoist`) or the dependent's own node_modules. */
|
|
110
|
+
function openPosition(required) {
|
|
111
|
+
const { open, layout, hoist } = required;
|
|
112
|
+
if (layout && open.includes(layout))
|
|
113
|
+
return layout;
|
|
114
|
+
return hoist ? open.at(-1) : open[0];
|
|
115
|
+
}
|
|
116
|
+
/** Add one declared dependency of `from` to the plan (validated, resolved, placed) and queue each new destination once. */
|
|
43
117
|
function planDependency(plan, required) {
|
|
44
|
-
const { outDir, excluded, fs, resolver, staged, visited, queue } = plan;
|
|
45
118
|
const { from, name } = required;
|
|
46
119
|
safePackageName(name);
|
|
47
|
-
if (isExcluded({ name, excluded }))
|
|
120
|
+
if (isExcluded({ name, excluded: plan.excluded }))
|
|
48
121
|
return;
|
|
49
|
-
const directory = resolveDependency({ from, name, fs, resolver });
|
|
122
|
+
const directory = resolveDependency({ from: from.directory, name, fs: plan.fs, resolver: plan.resolver });
|
|
50
123
|
if (plan.roots.has(directory))
|
|
51
124
|
return;
|
|
52
|
-
const planned = { directory, version: manifest(directory, fs).version };
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
visited.add(directory);
|
|
59
|
-
queue.push(directory);
|
|
60
|
-
}
|
|
125
|
+
const planned = { directory, version: manifest(directory, plan.fs).version };
|
|
126
|
+
const destination = placeDependency(plan, { from, name, planned });
|
|
127
|
+
if (!destination)
|
|
128
|
+
return;
|
|
129
|
+
plan.staged.set(destination, planned);
|
|
130
|
+
plan.queue.push({ directory, destination });
|
|
61
131
|
}
|
|
62
|
-
/** Plan selected runtime edges before copying; unresolved/
|
|
132
|
+
/** Plan selected runtime edges before copying; unresolved/irreconcilable versions throw atomically.
|
|
63
133
|
* Supplied roots are already owned by the caller and are never copied through a back edge.
|
|
64
|
-
*
|
|
134
|
+
* A version that conflicts with the hoisted copy is staged nested under its dependent, so every
|
|
135
|
+
* staged package still resolves its declared dependencies from where it sits.
|
|
136
|
+
* @complexity O(packages × nesting depth + edges × ancestor depth) filesystem reads, O(packages + edges × ancestor depth) plan memory.
|
|
65
137
|
* @example stageTransitiveDependencies({ roots, outDir, excluded, fs, resolver });
|
|
66
138
|
*/
|
|
67
139
|
export function stageTransitiveDependencies(required, optional = {}) {
|
|
68
|
-
const { roots,
|
|
69
|
-
const
|
|
70
|
-
const plan = { ...required, staged: new Map(),
|
|
140
|
+
const { roots, fs } = required;
|
|
141
|
+
const rootDirectories = new Set(roots.map(root => fs.realpath({ path: root })));
|
|
142
|
+
const plan = { ...required, staged: new Map(), bindings: new Map(), roots: rootDirectories, queue: [...rootDirectories].map(directory => ({ directory })) };
|
|
71
143
|
for (let index = 0; index < plan.queue.length; index++) {
|
|
72
144
|
const from = plan.queue[index];
|
|
73
|
-
for (const name of (optional.dependencies ?? declaredDependencies)({ packageDir: from, fs }))
|
|
145
|
+
for (const name of (optional.dependencies ?? declaredDependencies)({ packageDir: from.directory, fs }))
|
|
74
146
|
planDependency(plan, { from, name });
|
|
75
147
|
}
|
|
76
148
|
let count = 0;
|
|
77
|
-
|
|
78
|
-
|
|
149
|
+
// Insertion order puts every dependent before the packages nested under it.
|
|
150
|
+
for (const [destination, entry] of plan.staged) {
|
|
79
151
|
if (fs.exists({ path: destination }))
|
|
80
152
|
continue;
|
|
81
153
|
stageDir({ source: entry.directory, destination, fs }, { dropNestedModules: true });
|
|
@@ -39,12 +39,18 @@ export function runtimeImportReferences({ compiler: c, file, source }, _options
|
|
|
39
39
|
const value = init && c.isCallExpression(init) && isCreator(init.expression) ? 'require' : 'other';
|
|
40
40
|
bind(node, node.name.text, value);
|
|
41
41
|
}
|
|
42
|
+
/** A declared function or class (e.g. a factory-local `function require(capability)`) shadows the module require in its scope. */
|
|
43
|
+
function declarationBinding(node) {
|
|
44
|
+
if ((c.isFunctionDeclaration(node) || c.isClassDeclaration(node)) && node.name)
|
|
45
|
+
bind(node, node.name.text, 'other');
|
|
46
|
+
}
|
|
42
47
|
function bindings(node) {
|
|
43
48
|
if (c.isImportSpecifier(node) && (node.propertyName ?? node.name).text === 'createRequire')
|
|
44
49
|
bind(node, node.name.text, 'creator');
|
|
45
50
|
if (c.isParameter(node) && c.isIdentifier(node.name))
|
|
46
51
|
bind(node, node.name.text, 'other');
|
|
47
52
|
variableBinding(node);
|
|
53
|
+
declarationBinding(node);
|
|
48
54
|
c.forEachChild(node, bindings);
|
|
49
55
|
}
|
|
50
56
|
bindings(tree);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jini-ai/devops",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.19",
|
|
4
4
|
"description": "DevOps capabilities for deployment, source control, and CI/CD, exposed through independent subpaths.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -154,12 +154,12 @@
|
|
|
154
154
|
"@vitest/coverage-v8": "^2.1.9",
|
|
155
155
|
"undici": "^7.25.0",
|
|
156
156
|
"parse5": "7.3.0",
|
|
157
|
-
"@jini-ai/
|
|
158
|
-
"@jini-ai/platform": "^0.6.
|
|
159
|
-
"@jini-ai/
|
|
157
|
+
"@jini-ai/daemon": "0.6.19",
|
|
158
|
+
"@jini-ai/platform": "^0.6.19",
|
|
159
|
+
"@jini-ai/core": "^0.6.19"
|
|
160
160
|
},
|
|
161
161
|
"dependencies": {
|
|
162
|
-
"@jini-ai/core": "^0.6.
|
|
162
|
+
"@jini-ai/core": "^0.6.19"
|
|
163
163
|
},
|
|
164
164
|
"peerDependencies": {
|
|
165
165
|
"typescript": "^5.6.0",
|