@jini-ai/devops 0.7.1 → 0.7.3-next.1
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 +48 -14
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file A static publish run's terminal detail, shared by the Deployment Static Site tab and the
|
|
3
|
+
* Sites Export tab's Publish list (one copy, so both read a settled run the same way).
|
|
4
|
+
*/
|
|
5
|
+
export interface PublishRunResultProps {
|
|
6
|
+
run: {
|
|
7
|
+
status: 'idle' | 'running' | 'completed' | 'errored';
|
|
8
|
+
result?: {
|
|
9
|
+
ok: true;
|
|
10
|
+
url: string;
|
|
11
|
+
} | {
|
|
12
|
+
ok: false;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
error?: string;
|
|
16
|
+
};
|
|
17
|
+
publishedLabel: string;
|
|
18
|
+
linkLabel: string;
|
|
19
|
+
/** The result link's agent handle — unique per screen that shows a run. */
|
|
20
|
+
linkHandle: string;
|
|
21
|
+
}
|
|
22
|
+
/** A publish run's completed/errored detail — the live URL on success, or the failure message. */
|
|
23
|
+
export declare function PublishRunResult({ run, publishedLabel, linkLabel, linkHandle }: PublishRunResultProps): import("react").JSX.Element | null;
|
|
24
|
+
//# sourceMappingURL=PublishRunResult.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { agentHandle } from "@jini-ai/core/agent-handles";
|
|
3
|
+
/** A publish run's completed/errored detail — the live URL on success, or the failure message. */
|
|
4
|
+
export function PublishRunResult({ run, publishedLabel, linkLabel, linkHandle }) {
|
|
5
|
+
if (run.status !== "completed" && run.status !== "errored")
|
|
6
|
+
return null;
|
|
7
|
+
// `result` can be present at EITHER terminal status — `publish-site.ts`'s own trigger route maps
|
|
8
|
+
// ANY `publishStaticSite` outcome with `ok: false` (bad config, no credential, a rejected provider
|
|
9
|
+
// call) to `status: "errored"`, not `"completed"`; only a route-level exception the route itself
|
|
10
|
+
// never expected (no `result` at all) falls back to the bare `run.error` string. Checking `result`
|
|
11
|
+
// FIRST regardless of `status` is what a naive `status === "errored" -> run.error` branch gets
|
|
12
|
+
// wrong — verified live against a real triggered publish with no credential configured, which
|
|
13
|
+
// settles to `status: "errored"` with a full `result.message`, not an empty `run.error`.
|
|
14
|
+
if (run.result) {
|
|
15
|
+
if (!run.result.ok) {
|
|
16
|
+
return (_jsx("p", { className: "save-error", role: "alert", children: run.result.message }));
|
|
17
|
+
}
|
|
18
|
+
return (_jsxs("p", { className: "save-ok", children: [publishedLabel, " ", _jsx("a", { href: run.result.url, target: "_blank", rel: "noreferrer", translate: "no", ...agentHandle({ handle: linkHandle }, { role: "link", label: linkLabel }), children: run.result.url })] }));
|
|
19
|
+
}
|
|
20
|
+
if (run.error) {
|
|
21
|
+
return _jsx("p", { className: "save-error", role: "alert", children: run.error });
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=PublishRunResult.js.map
|
package/dist/deploy/tool.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare const DEFAULT_DEPLOY_PUBLISH_ROLE = "deploy:publish";
|
|
|
46
46
|
* calls, a wrongly-allowed `deploy.publish` is not cheaply reversible and
|
|
47
47
|
* has an externally visible blast radius. That is a strictly stronger case
|
|
48
48
|
* for deny-by-default than `@jini-ai/media`'s `DEFAULT_MEDIA_EXECUTION_POLICY`
|
|
49
|
-
* (SEC-RB-010, `packages/
|
|
49
|
+
* (SEC-RB-010, `packages/integrations/src/media-providers/policy.ts`) — media generation is
|
|
50
50
|
* costly but self-contained; a bad deploy is costly AND publicly visible AND
|
|
51
51
|
* (for custom domains) mutates DNS. Matching this branch's established
|
|
52
52
|
* "deny-by-default" discipline (see commit `0a9c9c237`'s media-policy fix)
|
package/dist/deploy/tool.js
CHANGED
|
@@ -26,7 +26,7 @@ export const DEFAULT_DEPLOY_PUBLISH_ROLE = 'deploy:publish';
|
|
|
26
26
|
* calls, a wrongly-allowed `deploy.publish` is not cheaply reversible and
|
|
27
27
|
* has an externally visible blast radius. That is a strictly stronger case
|
|
28
28
|
* for deny-by-default than `@jini-ai/media`'s `DEFAULT_MEDIA_EXECUTION_POLICY`
|
|
29
|
-
* (SEC-RB-010, `packages/
|
|
29
|
+
* (SEC-RB-010, `packages/integrations/src/media-providers/policy.ts`) — media generation is
|
|
30
30
|
* costly but self-contained; a bad deploy is costly AND publicly visible AND
|
|
31
31
|
* (for custom domains) mutates DNS. Matching this branch's established
|
|
32
32
|
* "deny-by-default" discipline (see commit `0a9c9c237`'s media-policy fix)
|
package/dist/dns/delegation.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export declare function settlePort<T>(required: {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function checkDelegation(required: {
|
|
31
31
|
readonly zone: string;
|
|
32
|
-
readonly expectedNameservers?: readonly string[];
|
|
33
|
-
}, ports: {
|
|
34
32
|
readonly resolver: AuthoritativeDnsPort;
|
|
33
|
+
}, optional?: {
|
|
34
|
+
readonly expectedNameservers?: readonly string[];
|
|
35
35
|
}): Promise<DelegationCheck>;
|
|
36
36
|
//# sourceMappingURL=delegation.d.ts.map
|
package/dist/dns/delegation.js
CHANGED
|
@@ -23,18 +23,18 @@ function compare(actual, expected) {
|
|
|
23
23
|
* exactly: a leftover nameserver of the previous host would answer some queries with old data.
|
|
24
24
|
* A transport failure is `unknown`, never `not_delegated`.
|
|
25
25
|
*/
|
|
26
|
-
export async function checkDelegation(required,
|
|
26
|
+
export async function checkDelegation(required, optional = {}) {
|
|
27
27
|
const zone = normalizeDnsName({ name: required.zone });
|
|
28
|
-
const result = await settlePort({ call: () =>
|
|
28
|
+
const result = await settlePort({ call: () => required.resolver.queryNs({ zone }) });
|
|
29
29
|
const empty = { zone, nameservers: [], missing: [], unexpected: [] };
|
|
30
30
|
if (result.status === 'unknown')
|
|
31
|
-
return { ...empty, state: 'unknown', reason: `The delegation of ${zone} could not be read:
|
|
31
|
+
return { ...empty, state: 'unknown', reason: `The delegation of ${zone} could not be read: DNS lookup failed.` };
|
|
32
32
|
if (result.status === 'rejected' && result.error.code !== 'not_found')
|
|
33
|
-
return { ...empty, state: 'unknown', reason: `The delegation of ${zone} could not be read:
|
|
33
|
+
return { ...empty, state: 'unknown', reason: `The delegation of ${zone} could not be read: DNS lookup failed.` };
|
|
34
34
|
const nameservers = result.status === 'ok' ? [...new Set(result.value.map(name => normalizeDnsName({ name })))].sort() : [];
|
|
35
35
|
if (nameservers.length === 0)
|
|
36
36
|
return { ...empty, state: 'not_delegated', reason: `${zone} has no NS delegation in its parent zone.` };
|
|
37
|
-
const expected = (
|
|
37
|
+
const expected = (optional.expectedNameservers ?? []).map(name => normalizeDnsName({ name }));
|
|
38
38
|
const { missing, unexpected } = compare(nameservers, expected);
|
|
39
39
|
if (expected.length > 0 && missing.length + unexpected.length > 0) {
|
|
40
40
|
return { zone, nameservers, missing, unexpected, state: 'not_delegated', reason: `${zone} is delegated to ${nameservers.join(', ')}, not to ${expected.join(', ')}; change the nameservers at the registrar.` };
|
|
@@ -69,6 +69,33 @@ function parentOf(name) {
|
|
|
69
69
|
const dot = name.indexOf('.');
|
|
70
70
|
return dot < 0 ? undefined : name.slice(dot + 1);
|
|
71
71
|
}
|
|
72
|
+
/** The NS set of the closest enclosing zone of `name` (a name without its own NS is not a zone cut). */
|
|
73
|
+
async function findEnclosingServers({ bootstrap, name }) {
|
|
74
|
+
for (let candidate = name; candidate !== undefined; candidate = parentOf(candidate)) {
|
|
75
|
+
const zone = candidate;
|
|
76
|
+
const result = await settle(() => bootstrap.resolveNs(zone), []);
|
|
77
|
+
if (result.status !== 'ok' || result.value.length > 0)
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
return providerUnknown({ code: 'network', message: `No zone enclosing ${name} has nameservers.` });
|
|
81
|
+
}
|
|
82
|
+
/** One NS question to one parent server; a mismatched id or truncated reply is not an answer. */
|
|
83
|
+
async function askParentServer({ address, zone, exchange, randomId, timeoutMs }) {
|
|
84
|
+
try {
|
|
85
|
+
const id = randomId();
|
|
86
|
+
const reply = decodeNsReply({ message: await exchange({ address, message: encodeNsQuery({ id, name: zone }), timeoutMs }), name: zone });
|
|
87
|
+
if (reply.id !== id || reply.truncated)
|
|
88
|
+
return providerUnknown({ code: 'network', message: `The parent nameserver ${address} sent an unusable reply.` });
|
|
89
|
+
if (reply.rcode === DNS_RCODE_NXDOMAIN)
|
|
90
|
+
return providerRejected({ code: 'not_found', message: 'The name does not exist.' });
|
|
91
|
+
if (reply.rcode !== 0)
|
|
92
|
+
return providerUnknown({ code: 'network', message: `The parent nameserver ${address} refused the query (rcode ${reply.rcode}).` });
|
|
93
|
+
return providerOk({ value: reply.nameservers });
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
return providerUnknown({ code: 'network', message: 'The DNS query failed before an answer arrived.' });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
72
99
|
/**
|
|
73
100
|
* Build the adapter.
|
|
74
101
|
* @param required.isPublicAddress - Host address policy: only addresses it accepts are queried.
|
|
@@ -94,41 +121,15 @@ export function createNodeAuthoritativeDnsResolver(required, optional = {}) {
|
|
|
94
121
|
const addresses = [v4, v6].flatMap(result => (result.status === 'ok' ? result.value : []));
|
|
95
122
|
return publicOnly(addresses)[0];
|
|
96
123
|
};
|
|
97
|
-
|
|
98
|
-
const enclosingServers = async (name) => {
|
|
99
|
-
for (let candidate = name; candidate !== undefined; candidate = parentOf(candidate)) {
|
|
100
|
-
const zone = candidate;
|
|
101
|
-
const result = await settle(() => bootstrap.resolveNs(zone), []);
|
|
102
|
-
if (result.status !== 'ok' || result.value.length > 0)
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
return providerUnknown({ code: 'network', message: `No zone enclosing ${name} has nameservers.` });
|
|
106
|
-
};
|
|
107
|
-
/** One NS question to one parent server; a mismatched id or truncated reply is not an answer. */
|
|
108
|
-
const askParent = async (address, zone) => {
|
|
109
|
-
try {
|
|
110
|
-
const id = randomId();
|
|
111
|
-
const reply = decodeNsReply({ message: await exchange({ address, message: encodeNsQuery({ id, name: zone }), timeoutMs }), name: zone });
|
|
112
|
-
if (reply.id !== id || reply.truncated)
|
|
113
|
-
return providerUnknown({ code: 'network', message: `The parent nameserver ${address} sent an unusable reply.` });
|
|
114
|
-
if (reply.rcode === DNS_RCODE_NXDOMAIN)
|
|
115
|
-
return providerRejected({ code: 'not_found', message: 'The name does not exist.' });
|
|
116
|
-
if (reply.rcode !== 0)
|
|
117
|
-
return providerUnknown({ code: 'network', message: `The parent nameserver ${address} refused the query (rcode ${reply.rcode}).` });
|
|
118
|
-
return providerOk({ value: reply.nameservers });
|
|
119
|
-
}
|
|
120
|
-
catch {
|
|
121
|
-
return providerUnknown({ code: 'network', message: 'The DNS query failed before an answer arrived.' });
|
|
122
|
-
}
|
|
123
|
-
};
|
|
124
|
+
const askParent = ({ address, zone }) => askParentServer({ address, zone, exchange, randomId, timeoutMs });
|
|
124
125
|
/** The parent's delegation of `zone`, from the first parent server that gives a usable reply. */
|
|
125
126
|
const delegation = async (zone, parent) => {
|
|
126
|
-
const servers = await
|
|
127
|
+
const servers = await findEnclosingServers({ bootstrap, name: parent });
|
|
127
128
|
if (servers.status !== 'ok')
|
|
128
129
|
return servers;
|
|
129
130
|
for (const server of servers.value) {
|
|
130
131
|
const address = await nameserverAddress(server);
|
|
131
|
-
const result = address === undefined ? undefined : await askParent(address, zone);
|
|
132
|
+
const result = address === undefined ? undefined : await askParent({ address, zone });
|
|
132
133
|
if (result !== undefined && result.status !== 'unknown')
|
|
133
134
|
return result;
|
|
134
135
|
}
|
package/dist/dns/verify.d.ts
CHANGED
|
@@ -55,7 +55,6 @@ export declare function aggregatePropagation(required: {
|
|
|
55
55
|
export declare function verifyRequirements(required: {
|
|
56
56
|
readonly zone: string;
|
|
57
57
|
readonly requirements: readonly DnsPlanRequirement[];
|
|
58
|
-
}, ports: {
|
|
59
58
|
readonly resolver: AuthoritativeDnsPort;
|
|
60
|
-
}): Promise<DnsVerification>;
|
|
59
|
+
}, _optional?: Record<string, never>): Promise<DnsVerification>;
|
|
61
60
|
//# sourceMappingURL=verify.d.ts.map
|
package/dist/dns/verify.js
CHANGED
|
@@ -90,10 +90,10 @@ export function aggregatePropagation(required, _optional = {}) {
|
|
|
90
90
|
* Check every requirement record on every authoritative nameserver of `zone`.
|
|
91
91
|
* @complexity O(records · nameservers) queries, issued concurrently.
|
|
92
92
|
*/
|
|
93
|
-
export async function verifyRequirements(required,
|
|
93
|
+
export async function verifyRequirements(required, _optional = {}) {
|
|
94
94
|
const zone = normalizeDnsName({ name: required.zone });
|
|
95
95
|
const records = required.requirements.flatMap(requirement => requirement.records);
|
|
96
|
-
const ns = await settlePort({ call: () =>
|
|
96
|
+
const ns = await settlePort({ call: () => required.resolver.queryNs({ zone }) });
|
|
97
97
|
const nameservers = ns.status === 'ok' ? [...new Set(ns.value.map(name => normalizeDnsName({ name })))] : [];
|
|
98
98
|
if (nameservers.length === 0) {
|
|
99
99
|
const reason = ns.status === 'ok' ? `${zone} has no authoritative nameservers.` : `The nameservers of ${zone} could not be read.`;
|
|
@@ -101,7 +101,7 @@ export async function verifyRequirements(required, ports) {
|
|
|
101
101
|
}
|
|
102
102
|
const verified = await Promise.all(records.map(async (record) => {
|
|
103
103
|
const siblings = sameRrset(records, record);
|
|
104
|
-
const byNameserver = await Promise.all(nameservers.map(nameserver => observe(record, nameserver, { resolver:
|
|
104
|
+
const byNameserver = await Promise.all(nameservers.map(nameserver => observe(record, nameserver, { resolver: required.resolver, siblings })));
|
|
105
105
|
return { record, state: recordState(byNameserver.map(observation => observation.state)), byNameserver };
|
|
106
106
|
}));
|
|
107
107
|
return { zone, nameservers, records: verified, state: aggregatePropagation({ states: verified.map(record => record.state) }) };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Both loopback addresses. A dev server that binds `localhost` can land on `::1` while other
|
|
2
|
+
* servers bind `127.0.0.1`, so a probe of one family can report free a port a strict bind on the
|
|
3
|
+
* other family then fails on. */
|
|
4
|
+
export declare const LOOPBACK_HOSTS: readonly string[];
|
|
5
|
+
/** Whether nothing listens on `port` on every host (default: both loopbacks), probed in order and
|
|
6
|
+
* stopping at the first taken one.
|
|
7
|
+
* @complexity One bind/close round trip per host. */
|
|
8
|
+
export declare function isPortFree({ port }: {
|
|
9
|
+
port: number;
|
|
10
|
+
}, { hosts }?: {
|
|
11
|
+
hosts?: readonly string[];
|
|
12
|
+
}): Promise<boolean>;
|
|
13
|
+
/** The first port in `[start, start + span)` the probe reports free, or `null` when none is.
|
|
14
|
+
* Scans upward from a fixed base rather than asking the OS for `:0`, so a single instance lands on a
|
|
15
|
+
* predictable port (easy to spot in logs) while a second instance still gets the next one.
|
|
16
|
+
* @complexity O(span) probes in the worst case. */
|
|
17
|
+
export declare function pickFreePort({ start, span }: {
|
|
18
|
+
start: number;
|
|
19
|
+
span: number;
|
|
20
|
+
}, { isPortFree: probe, }?: {
|
|
21
|
+
isPortFree?: (args: {
|
|
22
|
+
port: number;
|
|
23
|
+
}) => Promise<boolean>;
|
|
24
|
+
}): Promise<number | null>;
|
|
25
|
+
//# sourceMappingURL=free-port.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Advisory free-port scan for development launchers.
|
|
3
|
+
*
|
|
4
|
+
* A probe is a hint, not a reservation: another process can take the port between the probe and
|
|
5
|
+
* the real bind. Pair it with a strict bind that fails loudly; for a server this package binds
|
|
6
|
+
* itself, prefer `listenServer`, which retries on the real bind and has no probe/bind race.
|
|
7
|
+
*/
|
|
8
|
+
import net from 'node:net';
|
|
9
|
+
/** Both loopback addresses. A dev server that binds `localhost` can land on `::1` while other
|
|
10
|
+
* servers bind `127.0.0.1`, so a probe of one family can report free a port a strict bind on the
|
|
11
|
+
* other family then fails on. */
|
|
12
|
+
export const LOOPBACK_HOSTS = ['127.0.0.1', '::1'];
|
|
13
|
+
/** Only EADDRINUSE counts as taken. Any other bind error (e.g. EADDRNOTAVAIL for `::1` on a host
|
|
14
|
+
* with IPv6 disabled) means that address family cannot be used at all, which says nothing about the port.
|
|
15
|
+
* @complexity One bind/close round trip. */
|
|
16
|
+
function isPortFreeOn({ port, host }) {
|
|
17
|
+
return new Promise((resolve) => {
|
|
18
|
+
const server = net.createServer();
|
|
19
|
+
server.once('error', (error) => resolve(error.code !== 'EADDRINUSE'));
|
|
20
|
+
server.listen({ port, host, exclusive: true }, () => server.close(() => resolve(true)));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/** Whether nothing listens on `port` on every host (default: both loopbacks), probed in order and
|
|
24
|
+
* stopping at the first taken one.
|
|
25
|
+
* @complexity One bind/close round trip per host. */
|
|
26
|
+
export async function isPortFree({ port }, { hosts = LOOPBACK_HOSTS } = {}) {
|
|
27
|
+
for (const host of hosts) {
|
|
28
|
+
if (!(await isPortFreeOn({ port, host })))
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
/** The first port in `[start, start + span)` the probe reports free, or `null` when none is.
|
|
34
|
+
* Scans upward from a fixed base rather than asking the OS for `:0`, so a single instance lands on a
|
|
35
|
+
* predictable port (easy to spot in logs) while a second instance still gets the next one.
|
|
36
|
+
* @complexity O(span) probes in the worst case. */
|
|
37
|
+
export async function pickFreePort({ start, span }, { isPortFree: probe = ({ port }) => isPortFree({ port }), } = {}) {
|
|
38
|
+
for (let port = start; port < start + span; port += 1) {
|
|
39
|
+
if (await probe({ port }))
|
|
40
|
+
return port;
|
|
41
|
+
}
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=free-port.js.map
|
|
@@ -2,6 +2,7 @@ import type { ProcessRequest, ProcessRunnerPort } from '../checks/ports.js';
|
|
|
2
2
|
export { selectNodeRuntime } from './node-runtime.js';
|
|
3
3
|
export { sourceTreeStamp } from './source-tree-stamp.js';
|
|
4
4
|
export { createDevServerRetirement } from './server-retirement.js';
|
|
5
|
+
export { isPortFree, pickFreePort, LOOPBACK_HOSTS } from './free-port.js';
|
|
5
6
|
export interface EnvLoaderPort {
|
|
6
7
|
load(args: {
|
|
7
8
|
path: string;
|
|
@@ -21,11 +22,11 @@ export declare function loadRepoRootEnvFile({ environmentFile, fs, loader }: {
|
|
|
21
22
|
environmentFile: string;
|
|
22
23
|
fs: EnvironmentFilesystemPort;
|
|
23
24
|
loader: EnvLoaderPort;
|
|
24
|
-
}): boolean;
|
|
25
|
+
}, _optional?: Record<string, never>): boolean;
|
|
25
26
|
/** Parse lsof's field format, dropping incomplete records. Does not spawn a process. */
|
|
26
27
|
export declare function parseLsofListeners({ stdout }: {
|
|
27
28
|
stdout: string;
|
|
28
|
-
}): PortListener[];
|
|
29
|
+
}, _optional?: Record<string, never>): PortListener[];
|
|
29
30
|
/** Best-effort TCP-listener lookup. The host supplies the platform's listener executable/args. */
|
|
30
31
|
export declare function listenersOn({ port, runner, listenerCommand }: {
|
|
31
32
|
port: number;
|
|
@@ -33,7 +34,7 @@ export declare function listenersOn({ port, runner, listenerCommand }: {
|
|
|
33
34
|
listenerCommand: (args: {
|
|
34
35
|
port: number;
|
|
35
36
|
}) => ProcessRequest;
|
|
36
|
-
}): Promise<PortListener[]>;
|
|
37
|
+
}, _optional?: Record<string, never>): Promise<PortListener[]>;
|
|
37
38
|
/** Minimal listener port; adapters may supply HTTP, HTTPS, or a deterministic socket double. */
|
|
38
39
|
export interface ServerListenerPort {
|
|
39
40
|
once(event: 'error' | 'listening', handler: (...args: unknown[]) => void): unknown;
|
package/dist/local-dev/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export { selectNodeRuntime } from './node-runtime.js';
|
|
2
2
|
export { sourceTreeStamp } from './source-tree-stamp.js';
|
|
3
3
|
export { createDevServerRetirement } from './server-retirement.js';
|
|
4
|
+
export { isPortFree, pickFreePort, LOOPBACK_HOSTS } from './free-port.js';
|
|
4
5
|
/** Load the required environment-file path, if present. Loader errors propagate to the caller. */
|
|
5
|
-
export function loadRepoRootEnvFile({ environmentFile, fs, loader }) {
|
|
6
|
+
export function loadRepoRootEnvFile({ environmentFile, fs, loader }, _optional = {}) {
|
|
6
7
|
if (!fs.exists({ path: environmentFile }))
|
|
7
8
|
return false;
|
|
8
9
|
loader.load({ path: environmentFile });
|
|
9
10
|
return true;
|
|
10
11
|
}
|
|
11
12
|
/** Parse lsof's field format, dropping incomplete records. Does not spawn a process. */
|
|
12
|
-
export function parseLsofListeners({ stdout }) {
|
|
13
|
+
export function parseLsofListeners({ stdout }, _optional = {}) {
|
|
13
14
|
const found = [];
|
|
14
15
|
let pid;
|
|
15
16
|
for (const line of stdout.replace(/\r\n/g, '\n').split('\n')) {
|
|
@@ -25,7 +26,7 @@ export function parseLsofListeners({ stdout }) {
|
|
|
25
26
|
return found;
|
|
26
27
|
}
|
|
27
28
|
/** Best-effort TCP-listener lookup. The host supplies the platform's listener executable/args. */
|
|
28
|
-
export async function listenersOn({ port, runner, listenerCommand }) {
|
|
29
|
+
export async function listenersOn({ port, runner, listenerCommand }, _optional = {}) {
|
|
29
30
|
if (!Number.isInteger(port) || port < 1 || port > 65535)
|
|
30
31
|
throw new RangeError('port must be an integer from 1 to 65535');
|
|
31
32
|
const request = listenerCommand({ port });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
interface RuntimeInput {
|
|
2
2
|
searchFrom: readonly string[];
|
|
3
3
|
nodePath: string;
|
|
4
|
+
env: NodeJS.ProcessEnv;
|
|
4
5
|
}
|
|
5
6
|
interface RuntimeOptions {
|
|
6
7
|
resolveBinary?: (input: {
|
|
@@ -10,14 +11,13 @@ interface RuntimeOptions {
|
|
|
10
11
|
command: string;
|
|
11
12
|
env: NodeJS.ProcessEnv;
|
|
12
13
|
}) => boolean;
|
|
13
|
-
env?: NodeJS.ProcessEnv;
|
|
14
14
|
}
|
|
15
15
|
/** Select an installed desktop Node runtime, falling back without refusing boot.
|
|
16
16
|
* Executables are returned separately from arguments: paths with spaces work on Windows too.
|
|
17
17
|
* @returns Command and the minimal environment override; never mutates the caller's environment.
|
|
18
18
|
* @complexity O(search roots), with one bounded 5s native probe per discovered binary.
|
|
19
19
|
*/
|
|
20
|
-
export declare function selectNodeRuntime({ searchFrom, nodePath }: RuntimeInput, { resolveBinary, usable
|
|
20
|
+
export declare function selectNodeRuntime({ searchFrom, nodePath, env }: RuntimeInput, { resolveBinary, usable }?: RuntimeOptions): {
|
|
21
21
|
command: string;
|
|
22
22
|
env: Record<string, string>;
|
|
23
23
|
fallback: boolean;
|
|
@@ -20,7 +20,7 @@ function usableBinary({ command, env }) {
|
|
|
20
20
|
* @returns Command and the minimal environment override; never mutates the caller's environment.
|
|
21
21
|
* @complexity O(search roots), with one bounded 5s native probe per discovered binary.
|
|
22
22
|
*/
|
|
23
|
-
export function selectNodeRuntime({ searchFrom, nodePath }, { resolveBinary = installedBinary, usable = usableBinary
|
|
23
|
+
export function selectNodeRuntime({ searchFrom, nodePath, env }, { resolveBinary = installedBinary, usable = usableBinary } = {}) {
|
|
24
24
|
for (const directory of searchFrom) {
|
|
25
25
|
try {
|
|
26
26
|
const command = resolveBinary({ directory });
|
|
@@ -24,7 +24,7 @@ export interface AsarVerification {
|
|
|
24
24
|
export declare function filesUnderPrefixes({ headerFiles, prefixes }: {
|
|
25
25
|
headerFiles: Record<string, AsarHeaderNode> | undefined;
|
|
26
26
|
prefixes: readonly string[];
|
|
27
|
-
}): string[];
|
|
27
|
+
}, _optional?: Record<string, never>): string[];
|
|
28
28
|
/**
|
|
29
29
|
* Converts a POSIX-style archive-relative path (as {@link filesUnderPrefixes} always produces,
|
|
30
30
|
* e.g. `"src/sub/b.js"`) to the separator `extractFile` actually needs on this host.
|
|
@@ -42,7 +42,7 @@ export declare function filesUnderPrefixes({ headerFiles, prefixes }: {
|
|
|
42
42
|
export declare function toArchiveEntryPath({ relPath, separator }: {
|
|
43
43
|
relPath: string;
|
|
44
44
|
separator: string;
|
|
45
|
-
}): string;
|
|
45
|
+
}, _optional?: Record<string, never>): string;
|
|
46
46
|
type VerifyRequired = {
|
|
47
47
|
archivePath: string;
|
|
48
48
|
sourceRoot: string;
|
|
@@ -71,15 +71,15 @@ export declare function verifyAsarAgainstSource(required: VerifyRequired, option
|
|
|
71
71
|
*/
|
|
72
72
|
export declare function isEmptyVerification({ checkedCount }: {
|
|
73
73
|
checkedCount: number;
|
|
74
|
-
}): boolean;
|
|
74
|
+
}, _optional?: Record<string, never>): boolean;
|
|
75
75
|
export declare function formatMismatchReport({ mismatches }: {
|
|
76
76
|
mismatches: readonly AsarMismatch[];
|
|
77
|
-
}): string;
|
|
77
|
+
}, _optional?: Record<string, never>): string;
|
|
78
78
|
/** Resources inventory is caller supplied; an empty inventory is a failure. */
|
|
79
79
|
export declare function bundledNpmFailures(required: {
|
|
80
80
|
resourcesDirs: readonly string[];
|
|
81
81
|
requiredFiles: readonly string[];
|
|
82
82
|
fs: PackagingFilesystemPort;
|
|
83
|
-
}): string[];
|
|
83
|
+
}, _optional?: Record<string, never>): string[];
|
|
84
84
|
export {};
|
|
85
85
|
//# sourceMappingURL=archive.d.ts.map
|
|
@@ -19,7 +19,7 @@ function safeEntry(value) {
|
|
|
19
19
|
* @returns POSIX-style relative paths, e.g. `"src/tracked-sites.ts"`.
|
|
20
20
|
* @complexity O(n) in archive entries under the given prefixes.
|
|
21
21
|
*/
|
|
22
|
-
export function filesUnderPrefixes({ headerFiles, prefixes }) {
|
|
22
|
+
export function filesUnderPrefixes({ headerFiles, prefixes }, _optional = {}) {
|
|
23
23
|
const paths = new Set();
|
|
24
24
|
function walk(node, current) {
|
|
25
25
|
safeEntry(current);
|
|
@@ -58,7 +58,7 @@ export function filesUnderPrefixes({ headerFiles, prefixes }) {
|
|
|
58
58
|
* @param sep the separator to convert to; defaults to this host's real `path.sep`.
|
|
59
59
|
* @complexity O(n) in path length.
|
|
60
60
|
*/
|
|
61
|
-
export function toArchiveEntryPath({ relPath, separator }) {
|
|
61
|
+
export function toArchiveEntryPath({ relPath, separator }, _optional = {}) {
|
|
62
62
|
safeEntry(relPath);
|
|
63
63
|
return relPath.split('/').join(separator);
|
|
64
64
|
}
|
|
@@ -117,12 +117,12 @@ export function verifyAsarAgainstSource(required, optional = {}) {
|
|
|
117
117
|
* @param checkedCount `verifyAsarAgainstSource`'s returned count.
|
|
118
118
|
* @complexity O(1).
|
|
119
119
|
*/
|
|
120
|
-
export function isEmptyVerification({ checkedCount }) { return checkedCount === 0; }
|
|
121
|
-
export function formatMismatchReport({ mismatches }) {
|
|
120
|
+
export function isEmptyVerification({ checkedCount }, _optional = {}) { return checkedCount === 0; }
|
|
121
|
+
export function formatMismatchReport({ mismatches }, _optional = {}) {
|
|
122
122
|
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');
|
|
123
123
|
}
|
|
124
124
|
/** Resources inventory is caller supplied; an empty inventory is a failure. */
|
|
125
|
-
export function bundledNpmFailures(required) {
|
|
125
|
+
export function bundledNpmFailures(required, _optional = {}) {
|
|
126
126
|
if (!required.resourcesDirs.length)
|
|
127
127
|
return ['no packaged resources directory was found to check for the bundled npm'];
|
|
128
128
|
if (!required.requiredFiles.length)
|
|
@@ -9,5 +9,5 @@ export declare function createAsarArchiveReader({ asar }: {
|
|
|
9
9
|
};
|
|
10
10
|
extractFile(archivePath: string, entryPath: string): Uint8Array;
|
|
11
11
|
};
|
|
12
|
-
}): ArchiveReaderPort;
|
|
12
|
+
}, _optional?: Record<string, never>): ArchiveReaderPort;
|
|
13
13
|
//# sourceMappingURL=asar-adapter.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Bind @electron/asar in the host rather than depending on the packaging SDK in core. */
|
|
2
|
-
export function createAsarArchiveReader({ asar }) {
|
|
2
|
+
export function createAsarArchiveReader({ asar }, _optional = {}) {
|
|
3
3
|
return { header: ({ archivePath }) => asar.getRawHeader(archivePath).header, read: ({ archivePath, entryPath }) => asar.extractFile(archivePath, entryPath) };
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=asar-adapter.js.map
|
|
@@ -9,4 +9,8 @@ export * from './asar-adapter.js';
|
|
|
9
9
|
export * from './optional-peers.js';
|
|
10
10
|
export * from './staged-closure.js';
|
|
11
11
|
export * from './staged-closure-node.js';
|
|
12
|
+
export * from './tree-fingerprint.js';
|
|
13
|
+
export * from './isolation.js';
|
|
14
|
+
export * from './payload-scan.js';
|
|
15
|
+
export { mergeMacManifests, type UpdateFileEntry, type UpdateManifest } from "./update-manifest-merge.js";
|
|
12
16
|
//# sourceMappingURL=entry.d.ts.map
|
|
@@ -9,4 +9,8 @@ export * from './asar-adapter.js';
|
|
|
9
9
|
export * from './optional-peers.js';
|
|
10
10
|
export * from './staged-closure.js';
|
|
11
11
|
export * from './staged-closure-node.js';
|
|
12
|
+
export * from './tree-fingerprint.js';
|
|
13
|
+
export * from './isolation.js';
|
|
14
|
+
export * from './payload-scan.js';
|
|
15
|
+
export { mergeMacManifests } from "./update-manifest-merge.js";
|
|
12
16
|
//# sourceMappingURL=entry.js.map
|
|
@@ -18,6 +18,6 @@ export interface DistImportInput {
|
|
|
18
18
|
*
|
|
19
19
|
* @complexity O(files + imports) reachable from `entry`; each file is read once.
|
|
20
20
|
*/
|
|
21
|
-
export declare function undeclaredDistImports(required: DistImportInput): string[];
|
|
22
|
-
export declare function assertDistImportsDeclared(required: DistImportInput): void;
|
|
21
|
+
export declare function undeclaredDistImports(required: DistImportInput, _optional?: Record<string, never>): string[];
|
|
22
|
+
export declare function assertDistImportsDeclared(required: DistImportInput, _optional?: Record<string, never>): void;
|
|
23
23
|
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -21,7 +21,7 @@ function undeclaredPackage(required) {
|
|
|
21
21
|
*
|
|
22
22
|
* @complexity O(files + imports) reachable from `entry`; each file is read once.
|
|
23
23
|
*/
|
|
24
|
-
export function undeclaredDistImports(required) {
|
|
24
|
+
export function undeclaredDistImports(required, _optional = {}) {
|
|
25
25
|
const { distDir, entry, declared, fs, imports, aliases } = required;
|
|
26
26
|
const queue = [path.resolve(entry)];
|
|
27
27
|
const seen = new Set(queue);
|
|
@@ -61,7 +61,7 @@ export function undeclaredDistImports(required) {
|
|
|
61
61
|
}
|
|
62
62
|
return problems;
|
|
63
63
|
}
|
|
64
|
-
export function assertDistImportsDeclared(required) {
|
|
64
|
+
export function assertDistImportsDeclared(required, _optional = {}) {
|
|
65
65
|
const problems = undeclaredDistImports(required);
|
|
66
66
|
if (problems.length)
|
|
67
67
|
throw new Error(`built entry imports ${problems.length} undeclared packages or missing files:\n ${problems.join('\n ')}`);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** A fixed, path-only diagnostic safe for a gate to print. */
|
|
2
|
+
export declare class PackagedTreeIsolationError extends Error {
|
|
3
|
+
}
|
|
4
|
+
/** Throws when `directory` or any real (symlink-resolved) ancestor has a node_modules. */
|
|
5
|
+
export declare function assertPackagedTreeIsolation({ directory }: {
|
|
6
|
+
directory: string;
|
|
7
|
+
}, _optional?: Record<string, never>): void;
|
|
8
|
+
export interface PackagedTreeTargets {
|
|
9
|
+
readonly executablePath: string;
|
|
10
|
+
readonly nodeModulesDir: string;
|
|
11
|
+
}
|
|
12
|
+
export interface IsolatedPackagedTreeRequired {
|
|
13
|
+
readonly targets: PackagedTreeTargets;
|
|
14
|
+
/** Gate body, run against the copied targets with the copy's parent directory as a safe cwd. */
|
|
15
|
+
readonly run: (input: {
|
|
16
|
+
targets: PackagedTreeTargets;
|
|
17
|
+
directory: string;
|
|
18
|
+
}, optional?: Record<string, never>) => void | Promise<void>;
|
|
19
|
+
/** Host path resolution for the copy command (`cp`); `null` when unavailable. Unused on win32. */
|
|
20
|
+
readonly resolveCommand: (required: {
|
|
21
|
+
bin: string;
|
|
22
|
+
}) => string | null;
|
|
23
|
+
}
|
|
24
|
+
export interface IsolatedPackagedTreeOptions {
|
|
25
|
+
readonly tempRoot?: string;
|
|
26
|
+
/** Selects the copier: `cpSync` on win32, `cp -R` elsewhere. */
|
|
27
|
+
readonly platform?: NodeJS.Platform;
|
|
28
|
+
readonly tempPrefix?: string;
|
|
29
|
+
}
|
|
30
|
+
/** 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.
|
|
31
|
+
* @example await withIsolatedPackagedTree({ targets, run, resolveCommand }, { tempPrefix: "acme-gate-" });
|
|
32
|
+
* @throws PackagedTreeIsolationError when the temp root has a node_modules ancestor; copy and run errors propagate.
|
|
33
|
+
* @complexity O(bundle size) for the copy.
|
|
34
|
+
*/
|
|
35
|
+
export declare function withIsolatedPackagedTree({ targets, run, resolveCommand }: IsolatedPackagedTreeRequired, { tempRoot, platform, tempPrefix }?: IsolatedPackagedTreeOptions): Promise<void>;
|
|
36
|
+
//# sourceMappingURL=isolation.d.ts.map
|