@jini-ai/devops 0.7.2 → 0.7.3-next.2
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 +2 -2
- package/README.md +8 -4
- package/dist/agent-jobs/jobs.d.ts +1 -1
- package/dist/agent-jobs/jobs.js +4 -3
- package/dist/agent-jobs/node.d.ts +2 -2
- package/dist/agent-jobs/node.js +2 -2
- package/dist/backup/plan-store.node.d.ts +73 -0
- package/dist/backup/plan-store.node.js +60 -0
- package/dist/backup/push-jobs.d.ts +88 -0
- package/dist/backup/push-jobs.js +95 -0
- package/dist/backup/upload.node.d.ts +71 -0
- package/dist/backup/upload.node.js +122 -0
- package/dist/checks/coverage/diff.d.ts +2 -2
- package/dist/checks/coverage/diff.js +2 -2
- package/dist/checks/coverage/disk.d.ts +5 -5
- package/dist/checks/coverage/disk.js +5 -5
- package/dist/checks/coverage/floors.d.ts +2 -2
- package/dist/checks/coverage/floors.js +2 -2
- package/dist/checks/coverage/integrity.d.ts +10 -5
- package/dist/checks/coverage/integrity.js +12 -5
- package/dist/checks/coverage/lcov.d.ts +8 -8
- package/dist/checks/coverage/lcov.js +8 -8
- package/dist/checks/env-access.d.ts +37 -0
- package/dist/checks/env-access.js +57 -0
- package/dist/checks/hardwiring-node.d.ts +6 -3
- package/dist/checks/hardwiring-node.js +7 -6
- package/dist/checks/hardwiring.d.ts +32 -8
- package/dist/checks/hardwiring.js +395 -338
- package/dist/checks/node.d.ts +2 -2
- package/dist/checks/node.js +2 -2
- package/dist/checks/published-types/index.d.ts +10 -4
- package/dist/checks/published-types/index.js +30 -9
- package/dist/core/redirect-guard.d.ts +2 -2
- package/dist/core/redirect-guard.js +2 -2
- package/dist/deploy/adapters/undici.d.ts +8 -0
- package/dist/deploy/adapters/undici.js +6 -0
- package/dist/deploy/config-injection.d.ts +43 -0
- package/dist/deploy/config-injection.js +60 -0
- package/dist/deploy/index.d.ts +1 -0
- package/dist/deploy/index.js +1 -0
- package/dist/deploy/naming.d.ts +2 -2
- package/dist/deploy/naming.js +2 -2
- package/dist/deploy/node.d.ts +17 -6
- package/dist/deploy/node.js +8 -9
- package/dist/deploy/ops-runner.d.ts +8 -6
- package/dist/deploy/ops-runner.js +7 -6
- package/dist/deploy/ops-tool-contracts.d.ts +2 -1
- package/dist/deploy/ops-tools.js +1 -1
- package/dist/deploy/reachability.d.ts +1 -1
- package/dist/deploy/reachability.js +1 -1
- package/dist/deploy/react/PublishRunResult.d.ts +24 -0
- package/dist/deploy/react/PublishRunResult.js +25 -0
- package/dist/deploy/react/index.d.ts +3 -0
- package/dist/deploy/react/index.js +2 -0
- package/dist/deploy/tool.d.ts +1 -1
- package/dist/deploy/tool.js +1 -1
- package/dist/dns/delegation.d.ts +2 -2
- package/dist/dns/delegation.js +5 -5
- package/dist/dns/node/resolver.js +30 -29
- package/dist/dns/verify.d.ts +1 -2
- package/dist/dns/verify.js +3 -3
- package/dist/local-dev/free-port.d.ts +25 -0
- package/dist/local-dev/free-port.js +44 -0
- package/dist/local-dev/index.d.ts +4 -3
- package/dist/local-dev/index.js +4 -3
- package/dist/local-dev/node-runtime.d.ts +2 -2
- package/dist/local-dev/node-runtime.js +1 -1
- package/dist/packaging/electron/archive.d.ts +5 -5
- package/dist/packaging/electron/archive.js +5 -5
- package/dist/packaging/electron/asar-adapter.d.ts +1 -1
- package/dist/packaging/electron/asar-adapter.js +1 -1
- package/dist/packaging/electron/entry.d.ts +4 -0
- package/dist/packaging/electron/entry.js +4 -0
- package/dist/packaging/electron/imports.d.ts +2 -2
- package/dist/packaging/electron/imports.js +2 -2
- package/dist/packaging/electron/isolation.d.ts +36 -0
- package/dist/packaging/electron/isolation.js +64 -0
- package/dist/packaging/electron/node.d.ts +2 -2
- package/dist/packaging/electron/node.js +2 -2
- package/dist/packaging/electron/payload-scan.d.ts +17 -0
- package/dist/packaging/electron/payload-scan.js +20 -0
- package/dist/packaging/electron/policies.d.ts +6 -6
- package/dist/packaging/electron/policies.js +6 -6
- package/dist/packaging/electron/stability.d.ts +1 -1
- package/dist/packaging/electron/stability.js +1 -1
- package/dist/packaging/electron/staging.d.ts +11 -11
- package/dist/packaging/electron/staging.js +11 -11
- package/dist/packaging/electron/tree-fingerprint.d.ts +31 -0
- package/dist/packaging/electron/tree-fingerprint.js +59 -0
- package/dist/packaging/electron/typescript.d.ts +8 -2
- package/dist/packaging/electron/typescript.js +108 -99
- package/dist/packaging/electron/update-manifest-merge.d.ts +53 -0
- package/dist/packaging/electron/update-manifest-merge.js +82 -0
- package/dist/source-control/commit.d.ts +19 -3
- package/dist/source-control/commit.js +99 -16
- package/dist/source-control/contracts.d.ts +20 -1
- package/dist/source-control/kit.d.ts +1 -1
- package/dist/source-control/kit.js +1 -1
- package/dist/source-control/registry.d.ts +2 -2
- package/dist/source-control/registry.js +2 -2
- package/dist/static-export/css-urls.d.ts +3 -1
- package/dist/static-export/css-urls.js +1 -1
- package/dist/static-export/fetch-adapter.d.ts +1 -1
- package/dist/static-export/fetch-adapter.js +1 -1
- package/dist/static-export/html-url-locations.js +1 -1
- package/dist/static-export/transforms.d.ts +4 -4
- package/dist/static-export/transforms.js +6 -6
- package/package.json +49 -15
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Run a packaged-app gate against a COPY of the app in a fresh OS temp directory.
|
|
3
|
+
*
|
|
4
|
+
* Why: launched inside the checkout, a packaged app resolves a missing dependency from the checkout's
|
|
5
|
+
* `node_modules` (Node walks up the directory tree), which hides a missing-peer bug from every gate.
|
|
6
|
+
* The copy is made under a directory with no `node_modules` ancestor, the gate runs against it, and
|
|
7
|
+
* the copy is always removed. The directory is a real path: a symlinked temp root (macOS
|
|
8
|
+
* `/var` -> `/private/var`) would otherwise make an entry that runs only when its argv path equals
|
|
9
|
+
* its own resolved URL exit 0 without doing anything.
|
|
10
|
+
*/
|
|
11
|
+
import { cpSync, existsSync, mkdtempSync, realpathSync, rmSync } from 'node:fs';
|
|
12
|
+
import { execFileSync } from 'node:child_process';
|
|
13
|
+
import { tmpdir } from 'node:os';
|
|
14
|
+
import path from 'node:path';
|
|
15
|
+
/** A fixed, path-only diagnostic safe for a gate to print. */
|
|
16
|
+
export class PackagedTreeIsolationError extends Error {
|
|
17
|
+
}
|
|
18
|
+
/** Throws when `directory` or any real (symlink-resolved) ancestor has a node_modules. */
|
|
19
|
+
export function assertPackagedTreeIsolation({ directory }, _optional = {}) {
|
|
20
|
+
// Walks up until `dirname` stops changing (the filesystem root, which is checked too). The loop
|
|
21
|
+
// ends on its own condition rather than an inner `return`, so it has no unreachable exit path.
|
|
22
|
+
for (let dir = realpathSync(directory), previous = ''; dir !== previous; previous = dir, dir = path.dirname(dir)) {
|
|
23
|
+
const modules = path.join(dir, 'node_modules');
|
|
24
|
+
if (existsSync(modules))
|
|
25
|
+
throw new PackagedTreeIsolationError(`Packaged gate isolation refused: ${modules} exists above ${directory}`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function copyApp({ appRoot, copiedRoot, platform, resolveCommand }) {
|
|
29
|
+
// Keep framework-relative symlinks as-is. Never ditto: ditto-copied apps have hung before dyld.
|
|
30
|
+
if (platform === 'win32') {
|
|
31
|
+
cpSync(appRoot, copiedRoot, { recursive: true, verbatimSymlinks: true });
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const command = resolveCommand({ bin: 'cp' });
|
|
35
|
+
if (command === null)
|
|
36
|
+
throw new Error('cp executable is unavailable.');
|
|
37
|
+
execFileSync(command, ['-R', appRoot, copiedRoot], { stdio: 'pipe' });
|
|
38
|
+
}
|
|
39
|
+
/** Copy the whole app bundle (a macOS `.app` or a `win-unpacked` directory) into a fresh temp dir, run the gate against the copy, always remove it.
|
|
40
|
+
* @example await withIsolatedPackagedTree({ targets, run, resolveCommand }, { tempPrefix: "acme-gate-" });
|
|
41
|
+
* @throws PackagedTreeIsolationError when the temp root has a node_modules ancestor; copy and run errors propagate.
|
|
42
|
+
* @complexity O(bundle size) for the copy.
|
|
43
|
+
*/
|
|
44
|
+
export async function withIsolatedPackagedTree({ targets, run, resolveCommand }, { tempRoot = tmpdir(), platform = process.platform, tempPrefix = 'packaged-gate-' } = {}) {
|
|
45
|
+
const directory = realpathSync(mkdtempSync(path.join(tempRoot, tempPrefix)));
|
|
46
|
+
try {
|
|
47
|
+
assertPackagedTreeIsolation({ directory });
|
|
48
|
+
const executableDir = path.dirname(targets.executablePath);
|
|
49
|
+
const appRoot = path.basename(executableDir) === 'MacOS' ? path.resolve(executableDir, '../..') : executableDir;
|
|
50
|
+
const copiedRoot = path.join(directory, path.basename(appRoot));
|
|
51
|
+
copyApp({ appRoot, copiedRoot, platform, resolveCommand });
|
|
52
|
+
await run({
|
|
53
|
+
targets: {
|
|
54
|
+
executablePath: path.join(copiedRoot, path.relative(appRoot, targets.executablePath)),
|
|
55
|
+
nodeModulesDir: path.join(copiedRoot, path.relative(appRoot, targets.nodeModulesDir)),
|
|
56
|
+
},
|
|
57
|
+
directory,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
finally {
|
|
61
|
+
rmSync(directory, { recursive: true, force: true });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=isolation.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PackagingFilesystemPort, PackageResolverPort } from './ports.js';
|
|
2
2
|
/** Explicit Node filesystem adapter. No effects occur until a port method is called. */
|
|
3
|
-
export declare function createNodePackagingFilesystem(_required: Record<string, never>): PackagingFilesystemPort;
|
|
3
|
+
export declare function createNodePackagingFilesystem(_required: Record<string, never>, _optional?: Record<string, never>): PackagingFilesystemPort;
|
|
4
4
|
/** Node's upward node_modules walk resolves pnpm links to real package roots. */
|
|
5
5
|
export declare function createNodePackageResolver({ fs }: {
|
|
6
6
|
fs: PackagingFilesystemPort;
|
|
7
|
-
}): PackageResolverPort;
|
|
7
|
+
}, _optional?: Record<string, never>): PackageResolverPort;
|
|
8
8
|
//# sourceMappingURL=node.d.ts.map
|
|
@@ -7,7 +7,7 @@ function entryKind(info) {
|
|
|
7
7
|
return info.isDirectory() ? 'directory' : 'other';
|
|
8
8
|
}
|
|
9
9
|
/** Explicit Node filesystem adapter. No effects occur until a port method is called. */
|
|
10
|
-
export function createNodePackagingFilesystem(_required) {
|
|
10
|
+
export function createNodePackagingFilesystem(_required, _optional = {}) {
|
|
11
11
|
return {
|
|
12
12
|
exists: ({ path }) => existsSync(path), read: ({ path }) => readFileSync(path),
|
|
13
13
|
// Allocation and I/O depend only on the prefix bound, even for very large payload files.
|
|
@@ -38,7 +38,7 @@ export function createNodePackagingFilesystem(_required) {
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
/** Node's upward node_modules walk resolves pnpm links to real package roots. */
|
|
41
|
-
export function createNodePackageResolver({ fs }) {
|
|
41
|
+
export function createNodePackageResolver({ fs }, _optional = {}) {
|
|
42
42
|
return { resolve({ fromDirectory, packageName }) {
|
|
43
43
|
if (!/^(?:@[a-zA-Z0-9._-]+\/)?[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(packageName))
|
|
44
44
|
throw new Error('Invalid package name');
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PackagingFilesystemPort } from './ports.js';
|
|
2
|
+
/**
|
|
3
|
+
* Every file under `root` except directories the host prunes. Pruning is the host's policy (for
|
|
4
|
+
* example material an agent reads that the server never imports, so its imports are not runtime
|
|
5
|
+
* edges); the walk itself is generic. The root is never pruned.
|
|
6
|
+
* @example walkPayloadFiles({ root: dist, fs }, { skipDirectory: ({ relative }) => isSkillFolder(relative) });
|
|
7
|
+
* @complexity O(entries) under `root`; one stat per entry.
|
|
8
|
+
*/
|
|
9
|
+
export declare function walkPayloadFiles({ root, fs }: {
|
|
10
|
+
root: string;
|
|
11
|
+
fs: Pick<PackagingFilesystemPort, 'entries' | 'stat'>;
|
|
12
|
+
}, { skipDirectory }?: {
|
|
13
|
+
skipDirectory?: (required: {
|
|
14
|
+
relative: string;
|
|
15
|
+
}) => boolean;
|
|
16
|
+
}): string[];
|
|
17
|
+
//# sourceMappingURL=payload-scan.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
/**
|
|
3
|
+
* Every file under `root` except directories the host prunes. Pruning is the host's policy (for
|
|
4
|
+
* example material an agent reads that the server never imports, so its imports are not runtime
|
|
5
|
+
* edges); the walk itself is generic. The root is never pruned.
|
|
6
|
+
* @example walkPayloadFiles({ root: dist, fs }, { skipDirectory: ({ relative }) => isSkillFolder(relative) });
|
|
7
|
+
* @complexity O(entries) under `root`; one stat per entry.
|
|
8
|
+
*/
|
|
9
|
+
export function walkPayloadFiles({ root, fs }, { skipDirectory = () => false } = {}) {
|
|
10
|
+
const walk = ({ relative }) => {
|
|
11
|
+
const absolute = path.join(root, relative);
|
|
12
|
+
if (fs.stat({ path: absolute }).kind !== 'directory')
|
|
13
|
+
return [absolute];
|
|
14
|
+
if (relative !== '' && skipDirectory({ relative }))
|
|
15
|
+
return [];
|
|
16
|
+
return fs.entries({ path: absolute }).flatMap(name => walk({ relative: path.join(relative, name) }));
|
|
17
|
+
};
|
|
18
|
+
return walk({ relative: '' });
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=payload-scan.js.map
|
|
@@ -17,27 +17,27 @@ export declare function treeQuietProblems(required: {
|
|
|
17
17
|
watcherRunning: boolean;
|
|
18
18
|
gitDirtyPaths?: readonly string[];
|
|
19
19
|
movingPaths?: readonly string[];
|
|
20
|
-
}): string[];
|
|
20
|
+
}, _optional?: Record<string, never>): string[];
|
|
21
21
|
/** Conservative bundle-input policy, shared by source timestamp scanning. */
|
|
22
22
|
export declare function isBundleInput({ relPath }: {
|
|
23
23
|
relPath: string;
|
|
24
|
-
}): boolean;
|
|
24
|
+
}, _optional?: Record<string, never>): boolean;
|
|
25
25
|
/** Missing timestamps defer to the host's existence checks; there is no stale-build tolerance. */
|
|
26
26
|
export declare function shellStalenessFailure({ builtAt, sourceAt, shell }: {
|
|
27
27
|
builtAt: number;
|
|
28
28
|
sourceAt: number;
|
|
29
29
|
shell: StalenessShell;
|
|
30
|
-
}): string | null;
|
|
30
|
+
}, _optional?: Record<string, never>): string | null;
|
|
31
31
|
/** npm's parseable output may contain duplicates and Windows CRLF endings. */
|
|
32
32
|
export declare function parseNpmLsPaths({ stdout, modulesDir, separator }: {
|
|
33
33
|
stdout: string;
|
|
34
34
|
modulesDir: string;
|
|
35
35
|
separator: string;
|
|
36
|
-
}): string[];
|
|
36
|
+
}, _optional?: Record<string, never>): string[];
|
|
37
37
|
/** Unknown formats are retained rather than guessed to be incompatible. */
|
|
38
38
|
export declare function prebuildTarget({ entryName }: {
|
|
39
39
|
entryName: string;
|
|
40
|
-
}): PrebuildBuilt | undefined;
|
|
40
|
+
}, _optional?: Record<string, never>): PrebuildBuilt | undefined;
|
|
41
41
|
/** Targets come from arguments, never application environment names. */
|
|
42
42
|
export declare function resolveTargets({ host }: {
|
|
43
43
|
host: Target;
|
|
@@ -60,5 +60,5 @@ export declare function resolveNpmLsCommand(required: {
|
|
|
60
60
|
export declare function strippableReason({ relPath, keepScopes }: {
|
|
61
61
|
relPath: string;
|
|
62
62
|
keepScopes: ReadonlySet<string>;
|
|
63
|
-
}): 'declaration' | 'sourceMap' | undefined;
|
|
63
|
+
}, _optional?: Record<string, never>): 'declaration' | 'sourceMap' | undefined;
|
|
64
64
|
//# sourceMappingURL=policies.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
/** Independent live signals; a quiet sample still requires post-package byte verification. */
|
|
3
|
-
export function treeQuietProblems(required) {
|
|
3
|
+
export function treeQuietProblems(required, _optional = {}) {
|
|
4
4
|
const problems = [];
|
|
5
5
|
if (required.watcherRunning)
|
|
6
6
|
problems.push(`a build watch process is rewriting ${required.surface}; stop it before packaging.`);
|
|
@@ -11,25 +11,25 @@ export function treeQuietProblems(required) {
|
|
|
11
11
|
return problems;
|
|
12
12
|
}
|
|
13
13
|
/** Conservative bundle-input policy, shared by source timestamp scanning. */
|
|
14
|
-
export function isBundleInput({ relPath }) {
|
|
14
|
+
export function isBundleInput({ relPath }, _optional = {}) {
|
|
15
15
|
const normalized = relPath.replace(/\\/g, '/');
|
|
16
16
|
if (normalized.split('/').some(segment => segment === '__tests__' || segment === '__measurements__'))
|
|
17
17
|
return false;
|
|
18
18
|
return !/\.(test|spec)\.[cm]?[jt]sx?$/.test(normalized);
|
|
19
19
|
}
|
|
20
20
|
/** Missing timestamps defer to the host's existence checks; there is no stale-build tolerance. */
|
|
21
|
-
export function shellStalenessFailure({ builtAt, sourceAt, shell }) {
|
|
21
|
+
export function shellStalenessFailure({ builtAt, sourceAt, shell }, _optional = {}) {
|
|
22
22
|
if (builtAt === 0 || sourceAt === 0 || builtAt >= sourceAt)
|
|
23
23
|
return null;
|
|
24
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
25
|
}
|
|
26
26
|
/** npm's parseable output may contain duplicates and Windows CRLF endings. */
|
|
27
|
-
export function parseNpmLsPaths({ stdout, modulesDir, separator }) {
|
|
27
|
+
export function parseNpmLsPaths({ stdout, modulesDir, separator }, _optional = {}) {
|
|
28
28
|
const prefix = modulesDir + separator;
|
|
29
29
|
return [...new Set(stdout.split(/\r?\n/).filter(line => line.startsWith(prefix)).map(line => line.slice(prefix.length)))].sort();
|
|
30
30
|
}
|
|
31
31
|
/** Unknown formats are retained rather than guessed to be incompatible. */
|
|
32
|
-
export function prebuildTarget({ entryName }) {
|
|
32
|
+
export function prebuildTarget({ entryName }, _optional = {}) {
|
|
33
33
|
const tag = entryName.endsWith('.node') ? entryName.slice(0, -5) : entryName;
|
|
34
34
|
const split = tag.indexOf('-');
|
|
35
35
|
if (split <= 0)
|
|
@@ -52,7 +52,7 @@ export function resolveNpmLsCommand(required, optional = {}) {
|
|
|
52
52
|
return optional.npmExecPath ? { command: required.execPath, args: [optional.npmExecPath, ...args], shell: false } : { command: 'npm', args, shell: required.platform === 'win32' };
|
|
53
53
|
}
|
|
54
54
|
/** Keep source maps only for scopes explicitly supplied by the consumer. */
|
|
55
|
-
export function strippableReason({ relPath, keepScopes }) {
|
|
55
|
+
export function strippableReason({ relPath, keepScopes }, _optional = {}) {
|
|
56
56
|
const name = path.posix.basename(relPath);
|
|
57
57
|
if (/\.d\.[cm]?ts(\.map)?$/.test(name))
|
|
58
58
|
return 'declaration';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Compare live observations, not absolute file ages: a fresh checkout is quiet if unchanged. */
|
|
2
|
-
export async function observeMovingPaths(required) {
|
|
2
|
+
export async function observeMovingPaths(required, _optional = {}) {
|
|
3
3
|
if (!Number.isFinite(required.intervalMs) || required.intervalMs <= 0)
|
|
4
4
|
throw new Error('intervalMs must be positive');
|
|
5
5
|
if (!required.roots.length)
|
|
@@ -3,7 +3,7 @@ import type { PackagingFilesystemPort, PackageResolverPort, WorkspacePackagePack
|
|
|
3
3
|
export declare function isExcluded({ name, excluded }: {
|
|
4
4
|
name: string;
|
|
5
5
|
excluded: ReadonlySet<string>;
|
|
6
|
-
}): boolean;
|
|
6
|
+
}, _optional?: Record<string, never>): boolean;
|
|
7
7
|
export declare function declaredDependencies({ packageDir, fs }: {
|
|
8
8
|
packageDir: string;
|
|
9
9
|
fs: PackagingFilesystemPort;
|
|
@@ -40,7 +40,7 @@ export declare function stageTransitiveDependencies(required: {
|
|
|
40
40
|
export declare function stagedPackageDirs({ modulesDir, fs }: {
|
|
41
41
|
modulesDir: string;
|
|
42
42
|
fs: PackagingFilesystemPort;
|
|
43
|
-
}): string[];
|
|
43
|
+
}, _optional?: Record<string, never>): string[];
|
|
44
44
|
/** Inventory every staged package, including nested scopes, and report missing declared edges.
|
|
45
45
|
* Hosts may select peers/optionals through the same policy seam as the staging planner.
|
|
46
46
|
* @returns Ordered package-to-dependency diagnostics, suitable for host-specific refusal messages.
|
|
@@ -66,7 +66,7 @@ export declare function stagePackedWorkspace(required: {
|
|
|
66
66
|
rootNames: readonly string[];
|
|
67
67
|
destDir: string;
|
|
68
68
|
packer: WorkspacePackagePackerPort;
|
|
69
|
-
}): ReturnType<WorkspacePackagePackerPort['pack']>;
|
|
69
|
+
}, _optional?: Record<string, never>): ReturnType<WorkspacePackagePackerPort['pack']>;
|
|
70
70
|
/** Run npm's dependency listing through an explicit process port, then parse with parseNpmLsPaths. */
|
|
71
71
|
export declare function productionDependencyOutput(required: {
|
|
72
72
|
command: string;
|
|
@@ -74,16 +74,16 @@ export declare function productionDependencyOutput(required: {
|
|
|
74
74
|
cwd: string;
|
|
75
75
|
shell: boolean;
|
|
76
76
|
runner: ProcessRunnerPort;
|
|
77
|
-
}): string;
|
|
77
|
+
}, _optional?: Record<string, never>): string;
|
|
78
78
|
/** Source freshness scan ignores non-bundle inputs, hidden entries and dependency trees. */
|
|
79
79
|
export declare function newestMtime({ absolutePath, fs }: {
|
|
80
80
|
absolutePath: string;
|
|
81
81
|
fs: PackagingFilesystemPort;
|
|
82
|
-
}): number;
|
|
82
|
+
}, _optional?: Record<string, never>): number;
|
|
83
83
|
export declare function diskBytes({ absolutePath, fs }: {
|
|
84
84
|
absolutePath: string;
|
|
85
85
|
fs: PackagingFilesystemPort;
|
|
86
|
-
}): number;
|
|
86
|
+
}, _optional?: Record<string, never>): number;
|
|
87
87
|
export interface StripTally {
|
|
88
88
|
declaration: number;
|
|
89
89
|
sourceMap: number;
|
|
@@ -95,7 +95,7 @@ export declare function stripNonRuntimeFiles(required: {
|
|
|
95
95
|
outDir: string;
|
|
96
96
|
keepScopes: ReadonlySet<string>;
|
|
97
97
|
fs: PackagingFilesystemPort;
|
|
98
|
-
}): StripTally;
|
|
98
|
+
}, _optional?: Record<string, never>): StripTally;
|
|
99
99
|
export interface PruneTally {
|
|
100
100
|
prebuilds: number;
|
|
101
101
|
buildInputs: number;
|
|
@@ -106,18 +106,18 @@ export declare function pruneNativePrebuilds(required: {
|
|
|
106
106
|
outDir: string;
|
|
107
107
|
targets: readonly Target[];
|
|
108
108
|
fs: PackagingFilesystemPort;
|
|
109
|
-
}): PruneTally;
|
|
109
|
+
}, _optional?: Record<string, never>): PruneTally;
|
|
110
110
|
/** Runtime copy inventory is required, so no product shells or payload paths live in this package. */
|
|
111
111
|
export declare function stagePayloadFiles(required: {
|
|
112
112
|
repoRoot: string;
|
|
113
113
|
outDir: string;
|
|
114
114
|
relativePaths: readonly string[];
|
|
115
115
|
fs: PackagingFilesystemPort;
|
|
116
|
-
}): void;
|
|
116
|
+
}, _optional?: Record<string, never>): void;
|
|
117
117
|
/** Detect Mach-O/ELF/PE magic from bytes; short files are valid inputs. */
|
|
118
118
|
export declare function hasNativeBinaryMagic({ bytes }: {
|
|
119
119
|
bytes: Uint8Array;
|
|
120
|
-
}): boolean;
|
|
120
|
+
}, _optional?: Record<string, never>): boolean;
|
|
121
121
|
/** Stage npm with an explicit drop policy, refusing unsigned native binaries before any copy. */
|
|
122
122
|
export declare function stageBundledNpm(required: {
|
|
123
123
|
npmSource: string;
|
|
@@ -126,7 +126,7 @@ export declare function stageBundledNpm(required: {
|
|
|
126
126
|
droppedDirectoryNames: ReadonlySet<string>;
|
|
127
127
|
droppedFileSuffixes: readonly string[];
|
|
128
128
|
fs: PackagingFilesystemPort;
|
|
129
|
-
}): {
|
|
129
|
+
}, _optional?: Record<string, never>): {
|
|
130
130
|
fileCount: number;
|
|
131
131
|
bytes: number;
|
|
132
132
|
};
|
|
@@ -9,7 +9,7 @@ function safePackageName(name) {
|
|
|
9
9
|
if (!/^(?:@[a-zA-Z0-9._-]+\/)?[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(name) || name === '..')
|
|
10
10
|
throw new Error(`Invalid package name: ${name}`);
|
|
11
11
|
}
|
|
12
|
-
export function isExcluded({ name, excluded }) {
|
|
12
|
+
export function isExcluded({ name, excluded }, _optional = {}) {
|
|
13
13
|
return excluded.has(name) || excluded.has(name.replace(/\\/g, '/').split('/')[0]);
|
|
14
14
|
}
|
|
15
15
|
export function declaredDependencies({ packageDir, fs }) {
|
|
@@ -156,7 +156,7 @@ export function stageTransitiveDependencies(required, optional = {}) {
|
|
|
156
156
|
return count;
|
|
157
157
|
}
|
|
158
158
|
/** Enumerate real package roots, treating scoped directories as containers. */
|
|
159
|
-
export function stagedPackageDirs({ modulesDir, fs }) {
|
|
159
|
+
export function stagedPackageDirs({ modulesDir, fs }, _optional = {}) {
|
|
160
160
|
if (!fs.exists({ path: modulesDir }))
|
|
161
161
|
return [];
|
|
162
162
|
return fs.entries({ path: modulesDir }).filter(entry => !entry.startsWith('.')).flatMap(entry => {
|
|
@@ -215,12 +215,12 @@ export function assertClosureComplete(required, optional = {}) {
|
|
|
215
215
|
throw new Error(`staged tree is missing ${missing.length} declared dependencies:\n ${missing.join('\n ')}`);
|
|
216
216
|
}
|
|
217
217
|
/** Share the existing workspace build/pack/rewritten-tarball implementation via a host binding. */
|
|
218
|
-
export function stagePackedWorkspace(required) {
|
|
218
|
+
export function stagePackedWorkspace(required, _optional = {}) {
|
|
219
219
|
const { packer, ...input } = required;
|
|
220
220
|
return packer.pack(input);
|
|
221
221
|
}
|
|
222
222
|
/** Run npm's dependency listing through an explicit process port, then parse with parseNpmLsPaths. */
|
|
223
|
-
export function productionDependencyOutput(required) {
|
|
223
|
+
export function productionDependencyOutput(required, _optional = {}) {
|
|
224
224
|
const { runner, ...request } = required;
|
|
225
225
|
const result = runner.run(request);
|
|
226
226
|
if (result.exitCode !== 0)
|
|
@@ -228,7 +228,7 @@ export function productionDependencyOutput(required) {
|
|
|
228
228
|
return result.stdout;
|
|
229
229
|
}
|
|
230
230
|
/** Source freshness scan ignores non-bundle inputs, hidden entries and dependency trees. */
|
|
231
|
-
export function newestMtime({ absolutePath, fs }) {
|
|
231
|
+
export function newestMtime({ absolutePath, fs }, _optional = {}) {
|
|
232
232
|
if (!fs.exists({ path: absolutePath }))
|
|
233
233
|
return 0;
|
|
234
234
|
const info = fs.stat({ path: absolutePath });
|
|
@@ -242,12 +242,12 @@ export function newestMtime({ absolutePath, fs }) {
|
|
|
242
242
|
}
|
|
243
243
|
return newest;
|
|
244
244
|
}
|
|
245
|
-
export function diskBytes({ absolutePath, fs }) {
|
|
245
|
+
export function diskBytes({ absolutePath, fs }, _optional = {}) {
|
|
246
246
|
const info = fs.stat({ path: absolutePath });
|
|
247
247
|
return info.kind === 'directory' ? fs.entries({ path: absolutePath }).reduce((sum, name) => sum + diskBytes({ absolutePath: path.join(absolutePath, name), fs }), 0) : info.diskBytes;
|
|
248
248
|
}
|
|
249
249
|
/** Only staged roots are accepted; the caller must keep them separate from its source dependency tree. */
|
|
250
|
-
export function stripNonRuntimeFiles(required) {
|
|
250
|
+
export function stripNonRuntimeFiles(required, _optional = {}) {
|
|
251
251
|
const { outDir, keepScopes, fs } = required;
|
|
252
252
|
const modulesDir = path.join(outDir, 'node_modules');
|
|
253
253
|
const tally = { declaration: 0, sourceMap: 0, coverage: 0, bytes: 0 };
|
|
@@ -300,7 +300,7 @@ function packagePruneRemovals(required) {
|
|
|
300
300
|
return [...foreign, ...buildInputs];
|
|
301
301
|
}
|
|
302
302
|
/** Verify every target before removing foreign prebuilds or source build inputs. */
|
|
303
|
-
export function pruneNativePrebuilds(required) {
|
|
303
|
+
export function pruneNativePrebuilds(required, _optional = {}) {
|
|
304
304
|
const { outDir, targets, fs } = required;
|
|
305
305
|
if (!targets.length)
|
|
306
306
|
throw new Error('at least one native target is required');
|
|
@@ -315,7 +315,7 @@ export function pruneNativePrebuilds(required) {
|
|
|
315
315
|
return tally;
|
|
316
316
|
}
|
|
317
317
|
/** Runtime copy inventory is required, so no product shells or payload paths live in this package. */
|
|
318
|
-
export function stagePayloadFiles(required) {
|
|
318
|
+
export function stagePayloadFiles(required, _optional = {}) {
|
|
319
319
|
const entries = required.relativePaths.map(relative => {
|
|
320
320
|
if (!relative || path.isAbsolute(relative) || relative.replace(/\\/g, '/').split('/').some(x => x === '..' || x === '.'))
|
|
321
321
|
throw new Error(`Unsafe payload path: ${relative}`);
|
|
@@ -328,12 +328,12 @@ export function stagePayloadFiles(required) {
|
|
|
328
328
|
required.fs.copy(entry);
|
|
329
329
|
}
|
|
330
330
|
/** Detect Mach-O/ELF/PE magic from bytes; short files are valid inputs. */
|
|
331
|
-
export function hasNativeBinaryMagic({ bytes }) {
|
|
331
|
+
export function hasNativeBinaryMagic({ bytes }, _optional = {}) {
|
|
332
332
|
const hex = Buffer.from(bytes.subarray(0, 4)).toString('hex');
|
|
333
333
|
return ['feedface', 'feedfacf', 'cafebabe', 'cefaedfe', 'cffaedfe', '7f454c46', '4d5a'].some(prefix => hex.startsWith(prefix));
|
|
334
334
|
}
|
|
335
335
|
/** Stage npm with an explicit drop policy, refusing unsigned native binaries before any copy. */
|
|
336
|
-
export function stageBundledNpm(required) {
|
|
336
|
+
export function stageBundledNpm(required, _optional = {}) {
|
|
337
337
|
const { npmSource, outDir, marker, droppedDirectoryNames, droppedFileSuffixes, fs } = required;
|
|
338
338
|
if (!marker || path.isAbsolute(marker) || marker.replace(/\\/g, '/').split('/').some(x => x === '.' || x === '..'))
|
|
339
339
|
throw new Error('Invalid npm marker');
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** File count plus the newest mtime under a path, or `exists: false` when the path is absent. */
|
|
2
|
+
export interface TreeFingerprint {
|
|
3
|
+
readonly exists: boolean;
|
|
4
|
+
readonly fileCount: number;
|
|
5
|
+
readonly newestMtimeMs: number;
|
|
6
|
+
}
|
|
7
|
+
/** Fingerprint one path; an absent path is a value, never an error.
|
|
8
|
+
* @example fingerprintTree({ path: "/repo/app/src" });
|
|
9
|
+
* @complexity O(n) in files under the path.
|
|
10
|
+
*/
|
|
11
|
+
export declare function fingerprintTree({ path: target }: {
|
|
12
|
+
path: string;
|
|
13
|
+
}, _optional?: Record<string, never>): TreeFingerprint;
|
|
14
|
+
export declare function fingerprintsDiffer({ a, b }: {
|
|
15
|
+
a: TreeFingerprint;
|
|
16
|
+
b: TreeFingerprint;
|
|
17
|
+
}, _optional?: Record<string, never>): boolean;
|
|
18
|
+
export interface MovingRootsRequired {
|
|
19
|
+
readonly roots: readonly string[];
|
|
20
|
+
/** Blocks for the sampling window; synchronous so a gate script needs no async plumbing for a one-shot check. */
|
|
21
|
+
readonly pause: () => void;
|
|
22
|
+
readonly fingerprint: (required: {
|
|
23
|
+
path: string;
|
|
24
|
+
}) => TreeFingerprint;
|
|
25
|
+
}
|
|
26
|
+
/** The roots whose fingerprint changed across one `pause`. No roots is a configuration error: it must never read as quiet.
|
|
27
|
+
* @example sampleMovingRoots({ roots, pause, fingerprint: fingerprintTree });
|
|
28
|
+
* @complexity O(n) in files under the roots, twice.
|
|
29
|
+
*/
|
|
30
|
+
export declare function sampleMovingRoots({ roots, pause, fingerprint }: MovingRootsRequired, _optional?: Record<string, never>): string[];
|
|
31
|
+
//# sourceMappingURL=tree-fingerprint.d.ts.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Cheap live "is this tree being written to?" sampling for a packaging precondition gate.
|
|
3
|
+
*
|
|
4
|
+
* Why a fingerprint and not a content hash or an absolute file age: the check runs twice within a
|
|
5
|
+
* second, so it cannot walk-and-hash a large tree twice; and it also runs on a fresh CI checkout,
|
|
6
|
+
* where every file's mtime is "now", so "modified in the last N seconds" would read true on every
|
|
7
|
+
* run. Two fingerprints taken a short pause apart are identical exactly when nothing was created,
|
|
8
|
+
* deleted or written in between, whatever the absolute mtimes are. This is a sample, not proof the
|
|
9
|
+
* tree stays quiet for the pack that follows; the finished archive still has to be verified.
|
|
10
|
+
*/
|
|
11
|
+
import { readdirSync, statSync } from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
const ABSENT = { exists: false, fileCount: 0, newestMtimeMs: 0 };
|
|
14
|
+
/** Fingerprint one path; an absent path is a value, never an error.
|
|
15
|
+
* @example fingerprintTree({ path: "/repo/app/src" });
|
|
16
|
+
* @complexity O(n) in files under the path.
|
|
17
|
+
*/
|
|
18
|
+
export function fingerprintTree({ path: target }, _optional = {}) {
|
|
19
|
+
let stat;
|
|
20
|
+
try {
|
|
21
|
+
stat = statSync(target);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return ABSENT;
|
|
25
|
+
}
|
|
26
|
+
if (!stat.isDirectory())
|
|
27
|
+
return { exists: true, fileCount: 1, newestMtimeMs: stat.mtimeMs };
|
|
28
|
+
let fileCount = 0;
|
|
29
|
+
let newestMtimeMs = 0;
|
|
30
|
+
for (const entry of readdirSync(target, { withFileTypes: true })) {
|
|
31
|
+
const child = path.join(target, entry.name);
|
|
32
|
+
if (entry.isDirectory()) {
|
|
33
|
+
const inner = fingerprintTree({ path: child });
|
|
34
|
+
fileCount += inner.fileCount;
|
|
35
|
+
newestMtimeMs = Math.max(newestMtimeMs, inner.newestMtimeMs);
|
|
36
|
+
}
|
|
37
|
+
else if (entry.isFile()) {
|
|
38
|
+
fileCount += 1;
|
|
39
|
+
newestMtimeMs = Math.max(newestMtimeMs, statSync(child).mtimeMs);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return { exists: true, fileCount, newestMtimeMs };
|
|
43
|
+
}
|
|
44
|
+
export function fingerprintsDiffer({ a, b }, _optional = {}) {
|
|
45
|
+
return a.exists !== b.exists || a.fileCount !== b.fileCount || a.newestMtimeMs !== b.newestMtimeMs;
|
|
46
|
+
}
|
|
47
|
+
/** The roots whose fingerprint changed across one `pause`. No roots is a configuration error: it must never read as quiet.
|
|
48
|
+
* @example sampleMovingRoots({ roots, pause, fingerprint: fingerprintTree });
|
|
49
|
+
* @complexity O(n) in files under the roots, twice.
|
|
50
|
+
*/
|
|
51
|
+
export function sampleMovingRoots({ roots, pause, fingerprint }, _optional = {}) {
|
|
52
|
+
if (!roots.length)
|
|
53
|
+
throw new Error('packaged surface roots are required');
|
|
54
|
+
const before = roots.map(root => fingerprint({ path: root }));
|
|
55
|
+
pause();
|
|
56
|
+
const after = roots.map(root => fingerprint({ path: root }));
|
|
57
|
+
return roots.filter((_, index) => fingerprintsDiffer({ a: before[index], b: after[index] }));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=tree-fingerprint.js.map
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import type ts from 'typescript';
|
|
2
2
|
import type { ImportReaderPort } from './ports.js';
|
|
3
|
+
/** `syntax` names the form that loads the module (`import-equals` is `import x = require()`). */
|
|
4
|
+
export type RuntimeImportSyntax = 'import' | 'export' | 'import-equals' | 'dynamic' | 'require';
|
|
3
5
|
export interface RuntimeImportRef {
|
|
4
6
|
specifier: string;
|
|
5
7
|
kind: 'import' | 'require';
|
|
8
|
+
syntax: RuntimeImportSyntax;
|
|
6
9
|
line: number;
|
|
7
10
|
deferred: boolean;
|
|
8
11
|
typeOnly?: boolean;
|
|
9
12
|
}
|
|
10
|
-
/** Read syntax with the host's maintained parser. No module is executed. O(source length).
|
|
13
|
+
/** Read syntax with the host's maintained parser. No module is executed. O(source length).
|
|
14
|
+
* A caller that already parsed the file passes its `tree` so the source is parsed once. */
|
|
11
15
|
export declare function runtimeImportReferences({ compiler: c, file, source }: {
|
|
12
16
|
compiler: typeof ts;
|
|
13
17
|
file: string;
|
|
14
18
|
source: string;
|
|
15
|
-
},
|
|
19
|
+
}, { tree: parsed }?: {
|
|
20
|
+
tree?: ts.SourceFile;
|
|
21
|
+
}): RuntimeImportRef[];
|
|
16
22
|
/** Bind one parser owner for static, dynamic, CommonJS and createRequire references. */
|
|
17
23
|
export declare function createTypeScriptImportReader({ compiler }: {
|
|
18
24
|
compiler: typeof ts;
|