@patronage/factory-ci 1.0.0-alpha.45 → 1.0.0-alpha.47
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/README.md +4 -4
- package/dist/.build-fingerprint.json +1 -1
- package/dist/alchemy/index.d.ts +94 -112
- package/dist/alchemy/index.js +55 -46
- package/dist/{bundle-alchemy-entry-BuMrl5fR.js → bundle-alchemy-entry-Ba1Ebp91.js} +13 -10
- package/dist/{execute-alchemy-entry-CDMdbXIi.js → execute-alchemy-entry-CxQrjSg8.js} +5 -8
- package/dist/{execute-alchemy-entry-BR5dFO9k.d.ts → execute-alchemy-entry-D75saOiE.d.ts} +7 -9
- package/dist/index.d.ts +156 -207
- package/dist/index.js +43 -65
- package/package.json +12 -12
- package/src/alchemy/lifecycle.ts +88 -19
- package/src/bundle-alchemy-entry.ts +19 -8
- package/src/proof-reuse-gate.ts +0 -5
package/dist/alchemy/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-
|
|
1
|
+
import { i as isLocalPreviewStage, n as executeAlchemyEntry, r as resolveAlchemyChildCwd, s as ALCHEMY_BASELINE } from "../execute-alchemy-entry-CxQrjSg8.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { appendFileSync, closeSync, openSync, readFileSync } from "node:fs";
|
|
6
|
+
import { setTimeout } from "node:timers/promises";
|
|
6
7
|
import * as Alchemy from "alchemy";
|
|
7
8
|
import * as Output from "alchemy/Output";
|
|
8
9
|
import { tryFindProviderByType } from "alchemy/Provider";
|
|
@@ -12,7 +13,7 @@ import * as Option from "effect/Option";
|
|
|
12
13
|
import { State } from "alchemy/State";
|
|
13
14
|
import { allStages, deleteState } from "alchemy/State/Tree";
|
|
14
15
|
import { isDeepStrictEqual } from "node:util";
|
|
15
|
-
|
|
16
|
+
// src/alchemy/evaluate-stack.ts
|
|
16
17
|
var EvaluationProviders = class extends Alchemy.ProviderCollection()("factory-ci/evaluate-stack") {};
|
|
17
18
|
/** The lifecycle every provider evaluates with: read and list answer "absent"; a plan never applies. */
|
|
18
19
|
const absentProvider = (type) => ({
|
|
@@ -79,8 +80,7 @@ const evaluateStack = ({ name, program, providers, stage }) => {
|
|
|
79
80
|
})), Effect.map(toGraph), Effect.provide(Layer.mergeAll(Layer.succeed(Alchemy.Stack, stack), Layer.succeed(Alchemy.Stage, stage), Alchemy.inMemoryState(), evaluationProviders(providers))), Effect.scoped);
|
|
80
81
|
return Effect.runPromise(evaluation);
|
|
81
82
|
};
|
|
82
|
-
|
|
83
|
-
//#region src/alchemy/retained-identity.ts
|
|
83
|
+
// src/alchemy/retained-identity.ts
|
|
84
84
|
/** Every retained identity that did not hold. */
|
|
85
85
|
var RetainedIdentityError = class extends Error {
|
|
86
86
|
violations;
|
|
@@ -162,8 +162,7 @@ const assertRetainedIdentities = ({ after, before, markers }) => {
|
|
|
162
162
|
const violations = markers.map((marker) => violationFor(marker, after, before)).filter((violation) => violation !== void 0);
|
|
163
163
|
if (violations.length > 0) throw new RetainedIdentityError(violations);
|
|
164
164
|
};
|
|
165
|
-
|
|
166
|
-
//#region src/alchemy/credential-preflight.ts
|
|
165
|
+
// src/alchemy/credential-preflight.ts
|
|
167
166
|
/**
|
|
168
167
|
* Cloudflare credential preflight for an Alchemy deploy.
|
|
169
168
|
*
|
|
@@ -193,7 +192,7 @@ var CloudflareCredentialUnavailableError = class extends Error {
|
|
|
193
192
|
}
|
|
194
193
|
};
|
|
195
194
|
/** The exact source literals this preflight accepts. */
|
|
196
|
-
const CREDENTIAL_SOURCES = new Set(["hosted", "trusted-local"]);
|
|
195
|
+
const CREDENTIAL_SOURCES = /* @__PURE__ */ new Set(["hosted", "trusted-local"]);
|
|
197
196
|
const present = (environment, name) => Boolean(environment[name]?.trim());
|
|
198
197
|
const assertCredentialPosture = (source, accountId, environment) => {
|
|
199
198
|
if (!CREDENTIAL_SOURCES.has(source)) throw new Error("Credential preflight has an unknown credential source.");
|
|
@@ -324,8 +323,7 @@ const credentialPreflight = async ({ accountId, environment, fetchImplementation
|
|
|
324
323
|
tokenId: verification.id
|
|
325
324
|
};
|
|
326
325
|
};
|
|
327
|
-
|
|
328
|
-
//#region src/alchemy/stage-policy.ts
|
|
326
|
+
// src/alchemy/stage-policy.ts
|
|
329
327
|
/**
|
|
330
328
|
* Stage and stack pairing, and protected-stage policy, from a project-supplied
|
|
331
329
|
* table (#991).
|
|
@@ -450,8 +448,7 @@ const stagePolicy = (table) => {
|
|
|
450
448
|
isProtectedStage
|
|
451
449
|
};
|
|
452
450
|
};
|
|
453
|
-
|
|
454
|
-
//#region src/alchemy/local-emulation.ts
|
|
451
|
+
// src/alchemy/local-emulation.ts
|
|
455
452
|
/**
|
|
456
453
|
* The child environment a local-emulation Alchemy run needs (#1168).
|
|
457
454
|
*
|
|
@@ -518,8 +515,7 @@ const localEmulationEnvironment = (options) => {
|
|
|
518
515
|
[API_TOKEN_NAME]: SENTINEL_API_TOKEN
|
|
519
516
|
};
|
|
520
517
|
};
|
|
521
|
-
|
|
522
|
-
//#region src/alchemy/destroy-postcondition.ts
|
|
518
|
+
// src/alchemy/destroy-postcondition.ts
|
|
523
519
|
/**
|
|
524
520
|
* Read the state store through the project's reader.
|
|
525
521
|
*
|
|
@@ -556,8 +552,7 @@ const assertDestroyLeftNothing = async ({ stack, stage, stateReader }) => {
|
|
|
556
552
|
const remaining = [...listed].toSorted();
|
|
557
553
|
if (remaining.length > 0) throw new Error(`Alchemy destroy left ${remaining.length} resource registered for ${stack} in ${stage}: ${remaining.join(", ")}`);
|
|
558
554
|
};
|
|
559
|
-
|
|
560
|
-
//#region src/alchemy/plan-effects.ts
|
|
555
|
+
// src/alchemy/plan-effects.ts
|
|
561
556
|
/**
|
|
562
557
|
* The plan-output adapter (#1077): the one reader of what the installed
|
|
563
558
|
* Alchemy CLI prints for a plan.
|
|
@@ -619,13 +614,13 @@ var PlanEffectsError = class extends Error {
|
|
|
619
614
|
}
|
|
620
615
|
};
|
|
621
616
|
const ACTION_SET = new Set(PLAN_ACTIONS);
|
|
622
|
-
const BINDING_ACTIONS = new Set([
|
|
617
|
+
const BINDING_ACTIONS = /* @__PURE__ */ new Set([
|
|
623
618
|
"create",
|
|
624
619
|
"noop",
|
|
625
620
|
"unbind",
|
|
626
621
|
"update"
|
|
627
622
|
]);
|
|
628
|
-
const TASK_ACTIONS = new Set(["drop", "run"]);
|
|
623
|
+
const TASK_ACTIONS = /* @__PURE__ */ new Set(["drop", "run"]);
|
|
629
624
|
const ansiPattern = new RegExp(`${String.fromCodePoint(27)}\\[[0-?]*[ -/]*[@-~]`, "gu");
|
|
630
625
|
/**
|
|
631
626
|
* The prefix Effect's pretty console logger puts before every line the
|
|
@@ -920,8 +915,7 @@ const canonicalPlan = (output) => {
|
|
|
920
915
|
summary: lines.summary
|
|
921
916
|
});
|
|
922
917
|
};
|
|
923
|
-
|
|
924
|
-
//#region src/alchemy/first-deploy-authorization.ts
|
|
918
|
+
// src/alchemy/first-deploy-authorization.ts
|
|
925
919
|
/**
|
|
926
920
|
* First-deploy authorization by plan hash.
|
|
927
921
|
*
|
|
@@ -1017,8 +1011,7 @@ const firstDeployAuthorization = ({ authorizedHashes, planText, sourceSha, stack
|
|
|
1017
1011
|
if (!authorized.has(planHash)) throw new Error(`First deploy of ${stack} into ${stage} is not authorized. Reviewed plan hash: ${planHash}`);
|
|
1018
1012
|
return { planHash };
|
|
1019
1013
|
};
|
|
1020
|
-
|
|
1021
|
-
//#region src/alchemy/url-implies-auth.ts
|
|
1014
|
+
// src/alchemy/url-implies-auth.ts
|
|
1022
1015
|
/** The Alchemy resource type a Cloudflare Worker plans as, at beta.76. */
|
|
1023
1016
|
const WORKER_TYPE = "Cloudflare.Worker";
|
|
1024
1017
|
/** The Alchemy resource type a Cloudflare Access application plans as, at beta.76. */
|
|
@@ -1134,8 +1127,7 @@ const assertUrlImpliesAuth = (graph, { allowlist = [], authBindingName }) => {
|
|
|
1134
1127
|
}
|
|
1135
1128
|
if (violations.length > 0) throw new UrlImpliesAuthError(violations);
|
|
1136
1129
|
};
|
|
1137
|
-
|
|
1138
|
-
//#region src/alchemy/secret-name-policy.ts
|
|
1130
|
+
// src/alchemy/secret-name-policy.ts
|
|
1139
1131
|
/**
|
|
1140
1132
|
* A secret-name redaction policy for `executeAlchemyEntry`'s `redact` hook.
|
|
1141
1133
|
*
|
|
@@ -1192,8 +1184,7 @@ const secretNamePolicy = ({ names, values }) => {
|
|
|
1192
1184
|
return redacted;
|
|
1193
1185
|
};
|
|
1194
1186
|
};
|
|
1195
|
-
|
|
1196
|
-
//#region src/alchemy/lifecycle-failure.ts
|
|
1187
|
+
// src/alchemy/lifecycle-failure.ts
|
|
1197
1188
|
/**
|
|
1198
1189
|
* The one sentence each code is reported with. The table is the whole
|
|
1199
1190
|
* vocabulary: a message that is not in it cannot be raised.
|
|
@@ -1257,8 +1248,7 @@ var AlchemyLifecycleError = class extends Error {
|
|
|
1257
1248
|
}
|
|
1258
1249
|
};
|
|
1259
1250
|
const isAlchemyLifecycleError = (error) => error instanceof AlchemyLifecycleError;
|
|
1260
|
-
|
|
1261
|
-
//#region src/alchemy/state-tree.ts
|
|
1251
|
+
// src/alchemy/state-tree.ts
|
|
1262
1252
|
/**
|
|
1263
1253
|
* One read and delete surface over a state layer.
|
|
1264
1254
|
*
|
|
@@ -1361,8 +1351,7 @@ const deleteStageRows = async (state, target) => {
|
|
|
1361
1351
|
recursive: true
|
|
1362
1352
|
}));
|
|
1363
1353
|
};
|
|
1364
|
-
|
|
1365
|
-
//#region src/alchemy/child-diagnostics.ts
|
|
1354
|
+
// src/alchemy/child-diagnostics.ts
|
|
1366
1355
|
/**
|
|
1367
1356
|
* The optional record of what an Alchemy child printed (#1260).
|
|
1368
1357
|
*
|
|
@@ -1435,8 +1424,7 @@ const openChildDiagnostics = ({ child, diagnostics, operation, stack, stage }) =
|
|
|
1435
1424
|
failure: () => retained
|
|
1436
1425
|
};
|
|
1437
1426
|
};
|
|
1438
|
-
|
|
1439
|
-
//#region src/alchemy/lifecycle.ts
|
|
1427
|
+
// src/alchemy/lifecycle.ts
|
|
1440
1428
|
/**
|
|
1441
1429
|
* The shared Alchemy lifecycle operation (#1077).
|
|
1442
1430
|
*
|
|
@@ -1454,7 +1442,15 @@ const openChildDiagnostics = ({ child, diagnostics, operation, stack, stage }) =
|
|
|
1454
1442
|
* markers, the first-deploy authorization list, and the state store's own
|
|
1455
1443
|
* configuration. This module learns none of them.
|
|
1456
1444
|
*/
|
|
1457
|
-
const
|
|
1445
|
+
const MAX_CONVERGENCE_ATTEMPTS = 10;
|
|
1446
|
+
const MAX_CONVERGENCE_DELAY_MILLIS = 6e4;
|
|
1447
|
+
/**
|
|
1448
|
+
* A delay at or above an explicit lease TTL lapses the lease mid-wait, which
|
|
1449
|
+
* would surface late as `OWNERSHIP_LOST`; refuse it up front. This is a floor,
|
|
1450
|
+
* not a guarantee: the re-plan after the wait also runs before the renewal.
|
|
1451
|
+
*/
|
|
1452
|
+
const validConvergenceRetries = ({ convergenceRetries: retries, ownershipTtlMillis }) => retries === void 0 || Number.isInteger(retries.attempts) && retries.attempts >= 1 && retries.attempts <= MAX_CONVERGENCE_ATTEMPTS && Number.isInteger(retries.delayMillis) && retries.delayMillis >= 0 && retries.delayMillis <= MAX_CONVERGENCE_DELAY_MILLIS && (ownershipTtlMillis === void 0 || retries.delayMillis < ownershipTtlMillis);
|
|
1453
|
+
const OPERATIONS = /* @__PURE__ */ new Set([
|
|
1458
1454
|
"plan",
|
|
1459
1455
|
"deploy",
|
|
1460
1456
|
"destroy"
|
|
@@ -1498,7 +1494,7 @@ const persistedToSnapshot = (target, persisted) => ({ resources: persisted.resou
|
|
|
1498
1494
|
* and for a `deleting` one (a delete that was interrupted while the
|
|
1499
1495
|
* resource is still declared), and both finish at the same FQN.
|
|
1500
1496
|
*/
|
|
1501
|
-
const IN_FLIGHT_STATUSES = new Set(["creating", "deleting"]);
|
|
1497
|
+
const IN_FLIGHT_STATUSES = /* @__PURE__ */ new Set(["creating", "deleting"]);
|
|
1502
1498
|
const statusOf = (record) => isRecord(record.state) ? record.state.status : void 0;
|
|
1503
1499
|
/**
|
|
1504
1500
|
* Resolve plan rows onto persisted FQNs. A row's `id` is the FQN Alchemy
|
|
@@ -1579,7 +1575,7 @@ var LifecycleRun = class {
|
|
|
1579
1575
|
validateRequest() {
|
|
1580
1576
|
const { operation, stack, stage } = this.request;
|
|
1581
1577
|
if (!OPERATIONS.has(operation) || typeof stack !== "string" || typeof stage !== "string" || stack.trim() === "" || stage.trim() === "" || stack !== stack.trim() || stage !== stage.trim()) throw this.fail("INVALID_REQUEST", "request");
|
|
1582
|
-
if (typeof this.policy.holder !== "string" || this.policy.holder.trim() === "") throw this.fail("INVALID_POLICY", "request");
|
|
1578
|
+
if (typeof this.policy.holder !== "string" || this.policy.holder.trim() === "" || !validConvergenceRetries(this.policy)) throw this.fail("INVALID_POLICY", "request");
|
|
1583
1579
|
}
|
|
1584
1580
|
admitStage() {
|
|
1585
1581
|
let table;
|
|
@@ -1612,7 +1608,8 @@ var LifecycleRun = class {
|
|
|
1612
1608
|
installedAlchemyVersion() {
|
|
1613
1609
|
let version;
|
|
1614
1610
|
try {
|
|
1615
|
-
|
|
1611
|
+
const cli = createRequire(this.entry.from).resolve("alchemy/bin/alchemy.js");
|
|
1612
|
+
version = alchemyManifestVersion(cli);
|
|
1616
1613
|
} catch {
|
|
1617
1614
|
throw this.fail("PREPARATION_FAILED", "admission");
|
|
1618
1615
|
}
|
|
@@ -1625,7 +1622,7 @@ var LifecycleRun = class {
|
|
|
1625
1622
|
return;
|
|
1626
1623
|
}
|
|
1627
1624
|
try {
|
|
1628
|
-
const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-
|
|
1625
|
+
const { bundleAlchemyEntry } = await import("../bundle-alchemy-entry-Ba1Ebp91.js").then((n) => n.n);
|
|
1629
1626
|
this.bundledEntry = await bundleAlchemyEntry(this.entry.bundle);
|
|
1630
1627
|
} catch {
|
|
1631
1628
|
throw this.fail("PREPARATION_FAILED", "admission");
|
|
@@ -1962,7 +1959,8 @@ var LifecycleRun = class {
|
|
|
1962
1959
|
const namedByRow = new Set(planned.map(({ id }) => id));
|
|
1963
1960
|
const priorFqns = new Set(before.resources.map(({ fqn }) => fqn));
|
|
1964
1961
|
const inFlightBefore = new Set(before.resources.filter((record) => IN_FLIGHT_STATUSES.has(statusOf(record))).map(({ fqn }) => fqn));
|
|
1965
|
-
const
|
|
1962
|
+
const candidates = after.resources.filter((record) => !IN_FLIGHT_STATUSES.has(statusOf(record))).filter(({ fqn }) => !priorFqns.has(fqn) || inFlightBefore.has(fqn) && namedByRow.has(fqn)).map(({ fqn }) => fqn);
|
|
1963
|
+
const created = resolveRows(planned, candidates);
|
|
1966
1964
|
if (created === void 0) throw this.fail("DEPLOY_INCOMPLETE", "postcondition");
|
|
1967
1965
|
return created;
|
|
1968
1966
|
}
|
|
@@ -1987,12 +1985,25 @@ var LifecycleRun = class {
|
|
|
1987
1985
|
...this.stageArgs(),
|
|
1988
1986
|
"--yes"
|
|
1989
1987
|
], lease);
|
|
1990
|
-
const
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1988
|
+
const converge = async (retriesLeft) => {
|
|
1989
|
+
const post = await this.readOnlyPlan(this.planArgs(false), lease, accept, "postcondition");
|
|
1990
|
+
const after = post.before;
|
|
1991
|
+
if (after.resources.length === 0) throw this.fail("DEPLOY_INCOMPLETE", "postcondition");
|
|
1992
|
+
const createdNow = this.createdFqns(plan.before, after, plan.effects);
|
|
1993
|
+
if (isProtected && !admittedFirstDeploy) this.assertRetained(persistedToSnapshot(this.target, after), persistedToSnapshot(this.target, plan.before), "postcondition");
|
|
1994
|
+
try {
|
|
1995
|
+
this.assertConverged(post.effects, after);
|
|
1996
|
+
} catch (error) {
|
|
1997
|
+
if (retriesLeft === 0 || !(error instanceof AlchemyLifecycleError) || error.code !== "NOT_CONVERGED") throw error;
|
|
1998
|
+
await setTimeout(this.policy.convergenceRetries?.delayMillis ?? 0);
|
|
1999
|
+
return await converge(retriesLeft - 1);
|
|
2000
|
+
}
|
|
2001
|
+
return {
|
|
2002
|
+
createdNow,
|
|
2003
|
+
post
|
|
2004
|
+
};
|
|
2005
|
+
};
|
|
2006
|
+
const { createdNow, post } = await converge(this.policy.convergenceRetries?.attempts ?? 0);
|
|
1996
2007
|
return {
|
|
1997
2008
|
convergence: post.effects,
|
|
1998
2009
|
created: createdNow,
|
|
@@ -2098,8 +2109,7 @@ const runAlchemyLifecycle = async (options) => {
|
|
|
2098
2109
|
run.assertDiagnosticsWritten();
|
|
2099
2110
|
return result;
|
|
2100
2111
|
};
|
|
2101
|
-
|
|
2102
|
-
//#region src/alchemy/index.ts
|
|
2112
|
+
// src/alchemy/index.ts
|
|
2103
2113
|
/**
|
|
2104
2114
|
* The `@patronage/factory-ci/alchemy` subpath: the only place in this package
|
|
2105
2115
|
* where `alchemy` or `effect` may be imported (ADR 0031).
|
|
@@ -2118,5 +2128,4 @@ const runAlchemyLifecycle = async (options) => {
|
|
|
2118
2128
|
*/
|
|
2119
2129
|
/** The specifier a consumer imports this surface by. */
|
|
2120
2130
|
const ALCHEMY_SUBPATH = "@patronage/factory-ci/alchemy";
|
|
2121
|
-
//#endregion
|
|
2122
2131
|
export { ALCHEMY_SUBPATH, AlchemyLifecycleError, CloudflareCredentialUnavailableError, HOSTED_CLOUDFLARE_CREDENTIAL_NAMES, LIFECYCLE_FAILURE_MESSAGES, LOCAL_PREVIEW_STAGES, MINIMUM_REDACTABLE_SECRET_LENGTH, PLAN_ACTIONS, PLAN_OUTPUT_ALCHEMY_VERSION, PlanEffectsError, RetainedIdentityError, SECRET_REDACTION_PLACEHOLDER, StagePolicyError, UrlImpliesAuthError, anyStage, assertDestroyLeftNothing, assertRetainedIdentities, assertUrlImpliesAuth, credentialPreflight, deleteStageRows, evaluateStack, firstDeployAuthorization, firstDeployPlanHash, inventoryStages, isAlchemyLifecycleError, isLocalEmulationStage, localEmulationEnvironment, parsePlanEffects, parseStateSnapshot, readStageSnapshot, runAlchemyLifecycle, secretNamePolicy, stagePolicy };
|
|
@@ -2,7 +2,7 @@ import "node:module";
|
|
|
2
2
|
import { mkdir } from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { build } from "esbuild";
|
|
5
|
-
|
|
5
|
+
// \0rolldown/runtime.js
|
|
6
6
|
var __defProp = Object.defineProperty;
|
|
7
7
|
var __exportAll = (all, no_symbols) => {
|
|
8
8
|
let target = {};
|
|
@@ -13,17 +13,21 @@ var __exportAll = (all, no_symbols) => {
|
|
|
13
13
|
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
14
14
|
return target;
|
|
15
15
|
};
|
|
16
|
-
|
|
17
|
-
//#region src/bundle-alchemy-entry.ts
|
|
16
|
+
// src/bundle-alchemy-entry.ts
|
|
18
17
|
var bundle_alchemy_entry_exports = /* @__PURE__ */ __exportAll({ bundleAlchemyEntry: () => bundleAlchemyEntry });
|
|
19
18
|
/**
|
|
20
|
-
* Alchemy and Effect must resolve from
|
|
21
|
-
* time, never from the bundle: Alchemy's
|
|
22
|
-
* service tags are identity-sensitive, and a
|
|
19
|
+
* Alchemy, its `@alchemy.run/*` provider packages and Effect must resolve from
|
|
20
|
+
* the *consumer's* node_modules at run time, never from the bundle: Alchemy's
|
|
21
|
+
* resource registry and Effect's service tags are identity-sensitive, and a
|
|
22
|
+
* second copy silently breaks both. Since 2.0.0-beta.84 the providers
|
|
23
|
+
* (`@alchemy.run/cloudflare` and the rest) ship outside core, and they import
|
|
24
|
+
* runtime-only specifiers such as `cloudflare:workers` that no Node bundle can
|
|
25
|
+
* resolve.
|
|
23
26
|
*/
|
|
24
27
|
const ALCHEMY_EXTERNALS = [
|
|
25
28
|
"alchemy",
|
|
26
29
|
"alchemy/*",
|
|
30
|
+
"@alchemy.run/*",
|
|
27
31
|
"effect",
|
|
28
32
|
"effect/*"
|
|
29
33
|
];
|
|
@@ -72,11 +76,11 @@ const assertNoReservedInputs = (inputs) => {
|
|
|
72
76
|
if (offenders.length > 0) throw new Error(`bundleAlchemyEntry refused a bundle carrying a second copy of an identity-sensitive package: ${offenders.join(", ")}. Those packages must resolve from the consumer's runtime, so nothing may pull their files into the bundle — an alias that re-exports them by bare specifier stays external and is fine.`);
|
|
73
77
|
};
|
|
74
78
|
/**
|
|
75
|
-
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy
|
|
76
|
-
* `effect` external (#268).
|
|
79
|
+
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy`, its
|
|
80
|
+
* `@alchemy.run/*` providers and `effect` external (#268).
|
|
77
81
|
*
|
|
78
82
|
* The Alchemy CLI runs a JavaScript entry, so a TypeScript `alchemy.run.ts`
|
|
79
|
-
* has to be flattened first, and the flattening must not swallow the
|
|
83
|
+
* has to be flattened first, and the flattening must not swallow the
|
|
80
84
|
* packages whose identity matters.
|
|
81
85
|
*
|
|
82
86
|
* Returns the absolute path of the file written.
|
|
@@ -105,5 +109,4 @@ const bundleAlchemyEntry = async (options) => {
|
|
|
105
109
|
assertNoReservedInputs(Object.keys(result.metafile.inputs));
|
|
106
110
|
return outfile;
|
|
107
111
|
};
|
|
108
|
-
//#endregion
|
|
109
112
|
export { bundle_alchemy_entry_exports as n, bundleAlchemyEntry as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
|
-
|
|
4
|
+
// src/alchemy-baseline.ts
|
|
5
5
|
/**
|
|
6
6
|
* The Alchemy fleet baseline (#985, #993). Every factory project that
|
|
7
7
|
* imports `@patronage/factory-ci/alchemy` pins `alchemy` and `effect` to
|
|
@@ -50,8 +50,7 @@ const assertAlchemyBaseline = ({ packageJson }) => {
|
|
|
50
50
|
}
|
|
51
51
|
if (drifted.length > 0) throw new Error(`Alchemy fleet baseline drift: ${drifted.join(", ")}. Bump to match ALCHEMY_BASELINE in @patronage/factory-ci, or wait for the next lockstep release.`);
|
|
52
52
|
};
|
|
53
|
-
|
|
54
|
-
//#region src/disposable-stage.ts
|
|
53
|
+
// src/disposable-stage.ts
|
|
55
54
|
/**
|
|
56
55
|
* The disposable Alchemy stage a local preview deploy runs in:
|
|
57
56
|
* `local-pr-<pr>-<short sha>` (#268).
|
|
@@ -99,10 +98,9 @@ const localPreviewStage = (options) => {
|
|
|
99
98
|
if (!/^[0-9a-f]{40}$/u.test(normalizedHead)) throw new Error(`headSha must be exactly 40 hexadecimal characters, got "${headSha}".`);
|
|
100
99
|
return `local-pr-${pr}-${normalizedHead.slice(0, shaLength)}`;
|
|
101
100
|
};
|
|
102
|
-
|
|
103
|
-
//#region src/execute-alchemy-entry.ts
|
|
101
|
+
// src/execute-alchemy-entry.ts
|
|
104
102
|
/** Node's spawnSync default is 1 MiB; Alchemy plans routinely exceed that. */
|
|
105
|
-
const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER =
|
|
103
|
+
const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER = 67108864;
|
|
106
104
|
let spawnImplementation = spawnSync;
|
|
107
105
|
/**
|
|
108
106
|
* The child's working directory: the caller's `cwd`, then the bundle root,
|
|
@@ -113,7 +111,7 @@ let spawnImplementation = spawnSync;
|
|
|
113
111
|
const resolveAlchemyChildCwd = (options) => options.cwd ?? options.bundle?.absWorkingDir ?? process.cwd();
|
|
114
112
|
const resolveBundledEntry = async (options) => {
|
|
115
113
|
if (options.bundledEntry === void 0) {
|
|
116
|
-
const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-
|
|
114
|
+
const { bundleAlchemyEntry } = await import("./bundle-alchemy-entry-Ba1Ebp91.js").then((n) => n.n);
|
|
117
115
|
return await bundleAlchemyEntry(options.bundle);
|
|
118
116
|
}
|
|
119
117
|
return path.resolve(options.cwd ?? process.cwd(), options.bundledEntry);
|
|
@@ -162,5 +160,4 @@ const executeAlchemyEntry = async (options) => {
|
|
|
162
160
|
stdout: captured(result.stdout, options.redact)
|
|
163
161
|
};
|
|
164
162
|
};
|
|
165
|
-
//#endregion
|
|
166
163
|
export { localPreviewStage as a, assertAlchemyBaseline as c, isLocalPreviewStage as i, executeAlchemyEntry as n, parseLocalPreviewStage as o, resolveAlchemyChildCwd as r, ALCHEMY_BASELINE as s, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER as t };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/bundle-alchemy-entry.d.ts
|
|
2
1
|
interface BundleAlchemyEntryOptions {
|
|
3
2
|
/** The Alchemy entry to bundle, e.g. `alchemy.run.ts`. */
|
|
4
3
|
readonly entry: string;
|
|
@@ -13,7 +12,8 @@ interface BundleAlchemyEntryOptions {
|
|
|
13
12
|
* `packages: "external"`. Values are resolved the way esbuild resolves any
|
|
14
13
|
* import, so give absolute paths or package names — which aliases a repo
|
|
15
14
|
* needs is the consumer's policy and this package bakes in none. A key on
|
|
16
|
-
* `alchemy`, `effect`, or a subpath of
|
|
15
|
+
* `alchemy`, an `@alchemy.run/*` provider, `effect`, or a subpath of any of
|
|
16
|
+
* them is rejected outright, and the
|
|
17
17
|
* finished bundle is checked for files from those packages however they were
|
|
18
18
|
* reached.
|
|
19
19
|
*/
|
|
@@ -34,18 +34,16 @@ interface BundleAlchemyEntryOptions {
|
|
|
34
34
|
readonly tsconfig?: string;
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
|
-
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy
|
|
38
|
-
* `effect` external (#268).
|
|
37
|
+
* Pre-bundle an Alchemy entry to a single ESM file, keeping `alchemy`, its
|
|
38
|
+
* `@alchemy.run/*` providers and `effect` external (#268).
|
|
39
39
|
*
|
|
40
40
|
* The Alchemy CLI runs a JavaScript entry, so a TypeScript `alchemy.run.ts`
|
|
41
|
-
* has to be flattened first, and the flattening must not swallow the
|
|
41
|
+
* has to be flattened first, and the flattening must not swallow the
|
|
42
42
|
* packages whose identity matters.
|
|
43
43
|
*
|
|
44
44
|
* Returns the absolute path of the file written.
|
|
45
45
|
*/
|
|
46
46
|
declare const bundleAlchemyEntry: (options: BundleAlchemyEntryOptions) => Promise<string>;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/execute-alchemy-entry.d.ts
|
|
49
47
|
/** Node's spawnSync default is 1 MiB; Alchemy plans routinely exceed that. */
|
|
50
48
|
declare const EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER: number;
|
|
51
49
|
interface ExecuteAlchemyEntryCommon {
|
|
@@ -98,7 +96,8 @@ interface ExecuteAlchemyEntryCommon {
|
|
|
98
96
|
* together, and refuses neither, so no runtime check is needed.
|
|
99
97
|
*/
|
|
100
98
|
type ExecuteAlchemyEntryOptions = ExecuteAlchemyEntryCommon & ({
|
|
101
|
-
/** Bundle the consumer entry before execution. */
|
|
99
|
+
/** Bundle the consumer entry before execution. */
|
|
100
|
+
readonly bundle: BundleAlchemyEntryOptions;
|
|
102
101
|
readonly bundledEntry?: never;
|
|
103
102
|
} | {
|
|
104
103
|
readonly bundle?: never;
|
|
@@ -127,5 +126,4 @@ interface ExecuteAlchemyEntryResult {
|
|
|
127
126
|
* convergence or destructive-change policy remain the caller's responsibility.
|
|
128
127
|
*/
|
|
129
128
|
declare const executeAlchemyEntry: (options: ExecuteAlchemyEntryOptions) => Promise<ExecuteAlchemyEntryResult>;
|
|
130
|
-
//#endregion
|
|
131
129
|
export { BundleAlchemyEntryOptions as a, executeAlchemyEntry as i, ExecuteAlchemyEntryOptions as n, bundleAlchemyEntry as o, ExecuteAlchemyEntryResult as r, EXECUTE_ALCHEMY_ENTRY_MAX_BUFFER as t };
|