@jini-ai/devops 0.4.0 → 0.5.0
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 +120 -0
- package/README.md +62 -2
- package/dist/agent-jobs/entry.d.ts +4 -0
- package/dist/agent-jobs/entry.js +4 -0
- package/dist/agent-jobs/jobs.d.ts +25 -0
- package/dist/agent-jobs/jobs.js +115 -0
- package/dist/agent-jobs/node.d.ts +12 -0
- package/dist/agent-jobs/node.js +53 -0
- package/dist/agent-jobs/ports.d.ts +69 -0
- package/dist/agent-jobs/ports.js +2 -0
- package/dist/checks/coverage/diff.d.ts +57 -0
- package/dist/checks/coverage/diff.js +48 -0
- package/dist/checks/coverage/disk.d.ts +65 -0
- package/dist/checks/coverage/disk.js +136 -0
- package/dist/checks/coverage/floors.d.ts +31 -0
- package/dist/checks/coverage/floors.js +24 -0
- package/dist/checks/coverage/index.d.ts +7 -0
- package/dist/checks/coverage/index.js +6 -0
- package/dist/checks/coverage/integrity.d.ts +79 -0
- package/dist/checks/coverage/integrity.js +140 -0
- package/dist/checks/coverage/lcov.d.ts +65 -0
- package/dist/checks/coverage/lcov.js +64 -0
- package/dist/checks/node.d.ts +19 -0
- package/dist/checks/node.js +40 -0
- package/dist/checks/ports.d.ts +67 -0
- package/dist/checks/ports.js +2 -0
- package/dist/checks/published-types/index.d.ts +77 -0
- package/dist/checks/published-types/index.js +186 -0
- package/dist/deploy/host-kit.d.ts +27 -10
- package/dist/deploy/naming.d.ts +8 -4
- package/dist/deploy/naming.js +4 -5
- package/dist/deploy/node.d.ts +18 -0
- package/dist/deploy/node.js +57 -0
- package/dist/deploy/reachability.d.ts +42 -12
- package/dist/deploy/reachability.js +75 -69
- package/dist/deploy/redirect-guard.d.ts +7 -2
- package/dist/deploy/redirect-guard.js +3 -3
- package/dist/deploy/tokens.d.ts +14 -11
- package/dist/deploy/tokens.js +13 -13
- package/dist/deploy/tool.d.ts +9 -5
- package/dist/deploy/tool.js +5 -6
- package/dist/deploy/types.d.ts +22 -10
- package/dist/deploy/types.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/local-dev/index.d.ts +34 -0
- package/dist/local-dev/index.js +37 -0
- package/dist/packaging/electron/archive.d.ts +41 -0
- package/dist/packaging/electron/archive.js +77 -0
- package/dist/packaging/electron/asar-adapter.d.ts +13 -0
- package/dist/packaging/electron/asar-adapter.js +5 -0
- package/dist/packaging/electron/entry.d.ts +9 -0
- package/dist/packaging/electron/entry.js +9 -0
- package/dist/packaging/electron/imports.d.ts +13 -0
- package/dist/packaging/electron/imports.js +44 -0
- package/dist/packaging/electron/node.d.ts +8 -0
- package/dist/packaging/electron/node.js +51 -0
- package/dist/packaging/electron/policies.d.ts +64 -0
- package/dist/packaging/electron/policies.js +63 -0
- package/dist/packaging/electron/ports.d.ts +113 -0
- package/dist/packaging/electron/ports.js +2 -0
- package/dist/packaging/electron/stability.d.ts +9 -0
- package/dist/packaging/electron/stability.js +12 -0
- package/dist/packaging/electron/staging.d.ts +108 -0
- package/dist/packaging/electron/staging.js +249 -0
- package/dist/packaging/electron/typescript.d.ts +7 -0
- package/dist/packaging/electron/typescript.js +18 -0
- package/dist/source-control/commit.d.ts +11 -0
- package/dist/source-control/commit.js +71 -0
- package/dist/source-control/contracts.d.ts +327 -0
- package/dist/source-control/contracts.js +2 -0
- package/dist/source-control/entry.d.ts +6 -0
- package/dist/source-control/entry.js +6 -0
- package/dist/source-control/kit.d.ts +15 -0
- package/dist/source-control/kit.js +17 -0
- package/dist/source-control/registry.d.ts +100 -0
- package/dist/source-control/registry.js +174 -0
- package/dist/source-control/repository-target.d.ts +13 -0
- package/dist/source-control/repository-target.js +28 -0
- package/dist/static-export/contracts.d.ts +138 -0
- package/dist/static-export/contracts.js +5 -0
- package/dist/static-export/entry.d.ts +6 -0
- package/dist/static-export/entry.js +6 -0
- package/dist/static-export/failure-summary.d.ts +12 -0
- package/dist/static-export/failure-summary.js +12 -0
- package/dist/static-export/fetch-adapter.d.ts +6 -0
- package/dist/static-export/fetch-adapter.js +5 -0
- package/dist/static-export/node-adapters.d.ts +11 -0
- package/dist/static-export/node-adapters.js +111 -0
- package/dist/static-export/runner.d.ts +6 -0
- package/dist/static-export/runner.js +135 -0
- package/dist/static-export/transforms.d.ts +53 -0
- package/dist/static-export/transforms.js +154 -0
- package/package.json +82 -5
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ProcessRequest, ProcessRunnerPort } from '../checks/ports.js';
|
|
2
|
+
export interface EnvLoaderPort {
|
|
3
|
+
load(args: {
|
|
4
|
+
path: string;
|
|
5
|
+
}): void;
|
|
6
|
+
}
|
|
7
|
+
export interface EnvironmentFilesystemPort {
|
|
8
|
+
exists(args: {
|
|
9
|
+
path: string;
|
|
10
|
+
}): boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface PortListener {
|
|
13
|
+
pid: string;
|
|
14
|
+
command: string;
|
|
15
|
+
}
|
|
16
|
+
/** Load the required environment-file path, if present. Loader errors propagate to the caller. */
|
|
17
|
+
export declare function loadRepoRootEnvFile({ environmentFile, fs, loader }: {
|
|
18
|
+
environmentFile: string;
|
|
19
|
+
fs: EnvironmentFilesystemPort;
|
|
20
|
+
loader: EnvLoaderPort;
|
|
21
|
+
}): boolean;
|
|
22
|
+
/** Parse lsof's field format, dropping incomplete records. Does not spawn a process. */
|
|
23
|
+
export declare function parseLsofListeners({ stdout }: {
|
|
24
|
+
stdout: string;
|
|
25
|
+
}): PortListener[];
|
|
26
|
+
/** Best-effort TCP-listener lookup. The host supplies the platform's listener executable/args. */
|
|
27
|
+
export declare function listenersOn({ port, runner, listenerCommand }: {
|
|
28
|
+
port: number;
|
|
29
|
+
runner: ProcessRunnerPort;
|
|
30
|
+
listenerCommand: (args: {
|
|
31
|
+
port: number;
|
|
32
|
+
}) => ProcessRequest;
|
|
33
|
+
}): Promise<PortListener[]>;
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** Load the required environment-file path, if present. Loader errors propagate to the caller. */
|
|
2
|
+
export function loadRepoRootEnvFile({ environmentFile, fs, loader }) {
|
|
3
|
+
if (!fs.exists({ path: environmentFile }))
|
|
4
|
+
return false;
|
|
5
|
+
loader.load({ path: environmentFile });
|
|
6
|
+
return true;
|
|
7
|
+
}
|
|
8
|
+
/** Parse lsof's field format, dropping incomplete records. Does not spawn a process. */
|
|
9
|
+
export function parseLsofListeners({ stdout }) {
|
|
10
|
+
const found = [];
|
|
11
|
+
let pid;
|
|
12
|
+
for (const line of stdout.replace(/\r\n/g, '\n').split('\n')) {
|
|
13
|
+
if (line.startsWith('p'))
|
|
14
|
+
pid = line.slice(1);
|
|
15
|
+
else if (line.startsWith('c') && pid) {
|
|
16
|
+
found.push({ pid, command: line.slice(1) });
|
|
17
|
+
pid = undefined;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return found;
|
|
21
|
+
}
|
|
22
|
+
/** Best-effort TCP-listener lookup. The host supplies the platform's listener executable/args. */
|
|
23
|
+
export async function listenersOn({ port, runner, listenerCommand }) {
|
|
24
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
25
|
+
throw new RangeError('port must be an integer from 1 to 65535');
|
|
26
|
+
const request = listenerCommand({ port });
|
|
27
|
+
try {
|
|
28
|
+
const output = await runner.run(request);
|
|
29
|
+
if (output.exitCode !== 0 || !output.stdout)
|
|
30
|
+
return [];
|
|
31
|
+
return parseLsofListeners({ stdout: output.stdout });
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { AsarHeaderNode, ArchiveReaderPort, PackagingFilesystemPort } from './ports.js';
|
|
2
|
+
export interface AsarMismatch {
|
|
3
|
+
relPath: string;
|
|
4
|
+
reason: string;
|
|
5
|
+
}
|
|
6
|
+
export interface AsarVerification {
|
|
7
|
+
checkedCount: number;
|
|
8
|
+
mismatches: AsarMismatch[];
|
|
9
|
+
}
|
|
10
|
+
/** Enumerate files only; symlinks carry no content. Missing prefixes are checked by verification. */
|
|
11
|
+
export declare function filesUnderPrefixes({ headerFiles, prefixes }: {
|
|
12
|
+
headerFiles: Record<string, AsarHeaderNode> | undefined;
|
|
13
|
+
prefixes: readonly string[];
|
|
14
|
+
}): string[];
|
|
15
|
+
/** The reader's separator is host supplied, keeping archive enumeration in POSIX form. */
|
|
16
|
+
export declare function toArchiveEntryPath({ relPath, separator }: {
|
|
17
|
+
relPath: string;
|
|
18
|
+
separator: string;
|
|
19
|
+
}): string;
|
|
20
|
+
/** Compare actual content: equal sizes and an archive's own hash cannot detect shifted offsets. */
|
|
21
|
+
export declare function verifyAsarAgainstSource(required: {
|
|
22
|
+
archivePath: string;
|
|
23
|
+
sourceRoot: string;
|
|
24
|
+
prefixes: readonly string[];
|
|
25
|
+
separator: string;
|
|
26
|
+
fs: PackagingFilesystemPort;
|
|
27
|
+
archive: ArchiveReaderPort;
|
|
28
|
+
}): AsarVerification;
|
|
29
|
+
export declare function isEmptyVerification({ checkedCount }: {
|
|
30
|
+
checkedCount: number;
|
|
31
|
+
}): boolean;
|
|
32
|
+
export declare function formatMismatchReport({ mismatches }: {
|
|
33
|
+
mismatches: readonly AsarMismatch[];
|
|
34
|
+
}): string;
|
|
35
|
+
/** Resources inventory is caller supplied; an empty inventory is a failure. */
|
|
36
|
+
export declare function bundledNpmFailures(required: {
|
|
37
|
+
resourcesDirs: readonly string[];
|
|
38
|
+
requiredFiles: readonly string[];
|
|
39
|
+
fs: PackagingFilesystemPort;
|
|
40
|
+
}): string[];
|
|
41
|
+
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
function safeEntry(value) {
|
|
3
|
+
if (!value || value.includes('\\') || value.includes('\0') || value.split('/').some(segment => !segment || segment === '.' || segment === '..'))
|
|
4
|
+
throw new Error(`Unsafe archive entry: ${value}`);
|
|
5
|
+
}
|
|
6
|
+
/** Enumerate files only; symlinks carry no content. Missing prefixes are checked by verification. */
|
|
7
|
+
export function filesUnderPrefixes({ headerFiles, prefixes }) {
|
|
8
|
+
const paths = new Set();
|
|
9
|
+
function walk(node, current) {
|
|
10
|
+
safeEntry(current);
|
|
11
|
+
if ('link' in node)
|
|
12
|
+
return;
|
|
13
|
+
if (node.files)
|
|
14
|
+
for (const [name, child] of Object.entries(node.files))
|
|
15
|
+
walk(child, current + '/' + name);
|
|
16
|
+
else
|
|
17
|
+
paths.add(current);
|
|
18
|
+
}
|
|
19
|
+
for (const prefix of prefixes) {
|
|
20
|
+
safeEntry(prefix);
|
|
21
|
+
let node = { files: headerFiles ?? {} };
|
|
22
|
+
for (const segment of prefix.split('/'))
|
|
23
|
+
node = node?.files?.[segment];
|
|
24
|
+
if (node)
|
|
25
|
+
walk(node, prefix);
|
|
26
|
+
}
|
|
27
|
+
return [...paths];
|
|
28
|
+
}
|
|
29
|
+
/** The reader's separator is host supplied, keeping archive enumeration in POSIX form. */
|
|
30
|
+
export function toArchiveEntryPath({ relPath, separator }) {
|
|
31
|
+
safeEntry(relPath);
|
|
32
|
+
return relPath.split('/').join(separator);
|
|
33
|
+
}
|
|
34
|
+
/** Compare actual content: equal sizes and an archive's own hash cannot detect shifted offsets. */
|
|
35
|
+
export function verifyAsarAgainstSource(required) {
|
|
36
|
+
const { archivePath, sourceRoot, prefixes, separator, fs, archive } = required;
|
|
37
|
+
if (!prefixes.length)
|
|
38
|
+
return { checkedCount: 0, mismatches: [{ relPath: '', reason: 'no checked archive prefixes supplied' }] };
|
|
39
|
+
const { files: headerFiles } = archive.header({ archivePath });
|
|
40
|
+
const relPaths = filesUnderPrefixes({ headerFiles, prefixes });
|
|
41
|
+
const mismatches = prefixes.filter(prefix => !filesUnderPrefixes({ headerFiles, prefixes: [prefix] }).length)
|
|
42
|
+
.map(relPath => ({ relPath, reason: 'nothing under this checked prefix is in app.asar' }));
|
|
43
|
+
for (const relPath of relPaths) {
|
|
44
|
+
let source;
|
|
45
|
+
try {
|
|
46
|
+
source = fs.read({ path: path.join(sourceRoot, relPath) });
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
mismatches.push({ relPath, reason: 'shipped in app.asar but missing from the source tree' });
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
let shipped;
|
|
53
|
+
try {
|
|
54
|
+
shipped = archive.read({ archivePath, entryPath: toArchiveEntryPath({ relPath, separator }) });
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
mismatches.push({ relPath, reason: `present in the asar header but could not read it (${String(error)})` });
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (source.length !== shipped.length || !source.every((byte, index) => byte === shipped[index]))
|
|
61
|
+
mismatches.push({ relPath, reason: 'content differs from source (compared byte-for-byte, never by length alone)' });
|
|
62
|
+
}
|
|
63
|
+
return { checkedCount: relPaths.length, mismatches };
|
|
64
|
+
}
|
|
65
|
+
export function isEmptyVerification({ checkedCount }) { return checkedCount === 0; }
|
|
66
|
+
export function formatMismatchReport({ mismatches }) {
|
|
67
|
+
return [`${mismatches.length} file(s) in app.asar do NOT match source, byte-for-byte:`, ...mismatches.map(item => ` MISMATCH ${item.relPath} — ${item.reason}`), 'Equal sizes can hide a packaging race that shifts archive offsets.'].join('\n');
|
|
68
|
+
}
|
|
69
|
+
/** Resources inventory is caller supplied; an empty inventory is a failure. */
|
|
70
|
+
export function bundledNpmFailures(required) {
|
|
71
|
+
if (!required.resourcesDirs.length)
|
|
72
|
+
return ['no packaged resources directory was found to check for the bundled npm'];
|
|
73
|
+
if (!required.requiredFiles.length)
|
|
74
|
+
return ['no bundled npm files were specified to check'];
|
|
75
|
+
return required.resourcesDirs.flatMap(dir => required.requiredFiles.map(relative => { safeEntry(relative); return path.join(dir, relative); }).filter(file => !required.fs.exists({ path: file })));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=archive.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ArchiveReaderPort, AsarHeaderNode } from './ports.js';
|
|
2
|
+
/** Bind @electron/asar in the host rather than depending on the packaging SDK in core. */
|
|
3
|
+
export declare function createAsarArchiveReader({ asar }: {
|
|
4
|
+
asar: {
|
|
5
|
+
getRawHeader(archivePath: string): {
|
|
6
|
+
header: {
|
|
7
|
+
files?: Record<string, AsarHeaderNode>;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
extractFile(archivePath: string, entryPath: string): Uint8Array;
|
|
11
|
+
};
|
|
12
|
+
}): ArchiveReaderPort;
|
|
13
|
+
//# sourceMappingURL=asar-adapter.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Bind @electron/asar in the host rather than depending on the packaging SDK in core. */
|
|
2
|
+
export function createAsarArchiveReader({ asar }) {
|
|
3
|
+
return { header: ({ archivePath }) => asar.getRawHeader(archivePath).header, read: ({ archivePath, entryPath }) => asar.extractFile(archivePath, entryPath) };
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=asar-adapter.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ports.js';
|
|
2
|
+
export * from './policies.js';
|
|
3
|
+
export * from './archive.js';
|
|
4
|
+
export * from './staging.js';
|
|
5
|
+
export * from './imports.js';
|
|
6
|
+
export * from './stability.js';
|
|
7
|
+
export * from './node.js';
|
|
8
|
+
export * from './asar-adapter.js';
|
|
9
|
+
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './ports.js';
|
|
2
|
+
export * from './policies.js';
|
|
3
|
+
export * from './archive.js';
|
|
4
|
+
export * from './staging.js';
|
|
5
|
+
export * from './imports.js';
|
|
6
|
+
export * from './stability.js';
|
|
7
|
+
export * from './node.js';
|
|
8
|
+
export * from './asar-adapter.js';
|
|
9
|
+
//# sourceMappingURL=entry.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PackagingFilesystemPort, ImportReaderPort, ImportAliasPort } from './ports.js';
|
|
2
|
+
export interface DistImportInput {
|
|
3
|
+
distDir: string;
|
|
4
|
+
entry: string;
|
|
5
|
+
declared: ReadonlySet<string>;
|
|
6
|
+
fs: PackagingFilesystemPort;
|
|
7
|
+
imports: ImportReaderPort;
|
|
8
|
+
aliases: ImportAliasPort;
|
|
9
|
+
}
|
|
10
|
+
/** Walk reachable files once. The injected AST parser owns import syntax and comment handling. */
|
|
11
|
+
export declare function undeclaredDistImports(required: DistImportInput): string[];
|
|
12
|
+
export declare function assertDistImportsDeclared(required: DistImportInput): void;
|
|
13
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { builtinModules } from 'node:module';
|
|
3
|
+
const builtins = new Set(builtinModules);
|
|
4
|
+
/** Walk reachable files once. The injected AST parser owns import syntax and comment handling. */
|
|
5
|
+
export function undeclaredDistImports(required) {
|
|
6
|
+
const { distDir, entry, declared, fs, imports, aliases } = required;
|
|
7
|
+
const queue = [path.resolve(entry)];
|
|
8
|
+
const seen = new Set(queue);
|
|
9
|
+
const problems = [];
|
|
10
|
+
for (let index = 0; index < queue.length; index++) {
|
|
11
|
+
const file = queue[index];
|
|
12
|
+
if (!fs.exists({ path: file })) {
|
|
13
|
+
problems.push(`${path.relative(distDir, file)} (entry file not found)`);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
const source = Buffer.from(fs.read({ path: file })).toString('utf8');
|
|
17
|
+
for (const specifier of imports.imports({ file, source })) {
|
|
18
|
+
const alias = aliases.resolve({ specifier, fromFile: file, distDir });
|
|
19
|
+
const target = alias ?? (specifier.startsWith('.') || path.isAbsolute(specifier) ? path.resolve(path.dirname(file), specifier) : undefined);
|
|
20
|
+
const relative = path.relative(distDir, file);
|
|
21
|
+
if (target !== undefined) {
|
|
22
|
+
const absolute = path.resolve(target);
|
|
23
|
+
if (seen.has(absolute))
|
|
24
|
+
continue;
|
|
25
|
+
seen.add(absolute);
|
|
26
|
+
if (fs.exists({ path: absolute }))
|
|
27
|
+
queue.push(absolute);
|
|
28
|
+
else
|
|
29
|
+
problems.push(`${specifier} (${relative}: file not found)`);
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const name = specifier.split('/').slice(0, specifier.startsWith('@') ? 2 : 1).join('/');
|
|
33
|
+
if (!specifier.startsWith('node:') && !builtins.has(name) && !declared.has(name))
|
|
34
|
+
problems.push(`${name} (${relative})`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return problems;
|
|
38
|
+
}
|
|
39
|
+
export function assertDistImportsDeclared(required) {
|
|
40
|
+
const problems = undeclaredDistImports(required);
|
|
41
|
+
if (problems.length)
|
|
42
|
+
throw new Error(`built entry imports ${problems.length} undeclared packages or missing files:\n ${problems.join('\n ')}`);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PackagingFilesystemPort, PackageResolverPort } from './ports.js';
|
|
2
|
+
/** Explicit Node filesystem adapter. No effects occur until a port method is called. */
|
|
3
|
+
export declare function createNodePackagingFilesystem(_required: Record<string, never>): PackagingFilesystemPort;
|
|
4
|
+
/** Node's upward node_modules walk resolves pnpm links to real package roots. */
|
|
5
|
+
export declare function createNodePackageResolver({ fs }: {
|
|
6
|
+
fs: PackagingFilesystemPort;
|
|
7
|
+
}): PackageResolverPort;
|
|
8
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { existsSync, readFileSync, lstatSync, readdirSync, realpathSync, mkdirSync, cpSync, rmSync, statSync, openSync, readSync, closeSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
/** Explicit Node filesystem adapter. No effects occur until a port method is called. */
|
|
4
|
+
export function createNodePackagingFilesystem(_required) {
|
|
5
|
+
return {
|
|
6
|
+
exists: ({ path }) => existsSync(path), read: ({ path }) => readFileSync(path),
|
|
7
|
+
// Allocation and I/O depend only on the prefix bound, even for very large payload files.
|
|
8
|
+
readPrefix: ({ path, maxBytes }) => {
|
|
9
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 0)
|
|
10
|
+
throw new Error('maxBytes must be a nonnegative safe integer');
|
|
11
|
+
const bytes = Buffer.alloc(maxBytes);
|
|
12
|
+
const fd = openSync(path, 'r');
|
|
13
|
+
try {
|
|
14
|
+
const bytesRead = readSync(fd, bytes, 0, maxBytes, 0);
|
|
15
|
+
return bytes.subarray(0, bytesRead);
|
|
16
|
+
}
|
|
17
|
+
finally {
|
|
18
|
+
closeSync(fd);
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
stat: ({ path }) => { const info = lstatSync(path); return { kind: info.isFile() ? 'file' : info.isDirectory() ? 'directory' : 'other', mtimeMs: info.mtimeMs, diskBytes: info.blocks * 512 }; },
|
|
22
|
+
entries: ({ path }) => readdirSync(path), realpath: ({ path }) => realpathSync(path),
|
|
23
|
+
copy: ({ from, to }, optional = {}) => {
|
|
24
|
+
const source = realpathSync(from);
|
|
25
|
+
const destination = path.resolve(to);
|
|
26
|
+
if (destination === source || destination.startsWith(source + path.sep) || source.startsWith(destination + path.sep))
|
|
27
|
+
throw new Error('staging source and destination must be disjoint');
|
|
28
|
+
mkdirSync(path.dirname(destination), { recursive: true });
|
|
29
|
+
cpSync(source, destination, { recursive: true, dereference: true, filter: full => full === source || (!(optional.dropNestedModules && path.basename(full) === 'node_modules') && !optional.exclude?.({ path: full, directory: statSync(full).isDirectory() })) });
|
|
30
|
+
},
|
|
31
|
+
remove: ({ path }) => rmSync(path, { recursive: true, force: true }),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/** Node's upward node_modules walk resolves pnpm links to real package roots. */
|
|
35
|
+
export function createNodePackageResolver({ fs }) {
|
|
36
|
+
return { resolve({ fromDirectory, packageName }) {
|
|
37
|
+
if (!/^(?:@[a-zA-Z0-9._-]+\/)?[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(packageName))
|
|
38
|
+
throw new Error('Invalid package name');
|
|
39
|
+
let directory = path.resolve(fromDirectory);
|
|
40
|
+
for (;;) {
|
|
41
|
+
const candidate = path.join(directory, 'node_modules', packageName);
|
|
42
|
+
if (fs.exists({ path: path.join(candidate, 'package.json') }))
|
|
43
|
+
return fs.realpath({ path: candidate });
|
|
44
|
+
const parent = path.dirname(directory);
|
|
45
|
+
if (parent === directory)
|
|
46
|
+
return undefined;
|
|
47
|
+
directory = parent;
|
|
48
|
+
}
|
|
49
|
+
} };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface Target {
|
|
2
|
+
platform: string;
|
|
3
|
+
arch: string;
|
|
4
|
+
}
|
|
5
|
+
export interface PrebuildBuilt {
|
|
6
|
+
platform: string;
|
|
7
|
+
architectures: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface StalenessShell {
|
|
10
|
+
relative: string;
|
|
11
|
+
marker: string;
|
|
12
|
+
buildWith: string;
|
|
13
|
+
}
|
|
14
|
+
/** Independent live signals; a quiet sample still requires post-package byte verification. */
|
|
15
|
+
export declare function treeQuietProblems(required: {
|
|
16
|
+
surface: string;
|
|
17
|
+
watcherRunning: boolean;
|
|
18
|
+
gitDirtyPaths?: readonly string[];
|
|
19
|
+
movingPaths?: readonly string[];
|
|
20
|
+
}): string[];
|
|
21
|
+
/** Conservative bundle-input policy, shared by source timestamp scanning. */
|
|
22
|
+
export declare function isBundleInput({ relPath }: {
|
|
23
|
+
relPath: string;
|
|
24
|
+
}): boolean;
|
|
25
|
+
/** Missing timestamps defer to the host's existence checks; there is no stale-build tolerance. */
|
|
26
|
+
export declare function shellStalenessFailure({ builtAt, sourceAt, shell }: {
|
|
27
|
+
builtAt: number;
|
|
28
|
+
sourceAt: number;
|
|
29
|
+
shell: StalenessShell;
|
|
30
|
+
}): string | null;
|
|
31
|
+
/** npm's parseable output may contain duplicates and Windows CRLF endings. */
|
|
32
|
+
export declare function parseNpmLsPaths({ stdout, modulesDir, separator }: {
|
|
33
|
+
stdout: string;
|
|
34
|
+
modulesDir: string;
|
|
35
|
+
separator: string;
|
|
36
|
+
}): string[];
|
|
37
|
+
/** Unknown formats are retained rather than guessed to be incompatible. */
|
|
38
|
+
export declare function prebuildTarget({ entryName }: {
|
|
39
|
+
entryName: string;
|
|
40
|
+
}): PrebuildBuilt | undefined;
|
|
41
|
+
/** Targets come from arguments, never application environment names. */
|
|
42
|
+
export declare function resolveTargets({ host }: {
|
|
43
|
+
host: Target;
|
|
44
|
+
}, optional?: {
|
|
45
|
+
platform?: string;
|
|
46
|
+
arch?: string;
|
|
47
|
+
}): Target[];
|
|
48
|
+
/** Prefer npm-cli.js under Node; direct npm needs a shell only for Windows cmd wrappers. */
|
|
49
|
+
export declare function resolveNpmLsCommand(required: {
|
|
50
|
+
platform: string;
|
|
51
|
+
execPath: string;
|
|
52
|
+
}, optional?: {
|
|
53
|
+
npmExecPath?: string;
|
|
54
|
+
}): {
|
|
55
|
+
command: string;
|
|
56
|
+
args: string[];
|
|
57
|
+
shell: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** Keep source maps only for scopes explicitly supplied by the consumer. */
|
|
60
|
+
export declare function strippableReason({ relPath, keepScopes }: {
|
|
61
|
+
relPath: string;
|
|
62
|
+
keepScopes: ReadonlySet<string>;
|
|
63
|
+
}): 'declaration' | 'sourceMap' | undefined;
|
|
64
|
+
//# sourceMappingURL=policies.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
/** Independent live signals; a quiet sample still requires post-package byte verification. */
|
|
3
|
+
export function treeQuietProblems(required) {
|
|
4
|
+
const problems = [];
|
|
5
|
+
if (required.watcherRunning)
|
|
6
|
+
problems.push(`a build watch process is rewriting ${required.surface}; stop it before packaging.`);
|
|
7
|
+
if (required.gitDirtyPaths?.length)
|
|
8
|
+
problems.push(`${required.surface} has uncommitted changes: ${required.gitDirtyPaths.join(', ')}.`);
|
|
9
|
+
if (required.movingPaths?.length)
|
|
10
|
+
problems.push(`${required.surface} is still being written to: ${required.movingPaths.join(', ')} changed during this check.`);
|
|
11
|
+
return problems;
|
|
12
|
+
}
|
|
13
|
+
/** Conservative bundle-input policy, shared by source timestamp scanning. */
|
|
14
|
+
export function isBundleInput({ relPath }) {
|
|
15
|
+
const normalized = relPath.replace(/\\/g, '/');
|
|
16
|
+
if (normalized.split('/').some(segment => segment === '__tests__' || segment === '__measurements__'))
|
|
17
|
+
return false;
|
|
18
|
+
return !/\.(test|spec)\.[cm]?[jt]sx?$/.test(normalized);
|
|
19
|
+
}
|
|
20
|
+
/** Missing timestamps defer to the host's existence checks; there is no stale-build tolerance. */
|
|
21
|
+
export function shellStalenessFailure({ builtAt, sourceAt, shell }) {
|
|
22
|
+
if (builtAt === 0 || sourceAt === 0 || builtAt >= sourceAt)
|
|
23
|
+
return null;
|
|
24
|
+
return `the built shell at ${shell.relative} is STALE — its ${shell.marker} is ${((sourceAt - builtAt) / 86_400_000).toFixed(1)} day(s) older than its own source. Rebuild it with: ${shell.buildWith}`;
|
|
25
|
+
}
|
|
26
|
+
/** npm's parseable output may contain duplicates and Windows CRLF endings. */
|
|
27
|
+
export function parseNpmLsPaths({ stdout, modulesDir, separator }) {
|
|
28
|
+
const prefix = modulesDir + separator;
|
|
29
|
+
return [...new Set(stdout.split(/\r?\n/).filter(line => line.startsWith(prefix)).map(line => line.slice(prefix.length)))].sort();
|
|
30
|
+
}
|
|
31
|
+
/** Unknown formats are retained rather than guessed to be incompatible. */
|
|
32
|
+
export function prebuildTarget({ entryName }) {
|
|
33
|
+
const tag = entryName.endsWith('.node') ? entryName.slice(0, -5) : entryName;
|
|
34
|
+
const split = tag.indexOf('-');
|
|
35
|
+
if (split <= 0)
|
|
36
|
+
return undefined;
|
|
37
|
+
const platform = tag.slice(0, split);
|
|
38
|
+
const architectures = tag.slice(split + 1).split('+');
|
|
39
|
+
if (!['aix', 'android', 'darwin', 'freebsd', 'linux', 'linuxmusl', 'openbsd', 'sunos', 'win32'].includes(platform) || !architectures.every(Boolean))
|
|
40
|
+
return undefined;
|
|
41
|
+
return { platform, architectures };
|
|
42
|
+
}
|
|
43
|
+
/** Targets come from arguments, never application environment names. */
|
|
44
|
+
export function resolveTargets({ host }, optional = {}) {
|
|
45
|
+
const platform = optional.platform || host.platform;
|
|
46
|
+
const arch = optional.arch || host.arch;
|
|
47
|
+
return (arch === 'universal' ? ['x64', 'arm64'] : [arch]).map(arch => ({ platform, arch }));
|
|
48
|
+
}
|
|
49
|
+
/** Prefer npm-cli.js under Node; direct npm needs a shell only for Windows cmd wrappers. */
|
|
50
|
+
export function resolveNpmLsCommand(required, optional = {}) {
|
|
51
|
+
const args = ['ls', '--omit=dev', '--parseable', '--all'];
|
|
52
|
+
return optional.npmExecPath ? { command: required.execPath, args: [optional.npmExecPath, ...args], shell: false } : { command: 'npm', args, shell: required.platform === 'win32' };
|
|
53
|
+
}
|
|
54
|
+
/** Keep source maps only for scopes explicitly supplied by the consumer. */
|
|
55
|
+
export function strippableReason({ relPath, keepScopes }) {
|
|
56
|
+
const name = path.posix.basename(relPath);
|
|
57
|
+
if (/\.d\.[cm]?ts(\.map)?$/.test(name))
|
|
58
|
+
return 'declaration';
|
|
59
|
+
if (!name.endsWith('.map') || keepScopes.has(relPath.split('/')[0]))
|
|
60
|
+
return undefined;
|
|
61
|
+
return 'sourceMap';
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=policies.js.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export interface FileInfo {
|
|
2
|
+
kind: 'file' | 'directory' | 'other';
|
|
3
|
+
mtimeMs: number;
|
|
4
|
+
diskBytes: number;
|
|
5
|
+
}
|
|
6
|
+
/** lstat semantics for stat; copy may dereference package symlinks as explicitly requested. */
|
|
7
|
+
export interface PackagingFilesystemPort {
|
|
8
|
+
exists(required: {
|
|
9
|
+
path: string;
|
|
10
|
+
}): boolean;
|
|
11
|
+
read(required: {
|
|
12
|
+
path: string;
|
|
13
|
+
}): Uint8Array;
|
|
14
|
+
/** Required for npm staging: read at most maxBytes from offset zero, never the whole file.
|
|
15
|
+
* Optional so adapters used only for other packaging operations keep their existing shape. */
|
|
16
|
+
readPrefix?(required: {
|
|
17
|
+
path: string;
|
|
18
|
+
maxBytes: number;
|
|
19
|
+
}): Uint8Array;
|
|
20
|
+
stat(required: {
|
|
21
|
+
path: string;
|
|
22
|
+
}): FileInfo;
|
|
23
|
+
entries(required: {
|
|
24
|
+
path: string;
|
|
25
|
+
}): readonly string[];
|
|
26
|
+
realpath(required: {
|
|
27
|
+
path: string;
|
|
28
|
+
}): string;
|
|
29
|
+
copy(required: {
|
|
30
|
+
from: string;
|
|
31
|
+
to: string;
|
|
32
|
+
}, optional?: {
|
|
33
|
+
dropNestedModules?: boolean;
|
|
34
|
+
exclude?: (required: {
|
|
35
|
+
path: string;
|
|
36
|
+
directory: boolean;
|
|
37
|
+
}) => boolean;
|
|
38
|
+
}): void;
|
|
39
|
+
remove(required: {
|
|
40
|
+
path: string;
|
|
41
|
+
}): void;
|
|
42
|
+
}
|
|
43
|
+
export interface PackageResolverPort {
|
|
44
|
+
resolve(required: {
|
|
45
|
+
fromDirectory: string;
|
|
46
|
+
packageName: string;
|
|
47
|
+
}): string | undefined;
|
|
48
|
+
}
|
|
49
|
+
export interface ProcessRunnerPort {
|
|
50
|
+
run(required: {
|
|
51
|
+
command: string;
|
|
52
|
+
args: readonly string[];
|
|
53
|
+
cwd: string;
|
|
54
|
+
shell: boolean;
|
|
55
|
+
}): {
|
|
56
|
+
stdout: string;
|
|
57
|
+
exitCode: number;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface AsarHeaderNode {
|
|
61
|
+
files?: Record<string, AsarHeaderNode>;
|
|
62
|
+
link?: string;
|
|
63
|
+
size?: number;
|
|
64
|
+
offset?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface ArchiveReaderPort {
|
|
67
|
+
header(required: {
|
|
68
|
+
archivePath: string;
|
|
69
|
+
}): {
|
|
70
|
+
files?: Record<string, AsarHeaderNode>;
|
|
71
|
+
};
|
|
72
|
+
read(required: {
|
|
73
|
+
archivePath: string;
|
|
74
|
+
entryPath: string;
|
|
75
|
+
}): Uint8Array;
|
|
76
|
+
}
|
|
77
|
+
/** Must parse static imports, re-exports and literal dynamic imports using an AST, ignoring comments. */
|
|
78
|
+
export interface ImportReaderPort {
|
|
79
|
+
imports(required: {
|
|
80
|
+
file: string;
|
|
81
|
+
source: string;
|
|
82
|
+
}): readonly string[];
|
|
83
|
+
}
|
|
84
|
+
export interface ImportAliasPort {
|
|
85
|
+
resolve(required: {
|
|
86
|
+
specifier: string;
|
|
87
|
+
fromFile: string;
|
|
88
|
+
distDir: string;
|
|
89
|
+
}): string | undefined;
|
|
90
|
+
}
|
|
91
|
+
/** Bind to scripts/lib/pack-jini-packages.ts buildAndPackClosure in the host, not inside a package. */
|
|
92
|
+
export interface WorkspacePackagePackerPort {
|
|
93
|
+
pack(required: {
|
|
94
|
+
repoRoot: string;
|
|
95
|
+
packagesDir: string;
|
|
96
|
+
rootNames: readonly string[];
|
|
97
|
+
destDir: string;
|
|
98
|
+
}): {
|
|
99
|
+
readonly closure: readonly string[];
|
|
100
|
+
readonly tarballPathByName: ReadonlyMap<string, string>;
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export interface SnapshotPort {
|
|
104
|
+
snapshot(required: {
|
|
105
|
+
roots: readonly string[];
|
|
106
|
+
}): ReadonlyMap<string, string>;
|
|
107
|
+
}
|
|
108
|
+
export interface SleepPort {
|
|
109
|
+
sleep(required: {
|
|
110
|
+
milliseconds: number;
|
|
111
|
+
}): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=ports.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SnapshotPort, SleepPort } from './ports.js';
|
|
2
|
+
/** Compare live observations, not absolute file ages: a fresh checkout is quiet if unchanged. */
|
|
3
|
+
export declare function observeMovingPaths(required: {
|
|
4
|
+
roots: readonly string[];
|
|
5
|
+
intervalMs: number;
|
|
6
|
+
snapshots: SnapshotPort;
|
|
7
|
+
clock: SleepPort;
|
|
8
|
+
}): Promise<string[]>;
|
|
9
|
+
//# sourceMappingURL=stability.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Compare live observations, not absolute file ages: a fresh checkout is quiet if unchanged. */
|
|
2
|
+
export async function observeMovingPaths(required) {
|
|
3
|
+
if (!Number.isFinite(required.intervalMs) || required.intervalMs <= 0)
|
|
4
|
+
throw new Error('intervalMs must be positive');
|
|
5
|
+
if (!required.roots.length)
|
|
6
|
+
throw new Error('packaged surface roots are required');
|
|
7
|
+
const before = new Map(required.snapshots.snapshot({ roots: required.roots }));
|
|
8
|
+
await required.clock.sleep({ milliseconds: required.intervalMs });
|
|
9
|
+
const after = required.snapshots.snapshot({ roots: required.roots });
|
|
10
|
+
return [...new Set([...before.keys(), ...after.keys()])].filter(file => before.get(file) !== after.get(file)).sort();
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=stability.js.map
|