@icebreakers/monorepo 6.0.1 → 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{baseline-B6uEfHrm.mjs → baseline-Dpdng8Pw.mjs} +1 -1
- package/dist/{catalog-YipXrou_.mjs → catalog-A1_tGyBz.mjs} +3 -3
- package/dist/cli.mjs +186 -115
- package/dist/{commands-D1KtdxnV.mjs → commands-C8PiGh9h.mjs} +1507 -149
- package/dist/{config--wYfkdsO.mjs → config-CtnhpveO.mjs} +3 -3
- package/dist/{create-flow-D3ZzvBw6.mjs → create-flow-CqtNwZs7.mjs} +3 -3
- package/dist/{deps-qu9CwEKc.mjs → deps-CFZftEq2.mjs} +3 -3
- package/dist/docs-context-entry.d.mts +25 -0
- package/dist/docs-context-entry.mjs +88 -0
- package/dist/{execute-DP6M6JqN.mjs → execute-Brlvq-TY.mjs} +2 -2
- package/dist/{execute-BVtr43XS.mjs → execute-DE3pJ4nx.mjs} +2 -2
- package/dist/{format-VPlFgfoH.mjs → format-BXQ2yRvk.mjs} +1 -1
- package/dist/{index-DewDhzGv.d.mts → index-BJaI8Sig.d.mts} +170 -2
- package/dist/index.d.mts +45 -116
- package/dist/index.mjs +10 -10
- package/dist/{inputs-B_-kWnm2.mjs → inputs-DRWom7Va.mjs} +1 -1
- package/dist/{npm-S2sT1UgC.mjs → npm-CrQi6Gci.mjs} +1 -1
- package/dist/{plan-DuHMR5Za.mjs → plan-DT1Gz8tE.mjs} +1 -1
- package/dist/{run-BGHVj0Lj.mjs → run-BBf92Scj.mjs} +4 -4
- package/dist/{save-UiJgdSaY.mjs → save-CCCUswjG.mjs} +3 -3
- package/dist/{scan-Bg1EPIk6.mjs → scan-KcMaJTx2.mjs} +5 -4
- package/dist/{template-drift-BOk4oxoR.mjs → template-drift-BKCMx9vC.mjs} +3 -3
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/tooling-entry.mjs +2 -2
- package/dist/{transaction-Cg5I2q47.mjs → transaction-CTFrGYJO.mjs} +2 -2
- package/dist/{tsconfig-rZG7b9Ul.mjs → tsconfig-CO_6DRDo.mjs} +127 -42
- package/dist/{vitest-BbbU7-qn.mjs → vitest-Deitv0TQ.mjs} +1 -1
- package/dist/{workspace-tasks--x70rhb8.mjs → workspace-tasks-CbetXdoh.mjs} +6 -6
- package/package.json +8 -3
- package/resources/maintenance/validate.mjs +14 -0
- package/resources/skills/repoctl/references/commands.md +36 -0
- package/resources/skills/repoctl/references/config.md +10 -1
- package/resources/skills/repoctl/references/dependencies.md +2 -0
- package/resources/skills/repoctl/references/templates.md +6 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
|
-
import { A as referenceTarget, B as saveKnipBaseline, C as loadCompiler, D as ownershipFile, E as exists$1, Gt as getWorkspacePackages, Ht as clearWorkspaceCache, I as getKnipConfigurationSuggestions, J as getWorkspaceGraph, Jt as GitClient, K as mergeText, M as formatEnvironmentCache, O as readText, P as checkEnvironmentCache, R as planKnipCheck, S as configReader, St as localize, T as compare$1, Tt as resolveRepoctlLocale, Ut as getWorkspaceData, W as analyzeTurboRuns, Wt as getWorkspacePackageSummaries, Z as getWorkspaceImpact, _ as planTemplateLink, _t as assetsDir$1, at as record$2, b as planGenerate, c as loadTemplateInstanceRegistry$1, ct as renderCreateNewProject, dt as migrateLegacyToolingReferences, et as compareGraphValues, f as recoverTemplateUpgrade, ft as setByPath, g as applyTemplateLinkPlan, gt as validateCleanTargets, h as loadTemplateUpgradeJournal, ht as isWithin, it as readInput, j as relativeFile, jt as fs$2, k as referencePath, l as rebuildTemplateInstanceBaseline, lt as rewriteTemplateSnapshotReferences, m as planTemplateUpgrade, mt as assertSafePath, nt as workspaceDependencyTypes, o as listTemplateInstances, ot as safeFile, p as applyTemplateUpgradePlan, pt as stageFileTransaction, q as withOperationLock, qt as findWorkspacePackages, rt as hash$1, s as loadTemplateBaseline$1, tt as resolveWorkspaceGraphNode, u as relocateTemplateInstance, w as validateGraph, x as generators, xt as templatesDir, y as applyGeneratePlan, yt as packageDir$1, z as runKnipCheck } from "./workspace-tasks
|
|
3
|
-
import { a as resolveFullWorkspaceCheckPlan, c as verifyCommitMsg, d as logger, i as getKnownRepoCheckCommands, l as verifyPreCommit, n as resolveAffectedCheckContext, o as resolveRecommendedCheckPlan, r as resolveAffectedCheckPlan, s as runRecommendedCheck, t as runCheckWithReport, u as runPnpmCommand } from "./execute-
|
|
4
|
-
import { A as package_default$1, B as templateSourcePath, C as checkedFile, D as relativeFile$1, E as readOptionalSource, H as
|
|
5
|
-
import { c as selectCommandOverrides, i as rangesOverlap, l as chinaMirrorsEnvs, r as parseSpecifier, s as resolveCommandValues } from "./scan-
|
|
6
|
-
import { A as isRootAsset, B as toWorkspaceAssetPath, C as lockfileRecord, D as baselineDirectory, E as checkDependencyAdmission, F as getWorkspacePatterns, I as summarizeChecks, L as legacyStagedConfigNames, M as templatePackage, N as getAssetTargets, O as baselinePath, P as record$3, S as inspectPnpmRuntime, a as applyDoctorSuppressions, b as resolveReleaseBranches, c as collectSelectedDoctorChecks, d as recommendedRepoScripts, f as inspectInstallSecurity, g as isLegacyReleaseWorkflow, h as supportedVersion, i as hasTemplateDriftIssues, j as parseBaseline, k as encodeBaseline, l as getDoctorRuleIds, m as settingState, o as validateDoctorSuppressions, p as readSecuritySources, r as formatTemplateDriftReport, s as validateDoctorConfiguration, t as checkTemplateDrift, u as selectDoctorRules, v as renderReleaseWorkflow, w as parseWorkspaceLockfile, x as ReleaseCommandError, y as releasePullRequestHead } from "./template-drift-
|
|
7
|
-
import { t as writeDependencyTransaction } from "./transaction-
|
|
8
|
-
import { i as applyDependencyFixPlan, r as planDependencyFix, t as checkDependencies } from "./deps-
|
|
9
|
-
import { i as applyCatalogMigrationPlan, n as checkCatalogs, r as planCatalogMigration } from "./catalog-
|
|
2
|
+
import { A as referenceTarget, B as saveKnipBaseline, C as loadCompiler, D as ownershipFile, E as exists$1, Gt as getWorkspacePackages, Ht as clearWorkspaceCache, I as getKnipConfigurationSuggestions, J as getWorkspaceGraph, Jt as GitClient, K as mergeText, M as formatEnvironmentCache, O as readText, P as checkEnvironmentCache, R as planKnipCheck, S as configReader, St as localize, T as compare$1, Tt as resolveRepoctlLocale, Ut as getWorkspaceData, W as analyzeTurboRuns, Wt as getWorkspacePackageSummaries, Z as getWorkspaceImpact, _ as planTemplateLink, _t as assetsDir$1, at as record$2, b as planGenerate, c as loadTemplateInstanceRegistry$1, ct as renderCreateNewProject, dt as migrateLegacyToolingReferences, et as compareGraphValues, f as recoverTemplateUpgrade, ft as setByPath, g as applyTemplateLinkPlan, gt as validateCleanTargets, h as loadTemplateUpgradeJournal, ht as isWithin, it as readInput, j as relativeFile, jt as fs$2, k as referencePath, l as rebuildTemplateInstanceBaseline, lt as rewriteTemplateSnapshotReferences, m as planTemplateUpgrade, mt as assertSafePath, nt as workspaceDependencyTypes, o as listTemplateInstances, ot as safeFile, p as applyTemplateUpgradePlan, pt as stageFileTransaction, q as withOperationLock, qt as findWorkspacePackages, rt as hash$1, s as loadTemplateBaseline$1, tt as resolveWorkspaceGraphNode, u as relocateTemplateInstance, w as validateGraph, x as generators, xt as templatesDir, y as applyGeneratePlan, yt as packageDir$1, z as runKnipCheck } from "./workspace-tasks-CbetXdoh.mjs";
|
|
3
|
+
import { a as resolveFullWorkspaceCheckPlan, c as verifyCommitMsg, d as logger, i as getKnownRepoCheckCommands, l as verifyPreCommit, n as resolveAffectedCheckContext, o as resolveRecommendedCheckPlan, r as resolveAffectedCheckPlan, s as runRecommendedCheck, t as runCheckWithReport, u as runPnpmCommand } from "./execute-DE3pJ4nx.mjs";
|
|
4
|
+
import { A as package_default$1, B as templateSourcePath, C as checkedFile, D as relativeFile$1, E as readOptionalSource, G as presetVersion, H as isUpgradeExpiry, I as normalizeTemplateRemoteSource, J as isRecord$2, K as withLegacyHookConfig, L as normalizeTemplateSourceRequest, N as ConfigValidationError, O as engines$1, Q as commandConfigDirectory, S as canonicalDirectory, T as readOptional$1, U as resolveNightlyConfig, W as presetPackageName, X as appendConfigPath, _ as listToolingCapabilities, b as presetRelativePath, d as loadMonorepoConfig, f as loadMonorepoConfigDetails, g as presetAssetTarget, j as version$2, n as defineTsconfigConfig, p as resolveCommandConfig, u as getRepoctlConfigCandidates, v as installedPresetDirectory, w as hash$2, x as readPresetFile, y as parsePresetJson, z as sourceRequestKey } from "./tsconfig-CO_6DRDo.mjs";
|
|
5
|
+
import { c as selectCommandOverrides, i as rangesOverlap, l as chinaMirrorsEnvs, o as matchGroup, r as parseSpecifier, s as resolveCommandValues, t as scanDependencies } from "./scan-KcMaJTx2.mjs";
|
|
6
|
+
import { A as isRootAsset, B as toWorkspaceAssetPath, C as lockfileRecord, D as baselineDirectory, E as checkDependencyAdmission, F as getWorkspacePatterns, I as summarizeChecks, L as legacyStagedConfigNames, M as templatePackage, N as getAssetTargets, O as baselinePath, P as record$3, S as inspectPnpmRuntime, a as applyDoctorSuppressions, b as resolveReleaseBranches, c as collectSelectedDoctorChecks, d as recommendedRepoScripts, f as inspectInstallSecurity, g as isLegacyReleaseWorkflow, h as supportedVersion, i as hasTemplateDriftIssues, j as parseBaseline, k as encodeBaseline, l as getDoctorRuleIds, m as settingState, o as validateDoctorSuppressions, p as readSecuritySources, r as formatTemplateDriftReport, s as validateDoctorConfiguration, t as checkTemplateDrift, u as selectDoctorRules, v as renderReleaseWorkflow, w as parseWorkspaceLockfile, x as ReleaseCommandError, y as releasePullRequestHead } from "./template-drift-BKCMx9vC.mjs";
|
|
7
|
+
import { t as writeDependencyTransaction } from "./transaction-CTFrGYJO.mjs";
|
|
8
|
+
import { i as applyDependencyFixPlan, r as planDependencyFix, t as checkDependencies } from "./deps-CFZftEq2.mjs";
|
|
9
|
+
import { i as applyCatalogMigrationPlan, n as checkCatalogs, r as planCatalogMigration } from "./catalog-A1_tGyBz.mjs";
|
|
10
10
|
import { createRequire, isBuiltin } from "node:module";
|
|
11
11
|
import { findWorkspaceDir } from "@pnpm/find-workspace-dir";
|
|
12
12
|
import { readWorkspaceManifest } from "@pnpm/workspace.read-manifest";
|
|
@@ -15,7 +15,7 @@ import process from "node:process";
|
|
|
15
15
|
import { access, appendFile, copyFile, link, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, rmdir, stat, symlink, unlink, utimes, writeFile } from "node:fs/promises";
|
|
16
16
|
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
17
17
|
import fs$1, { constants, createReadStream, existsSync } from "node:fs";
|
|
18
|
-
import semver, { coerce, compare, gt, gte, lte, minVersion, parse, satisfies, subset, valid, validRange } from "semver";
|
|
18
|
+
import semver, { coerce, compare, gt, gte, intersects, lte, maxSatisfying, minVersion, parse, satisfies, subset, valid, validRange } from "semver";
|
|
19
19
|
import validatePackageName from "validate-npm-package-name";
|
|
20
20
|
import { createHash, randomUUID } from "node:crypto";
|
|
21
21
|
import path$1, { delimiter, matchesGlob } from "node:path";
|
|
@@ -37,8 +37,8 @@ import Config from "@npmcli/config";
|
|
|
37
37
|
import definitionsModule from "@npmcli/config/lib/definitions/index.js";
|
|
38
38
|
import micromatch from "micromatch";
|
|
39
39
|
import { gzipSync } from "node:zlib";
|
|
40
|
-
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
41
40
|
import { createPackageFromTarballData } from "@arethetypeswrong/core";
|
|
41
|
+
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
42
42
|
import { build } from "esbuild";
|
|
43
43
|
//#region src/commands/ai.ts
|
|
44
44
|
const agenticSections = [
|
|
@@ -729,7 +729,7 @@ function inferWorkspacePattern(targetName) {
|
|
|
729
729
|
if (parts.length >= 2) return `${parts[0]}/*`;
|
|
730
730
|
return "packages/*";
|
|
731
731
|
}
|
|
732
|
-
async function planWorkspaceManifest(workspaceDir, targetName) {
|
|
732
|
+
async function planWorkspaceManifest$1(workspaceDir, targetName) {
|
|
733
733
|
const workspacePath = path.resolve(workspaceDir, "pnpm-workspace.yaml");
|
|
734
734
|
const before = await fs$2.pathExists(workspacePath) ? await fs$2.readFile(workspacePath) : null;
|
|
735
735
|
const manifest = before ? YAML.parse(before.toString("utf8")) ?? {} : {};
|
|
@@ -749,7 +749,7 @@ async function planWorkspaceManifest(workspaceDir, targetName) {
|
|
|
749
749
|
};
|
|
750
750
|
}
|
|
751
751
|
async function updateWorkspaceManifest(workspaceDir, targetName) {
|
|
752
|
-
const plan = await planWorkspaceManifest(workspaceDir, targetName);
|
|
752
|
+
const plan = await planWorkspaceManifest$1(workspaceDir, targetName);
|
|
753
753
|
if (plan.after && !plan.after.equals(plan.before ?? Buffer.alloc(0))) await fs$2.outputFile(path.resolve(workspaceDir, "pnpm-workspace.yaml"), plan.after);
|
|
754
754
|
}
|
|
755
755
|
//#endregion
|
|
@@ -895,7 +895,7 @@ async function applyParameterizedProject(plan, gitMetadata) {
|
|
|
895
895
|
};
|
|
896
896
|
await verifySource();
|
|
897
897
|
const staged = await stageParameterizedProject(plan, prepared, target, gitMetadata);
|
|
898
|
-
const workspace = await planWorkspaceManifest(root, plan.targetName);
|
|
898
|
+
const workspace = await planWorkspaceManifest$1(root, plan.targetName);
|
|
899
899
|
const updates = staged.snapshot.files.map((file) => ({
|
|
900
900
|
path: `${target}/${file.path}`,
|
|
901
901
|
beforeHash: null,
|
|
@@ -1541,7 +1541,7 @@ async function downloadGitTemplate(source, directory, timeout) {
|
|
|
1541
1541
|
async function resolveRemoteTemplateSource(source, templatePath = ".", options = {}) {
|
|
1542
1542
|
const request = normalizeTemplateSourceRequest(source, templatePath);
|
|
1543
1543
|
const cwd = path$1.resolve(options.cwd ?? process.cwd());
|
|
1544
|
-
const npm = request.source.kind === "npm" ? await import("./npm-
|
|
1544
|
+
const npm = request.source.kind === "npm" ? await import("./npm-CrQi6Gci.mjs") : void 0;
|
|
1545
1545
|
const configuration = request.source.kind === "npm" ? await npm.npmTemplateConfiguration(request.source, cwd) : void 0;
|
|
1546
1546
|
if (request.source.kind === "npm") request.source.registry = configuration.registry;
|
|
1547
1547
|
const cacheDir = path$1.resolve(cwd, options.cacheDir ?? path$1.join(process.env["XDG_CACHE_HOME"] ?? path$1.join(homedir(), ".cache"), "repoctl", "template-sources-v1"));
|
|
@@ -2295,11 +2295,53 @@ function validateMigrationPlan(plan) {
|
|
|
2295
2295
|
}
|
|
2296
2296
|
}
|
|
2297
2297
|
//#endregion
|
|
2298
|
+
//#region src/commands/upgrade/workspace/decisions.ts
|
|
2299
|
+
/** Override values are strings. Include presence so absence and YAML null differ. */
|
|
2300
|
+
function overrideFingerprint(values, selector) {
|
|
2301
|
+
return hash$2(Buffer.from(JSON.stringify(Object.hasOwn(values, selector) ? {
|
|
2302
|
+
present: true,
|
|
2303
|
+
value: values[selector]
|
|
2304
|
+
} : { present: false })));
|
|
2305
|
+
}
|
|
2306
|
+
function keepDecisions(decisions) {
|
|
2307
|
+
const result = /* @__PURE__ */ new Map();
|
|
2308
|
+
for (const decision of decisions) {
|
|
2309
|
+
const selector = decision.path[1];
|
|
2310
|
+
if (result.has(selector)) throw new Error(`Duplicate upgrade keep decision: overrides[${JSON.stringify(selector)}].`);
|
|
2311
|
+
result.set(selector, decision);
|
|
2312
|
+
}
|
|
2313
|
+
return result;
|
|
2314
|
+
}
|
|
2315
|
+
function applyKeepDecision(finding, decision, today) {
|
|
2316
|
+
if (decision.expires && decision.expires < today) {
|
|
2317
|
+
finding.status = "expired-decision";
|
|
2318
|
+
finding.detail = `Keep decision expired on ${decision.expires}; review again. ${decision.reason}`;
|
|
2319
|
+
} else if (decision.upstreamHash !== finding.upstreamHash || decision.localHash !== finding.localHash) {
|
|
2320
|
+
finding.status = "stale-decision";
|
|
2321
|
+
finding.detail = `The upstream or local override changed; review again. ${decision.reason}`;
|
|
2322
|
+
} else {
|
|
2323
|
+
finding.status = "kept";
|
|
2324
|
+
finding.detail = decision.reason;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
/** A saved plan cannot outlive the review decision even when files are unchanged. */
|
|
2328
|
+
function validateWorkspacePolicyExpiry(plan) {
|
|
2329
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2330
|
+
for (const file of plan.files) {
|
|
2331
|
+
const expires = file.workspacePolicy?.expires;
|
|
2332
|
+
if (expires !== void 0 && (!isUpgradeExpiry(expires) || expires < today)) throw new Error(`Upgrade keep decision expired or invalid for ${file.path}; regenerate the plan.`);
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
//#endregion
|
|
2298
2336
|
//#region src/commands/upgrade/apply/validate.ts
|
|
2299
2337
|
const actionable = (file) => writesAsset(file) || Boolean(file.baseline);
|
|
2338
|
+
function blockedUpgradeGroups(plan) {
|
|
2339
|
+
return new Set(plan.files.filter((file) => file.group && ["conflict", "skip"].includes(file.status)).map((file) => file.group));
|
|
2340
|
+
}
|
|
2300
2341
|
function validateUpgradePlan(plan) {
|
|
2301
2342
|
validateUpgradePlanFiles(plan);
|
|
2302
2343
|
validateMigrationPlan(plan);
|
|
2344
|
+
validateWorkspacePolicyExpiry(plan);
|
|
2303
2345
|
}
|
|
2304
2346
|
//#endregion
|
|
2305
2347
|
//#region src/commands/upgrade/apply/index.ts
|
|
@@ -2307,9 +2349,13 @@ function validateUpgradePlan(plan) {
|
|
|
2307
2349
|
async function applyLocked$2(cwd, plan, options) {
|
|
2308
2350
|
validateUpgradePlan(plan);
|
|
2309
2351
|
if (await canonicalDirectory(path.resolve(cwd)) !== plan.cwd || await canonicalDirectory(plan.rootDir) !== plan.rootDir || await canonicalDirectory(assetsDir$1) !== plan.assetDir) throw new Error("Upgrade plan belongs to another directory or asset installation.");
|
|
2310
|
-
const
|
|
2352
|
+
const blockedGroups = blockedUpgradeGroups(plan);
|
|
2353
|
+
const selected = new Set(options.files ?? plan.files.filter((file) => actionable(file) && !blockedGroups.has(file.group)).map((file) => file.path));
|
|
2311
2354
|
if ([...selected].some((filename) => !plan.files.some((file) => file.path === filename && actionable(file)))) throw new Error("Selection contains an unplanned upgrade path.");
|
|
2312
|
-
for (const file of plan.files.filter(actionable))
|
|
2355
|
+
for (const file of plan.files.filter(actionable)) {
|
|
2356
|
+
if (file.group && selected.has(file.path) && blockedGroups.has(file.group)) throw new Error(`Resolve every blocked file in migration group ${file.group} before applying it.`);
|
|
2357
|
+
if (file.group && selected.has(file.path) && plan.files.some((other) => other.group === file.group && actionable(other) && !selected.has(other.path))) throw new Error(`Apply every file in migration group ${file.group} together.`);
|
|
2358
|
+
}
|
|
2313
2359
|
const conflicts = [];
|
|
2314
2360
|
const unresolved = plan.files.filter((file) => file.status === "conflict").map((file) => file.path);
|
|
2315
2361
|
const report = unresolved.length ? { conflicts: unresolved } : {};
|
|
@@ -2442,7 +2488,7 @@ async function planMigrationRecovery(context, attempt) {
|
|
|
2442
2488
|
}));
|
|
2443
2489
|
}
|
|
2444
2490
|
//#endregion
|
|
2445
|
-
//#region src/commands/upgrade/workspace.ts
|
|
2491
|
+
//#region src/commands/upgrade/workspace/merge.ts
|
|
2446
2492
|
function isPlainObject(value) {
|
|
2447
2493
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2448
2494
|
}
|
|
@@ -2506,6 +2552,125 @@ function mergeWorkspaceManifest(source, target) {
|
|
|
2506
2552
|
return result;
|
|
2507
2553
|
}
|
|
2508
2554
|
//#endregion
|
|
2555
|
+
//#region src/commands/upgrade/workspace/overrides.ts
|
|
2556
|
+
/** Nested parent selectors need a resolved dependency graph; never guess their scope. */
|
|
2557
|
+
function parseSelector(selector) {
|
|
2558
|
+
const match = /^((?:@[\w.~-]+\/)?[\w.~-]+)(?:@(.+))?$/.exec(selector);
|
|
2559
|
+
if (!match || match[2] && !validRange(match[2])) return null;
|
|
2560
|
+
return {
|
|
2561
|
+
name: match[1],
|
|
2562
|
+
range: match[2] ?? "*"
|
|
2563
|
+
};
|
|
2564
|
+
}
|
|
2565
|
+
function nestedChild(selector) {
|
|
2566
|
+
for (let index = 0; index < selector.length; index++) if (selector[index] === ">" && parseSelector(selector.slice(0, index))) {
|
|
2567
|
+
const child = parseSelector(selector.slice(index + 1));
|
|
2568
|
+
if (child) return child;
|
|
2569
|
+
}
|
|
2570
|
+
return null;
|
|
2571
|
+
}
|
|
2572
|
+
function inspectOverride(selector, upstream, local, scan) {
|
|
2573
|
+
const finding = {
|
|
2574
|
+
path: ["overrides", selector],
|
|
2575
|
+
status: "compatible",
|
|
2576
|
+
detail: "The new override stays within the inspected dependency declarations and existing selector boundaries.",
|
|
2577
|
+
upstreamHash: overrideFingerprint(upstream, selector),
|
|
2578
|
+
localHash: overrideFingerprint(local, selector),
|
|
2579
|
+
affected: []
|
|
2580
|
+
};
|
|
2581
|
+
const selected = parseSelector(selector);
|
|
2582
|
+
const value = upstream[selector];
|
|
2583
|
+
const replacement = selected && typeof value === "string" ? parseSpecifier(selected.name, value, scan.workspace) : null;
|
|
2584
|
+
const reasons = /* @__PURE__ */ new Set();
|
|
2585
|
+
if (!selected || !replacement?.range || replacement.source !== selected.name) {
|
|
2586
|
+
finding.status = "unverified";
|
|
2587
|
+
finding.detail = "The override selector or replacement cannot be compared safely. Review it explicitly; nested selectors and non-semver replacements are not inferred.";
|
|
2588
|
+
return finding;
|
|
2589
|
+
}
|
|
2590
|
+
for (const [existing, specifier] of Object.entries(local)) {
|
|
2591
|
+
if (existing === selector) continue;
|
|
2592
|
+
const parsed = parseSelector(existing);
|
|
2593
|
+
const child = parsed ? null : nestedChild(existing);
|
|
2594
|
+
if (parsed?.name === selected.name && intersects(selected.range, parsed.range) && !subset(selected.range, parsed.range)) {
|
|
2595
|
+
reasons.add("The new selector expands an existing local override boundary.");
|
|
2596
|
+
finding.affected.push({
|
|
2597
|
+
path: "pnpm-workspace.yaml",
|
|
2598
|
+
section: `overrides[${JSON.stringify(existing)}]`,
|
|
2599
|
+
specifier: String(specifier)
|
|
2600
|
+
});
|
|
2601
|
+
} else if (child?.name === selected.name && intersects(selected.range, child.range)) {
|
|
2602
|
+
reasons.add("An existing parent-qualified override requires explicit scope review.");
|
|
2603
|
+
finding.affected.push({
|
|
2604
|
+
path: "pnpm-workspace.yaml",
|
|
2605
|
+
section: `overrides[${JSON.stringify(existing)}]`,
|
|
2606
|
+
specifier: String(specifier)
|
|
2607
|
+
});
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2610
|
+
for (const occurrence of scan.occurrences) {
|
|
2611
|
+
if (occurrence.name !== selected.name && occurrence.source !== selected.name) continue;
|
|
2612
|
+
if (occurrence.range && !intersects(selected.range, occurrence.range)) continue;
|
|
2613
|
+
const group = matchGroup(occurrence, scan.policy);
|
|
2614
|
+
finding.affected.push({
|
|
2615
|
+
path: occurrence.path,
|
|
2616
|
+
section: `${occurrence.section}.${occurrence.name}`,
|
|
2617
|
+
specifier: occurrence.specifier,
|
|
2618
|
+
group: group?.name ?? "default",
|
|
2619
|
+
...group ? { reason: group.reason } : {}
|
|
2620
|
+
});
|
|
2621
|
+
if (!occurrence.range || occurrence.source !== selected.name) reasons.add("A matching dependency declaration cannot be compared safely.");
|
|
2622
|
+
else if (!subset(replacement.range, occurrence.range)) reasons.add("The replacement can escape a matching dependency declaration, including intentional version groups.");
|
|
2623
|
+
}
|
|
2624
|
+
if (reasons.size) {
|
|
2625
|
+
finding.status = "conflict";
|
|
2626
|
+
finding.detail = [...reasons].join(" ");
|
|
2627
|
+
}
|
|
2628
|
+
return finding;
|
|
2629
|
+
}
|
|
2630
|
+
//#endregion
|
|
2631
|
+
//#region src/commands/upgrade/workspace/plan.ts
|
|
2632
|
+
async function planWorkspaceManifest(context, upstream, local, deferUnverified = false) {
|
|
2633
|
+
const merged = mergeWorkspaceManifest(upstream, local);
|
|
2634
|
+
const sourceOverrides = record$2(upstream["overrides"]) ?? {};
|
|
2635
|
+
const localOverrides = record$2(local["overrides"]) ?? {};
|
|
2636
|
+
const decisions = keepDecisions(context.workspaceDecisions);
|
|
2637
|
+
const selectors = [.../* @__PURE__ */ new Set([...Object.keys(sourceOverrides).filter((key) => !Object.hasOwn(localOverrides, key)), ...decisions.keys()])].sort();
|
|
2638
|
+
if (!selectors.length) return { manifest: merged };
|
|
2639
|
+
const scan = await scanDependencies(context.plan.rootDir, merged.packages ? { patterns: merged.packages } : {});
|
|
2640
|
+
if (scan.workspaceDir !== context.plan.rootDir) throw new Error("Upgrade dependency policy must use the destination workspace.");
|
|
2641
|
+
for (const [filename, content] of scan.contents) {
|
|
2642
|
+
const area = filename === "pnpm-workspace.yaml" || filename.endsWith("package.json") ? "target" : "config";
|
|
2643
|
+
if ((await context.read(area, area === "config" ? path.resolve(scan.workspaceDir, filename) : filename))?.toString() !== content) throw new Error(`Dependency policy input changed while planning: ${filename}`);
|
|
2644
|
+
}
|
|
2645
|
+
context.plan.discovery = {
|
|
2646
|
+
patterns: merged.packages ?? null,
|
|
2647
|
+
manifests: scan.manifests
|
|
2648
|
+
};
|
|
2649
|
+
const policy = { findings: [] };
|
|
2650
|
+
const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
2651
|
+
const overrides = { ...record$2(merged["overrides"]) };
|
|
2652
|
+
for (const selector of selectors) {
|
|
2653
|
+
const finding = inspectOverride(selector, sourceOverrides, localOverrides, scan);
|
|
2654
|
+
const decision = decisions.get(selector);
|
|
2655
|
+
if (decision) applyKeepDecision(finding, decision, today);
|
|
2656
|
+
if (finding.status === "unverified" && deferUnverified) {
|
|
2657
|
+
finding.status = "deferred";
|
|
2658
|
+
finding.detail = "Preserve the local override during the atomic hook migration. Preview again afterwards to review this unverified override separately.";
|
|
2659
|
+
}
|
|
2660
|
+
if (finding.status === "kept" || finding.status === "deferred") {
|
|
2661
|
+
if (Object.hasOwn(localOverrides, selector)) overrides[selector] = localOverrides[selector];
|
|
2662
|
+
else delete overrides[selector];
|
|
2663
|
+
if (decision?.expires && (!policy.expires || decision.expires < policy.expires)) policy.expires = decision.expires;
|
|
2664
|
+
}
|
|
2665
|
+
policy.findings.push(finding);
|
|
2666
|
+
}
|
|
2667
|
+
merged["overrides"] = overrides;
|
|
2668
|
+
return {
|
|
2669
|
+
manifest: merged,
|
|
2670
|
+
policy
|
|
2671
|
+
};
|
|
2672
|
+
}
|
|
2673
|
+
//#endregion
|
|
2509
2674
|
//#region src/commands/upgrade/plan/migration.ts
|
|
2510
2675
|
/** Plan both lane changes and legacy metadata removals before any asset is applied. */
|
|
2511
2676
|
async function planVersioningMigration(context) {
|
|
@@ -2526,7 +2691,7 @@ async function planVersioningMigration(context) {
|
|
|
2526
2691
|
} catch {}
|
|
2527
2692
|
const workspace = plan.files.find((file) => file.path === "pnpm-workspace.yaml");
|
|
2528
2693
|
const current = await read("target", "pnpm-workspace.yaml");
|
|
2529
|
-
if (!tag || workspace
|
|
2694
|
+
if (!tag || workspace && ["skip", "conflict"].includes(workspace.status) || current === null && !workspace?.content) {
|
|
2530
2695
|
await put(".changeset/pre.json", pre, "prerelease-state-retained", "Unrecognized prerelease state or protected workspace configuration requires manual migration.", { skip: true });
|
|
2531
2696
|
if (config !== null) await put(".changeset/config.json", config, "prerelease-state-retained", "Retain the legacy configuration until prerelease migration is possible.", { skip: true });
|
|
2532
2697
|
return;
|
|
@@ -2549,7 +2714,11 @@ async function planVersioningMigration(context) {
|
|
|
2549
2714
|
}
|
|
2550
2715
|
versioning["lanes"] = lanes;
|
|
2551
2716
|
manifest["versioning"] = versioning;
|
|
2552
|
-
await put("pnpm-workspace.yaml", Buffer.from(YAML.stringify(manifest, { singleQuote: true })), "legacy-lane-migration", "Merge workspace settings and migrate the Changesets prerelease tag to pnpm lanes.", { group });
|
|
2717
|
+
const migrated = await put("pnpm-workspace.yaml", Buffer.from(YAML.stringify(manifest, { singleQuote: true })), "legacy-lane-migration", "Merge workspace settings and migrate the Changesets prerelease tag to pnpm lanes.", { group });
|
|
2718
|
+
if (workspace?.workspacePolicy) {
|
|
2719
|
+
migrated.workspacePolicy = workspace.workspacePolicy;
|
|
2720
|
+
if (workspace.workspacePolicy.findings.some((finding) => finding.status === "unverified")) migrated.automatic = false;
|
|
2721
|
+
}
|
|
2553
2722
|
await put(".changeset/pre.json", null, "legacy-pre-migrated", "Remove prerelease metadata only with the planned lane migration.", { group });
|
|
2554
2723
|
}
|
|
2555
2724
|
if (config !== null) await put(".changeset/config.json", null, "legacy-config-removal", "Remove configuration that belongs to the replaced Changesets CLI.", { group });
|
|
@@ -3170,6 +3339,7 @@ async function planAssets(context) {
|
|
|
3170
3339
|
let upstream = source;
|
|
3171
3340
|
let reason = "managed-asset";
|
|
3172
3341
|
let skip = false;
|
|
3342
|
+
let workspacePolicy;
|
|
3173
3343
|
if ((config.skipChangesetMarkdown ?? true) && filename.startsWith(".changeset/") && filename.endsWith(".md")) {
|
|
3174
3344
|
reason = "change-intent-protected";
|
|
3175
3345
|
skip = true;
|
|
@@ -3201,7 +3371,9 @@ async function planAssets(context) {
|
|
|
3201
3371
|
}
|
|
3202
3372
|
} else if (filename === "pnpm-workspace.yaml") {
|
|
3203
3373
|
const original = normalizeWorkspaceManifest(YAML.parse(source.toString()));
|
|
3204
|
-
|
|
3374
|
+
const result = before && !options.noOverwrite && !options.skipOverwrite ? await planWorkspaceManifest(context, original, normalizeWorkspaceManifest(YAML.parse(before.toString())), hooks.migrate) : { manifest: original };
|
|
3375
|
+
after = Buffer.from(YAML.stringify(result.manifest, { singleQuote: true }));
|
|
3376
|
+
workspacePolicy = result.policy;
|
|
3205
3377
|
reason = "workspace-semantic-merge";
|
|
3206
3378
|
} else if (filename === ".gitignore" && before !== null) {
|
|
3207
3379
|
after = Buffer.from(mergeGitignore(source.toString(), before.toString()));
|
|
@@ -3235,7 +3407,22 @@ async function planAssets(context) {
|
|
|
3235
3407
|
force: filename === ".github/workflows/release.yml" && options.overwriteRelease === true
|
|
3236
3408
|
});
|
|
3237
3409
|
baseline.annotate(file, result);
|
|
3238
|
-
if (
|
|
3410
|
+
if (workspacePolicy) {
|
|
3411
|
+
file.workspacePolicy = workspacePolicy;
|
|
3412
|
+
if (workspacePolicy.findings.some((finding) => finding.status === "unverified")) file.automatic = false;
|
|
3413
|
+
if (workspacePolicy.findings.some((finding) => [
|
|
3414
|
+
"conflict",
|
|
3415
|
+
"stale-decision",
|
|
3416
|
+
"expired-decision"
|
|
3417
|
+
].includes(finding.status))) {
|
|
3418
|
+
file.status = "conflict";
|
|
3419
|
+
file.reason = "workspace-override-policy";
|
|
3420
|
+
file.detail = "Review override scope and stale keep decisions in workspacePolicy. No workspace changes or baseline will be applied.";
|
|
3421
|
+
file.afterHash = file.beforeHash;
|
|
3422
|
+
file.content = null;
|
|
3423
|
+
file.automatic = false;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3239
3426
|
} catch (error) {
|
|
3240
3427
|
context.conflict(filename, error);
|
|
3241
3428
|
}
|
|
@@ -3247,6 +3434,7 @@ async function planAssets(context) {
|
|
|
3247
3434
|
baseline.retire(filename);
|
|
3248
3435
|
}
|
|
3249
3436
|
await baseline.removals();
|
|
3437
|
+
if (hooks.migrate) for (const file of plan.files.filter((file) => hookTargets.includes(file.path))) file.group = hookGroup;
|
|
3250
3438
|
return baseline;
|
|
3251
3439
|
}
|
|
3252
3440
|
//#endregion
|
|
@@ -3407,6 +3595,7 @@ async function createContext$1(opts) {
|
|
|
3407
3595
|
config,
|
|
3408
3596
|
releaseConfig: loaded.config.commands?.release,
|
|
3409
3597
|
docsConfig: targetConfig.config.commands?.docs,
|
|
3598
|
+
workspaceDecisions: targetConfig.config.commands?.upgrade?.keep ?? [],
|
|
3410
3599
|
read,
|
|
3411
3600
|
put,
|
|
3412
3601
|
conflict
|
|
@@ -3940,8 +4129,6 @@ var package_default = {
|
|
|
3940
4129
|
"test:packaged-generators": "node scripts/generate/index.mjs",
|
|
3941
4130
|
"test:packaged-template-parameters": "node scripts/template-parameters/index.mjs",
|
|
3942
4131
|
"docs:build": "node scripts/docs-deployment/build.mjs",
|
|
3943
|
-
"docs:deploy:preview": "node scripts/docs-deployment/deploy.mjs preview",
|
|
3944
|
-
"docs:deploy:stable": "node scripts/docs-deployment/deploy.mjs stable",
|
|
3945
4132
|
"docs:test": "node --test scripts/docs-deployment/deployment.test.mjs scripts/docs-deployment/release-inputs.test.mjs",
|
|
3946
4133
|
"docs:lint": "eslint scripts/docs-deployment repoctl.config.ts"
|
|
3947
4134
|
},
|
|
@@ -5036,6 +5223,11 @@ function hasVerification(options) {
|
|
|
5036
5223
|
//#endregion
|
|
5037
5224
|
//#region src/commands/release/workspace-protocol.ts
|
|
5038
5225
|
const EXPECTED_WORKSPACE_SPEC = "workspace:*";
|
|
5226
|
+
const PEER_WORKSPACE_SPECS = /* @__PURE__ */ new Set([
|
|
5227
|
+
EXPECTED_WORKSPACE_SPEC,
|
|
5228
|
+
"workspace:^",
|
|
5229
|
+
"workspace:~"
|
|
5230
|
+
]);
|
|
5039
5231
|
const DEPENDENCY_SECTIONS = [
|
|
5040
5232
|
"dependencies",
|
|
5041
5233
|
"devDependencies",
|
|
@@ -5052,7 +5244,10 @@ function collectWorkspaceProtocolViolations(options) {
|
|
|
5052
5244
|
for (const section of DEPENDENCY_SECTIONS) {
|
|
5053
5245
|
const dependencies = entry.packageJson[section];
|
|
5054
5246
|
if (!dependencies) continue;
|
|
5055
|
-
for (const [dependencyName, spec] of Object.entries(dependencies))
|
|
5247
|
+
for (const [dependencyName, spec] of Object.entries(dependencies)) {
|
|
5248
|
+
const validSpec = section === "peerDependencies" ? PEER_WORKSPACE_SPECS.has(spec) : spec === EXPECTED_WORKSPACE_SPEC;
|
|
5249
|
+
if (options.workspacePackageNames.has(dependencyName) && !validSpec) violations.push(`${displayPath(options.workspaceDir, entry.file)} -> ${section}.${dependencyName}=${spec}`);
|
|
5250
|
+
}
|
|
5056
5251
|
}
|
|
5057
5252
|
}
|
|
5058
5253
|
return violations;
|
|
@@ -5071,7 +5266,11 @@ async function assertWorkspaceDependencyProtocols(cwd) {
|
|
|
5071
5266
|
packages: manifests,
|
|
5072
5267
|
workspacePackageNames: new Set(manifests.map(({ packageJson }) => packageJson.name).filter((name) => typeof name === "string"))
|
|
5073
5268
|
});
|
|
5074
|
-
if (violations.length > 0) throw new ReleaseCommandError([
|
|
5269
|
+
if (violations.length > 0) throw new ReleaseCommandError([
|
|
5270
|
+
`Expected publishable workspace dependencies to use ${EXPECTED_WORKSPACE_SPEC}:`,
|
|
5271
|
+
"Internal peerDependencies may also use workspace:^ or workspace:~ to preserve their compatibility ranges.",
|
|
5272
|
+
...violations.map((violation) => `- ${violation}`)
|
|
5273
|
+
].join("\n"));
|
|
5075
5274
|
}
|
|
5076
5275
|
//#endregion
|
|
5077
5276
|
//#region src/commands/release/hooks.ts
|
|
@@ -6864,7 +7063,7 @@ function capturePlan(args, options) {
|
|
|
6864
7063
|
if (result.error || result.status !== 0) throw new PlanError("pnpm-plan-failed", `pnpm ${args.join(" ")} failed: ${result.error?.message ?? result.stderr?.toString().trim() ?? result.status}`);
|
|
6865
7064
|
return result.stdout?.toString().trim() ?? "";
|
|
6866
7065
|
}
|
|
6867
|
-
function unsupported() {
|
|
7066
|
+
function unsupported$1() {
|
|
6868
7067
|
throw new PlanError("unsupported-pnpm-plan", "Unsupported pnpm release-plan output. Use a pnpm version with recursive --dry-run support (tested with 12.8.1); no versions were applied.");
|
|
6869
7068
|
}
|
|
6870
7069
|
/** Interpret native results only; pnpm remains the sole version solver. */
|
|
@@ -6876,7 +7075,7 @@ function parseNativePlan(output) {
|
|
|
6876
7075
|
if (Array.isArray(json)) return {
|
|
6877
7076
|
format: "json",
|
|
6878
7077
|
packages: json.map((item) => {
|
|
6879
|
-
if (!item || typeof item.name !== "string" || typeof item.currentVersion !== "string" || typeof item.newVersion !== "string" || !valid(item.currentVersion) || !valid(item.newVersion)) return unsupported();
|
|
7078
|
+
if (!item || typeof item.name !== "string" || typeof item.currentVersion !== "string" || typeof item.newVersion !== "string" || !valid(item.currentVersion) || !valid(item.newVersion)) return unsupported$1();
|
|
6880
7079
|
return {
|
|
6881
7080
|
name: item.name,
|
|
6882
7081
|
currentVersion: item.currentVersion,
|
|
@@ -6887,12 +7086,12 @@ function parseNativePlan(output) {
|
|
|
6887
7086
|
})
|
|
6888
7087
|
};
|
|
6889
7088
|
const lines = output.split(/\r?\n/).filter((line) => line.trim());
|
|
6890
|
-
if (lines.shift() !== "Release plan:" || !lines.length) return unsupported();
|
|
7089
|
+
if (lines.shift() !== "Release plan:" || !lines.length) return unsupported$1();
|
|
6891
7090
|
return {
|
|
6892
7091
|
format: "text",
|
|
6893
7092
|
packages: lines.map((line) => {
|
|
6894
7093
|
const match = /^ {2}(.+): (\S+) → (\S+) \(([^,]+), via ([^)]+)\)$/.exec(line);
|
|
6895
|
-
if (!match || !valid(match[2]) || !valid(match[3])) return unsupported();
|
|
7094
|
+
if (!match || !valid(match[2]) || !valid(match[3])) return unsupported$1();
|
|
6896
7095
|
return {
|
|
6897
7096
|
name: match[1],
|
|
6898
7097
|
currentVersion: match[2],
|
|
@@ -6905,9 +7104,9 @@ function parseNativePlan(output) {
|
|
|
6905
7104
|
}
|
|
6906
7105
|
function nativePlan(options) {
|
|
6907
7106
|
const version = capturePlan(["--version"], options);
|
|
6908
|
-
if (!valid(version)) return unsupported();
|
|
7107
|
+
if (!valid(version)) return unsupported$1();
|
|
6909
7108
|
const help = capturePlan(["version", "--help"], options);
|
|
6910
|
-
if (!help.includes("--dry-run") || !help.includes("--json")) return unsupported();
|
|
7109
|
+
if (!help.includes("--dry-run") || !help.includes("--json")) return unsupported$1();
|
|
6911
7110
|
const plan = parseNativePlan(capturePlan([
|
|
6912
7111
|
"version",
|
|
6913
7112
|
"-r",
|
|
@@ -8484,8 +8683,9 @@ async function checkTemplates(options = {}) {
|
|
|
8484
8683
|
//#region src/commands/upgrade/select.ts
|
|
8485
8684
|
/** Collect every approval before apply, including atomic migration groups. */
|
|
8486
8685
|
async function selectUpgradeFiles(plan) {
|
|
8686
|
+
const blocked = blockedUpgradeGroups(plan);
|
|
8487
8687
|
const groups = /* @__PURE__ */ new Map();
|
|
8488
|
-
for (const file of plan.files.filter(actionable)) {
|
|
8688
|
+
for (const file of plan.files.filter((file) => actionable(file) && !blocked.has(file.group))) {
|
|
8489
8689
|
const key = file.group ? `group:${file.group}` : path.join(plan.rootDir, file.path);
|
|
8490
8690
|
groups.set(key, [...groups.get(key) ?? [], file]);
|
|
8491
8691
|
}
|
|
@@ -8522,6 +8722,11 @@ function formatUpgradePlan(plan, format = "text") {
|
|
|
8522
8722
|
lines.push(format === "markdown" ? `## ${file.path}` : file.path);
|
|
8523
8723
|
lines.push(`${file.status} (${file.reason}): ${file.detail}`);
|
|
8524
8724
|
if (file.baseline) lines.push(`baseline: ${file.baseline.path} (${file.baseline.beforeHash ?? "absent"} -> ${file.baseline.afterHash ?? "removed"})`);
|
|
8725
|
+
for (const finding of file.workspacePolicy?.findings ?? []) {
|
|
8726
|
+
lines.push(`${JSON.stringify(finding.path)}: ${finding.status}. ${finding.detail}`);
|
|
8727
|
+
lines.push(`upstreamHash: ${finding.upstreamHash}; localHash: ${finding.localHash}`);
|
|
8728
|
+
for (const affected of finding.affected) lines.push(` ${affected.path} ${affected.section ?? ""}: ${affected.specifier}${affected.group ? ` [${affected.group}]` : ""}${affected.reason ? ` (${affected.reason})` : ""}`);
|
|
8729
|
+
}
|
|
8525
8730
|
for (const conflict of file.merge?.conflicts ?? []) lines.push(`Conflict at base lines ${conflict.baseStart}-${conflict.baseEnd}:`, "<<<<<<< local", conflict.local, "||||||| base", conflict.base, "=======", conflict.upstream, ">>>>>>> upstream");
|
|
8526
8731
|
if (file.diff) lines.push(...format === "markdown" ? [
|
|
8527
8732
|
"````diff",
|
|
@@ -8561,7 +8766,9 @@ async function upgradeMonorepo(options) {
|
|
|
8561
8766
|
}
|
|
8562
8767
|
}
|
|
8563
8768
|
if (plan.status === "blocked") throw new Error(plan.blockers.map((item) => `${item.id}: ${item.path ?? ""} ${item.detail}`).join("\n"));
|
|
8564
|
-
for (const file of plan.files.filter((file) => file.status === "conflict" || file.reason === "custom-hooks-protected")) logger.warn(`${file.path}: ${file.reason}. ${file.detail}`);
|
|
8769
|
+
for (const file of plan.files.filter((file) => file.status === "conflict" || file.status === "skip" && file.group || file.reason === "custom-hooks-protected")) logger.warn(`${file.path}: ${file.reason}. ${file.detail}`);
|
|
8770
|
+
for (const file of plan.files.filter((file) => file.workspacePolicy?.findings.some((finding) => finding.status === "unverified"))) logger.warn(`${file.path}: unverified override scope. Review repo upgrade --json and explicitly select the file or apply the reviewed saved plan.`);
|
|
8771
|
+
for (const file of plan.files.filter((file) => file.workspacePolicy?.findings.some((finding) => finding.status === "deferred"))) logger.warn(`${file.path}: unverified overrides were deferred and remain unchanged. Preview again after the hook migration to review them.`);
|
|
8565
8772
|
const files = await selectUpgradeFiles(plan);
|
|
8566
8773
|
const result = await applyUpgradePlan(plan.cwd, plan, { files });
|
|
8567
8774
|
for (const filename of result.changed) logger.success(path.join(plan.rootDir, filename));
|
|
@@ -9177,14 +9384,90 @@ async function checkPeerDependencies(cwd) {
|
|
|
9177
9384
|
return report;
|
|
9178
9385
|
}
|
|
9179
9386
|
//#endregion
|
|
9387
|
+
//#region src/commands/docs/diagnostics.ts
|
|
9388
|
+
/** Only repoctl-owned messages enter generated errors and reports; never copy exception text. */
|
|
9389
|
+
const messages = {
|
|
9390
|
+
"plan-failed": "Run repo docs plan with the same inputs to inspect configuration, source selection and release evidence before retrying.",
|
|
9391
|
+
"plan-blocked": "Documentation source or release checks blocked this deployment; run repo docs plan with the same inputs to inspect the blockers.",
|
|
9392
|
+
"workflow-required": "Stable documentation requires the managed GitHub workflow and its per-site concurrency group.",
|
|
9393
|
+
"deployment-unresolved": "An unfinished deployment must be retried with the same release and corrections before advancing.",
|
|
9394
|
+
"readiness-policy-missing": "An unfinished verification requires its frozen readiness policy; retry the original deployment.",
|
|
9395
|
+
"claim-changed": "The deployment claim changed; another run owns this checkpoint. Refusing to advance stale work.",
|
|
9396
|
+
"main-advanced": "Main advanced during preview deployment; deploy the latest main source instead.",
|
|
9397
|
+
"source-tree-changed": "The source tree no longer matches the inspected deployment; repeat the plan before deploying.",
|
|
9398
|
+
"snapshot-mismatch": "The frozen stable snapshot no longer matches the verified deployment; inspect the persisted checkpoint.",
|
|
9399
|
+
"checkpoint-invalid": "The documentation checkpoint is invalid; inspect its identity, snapshot and provider receipt before retrying.",
|
|
9400
|
+
"checkpoint-read-failed": "Cannot read the documentation checkpoint; verify state-store access before retrying.",
|
|
9401
|
+
"checkpoint-write-failed": "The checkpoint write or revision comparison failed; reload state and retry the same deployment without replacing another run.",
|
|
9402
|
+
"receipt-invalid": "The provider receipt requires a nonempty versionId and optional HTTP(S) URL without credentials, query or fragment.",
|
|
9403
|
+
"process-failed": "The documentation process failed; inspect its streamed terminal output and retry after fixing the command.",
|
|
9404
|
+
"script-result-invalid": "The deployment script must write valid { versionId, url? } JSON to REPO_DOCS_RESULT_FILE after provider verification.",
|
|
9405
|
+
"artifact-path-invalid": "The documentation configuration and assets must stay inside the frozen checkout without external symlinks.",
|
|
9406
|
+
"artifact-output-missing": "The documentation build must produce an existing assets output directory.",
|
|
9407
|
+
"manifest-conflict": "The deployment manifest conflicts with existing output; remove the conflicting file from the build output.",
|
|
9408
|
+
"credentials-missing": "CLOUDFLARE_API_TOKEN is required to verify documentation deployments.",
|
|
9409
|
+
"provider-environment-conflict": "Cloudflare environment overrides conflict with the frozen account, Worker or API origin; remove the conflicting override.",
|
|
9410
|
+
"provider-access-denied": "Cloudflare denied read access; verify the API token, account and Worker permissions.",
|
|
9411
|
+
"provider-rate-limited": "Cloudflare rate-limited verification; retry the same deployment after the limit clears.",
|
|
9412
|
+
"provider-request-rejected": "Cloudflare rejected verification; inspect the account and Worker configuration before retrying.",
|
|
9413
|
+
"provider-network-failed": "Cloudflare read-only verification failed due to a network error, timeout or invalid JSON response.",
|
|
9414
|
+
"provider-response-invalid": "Cloudflare returned an invalid verification response; do not upload until provider state can be verified.",
|
|
9415
|
+
"provider-traffic-ambiguous": "The active Cloudflare deployment must serve exactly one valid version at 100% traffic.",
|
|
9416
|
+
"provider-version-mismatch": "Cloudflare returned a different version than requested; retry only after the active version is verified.",
|
|
9417
|
+
"provider-version-inactive": "The uploaded documentation version is not confirmed active; retry the same deployment.",
|
|
9418
|
+
"saved-version-inactive": "The saved documentation version is no longer active; recovery cannot upload a replacement.",
|
|
9419
|
+
"provider-target-invalid": "Cloudflare requires valid accountId, workerName and optional environment values.",
|
|
9420
|
+
"provider-config-invalid": "The frozen Cloudflare configuration must be valid static JSON or JSONC.",
|
|
9421
|
+
"provider-config-unreadable": "Cannot read the frozen Cloudflare configuration; verify the configured file exists inside the checkout.",
|
|
9422
|
+
"provider-identity-mismatch": "Cloudflare configuration does not match the frozen accountId and workerName.",
|
|
9423
|
+
"provider-domain-mismatch": "The Cloudflare documentation URL must match a configured HTTPS custom domain.",
|
|
9424
|
+
"provider-target-shared": "Preview and stable cannot deploy to the same Cloudflare Worker.",
|
|
9425
|
+
"provider-domain-shared": "Preview and stable Cloudflare Workers cannot own the same custom domain.",
|
|
9426
|
+
"provider-config-changed": "Cloudflare configuration changed during the documentation build; keep deployment configuration immutable.",
|
|
9427
|
+
"unsupported-config": "Unsupported static Cloudflare configuration; use the documentation script adapter for custom deployment features.",
|
|
9428
|
+
"generated-config": "Generated Wrangler configuration is not supported by the native provider; use the documentation script adapter.",
|
|
9429
|
+
"environment-routes-missing": "A named Cloudflare environment must explicitly declare routes when the top level owns routes.",
|
|
9430
|
+
"wrangler-missing": "Declare Wrangler in this workspace and install it with the frozen lockfile before deployment.",
|
|
9431
|
+
"wrangler-invalid": "Wrangler must resolve to a valid CLI inside the frozen checkout node_modules.",
|
|
9432
|
+
"wrangler-result-invalid": "Wrangler must report exactly one valid deployed version matching the frozen Worker and environment.",
|
|
9433
|
+
"readiness-url-invalid": "Documentation readiness requires an explicit HTTPS target URL without credentials, query or fragment.",
|
|
9434
|
+
"preview-selection-invalid": "Preview only accepts a source SHA, not stable release records or corrections",
|
|
9435
|
+
"stable-selection-invalid": "Stable documentation requires a completed release record, never an arbitrary source SHA",
|
|
9436
|
+
"stable-baseline-missing": "No stable documentation baseline exists; wait for a complete stable release and provide its record ID",
|
|
9437
|
+
"release-identity-mismatch": "Stable documentation requires this repository’s main/latest release completion",
|
|
9438
|
+
"preview-source-missing": "Preview requires an explicit source SHA"
|
|
9439
|
+
};
|
|
9440
|
+
function docsDiagnosticMessage(reason) {
|
|
9441
|
+
return Object.hasOwn(messages, reason) ? messages[reason] : void 0;
|
|
9442
|
+
}
|
|
9443
|
+
var DocsDiagnosticError = class extends Error {
|
|
9444
|
+
reason;
|
|
9445
|
+
constructor(reason) {
|
|
9446
|
+
super(messages[reason]);
|
|
9447
|
+
this.reason = reason;
|
|
9448
|
+
this.name = "DocsDiagnosticError";
|
|
9449
|
+
}
|
|
9450
|
+
};
|
|
9451
|
+
//#endregion
|
|
9180
9452
|
//#region src/commands/docs/execute.ts
|
|
9181
9453
|
function runDocsProcess(options, source, args, env) {
|
|
9182
9454
|
const result = (options.spawn ?? crossSpawn.sync)("pnpm", args, {
|
|
9183
9455
|
cwd: source,
|
|
9184
9456
|
env,
|
|
9185
|
-
stdio:
|
|
9457
|
+
stdio: options.json ? [
|
|
9458
|
+
"inherit",
|
|
9459
|
+
2,
|
|
9460
|
+
2
|
|
9461
|
+
] : "inherit"
|
|
9186
9462
|
});
|
|
9187
|
-
if (result.error || result.status !== 0) throw new
|
|
9463
|
+
if (result.error || result.status !== 0) throw new DocsDiagnosticError("process-failed");
|
|
9464
|
+
}
|
|
9465
|
+
/** Installation lifecycles may build unrelated sites with their own default origins. */
|
|
9466
|
+
function docsInstallEnvironment(env) {
|
|
9467
|
+
return {
|
|
9468
|
+
...Object.fromEntries(Object.entries(env).filter(([key]) => !key.toUpperCase().startsWith("REPO_DOCS_"))),
|
|
9469
|
+
LEFTHOOK: "0"
|
|
9470
|
+
};
|
|
9188
9471
|
}
|
|
9189
9472
|
function docsEnvironment(context, plan, resultFile) {
|
|
9190
9473
|
const target = context.site[plan.channel];
|
|
@@ -9194,6 +9477,7 @@ function docsEnvironment(context, plan, resultFile) {
|
|
|
9194
9477
|
REPO_DOCS_SITE: plan.site,
|
|
9195
9478
|
REPO_DOCS_CHANNEL: plan.channel,
|
|
9196
9479
|
REPO_DOCS_SOURCE_SHA: plan.sourceSha,
|
|
9480
|
+
REPO_DOCS_TREE_SHA: plan.treeSha,
|
|
9197
9481
|
REPO_DOCS_RELEASE_ID: plan.releaseId ?? "",
|
|
9198
9482
|
REPO_DOCS_DEPLOYMENT_ID: plan.deploymentId,
|
|
9199
9483
|
REPO_DOCS_URL: target.url ?? "",
|
|
@@ -9205,9 +9489,9 @@ async function readDeploymentResult(filename) {
|
|
|
9205
9489
|
try {
|
|
9206
9490
|
value = JSON.parse(await readFile(filename, "utf8"));
|
|
9207
9491
|
} catch {
|
|
9208
|
-
throw new
|
|
9492
|
+
throw new DocsDiagnosticError("script-result-invalid");
|
|
9209
9493
|
}
|
|
9210
|
-
if (!value || typeof value !== "object" || !("versionId" in value) || typeof value.versionId !== "string" || !value.versionId.trim() || "url" in value && (typeof value.url !== "string" || !/^https?:\/\//.test(value.url))) throw new
|
|
9494
|
+
if (!value || typeof value !== "object" || !("versionId" in value) || typeof value.versionId !== "string" || !value.versionId.trim() || "url" in value && (typeof value.url !== "string" || !/^https?:\/\//.test(value.url))) throw new DocsDiagnosticError("script-result-invalid");
|
|
9211
9495
|
return {
|
|
9212
9496
|
versionId: value.versionId,
|
|
9213
9497
|
..."url" in value ? { url: value.url } : {}
|
|
@@ -9524,6 +9808,186 @@ async function checkReleaseCoverage(source, record, site) {
|
|
|
9524
9808
|
};
|
|
9525
9809
|
}
|
|
9526
9810
|
//#endregion
|
|
9811
|
+
//#region src/commands/docs/artifacts/paths.ts
|
|
9812
|
+
function contained(root, filename) {
|
|
9813
|
+
const relative = path.relative(root, filename);
|
|
9814
|
+
return relative === "" || !path.isAbsolute(relative) && relative !== ".." && !relative.startsWith("../");
|
|
9815
|
+
}
|
|
9816
|
+
function relativePath(root, value, _label) {
|
|
9817
|
+
if (!value || path.isAbsolute(value) || value.includes("\\") || /^[a-z]:/i.test(value)) throw new DocsDiagnosticError("artifact-path-invalid");
|
|
9818
|
+
return path.resolve(root, value);
|
|
9819
|
+
}
|
|
9820
|
+
/** Check existing ancestors without creating the build output during preflight. */
|
|
9821
|
+
async function assertContainedPath(root, filename) {
|
|
9822
|
+
if (!contained(root, filename)) throw new DocsDiagnosticError("artifact-path-invalid");
|
|
9823
|
+
const physicalRoot = await realpath(root);
|
|
9824
|
+
let cursor = filename;
|
|
9825
|
+
while (true) {
|
|
9826
|
+
try {
|
|
9827
|
+
await lstat(cursor);
|
|
9828
|
+
} catch (error) {
|
|
9829
|
+
if (error.code !== "ENOENT") throw error;
|
|
9830
|
+
const parent = path.dirname(cursor);
|
|
9831
|
+
if (cursor === parent) throw new DocsDiagnosticError("artifact-path-invalid");
|
|
9832
|
+
cursor = parent;
|
|
9833
|
+
continue;
|
|
9834
|
+
}
|
|
9835
|
+
if (!contained(physicalRoot, await realpath(cursor))) throw new DocsDiagnosticError("artifact-path-invalid");
|
|
9836
|
+
return;
|
|
9837
|
+
}
|
|
9838
|
+
}
|
|
9839
|
+
//#endregion
|
|
9840
|
+
//#region src/commands/docs/manifest.ts
|
|
9841
|
+
const docsManifestPath = ".well-known/repoctl-deployment.json";
|
|
9842
|
+
function docsManifest(plan) {
|
|
9843
|
+
return {
|
|
9844
|
+
schemaVersion: 1,
|
|
9845
|
+
site: plan.site,
|
|
9846
|
+
channel: plan.channel,
|
|
9847
|
+
deploymentId: plan.deploymentId,
|
|
9848
|
+
sourceSha: plan.sourceSha,
|
|
9849
|
+
treeSha: plan.treeSha,
|
|
9850
|
+
...plan.releaseId ? { releaseId: plan.releaseId } : {}
|
|
9851
|
+
};
|
|
9852
|
+
}
|
|
9853
|
+
async function stampDocsManifest(source, output, plan) {
|
|
9854
|
+
await assertContainedPath(source, output);
|
|
9855
|
+
if (!(await stat(output)).isDirectory()) throw new DocsDiagnosticError("artifact-output-missing");
|
|
9856
|
+
const filename = path.join(output, docsManifestPath);
|
|
9857
|
+
await assertContainedPath(source, filename);
|
|
9858
|
+
const expected = docsManifest(plan);
|
|
9859
|
+
try {
|
|
9860
|
+
const value = JSON.parse(await readFile(filename, "utf8"));
|
|
9861
|
+
if (!value || typeof value !== "object" || Object.keys(value).length !== Object.keys(expected).length || Object.entries(expected).some(([key, item]) => Reflect.get(value, key) !== item)) throw new DocsDiagnosticError("manifest-conflict");
|
|
9862
|
+
return;
|
|
9863
|
+
} catch (error) {
|
|
9864
|
+
if (error.code !== "ENOENT") throw new DocsDiagnosticError("manifest-conflict");
|
|
9865
|
+
}
|
|
9866
|
+
await mkdir(path.dirname(filename), { recursive: true });
|
|
9867
|
+
await assertContainedPath(source, filename);
|
|
9868
|
+
await writeFile(filename, `${JSON.stringify(expected)}\n`, { flag: "wx" });
|
|
9869
|
+
}
|
|
9870
|
+
//#endregion
|
|
9871
|
+
//#region src/commands/docs/readiness.ts
|
|
9872
|
+
var DocsReadinessError = class extends Error {
|
|
9873
|
+
reason;
|
|
9874
|
+
attempts;
|
|
9875
|
+
constructor(reason, attempts) {
|
|
9876
|
+
super(`Documentation readiness budget exhausted (${reason})`);
|
|
9877
|
+
this.reason = reason;
|
|
9878
|
+
this.attempts = attempts;
|
|
9879
|
+
this.name = "DocsReadinessError";
|
|
9880
|
+
}
|
|
9881
|
+
};
|
|
9882
|
+
function readinessUrl(target) {
|
|
9883
|
+
let url;
|
|
9884
|
+
try {
|
|
9885
|
+
url = new URL(target.url ?? "");
|
|
9886
|
+
} catch {
|
|
9887
|
+
throw new DocsDiagnosticError("readiness-url-invalid");
|
|
9888
|
+
}
|
|
9889
|
+
if (url.protocol !== "https:" || url.username || url.password || url.search || url.hash) throw new DocsDiagnosticError("readiness-url-invalid");
|
|
9890
|
+
return new URL(`/${docsManifestPath}`, url).href;
|
|
9891
|
+
}
|
|
9892
|
+
function matches(value, plan) {
|
|
9893
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
9894
|
+
return Object.entries(docsManifest(plan)).every(([key, expected]) => Reflect.get(value, key) === expected) && (plan.releaseId !== void 0 || !Object.hasOwn(value, "releaseId"));
|
|
9895
|
+
}
|
|
9896
|
+
async function readBody(response, signal) {
|
|
9897
|
+
const reader = response.body?.getReader();
|
|
9898
|
+
if (!reader) throw new DocsReadinessError("invalid-payload", 0);
|
|
9899
|
+
const chunks = [];
|
|
9900
|
+
let bytes = 0;
|
|
9901
|
+
const cancel = () => {
|
|
9902
|
+
reader.cancel().catch(() => {});
|
|
9903
|
+
};
|
|
9904
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
9905
|
+
try {
|
|
9906
|
+
while (true) {
|
|
9907
|
+
const chunk = await reader.read();
|
|
9908
|
+
if (chunk.done) break;
|
|
9909
|
+
bytes += chunk.value.byteLength;
|
|
9910
|
+
if (bytes > 65536) {
|
|
9911
|
+
reader.cancel().catch(() => {});
|
|
9912
|
+
throw new DocsReadinessError("response-too-large", 0);
|
|
9913
|
+
}
|
|
9914
|
+
chunks.push(chunk.value);
|
|
9915
|
+
}
|
|
9916
|
+
try {
|
|
9917
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
9918
|
+
} catch {
|
|
9919
|
+
throw new DocsReadinessError("invalid-json", 0);
|
|
9920
|
+
}
|
|
9921
|
+
} finally {
|
|
9922
|
+
signal.removeEventListener("abort", cancel);
|
|
9923
|
+
reader.releaseLock();
|
|
9924
|
+
}
|
|
9925
|
+
}
|
|
9926
|
+
async function probe(url, plan, request, timeoutMs) {
|
|
9927
|
+
const controller = new AbortController();
|
|
9928
|
+
let timer;
|
|
9929
|
+
const timeout = new Promise((resolve) => {
|
|
9930
|
+
timer = setTimeout(() => {
|
|
9931
|
+
controller.abort();
|
|
9932
|
+
resolve("request-timeout");
|
|
9933
|
+
}, timeoutMs);
|
|
9934
|
+
});
|
|
9935
|
+
const operation = async () => {
|
|
9936
|
+
try {
|
|
9937
|
+
const response = await request(url, {
|
|
9938
|
+
method: "GET",
|
|
9939
|
+
redirect: "error",
|
|
9940
|
+
credentials: "omit",
|
|
9941
|
+
cache: "no-store",
|
|
9942
|
+
headers: {
|
|
9943
|
+
"Cache-Control": "no-cache, no-store",
|
|
9944
|
+
"Pragma": "no-cache",
|
|
9945
|
+
"Accept": "application/json"
|
|
9946
|
+
},
|
|
9947
|
+
signal: controller.signal
|
|
9948
|
+
});
|
|
9949
|
+
if (controller.signal.aborted) {
|
|
9950
|
+
response.body?.cancel().catch(() => {});
|
|
9951
|
+
return "request-timeout";
|
|
9952
|
+
}
|
|
9953
|
+
if (response.status !== 200) {
|
|
9954
|
+
response.body?.cancel().catch(() => {});
|
|
9955
|
+
return "http-status";
|
|
9956
|
+
}
|
|
9957
|
+
const value = await readBody(response, controller.signal);
|
|
9958
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return "invalid-payload";
|
|
9959
|
+
return matches(value, plan) ? void 0 : "identity-mismatch";
|
|
9960
|
+
} catch (error) {
|
|
9961
|
+
return controller.signal.aborted ? "request-timeout" : error instanceof DocsReadinessError ? error.reason : "network-error";
|
|
9962
|
+
}
|
|
9963
|
+
};
|
|
9964
|
+
try {
|
|
9965
|
+
return await Promise.race([operation(), timeout]);
|
|
9966
|
+
} finally {
|
|
9967
|
+
clearTimeout(timer);
|
|
9968
|
+
controller.abort();
|
|
9969
|
+
}
|
|
9970
|
+
}
|
|
9971
|
+
/** A fresh finite budget for each invocation; provider credentials are never sent publicly. */
|
|
9972
|
+
async function verifyDocsReadiness(target, plan, request = fetch, now = () => performance.now()) {
|
|
9973
|
+
const url = readinessUrl(target);
|
|
9974
|
+
const timeoutMs = target.readiness?.timeoutMs ?? 12e4;
|
|
9975
|
+
const requestTimeoutMs = target.readiness?.requestTimeoutMs ?? 1e4;
|
|
9976
|
+
const deadline = now() + timeoutMs;
|
|
9977
|
+
let attempts = 0;
|
|
9978
|
+
let reason = "request-timeout";
|
|
9979
|
+
while (now() < deadline) {
|
|
9980
|
+
attempts++;
|
|
9981
|
+
const result = await probe(url, plan, request, Math.min(requestTimeoutMs, Math.max(1, deadline - now())));
|
|
9982
|
+
if (result === void 0 && now() <= deadline) return;
|
|
9983
|
+
reason = result ?? "request-timeout";
|
|
9984
|
+
const remaining = deadline - now();
|
|
9985
|
+
if (remaining <= 0) break;
|
|
9986
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(remaining, Math.min(5e3, 1e3 * 2 ** Math.min(attempts - 1, 3)))));
|
|
9987
|
+
}
|
|
9988
|
+
throw new DocsReadinessError(reason, attempts);
|
|
9989
|
+
}
|
|
9990
|
+
//#endregion
|
|
9527
9991
|
//#region src/commands/docs/config.ts
|
|
9528
9992
|
function assertPatterns(patterns, label) {
|
|
9529
9993
|
if (!patterns.length || !patterns.some((value) => !value.startsWith("!"))) throw new Error(`${label} requires at least one positive repository-relative glob`);
|
|
@@ -9536,7 +10000,10 @@ function validateSite(site) {
|
|
|
9536
10000
|
if (!site.packages.length || new Set(site.packages).size !== site.packages.length) throw new Error("Documentation packages must be a nonempty list of unique package names");
|
|
9537
10001
|
if (site.patchPaths.length) assertPatterns(site.patchPaths, "patchPaths");
|
|
9538
10002
|
for (const [name, patterns] of Object.entries(site.releaseInputs ?? {})) assertPatterns(patterns, `releaseInputs.${name}`);
|
|
9539
|
-
for (const target of [site.preview, site.stable])
|
|
10003
|
+
for (const target of [site.preview, site.stable]) {
|
|
10004
|
+
if (target.url && !/^https?:\/\//.test(target.url)) throw new Error("Documentation URLs must use http or https");
|
|
10005
|
+
if (target.readiness) readinessUrl(target);
|
|
10006
|
+
}
|
|
9540
10007
|
}
|
|
9541
10008
|
function docsIdentity(options) {
|
|
9542
10009
|
if (!/^[a-z0-9][a-z0-9-]{0,63}$/.test(options.site)) throw new Error("Documentation site IDs must use lowercase letters, digits and hyphens");
|
|
@@ -9567,14 +10034,26 @@ function isObject(value) {
|
|
|
9567
10034
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9568
10035
|
}
|
|
9569
10036
|
function assertIdentity(value) {
|
|
9570
|
-
if (typeof value !== "string" || !/^[a-f0-9]{64}$/.test(value)) throw new
|
|
10037
|
+
if (typeof value !== "string" || !/^[a-f0-9]{64}$/.test(value)) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
9571
10038
|
}
|
|
9572
10039
|
function assertCommits(value) {
|
|
9573
|
-
if (!Array.isArray(value) || value.some((item) => typeof item !== "string") || new Set(value).size !== value.length) throw new
|
|
10040
|
+
if (!Array.isArray(value) || value.some((item) => typeof item !== "string") || new Set(value).size !== value.length) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
9574
10041
|
value.forEach((commit) => assertSha(commit, "Correction"));
|
|
9575
10042
|
}
|
|
10043
|
+
function assertProviderReceipt(value) {
|
|
10044
|
+
if (!isObject(value) || typeof value["versionId"] !== "string" || !value["versionId"].trim() || value["versionId"].length > 512 || /[\p{Cc}\p{Cf}]/u.test(value["versionId"]) || Object.keys(value).some((key) => !["versionId", "url"].includes(key))) throw new DocsDiagnosticError("receipt-invalid");
|
|
10045
|
+
if (value["url"] !== void 0) {
|
|
10046
|
+
let url;
|
|
10047
|
+
try {
|
|
10048
|
+
url = new URL(String(value["url"]));
|
|
10049
|
+
} catch {
|
|
10050
|
+
throw new DocsDiagnosticError("receipt-invalid");
|
|
10051
|
+
}
|
|
10052
|
+
if (typeof value["url"] !== "string" || !["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) throw new DocsDiagnosticError("receipt-invalid");
|
|
10053
|
+
}
|
|
10054
|
+
}
|
|
9576
10055
|
function assertStableSnapshot(value) {
|
|
9577
|
-
if (!isObject(value) || typeof value["sourceSha"] !== "string" || typeof value["treeSha"] !== "string" || !isObject(value["config"])) throw new
|
|
10056
|
+
if (!isObject(value) || typeof value["sourceSha"] !== "string" || typeof value["treeSha"] !== "string" || !isObject(value["config"])) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
9578
10057
|
assertIdentity(value["releaseId"]);
|
|
9579
10058
|
assertSha(value["sourceSha"]);
|
|
9580
10059
|
assertSha(value["treeSha"], "Source tree");
|
|
@@ -9585,7 +10064,9 @@ function assertStableSnapshot(value) {
|
|
|
9585
10064
|
validateSite(config);
|
|
9586
10065
|
}
|
|
9587
10066
|
async function readDocsState(context, site, channel) {
|
|
9588
|
-
const snapshot = await context.github.readAutomationState(context.key)
|
|
10067
|
+
const snapshot = await context.github.readAutomationState(context.key).catch(() => {
|
|
10068
|
+
throw new DocsDiagnosticError("checkpoint-read-failed");
|
|
10069
|
+
});
|
|
9589
10070
|
if (!snapshot) return { state: {
|
|
9590
10071
|
schemaVersion: 1,
|
|
9591
10072
|
repository: context.repository,
|
|
@@ -9593,10 +10074,10 @@ async function readDocsState(context, site, channel) {
|
|
|
9593
10074
|
channel
|
|
9594
10075
|
} };
|
|
9595
10076
|
const value = snapshot.value;
|
|
9596
|
-
if (!isObject(value) || value["schemaVersion"] !== 1 || value["repository"] !== context.repository || value["site"] !== site || value["channel"] !== channel) throw new
|
|
10077
|
+
if (!isObject(value) || value["schemaVersion"] !== 1 || value["repository"] !== context.repository || value["site"] !== site || value["channel"] !== channel) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
9597
10078
|
if (value["current"] !== void 0) {
|
|
9598
10079
|
const current = value["current"];
|
|
9599
|
-
if (!isObject(current) || typeof current["sourceSha"] !== "string" || typeof current["treeSha"] !== "string" || typeof current["versionId"] !== "string" || !current["versionId"]) throw new
|
|
10080
|
+
if (!isObject(current) || typeof current["sourceSha"] !== "string" || typeof current["treeSha"] !== "string" || typeof current["versionId"] !== "string" || !current["versionId"]) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
9600
10081
|
assertIdentity(current["deploymentId"]);
|
|
9601
10082
|
assertSha(current["sourceSha"]);
|
|
9602
10083
|
assertSha(current["treeSha"], "Source tree");
|
|
@@ -9605,15 +10086,30 @@ async function readDocsState(context, site, channel) {
|
|
|
9605
10086
|
}
|
|
9606
10087
|
if (value["pending"] !== void 0) {
|
|
9607
10088
|
const pending = value["pending"];
|
|
9608
|
-
if (!isObject(pending) || typeof pending["runId"] !== "string" || !pending["runId"] ||
|
|
10089
|
+
if (!isObject(pending) || typeof pending["runId"] !== "string" || !pending["runId"] || typeof pending["phase"] !== "string" || ![
|
|
10090
|
+
"building",
|
|
10091
|
+
"deploying",
|
|
10092
|
+
"verifying"
|
|
10093
|
+
].includes(pending["phase"])) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
9609
10094
|
assertIdentity(pending["deploymentId"]);
|
|
9610
10095
|
if (channel === "stable") assertStableSnapshot(pending["snapshot"]);
|
|
10096
|
+
if (pending["phase"] === "verifying") {
|
|
10097
|
+
assertProviderReceipt(pending["receipt"]);
|
|
10098
|
+
if (channel === "stable" && !pending["snapshot"].config.stable.readiness) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
10099
|
+
} else if (pending["receipt"] !== void 0) throw new DocsDiagnosticError("checkpoint-invalid");
|
|
9611
10100
|
}
|
|
9612
10101
|
return {
|
|
9613
10102
|
state: value,
|
|
9614
10103
|
revision: snapshot.revision
|
|
9615
10104
|
};
|
|
9616
10105
|
}
|
|
10106
|
+
async function writeDocsState(context, state, revision) {
|
|
10107
|
+
try {
|
|
10108
|
+
return await context.github.writeAutomationState(context.key, state, revision);
|
|
10109
|
+
} catch {
|
|
10110
|
+
throw new DocsDiagnosticError("checkpoint-write-failed");
|
|
10111
|
+
}
|
|
10112
|
+
}
|
|
9617
10113
|
//#endregion
|
|
9618
10114
|
//#region src/commands/docs/recovery.ts
|
|
9619
10115
|
async function prepareDocsContext(options) {
|
|
@@ -9624,7 +10120,7 @@ async function prepareDocsContext(options) {
|
|
|
9624
10120
|
const releaseId = options.channel === "stable" ? options.release ?? previous.state.current?.releaseId ?? snapshot?.releaseId : void 0;
|
|
9625
10121
|
const requestedCommits = [...new Set(options.commits ?? [])];
|
|
9626
10122
|
const recovery = snapshot?.releaseId === releaseId && JSON.stringify(snapshot?.requestedCommits) === JSON.stringify(requestedCommits) ? snapshot : void 0;
|
|
9627
|
-
if (options.channel === "stable" && pending
|
|
10123
|
+
if (options.channel === "stable" && pending && ["deploying", "verifying"].includes(pending.phase) && !recovery) throw new DocsDiagnosticError("deployment-unresolved");
|
|
9628
10124
|
return {
|
|
9629
10125
|
context: {
|
|
9630
10126
|
...identity,
|
|
@@ -9637,21 +10133,21 @@ async function prepareDocsContext(options) {
|
|
|
9637
10133
|
};
|
|
9638
10134
|
}
|
|
9639
10135
|
function assertRecoveredPlan(plan, snapshot, deploymentId) {
|
|
9640
|
-
if (plan.sourceSha !== snapshot.sourceSha || plan.releaseId !== snapshot.releaseId || plan.treeSha !== snapshot.treeSha || plan.deploymentId !== deploymentId || JSON.stringify(plan.commits) !== JSON.stringify(snapshot.commits)) throw new
|
|
10136
|
+
if (plan.sourceSha !== snapshot.sourceSha || plan.releaseId !== snapshot.releaseId || plan.treeSha !== snapshot.treeSha || plan.deploymentId !== deploymentId || JSON.stringify(plan.commits) !== JSON.stringify(snapshot.commits)) throw new DocsDiagnosticError("snapshot-mismatch");
|
|
9641
10137
|
}
|
|
9642
10138
|
//#endregion
|
|
9643
10139
|
//#region src/commands/docs/plan.ts
|
|
9644
10140
|
async function prepareDocsPlan(options) {
|
|
9645
|
-
if (options.channel === "preview" && (options.release || options.commits?.length)) throw new
|
|
9646
|
-
if (options.channel === "stable" && options.sourceSha) throw new
|
|
10141
|
+
if (options.channel === "preview" && (options.release || options.commits?.length)) throw new DocsDiagnosticError("preview-selection-invalid");
|
|
10142
|
+
if (options.channel === "stable" && options.sourceSha) throw new DocsDiagnosticError("stable-selection-invalid");
|
|
9647
10143
|
const { context, previous, releaseId, requestedCommits, recovery } = await prepareDocsContext(options);
|
|
9648
10144
|
const current = previous.state.current;
|
|
9649
10145
|
const blockers = [];
|
|
9650
10146
|
const record = releaseId ? await readReleaseCompletion(context.github, releaseId) : void 0;
|
|
9651
|
-
if (options.channel === "stable" && !record) throw new
|
|
9652
|
-
if (record && (record.repository !== context.repository || record.branch !== "main" || record.distTag !== "latest")) throw new
|
|
10147
|
+
if (options.channel === "stable" && !record) throw new DocsDiagnosticError("stable-baseline-missing");
|
|
10148
|
+
if (record && (record.repository !== context.repository || record.branch !== "main" || record.distTag !== "latest")) throw new DocsDiagnosticError("release-identity-mismatch");
|
|
9653
10149
|
const sourceSha = record?.sourceSha ?? options.sourceSha;
|
|
9654
|
-
if (!sourceSha) throw new
|
|
10150
|
+
if (!sourceSha) throw new DocsDiagnosticError("preview-source-missing");
|
|
9655
10151
|
assertMainSource(options.cwd, sourceSha);
|
|
9656
10152
|
if (options.channel === "preview" && git(options.cwd, ["rev-parse", "refs/remotes/origin/main"]) !== sourceSha) blockers.push("Preview source is no longer the latest fetched origin/main");
|
|
9657
10153
|
return withSource(options.cwd, sourceSha, async (source) => {
|
|
@@ -9717,81 +10213,657 @@ async function planDocsDeployment(options) {
|
|
|
9717
10213
|
return (await prepareDocsPlan(options)).plan;
|
|
9718
10214
|
}
|
|
9719
10215
|
//#endregion
|
|
9720
|
-
//#region src/commands/docs/
|
|
9721
|
-
|
|
9722
|
-
|
|
9723
|
-
|
|
9724
|
-
|
|
9725
|
-
if (
|
|
9726
|
-
|
|
9727
|
-
|
|
10216
|
+
//#region src/commands/docs/providers/cloudflare/client.ts
|
|
10217
|
+
const cloudflareApiOrigin = "https://api.cloudflare.com/client/v4";
|
|
10218
|
+
const versionPattern = /^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/i;
|
|
10219
|
+
const deploymentMessage = (deploymentId) => `repoctl-docs:${deploymentId}`;
|
|
10220
|
+
function validTimestamp(value) {
|
|
10221
|
+
if (typeof value !== "string" || !/^\d{4}-\d{2}-\d{2}T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(value) || !Number.isFinite(Date.parse(value))) return false;
|
|
10222
|
+
const date = value.slice(0, 10);
|
|
10223
|
+
return (/* @__PURE__ */ new Date(`${date}T00:00:00Z`)).toISOString().slice(0, 10) === date;
|
|
10224
|
+
}
|
|
10225
|
+
async function readPayload(response) {
|
|
10226
|
+
const reader = response.body?.getReader();
|
|
10227
|
+
if (!reader) throw new DocsDiagnosticError("provider-response-invalid");
|
|
10228
|
+
const chunks = [];
|
|
10229
|
+
let size = 0;
|
|
10230
|
+
try {
|
|
10231
|
+
while (true) {
|
|
10232
|
+
const chunk = await reader.read();
|
|
10233
|
+
if (chunk.done) break;
|
|
10234
|
+
size += chunk.value.length;
|
|
10235
|
+
if (size > 1048576) {
|
|
10236
|
+
await reader.cancel();
|
|
10237
|
+
throw new DocsDiagnosticError("provider-response-invalid");
|
|
10238
|
+
}
|
|
10239
|
+
chunks.push(chunk.value);
|
|
10240
|
+
}
|
|
10241
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
10242
|
+
} finally {
|
|
10243
|
+
reader.releaseLock();
|
|
10244
|
+
}
|
|
10245
|
+
}
|
|
10246
|
+
function cloudflareClient(target, env, request = fetch) {
|
|
10247
|
+
const token = env["CLOUDFLARE_API_TOKEN"];
|
|
10248
|
+
if (!token?.trim()) throw new DocsDiagnosticError("credentials-missing");
|
|
10249
|
+
if (env["CLOUDFLARE_ACCOUNT_ID"] && env["CLOUDFLARE_ACCOUNT_ID"] !== target.accountId || env["CF_ACCOUNT_ID"] && env["CF_ACCOUNT_ID"] !== target.accountId || env["CLOUDFLARE_API_BASE_URL"] && env["CLOUDFLARE_API_BASE_URL"] !== "https://api.cloudflare.com/client/v4" || env["CF_API_BASE_URL"] && env["CF_API_BASE_URL"] !== "https://api.cloudflare.com/client/v4" || env["CLOUDFLARE_API_KEY"] || env["CF_API_KEY"] || env["WRANGLER_CI_OVERRIDE_NAME"]) throw new DocsDiagnosticError("provider-environment-conflict");
|
|
10250
|
+
return async (endpoint, allowMissing = false) => {
|
|
10251
|
+
let response;
|
|
10252
|
+
let payload;
|
|
10253
|
+
try {
|
|
10254
|
+
response = await request(`${cloudflareApiOrigin}/accounts/${target.accountId}/workers/scripts/${encodeURIComponent(target.workerName)}/${endpoint}`, {
|
|
10255
|
+
headers: { Authorization: `Bearer ${token}` },
|
|
10256
|
+
redirect: "error",
|
|
10257
|
+
signal: AbortSignal.timeout(3e4)
|
|
10258
|
+
});
|
|
10259
|
+
payload = await readPayload(response);
|
|
10260
|
+
} catch (error) {
|
|
10261
|
+
if (error instanceof DocsDiagnosticError) throw error;
|
|
10262
|
+
throw new DocsDiagnosticError("provider-network-failed");
|
|
10263
|
+
}
|
|
10264
|
+
if (!isRecord$2(payload)) throw new DocsDiagnosticError("provider-response-invalid");
|
|
10265
|
+
const codes = Array.isArray(payload["errors"]) ? payload["errors"].flatMap((error) => isRecord$2(error) && Number.isSafeInteger(error["code"]) ? [error["code"]] : []) : [];
|
|
10266
|
+
if (allowMissing && endpoint === "deployments" && response.status === 404 && payload["success"] === false && Array.isArray(payload["errors"]) && payload["errors"].length === 1 && codes.length === 1 && codes[0] === 10007) return;
|
|
10267
|
+
if (!response.ok || payload["success"] !== true) throw new DocsDiagnosticError(response.status === 401 || response.status === 403 ? "provider-access-denied" : response.status === 429 ? "provider-rate-limited" : "provider-request-rejected");
|
|
10268
|
+
if (!isRecord$2(payload["result"]) || payload["errors"] !== void 0 && (!Array.isArray(payload["errors"]) || payload["errors"].length > 0)) throw new DocsDiagnosticError("provider-response-invalid");
|
|
10269
|
+
return payload["result"];
|
|
9728
10270
|
};
|
|
9729
|
-
|
|
9730
|
-
|
|
9731
|
-
const
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
10271
|
+
}
|
|
10272
|
+
async function activeMatchingVersion(client, deploymentId) {
|
|
10273
|
+
const result = await client("deployments", true);
|
|
10274
|
+
if (result === void 0) return;
|
|
10275
|
+
if (!isRecord$2(result) || !Array.isArray(result["deployments"]) || result["deployments"].length === 0) throw new DocsDiagnosticError("provider-response-invalid");
|
|
10276
|
+
const active = result["deployments"][0];
|
|
10277
|
+
if (!isRecord$2(active) || !validTimestamp(active["created_on"]) || active["strategy"] !== "percentage" || !Array.isArray(active["versions"]) || active["versions"].length !== 1) throw new DocsDiagnosticError("provider-traffic-ambiguous");
|
|
10278
|
+
const version = active["versions"][0];
|
|
10279
|
+
if (!isRecord$2(version) || version["percentage"] !== 100 || typeof version["version_id"] !== "string" || !versionPattern.test(version["version_id"])) throw new DocsDiagnosticError("provider-traffic-ambiguous");
|
|
10280
|
+
const versionId = version["version_id"];
|
|
10281
|
+
const detail = await client(`versions/${versionId}`);
|
|
10282
|
+
if (!isRecord$2(detail) || detail["id"] !== versionId || detail["annotations"] !== void 0 && !isRecord$2(detail["annotations"])) throw new DocsDiagnosticError("provider-version-mismatch");
|
|
10283
|
+
const message = isRecord$2(detail["annotations"]) ? detail["annotations"]["workers/message"] : void 0;
|
|
10284
|
+
if (message !== void 0 && typeof message !== "string") throw new DocsDiagnosticError("provider-response-invalid");
|
|
10285
|
+
return message === deploymentMessage(deploymentId) ? versionId : void 0;
|
|
10286
|
+
}
|
|
10287
|
+
//#endregion
|
|
10288
|
+
//#region src/commands/docs/providers/cloudflare/shape.ts
|
|
10289
|
+
const common = /* @__PURE__ */ new Set([
|
|
10290
|
+
"name",
|
|
10291
|
+
"account_id",
|
|
10292
|
+
"compatibility_date",
|
|
10293
|
+
"compatibility_flags",
|
|
10294
|
+
"workers_dev",
|
|
10295
|
+
"preview_urls",
|
|
10296
|
+
"assets",
|
|
10297
|
+
"route",
|
|
10298
|
+
"routes",
|
|
10299
|
+
"observability"
|
|
10300
|
+
]);
|
|
10301
|
+
function unsupported(field) {
|
|
10302
|
+
throw new DocsDiagnosticError(field === "generated Wrangler configuration" ? "generated-config" : field === "named environment must declare its own routes" ? "environment-routes-missing" : "unsupported-config");
|
|
10303
|
+
}
|
|
10304
|
+
function staticFields(value, root = false) {
|
|
10305
|
+
if (!isRecord$2(value)) return unsupported("object required");
|
|
10306
|
+
for (const [key, item] of Object.entries(value)) {
|
|
10307
|
+
if (item === null) unsupported(key);
|
|
10308
|
+
if (!common.has(key) && !(root && ["$schema", "env"].includes(key))) unsupported(key);
|
|
10309
|
+
if ([
|
|
10310
|
+
"name",
|
|
10311
|
+
"account_id",
|
|
10312
|
+
"$schema"
|
|
10313
|
+
].includes(key) && (typeof item !== "string" || !item.trim())) unsupported(key);
|
|
10314
|
+
if (["workers_dev", "preview_urls"].includes(key) && typeof item !== "boolean") unsupported(key);
|
|
10315
|
+
if (key === "compatibility_date" && (typeof item !== "string" || !/^\d{4}-\d{2}-\d{2}$/.test(item) || !Number.isFinite(Date.parse(item)) || new Date(item).toISOString().slice(0, 10) !== item)) unsupported(key);
|
|
10316
|
+
if (key === "compatibility_flags" && (!Array.isArray(item) || item.some((flag) => typeof flag !== "string" || !flag.trim()))) unsupported(key);
|
|
10317
|
+
if (key === "env" && !isRecord$2(item)) unsupported(key);
|
|
10318
|
+
if (key === "observability") {
|
|
10319
|
+
if (!isRecord$2(item) || Object.keys(item).some((field) => !["enabled", "head_sampling_rate"].includes(field)) || item["enabled"] !== void 0 && typeof item["enabled"] !== "boolean" || item["head_sampling_rate"] !== void 0 && (typeof item["head_sampling_rate"] !== "number" || !Number.isFinite(item["head_sampling_rate"]) || item["head_sampling_rate"] < 0 || item["head_sampling_rate"] > 1)) unsupported(key);
|
|
10320
|
+
}
|
|
10321
|
+
}
|
|
10322
|
+
return value;
|
|
10323
|
+
}
|
|
10324
|
+
function assetDirectory(value) {
|
|
10325
|
+
if (!isRecord$2(value) || Object.keys(value).some((key) => ![
|
|
10326
|
+
"directory",
|
|
10327
|
+
"html_handling",
|
|
10328
|
+
"not_found_handling"
|
|
10329
|
+
].includes(key)) || typeof value["directory"] !== "string" || !value["directory"] || value["html_handling"] !== void 0 && (typeof value["html_handling"] !== "string" || ![
|
|
10330
|
+
"auto-trailing-slash",
|
|
10331
|
+
"force-trailing-slash",
|
|
10332
|
+
"drop-trailing-slash",
|
|
10333
|
+
"none"
|
|
10334
|
+
].includes(value["html_handling"])) || value["not_found_handling"] !== void 0 && (typeof value["not_found_handling"] !== "string" || ![
|
|
10335
|
+
"none",
|
|
10336
|
+
"404-page",
|
|
10337
|
+
"single-page-application"
|
|
10338
|
+
].includes(value["not_found_handling"]))) return unsupported("assets");
|
|
10339
|
+
return value["directory"];
|
|
10340
|
+
}
|
|
10341
|
+
function customDomains(config) {
|
|
10342
|
+
if (config["route"] !== void 0 && config["routes"] !== void 0) return unsupported("route and routes");
|
|
10343
|
+
const routes = config["routes"] ?? (config["route"] === void 0 ? [] : [config["route"]]);
|
|
10344
|
+
if (!Array.isArray(routes)) return unsupported("routes");
|
|
10345
|
+
return routes.map((route) => {
|
|
10346
|
+
if (!isRecord$2(route) || Object.keys(route).some((key) => !["pattern", "custom_domain"].includes(key)) || route["custom_domain"] !== true || typeof route["pattern"] !== "string" || !/^(?:[a-z\d](?:[a-z\d-]{0,61}[a-z\d])?\.)+[a-z]{2,63}$/i.test(route["pattern"])) return unsupported("custom domain route");
|
|
10347
|
+
return route["pattern"].toLowerCase();
|
|
10348
|
+
});
|
|
10349
|
+
}
|
|
10350
|
+
//#endregion
|
|
10351
|
+
//#region src/commands/docs/providers/cloudflare/config.ts
|
|
10352
|
+
async function readCloudflareConfig(source, target) {
|
|
10353
|
+
if (!/^[a-f\d]{32}$/.test(target.accountId) || !/^[a-z\d][a-z\d-]{0,62}$/.test(target.workerName) || target.environment !== void 0 && !/^[\w-]+$/.test(target.environment)) throw new DocsDiagnosticError("provider-target-invalid");
|
|
10354
|
+
const filename = relativePath(source, target.config, "Cloudflare config");
|
|
10355
|
+
if (!/\.jsonc?$/.test(filename)) unsupported("config must be JSON or JSONC");
|
|
10356
|
+
await assertContainedPath(source, filename);
|
|
10357
|
+
const bytes = await readFile(filename, "utf8").catch(() => {
|
|
10358
|
+
throw new DocsDiagnosticError("provider-config-unreadable");
|
|
10359
|
+
});
|
|
10360
|
+
let raw;
|
|
10361
|
+
try {
|
|
10362
|
+
raw = parse$2(bytes);
|
|
10363
|
+
} catch {
|
|
10364
|
+
throw new DocsDiagnosticError("provider-config-invalid");
|
|
10365
|
+
}
|
|
10366
|
+
const root = staticFields(raw, true);
|
|
10367
|
+
const environment = target.environment ?? "";
|
|
10368
|
+
const selected = environment ? staticFields(isRecord$2(root["env"]) ? root["env"][environment] : void 0) : root;
|
|
10369
|
+
const effective = Object.fromEntries([
|
|
10370
|
+
"account_id",
|
|
10371
|
+
"assets",
|
|
10372
|
+
"route",
|
|
10373
|
+
"routes"
|
|
10374
|
+
].map((key) => [key, selected[key] ?? root[key]]));
|
|
10375
|
+
if ((selected["name"] ?? (environment && typeof root["name"] === "string" ? `${root["name"]}-${environment}` : root["name"])) !== target.workerName || effective["account_id"] !== void 0 && effective["account_id"] !== target.accountId) throw new DocsDiagnosticError("provider-identity-mismatch");
|
|
10376
|
+
if (environment && (root["route"] !== void 0 || root["routes"] !== void 0) && selected["route"] === void 0 && selected["routes"] === void 0) unsupported("named environment must declare its own routes");
|
|
10377
|
+
const domains = customDomains(effective);
|
|
10378
|
+
if (target.url) {
|
|
10379
|
+
const url = new URL(target.url);
|
|
10380
|
+
if (url.protocol !== "https:" || url.username || url.password || url.port || url.search || url.hash || url.pathname !== "/" || !domains.includes(url.hostname)) throw new DocsDiagnosticError("provider-domain-mismatch");
|
|
10381
|
+
}
|
|
10382
|
+
const output = relativePath(path.dirname(filename), assetDirectory(effective["assets"]), "Cloudflare assets.directory");
|
|
10383
|
+
await assertContainedPath(source, output);
|
|
10384
|
+
const directories = /* @__PURE__ */ new Set();
|
|
10385
|
+
const rootDirectory = path.resolve(source);
|
|
10386
|
+
for (let directory = path.dirname(filename);; directory = path.dirname(directory)) {
|
|
10387
|
+
directories.add(directory);
|
|
10388
|
+
if (directory === rootDirectory) break;
|
|
10389
|
+
}
|
|
10390
|
+
for (const directory of directories) {
|
|
10391
|
+
try {
|
|
10392
|
+
await access(path.join(directory, ".wrangler/deploy/config.json"));
|
|
10393
|
+
} catch (error) {
|
|
10394
|
+
if (error.code === "ENOENT") continue;
|
|
10395
|
+
throw error;
|
|
9742
10396
|
}
|
|
10397
|
+
unsupported("generated Wrangler configuration");
|
|
10398
|
+
}
|
|
10399
|
+
return {
|
|
10400
|
+
filename,
|
|
10401
|
+
output,
|
|
10402
|
+
domains,
|
|
10403
|
+
environment,
|
|
10404
|
+
digest: createHash("sha256").update(bytes).digest("hex"),
|
|
10405
|
+
target
|
|
9743
10406
|
};
|
|
9744
|
-
|
|
9745
|
-
|
|
10407
|
+
}
|
|
10408
|
+
async function preflightConfiguration(source, site, channel) {
|
|
10409
|
+
const target = site[channel];
|
|
10410
|
+
if (target.provider !== "cloudflare-workers") throw new DocsDiagnosticError("provider-target-invalid");
|
|
10411
|
+
const current = await readCloudflareConfig(source, target);
|
|
10412
|
+
const other = site[channel === "preview" ? "stable" : "preview"];
|
|
10413
|
+
if (other.provider === "cloudflare-workers") {
|
|
10414
|
+
if (other.accountId === target.accountId && other.workerName === target.workerName) throw new DocsDiagnosticError("provider-target-shared");
|
|
10415
|
+
const sibling = await readCloudflareConfig(source, other);
|
|
10416
|
+
if (current.domains.some((domain) => sibling.domains.includes(domain))) throw new DocsDiagnosticError("provider-domain-shared");
|
|
10417
|
+
}
|
|
10418
|
+
return current;
|
|
10419
|
+
}
|
|
10420
|
+
//#endregion
|
|
10421
|
+
//#region src/commands/docs/providers/cloudflare/wrangler.ts
|
|
10422
|
+
/** Unset alternate credentials and CI identity overrides; empty values can still override Wrangler config. */
|
|
10423
|
+
function wranglerEnvironment(env, accountId, environment, output) {
|
|
10424
|
+
const result = {
|
|
10425
|
+
...env,
|
|
10426
|
+
CLOUDFLARE_ACCOUNT_ID: accountId,
|
|
10427
|
+
CLOUDFLARE_API_BASE_URL: cloudflareApiOrigin,
|
|
10428
|
+
CLOUDFLARE_ENV: environment,
|
|
10429
|
+
WRANGLER_OUTPUT_FILE_PATH: output
|
|
10430
|
+
};
|
|
10431
|
+
delete result["CLOUDFLARE_API_KEY"];
|
|
10432
|
+
delete result["CF_API_KEY"];
|
|
10433
|
+
delete result["WRANGLER_CI_OVERRIDE_NAME"];
|
|
10434
|
+
return result;
|
|
10435
|
+
}
|
|
10436
|
+
/** Resolve the installed package directly; pnpm exec alone may fall through to a global PATH binary. */
|
|
10437
|
+
async function localWrangler(source, configFile) {
|
|
10438
|
+
let manifestPath;
|
|
9746
10439
|
try {
|
|
9747
|
-
|
|
9748
|
-
|
|
9749
|
-
|
|
9750
|
-
|
|
9751
|
-
|
|
9752
|
-
|
|
9753
|
-
|
|
9754
|
-
|
|
9755
|
-
|
|
9756
|
-
|
|
9757
|
-
|
|
9758
|
-
|
|
9759
|
-
|
|
9760
|
-
|
|
9761
|
-
|
|
10440
|
+
manifestPath = createRequire(path.join(path.dirname(configFile), "package.json")).resolve("wrangler/package.json");
|
|
10441
|
+
await assertContainedPath(source, manifestPath);
|
|
10442
|
+
} catch {
|
|
10443
|
+
throw new DocsDiagnosticError("wrangler-missing");
|
|
10444
|
+
}
|
|
10445
|
+
const physical = await realpath(manifestPath);
|
|
10446
|
+
if (!contained(await realpath(source), physical) || !path.normalize(physical).split("/").includes("node_modules")) throw new DocsDiagnosticError("wrangler-invalid");
|
|
10447
|
+
const manifest = JSON.parse(await readFile(manifestPath, "utf8"));
|
|
10448
|
+
const bin = isRecord$2(manifest) && isRecord$2(manifest["bin"]) ? manifest["bin"]["wrangler"] : void 0;
|
|
10449
|
+
if (!isRecord$2(manifest) || manifest["name"] !== "wrangler" || typeof bin !== "string") throw new DocsDiagnosticError("wrangler-invalid");
|
|
10450
|
+
const filename = path.resolve(path.dirname(manifestPath), bin);
|
|
10451
|
+
await assertContainedPath(source, filename);
|
|
10452
|
+
await access(filename);
|
|
10453
|
+
return filename;
|
|
10454
|
+
}
|
|
10455
|
+
async function readWranglerVersion(filename, worker, environment) {
|
|
10456
|
+
if ((await stat(filename)).size > 1048576) throw new DocsDiagnosticError("wrangler-result-invalid");
|
|
10457
|
+
let entries;
|
|
10458
|
+
try {
|
|
10459
|
+
entries = (await readFile(filename, "utf8")).split(/\r?\n/).filter((line) => line.trim()).map((line) => JSON.parse(line));
|
|
10460
|
+
} catch {
|
|
10461
|
+
throw new DocsDiagnosticError("wrangler-result-invalid");
|
|
10462
|
+
}
|
|
10463
|
+
const deployments = entries.filter((entry) => isRecord$2(entry) && entry["type"] === "deploy");
|
|
10464
|
+
const versions = /* @__PURE__ */ new Set();
|
|
10465
|
+
for (const entry of deployments) {
|
|
10466
|
+
if (!isRecord$2(entry) || entry["version"] !== 1 || entry["worker_name"] !== worker || (entry["wrangler_environment"] === void 0 ? "" : entry["wrangler_environment"]) !== environment || typeof entry["version_id"] !== "string" || !versionPattern.test(entry["version_id"])) throw new DocsDiagnosticError("wrangler-result-invalid");
|
|
10467
|
+
versions.add(entry["version_id"]);
|
|
10468
|
+
}
|
|
10469
|
+
if (versions.size !== 1) throw new DocsDiagnosticError("wrangler-result-invalid");
|
|
10470
|
+
return [...versions][0];
|
|
10471
|
+
}
|
|
10472
|
+
//#endregion
|
|
10473
|
+
//#region src/commands/docs/providers/index.ts
|
|
10474
|
+
/** Select a closed provider contract without changing script targets or frozen plan identities. */
|
|
10475
|
+
async function prepareDocsProvider(options, source, site, plan, env, resultFile, operation) {
|
|
10476
|
+
const target = site[plan.channel];
|
|
10477
|
+
if (target.provider !== "cloudflare-workers") return async () => async () => {
|
|
10478
|
+
runDocsProcess(options, source, ["run", target.deployScript], env);
|
|
10479
|
+
return readDeploymentResult(resultFile);
|
|
10480
|
+
};
|
|
10481
|
+
const config = await preflightConfiguration(source, site, plan.channel);
|
|
10482
|
+
const client = cloudflareClient(target, env, options.fetch);
|
|
10483
|
+
await activeMatchingVersion(client, plan.deploymentId);
|
|
10484
|
+
return async () => {
|
|
10485
|
+
const current = await preflightConfiguration(source, site, plan.channel);
|
|
10486
|
+
if (JSON.stringify(current) !== JSON.stringify(config)) throw new DocsDiagnosticError("provider-config-changed");
|
|
10487
|
+
await stampDocsManifest(source, config.output, plan);
|
|
10488
|
+
const cli = await localWrangler(source, config.filename);
|
|
10489
|
+
return async () => {
|
|
10490
|
+
let versionId = await activeMatchingVersion(client, plan.deploymentId);
|
|
10491
|
+
if (operation) operation.operation = versionId ? "reconcile" : "upload";
|
|
10492
|
+
if (!versionId) {
|
|
10493
|
+
const temporary = await mkdtemp(path.join(tmpdir(), "repoctl-docs-cloudflare-"));
|
|
10494
|
+
const output = path.join(temporary, "wrangler.jsonl");
|
|
10495
|
+
try {
|
|
10496
|
+
runDocsProcess(options, path.dirname(config.filename), [
|
|
10497
|
+
"exec",
|
|
10498
|
+
"node",
|
|
10499
|
+
cli,
|
|
10500
|
+
"deploy",
|
|
10501
|
+
"--config",
|
|
10502
|
+
config.filename,
|
|
10503
|
+
"--env",
|
|
10504
|
+
config.environment,
|
|
10505
|
+
"--message",
|
|
10506
|
+
deploymentMessage(plan.deploymentId)
|
|
10507
|
+
], wranglerEnvironment(env, target.accountId, config.environment, output));
|
|
10508
|
+
versionId = await readWranglerVersion(output, target.workerName, config.environment);
|
|
10509
|
+
if (await activeMatchingVersion(client, plan.deploymentId) !== versionId) throw new DocsDiagnosticError("provider-version-inactive");
|
|
10510
|
+
} finally {
|
|
10511
|
+
await rm(temporary, {
|
|
10512
|
+
recursive: true,
|
|
10513
|
+
force: true
|
|
10514
|
+
});
|
|
9762
10515
|
}
|
|
10516
|
+
}
|
|
10517
|
+
return {
|
|
10518
|
+
versionId,
|
|
10519
|
+
...target.url ? { url: target.url } : {}
|
|
9763
10520
|
};
|
|
9764
|
-
|
|
9765
|
-
|
|
9766
|
-
|
|
9767
|
-
|
|
9768
|
-
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9772
|
-
|
|
9773
|
-
|
|
9774
|
-
|
|
9775
|
-
|
|
9776
|
-
|
|
9777
|
-
|
|
9778
|
-
|
|
9779
|
-
|
|
10521
|
+
};
|
|
10522
|
+
};
|
|
10523
|
+
}
|
|
10524
|
+
/** Recovery never uploads: the exact saved version must still own all active traffic. */
|
|
10525
|
+
async function reconcileDocsProvider(options, site, plan, env, receipt) {
|
|
10526
|
+
const target = site[plan.channel];
|
|
10527
|
+
if (target.provider === "cloudflare-workers") {
|
|
10528
|
+
if (await activeMatchingVersion(cloudflareClient(target, env, options.fetch), plan.deploymentId) !== receipt.versionId) throw new DocsDiagnosticError("saved-version-inactive");
|
|
10529
|
+
}
|
|
10530
|
+
}
|
|
10531
|
+
//#endregion
|
|
10532
|
+
//#region src/commands/docs/report/safety.ts
|
|
10533
|
+
const stageOrder = [
|
|
10534
|
+
"plan",
|
|
10535
|
+
"preflight",
|
|
10536
|
+
"install",
|
|
10537
|
+
"build",
|
|
10538
|
+
"provider",
|
|
10539
|
+
"readiness",
|
|
10540
|
+
"finalize"
|
|
10541
|
+
];
|
|
10542
|
+
const skipReasons = /* @__PURE__ */ new Set([
|
|
10543
|
+
"not-required",
|
|
10544
|
+
"already-completed",
|
|
10545
|
+
"resumed-verification",
|
|
10546
|
+
"not-run"
|
|
10547
|
+
]);
|
|
10548
|
+
const readinessReasons = /* @__PURE__ */ new Set([
|
|
10549
|
+
"identity-mismatch",
|
|
10550
|
+
"invalid-payload",
|
|
10551
|
+
"invalid-json",
|
|
10552
|
+
"response-too-large",
|
|
10553
|
+
"http-status",
|
|
10554
|
+
"network-error",
|
|
10555
|
+
"request-timeout"
|
|
10556
|
+
]);
|
|
10557
|
+
function safeSkipReason(reason) {
|
|
10558
|
+
return skipReasons.has(reason) ? reason : "not-run";
|
|
10559
|
+
}
|
|
10560
|
+
function safeFailureReason(error, stage) {
|
|
10561
|
+
if (error instanceof DocsDiagnosticError && docsDiagnosticMessage(error.reason)) return error.reason;
|
|
10562
|
+
if (error instanceof DocsReadinessError && readinessReasons.has(error.reason)) return error.reason;
|
|
10563
|
+
return `${stage}-failed`;
|
|
10564
|
+
}
|
|
10565
|
+
function safeFailureMessage(reason) {
|
|
10566
|
+
return docsDiagnosticMessage(reason);
|
|
10567
|
+
}
|
|
10568
|
+
/** Defense in depth for public IDs; never inspect or serialize a caught error's data. */
|
|
10569
|
+
function identityRedactor(env) {
|
|
10570
|
+
const secrets = Object.entries(env).flatMap(([key, value]) => /TOKEN|SECRET|PASSWORD|API_KEY|AUTHORIZATION|COOKIE/i.test(key) && value && value.length >= 4 ? [value] : []);
|
|
10571
|
+
return (value) => {
|
|
10572
|
+
if (secrets.some((secret) => value.includes(secret))) return "[redacted]";
|
|
10573
|
+
return /^[a-z\d][\w.:-]{0,255}$/i.test(value) ? value : "[unavailable]";
|
|
10574
|
+
};
|
|
10575
|
+
}
|
|
10576
|
+
function duration(start, end) {
|
|
10577
|
+
return Number.isFinite(start) && Number.isFinite(end) ? Math.max(0, Math.round(end - start)) : 0;
|
|
10578
|
+
}
|
|
10579
|
+
//#endregion
|
|
10580
|
+
//#region src/commands/docs/report/summary.ts
|
|
10581
|
+
function escape$1(value) {
|
|
10582
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("`", "`").replaceAll("|", "|").replace(/[\p{Cc}\p{Cf}]+/gu, " ").replace(/[[\]()!*_\\~]/g, (character) => `&#${character.charCodeAt(0)};`);
|
|
10583
|
+
}
|
|
10584
|
+
/** One attempt only; user script output and HTTP response bodies never enter this summary. */
|
|
10585
|
+
function formatDocsSummary(report) {
|
|
10586
|
+
const lines = [
|
|
10587
|
+
"## Documentation deployment",
|
|
10588
|
+
"",
|
|
10589
|
+
`Site: \`${escape$1(report.site)}\` · Channel: \`${escape$1(report.channel)}\``,
|
|
10590
|
+
"",
|
|
10591
|
+
`Status: ${escape$1(report.status)} · Attempt duration: ${report.elapsedMs} ms`,
|
|
10592
|
+
"",
|
|
10593
|
+
`Started: ${escape$1(report.startedAt)}`,
|
|
10594
|
+
""
|
|
10595
|
+
];
|
|
10596
|
+
if (report.deploymentId) lines.push(`Deployment: \`${escape$1(report.deploymentId)}\``, "");
|
|
10597
|
+
if (report.versionId) lines.push(`Provider version: \`${escape$1(report.versionId)}\``, "");
|
|
10598
|
+
if (report.failedStage) lines.push(`Failed stage: \`${escape$1(report.failedStage)}\``, "");
|
|
10599
|
+
if (report.resumablePhase) {
|
|
10600
|
+
lines.push(`Saved phase: \`${escape$1(report.resumablePhase)}\`. Retry the same deployment to resume.`, "");
|
|
10601
|
+
if (report.resumablePhase === "verifying") lines.push("The provider receipt is saved. Public traffic may already serve that version; the current pointer remains at the previous fully verified deployment until readiness and finalization succeed.", "");
|
|
10602
|
+
}
|
|
10603
|
+
lines.push("| Stage | Status | Duration (ms) | Operation | Reason |", "| --- | --- | ---: | --- | --- |");
|
|
10604
|
+
for (const entry of report.stages) lines.push(`| ${escape$1(entry.stage)} | ${escape$1(entry.status)} | ${entry.elapsedMs} | ${escape$1(entry.operation ?? "")} | ${escape$1(entry.reason ?? "")} |`);
|
|
10605
|
+
for (const entry of report.stages) if (entry.message) lines.push("", `${escape$1(entry.stage)}: ${escape$1(entry.message)}`);
|
|
10606
|
+
return `${lines.join("\n")}\n`;
|
|
10607
|
+
}
|
|
10608
|
+
async function writeDocsSummary(report, filename) {
|
|
10609
|
+
if (!filename) return;
|
|
10610
|
+
try {
|
|
10611
|
+
await appendFile(filename, formatDocsSummary(report));
|
|
10612
|
+
} catch {
|
|
10613
|
+
report.warnings = [.../* @__PURE__ */ new Set([...report.warnings ?? [], "summary-write-failed"])];
|
|
10614
|
+
}
|
|
10615
|
+
}
|
|
10616
|
+
//#endregion
|
|
10617
|
+
//#region src/commands/docs/report/index.ts
|
|
10618
|
+
var DocsDeploymentError = class extends Error {
|
|
10619
|
+
report;
|
|
10620
|
+
constructor(report) {
|
|
10621
|
+
const stage = stageOrder.find((item) => item === report.failedStage) ?? "plan";
|
|
10622
|
+
const reason = report.stages.find((item) => item.stage === stage && item.status === "failed")?.reason;
|
|
10623
|
+
const message = reason ? safeFailureMessage(reason) : void 0;
|
|
10624
|
+
super(`Documentation deployment failed during ${stage}. ${message ?? "Inspect the deployment report and retry the same deployment when applicable."}`);
|
|
10625
|
+
this.name = "DocsDeploymentError";
|
|
10626
|
+
this.report = report;
|
|
10627
|
+
}
|
|
10628
|
+
};
|
|
10629
|
+
/** Track work without retaining exceptions, credentials, provider bodies or configuration. */
|
|
10630
|
+
function createDocsReport(options, clock = {
|
|
10631
|
+
now: () => performance.now(),
|
|
10632
|
+
timestamp: () => /* @__PURE__ */ new Date()
|
|
10633
|
+
}) {
|
|
10634
|
+
const env = options.env ?? process.env;
|
|
10635
|
+
const redact = identityRedactor(env);
|
|
10636
|
+
const start = clock.now();
|
|
10637
|
+
const startedAt = clock.timestamp().toISOString();
|
|
10638
|
+
const stages = /* @__PURE__ */ new Map();
|
|
10639
|
+
let failedStage;
|
|
10640
|
+
let deploymentId;
|
|
10641
|
+
let finished;
|
|
10642
|
+
async function finish(status, resumablePhase, versionId) {
|
|
10643
|
+
if (finished) return finished;
|
|
10644
|
+
finished = {
|
|
10645
|
+
schemaVersion: 1,
|
|
10646
|
+
site: redact(options.site),
|
|
10647
|
+
channel: options.channel === "stable" ? "stable" : "preview",
|
|
10648
|
+
startedAt,
|
|
10649
|
+
elapsedMs: duration(start, clock.now()),
|
|
10650
|
+
status,
|
|
10651
|
+
stages: stageOrder.map((stage) => stages.get(stage) ?? {
|
|
10652
|
+
stage,
|
|
10653
|
+
status: "skipped",
|
|
10654
|
+
elapsedMs: 0,
|
|
10655
|
+
reason: "not-run"
|
|
10656
|
+
}),
|
|
10657
|
+
...failedStage ? { failedStage } : {},
|
|
10658
|
+
...resumablePhase ? { resumablePhase } : {},
|
|
10659
|
+
...deploymentId ? { deploymentId } : {},
|
|
10660
|
+
...versionId ? { versionId: redact(versionId) } : {}
|
|
10661
|
+
};
|
|
10662
|
+
await writeDocsSummary(finished, env["GITHUB_STEP_SUMMARY"]);
|
|
10663
|
+
return finished;
|
|
10664
|
+
}
|
|
10665
|
+
return {
|
|
10666
|
+
async run(stage, fn, metadata = {}) {
|
|
10667
|
+
const before = clock.now();
|
|
10668
|
+
try {
|
|
10669
|
+
const result = await fn();
|
|
10670
|
+
stages.set(stage, {
|
|
10671
|
+
stage,
|
|
10672
|
+
status: "completed",
|
|
10673
|
+
elapsedMs: duration(before, clock.now()),
|
|
10674
|
+
...metadata.operation ? { operation: metadata.operation } : {}
|
|
10675
|
+
});
|
|
10676
|
+
return result;
|
|
10677
|
+
} catch (error) {
|
|
10678
|
+
failedStage ??= stage;
|
|
10679
|
+
const reason = safeFailureReason(error, stage);
|
|
10680
|
+
const message = safeFailureMessage(reason);
|
|
10681
|
+
stages.set(stage, {
|
|
10682
|
+
stage,
|
|
10683
|
+
status: "failed",
|
|
10684
|
+
elapsedMs: duration(before, clock.now()),
|
|
10685
|
+
reason,
|
|
10686
|
+
...message ? { message } : {},
|
|
10687
|
+
...metadata.operation ? { operation: metadata.operation } : {}
|
|
10688
|
+
});
|
|
10689
|
+
throw error;
|
|
10690
|
+
}
|
|
10691
|
+
},
|
|
10692
|
+
skip(stage, reason) {
|
|
10693
|
+
stages.set(stage, {
|
|
10694
|
+
stage,
|
|
10695
|
+
status: "skipped",
|
|
10696
|
+
elapsedMs: 0,
|
|
10697
|
+
reason: safeSkipReason(reason)
|
|
10698
|
+
});
|
|
10699
|
+
},
|
|
10700
|
+
setIdentity(plan) {
|
|
10701
|
+
deploymentId = redact(plan.deploymentId);
|
|
10702
|
+
},
|
|
10703
|
+
finish,
|
|
10704
|
+
async fail(error, resumablePhase, versionId) {
|
|
10705
|
+
if (!failedStage) {
|
|
10706
|
+
failedStage = "plan";
|
|
10707
|
+
const reason = safeFailureReason(error, "plan");
|
|
10708
|
+
const message = safeFailureMessage(reason);
|
|
10709
|
+
stages.set("plan", {
|
|
10710
|
+
stage: "plan",
|
|
10711
|
+
status: "failed",
|
|
10712
|
+
elapsedMs: duration(start, clock.now()),
|
|
10713
|
+
reason,
|
|
10714
|
+
...message ? { message } : {}
|
|
10715
|
+
});
|
|
10716
|
+
}
|
|
10717
|
+
return new DocsDeploymentError(await finish("failed", resumablePhase, versionId));
|
|
10718
|
+
}
|
|
10719
|
+
};
|
|
10720
|
+
}
|
|
10721
|
+
//#endregion
|
|
10722
|
+
//#region src/commands/docs/deploy.ts
|
|
10723
|
+
/** Build, deploy and optionally verify an independently recoverable documentation snapshot. */
|
|
10724
|
+
async function deployDocs(options) {
|
|
10725
|
+
const report = createDocsReport(options);
|
|
10726
|
+
let cleanup;
|
|
10727
|
+
let resumablePhase;
|
|
10728
|
+
let receipt;
|
|
10729
|
+
try {
|
|
10730
|
+
const { plan, previous, context, snapshot } = await report.run("plan", async () => {
|
|
10731
|
+
const prepared = await prepareDocsPlan(options);
|
|
10732
|
+
report.setIdentity(prepared.plan);
|
|
10733
|
+
if (!prepared.plan.eligible) throw new DocsDiagnosticError("plan-blocked");
|
|
10734
|
+
return prepared;
|
|
10735
|
+
});
|
|
10736
|
+
if (plan.skipped) return {
|
|
10737
|
+
plan,
|
|
10738
|
+
status: "skipped",
|
|
10739
|
+
report: await report.finish("skipped")
|
|
10740
|
+
};
|
|
10741
|
+
const target = context.site[options.channel];
|
|
10742
|
+
const pending = previous.state.pending;
|
|
10743
|
+
const sameDeployment = pending?.deploymentId === plan.deploymentId;
|
|
10744
|
+
const resumeVerification = sameDeployment && pending?.phase === "verifying";
|
|
10745
|
+
const resumeProvider = sameDeployment && pending?.phase === "deploying";
|
|
10746
|
+
const runId = context.env["GITHUB_RUN_ID"] ?? randomUUID();
|
|
10747
|
+
let state = {
|
|
10748
|
+
...previous.state,
|
|
10749
|
+
pending: {
|
|
10750
|
+
deploymentId: plan.deploymentId,
|
|
10751
|
+
runId,
|
|
10752
|
+
phase: resumeVerification ? "verifying" : resumeProvider ? "deploying" : "building",
|
|
10753
|
+
...resumeVerification ? { receipt: pending.receipt } : {},
|
|
10754
|
+
...snapshot ? { snapshot } : {}
|
|
10755
|
+
}
|
|
10756
|
+
};
|
|
10757
|
+
let revision;
|
|
10758
|
+
const claim = async () => {
|
|
10759
|
+
const serialized = context.env["GITHUB_ACTIONS"] === "true" && Boolean(context.env["GITHUB_RUN_ID"]) && context.env["REPO_DOCS_CONCURRENCY_GROUP"] === `docs-${options.site}-${options.channel}`;
|
|
10760
|
+
if (options.channel === "stable" && !serialized) throw new DocsDiagnosticError("workflow-required");
|
|
10761
|
+
if (pending && (!serialized || options.channel === "stable" && pending.phase !== "building" && !sameDeployment)) throw new DocsDiagnosticError("deployment-unresolved");
|
|
10762
|
+
if (resumeVerification && !target.readiness) throw new DocsDiagnosticError("readiness-policy-missing");
|
|
10763
|
+
revision = await writeDocsState(context, state, previous.revision);
|
|
10764
|
+
resumablePhase = resumeVerification ? "verifying" : resumeProvider ? "deploying" : void 0;
|
|
10765
|
+
cleanup = async () => {
|
|
10766
|
+
if (!resumablePhase) {
|
|
10767
|
+
const { pending: _pending, ...idle } = state;
|
|
10768
|
+
await writeDocsState(context, idle, revision);
|
|
9780
10769
|
}
|
|
9781
10770
|
};
|
|
9782
|
-
|
|
10771
|
+
};
|
|
10772
|
+
const assertClaim = async () => {
|
|
10773
|
+
const latest = await readDocsState(context, options.site, options.channel);
|
|
10774
|
+
if (latest.revision !== revision || latest.state.pending?.deploymentId !== plan.deploymentId || latest.state.pending.runId !== runId) throw new DocsDiagnosticError("claim-changed");
|
|
10775
|
+
if (options.channel === "preview" && await context.github.readBranchHead("main") !== plan.sourceSha) throw new DocsDiagnosticError("main-advanced");
|
|
10776
|
+
};
|
|
10777
|
+
const verifyAndComplete = async (result) => {
|
|
10778
|
+
if (target.readiness) await report.run("readiness", () => verifyDocsReadiness(target, plan, options.fetch));
|
|
10779
|
+
else report.skip("readiness", "not-required");
|
|
10780
|
+
await report.run("finalize", async () => {
|
|
10781
|
+
await assertClaim();
|
|
10782
|
+
if (target.readiness) {
|
|
10783
|
+
await reconcileDocsProvider(options, context.site, plan, context.env, result);
|
|
10784
|
+
await assertClaim();
|
|
10785
|
+
}
|
|
10786
|
+
const complete = {
|
|
10787
|
+
schemaVersion: 1,
|
|
10788
|
+
repository: context.repository,
|
|
10789
|
+
site: options.site,
|
|
10790
|
+
channel: options.channel,
|
|
10791
|
+
current: {
|
|
10792
|
+
deploymentId: plan.deploymentId,
|
|
10793
|
+
sourceSha: plan.sourceSha,
|
|
10794
|
+
...plan.releaseId ? { releaseId: plan.releaseId } : {},
|
|
10795
|
+
commits: plan.commits,
|
|
10796
|
+
treeSha: plan.treeSha,
|
|
10797
|
+
...result
|
|
10798
|
+
}
|
|
10799
|
+
};
|
|
10800
|
+
await writeDocsState(context, complete, revision);
|
|
10801
|
+
cleanup = void 0;
|
|
10802
|
+
resumablePhase = void 0;
|
|
10803
|
+
});
|
|
9783
10804
|
return {
|
|
9784
10805
|
plan,
|
|
9785
10806
|
status: "deployed",
|
|
9786
|
-
...result
|
|
10807
|
+
...result,
|
|
10808
|
+
report: await report.finish("deployed", void 0, result.versionId)
|
|
9787
10809
|
};
|
|
9788
|
-
}
|
|
9789
|
-
|
|
9790
|
-
|
|
9791
|
-
|
|
9792
|
-
|
|
10810
|
+
};
|
|
10811
|
+
if (resumeVerification) {
|
|
10812
|
+
await report.run("preflight", claim);
|
|
10813
|
+
receipt = pending.receipt;
|
|
10814
|
+
report.skip("install", "resumed-verification");
|
|
10815
|
+
report.skip("build", "resumed-verification");
|
|
10816
|
+
await report.run("provider", () => reconcileDocsProvider(options, context.site, plan, context.env, receipt), { operation: "reconcile" });
|
|
10817
|
+
return await verifyAndComplete(receipt);
|
|
9793
10818
|
}
|
|
9794
|
-
|
|
10819
|
+
return await verifyAndComplete(await withSource(options.cwd, plan.sourceSha, async (source) => {
|
|
10820
|
+
const resultFile = path.join(path.dirname(source), "deployment-result.json");
|
|
10821
|
+
const env = docsEnvironment(context, plan, resultFile);
|
|
10822
|
+
const operation = { operation: "upload" };
|
|
10823
|
+
const prepareProvider = await report.run("preflight", async () => {
|
|
10824
|
+
await claim();
|
|
10825
|
+
applyDocsPatches(options.cwd, source, plan.sourceSha, plan.commits, context.site);
|
|
10826
|
+
if (git(source, ["write-tree"]) !== plan.treeSha) throw new DocsDiagnosticError("source-tree-changed");
|
|
10827
|
+
return prepareDocsProvider(options, source, context.site, plan, env, resultFile, operation);
|
|
10828
|
+
});
|
|
10829
|
+
await report.run("install", () => runDocsProcess(options, source, ["install", "--frozen-lockfile"], docsInstallEnvironment(context.env)));
|
|
10830
|
+
await report.run("build", () => runDocsProcess(options, source, ["run", context.site.buildScript], env));
|
|
10831
|
+
receipt = await report.run("provider", async () => {
|
|
10832
|
+
await assertClaim();
|
|
10833
|
+
const deploy = await prepareProvider();
|
|
10834
|
+
state = {
|
|
10835
|
+
...state,
|
|
10836
|
+
pending: {
|
|
10837
|
+
...state.pending,
|
|
10838
|
+
phase: "deploying"
|
|
10839
|
+
}
|
|
10840
|
+
};
|
|
10841
|
+
revision = await writeDocsState(context, state, revision);
|
|
10842
|
+
resumablePhase = "deploying";
|
|
10843
|
+
const result = await deploy();
|
|
10844
|
+
receipt = result;
|
|
10845
|
+
if (target.readiness) {
|
|
10846
|
+
assertProviderReceipt(result);
|
|
10847
|
+
state = {
|
|
10848
|
+
...state,
|
|
10849
|
+
pending: {
|
|
10850
|
+
...state.pending,
|
|
10851
|
+
phase: "verifying",
|
|
10852
|
+
receipt: result
|
|
10853
|
+
}
|
|
10854
|
+
};
|
|
10855
|
+
revision = await writeDocsState(context, state, revision);
|
|
10856
|
+
resumablePhase = "verifying";
|
|
10857
|
+
}
|
|
10858
|
+
return result;
|
|
10859
|
+
}, operation);
|
|
10860
|
+
return receipt;
|
|
10861
|
+
}));
|
|
10862
|
+
} catch (error) {
|
|
10863
|
+
try {
|
|
10864
|
+
await cleanup?.();
|
|
10865
|
+
} catch {}
|
|
10866
|
+
throw await report.fail(error, resumablePhase, receipt?.versionId);
|
|
9795
10867
|
}
|
|
9796
10868
|
}
|
|
9797
10869
|
//#endregion
|
|
@@ -10715,6 +11787,7 @@ async function generate(options, report) {
|
|
|
10715
11787
|
overwriteRelease: false
|
|
10716
11788
|
});
|
|
10717
11789
|
report.plan = plan;
|
|
11790
|
+
if (plan.files.some((file) => file.workspacePolicy?.findings.some((finding) => ["unverified", "deferred"].includes(finding.status)))) throw new Error("Root override scope requires a reviewed manual upgrade; automatic maintenance cannot accept unverified selectors or replacements, including deferred hook migration decisions. Complete the hook migration with repo upgrade first, then review a new plan.");
|
|
10718
11791
|
if (plan.status !== "ready" || plan.files.some((file) => file.status === "conflict")) throw new Error(`Root asset upgrade has conflicts: ${plan.blockers.map((blocker) => blocker.detail).join("; ")}`);
|
|
10719
11792
|
const migrationPath = await maintenanceMigrationPath(options.cwd, report.head, report.versions.to, plan);
|
|
10720
11793
|
if (await realpath(plan.rootDir) !== options.cwd || plan.files.some((file) => !isRootAsset(file.path) && file.path !== migrationPath)) throw new Error("Maintenance supports only managed root assets in the checked-out repository.");
|
|
@@ -10831,6 +11904,32 @@ async function getMaintenanceWorkflow(cwd) {
|
|
|
10831
11904
|
return template.replace(" __VALIDATOR__", () => script.split("\n").map((line) => ` ${line}`).join("\n")).replace("__TARGETS__", () => JSON.stringify(getAssetTargets())).replace("__PRESET_ASSETS__", () => JSON.stringify(policy)).replace("__MIGRATION_POLICY__", () => JSON.stringify(getMaintenanceMigrationPolicy()));
|
|
10832
11905
|
}
|
|
10833
11906
|
//#endregion
|
|
11907
|
+
//#region src/commands/package-check/consumer/runtime-assets.ts
|
|
11908
|
+
function consumerRuntimeAssets(manifest) {
|
|
11909
|
+
const assets = manifest.repoctl?.packageCheck?.runtimeAssets ?? [];
|
|
11910
|
+
const result = /* @__PURE__ */ new Set();
|
|
11911
|
+
if (!Array.isArray(assets)) throw new TypeError(`Package ${manifest.name} repoctl.packageCheck.runtimeAssets must list exact export subpaths.`);
|
|
11912
|
+
for (const asset of assets) {
|
|
11913
|
+
if (typeof asset !== "string" || asset !== "." && !asset.startsWith("./") || asset.includes("*") || asset.includes("\\") || asset.split("/").includes("..")) throw new Error(`Package ${manifest.name} repoctl.packageCheck.runtimeAssets must list exact export subpaths.`);
|
|
11914
|
+
result.add(asset);
|
|
11915
|
+
}
|
|
11916
|
+
return result;
|
|
11917
|
+
}
|
|
11918
|
+
/** Resolve resources through the consumer's real export map without executing browser globals. */
|
|
11919
|
+
function consumerAssetSource(entry, specifier, installed) {
|
|
11920
|
+
const resolve = entry.format === "esm" ? `process.getBuiltinModule("node:url").fileURLToPath(import.meta.resolve(${JSON.stringify(specifier)}))` : `require.resolve(${JSON.stringify(specifier)})`;
|
|
11921
|
+
return [
|
|
11922
|
+
"const fs = process.getBuiltinModule(\"node:fs\");",
|
|
11923
|
+
"const path = process.getBuiltinModule(\"node:path\");",
|
|
11924
|
+
`const root = fs.realpathSync.native(${JSON.stringify(installed)});`,
|
|
11925
|
+
`const filename = fs.realpathSync.native(${resolve});`,
|
|
11926
|
+
`const expected = fs.realpathSync.native(path.resolve(root, ${JSON.stringify(entry.target)}));`,
|
|
11927
|
+
"const relative = path.relative(root, filename);",
|
|
11928
|
+
"if (!relative || relative === \"..\" || relative.startsWith(\"..\" + path.sep) || path.isAbsolute(relative) || filename !== expected || !fs.statSync(filename).isFile()) throw new Error(\"Exported runtime asset does not resolve to its checked package file.\");",
|
|
11929
|
+
"fs.readFileSync(filename);"
|
|
11930
|
+
].join("\n");
|
|
11931
|
+
}
|
|
11932
|
+
//#endregion
|
|
10834
11933
|
//#region src/commands/package-check/entries.ts
|
|
10835
11934
|
function resolveTarget(value, conditions) {
|
|
10836
11935
|
if (typeof value === "string") return value;
|
|
@@ -10861,6 +11960,7 @@ function expand(subpath, target, files) {
|
|
|
10861
11960
|
}
|
|
10862
11961
|
/** Only exercise declared Node entrypoints; browser/assets/type-only paths are not Node modules. */
|
|
10863
11962
|
function consumerEntries(manifest, files) {
|
|
11963
|
+
const assets = consumerRuntimeAssets(manifest);
|
|
10864
11964
|
const exports = manifest.exports;
|
|
10865
11965
|
const mappings = exports && typeof exports === "object" && !Array.isArray(exports) && Object.keys(exports).some((key) => key.startsWith(".")) ? exports : { ".": exports !== void 0 ? exports : manifest.main ?? (files.includes("index.js") ? "./index.js" : void 0) };
|
|
10866
11966
|
const entries = [];
|
|
@@ -10880,16 +11980,29 @@ function consumerEntries(manifest, files) {
|
|
|
10880
11980
|
])) ?? (subpath === "." ? manifest.types : void 0);
|
|
10881
11981
|
if (!target || !runtime && !/\.d\.[cm]?ts$/u.test(target)) continue;
|
|
10882
11982
|
if ((/\.(?:mjs|mts)$/u.test(target) || !/\.(?:cjs|cts)$/u.test(target) && manifest.type === "module" ? "esm" : "cjs") !== format && !declaresCondition(value, condition)) continue;
|
|
10883
|
-
for (const expanded of expand(subpath, target, files))
|
|
10884
|
-
|
|
10885
|
-
|
|
10886
|
-
|
|
10887
|
-
|
|
11983
|
+
for (const expanded of expand(subpath, target, files)) {
|
|
11984
|
+
const asset = assets.has(expanded.subpath);
|
|
11985
|
+
const declaration = expanded.target.replace(/\.([cm]?)js$/u, ".d.$1ts").replace(/^\.\//u, "");
|
|
11986
|
+
const typecheck = declaresCondition(value, "types") || expanded.subpath === "." && typeof manifest.types === "string" || files.includes(declaration);
|
|
11987
|
+
entries.push({
|
|
11988
|
+
...expanded,
|
|
11989
|
+
format,
|
|
11990
|
+
runtime,
|
|
11991
|
+
...asset ? {
|
|
11992
|
+
asset: true,
|
|
11993
|
+
typecheck
|
|
11994
|
+
} : {}
|
|
11995
|
+
});
|
|
11996
|
+
}
|
|
11997
|
+
}
|
|
11998
|
+
for (const asset of assets) {
|
|
11999
|
+
const matches = entries.filter((entry) => entry.subpath === asset && entry.runtime);
|
|
12000
|
+
if (!matches.length || matches.some((entry) => !entry.target.startsWith("./") || entry.target.split(/[\\/]/u).includes("..") || !files.includes(entry.target.slice(2)))) throw new Error(`Runtime asset ${manifest.name}${asset.slice(1)} must name a packed JavaScript export.`);
|
|
10888
12001
|
}
|
|
10889
12002
|
return entries;
|
|
10890
12003
|
}
|
|
10891
12004
|
function supportsResolution(entries, subpath, kind, legacy) {
|
|
10892
|
-
entries = entries.filter((entry) => entry.runtime);
|
|
12005
|
+
entries = entries.filter((entry) => entry.runtime && entry.typecheck !== false);
|
|
10893
12006
|
if (kind === "node10") return legacy && entries.some((entry) => entry.subpath === subpath);
|
|
10894
12007
|
return entries.some((entry) => entry.subpath === subpath && (kind === "bundler" || entry.format === (kind === "node16-cjs" ? "cjs" : "esm")));
|
|
10895
12008
|
}
|
|
@@ -10986,6 +12099,172 @@ function checkDependencyRanges(pkg, packages, results, expected) {
|
|
|
10986
12099
|
}
|
|
10987
12100
|
}
|
|
10988
12101
|
//#endregion
|
|
12102
|
+
//#region src/commands/package-check/consumer/optional-peers.ts
|
|
12103
|
+
/** Install integrations exercised by exported entries without copying development dependencies. */
|
|
12104
|
+
function consumerOptionalPeers(closure, localLocators) {
|
|
12105
|
+
const peers = /* @__PURE__ */ new Map();
|
|
12106
|
+
for (const { manifest, reference, name } of closure.references) {
|
|
12107
|
+
if (reference.field !== "peerDependencies") continue;
|
|
12108
|
+
const peer = peers.get(reference.alias) ?? {
|
|
12109
|
+
names: /* @__PURE__ */ new Set(),
|
|
12110
|
+
ranges: [],
|
|
12111
|
+
optional: false,
|
|
12112
|
+
registry: true
|
|
12113
|
+
};
|
|
12114
|
+
peer.names.add(name);
|
|
12115
|
+
peer.ranges.push(reference.range);
|
|
12116
|
+
peer.registry &&= reference.protocol === "registry";
|
|
12117
|
+
peer.optional ||= manifest.peerDependenciesMeta?.[reference.alias]?.optional === true;
|
|
12118
|
+
peers.set(reference.alias, peer);
|
|
12119
|
+
}
|
|
12120
|
+
return Object.fromEntries([...peers].filter(([, peer]) => peer.optional).sort(([left], [right]) => left.localeCompare(right)).map(([alias, peer]) => {
|
|
12121
|
+
if (peer.names.size !== 1) throw new Error(`Consumer peer alias ${alias} has conflicting package names.`);
|
|
12122
|
+
const name = [...peer.names][0];
|
|
12123
|
+
if (!peer.registry) throw new Error(`Consumer optional peer ${alias} must declare a registry version range.`);
|
|
12124
|
+
let alternatives = [""];
|
|
12125
|
+
for (const range of peer.ranges) {
|
|
12126
|
+
const normalized = validRange(range);
|
|
12127
|
+
if (!normalized) throw new Error(`Consumer optional peer ${alias} must declare a registry version range: ${range}.`);
|
|
12128
|
+
alternatives = alternatives.flatMap((left) => normalized.split("||").map((right) => `${left} ${right}`.trim())).filter((range) => minVersion(range) !== null);
|
|
12129
|
+
}
|
|
12130
|
+
const intersection = [...new Set(alternatives)].join(" || ");
|
|
12131
|
+
if (!intersection) throw new Error(`Consumer optional peer ${alias} has incompatible declared ranges: ${peer.ranges.join(", ")}.`);
|
|
12132
|
+
const range = (peer.ranges.find((candidate) => peer.ranges.every((other) => subset(candidate, other))) ?? intersection).trim().replace(/([<>=~^])\s+/gu, "$1");
|
|
12133
|
+
const local = closure.known.get(name);
|
|
12134
|
+
if (local) {
|
|
12135
|
+
if (!local.version || !satisfies(local.version, range)) throw new Error(`Consumer optional peer ${alias} does not accept checked workspace package ${name}@${local.version}: ${range}.`);
|
|
12136
|
+
if (localLocators) {
|
|
12137
|
+
const locator = localLocators.get(name);
|
|
12138
|
+
if (!locator) throw new Error(`Consumer optional peer ${alias} has no checked tarball for ${name}.`);
|
|
12139
|
+
return [alias, locator];
|
|
12140
|
+
}
|
|
12141
|
+
return [alias, alias === name ? local.version : `npm:${name}@${local.version}`];
|
|
12142
|
+
}
|
|
12143
|
+
return [alias, alias === name ? range : `npm:${name}@${range}`];
|
|
12144
|
+
}));
|
|
12145
|
+
}
|
|
12146
|
+
//#endregion
|
|
12147
|
+
//#region src/commands/package-check/consumer/peer-aliases.ts
|
|
12148
|
+
/** pnpm 12 cannot install npm aliases whose range contains AND comparators. */
|
|
12149
|
+
async function resolveConsumerPeerAliases(dependencies, query) {
|
|
12150
|
+
const resolved = { ...dependencies };
|
|
12151
|
+
for (const reference of dependencyReferences({ dependencies }, ".")) {
|
|
12152
|
+
const { alias, name, range } = reference;
|
|
12153
|
+
if (!dependencies[alias].startsWith("npm:") || !validRange(range) || range.split("||").every((alternative) => !/\s/u.test(alternative.trim()))) continue;
|
|
12154
|
+
const output = await query(`${name}@${range}`);
|
|
12155
|
+
let response;
|
|
12156
|
+
try {
|
|
12157
|
+
response = JSON.parse(output);
|
|
12158
|
+
} catch {
|
|
12159
|
+
throw new Error(`Consumer optional peer ${alias} received an invalid registry version response.`);
|
|
12160
|
+
}
|
|
12161
|
+
const versions = typeof response === "string" ? [response] : response;
|
|
12162
|
+
if (!Array.isArray(versions) || !versions.every((version) => typeof version === "string" && valid(version))) throw new Error(`Consumer optional peer ${alias} received an invalid registry version response.`);
|
|
12163
|
+
const version = maxSatisfying(versions, range);
|
|
12164
|
+
if (!version) throw new Error(`Consumer optional peer ${alias} has no published version matching ${range}.`);
|
|
12165
|
+
resolved[alias] = `npm:${name}@${version}`;
|
|
12166
|
+
}
|
|
12167
|
+
return resolved;
|
|
12168
|
+
}
|
|
12169
|
+
//#endregion
|
|
12170
|
+
//#region src/commands/package-check/consumer/runtime-closure.ts
|
|
12171
|
+
/** Follow checked runtime dependencies and peers without importing development tooling. */
|
|
12172
|
+
function consumerRuntimeClosure(roots, manifests, expected) {
|
|
12173
|
+
const known = new Map(manifests.map((manifest) => [manifest.name, manifest]));
|
|
12174
|
+
const visited = /* @__PURE__ */ new Set();
|
|
12175
|
+
const references = [];
|
|
12176
|
+
const visit = (manifest) => {
|
|
12177
|
+
if (visited.has(manifest)) return;
|
|
12178
|
+
visited.add(manifest);
|
|
12179
|
+
for (const reference of dependencyReferences(manifest, ".")) {
|
|
12180
|
+
const name = consumerDependency({ manifest }, reference, expected)?.name ?? reference.name;
|
|
12181
|
+
references.push({
|
|
12182
|
+
manifest,
|
|
12183
|
+
reference,
|
|
12184
|
+
name
|
|
12185
|
+
});
|
|
12186
|
+
const local = known.get(name);
|
|
12187
|
+
if (local) visit(local);
|
|
12188
|
+
}
|
|
12189
|
+
};
|
|
12190
|
+
roots.forEach(visit);
|
|
12191
|
+
return {
|
|
12192
|
+
known,
|
|
12193
|
+
references
|
|
12194
|
+
};
|
|
12195
|
+
}
|
|
12196
|
+
//#endregion
|
|
12197
|
+
//#region src/commands/package-check/consumer/typescript.ts
|
|
12198
|
+
async function packageVersion(filename, name) {
|
|
12199
|
+
const manifest = JSON.parse(await readFile(filename, "utf8"));
|
|
12200
|
+
if (manifest.name !== name || !manifest.version || !valid(manifest.version)) throw new Error(`Consumer requires an exact installed ${name} version: ${filename}.`);
|
|
12201
|
+
return manifest.version;
|
|
12202
|
+
}
|
|
12203
|
+
/** Read only the source workspace's installation, never an incidental ancestor. */
|
|
12204
|
+
async function consumerTypeScriptVersion(sourceDirectory) {
|
|
12205
|
+
const workspace = await findWorkspaceDir(sourceDirectory) ?? sourceDirectory;
|
|
12206
|
+
const filename = path$1.join(workspace, "node_modules/typescript/package.json");
|
|
12207
|
+
try {
|
|
12208
|
+
return await packageVersion(filename, "typescript");
|
|
12209
|
+
} catch (error) {
|
|
12210
|
+
if (error.code !== "ENOENT") throw error;
|
|
12211
|
+
}
|
|
12212
|
+
return packageVersion(createRequire(import.meta.resolve("@arethetypeswrong/core/package.json")).resolve("typescript/package.json"), "typescript");
|
|
12213
|
+
}
|
|
12214
|
+
/** Keep verification tools separate from the package's own runtime integrations. */
|
|
12215
|
+
async function consumerTypeToolchain(sourceDirectory, dependencies, closure) {
|
|
12216
|
+
const occupied = /* @__PURE__ */ new Set([...Object.keys(dependencies), ...closure.references.map(({ reference }) => reference.alias)]);
|
|
12217
|
+
const reserve = (base) => {
|
|
12218
|
+
let alias = base;
|
|
12219
|
+
for (let suffix = 1; occupied.has(alias); suffix++) alias = `${base}-${suffix}`;
|
|
12220
|
+
occupied.add(alias);
|
|
12221
|
+
return alias;
|
|
12222
|
+
};
|
|
12223
|
+
const typescript = {
|
|
12224
|
+
alias: reserve("repoctl-consumer-typescript"),
|
|
12225
|
+
version: await consumerTypeScriptVersion(sourceDirectory)
|
|
12226
|
+
};
|
|
12227
|
+
const nodeTypes = {
|
|
12228
|
+
alias: reserve("repoctl-consumer-node-types"),
|
|
12229
|
+
version: await packageVersion(createRequire(import.meta.url).resolve("@types/node/package.json"), "@types/node")
|
|
12230
|
+
};
|
|
12231
|
+
return {
|
|
12232
|
+
typescript,
|
|
12233
|
+
nodeTypes,
|
|
12234
|
+
devDependencies: {
|
|
12235
|
+
[typescript.alias]: `npm:typescript@${typescript.version}`,
|
|
12236
|
+
[nodeTypes.alias]: `npm:@types/node@${nodeTypes.version}`
|
|
12237
|
+
}
|
|
12238
|
+
};
|
|
12239
|
+
}
|
|
12240
|
+
async function installedTool(directory, dependency, name, entry) {
|
|
12241
|
+
const root = await realpath(directory);
|
|
12242
|
+
const require = createRequire(path$1.join(root, "package.json"));
|
|
12243
|
+
const files = await Promise.all([`${dependency.alias}/package.json`, `${dependency.alias}/${entry}`].map((specifier) => realpath(require.resolve(specifier))));
|
|
12244
|
+
for (const filename of files) {
|
|
12245
|
+
const relative = path$1.relative(root, filename);
|
|
12246
|
+
if (!relative || relative === ".." || relative.startsWith(`..${path$1.sep}`) || path$1.isAbsolute(relative)) throw new Error(`Consumer resolved ${name} outside its isolated directory.`);
|
|
12247
|
+
}
|
|
12248
|
+
if (await packageVersion(files[0], name) !== dependency.version) throw new Error(`Consumer installed an unexpected ${name} version; expected ${dependency.version}.`);
|
|
12249
|
+
return files[1];
|
|
12250
|
+
}
|
|
12251
|
+
function installedConsumerTypeScript(directory, version, alias = "typescript") {
|
|
12252
|
+
return installedTool(directory, {
|
|
12253
|
+
alias,
|
|
12254
|
+
version
|
|
12255
|
+
}, "typescript", "bin/tsc");
|
|
12256
|
+
}
|
|
12257
|
+
async function installedConsumerTypeToolchain(directory, toolchain) {
|
|
12258
|
+
const [tsc, nodeTypes] = await Promise.all([installedConsumerTypeScript(directory, toolchain.typescript.version, toolchain.typescript.alias), installedTool(directory, toolchain.nodeTypes, "@types/node", "index.d.ts")]);
|
|
12259
|
+
const typeRoots = await mkdtemp(path$1.join(await realpath(directory), ".repoctl-type-roots-"));
|
|
12260
|
+
await symlink(path$1.dirname(nodeTypes), path$1.join(typeRoots, "node"), "junction");
|
|
12261
|
+
return {
|
|
12262
|
+
tsc,
|
|
12263
|
+
nodeTypes: "node",
|
|
12264
|
+
typeRoots
|
|
12265
|
+
};
|
|
12266
|
+
}
|
|
12267
|
+
//#endregion
|
|
10989
12268
|
//#region src/commands/package-check/process.ts
|
|
10990
12269
|
function stop$1(child) {
|
|
10991
12270
|
if (!child.pid) return;
|
|
@@ -11096,15 +12375,21 @@ async function consumeTarball(pkg, packages, results, entries, directory, timeou
|
|
|
11096
12375
|
checkDependencyRanges(pkg, packages, results, options.expectedWorkspaceLocators);
|
|
11097
12376
|
if (result.diagnostics.some((item) => item.severity === "error")) return;
|
|
11098
12377
|
const checkTypes = entries.length > 0 && result.files.some((file) => /\.d\.[cm]?ts$/u.test(file));
|
|
11099
|
-
const
|
|
11100
|
-
|
|
11101
|
-
|
|
12378
|
+
const closure = consumerRuntimeClosure([pkg.manifest], packages.map((item) => item.manifest), options.expectedWorkspaceLocators);
|
|
12379
|
+
const dependencies = {
|
|
12380
|
+
...consumerOptionalPeers(closure, new Map(packages.map((item) => [String(item.manifest.name), `file:${item.result.tarball}`]))),
|
|
12381
|
+
[String(pkg.manifest.name)]: `file:${result.tarball}`
|
|
12382
|
+
};
|
|
12383
|
+
const tooling = checkTypes ? await consumerTypeToolchain(result.directory, dependencies, closure) : void 0;
|
|
12384
|
+
const manifest = {
|
|
11102
12385
|
name: "repoctl-package-consumer",
|
|
11103
12386
|
private: true,
|
|
11104
12387
|
...packageManager ? { packageManager } : {},
|
|
11105
|
-
dependencies
|
|
11106
|
-
...
|
|
11107
|
-
}
|
|
12388
|
+
dependencies,
|
|
12389
|
+
...tooling ? { devDependencies: tooling.devDependencies } : {}
|
|
12390
|
+
};
|
|
12391
|
+
await mkdir(directory, { recursive: true });
|
|
12392
|
+
await writeFile(path$1.join(directory, "package.json"), JSON.stringify(manifest, null, 2));
|
|
11108
12393
|
await writeFile(path$1.join(directory, "pnpm-workspace.yaml"), stringify({
|
|
11109
12394
|
packages: [],
|
|
11110
12395
|
overrides: Object.fromEntries([...packages.map((item) => [String(item.manifest.name), `file:${item.result.tarball}`]), ...packages.flatMap((item) => dependencyReferences(item.manifest, item.result.directory).flatMap((reference) => {
|
|
@@ -11113,6 +12398,20 @@ async function consumeTarball(pkg, packages, results, entries, directory, timeou
|
|
|
11113
12398
|
return local ? [[`${item.manifest.name}>${reference.alias}`, `file:${local.result.tarball}`]] : [];
|
|
11114
12399
|
}))])
|
|
11115
12400
|
}));
|
|
12401
|
+
manifest.dependencies = await resolveConsumerPeerAliases(dependencies, async (specifier) => {
|
|
12402
|
+
const query = await execute(packageManager ? "corepack" : "pnpm", [
|
|
12403
|
+
...packageManager ? ["pnpm"] : [],
|
|
12404
|
+
"view",
|
|
12405
|
+
specifier,
|
|
12406
|
+
"version",
|
|
12407
|
+
"--json",
|
|
12408
|
+
"--config.manage-package-manager-versions=false"
|
|
12409
|
+
], directory, timeout, options);
|
|
12410
|
+
result.commands.push(query);
|
|
12411
|
+
if (query.exitCode !== 0) throw new Error(failureMessage(query));
|
|
12412
|
+
return query.stdout;
|
|
12413
|
+
});
|
|
12414
|
+
await writeFile(path$1.join(directory, "package.json"), JSON.stringify(manifest, null, 2));
|
|
11116
12415
|
const install = await execute(packageManager ? "corepack" : "pnpm", [
|
|
11117
12416
|
...packageManager ? ["pnpm"] : [],
|
|
11118
12417
|
"install",
|
|
@@ -11133,11 +12432,11 @@ async function consumeTarball(pkg, packages, results, entries, directory, timeou
|
|
|
11133
12432
|
const installed = await realpath(path$1.join(directory, "node_modules", String(pkg.manifest.name)));
|
|
11134
12433
|
const relative = path$1.relative(await realpath(directory), installed);
|
|
11135
12434
|
if (relative.startsWith("..") || path$1.isAbsolute(relative)) throw new Error("Consumer resolved a package outside its isolated directory.");
|
|
11136
|
-
const
|
|
12435
|
+
const toolchain = tooling ? await installedConsumerTypeToolchain(directory, tooling) : void 0;
|
|
11137
12436
|
for (const [index, entry] of entries.entries()) {
|
|
11138
12437
|
const specifier = `${pkg.manifest.name}${entry.subpath === "." ? "" : entry.subpath.slice(1)}`;
|
|
11139
12438
|
if (entry.runtime) {
|
|
11140
|
-
const source = entry.format === "esm" ? `await import(${JSON.stringify(specifier)})` : `require(${JSON.stringify(specifier)})`;
|
|
12439
|
+
const source = entry.asset ? consumerAssetSource(entry, specifier, installed) : entry.format === "esm" ? `await import(${JSON.stringify(specifier)})` : `require(${JSON.stringify(specifier)})`;
|
|
11141
12440
|
const command = await execute(process.execPath, [
|
|
11142
12441
|
"--input-type",
|
|
11143
12442
|
entry.format === "esm" ? "module" : "commonjs",
|
|
@@ -11147,19 +12446,31 @@ async function consumeTarball(pkg, packages, results, entries, directory, timeou
|
|
|
11147
12446
|
result.commands.push(command);
|
|
11148
12447
|
if (command.exitCode !== 0) result.diagnostics.push({
|
|
11149
12448
|
source: "node",
|
|
11150
|
-
code: "RUNTIME_IMPORT",
|
|
12449
|
+
code: entry.asset ? "RUNTIME_ASSET" : "RUNTIME_IMPORT",
|
|
11151
12450
|
severity: "error",
|
|
11152
12451
|
entry: entry.subpath,
|
|
11153
12452
|
file: entry.target,
|
|
11154
12453
|
message: failureMessage(command)
|
|
11155
12454
|
});
|
|
12455
|
+
if (entry.asset && command.exitCode === 0) {
|
|
12456
|
+
const syntax = await execute(process.execPath, ["--check", path$1.resolve(installed, entry.target)], directory, timeout, options);
|
|
12457
|
+
result.commands.push(syntax);
|
|
12458
|
+
if (syntax.exitCode !== 0) result.diagnostics.push({
|
|
12459
|
+
source: "node",
|
|
12460
|
+
code: "RUNTIME_ASSET_SYNTAX",
|
|
12461
|
+
severity: "error",
|
|
12462
|
+
entry: entry.subpath,
|
|
12463
|
+
file: entry.target,
|
|
12464
|
+
message: failureMessage(syntax)
|
|
12465
|
+
});
|
|
12466
|
+
}
|
|
11156
12467
|
}
|
|
11157
|
-
if (
|
|
12468
|
+
if (toolchain && entry.typecheck !== false) {
|
|
11158
12469
|
const file = `consume-${index}.${entry.format === "esm" ? "mts" : "cts"}`;
|
|
11159
12470
|
const importText = !entry.runtime ? `import type * as subject from ${JSON.stringify(specifier)}` : entry.format === "esm" ? `import * as subject from ${JSON.stringify(specifier)}` : `import subject = require(${JSON.stringify(specifier)})`;
|
|
11160
12471
|
await writeFile(path$1.join(directory, file), `${importText};\ntype Consumer = typeof subject;\n`);
|
|
11161
12472
|
const types = await execute(process.execPath, [
|
|
11162
|
-
tsc,
|
|
12473
|
+
toolchain.tsc,
|
|
11163
12474
|
"--noEmit",
|
|
11164
12475
|
"--strict",
|
|
11165
12476
|
"--skipLibCheck",
|
|
@@ -11168,8 +12479,10 @@ async function consumeTarball(pkg, packages, results, entries, directory, timeou
|
|
|
11168
12479
|
"nodenext",
|
|
11169
12480
|
"--target",
|
|
11170
12481
|
"es2022",
|
|
12482
|
+
"--typeRoots",
|
|
12483
|
+
toolchain.typeRoots,
|
|
11171
12484
|
"--types",
|
|
11172
|
-
|
|
12485
|
+
toolchain.nodeTypes,
|
|
11173
12486
|
file
|
|
11174
12487
|
], directory, timeout, options);
|
|
11175
12488
|
result.commands.push(types);
|
|
@@ -12378,27 +13691,28 @@ async function releaseSnapshot(options) {
|
|
|
12378
13691
|
}
|
|
12379
13692
|
//#endregion
|
|
12380
13693
|
//#region src/commands/release/nightly/consumer/entries.ts
|
|
12381
|
-
async function checkInstalledEntries(manifest, files, installed, directory, run, packageIndex) {
|
|
13694
|
+
async function checkInstalledEntries(manifest, files, installed, directory, run, packageIndex, toolchain) {
|
|
12382
13695
|
const entries = consumerEntries(manifest, files);
|
|
12383
13696
|
const checkTypes = files.some((file) => /\.d\.[cm]?ts$/u.test(file));
|
|
12384
|
-
const tsc = createRequire(import.meta.resolve("@arethetypeswrong/core/package.json")).resolve("typescript/bin/tsc");
|
|
12385
13697
|
for (const [index, entry] of entries.entries()) {
|
|
12386
13698
|
const specifier = `${manifest.name}${entry.subpath === "." ? "" : entry.subpath.slice(1)}`;
|
|
12387
13699
|
if (entry.runtime) {
|
|
12388
|
-
const source = entry.format === "esm" ? `await import(${JSON.stringify(specifier)})` : `require(${JSON.stringify(specifier)})`;
|
|
13700
|
+
const source = entry.asset ? consumerAssetSource(entry, specifier, installed) : entry.format === "esm" ? `await import(${JSON.stringify(specifier)})` : `require(${JSON.stringify(specifier)})`;
|
|
12389
13701
|
await run(process.execPath, [
|
|
12390
13702
|
"--input-type",
|
|
12391
13703
|
entry.format === "esm" ? "module" : "commonjs",
|
|
12392
13704
|
"--eval",
|
|
12393
13705
|
source
|
|
12394
13706
|
]);
|
|
13707
|
+
if (entry.asset) await run(process.execPath, ["--check", path$1.resolve(installed, entry.target)]);
|
|
12395
13708
|
}
|
|
12396
|
-
if (checkTypes) {
|
|
13709
|
+
if (checkTypes && entry.typecheck !== false) {
|
|
13710
|
+
if (!toolchain) throw new Error("Nightly consumer requires its isolated TypeScript compiler for declaration checks.");
|
|
12397
13711
|
const file = `consume-${packageIndex}-${index}.${entry.format === "esm" ? "mts" : "cts"}`;
|
|
12398
13712
|
const importText = !entry.runtime ? `import type * as subject from ${JSON.stringify(specifier)}` : entry.format === "esm" ? `import * as subject from ${JSON.stringify(specifier)}` : `import subject = require(${JSON.stringify(specifier)})`;
|
|
12399
13713
|
await writeFile(path$1.join(directory, file), `${importText};\ntype Consumer = typeof subject;\n`);
|
|
12400
13714
|
await run(process.execPath, [
|
|
12401
|
-
tsc,
|
|
13715
|
+
toolchain.tsc,
|
|
12402
13716
|
"--noEmit",
|
|
12403
13717
|
"--strict",
|
|
12404
13718
|
"--skipLibCheck",
|
|
@@ -12407,8 +13721,10 @@ async function checkInstalledEntries(manifest, files, installed, directory, run,
|
|
|
12407
13721
|
"nodenext",
|
|
12408
13722
|
"--target",
|
|
12409
13723
|
"es2022",
|
|
13724
|
+
"--typeRoots",
|
|
13725
|
+
toolchain.typeRoots,
|
|
12410
13726
|
"--types",
|
|
12411
|
-
|
|
13727
|
+
toolchain.nodeTypes,
|
|
12412
13728
|
file
|
|
12413
13729
|
]);
|
|
12414
13730
|
}
|
|
@@ -12600,6 +13916,22 @@ async function installNightlyConsumer(report, options, directory, run) {
|
|
|
12600
13916
|
throw new Error("Nightly consumer installation visibility timed out; the confirmed npm batch was not uploaded again.", { cause: lastFailure });
|
|
12601
13917
|
}
|
|
12602
13918
|
//#endregion
|
|
13919
|
+
//#region src/commands/release/nightly/consumer/manifests.ts
|
|
13920
|
+
/** Derive the consumer contract from the checked artifacts, never mutable source manifests. */
|
|
13921
|
+
async function nightlyConsumerManifests(report) {
|
|
13922
|
+
const snapshot = report.snapshot;
|
|
13923
|
+
if (!snapshot) throw new Error("Nightly consumer requires a checked snapshot.");
|
|
13924
|
+
return Promise.all(snapshot.packages.map(async (pkg) => {
|
|
13925
|
+
if (!pkg.tarball) throw new Error(`Nightly consumer has no checked tarball for ${pkg.name}.`);
|
|
13926
|
+
const bytes = await readFile(pkg.tarball);
|
|
13927
|
+
if (`sha512-${createHash("sha512").update(bytes).digest("base64")}` !== pkg.integrity) throw new Error(`Nightly consumer tarball integrity changed for ${pkg.name}.`);
|
|
13928
|
+
const packed = createPackageFromTarballData(Uint8Array.from(bytes));
|
|
13929
|
+
const manifest = JSON.parse(packed.readFile(`/node_modules/${pkg.name}/package.json`));
|
|
13930
|
+
if (manifest.name !== pkg.name || manifest.version !== pkg.version || !matchesSnapshotMetadata(manifest.repoctlSnapshot, snapshot)) throw new Error(`Nightly consumer tarball identity changed for ${pkg.name}.`);
|
|
13931
|
+
return manifest;
|
|
13932
|
+
}));
|
|
13933
|
+
}
|
|
13934
|
+
//#endregion
|
|
12603
13935
|
//#region src/commands/release/nightly/consumer.ts
|
|
12604
13936
|
/** Exercise the real published channel with no workspace links or dependency overrides. */
|
|
12605
13937
|
async function verifyNightlyConsumer(report, options) {
|
|
@@ -12616,25 +13948,45 @@ async function verifyNightlyConsumer(report, options) {
|
|
|
12616
13948
|
const source = JSON.parse(await readFile(path$1.join(options.cwd, "package.json"), "utf8"));
|
|
12617
13949
|
const pin = /^pnpm@(\d+\.\d+\.\d+)(?:\+sha\d+\.[a-f0-9]+)?$/u.exec(source.packageManager ?? "");
|
|
12618
13950
|
if (!pin) throw new Error("Nightly consumer requires an exact pnpm packageManager pin.");
|
|
13951
|
+
const manifests = await nightlyConsumerManifests(report);
|
|
12619
13952
|
await mkdir(report.outputDirectory, { recursive: true });
|
|
12620
13953
|
directory = await realpath(await mkdtemp(path$1.join(report.outputDirectory, "consumer-")));
|
|
12621
|
-
const
|
|
13954
|
+
const checkTypes = report.snapshot.checks?.some((check) => check.files.some((file) => /\.d\.[cm]?ts$/u.test(file)));
|
|
13955
|
+
const closure = consumerRuntimeClosure(manifests, manifests);
|
|
13956
|
+
const dependencies = {
|
|
13957
|
+
...consumerOptionalPeers(closure, new Map(report.packages.map((pkg) => [pkg.name, report.provider === "npm" ? `npm:${pkg.name}@snapshot-nightly` : pkg.locator]))),
|
|
13958
|
+
...Object.fromEntries(report.packages.map((pkg) => [pkg.name, report.provider === "npm" ? "snapshot-nightly" : pkg.locator]))
|
|
13959
|
+
};
|
|
13960
|
+
const tooling = checkTypes ? await consumerTypeToolchain(options.cwd, dependencies, closure) : void 0;
|
|
13961
|
+
const manifest = {
|
|
13962
|
+
name: "repoctl-nightly-consumer",
|
|
13963
|
+
private: true,
|
|
13964
|
+
type: "module",
|
|
13965
|
+
packageManager: source.packageManager,
|
|
13966
|
+
dependencies,
|
|
13967
|
+
...tooling ? { devDependencies: tooling.devDependencies } : {}
|
|
13968
|
+
};
|
|
12622
13969
|
await Promise.all([
|
|
12623
|
-
writeFile(path$1.join(directory, "package.json"), `${JSON.stringify(
|
|
12624
|
-
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
packageManager: source.packageManager,
|
|
12628
|
-
dependencies: Object.fromEntries(report.packages.map((pkg) => [pkg.name, report.provider === "npm" ? "snapshot-nightly" : pkg.locator])),
|
|
12629
|
-
...!report.packages.some((pkg) => pkg.name === "@types/node") ? { devDependencies: { "@types/node": nodeTypes.version } } : {}
|
|
13970
|
+
writeFile(path$1.join(directory, "package.json"), `${JSON.stringify(manifest, null, 2)}\n`),
|
|
13971
|
+
writeFile(path$1.join(directory, "pnpm-workspace.yaml"), `${JSON.stringify({
|
|
13972
|
+
packages: [],
|
|
13973
|
+
...report.provider === "npm" ? { minimumReleaseAgeExclude: report.packages.map((pkg) => `${pkg.name}@${pkg.version}`) } : {}
|
|
12630
13974
|
}, null, 2)}\n`),
|
|
12631
|
-
writeFile(path$1.join(directory, "pnpm-workspace.yaml"), "packages: []\n"),
|
|
12632
13975
|
writeFile(path$1.join(directory, "user.npmrc"), ""),
|
|
12633
13976
|
writeFile(path$1.join(directory, "global.npmrc"), "")
|
|
12634
13977
|
]);
|
|
12635
13978
|
const run = consumerRunner(result, options, directory, consumerEnvironment(options.env ?? process.env, directory));
|
|
12636
13979
|
if (await run("pnpm", [...consumerPnpmOptions, "--version"]) !== pin[1]) throw new Error(`Nightly consumer requires pnpm ${pin[1]}.`);
|
|
13980
|
+
manifest.dependencies = await resolveConsumerPeerAliases(dependencies, (specifier) => run("pnpm", [
|
|
13981
|
+
...consumerPnpmOptions,
|
|
13982
|
+
"view",
|
|
13983
|
+
specifier,
|
|
13984
|
+
"version",
|
|
13985
|
+
"--json"
|
|
13986
|
+
]));
|
|
13987
|
+
await writeFile(path$1.join(directory, "package.json"), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
12637
13988
|
await installNightlyConsumer(report, options, directory, run);
|
|
13989
|
+
const toolchain = tooling ? await installedConsumerTypeToolchain(directory, tooling) : void 0;
|
|
12638
13990
|
const validated = [];
|
|
12639
13991
|
for (const pkg of report.packages) {
|
|
12640
13992
|
const installed = await realpath(path$1.join(directory, "node_modules", pkg.name));
|
|
@@ -12652,7 +14004,7 @@ async function verifyNightlyConsumer(report, options) {
|
|
|
12652
14004
|
});
|
|
12653
14005
|
}
|
|
12654
14006
|
for (const [index, { manifest, files, installed, pkg }] of validated.entries()) {
|
|
12655
|
-
await checkInstalledEntries(manifest, files, installed, directory, run, index);
|
|
14007
|
+
await checkInstalledEntries(manifest, files, installed, directory, run, index, toolchain);
|
|
12656
14008
|
result.packages.push({
|
|
12657
14009
|
name: pkg.name,
|
|
12658
14010
|
version: pkg.version
|
|
@@ -12991,6 +14343,10 @@ function formatNightlySummary(report) {
|
|
|
12991
14343
|
for (const pkg of report.packages) lines.push(`| ${escape(pkg.name)} | \`pnpm add ${escape(pkg.locator)}\` |`);
|
|
12992
14344
|
lines.push("", report.provider === "npm" ? "All snapshot-nightly tags match this build; latest tags are unchanged." : "All full-commit preview URLs match the verified tarballs.", "");
|
|
12993
14345
|
} else if (report.status === "prepared") lines.push("Artifacts are prepared and validated. Publication was not requested.", "");
|
|
14346
|
+
else if (report.status === "failed" && report.confirmed && report.consumer?.status === "failed") {
|
|
14347
|
+
lines.push("Publication was confirmed, but consumer verification failed. This run remains failed.", "", `Confirmed build: \`${escape(report.buildId)}\``, "", "Review nightly-report.json, consumer-report.json and the retained package artifacts before retrying.", "");
|
|
14348
|
+
if (report.provider === "npm") lines.push("A scheduled run for the same commit may skip this batch without repeating consumer verification.", "", "After fixing the failure, if a new nightly publication is intended, run the managed Release workflow manually with mode=nightly and dry-run=false. This repeats the pipeline and publishes snapshots with a new build identity.", "");
|
|
14349
|
+
}
|
|
12994
14350
|
return `${lines.join("\n")}\n`;
|
|
12995
14351
|
}
|
|
12996
14352
|
async function writeNightlySummary(report, filename) {
|
|
@@ -13144,6 +14500,7 @@ async function createReleasePlan(options) {
|
|
|
13144
14500
|
report = await createNativeReleasePlan(options);
|
|
13145
14501
|
report.branchRule = selected;
|
|
13146
14502
|
if (report.status !== "blocked") {
|
|
14503
|
+
await assertWorkspaceDependencyProtocols(report.cwd);
|
|
13147
14504
|
await assertProjectedLine(selected, report.packages, {
|
|
13148
14505
|
...options,
|
|
13149
14506
|
cwd: report.cwd
|
|
@@ -16427,6 +17784,7 @@ async function applyWorkspaceRemovalPlan(cwd, plan) {
|
|
|
16427
17784
|
//#endregion
|
|
16428
17785
|
//#region src/commands/index.ts
|
|
16429
17786
|
var commands_exports = /* @__PURE__ */ __exportAll({
|
|
17787
|
+
DocsDeploymentError: () => DocsDeploymentError,
|
|
16430
17788
|
GitClient: () => GitClient,
|
|
16431
17789
|
GitHubApiError: () => GitHubApiError,
|
|
16432
17790
|
GitHubClient: () => GitHubClient,
|
|
@@ -16560,4 +17918,4 @@ var commands_exports = /* @__PURE__ */ __exportAll({
|
|
|
16560
17918
|
verifyStagedTypecheck: () => verifyStagedTypecheck
|
|
16561
17919
|
});
|
|
16562
17920
|
//#endregion
|
|
16563
|
-
export {
|
|
17921
|
+
export { releaseStable as $, applyInstallSecurityPreset as A, getCreateChoices as At, formatPublicApiReport as B, sanitizeConfigReport as Bt, getMaintenanceWorkflow as C, planDoctorFix as Ct, planOrganizationPresetAssets as D, createNewProject as Dt, applyOrganizationPresetAssets as E, applyCreateNewProjectPlan as Et, checkPeerDependencies as F, resolveTemplateCatalog as Ft, skillTargets as G, createTimestampFolderName as Gt, formatUpgradePlan as H, cleanProjects as Ht, resolveAffectedCheckMatrix as I, loadTemplateCatalogContext as It, createReleasePullRequest as J, generateAgenticTemplates as Jt, syncSkills as K, defaultAgenticBaseDir as Kt, checkPublicApi as L, updateIssueTemplateConfig as Lt, deployDocs as M, templateMap as Mt, DocsDeploymentError as N, resolveRemoteTemplateSource as Nt, applyDevContainerPlan as O, defaultTemplate as Ot, planDocsDeployment as P, createTemplateCatalog as Pt, publishStable as Q, applyPublicApiUpdate as R, inspectMonorepoConfig as Rt, checkPackages as S, applyDoctorFixPlan as St, detectMaintenanceVersionChange as T, applyUpgradePlan as Tt, checkTemplates as U, verifyStagedTypecheck as Ut, upgradeMonorepo as V, validateConfigFile as Vt, getSkillTargetPaths as W, verifyPrePush as Wt, releaseCi as X, recoverUnpublished as Y, loadAgenticTasks as Yt, prepareStable as Z, createSnapshotPlan as _, collectEnvInfo as _t, planWorkspaceMove as a, GitHubClient as at, applyProjectReferencesPlan as b, collectEnvSupportBundle as bt, applyToolingCapability as c, resolveReleaseMode as ct, planTemplateValidation as d, init as dt, reconcileRelease as et, createReleasePlan as f, initMetadata as ft, releaseSnapshot as g, createContext as gt, formatNightlySummary as h, initToolingTargets as ht, applyWorkspaceMovePlan as i, auditReleaseOidc as it, planInstallSecurityPreset as j, getTemplateMap as jt, planDevContainer as k, resolveCreateNewProjectPlan as kt, planToolingCapability as l, renderReleasePullRequest as lt, releaseNightly as m, normalizeInitToolingTargets as mt, applyWorkspaceRemovalPlan as n, exitPrerelease as nt, applyWorkspaceArtifactPlan as o, GitHubApiError as ot, createNightlyPlan as p, initTooling as pt, repairReleaseNotes as q, generateAgenticTemplate as qt, planWorkspaceRemoval as r, releasePrerelease as rt, planWorkspaceArtifact as s, parsePublishSummary as st, commands_exports as t, enterPrerelease as tt, validateTemplate as u, setVscodeBinaryMirror as ut, checkProjectReferences as v, collectEnvPaths as vt, prepareMaintenanceUpgrade as w, planUpgrade as wt, planProjectReferences as x, runDoctor as xt, syncProjectReferences as y, collectEnvSnapshot as yt, planPublicApiUpdate as z, explainMonorepoConfig as zt };
|