@icebreakers/monorepo 5.9.0 → 5.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{baseline-B9EyxrbO.mjs → baseline-DCJJvYYC.mjs} +1 -1
- package/dist/{catalog-5kzxXyLB.mjs → catalog-qV07HZ4U.mjs} +3 -3
- package/dist/cli.mjs +64 -63
- package/dist/{commands-CusCWJxk.mjs → commands-D_OwcGBP.mjs} +746 -128
- package/dist/{config-rSoYOMXe.mjs → config-BRlyvWE8.mjs} +3 -3
- package/dist/{create-flow-CBuv4d_0.mjs → create-flow-CFenuXHL.mjs} +3 -3
- package/dist/{deps-BncO3_-h.mjs → deps-DCnSRQFC.mjs} +3 -3
- package/dist/{execute-0x7C8Kn_.mjs → execute-CiJ4Medm.mjs} +2 -2
- package/dist/{execute-BG1gfWOr.mjs → execute-Dr5xQO9_.mjs} +2 -2
- package/dist/{format-CR1vN-6r.mjs → format-3ej8Ga7W.mjs} +1 -1
- package/dist/{index-D61zjikU.d.mts → index-VZQIHM49.d.mts} +10 -1
- package/dist/index.d.mts +30 -3
- package/dist/index.mjs +9 -9
- package/dist/{inputs-WX7RZBFF.mjs → inputs-CidMzXAI.mjs} +1 -1
- package/dist/{npm-Dq9vIMv5.mjs → npm-DiLcvA28.mjs} +2 -2
- package/dist/{plan-BvJst3z5.mjs → plan-Cxp3nbEF.mjs} +1 -1
- package/dist/{run-Bj0TtsEm.mjs → run-Bam_5lxm.mjs} +4 -4
- package/dist/{save-PjFHzG0t.mjs → save-74GxEVCT.mjs} +3 -3
- package/dist/{scan-DlTxgMtA.mjs → scan-CDAtNu-V.mjs} +7 -2
- package/dist/{template-drift-CekAiCI1.mjs → template-drift-CxK6TaR_.mjs} +3 -3
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/tooling-entry.mjs +2 -2
- package/dist/{transaction-g0QYi-eZ.mjs → transaction-CDFoYQ_X.mjs} +2 -2
- package/dist/{tsconfig-CjMxxX9j.mjs → tsconfig-BvBbfdrb.mjs} +11 -4
- package/dist/{vitest-B4Gcs7ZS.mjs → vitest-BQ_24o8l.mjs} +1 -1
- package/dist/{workspace-tasks-DeISSjjU.mjs → workspace-tasks-BI0-mbJt.mjs} +5 -5
- package/package.json +3 -5
|
@@ -1,19 +1,19 @@
|
|
|
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$3, 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 runPnpmCommand, f 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 verifyStagedTypecheck } from "./execute-
|
|
4
|
-
import { B as presetPackageName, C as checkedFile, E as relativeFile$1, F as normalizeTemplateSourceRequest, G as commandConfigDirectory, L as sourceRequestKey, O as package_default$1, P as normalizeTemplateRemoteSource, R as templateSourcePath, S as canonicalDirectory, T as readOptional$1, U as appendConfigPath, V as presetVersion, _ as listToolingCapabilities, b as presetRelativePath, d as loadMonorepoConfig, f as loadMonorepoConfigDetails, g as presetAssetTarget, j as ConfigValidationError, k 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 } from "./tsconfig-
|
|
5
|
-
import { c as selectCommandOverrides, i as rangesOverlap, l as chinaMirrorsEnvs, r as parseSpecifier, s as resolveCommandValues } from "./scan-
|
|
6
|
-
import { A as record$4, C as baselineDirectory, D as parseBaseline, E as isRootAsset, F as toWorkspaceAssetPath, M as summarizeChecks, O as templatePackage, S as checkDependencyAdmission, T as encodeBaseline, a as applyDoctorSuppressions, b as parseWorkspaceLockfile, c as collectSelectedDoctorChecks, d as recommendedRepoScripts, f as inspectInstallSecurity, g as isLegacyReleaseWorkflow, h as supportedVersion, i as hasTemplateDriftIssues, j as getWorkspacePatterns, k as getAssetTargets, 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 inspectPnpmRuntime, w as baselinePath, y as lockfileRecord } 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$3, 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-BI0-mbJt.mjs";
|
|
3
|
+
import { a as resolveFullWorkspaceCheckPlan, c as verifyCommitMsg, d as runPnpmCommand, f 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 verifyStagedTypecheck } from "./execute-Dr5xQO9_.mjs";
|
|
4
|
+
import { B as presetPackageName, C as checkedFile, E as relativeFile$1, F as normalizeTemplateSourceRequest, G as commandConfigDirectory, L as sourceRequestKey, O as package_default$1, P as normalizeTemplateRemoteSource, R as templateSourcePath, S as canonicalDirectory, T as readOptional$1, U as appendConfigPath, V as presetVersion, _ as listToolingCapabilities, b as presetRelativePath, d as loadMonorepoConfig, f as loadMonorepoConfigDetails, g as presetAssetTarget, j as ConfigValidationError, k 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 } from "./tsconfig-BvBbfdrb.mjs";
|
|
5
|
+
import { c as selectCommandOverrides, i as rangesOverlap, l as chinaMirrorsEnvs, r as parseSpecifier, s as resolveCommandValues } from "./scan-CDAtNu-V.mjs";
|
|
6
|
+
import { A as record$4, C as baselineDirectory, D as parseBaseline, E as isRootAsset, F as toWorkspaceAssetPath, M as summarizeChecks, O as templatePackage, S as checkDependencyAdmission, T as encodeBaseline, a as applyDoctorSuppressions, b as parseWorkspaceLockfile, c as collectSelectedDoctorChecks, d as recommendedRepoScripts, f as inspectInstallSecurity, g as isLegacyReleaseWorkflow, h as supportedVersion, i as hasTemplateDriftIssues, j as getWorkspacePatterns, k as getAssetTargets, 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 inspectPnpmRuntime, w as baselinePath, y as lockfileRecord } from "./template-drift-CxK6TaR_.mjs";
|
|
7
|
+
import { t as writeDependencyTransaction } from "./transaction-CDFoYQ_X.mjs";
|
|
8
|
+
import { i as applyDependencyFixPlan, r as planDependencyFix, t as checkDependencies } from "./deps-DCnSRQFC.mjs";
|
|
9
|
+
import { i as applyCatalogMigrationPlan, n as checkCatalogs, r as planCatalogMigration } from "./catalog-qV07HZ4U.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";
|
|
13
13
|
import path, { normalize } from "pathe";
|
|
14
14
|
import process from "node:process";
|
|
15
|
-
import { access, copyFile, link, lstat, mkdir, mkdtemp, open, readFile, readdir, readlink, realpath, rename, rm, rmdir, stat, symlink, unlink, utimes, writeFile } from "node:fs/promises";
|
|
16
|
-
import { execFile, execFileSync, spawnSync } from "node:child_process";
|
|
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
|
+
import { execFile, execFileSync, spawn, spawnSync } from "node:child_process";
|
|
17
17
|
import fs$1, { constants, createReadStream, existsSync } from "node:fs";
|
|
18
18
|
import semver, { coerce, compare, gt, gte, lte, minVersion, parse, satisfies, subset, valid, validRange } from "semver";
|
|
19
19
|
import validatePackageName from "validate-npm-package-name";
|
|
@@ -33,6 +33,8 @@ import { glob } from "tinyglobby";
|
|
|
33
33
|
import * as JSONC from "comment-json";
|
|
34
34
|
import { parse as parse$2, stringify as stringify$1 } from "comment-json";
|
|
35
35
|
import { performance } from "node:perf_hooks";
|
|
36
|
+
import Config from "@npmcli/config";
|
|
37
|
+
import definitionsModule from "@npmcli/config/lib/definitions/index.js";
|
|
36
38
|
import micromatch from "micromatch";
|
|
37
39
|
import { build } from "esbuild";
|
|
38
40
|
//#region src/commands/ai.ts
|
|
@@ -1458,7 +1460,7 @@ async function downloadGitTemplate(source, directory, timeout) {
|
|
|
1458
1460
|
async function resolveRemoteTemplateSource(source, templatePath = ".", options = {}) {
|
|
1459
1461
|
const request = normalizeTemplateSourceRequest(source, templatePath);
|
|
1460
1462
|
const cwd = path$1.resolve(options.cwd ?? process.cwd());
|
|
1461
|
-
const npm = request.source.kind === "npm" ? await import("./npm-
|
|
1463
|
+
const npm = request.source.kind === "npm" ? await import("./npm-DiLcvA28.mjs") : void 0;
|
|
1462
1464
|
const configuration = request.source.kind === "npm" ? await npm.npmTemplateConfiguration(request.source, cwd) : void 0;
|
|
1463
1465
|
if (request.source.kind === "npm") request.source.registry = configuration.registry;
|
|
1464
1466
|
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"));
|
|
@@ -4781,6 +4783,18 @@ function buildGitHubReleaseBodyFromChangelog(packageName, packageVersion, change
|
|
|
4781
4783
|
}], metadata), metadata);
|
|
4782
4784
|
}
|
|
4783
4785
|
//#endregion
|
|
4786
|
+
//#region src/commands/release/stages/verification.ts
|
|
4787
|
+
const verified = Symbol("repoctl verified stage");
|
|
4788
|
+
function authorizeVerification(options) {
|
|
4789
|
+
return {
|
|
4790
|
+
...options,
|
|
4791
|
+
[verified]: true
|
|
4792
|
+
};
|
|
4793
|
+
}
|
|
4794
|
+
function hasVerification(options) {
|
|
4795
|
+
return options[verified] === true;
|
|
4796
|
+
}
|
|
4797
|
+
//#endregion
|
|
4784
4798
|
//#region src/commands/release/workspace-protocol.ts
|
|
4785
4799
|
const EXPECTED_WORKSPACE_SPEC = "workspace:*";
|
|
4786
4800
|
const DEPENDENCY_SECTIONS = [
|
|
@@ -4850,6 +4864,7 @@ function verificationEnvironment(options) {
|
|
|
4850
4864
|
return env;
|
|
4851
4865
|
}
|
|
4852
4866
|
async function runQualityScripts(options) {
|
|
4867
|
+
if (hasVerification(options)) return;
|
|
4853
4868
|
await assertWorkspaceDependencyProtocols(options.cwd);
|
|
4854
4869
|
const config = resolveCommandValues("release", options.config).values;
|
|
4855
4870
|
const verificationOptions = {
|
|
@@ -4860,6 +4875,7 @@ async function runQualityScripts(options) {
|
|
|
4860
4875
|
runScripts(config.hooks?.verify ?? [], verificationOptions);
|
|
4861
4876
|
}
|
|
4862
4877
|
function runReleaseHooks(phase, options) {
|
|
4878
|
+
if (phase === "beforeVersion" && hasVerification(options)) return;
|
|
4863
4879
|
runScripts(options.config?.hooks?.[phase] ?? [], options);
|
|
4864
4880
|
}
|
|
4865
4881
|
function runAfterPublishHooks(packages, options) {
|
|
@@ -5180,10 +5196,9 @@ var GitHubClient = class {
|
|
|
5180
5196
|
});
|
|
5181
5197
|
const existing = (await this.request("GET", `/pulls?${query.toString()}`)).data?.[0];
|
|
5182
5198
|
if (existing) {
|
|
5183
|
-
await this.request("PATCH", `/pulls/${existing.number}`, {
|
|
5199
|
+
if (existing.title !== options.title || (existing.body ?? "") !== options.body) await this.request("PATCH", `/pulls/${existing.number}`, {
|
|
5184
5200
|
title: options.title,
|
|
5185
|
-
body: options.body
|
|
5186
|
-
base: options.base
|
|
5201
|
+
body: options.body
|
|
5187
5202
|
});
|
|
5188
5203
|
return existing;
|
|
5189
5204
|
}
|
|
@@ -5538,74 +5553,282 @@ var PublishState = class {
|
|
|
5538
5553
|
}
|
|
5539
5554
|
};
|
|
5540
5555
|
//#endregion
|
|
5541
|
-
//#region src/commands/release/
|
|
5542
|
-
|
|
5543
|
-
const
|
|
5544
|
-
|
|
5545
|
-
|
|
5556
|
+
//#region src/commands/release/registry/cli.ts
|
|
5557
|
+
async function queryNpm(args, timeout, options) {
|
|
5558
|
+
const settings = {
|
|
5559
|
+
cwd: options.cwd,
|
|
5560
|
+
env: getReleaseEnv(options),
|
|
5561
|
+
encoding: "utf8",
|
|
5562
|
+
shell: false,
|
|
5563
|
+
timeout,
|
|
5564
|
+
killSignal: "SIGKILL",
|
|
5565
|
+
stdio: [
|
|
5566
|
+
"ignore",
|
|
5567
|
+
"pipe",
|
|
5568
|
+
"pipe"
|
|
5569
|
+
]
|
|
5570
|
+
};
|
|
5571
|
+
if (options.spawn) return options.spawn("npm", args, settings);
|
|
5572
|
+
return new Promise((resolve) => {
|
|
5573
|
+
const child = spawn("npm", args, settings);
|
|
5574
|
+
let stdout = "";
|
|
5575
|
+
let stderr = "";
|
|
5576
|
+
let error;
|
|
5577
|
+
child.on("error", (value) => {
|
|
5578
|
+
error = value;
|
|
5579
|
+
});
|
|
5580
|
+
child.stdout.on("data", (value) => {
|
|
5581
|
+
stdout += String(value);
|
|
5582
|
+
});
|
|
5583
|
+
child.stderr.on("data", (value) => {
|
|
5584
|
+
stderr += String(value);
|
|
5585
|
+
});
|
|
5586
|
+
child.on("close", (status) => resolve({
|
|
5587
|
+
status,
|
|
5588
|
+
stdout,
|
|
5589
|
+
stderr,
|
|
5590
|
+
...error ? { error } : {}
|
|
5591
|
+
}));
|
|
5592
|
+
});
|
|
5593
|
+
}
|
|
5594
|
+
//#endregion
|
|
5595
|
+
//#region src/commands/release/registry/configuration.ts
|
|
5596
|
+
const require = createRequire(import.meta.url);
|
|
5597
|
+
async function registryConfiguration(options) {
|
|
5598
|
+
const config = new Config({
|
|
5599
|
+
...definitionsModule,
|
|
5600
|
+
npmPath: path.dirname(require.resolve("@npmcli/config/package.json")),
|
|
5601
|
+
argv: [],
|
|
5602
|
+
cwd: options.cwd,
|
|
5603
|
+
env: getReleaseEnv(options)
|
|
5604
|
+
});
|
|
5605
|
+
await config.load();
|
|
5606
|
+
const access = new Map(await Promise.all((await getWorkspacePackages(options.cwd)).map(async (pkg) => {
|
|
5607
|
+
const manifest = JSON.parse(await readFile(pkg.pkgJsonPath, "utf8"));
|
|
5608
|
+
return [pkg.manifest.name, manifest.publishConfig?.access];
|
|
5609
|
+
})));
|
|
5610
|
+
return (name) => {
|
|
5611
|
+
const scope = name.startsWith("@") ? name.split("/")[0] : void 0;
|
|
5612
|
+
const registry = String((scope ? config.flat[`${scope}:registry`] : void 0) ?? config.flat["registry"]);
|
|
5613
|
+
const authenticated = Object.entries(config.flat).some(([key, value]) => /(?:^|:)(?:_authToken|_auth|_password|username|certfile|keyfile)$/.test(key) && Boolean(value));
|
|
5614
|
+
const configuredTransport = [
|
|
5615
|
+
"proxy",
|
|
5616
|
+
"httpsProxy",
|
|
5617
|
+
"ca",
|
|
5618
|
+
"cert",
|
|
5619
|
+
"key",
|
|
5620
|
+
"localAddress"
|
|
5621
|
+
].some((key) => Boolean(config.flat[key])) || config.flat["strictSSL"] === false;
|
|
5622
|
+
return registry.replace(/\/$/, "") === "https://registry.npmjs.org" && access.get(name) !== "restricted" && !configuredTransport && !authenticated;
|
|
5623
|
+
};
|
|
5624
|
+
}
|
|
5625
|
+
//#endregion
|
|
5626
|
+
//#region src/commands/release/registry/settings.ts
|
|
5627
|
+
function registrySettings(options) {
|
|
5628
|
+
const config = resolveCommandValues("release", options.config).values.registry;
|
|
5629
|
+
return {
|
|
5630
|
+
concurrency: config.concurrency,
|
|
5631
|
+
requestTimeoutMs: config.requestTimeoutMs,
|
|
5632
|
+
visibilityTimeoutMs: config.visibilityTimeoutMs
|
|
5633
|
+
};
|
|
5634
|
+
}
|
|
5635
|
+
/** All workers and their retries consume the same deadline. */
|
|
5636
|
+
async function mapConcurrent(items, concurrency, task) {
|
|
5637
|
+
const results = [];
|
|
5638
|
+
let next = 0;
|
|
5639
|
+
let failure;
|
|
5640
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, items.length) }, async () => {
|
|
5641
|
+
while (next < items.length && !failure) {
|
|
5642
|
+
const index = next++;
|
|
5643
|
+
try {
|
|
5644
|
+
results[index] = await task(items[index]);
|
|
5645
|
+
} catch (error) {
|
|
5646
|
+
failure = error;
|
|
5647
|
+
}
|
|
5648
|
+
}
|
|
5649
|
+
}));
|
|
5650
|
+
if (failure) throw failure;
|
|
5651
|
+
return results;
|
|
5652
|
+
}
|
|
5653
|
+
//#endregion
|
|
5654
|
+
//#region src/commands/release/registry/index.ts
|
|
5546
5655
|
function sleep(milliseconds, options) {
|
|
5547
5656
|
return options.sleep?.(milliseconds) ?? new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
5548
5657
|
}
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5658
|
+
var RetryableQuery = class extends Error {};
|
|
5659
|
+
const clients = /* @__PURE__ */ new WeakMap();
|
|
5660
|
+
function registryClient(options) {
|
|
5661
|
+
let client = clients.get(options);
|
|
5662
|
+
if (!client) {
|
|
5663
|
+
client = new RegistryClient(options);
|
|
5664
|
+
clients.set(options, client);
|
|
5665
|
+
}
|
|
5666
|
+
return client;
|
|
5667
|
+
}
|
|
5668
|
+
var RegistryClient = class {
|
|
5669
|
+
options;
|
|
5670
|
+
versions = /* @__PURE__ */ new Map();
|
|
5671
|
+
configuration;
|
|
5672
|
+
constructor(options) {
|
|
5673
|
+
this.options = options;
|
|
5674
|
+
}
|
|
5675
|
+
async publicHttp(name) {
|
|
5676
|
+
if (this.options.spawn && !this.options.registryFetch) return false;
|
|
5677
|
+
this.configuration ??= registryConfiguration(this.options);
|
|
5678
|
+
return (await this.configuration)(name);
|
|
5679
|
+
}
|
|
5680
|
+
async http(url, timeout) {
|
|
5681
|
+
const controller = new AbortController();
|
|
5682
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
5683
|
+
try {
|
|
5684
|
+
const response = await (this.options.registryFetch ?? globalThis.fetch)(url, {
|
|
5685
|
+
signal: controller.signal,
|
|
5686
|
+
redirect: "error",
|
|
5687
|
+
headers: {
|
|
5688
|
+
"accept": "application/json",
|
|
5689
|
+
"cache-control": "no-cache"
|
|
5690
|
+
}
|
|
5691
|
+
});
|
|
5692
|
+
if (response.status === 404) {
|
|
5693
|
+
await response.body?.cancel();
|
|
5694
|
+
return;
|
|
5695
|
+
}
|
|
5696
|
+
if (!response.ok) {
|
|
5697
|
+
await response.body?.cancel();
|
|
5698
|
+
if ([401, 403].includes(response.status)) throw new ReleaseCommandError(`npm authentication failed (HTTP ${response.status}); check registry permissions`);
|
|
5699
|
+
if (response.status === 429 || response.status >= 500) throw new RetryableQuery(`HTTP ${response.status}`);
|
|
5700
|
+
throw new ReleaseCommandError(`npm registry query failed (HTTP ${response.status}); registry state is unknown`);
|
|
5701
|
+
}
|
|
5702
|
+
return await response.json();
|
|
5703
|
+
} catch (error) {
|
|
5704
|
+
if (error instanceof ReleaseCommandError || error instanceof RetryableQuery) throw error;
|
|
5705
|
+
throw new RetryableQuery(controller.signal.aborted ? `request timed out after ${timeout}ms` : error instanceof Error ? error.name : "network error");
|
|
5706
|
+
} finally {
|
|
5707
|
+
clearTimeout(timer);
|
|
5708
|
+
}
|
|
5579
5709
|
}
|
|
5710
|
+
async inspect(pkg, deadline, fields = "metadata") {
|
|
5711
|
+
const settings = registrySettings(this.options);
|
|
5712
|
+
const http = await this.publicHttp(pkg.name);
|
|
5713
|
+
let reason = "request deadline exhausted";
|
|
5714
|
+
for (let attempt = 0; attempt < 3; attempt++) {
|
|
5715
|
+
const timeout = Math.floor(Math.min(settings.requestTimeoutMs, deadline - performance.now()));
|
|
5716
|
+
if (timeout <= 0) break;
|
|
5717
|
+
try {
|
|
5718
|
+
let data;
|
|
5719
|
+
if (http) {
|
|
5720
|
+
const name = encodeURIComponent(pkg.name);
|
|
5721
|
+
data = this.versions.get(packageKey(pkg)) ?? await this.http(`https://registry.npmjs.org/${name}/${encodeURIComponent(pkg.version)}`, timeout);
|
|
5722
|
+
if (data === void 0) return;
|
|
5723
|
+
if (!data || typeof data !== "object" || data.version !== pkg.version) throw new ReleaseCommandError(`npm returned invalid metadata for ${packageKey(pkg)}; registry state is unknown`);
|
|
5724
|
+
this.versions.set(packageKey(pkg), data);
|
|
5725
|
+
if (fields === "metadata") {
|
|
5726
|
+
const remaining = Math.floor(Math.min(settings.requestTimeoutMs, deadline - performance.now()));
|
|
5727
|
+
if (remaining <= 0) throw new RetryableQuery("dist-tag request deadline exhausted");
|
|
5728
|
+
const tags = await this.http(`https://registry.npmjs.org/-/package/${name}/dist-tags`, remaining);
|
|
5729
|
+
data = {
|
|
5730
|
+
...data,
|
|
5731
|
+
"dist-tags": tags ?? {}
|
|
5732
|
+
};
|
|
5733
|
+
}
|
|
5734
|
+
} else {
|
|
5735
|
+
const result = await queryNpm([
|
|
5736
|
+
"view",
|
|
5737
|
+
packageKey(pkg),
|
|
5738
|
+
...fields === "version" ? ["version"] : ["--json"]
|
|
5739
|
+
], timeout, this.options);
|
|
5740
|
+
const output = `${String(result.stdout ?? "")}\n${String(result.stderr ?? "")}`;
|
|
5741
|
+
if (result.status !== 0) {
|
|
5742
|
+
if (!result.error && /\bE404\b/.test(output)) return;
|
|
5743
|
+
if (/\b(?:E401|E403|ENEEDAUTH)\b/.test(output)) throw new ReleaseCommandError(`npm authentication failed for ${packageKey(pkg)}`);
|
|
5744
|
+
throw new RetryableQuery(result.error?.name ?? output.match(/\b(?:E[A-Z]+|429|5\d\d)\b/)?.[0] ?? "npm query failed");
|
|
5745
|
+
}
|
|
5746
|
+
data = fields === "version" ? { version: String(result.stdout).trim() } : JSON.parse(String(result.stdout));
|
|
5747
|
+
}
|
|
5748
|
+
if (!data || typeof data !== "object" || data.version !== pkg.version) throw new ReleaseCommandError(`npm returned invalid metadata for ${packageKey(pkg)}; registry state is unknown`);
|
|
5749
|
+
return data;
|
|
5750
|
+
} catch (error) {
|
|
5751
|
+
if (!(error instanceof RetryableQuery)) throw error;
|
|
5752
|
+
reason = error.message;
|
|
5753
|
+
logger.warn(`Registry query ${packageKey(pkg)}: ${reason} (attempt ${attempt + 1}/3)`);
|
|
5754
|
+
const delay = Math.min(1e3 * 2 ** attempt, Math.max(0, deadline - performance.now()));
|
|
5755
|
+
if (attempt < 2 && delay) {
|
|
5756
|
+
await sleep(delay, this.options);
|
|
5757
|
+
if (this.options.sleep) deadline -= delay;
|
|
5758
|
+
}
|
|
5759
|
+
}
|
|
5760
|
+
}
|
|
5761
|
+
throw new ReleaseCommandError(`npm registry state is unknown for ${packageKey(pkg)} after bounded retries; no upload attempted (${reason})`);
|
|
5762
|
+
}
|
|
5763
|
+
};
|
|
5764
|
+
//#endregion
|
|
5765
|
+
//#region src/commands/release/publish/registry.ts
|
|
5766
|
+
async function refreshRegistry(state, options, packages = state.candidates, deadline = performance.now() + registrySettings(options).visibilityTimeoutMs) {
|
|
5767
|
+
const unknown = [];
|
|
5768
|
+
const client = registryClient(options);
|
|
5769
|
+
await mapConcurrent(state.unconfirmed(packages), registrySettings(options).concurrency, async (pkg) => {
|
|
5770
|
+
try {
|
|
5771
|
+
if (await client.inspect(pkg, deadline, "version")) state.confirm(pkg);
|
|
5772
|
+
} catch (error) {
|
|
5773
|
+
if (error instanceof ReleaseCommandError && error.message.includes("authentication failed")) throw error;
|
|
5774
|
+
unknown.push(pkg);
|
|
5775
|
+
logger.warn(error instanceof Error ? error.message : String(error));
|
|
5776
|
+
}
|
|
5777
|
+
});
|
|
5778
|
+
await state.save(options.cwd, "confirming");
|
|
5580
5779
|
return unknown;
|
|
5581
5780
|
}
|
|
5582
|
-
async function confirmVisibility(state, options, packages, initialDelay = 0) {
|
|
5583
|
-
|
|
5781
|
+
async function confirmVisibility(state, options, packages, initialDelay = 0, distTag) {
|
|
5782
|
+
const settings = registrySettings(options);
|
|
5783
|
+
const budget = settings.visibilityTimeoutMs;
|
|
5784
|
+
const started = performance.now();
|
|
5785
|
+
let virtualWait = 0;
|
|
5786
|
+
const elapsed = () => performance.now() - started + virtualWait;
|
|
5787
|
+
const tagged = /* @__PURE__ */ new Set();
|
|
5788
|
+
const pending = () => distTag ? packages.filter((pkg) => !tagged.has(packageKey(pkg))) : state.unconfirmed(packages);
|
|
5584
5789
|
let delay = initialDelay;
|
|
5585
5790
|
let lastProgress = 0;
|
|
5586
|
-
let pendingVersions =
|
|
5587
|
-
if (pendingVersions && !options.quiet) logger.info(`Waiting up to ${
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5598
|
-
|
|
5599
|
-
|
|
5600
|
-
|
|
5601
|
-
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5791
|
+
let pendingVersions = pending().map(packageKey).join(", ");
|
|
5792
|
+
if (pendingVersions && !options.quiet) logger.info(`Waiting up to ${budget / 6e4} minutes for npm registry visibility${distTag ? ` and dist-tag ${distTag}` : ""}; pending versions: ${pendingVersions}`);
|
|
5793
|
+
try {
|
|
5794
|
+
while (pending().length && elapsed() < budget) {
|
|
5795
|
+
const wait = Math.min(delay, budget - elapsed());
|
|
5796
|
+
if (wait) {
|
|
5797
|
+
const before = performance.now();
|
|
5798
|
+
await sleep(wait, options);
|
|
5799
|
+
virtualWait += Math.max(0, wait - (performance.now() - before));
|
|
5800
|
+
}
|
|
5801
|
+
if (elapsed() >= budget) break;
|
|
5802
|
+
const deadline = performance.now() + Math.max(0, budget - elapsed());
|
|
5803
|
+
if (distTag) await mapConcurrent(pending(), settings.concurrency, async (pkg) => {
|
|
5804
|
+
const remote = await registryClient(options).inspect(pkg, deadline);
|
|
5805
|
+
if (remote) {
|
|
5806
|
+
state.accept([pkg]);
|
|
5807
|
+
if (remote["dist-tags"]?.[distTag] === pkg.version) {
|
|
5808
|
+
state.confirm(pkg);
|
|
5809
|
+
tagged.add(packageKey(pkg));
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
});
|
|
5813
|
+
else {
|
|
5814
|
+
const unknown = await refreshRegistry(state, options, packages, deadline);
|
|
5815
|
+
if (unknown.length && elapsed() < budget) throw new ReleaseCommandError(`npm registry state is unknown after bounded retries: ${unknown.map(packageKey).join(", ")}; upload evidence preserved`);
|
|
5816
|
+
}
|
|
5817
|
+
await state.save(options.cwd, "confirming");
|
|
5818
|
+
const next = pending().map(packageKey).join(", ");
|
|
5819
|
+
if (next && elapsed() < budget && !options.quiet && (next !== pendingVersions || elapsed() - lastProgress >= 6e4)) {
|
|
5820
|
+
logger.info(`Waiting for npm registry visibility (${Math.floor(elapsed() / 1e3)}s/${budget / 1e3}s); pending versions: ${next}`);
|
|
5821
|
+
lastProgress = elapsed();
|
|
5822
|
+
}
|
|
5823
|
+
pendingVersions = next;
|
|
5824
|
+
delay = elapsed() < 3e4 ? 2e3 : elapsed() < 12e4 ? 5e3 : 1e4;
|
|
5825
|
+
}
|
|
5826
|
+
if (pending().length) throw new ReleaseCommandError(`npm registry visibility confirmation timed out after ${budget / 6e4} minutes; pending versions: ${pending().map(packageKey).join(", ")}${distTag ? ` (including dist-tag ${distTag})` : ""}. Upload evidence is preserved in repoctl-publish-progress.json; resume confirmation without re-uploading accepted versions.`);
|
|
5827
|
+
if (packages.length && !options.quiet) logger.info("npm registry visibility confirmed for all requested versions.");
|
|
5828
|
+
} catch (error) {
|
|
5829
|
+
await state.save(options.cwd, "failed");
|
|
5830
|
+
throw error;
|
|
5831
|
+
}
|
|
5609
5832
|
}
|
|
5610
5833
|
//#endregion
|
|
5611
5834
|
//#region src/commands/release/publish/index.ts
|
|
@@ -5634,16 +5857,16 @@ async function publishWithRetry(args, options, candidates, confirmAll = false, r
|
|
|
5634
5857
|
state.accept(await readPublishSummary(options.cwd));
|
|
5635
5858
|
await state.save(options.cwd, "publishing");
|
|
5636
5859
|
if (result.status === 0) {
|
|
5637
|
-
await confirmVisibility(state, options, recovering ? candidates : state.acceptedPackages);
|
|
5638
|
-
await state.save(options.cwd, "complete");
|
|
5860
|
+
if (!options.deferConfirmation) await confirmVisibility(state, options, recovering ? candidates : state.acceptedPackages);
|
|
5861
|
+
await state.save(options.cwd, options.deferConfirmation ? "confirming" : "complete");
|
|
5639
5862
|
return;
|
|
5640
5863
|
}
|
|
5641
5864
|
recovering = true;
|
|
5642
|
-
await refreshRegistry(state, options);
|
|
5643
|
-
await state.save(options.cwd, "publishing");
|
|
5644
5865
|
const transient = isTransientPublishFailure(result.output);
|
|
5645
5866
|
const conflict = isPublishConflict(result.output);
|
|
5646
5867
|
if (!transient && !conflict) throw new ReleaseCommandError(`command failed: pnpm ${args.join(" ")}`, result.status ?? 1);
|
|
5868
|
+
await refreshRegistry(state, options);
|
|
5869
|
+
await state.save(options.cwd, "publishing");
|
|
5647
5870
|
if (!state.pendingUploads.length || conflict && !transient) {
|
|
5648
5871
|
await confirmVisibility(state, options, candidates, state.unconfirmed(candidates).length ? 2e4 : 0);
|
|
5649
5872
|
await state.save(options.cwd, "complete");
|
|
@@ -5780,44 +6003,14 @@ function releaseStateKey(repository, distTag, candidates) {
|
|
|
5780
6003
|
}
|
|
5781
6004
|
//#endregion
|
|
5782
6005
|
//#region src/commands/release/lifecycle/registry.ts
|
|
5783
|
-
/**
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
"view",
|
|
5788
|
-
packageKey(pkg),
|
|
5789
|
-
"--json"
|
|
5790
|
-
], {
|
|
5791
|
-
cwd: options.cwd,
|
|
5792
|
-
env: getReleaseEnv(options),
|
|
5793
|
-
encoding: "utf8",
|
|
5794
|
-
shell: false,
|
|
5795
|
-
stdio: [
|
|
5796
|
-
"ignore",
|
|
5797
|
-
"pipe",
|
|
5798
|
-
"pipe"
|
|
5799
|
-
],
|
|
5800
|
-
timeout: 1e4,
|
|
5801
|
-
killSignal: "SIGKILL"
|
|
5802
|
-
});
|
|
5803
|
-
const output = `${String(result.stdout ?? "")}
|
|
5804
|
-
${String(result.stderr ?? "")}`;
|
|
5805
|
-
if (result.status === 0) {
|
|
5806
|
-
try {
|
|
5807
|
-
const data = JSON.parse(String(result.stdout));
|
|
5808
|
-
if (data.version === pkg.version) return data;
|
|
5809
|
-
} catch {}
|
|
5810
|
-
throw new ReleaseCommandError(`npm returned invalid metadata for ${packageKey(pkg)}; registry state is unknown`);
|
|
5811
|
-
}
|
|
5812
|
-
if (/\bE404\b/.test(output) && !result.error) return;
|
|
5813
|
-
if (/\b(?:E401|E403|ENEEDAUTH)\b/.test(output)) throw new ReleaseCommandError(`npm authentication failed for ${packageKey(pkg)}`);
|
|
5814
|
-
if (attempt < 2) await sleep(1e3 * 2 ** attempt, options);
|
|
5815
|
-
}
|
|
5816
|
-
throw new ReleaseCommandError(`npm registry state is unknown for ${packageKey(pkg)} after bounded retries; no upload attempted`);
|
|
6006
|
+
/** Only an explicit 404 proves absence; unknown state must never cause an upload. */
|
|
6007
|
+
function inspectRegistry(pkg, options, deadline) {
|
|
6008
|
+
const settings = registrySettings(options);
|
|
6009
|
+
return registryClient(options).inspect(pkg, deadline ?? performance.now() + Math.min(settings.visibilityTimeoutMs, settings.requestTimeoutMs * 6 + 3e3));
|
|
5817
6010
|
}
|
|
5818
6011
|
//#endregion
|
|
5819
|
-
//#region src/commands/release/lifecycle/
|
|
5820
|
-
async function
|
|
6012
|
+
//#region src/commands/release/lifecycle/session.ts
|
|
6013
|
+
async function openLifecycle(options, selected, distTag = "latest") {
|
|
5821
6014
|
const github = resolveGitHub(options);
|
|
5822
6015
|
if (!github.readReleaseState || !github.writeReleaseState || !github.ensureTag || !github.listReleases) throw new ReleaseCommandError("Release recovery requires checkpoint, tag and release query operations");
|
|
5823
6016
|
const env = getReleaseEnv(options);
|
|
@@ -5834,7 +6027,11 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5834
6027
|
let revision = snapshot?.revision;
|
|
5835
6028
|
const releases = new Map((await github.listReleases()).map((release) => [release.tag_name, release]));
|
|
5836
6029
|
const registry = /* @__PURE__ */ new Map();
|
|
5837
|
-
|
|
6030
|
+
const settings = registrySettings(options);
|
|
6031
|
+
const deadline = performance.now() + Math.min(settings.visibilityTimeoutMs, settings.requestTimeoutMs * 6 + 3e3);
|
|
6032
|
+
await mapConcurrent(candidates, settings.concurrency, async (pkg) => {
|
|
6033
|
+
registry.set(packageKey(pkg), await inspectRegistry(pkg, options, deadline));
|
|
6034
|
+
});
|
|
5838
6035
|
const tags = /* @__PURE__ */ new Map();
|
|
5839
6036
|
if (github.readTagTarget) for (const pkg of candidates) tags.set(packageKey(pkg), await github.readTagTarget(packageKey(pkg)));
|
|
5840
6037
|
let state;
|
|
@@ -5871,7 +6068,7 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5871
6068
|
}
|
|
5872
6069
|
if (!packages.length) {
|
|
5873
6070
|
logger.info("No unfinished release targets found.");
|
|
5874
|
-
return
|
|
6071
|
+
return;
|
|
5875
6072
|
}
|
|
5876
6073
|
const legacy = packages.some((pkg) => registry.has(packageKey(pkg)) && registry.get(packageKey(pkg)));
|
|
5877
6074
|
state = {
|
|
@@ -5906,10 +6103,10 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5906
6103
|
metadata: state.packages.filter((pkg) => !releases.has(packageKey(pkg))).map(packageKey),
|
|
5907
6104
|
hooks: state.hooks
|
|
5908
6105
|
}, null, 2));
|
|
5909
|
-
return state.packages.map(({ name, version }) => ({
|
|
6106
|
+
return { preview: state.packages.map(({ name, version }) => ({
|
|
5910
6107
|
name,
|
|
5911
6108
|
version
|
|
5912
|
-
}));
|
|
6109
|
+
})) };
|
|
5913
6110
|
}
|
|
5914
6111
|
state.writer = randomUUID();
|
|
5915
6112
|
state.complete = false;
|
|
@@ -5922,12 +6119,26 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5922
6119
|
name,
|
|
5923
6120
|
version
|
|
5924
6121
|
}));
|
|
6122
|
+
return {
|
|
6123
|
+
github,
|
|
6124
|
+
env,
|
|
6125
|
+
rule,
|
|
6126
|
+
state,
|
|
6127
|
+
save,
|
|
6128
|
+
packages,
|
|
6129
|
+
registry,
|
|
6130
|
+
releases
|
|
6131
|
+
};
|
|
6132
|
+
}
|
|
6133
|
+
//#endregion
|
|
6134
|
+
//#region src/commands/release/lifecycle/index.ts
|
|
6135
|
+
async function upload(session, options, distTag) {
|
|
6136
|
+
const { state, save, packages, registry, rule } = session;
|
|
5925
6137
|
const confirmed = new PublishState(packages);
|
|
5926
6138
|
confirmed.accept(state.accepted);
|
|
5927
6139
|
for (const pkg of packages) if (registry.get(packageKey(pkg))) confirmed.confirm(pkg);
|
|
5928
|
-
if (state.npm === "running") await confirmVisibility(confirmed, options, packages);
|
|
5929
|
-
|
|
5930
|
-
const missing = packages.filter((pkg) => !confirmed.acceptedPackages.some((item) => packageKey(item) === packageKey(pkg)));
|
|
6140
|
+
if (state.npm === "running" && (!state.uploadComplete || packages.some((pkg) => !state.accepted.some((accepted) => packageKey(accepted) === packageKey(pkg))))) await confirmVisibility(confirmed, options, packages);
|
|
6141
|
+
const missing = confirmed.pendingUploads;
|
|
5931
6142
|
if (missing.length) {
|
|
5932
6143
|
runReleaseHooks("beforePublish", options);
|
|
5933
6144
|
const actual = await getPublishCandidates(options.cwd);
|
|
@@ -5935,7 +6146,7 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5935
6146
|
if (rule) assertReleaseLineVersions(rule, actual);
|
|
5936
6147
|
await clearPublishSummary(options.cwd);
|
|
5937
6148
|
state.npm = "running";
|
|
5938
|
-
state.
|
|
6149
|
+
state.uploadComplete = false;
|
|
5939
6150
|
await save();
|
|
5940
6151
|
try {
|
|
5941
6152
|
await publishWithRetry([
|
|
@@ -5947,7 +6158,10 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5947
6158
|
"--tag",
|
|
5948
6159
|
distTag,
|
|
5949
6160
|
...missing.flatMap((pkg) => ["--filter", pkg.name])
|
|
5950
|
-
],
|
|
6161
|
+
], {
|
|
6162
|
+
...options,
|
|
6163
|
+
deferConfirmation: true
|
|
6164
|
+
}, packages, true, {
|
|
5951
6165
|
accepted: confirmed.acceptedPackages,
|
|
5952
6166
|
save: async (accepted) => {
|
|
5953
6167
|
state.accepted = accepted;
|
|
@@ -5959,15 +6173,33 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5959
6173
|
await save();
|
|
5960
6174
|
throw error;
|
|
5961
6175
|
}
|
|
5962
|
-
}
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
6176
|
+
} else state.accepted = confirmed.acceptedPackages;
|
|
6177
|
+
state.uploadComplete = packages.every((pkg) => state.accepted.some((accepted) => packageKey(accepted) === packageKey(pkg)));
|
|
6178
|
+
await save();
|
|
6179
|
+
}
|
|
6180
|
+
async function confirm(session, options, distTag) {
|
|
6181
|
+
const { state, packages, save } = session;
|
|
6182
|
+
if (state.npm !== "running" && packages.some((pkg) => !state.accepted.some((accepted) => packageKey(accepted) === packageKey(pkg)))) throw new ReleaseCommandError("Confirmation requires accepted upload evidence for every release target; run upload first");
|
|
6183
|
+
const confirmed = new PublishState(packages, async (accepted) => {
|
|
6184
|
+
state.accepted = accepted;
|
|
6185
|
+
await save();
|
|
6186
|
+
});
|
|
6187
|
+
confirmed.accept(state.accepted);
|
|
6188
|
+
try {
|
|
6189
|
+
await confirmVisibility(confirmed, options, packages, 0, distTag);
|
|
6190
|
+
} catch (error) {
|
|
6191
|
+
state.npm = "failed";
|
|
6192
|
+
await save();
|
|
6193
|
+
throw error;
|
|
5966
6194
|
}
|
|
5967
6195
|
state.npm = "complete";
|
|
5968
6196
|
state.accepted = packages;
|
|
5969
6197
|
await save();
|
|
5970
6198
|
await writeFile(path.join(options.cwd, "pnpm-publish-summary.json"), JSON.stringify({ publishedPackages: packages }));
|
|
6199
|
+
}
|
|
6200
|
+
async function finalize(session, options) {
|
|
6201
|
+
const { github, state, packages, releases, env, save } = session;
|
|
6202
|
+
if (state.npm !== "complete") throw new ReleaseCommandError("Finalize requires completed version/dist-tag confirmation; run confirm first");
|
|
5971
6203
|
for (const pkg of state.packages) {
|
|
5972
6204
|
await github.ensureTag({
|
|
5973
6205
|
tag: packageKey(pkg),
|
|
@@ -5990,7 +6222,16 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
5990
6222
|
state.complete = true;
|
|
5991
6223
|
await save();
|
|
5992
6224
|
logger.success(`Release lifecycle complete: ${packages.map(packageKey).join(", ")}`);
|
|
5993
|
-
|
|
6225
|
+
}
|
|
6226
|
+
async function publishLifecycle(options, selected, distTag = "latest") {
|
|
6227
|
+
const session = await openLifecycle(options, selected, distTag);
|
|
6228
|
+
if (!session) return [];
|
|
6229
|
+
if ("preview" in session) return session.preview;
|
|
6230
|
+
const stage = options.stage ?? "all";
|
|
6231
|
+
if (stage === "all" || stage === "upload") await upload(session, options, distTag);
|
|
6232
|
+
if (stage === "all" || stage === "confirm") await confirm(session, options, distTag);
|
|
6233
|
+
if (stage === "all" || stage === "finalize") await finalize(session, options);
|
|
6234
|
+
return session.packages;
|
|
5994
6235
|
}
|
|
5995
6236
|
//#endregion
|
|
5996
6237
|
//#region src/core/oidc/identity.ts
|
|
@@ -6831,6 +7072,382 @@ async function readReleaseTriggerContext(options) {
|
|
|
6831
7072
|
};
|
|
6832
7073
|
}
|
|
6833
7074
|
//#endregion
|
|
7075
|
+
//#region src/commands/release/stages/receipt.ts
|
|
7076
|
+
function ordered(value) {
|
|
7077
|
+
if (Array.isArray(value)) return value.map(ordered);
|
|
7078
|
+
if (value && typeof value === "object") return Object.fromEntries(Object.entries(value).sort(([a], [b]) => a.localeCompare(b)).map(([key, item]) => [key, ordered(item)]));
|
|
7079
|
+
return value;
|
|
7080
|
+
}
|
|
7081
|
+
function stageDirectory(options) {
|
|
7082
|
+
const directory = capture("git", ["rev-parse", "--git-dir"], options);
|
|
7083
|
+
if (!directory) throw new ReleaseCommandError("Staged release requires a Git checkout");
|
|
7084
|
+
return path.resolve(options.cwd, directory, "repoctl-release-ci");
|
|
7085
|
+
}
|
|
7086
|
+
async function stageIdentity(options) {
|
|
7087
|
+
const env = getReleaseEnv(options);
|
|
7088
|
+
const untracked = capture("git", [
|
|
7089
|
+
"ls-files",
|
|
7090
|
+
"--others",
|
|
7091
|
+
"--exclude-standard",
|
|
7092
|
+
"-z"
|
|
7093
|
+
], options).split("\0").filter(Boolean).filter((file) => ![
|
|
7094
|
+
"repoctl-ci-progress.json",
|
|
7095
|
+
"repoctl-publish-progress.json",
|
|
7096
|
+
"repoctl-release-progress.json",
|
|
7097
|
+
"pnpm-publish-summary.json"
|
|
7098
|
+
].includes(file));
|
|
7099
|
+
const value = {
|
|
7100
|
+
files: await Promise.all(untracked.sort().map(async (file) => [file, createHash("sha256").update(await readFile(path.join(options.cwd, file))).digest("hex")])),
|
|
7101
|
+
repository: env["GITHUB_REPOSITORY"] ?? capture("git", [
|
|
7102
|
+
"remote",
|
|
7103
|
+
"get-url",
|
|
7104
|
+
"origin"
|
|
7105
|
+
], options),
|
|
7106
|
+
source: capture("git", ["rev-parse", "HEAD"], options),
|
|
7107
|
+
diff: capture("git", [
|
|
7108
|
+
"diff",
|
|
7109
|
+
"--binary",
|
|
7110
|
+
"HEAD"
|
|
7111
|
+
], options),
|
|
7112
|
+
candidates: (await getPublishCandidates(options.cwd)).map(packageKey).sort(),
|
|
7113
|
+
configuration: options.config,
|
|
7114
|
+
branch: options.branch ?? env["GITHUB_REF_NAME"],
|
|
7115
|
+
mode: resolveReleaseMode(options),
|
|
7116
|
+
recovery: options.sourceSha ?? env["REPO_RELEASE_RECOVERY_SOURCE_SHA"],
|
|
7117
|
+
selection: [options.packageName ?? env["REPO_RELEASE_PACKAGE"], options.packageVersion ?? env["REPO_RELEASE_VERSION"]],
|
|
7118
|
+
dryRun: options.dryRun ?? env["REPO_RELEASE_DRY_RUN"] === "true",
|
|
7119
|
+
run: [env["GITHUB_RUN_ID"], env["GITHUB_RUN_ATTEMPT"]]
|
|
7120
|
+
};
|
|
7121
|
+
return createHash("sha256").update(JSON.stringify(ordered(value))).digest("hex");
|
|
7122
|
+
}
|
|
7123
|
+
async function saveReceipt(receipt, options) {
|
|
7124
|
+
const directory = stageDirectory(options);
|
|
7125
|
+
await mkdir(directory, { recursive: true });
|
|
7126
|
+
const exclude = path.resolve(directory, "../info/exclude");
|
|
7127
|
+
await mkdir(path.dirname(exclude), { recursive: true });
|
|
7128
|
+
const previous = await readFile(exclude, "utf8").catch((error) => {
|
|
7129
|
+
if (error.code !== "ENOENT") throw error;
|
|
7130
|
+
return "";
|
|
7131
|
+
});
|
|
7132
|
+
const ignored = [
|
|
7133
|
+
"repoctl-ci-progress.json",
|
|
7134
|
+
"repoctl-publish-progress.json",
|
|
7135
|
+
"repoctl-release-progress.json",
|
|
7136
|
+
"pnpm-publish-summary.json"
|
|
7137
|
+
].map((file) => `/${file}`).filter((file) => !previous.split("\n").includes(file));
|
|
7138
|
+
if (ignored.length) await appendFile(exclude, `\n${ignored.join("\n")}\n`);
|
|
7139
|
+
const filename = path.join(directory, "receipt.json");
|
|
7140
|
+
const temporary = `${filename}.${randomUUID()}.tmp`;
|
|
7141
|
+
await writeFile(temporary, `${JSON.stringify(receipt, null, 2)}\n`);
|
|
7142
|
+
await rename(temporary, filename);
|
|
7143
|
+
await writeFile(path.join(options.cwd, "repoctl-ci-progress.json"), `${JSON.stringify(receipt, null, 2)}\n`);
|
|
7144
|
+
}
|
|
7145
|
+
async function readReceipt(options) {
|
|
7146
|
+
try {
|
|
7147
|
+
const receipt = JSON.parse(await readFile(path.join(stageDirectory(options), "receipt.json"), "utf8"));
|
|
7148
|
+
if (receipt.schemaVersion !== 1 || receipt.identity !== await stageIdentity(options)) throw new ReleaseCommandError("Stale release stage receipt: repository, source, candidates, configuration or run changed; restart at plan and verify");
|
|
7149
|
+
return receipt;
|
|
7150
|
+
} catch (error) {
|
|
7151
|
+
if (error.code === "ENOENT") throw new ReleaseCommandError("Release stage receipt missing; run plan and verify first");
|
|
7152
|
+
throw error;
|
|
7153
|
+
}
|
|
7154
|
+
}
|
|
7155
|
+
async function stageOutput(options, values) {
|
|
7156
|
+
const filename = getReleaseEnv(options)["GITHUB_OUTPUT"];
|
|
7157
|
+
if (filename) await appendFile(filename, `${Object.entries(values).map(([key, value]) => `${key}=${value}`).join("\n")}\n`);
|
|
7158
|
+
}
|
|
7159
|
+
async function reportStage(receipt, options, stage, started, status, progressCwd = options.cwd) {
|
|
7160
|
+
let accepted = [];
|
|
7161
|
+
let targets = receipt.candidates;
|
|
7162
|
+
try {
|
|
7163
|
+
const progress = JSON.parse(await readFile(path.join(progressCwd, "repoctl-publish-progress.json"), "utf8"));
|
|
7164
|
+
targets = progress.candidates ?? targets;
|
|
7165
|
+
accepted = stage === "confirm" ? progress.confirmedPackages ?? [] : progress.acceptedPackages ?? [];
|
|
7166
|
+
} catch (error) {
|
|
7167
|
+
if (error.code !== "ENOENT") logger.warn("Could not read publish progress for stage summary; durable checkpoint is preserved");
|
|
7168
|
+
}
|
|
7169
|
+
const pending = [
|
|
7170
|
+
"upload",
|
|
7171
|
+
"confirm",
|
|
7172
|
+
"finalize"
|
|
7173
|
+
].includes(stage) && receipt.publish ? targets.filter((pkg) => !accepted.some((item) => packageKey(item) === packageKey(pkg))).map(packageKey) : [];
|
|
7174
|
+
const elapsedMs = Math.round(performance.now() - started);
|
|
7175
|
+
const count = ["upload", "confirm"].includes(stage) ? accepted.length : targets.length;
|
|
7176
|
+
receipt.stages.push({
|
|
7177
|
+
stage,
|
|
7178
|
+
elapsedMs,
|
|
7179
|
+
status,
|
|
7180
|
+
count,
|
|
7181
|
+
pending
|
|
7182
|
+
});
|
|
7183
|
+
logger.info(`Release ${stage}: ${status}; ${(elapsedMs / 1e3).toFixed(2)}s; completed ${count}; pending ${pending.join(", ") || "(none)"}`);
|
|
7184
|
+
const summary = getReleaseEnv(options)["GITHUB_STEP_SUMMARY"];
|
|
7185
|
+
if (summary) await appendFile(summary, `### Release ${stage}\n\n- Status: ${status}\n- Duration: ${(elapsedMs / 1e3).toFixed(2)}s\n- Completed: ${count}\n- Pending: ${pending.join(", ") || "(none)"}\n\n`);
|
|
7186
|
+
await saveReceipt(receipt, options);
|
|
7187
|
+
}
|
|
7188
|
+
//#endregion
|
|
7189
|
+
//#region src/commands/release/stages/source.ts
|
|
7190
|
+
async function stagedSource(options, create = false, install = false) {
|
|
7191
|
+
const source = options.sourceSha ?? getReleaseEnv(options)["REPO_RELEASE_RECOVERY_SOURCE_SHA"]?.trim();
|
|
7192
|
+
if (!source) return {
|
|
7193
|
+
options,
|
|
7194
|
+
selected: void 0
|
|
7195
|
+
};
|
|
7196
|
+
const mode = resolveReleaseMode(options);
|
|
7197
|
+
const rule = await resolveStableReleaseBranch(options, "publish");
|
|
7198
|
+
if (!/^[a-f0-9]{40}$/.test(source) || !["publish", "publish-unpublished"].includes(mode)) throw new ReleaseCommandError("source-sha requires a full commit SHA and a publish mode");
|
|
7199
|
+
if (capture("git", ["rev-parse", "--is-shallow-repository"], options) !== "false") throw new ReleaseCommandError("Source recovery requires full Git history");
|
|
7200
|
+
run("git", [
|
|
7201
|
+
"merge-base",
|
|
7202
|
+
"--is-ancestor",
|
|
7203
|
+
source,
|
|
7204
|
+
`refs/remotes/origin/${rule.branch}`
|
|
7205
|
+
], options);
|
|
7206
|
+
const root = path.join(stageDirectory(options), "source");
|
|
7207
|
+
const cwd = path.join(root, "checkout");
|
|
7208
|
+
const env = {
|
|
7209
|
+
...getReleaseEnv(options),
|
|
7210
|
+
REPO_RELEASE_SOURCE_SHA: source
|
|
7211
|
+
};
|
|
7212
|
+
let recovery = {
|
|
7213
|
+
...options,
|
|
7214
|
+
cwd,
|
|
7215
|
+
branch: rule.branch,
|
|
7216
|
+
env
|
|
7217
|
+
};
|
|
7218
|
+
if (create) {
|
|
7219
|
+
await rm(root, {
|
|
7220
|
+
recursive: true,
|
|
7221
|
+
force: true
|
|
7222
|
+
});
|
|
7223
|
+
await mkdir(root, { recursive: true });
|
|
7224
|
+
run("git", [
|
|
7225
|
+
"clone",
|
|
7226
|
+
"--shared",
|
|
7227
|
+
"--no-checkout",
|
|
7228
|
+
options.cwd,
|
|
7229
|
+
cwd
|
|
7230
|
+
], options);
|
|
7231
|
+
run("git", [
|
|
7232
|
+
"remote",
|
|
7233
|
+
"set-url",
|
|
7234
|
+
"origin",
|
|
7235
|
+
capture("git", [
|
|
7236
|
+
"remote",
|
|
7237
|
+
"get-url",
|
|
7238
|
+
"origin"
|
|
7239
|
+
], options)
|
|
7240
|
+
], recovery);
|
|
7241
|
+
run("git", [
|
|
7242
|
+
"checkout",
|
|
7243
|
+
"--detach",
|
|
7244
|
+
source
|
|
7245
|
+
], recovery);
|
|
7246
|
+
}
|
|
7247
|
+
if (capture("git", ["rev-parse", "HEAD"], recovery) !== source || capture("git", [
|
|
7248
|
+
"diff",
|
|
7249
|
+
"--binary",
|
|
7250
|
+
"HEAD"
|
|
7251
|
+
], recovery)) throw new ReleaseCommandError("Recovery checkout changed; restart at plan and verify");
|
|
7252
|
+
clearWorkspaceCache();
|
|
7253
|
+
const candidates = await readSourceCandidates(recovery, source);
|
|
7254
|
+
assertReleaseLineVersions(rule, candidates);
|
|
7255
|
+
if (!candidates.length || await hasPendingIntents(cwd)) throw new ReleaseCommandError("Source must contain prepared release versions and no pending intents");
|
|
7256
|
+
const name = options.packageName ?? env["REPO_RELEASE_PACKAGE"];
|
|
7257
|
+
const version = options.packageVersion ?? env["REPO_RELEASE_VERSION"];
|
|
7258
|
+
if ((name || version) && !candidates.some((pkg) => pkg.name === name && pkg.version === version)) throw new ReleaseCommandError("Requested package/version is not part of the source release");
|
|
7259
|
+
const github = resolveGitHub(options);
|
|
7260
|
+
let selected = candidates;
|
|
7261
|
+
const workspace = await getPublishCandidates(cwd);
|
|
7262
|
+
const repository = env["GITHUB_REPOSITORY"];
|
|
7263
|
+
if (repository && github.readReleaseState) {
|
|
7264
|
+
const checkpoint = await github.readReleaseState(releaseStateKey(repository, rule.distTag, workspace));
|
|
7265
|
+
if (checkpoint) {
|
|
7266
|
+
if (checkpoint.state.packages.some((pkg) => pkg.target !== source || !candidates.some((item) => packageKey(item) === packageKey(pkg)))) throw new ReleaseCommandError("Existing checkpoint belongs to another source release");
|
|
7267
|
+
selected = workspace;
|
|
7268
|
+
}
|
|
7269
|
+
}
|
|
7270
|
+
if (!(options.dryRun ?? env["REPO_RELEASE_DRY_RUN"] === "true")) {
|
|
7271
|
+
recovery = {
|
|
7272
|
+
...recovery,
|
|
7273
|
+
env: await sourcePackageManagerEnvironment(recovery, root)
|
|
7274
|
+
};
|
|
7275
|
+
if (install) run("pnpm", ["install", "--frozen-lockfile"], recovery);
|
|
7276
|
+
if (!create || install) {
|
|
7277
|
+
const config = await resolveCommandConfig("release", cwd);
|
|
7278
|
+
recovery = {
|
|
7279
|
+
...recovery,
|
|
7280
|
+
config: {
|
|
7281
|
+
...config,
|
|
7282
|
+
branches: options.config?.branches ?? {}
|
|
7283
|
+
}
|
|
7284
|
+
};
|
|
7285
|
+
}
|
|
7286
|
+
}
|
|
7287
|
+
return {
|
|
7288
|
+
options: {
|
|
7289
|
+
...recovery,
|
|
7290
|
+
github
|
|
7291
|
+
},
|
|
7292
|
+
selected
|
|
7293
|
+
};
|
|
7294
|
+
}
|
|
7295
|
+
//#endregion
|
|
7296
|
+
//#region src/commands/release/stages/index.ts
|
|
7297
|
+
const stages = [
|
|
7298
|
+
"plan",
|
|
7299
|
+
"verify",
|
|
7300
|
+
"prepare",
|
|
7301
|
+
"upload",
|
|
7302
|
+
"confirm",
|
|
7303
|
+
"finalize"
|
|
7304
|
+
];
|
|
7305
|
+
async function plan(options) {
|
|
7306
|
+
const mode = resolveReleaseMode(options);
|
|
7307
|
+
const event = getReleaseEnv(options)["GITHUB_EVENT_NAME"]?.trim();
|
|
7308
|
+
let action = "publish";
|
|
7309
|
+
if (mode === "auto" && event && event !== "workflow_dispatch" && !shouldRunRelease(await readReleaseTriggerContext(options))) action = "skip";
|
|
7310
|
+
else if (mode === "reconcile") action = "reconcile";
|
|
7311
|
+
else if (options.sourceSha ?? getReleaseEnv(options)["REPO_RELEASE_RECOVERY_SOURCE_SHA"]) await stagedSource(options, true);
|
|
7312
|
+
else if (mode === "prepare") action = "prepare";
|
|
7313
|
+
else if (mode === "auto") action = (await resolveReleaseBranch(options)).kind === "prerelease" ? "prerelease" : await hasPendingIntents(options.cwd) ? "prepare" : "publish";
|
|
7314
|
+
else if (!["publish", "publish-unpublished"].includes(mode)) throw new ReleaseCommandError(`Unknown release CI mode: ${mode}`);
|
|
7315
|
+
if (mode === "publish-unpublished" && !(options.sourceSha ?? getReleaseEnv(options)["REPO_RELEASE_RECOVERY_SOURCE_SHA"])) {
|
|
7316
|
+
const env = getReleaseEnv(options);
|
|
7317
|
+
const name = options.packageName ?? env["REPO_RELEASE_PACKAGE"];
|
|
7318
|
+
const version = options.packageVersion ?? env["REPO_RELEASE_VERSION"];
|
|
7319
|
+
if (!name || !version || !(await getPublishCandidates(options.cwd)).some((pkg) => pkg.name === name && pkg.version === version)) throw new ReleaseCommandError("publish-unpublished requires a matching workspace package and exact version");
|
|
7320
|
+
}
|
|
7321
|
+
return {
|
|
7322
|
+
schemaVersion: 1,
|
|
7323
|
+
id: randomUUID(),
|
|
7324
|
+
identity: await stageIdentity(options),
|
|
7325
|
+
action,
|
|
7326
|
+
publish: !["skip", "prepare"].includes(action),
|
|
7327
|
+
done: [],
|
|
7328
|
+
candidates: await getPublishCandidates(options.cwd),
|
|
7329
|
+
stages: []
|
|
7330
|
+
};
|
|
7331
|
+
}
|
|
7332
|
+
async function verify(options, action) {
|
|
7333
|
+
const dryRun = options.dryRun ?? getReleaseEnv(options)["REPO_RELEASE_DRY_RUN"] === "true";
|
|
7334
|
+
if (action === "reconcile" || dryRun) return;
|
|
7335
|
+
if (getReleaseEnv(options)["REPO_RELEASE_SOURCE_SHA"]) {
|
|
7336
|
+
await runQualityScripts(options);
|
|
7337
|
+
return;
|
|
7338
|
+
}
|
|
7339
|
+
const rule = await resolveReleaseBranch(options);
|
|
7340
|
+
const pending = await hasPendingIntents(options.cwd);
|
|
7341
|
+
if (action === "prepare" && !pending) return;
|
|
7342
|
+
if (action === "prepare" || action === "prerelease" && pending) {
|
|
7343
|
+
if (action === "prepare" && rule.kind === "prerelease") throw new ReleaseCommandError("Stable preparation requires a stable release branch");
|
|
7344
|
+
if (rule.kind === "prerelease") await assertLaneAssignments(rule.lane, options);
|
|
7345
|
+
else await assertStableLaneAssignments(options);
|
|
7346
|
+
await assertPlannedLine(rule, options);
|
|
7347
|
+
await assertPreviousReleaseComplete(options, rule.distTag);
|
|
7348
|
+
runReleaseHooks("beforeVersion", options);
|
|
7349
|
+
} else if (rule.kind === "prerelease") {
|
|
7350
|
+
await assertLaneAssignments(rule.lane, options);
|
|
7351
|
+
assertReleaseLineVersions(rule, await getPublishCandidates(options.cwd));
|
|
7352
|
+
} else await assertStablePublish(options, false);
|
|
7353
|
+
await runQualityScripts(options);
|
|
7354
|
+
}
|
|
7355
|
+
async function releaseCiStage(options) {
|
|
7356
|
+
const stage = options.stage;
|
|
7357
|
+
if (!stages.includes(stage)) throw new ReleaseCommandError(`Unknown release CI stage ${stage}; expected all, ${stages.join(", ")}`);
|
|
7358
|
+
const started = performance.now();
|
|
7359
|
+
const receipt = stage === "plan" ? await plan(options) : await readReceipt(options);
|
|
7360
|
+
if (stage !== "plan" && !receipt.done.includes(stages[stages.indexOf(stage) - 1])) throw new ReleaseCommandError(`Release ${stage} requires the preceding stage to complete; restart at plan if interrupted`);
|
|
7361
|
+
if (receipt.done.includes(stage)) {
|
|
7362
|
+
await stageOutput(options, {
|
|
7363
|
+
run: receipt.action !== "skip",
|
|
7364
|
+
publish: receipt.publish
|
|
7365
|
+
});
|
|
7366
|
+
return receipt;
|
|
7367
|
+
}
|
|
7368
|
+
await saveReceipt(receipt, options);
|
|
7369
|
+
let effective = options;
|
|
7370
|
+
try {
|
|
7371
|
+
if (receipt.action !== "skip") {
|
|
7372
|
+
const source = stage === "plan" ? void 0 : await stagedSource(options, false, stage === "verify");
|
|
7373
|
+
effective = source?.options ?? options;
|
|
7374
|
+
if (!["plan", "verify"].includes(stage) && receipt.effectiveIdentity !== await stageIdentity(effective)) throw new ReleaseCommandError("Verified source/configuration changed; restart at plan and verify");
|
|
7375
|
+
const github = resolveGitHub(effective);
|
|
7376
|
+
if (!github.readReleaseState || !github.writeReleaseState) throw new ReleaseCommandError("Staged release requires durable GitHub checkpoint operations");
|
|
7377
|
+
if (stage === "verify") await verify({
|
|
7378
|
+
...effective,
|
|
7379
|
+
github
|
|
7380
|
+
}, receipt.action);
|
|
7381
|
+
else if (stage === "prepare") {
|
|
7382
|
+
const authorized = authorizeVerification({
|
|
7383
|
+
...effective,
|
|
7384
|
+
github
|
|
7385
|
+
});
|
|
7386
|
+
if (receipt.action === "prepare") await createReleasePullRequest(authorized);
|
|
7387
|
+
else if (receipt.action === "prerelease") {
|
|
7388
|
+
let ready = !await hasPendingIntents(effective.cwd);
|
|
7389
|
+
await releasePrerelease(authorized, async () => {
|
|
7390
|
+
ready = true;
|
|
7391
|
+
return [];
|
|
7392
|
+
});
|
|
7393
|
+
receipt.publish = ready;
|
|
7394
|
+
}
|
|
7395
|
+
receipt.identity = await stageIdentity(options);
|
|
7396
|
+
receipt.candidates = source?.selected ?? await getPublishCandidates(effective.cwd);
|
|
7397
|
+
} else if ([
|
|
7398
|
+
"upload",
|
|
7399
|
+
"confirm",
|
|
7400
|
+
"finalize"
|
|
7401
|
+
].includes(stage) && receipt.publish) {
|
|
7402
|
+
if (receipt.action === "reconcile") {
|
|
7403
|
+
if (stage === "finalize") await reconcileRelease(effective);
|
|
7404
|
+
} else {
|
|
7405
|
+
const rule = await resolveReleaseBranch(effective);
|
|
7406
|
+
const env = getReleaseEnv(effective);
|
|
7407
|
+
const name = options.packageName ?? env["REPO_RELEASE_PACKAGE"];
|
|
7408
|
+
const version = options.packageVersion ?? env["REPO_RELEASE_VERSION"];
|
|
7409
|
+
const selected = source?.selected ?? (resolveReleaseMode(options) === "publish-unpublished" ? [{
|
|
7410
|
+
name: name ?? "",
|
|
7411
|
+
version: version ?? ""
|
|
7412
|
+
}] : void 0);
|
|
7413
|
+
if (selected?.some((pkg) => !receipt.candidates.some((candidate) => candidate.name === pkg.name && candidate.version === pkg.version))) throw new ReleaseCommandError("Recovery package/version does not match prepared candidates");
|
|
7414
|
+
await publishLifecycle({
|
|
7415
|
+
...effective,
|
|
7416
|
+
stage,
|
|
7417
|
+
github
|
|
7418
|
+
}, selected, rule.distTag);
|
|
7419
|
+
}
|
|
7420
|
+
}
|
|
7421
|
+
} else logger.info("No release trigger detected; skipping release CI.");
|
|
7422
|
+
if (!receipt.done.includes(stage)) receipt.done.push(stage);
|
|
7423
|
+
await stageOutput(options, {
|
|
7424
|
+
run: receipt.action !== "skip",
|
|
7425
|
+
publish: receipt.publish
|
|
7426
|
+
});
|
|
7427
|
+
receipt.identity = await stageIdentity(options);
|
|
7428
|
+
receipt.effectiveIdentity = await stageIdentity(effective);
|
|
7429
|
+
await reportStage(receipt, options, stage, started, "complete", effective.cwd);
|
|
7430
|
+
} catch (error) {
|
|
7431
|
+
await reportStage(receipt, options, stage, started, "failed", effective.cwd);
|
|
7432
|
+
throw error;
|
|
7433
|
+
} finally {
|
|
7434
|
+
if (effective.cwd !== options.cwd) {
|
|
7435
|
+
for (const file of [
|
|
7436
|
+
"repoctl-publish-progress.json",
|
|
7437
|
+
"repoctl-release-progress.json",
|
|
7438
|
+
"pnpm-publish-summary.json"
|
|
7439
|
+
]) await copyFile(path.join(effective.cwd, file), path.join(options.cwd, file)).catch((error) => {
|
|
7440
|
+
if (error.code !== "ENOENT") throw error;
|
|
7441
|
+
});
|
|
7442
|
+
if (stage === "finalize" && receipt.done.includes("finalize")) await rm(path.join(stageDirectory(options), "source"), {
|
|
7443
|
+
recursive: true,
|
|
7444
|
+
force: true
|
|
7445
|
+
});
|
|
7446
|
+
}
|
|
7447
|
+
}
|
|
7448
|
+
return receipt;
|
|
7449
|
+
}
|
|
7450
|
+
//#endregion
|
|
6834
7451
|
//#region src/commands/release/ci.ts
|
|
6835
7452
|
async function createReleasePullRequest(options) {
|
|
6836
7453
|
const rule = await resolveStableReleaseBranch(options, "prepare");
|
|
@@ -6970,6 +7587,7 @@ async function releaseCi(options) {
|
|
|
6970
7587
|
...options,
|
|
6971
7588
|
config: options.config ?? await resolveCommandConfig("release", options.cwd) ?? {}
|
|
6972
7589
|
};
|
|
7590
|
+
if (options.stage && options.stage !== "all") return releaseCiStage(options);
|
|
6973
7591
|
const source = options.sourceSha ?? getReleaseEnv(options)["REPO_RELEASE_RECOVERY_SOURCE_SHA"]?.trim();
|
|
6974
7592
|
if (source) return recoverSource({
|
|
6975
7593
|
...options,
|