@icebreakers/monorepo 5.0.3 → 5.1.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/cli.mjs +75 -38
- package/dist/{commands-KNarzvFs.mjs → commands-DwvtvWjz.mjs} +1260 -96
- package/dist/{create-flow-D2KdMg-m.mjs → create-flow-D-_VjRtz.mjs} +2 -2
- package/dist/{index-Ltm2Ry5E.d.mts → index-cBqxgIwY.d.mts} +7 -2
- package/dist/index.d.mts +177 -13
- package/dist/index.mjs +3 -3
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/{types-DYEKpMcN.mjs → types-CLzhRYdV.mjs} +4 -4
- package/package.json +6 -6
- package/resources/skills/icebreakers-monorepo-cli/references/commands.md +21 -1
- package/resources/skills/icebreakers-monorepo-cli/references/config.md +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
2
|
import { i as getWorkspacePackages, n as getWorkspaceData, r as getWorkspacePackageSummaries } from "./workspace-MCKewElu.mjs";
|
|
3
|
-
import { _ as isIgnorableFsError, c as devDependencies$1, d as logger, g as fs$1, i as packageDir, n as assetsDir, o as templatesDir, s as dependencies, t as initToolingTargets, u as version$1 } from "./types-
|
|
3
|
+
import { _ as isIgnorableFsError, c as devDependencies$1, d as logger, g as fs$1, i as packageDir, n as assetsDir, o as templatesDir, s as dependencies, t as initToolingTargets, u as version$1 } from "./types-CLzhRYdV.mjs";
|
|
4
4
|
import { a as loadMonorepoConfig, c as resolveToolingConfig, i as getRepoctlConfigCandidates, o as loadMonorepoConfigDetails, s as resolveCommandConfig } from "./config-p842Knhq.mjs";
|
|
5
5
|
import { f as defineTsconfigConfig } from "./tooling-Bn3XOfO0.mjs";
|
|
6
6
|
import gitUrlParse from "git-url-parse";
|
|
@@ -8,7 +8,7 @@ import { simpleGit } from "simple-git";
|
|
|
8
8
|
import { findWorkspaceDir } from "@pnpm/find-workspace-dir";
|
|
9
9
|
import path from "pathe";
|
|
10
10
|
import process from "node:process";
|
|
11
|
-
import { readFile, readdir } from "node:fs/promises";
|
|
11
|
+
import { access, readFile, readdir, realpath } from "node:fs/promises";
|
|
12
12
|
import { execFileSync, spawnSync } from "node:child_process";
|
|
13
13
|
import fs from "node:fs";
|
|
14
14
|
import path$1 from "node:path";
|
|
@@ -1206,6 +1206,94 @@ async function createNewProject(options) {
|
|
|
1206
1206
|
logger.success(`${pc.bgGreenBright(pc.white(`[${plan.template}]`))} ${plan.targetName} 项目创建成功!`);
|
|
1207
1207
|
}
|
|
1208
1208
|
//#endregion
|
|
1209
|
+
//#region src/commands/upgrade/release-migration.ts
|
|
1210
|
+
const releaseWorkflowMarker = "# repoctl-managed: release/v2";
|
|
1211
|
+
function isLegacyReleaseWorkflow(content) {
|
|
1212
|
+
if (!content.includes("changesets/action")) return false;
|
|
1213
|
+
return content.includes("publish-script:") || content.includes("changeset publish") || content.includes("changeset version") || content.includes("pnpm exec repo release");
|
|
1214
|
+
}
|
|
1215
|
+
async function classifyReleaseWorkflow(workspaceDir) {
|
|
1216
|
+
const workflowPath = path.join(workspaceDir, ".github/workflows/release.yml");
|
|
1217
|
+
if (!await fs$1.pathExists(workflowPath)) return "missing";
|
|
1218
|
+
const content = await fs$1.readFile(workflowPath, "utf8");
|
|
1219
|
+
if (content.includes("# repoctl-managed: release/v2")) return "managed";
|
|
1220
|
+
if (isLegacyReleaseWorkflow(content)) return "legacy";
|
|
1221
|
+
return "custom";
|
|
1222
|
+
}
|
|
1223
|
+
/**
|
|
1224
|
+
* 将 Changesets prerelease 状态迁移到 pnpm lanes,并移除只属于旧 CLI 的元数据。
|
|
1225
|
+
* 未识别的 pre.json 会保留,避免静默丢失用户状态。
|
|
1226
|
+
*/
|
|
1227
|
+
async function migrateLegacyVersioning(workspaceDir) {
|
|
1228
|
+
const changesetDir = path.join(workspaceDir, ".changeset");
|
|
1229
|
+
const configPath = path.join(changesetDir, "config.json");
|
|
1230
|
+
const prePath = path.join(changesetDir, "pre.json");
|
|
1231
|
+
let migratedLane = false;
|
|
1232
|
+
if (await fs$1.pathExists(prePath)) try {
|
|
1233
|
+
const state = JSON.parse(await readFile(prePath, "utf8"));
|
|
1234
|
+
if (state.mode === "pre" && typeof state.tag === "string" && state.tag.length > 0) {
|
|
1235
|
+
const workspacePath = path.join(workspaceDir, "pnpm-workspace.yaml");
|
|
1236
|
+
const manifest = YAML.parse(await readFile(workspacePath, "utf8"));
|
|
1237
|
+
const versioningValue = manifest["versioning"];
|
|
1238
|
+
const versioning = versioningValue && typeof versioningValue === "object" && !Array.isArray(versioningValue) ? versioningValue : {};
|
|
1239
|
+
const lanesValue = versioning["lanes"];
|
|
1240
|
+
const lanes = lanesValue && typeof lanesValue === "object" && !Array.isArray(lanesValue) ? lanesValue : {};
|
|
1241
|
+
const packages = await getWorkspacePackages(workspaceDir);
|
|
1242
|
+
for (const pkg of packages) if (pkg.manifest.name) lanes[pkg.manifest.name] = state.tag;
|
|
1243
|
+
versioning["lanes"] = lanes;
|
|
1244
|
+
manifest["versioning"] = versioning;
|
|
1245
|
+
await fs$1.writeFile(workspacePath, YAML.stringify(manifest, { singleQuote: true }), "utf8");
|
|
1246
|
+
await fs$1.remove(prePath);
|
|
1247
|
+
migratedLane = true;
|
|
1248
|
+
}
|
|
1249
|
+
} catch {}
|
|
1250
|
+
if (await fs$1.pathExists(configPath)) await fs$1.remove(configPath);
|
|
1251
|
+
return { migratedLane };
|
|
1252
|
+
}
|
|
1253
|
+
//#endregion
|
|
1254
|
+
//#region src/commands/doctor/release.ts
|
|
1255
|
+
const releaseCiMinimumVersion = "5.1.0";
|
|
1256
|
+
function check(id, title, status, detail, fix) {
|
|
1257
|
+
return {
|
|
1258
|
+
id,
|
|
1259
|
+
title,
|
|
1260
|
+
status,
|
|
1261
|
+
detail,
|
|
1262
|
+
...fix ? { fix } : {}
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
async function collectReleaseChecks(workspaceDir, pkgJson) {
|
|
1266
|
+
const workflowPath = path.join(workspaceDir, ".github/workflows/release.yml");
|
|
1267
|
+
const [hasWorkflow, hasPreState, hasChangesetConfig] = await Promise.all([
|
|
1268
|
+
fs$1.pathExists(workflowPath),
|
|
1269
|
+
fs$1.pathExists(path.join(workspaceDir, ".changeset/pre.json")),
|
|
1270
|
+
fs$1.pathExists(path.join(workspaceDir, ".changeset/config.json"))
|
|
1271
|
+
]);
|
|
1272
|
+
if (!hasWorkflow && !hasPreState && !hasChangesetConfig) return [];
|
|
1273
|
+
const checks = [];
|
|
1274
|
+
const workflowStatus = await classifyReleaseWorkflow(workspaceDir);
|
|
1275
|
+
if (workflowStatus === "managed") checks.push(check("release-workflow", "release workflow", "pass", `release workflow 已由 ${releaseWorkflowMarker} 管理。`));
|
|
1276
|
+
else if (workflowStatus === "legacy") checks.push(check("release-workflow", "release workflow", "warn", "检测到旧的 Changesets release workflow。", "首次迁移运行 pnpm dlx repoctl@latest upgrade --yes。"));
|
|
1277
|
+
else if (workflowStatus === "custom") checks.push(check("release-workflow", "release workflow", "warn", "release workflow 未包含 repoctl managed marker,可能存在自定义发布逻辑。", "确认内容后运行 repo upgrade --overwrite-release,或手动加入 repoctl-managed: release/v2。"));
|
|
1278
|
+
if (hasPreState) checks.push(check("release-prerelease-state", "prerelease state", "warn", "检测到旧的 .changeset/pre.json。", "运行 pnpm dlx repoctl@latest upgrade --yes 将其迁移为 pnpm versioning.lanes。"));
|
|
1279
|
+
if (hasChangesetConfig) checks.push(check("release-changeset-config", "changeset config", "warn", "检测到只属于 Changesets CLI 的 .changeset/config.json。", "运行 pnpm dlx repoctl@latest upgrade --yes 清理旧配置。"));
|
|
1280
|
+
if (hasWorkflow) {
|
|
1281
|
+
const packageVersion = pkgJson.devDependencies?.["repoctl"] ?? pkgJson.dependencies?.["repoctl"];
|
|
1282
|
+
const parsed = minVersion(packageVersion ?? "");
|
|
1283
|
+
if (!parsed || !gte(parsed, "5.1.0")) checks.push(check("release-cli-version", "release CLI version", "warn", `repoctl 版本 ${packageVersion ?? "missing"} 不保证支持 release ci。`, `运行 pnpm dlx repoctl@latest upgrade --yes,或将 repoctl 升级到 >=${releaseCiMinimumVersion}。`));
|
|
1284
|
+
else checks.push(check("release-cli-version", "release CLI version", "pass", `repoctl 版本 ${packageVersion} 支持 release ci。`));
|
|
1285
|
+
try {
|
|
1286
|
+
const workspace = YAML.parse(await readFile(path.join(workspaceDir, "pnpm-workspace.yaml"), "utf8"));
|
|
1287
|
+
const hasFixed = Array.isArray(workspace.versioning?.fixed) && workspace.versioning.fixed.length > 0;
|
|
1288
|
+
const hasRepositoryChangelog = workspace.versioning?.changelog?.storage === "repository";
|
|
1289
|
+
checks.push(hasFixed && hasRepositoryChangelog ? check("release-versioning-config", "release versioning config", "pass", "pnpm fixed group 与 repository changelog 配置完整。") : check("release-versioning-config", "release versioning config", "warn", "pnpm-workspace.yaml 缺少 release 所需的 fixed 或 repository changelog 配置。", "运行 repo upgrade --yes 同步 pnpm versioning 配置。"));
|
|
1290
|
+
} catch {
|
|
1291
|
+
checks.push(check("release-versioning-config", "release versioning config", "warn", "无法读取 pnpm-workspace.yaml 的 versioning 配置。", "运行 repo upgrade --yes 同步 pnpm versioning 配置。"));
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
return checks;
|
|
1295
|
+
}
|
|
1296
|
+
//#endregion
|
|
1209
1297
|
//#region src/commands/doctor.ts
|
|
1210
1298
|
const recommendedRepoScripts = {
|
|
1211
1299
|
"repo:init": "repo init",
|
|
@@ -1491,6 +1579,7 @@ async function runDoctor(cwd) {
|
|
|
1491
1579
|
detail: `以下 package.json 未被 pnpm-workspace.yaml 覆盖:${uncoveredWorkspacePackages.join(", ")}。`,
|
|
1492
1580
|
fix: "运行 repo init --yes 追加缺失 workspace patterns。"
|
|
1493
1581
|
}));
|
|
1582
|
+
checks.push(...await collectReleaseChecks(workspaceDir, pkgJson));
|
|
1494
1583
|
return {
|
|
1495
1584
|
cwd,
|
|
1496
1585
|
workspaceDir,
|
|
@@ -1618,20 +1707,10 @@ async function createContext(cwd) {
|
|
|
1618
1707
|
//#endregion
|
|
1619
1708
|
//#region src/commands/init/setChangeset.ts
|
|
1620
1709
|
/**
|
|
1621
|
-
*
|
|
1710
|
+
* 保留兼容的初始化入口,并确保 pnpm change 有可写入的 intent 目录。
|
|
1622
1711
|
*/
|
|
1623
1712
|
async function setChangeset_default(ctx) {
|
|
1624
|
-
|
|
1625
|
-
if (gitUrl && await fs$1.exists(workspaceFilepath)) {
|
|
1626
|
-
const changesetConfigPath = path.resolve(path.dirname(workspaceFilepath), ".changeset/config.json");
|
|
1627
|
-
if (await fs$1.exists(changesetConfigPath)) {
|
|
1628
|
-
const changesetConfig = await fs$1.readJson(changesetConfigPath);
|
|
1629
|
-
if (gitUrl.full_name) {
|
|
1630
|
-
setByPath(changesetConfig, "changelog.1.repo", gitUrl.full_name);
|
|
1631
|
-
await fs$1.outputJson(changesetConfigPath, changesetConfig, { spaces: 2 });
|
|
1632
|
-
}
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1713
|
+
if (await fs$1.exists(ctx.workspaceDir)) await fs$1.ensureDir(path.join(ctx.workspaceDir, ".changeset"));
|
|
1635
1714
|
}
|
|
1636
1715
|
//#endregion
|
|
1637
1716
|
//#region src/commands/init/setIssueTemplateConfig.ts
|
|
@@ -1722,9 +1801,7 @@ async function setReadme_default(ctx, options = {}) {
|
|
|
1722
1801
|
//#endregion
|
|
1723
1802
|
//#region ../../package.json
|
|
1724
1803
|
var devDependencies = {
|
|
1725
|
-
"@
|
|
1726
|
-
"@commitlint/cli": "^21.2.1",
|
|
1727
|
-
"@icebreakers/changelog-github": "^2.0.0",
|
|
1804
|
+
"@commitlint/cli": "^21.2.2",
|
|
1728
1805
|
"@icebreakers/monorepo": "workspace:*",
|
|
1729
1806
|
"@types/node": "^26.2.0",
|
|
1730
1807
|
"@types/semver": "^7.8.0",
|
|
@@ -1746,7 +1823,7 @@ var devDependencies = {
|
|
|
1746
1823
|
"tsdown": "0.22.14",
|
|
1747
1824
|
"tslib": "^2.8.1",
|
|
1748
1825
|
"tsx": "^4.23.12",
|
|
1749
|
-
"turbo": "^2.10.
|
|
1826
|
+
"turbo": "^2.10.10",
|
|
1750
1827
|
"type-fest": "^5.8.0",
|
|
1751
1828
|
"typescript": "^6.0.3",
|
|
1752
1829
|
"vitest": "~4.1.10",
|
|
@@ -1783,8 +1860,9 @@ const packageDependencies = {
|
|
|
1783
1860
|
"typecheck": "turbo run typecheck",
|
|
1784
1861
|
"format": "eslint . --fix",
|
|
1785
1862
|
"validate": "pnpm run build && pnpm run lint && pnpm run typecheck && pnpm run tsd && pnpm run test",
|
|
1786
|
-
"release": "
|
|
1787
|
-
"
|
|
1863
|
+
"release": "pnpm change",
|
|
1864
|
+
"version-packages": "pnpm version -r",
|
|
1865
|
+
"publish-packages": "repo release stable publish",
|
|
1788
1866
|
"release:pre": "repo release pre publish",
|
|
1789
1867
|
"------": "--------------",
|
|
1790
1868
|
"preinstall": "npx only-allow pnpm",
|
|
@@ -2131,13 +2209,342 @@ async function setVscodeBinaryMirror(cwd) {
|
|
|
2131
2209
|
await fs$1.writeFile(targetJsonPath, `${stringify(json, void 0, 2)}\n`, "utf8");
|
|
2132
2210
|
}
|
|
2133
2211
|
//#endregion
|
|
2134
|
-
//#region src/commands/release.ts
|
|
2135
|
-
const
|
|
2136
|
-
"
|
|
2137
|
-
"
|
|
2138
|
-
"
|
|
2139
|
-
"
|
|
2140
|
-
|
|
2212
|
+
//#region src/commands/release/notes/model.ts
|
|
2213
|
+
const categoryOrder = [
|
|
2214
|
+
"breaking",
|
|
2215
|
+
"features",
|
|
2216
|
+
"fixes",
|
|
2217
|
+
"performance",
|
|
2218
|
+
"docs",
|
|
2219
|
+
"other",
|
|
2220
|
+
"maintenance"
|
|
2221
|
+
];
|
|
2222
|
+
const categoryTitles = {
|
|
2223
|
+
breaking: "🚨 Breaking Changes",
|
|
2224
|
+
features: "🚀 Features",
|
|
2225
|
+
fixes: "🐞 Bug Fixes",
|
|
2226
|
+
performance: "🏎 Performance",
|
|
2227
|
+
docs: "📚 Documentation",
|
|
2228
|
+
maintenance: "🧰 Maintenance",
|
|
2229
|
+
other: "🧩 Other Changes"
|
|
2230
|
+
};
|
|
2231
|
+
function readVersionSection(changelog, version) {
|
|
2232
|
+
const versions = [...changelog.matchAll(/^## ([^\n]+)$/gm)];
|
|
2233
|
+
const index = versions.findIndex((match) => match[1] === version);
|
|
2234
|
+
const current = versions[index];
|
|
2235
|
+
if (index < 0 || !current || current.index === void 0) return;
|
|
2236
|
+
const end = versions[index + 1]?.index ?? changelog.length;
|
|
2237
|
+
return {
|
|
2238
|
+
content: changelog.slice(current.index, end).trim().slice(current[0].length).trim() || void 0,
|
|
2239
|
+
previousVersion: versions[index + 1]?.[1]
|
|
2240
|
+
};
|
|
2241
|
+
}
|
|
2242
|
+
function readIntentSections(content) {
|
|
2243
|
+
const lines = content.split(/\r?\n/);
|
|
2244
|
+
if (lines[0]?.trim() !== "---") return;
|
|
2245
|
+
const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
|
|
2246
|
+
if (end < 0) return;
|
|
2247
|
+
return {
|
|
2248
|
+
frontmatter: lines.slice(1, end).join("\n"),
|
|
2249
|
+
summary: lines.slice(end + 1).join("\n").trim()
|
|
2250
|
+
};
|
|
2251
|
+
}
|
|
2252
|
+
function parseIntentPackages(content) {
|
|
2253
|
+
const sections = readIntentSections(content);
|
|
2254
|
+
if (!sections) return [];
|
|
2255
|
+
try {
|
|
2256
|
+
const frontmatter = YAML.parse(sections.frontmatter);
|
|
2257
|
+
if (!frontmatter || typeof frontmatter !== "object" || Array.isArray(frontmatter)) return [];
|
|
2258
|
+
return Object.keys(frontmatter).filter((key) => key !== "summary" && key !== "type");
|
|
2259
|
+
} catch {
|
|
2260
|
+
return [];
|
|
2261
|
+
}
|
|
2262
|
+
}
|
|
2263
|
+
function parseIntentSummary(content) {
|
|
2264
|
+
return readIntentSections(content)?.summary ?? content.trim();
|
|
2265
|
+
}
|
|
2266
|
+
function uniqueCommits(commits) {
|
|
2267
|
+
const merged = /* @__PURE__ */ new Map();
|
|
2268
|
+
for (const commit of commits) {
|
|
2269
|
+
const existing = merged.get(commit.sha);
|
|
2270
|
+
if (!existing) {
|
|
2271
|
+
merged.set(commit.sha, commit);
|
|
2272
|
+
continue;
|
|
2273
|
+
}
|
|
2274
|
+
merged.set(commit.sha, {
|
|
2275
|
+
...existing,
|
|
2276
|
+
packages: [.../* @__PURE__ */ new Set([...existing.packages ?? [], ...commit.packages ?? []])],
|
|
2277
|
+
summaries: [...new Set([
|
|
2278
|
+
existing.summary,
|
|
2279
|
+
...existing.summaries ?? [],
|
|
2280
|
+
commit.summary,
|
|
2281
|
+
...commit.summaries ?? []
|
|
2282
|
+
].filter((summary) => Boolean(summary)))]
|
|
2283
|
+
});
|
|
2284
|
+
}
|
|
2285
|
+
return [...merged.values()];
|
|
2286
|
+
}
|
|
2287
|
+
function isAutomationContributor(value) {
|
|
2288
|
+
return /github-actions|dependabot|renovate|\[bot\]$/i.test(value);
|
|
2289
|
+
}
|
|
2290
|
+
function buildPackageCompareUrl(release, metadata) {
|
|
2291
|
+
if (!release.previousVersion || !metadata.repository || !/^[^/]+\/[^/]+$/.test(metadata.repository)) return;
|
|
2292
|
+
const serverUrl = (metadata.serverUrl || "https://github.com").replace(/\/$/, "");
|
|
2293
|
+
const previousTag = encodeURIComponent([release.name, release.previousVersion].join("@"));
|
|
2294
|
+
const currentTag = encodeURIComponent([release.name, release.version].join("@"));
|
|
2295
|
+
return [
|
|
2296
|
+
serverUrl,
|
|
2297
|
+
metadata.repository,
|
|
2298
|
+
"compare",
|
|
2299
|
+
`${previousTag}...${currentTag}`
|
|
2300
|
+
].join("/");
|
|
2301
|
+
}
|
|
2302
|
+
function buildNpmPackageUrl(name, version) {
|
|
2303
|
+
return `https://www.npmjs.com/package/${name.startsWith("@") ? name : encodeURIComponent(name)}/v/${encodeURIComponent(version)}`;
|
|
2304
|
+
}
|
|
2305
|
+
//#endregion
|
|
2306
|
+
//#region src/commands/release/notes/entries.ts
|
|
2307
|
+
function parseReferences(commits, content) {
|
|
2308
|
+
const pullRequests = /* @__PURE__ */ new Set();
|
|
2309
|
+
const issues = /* @__PURE__ */ new Set();
|
|
2310
|
+
for (const message of [...commits.map((commit) => [commit.subject, commit.body ?? ""].join("\n")), content]) {
|
|
2311
|
+
for (const match of message.matchAll(/\]\([^)]*\/pull\/(\d+)\)/g)) pullRequests.add(Number(match[1]));
|
|
2312
|
+
for (const match of message.matchAll(/\]\([^)]*\/issues\/(\d+)\)/g)) issues.add(Number(match[1]));
|
|
2313
|
+
for (const match of message.matchAll(/\(#(\d+)\)/g)) pullRequests.add(Number(match[1]));
|
|
2314
|
+
for (const match of message.matchAll(/(?:^|\W)#(\d+)\b/g)) {
|
|
2315
|
+
const number = Number(match[1]);
|
|
2316
|
+
if (!pullRequests.has(number)) issues.add(number);
|
|
2317
|
+
}
|
|
2318
|
+
for (const match of message.matchAll(/\bGH[- ]?(\d+)\b/gi)) issues.add(Number(match[1]));
|
|
2319
|
+
}
|
|
2320
|
+
for (const number of pullRequests) issues.delete(number);
|
|
2321
|
+
return {
|
|
2322
|
+
issues: [...issues].sort((a, b) => a - b),
|
|
2323
|
+
pullRequests: [...pullRequests].sort((a, b) => a - b)
|
|
2324
|
+
};
|
|
2325
|
+
}
|
|
2326
|
+
function sourceCategory(commits) {
|
|
2327
|
+
for (const commit of commits) {
|
|
2328
|
+
const subject = commit.subject.toLowerCase();
|
|
2329
|
+
const conventional = /^([a-z]+)(?:\([^)]*\))?(!)?:/.exec(subject);
|
|
2330
|
+
if (conventional?.[2] || subject.startsWith("breaking")) return "breaking";
|
|
2331
|
+
if (conventional?.[1] === "feat" || conventional?.[1] === "feature" || subject.includes("🚀")) return "features";
|
|
2332
|
+
if (conventional?.[1] === "fix" || subject.includes("🐛") || subject.includes("🐞")) return "fixes";
|
|
2333
|
+
if (conventional?.[1] === "perf" || subject.includes("🏎")) return "performance";
|
|
2334
|
+
if ([
|
|
2335
|
+
"doc",
|
|
2336
|
+
"docs",
|
|
2337
|
+
"documentation"
|
|
2338
|
+
].includes(conventional?.[1] ?? "") || subject.includes("📚")) return "docs";
|
|
2339
|
+
if ([
|
|
2340
|
+
"chore",
|
|
2341
|
+
"ci",
|
|
2342
|
+
"test",
|
|
2343
|
+
"refactor",
|
|
2344
|
+
"dep",
|
|
2345
|
+
"deps"
|
|
2346
|
+
].includes(conventional?.[1] ?? "") || /dependencies|maintenance/i.test(subject)) return "maintenance";
|
|
2347
|
+
}
|
|
2348
|
+
}
|
|
2349
|
+
function classifyChange(heading, summary, commits) {
|
|
2350
|
+
if (/dependenc(?:y|ies)/i.test(heading)) return "maintenance";
|
|
2351
|
+
const fromCommit = sourceCategory(commits);
|
|
2352
|
+
if (fromCommit) return fromCommit;
|
|
2353
|
+
const categoryHint = [heading, summary].join(" ").toLowerCase();
|
|
2354
|
+
if (/major|breaking|重大|破坏/.test(categoryHint)) return "breaking";
|
|
2355
|
+
if (/minor|feature|🚀|新增|功能/.test(categoryHint)) return "features";
|
|
2356
|
+
if (/fix|bug|🐛|🐞|修复|错误|问题/.test(categoryHint)) return "fixes";
|
|
2357
|
+
if (/perf|🏎|性能/.test(categoryHint)) return "performance";
|
|
2358
|
+
if (/doc|📚|文档/.test(categoryHint)) return "docs";
|
|
2359
|
+
if (/dependenc|chore|ci|test|refactor|maintenance|📦|依赖|维护/.test(categoryHint)) return "maintenance";
|
|
2360
|
+
return "other";
|
|
2361
|
+
}
|
|
2362
|
+
function readMarkdownEntries(content) {
|
|
2363
|
+
const headings = [...content.matchAll(/^### ([^\n]+)$/gm)];
|
|
2364
|
+
if (!headings.length) return [{
|
|
2365
|
+
heading: "Patch Changes",
|
|
2366
|
+
summary: content.trim()
|
|
2367
|
+
}];
|
|
2368
|
+
const entries = [];
|
|
2369
|
+
for (let index = 0; index < headings.length; index++) {
|
|
2370
|
+
const heading = headings[index];
|
|
2371
|
+
if (!heading || heading.index === void 0) continue;
|
|
2372
|
+
const start = heading.index + heading[0].length;
|
|
2373
|
+
const end = headings[index + 1]?.index ?? content.length;
|
|
2374
|
+
const lines = content.slice(start, end).trim().split("\n");
|
|
2375
|
+
let current = "";
|
|
2376
|
+
for (const line of lines) if (line.startsWith("- ")) {
|
|
2377
|
+
if (current) entries.push({
|
|
2378
|
+
heading: heading[1],
|
|
2379
|
+
summary: current.trim()
|
|
2380
|
+
});
|
|
2381
|
+
current = line.slice(2).trim();
|
|
2382
|
+
} else if (line.trim()) current = current ? [current, line.trim()].join("\n") : line.trim();
|
|
2383
|
+
if (current) entries.push({
|
|
2384
|
+
heading: heading[1],
|
|
2385
|
+
summary: current.trim()
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
return entries.length ? entries : [{
|
|
2389
|
+
heading: "Patch Changes",
|
|
2390
|
+
summary: content.trim()
|
|
2391
|
+
}];
|
|
2392
|
+
}
|
|
2393
|
+
function normalizeMarkdownEntry(item) {
|
|
2394
|
+
const raw = item.summary.replace(/\r?\n/g, " ").replace(/\s+/g, " ").trim();
|
|
2395
|
+
const commitMatches = [...raw.matchAll(/\[{1,2}`?([0-9a-f]{7,40})`?\]\(([^)]+\/commit\/[^)]+)\)/gi)];
|
|
2396
|
+
const pullRequests = [...raw.matchAll(/\[#(\d+)\]\(([^)]+\/pull\/\d+)\)/gi)].map((match) => Number(match[1]));
|
|
2397
|
+
const issues = [...raw.matchAll(/\[#(\d+)\]\(([^)]+\/issues\/\d+)\)/gi)].map((match) => Number(match[1]));
|
|
2398
|
+
const authors = [...raw.matchAll(/\bby\s+(@?[\w-]+(?:\[bot\])?)/gi)].map((match) => match[1]);
|
|
2399
|
+
const arrowDependency = raw.match(/→\s*`([^`]+)`/)?.[1];
|
|
2400
|
+
const dependencyVersions = [...raw.matchAll(/(?:^|\s)((?:@[\w.-]+\/)?[\w.-]+@\d+\.\d+\.\d+(?:-[\w.-]+)?)/g)].map((match) => match[1]);
|
|
2401
|
+
const dependencyLabel = /\bdependenc(?:y|ies):/i.test(raw) ? raw.replace(/^.*?\bdependenc(?:y|ies):/i, "").trim().replace(/^[-*]\s*/, "").replace(/^`|`$/g, "") : void 0;
|
|
2402
|
+
const dependencyName = arrowDependency ?? (dependencyVersions.length ? [...new Set(dependencyVersions)].join(", ") : dependencyLabel);
|
|
2403
|
+
const hasDependency = /\bupdated\s+dependenc(?:y|ies)\b|Dependencies:|Dependency:|\*\*Dependencies\*\*|\*\*Dependency\*\*/i.test(raw) || Boolean(dependencyName);
|
|
2404
|
+
const summary = hasDependency && dependencyName ? dependencyVersions.length > 1 ? `Updated dependencies: ${[...new Set(dependencyVersions)].join(", ")}.` : `Updated dependency to ${dependencyName}.` : raw.replace(/\[{1,2}`?([0-9a-f]{7,40})`?\]\([^)]+\)/gi, "").replace(/\[#\d+\]\([^)]+\)/g, "").replace(/\bby\s+@?[\w-]+(?:\[bot\])?/gi, "").replace(/\*\*/g, "").replace(/`/g, "").replace(/^[-*]\s+/, "").replace(/^[^\p{L}\p{N}]+/u, "").replace(/\s+/g, " ").trim();
|
|
2405
|
+
const categoryHint = /🚨|breaking/i.test(raw) ? "🚨" : /🚀|✨/.test(raw) ? "🚀" : /🐛|🐞/.test(raw) ? "🐞" : hasDependency ? "Dependencies" : "";
|
|
2406
|
+
const commits = commitMatches.map((match) => ({
|
|
2407
|
+
sha: match[2]?.match(/\/commit\/([0-9a-f]{7,40})/i)?.[1] ?? match[1],
|
|
2408
|
+
subject: `${hasDependency ? "chore" : categoryHint === "🐞" ? "fix" : categoryHint === "🚀" ? "feat" : "chore"}: ${summary}`,
|
|
2409
|
+
...authors[0] ? { author: authors[0] } : {},
|
|
2410
|
+
summary
|
|
2411
|
+
}));
|
|
2412
|
+
return {
|
|
2413
|
+
heading: categoryHint ? `${item.heading} ${categoryHint}` : item.heading,
|
|
2414
|
+
summary,
|
|
2415
|
+
commits,
|
|
2416
|
+
pullRequests: [...new Set(pullRequests)],
|
|
2417
|
+
issues: [...new Set(issues)],
|
|
2418
|
+
authors: [...new Set(authors)],
|
|
2419
|
+
raw
|
|
2420
|
+
};
|
|
2421
|
+
}
|
|
2422
|
+
function commitsForPackage(commits, packageName) {
|
|
2423
|
+
return uniqueCommits(commits.filter((commit) => !commit.packages?.length || commit.packages.includes(packageName)));
|
|
2424
|
+
}
|
|
2425
|
+
function normalizeForMatch(value) {
|
|
2426
|
+
return value.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1").replace(/[*_`]/g, "").replace(/[^\p{L}\p{N}]+/gu, " ").trim().toLowerCase();
|
|
2427
|
+
}
|
|
2428
|
+
function commitsForEntry(commits, summary) {
|
|
2429
|
+
const normalizedSummary = normalizeForMatch(summary);
|
|
2430
|
+
const matched = commits.filter((commit) => {
|
|
2431
|
+
const summaries = [commit.summary, ...commit.summaries ?? []].filter((value) => Boolean(value));
|
|
2432
|
+
if (!summaries.length) return false;
|
|
2433
|
+
return summaries.some((summary) => {
|
|
2434
|
+
const normalizedIntent = normalizeForMatch(summary);
|
|
2435
|
+
return normalizedIntent === normalizedSummary || normalizedSummary.includes(normalizedIntent) || normalizedIntent.includes(normalizedSummary);
|
|
2436
|
+
});
|
|
2437
|
+
});
|
|
2438
|
+
if (matched.length) return matched;
|
|
2439
|
+
return commits.length === 1 ? commits : [];
|
|
2440
|
+
}
|
|
2441
|
+
function buildEntries(release, commits) {
|
|
2442
|
+
const packageCommits = commitsForPackage(commits, release.name);
|
|
2443
|
+
return readMarkdownEntries(release.content).flatMap((item) => {
|
|
2444
|
+
const normalized = normalizeMarkdownEntry(item);
|
|
2445
|
+
const summary = normalized.summary;
|
|
2446
|
+
if (!summary) return [];
|
|
2447
|
+
const entryCommits = uniqueCommits([...commitsForEntry(packageCommits, summary), ...normalized.commits]);
|
|
2448
|
+
const refs = parseReferences(entryCommits, [normalized.raw, summary].join("\n"));
|
|
2449
|
+
return [{
|
|
2450
|
+
packageName: release.name,
|
|
2451
|
+
version: release.version,
|
|
2452
|
+
...release.npmUrl ? { npmUrl: release.npmUrl } : {},
|
|
2453
|
+
category: classifyChange(normalized.heading, summary, entryCommits),
|
|
2454
|
+
summary,
|
|
2455
|
+
commits: entryCommits,
|
|
2456
|
+
pullRequests: [.../* @__PURE__ */ new Set([...refs.pullRequests, ...normalized.pullRequests])].sort((a, b) => a - b),
|
|
2457
|
+
issues: [.../* @__PURE__ */ new Set([...refs.issues, ...normalized.issues])].sort((a, b) => a - b),
|
|
2458
|
+
authors: [.../* @__PURE__ */ new Set([...normalized.authors, ...entryCommits.map((commit) => commit.author).filter((author) => Boolean(author))])]
|
|
2459
|
+
}];
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
2462
|
+
//#endregion
|
|
2463
|
+
//#region src/commands/release/notes/render.ts
|
|
2464
|
+
function formatReferenceLinks(entry, metadata) {
|
|
2465
|
+
const repository = metadata.repository && /^[^/]+\/[^/]+$/.test(metadata.repository) ? metadata.repository : void 0;
|
|
2466
|
+
const serverUrl = (metadata.serverUrl || "https://github.com").replace(/\/$/, "");
|
|
2467
|
+
const baseUrl = repository ? `${serverUrl}/${repository}` : void 0;
|
|
2468
|
+
const links = [];
|
|
2469
|
+
for (const commit of entry.commits) {
|
|
2470
|
+
const label = commit.sha.slice(0, 7);
|
|
2471
|
+
links.push(baseUrl ? `[\`${label}\`](${baseUrl}/commit/${commit.sha})` : `\`${label}\``);
|
|
2472
|
+
}
|
|
2473
|
+
for (const number of entry.pullRequests) links.push(baseUrl ? `[#${number}](${baseUrl}/pull/${number})` : `#${number}`);
|
|
2474
|
+
for (const number of entry.issues) links.push(baseUrl ? `[#${number}](${baseUrl}/issues/${number})` : `#${number}`);
|
|
2475
|
+
return links.length ? ` ${links.join(" · ")}` : "";
|
|
2476
|
+
}
|
|
2477
|
+
function formatEntry(entry, metadata, linkNpmVersion) {
|
|
2478
|
+
return `- **${linkNpmVersion && entry.npmUrl ? `[${entry.packageName}@${entry.version}](${entry.npmUrl})` : `${entry.packageName}@${entry.version}`}**: ${entry.summary}${formatReferenceLinks(entry, metadata)}`;
|
|
2479
|
+
}
|
|
2480
|
+
function formatCategoryEntries(entries, category, metadata, headingLevel, linkNpmVersion) {
|
|
2481
|
+
const matching = entries.filter((entry) => entry.category === category);
|
|
2482
|
+
if (!matching.length) return [];
|
|
2483
|
+
return [
|
|
2484
|
+
`${"#".repeat(headingLevel)} ${categoryTitles[category]}`,
|
|
2485
|
+
"",
|
|
2486
|
+
...matching.map((entry) => formatEntry(entry, metadata, linkNpmVersion))
|
|
2487
|
+
];
|
|
2488
|
+
}
|
|
2489
|
+
function formatContributor(value) {
|
|
2490
|
+
if (value.startsWith("@")) return value;
|
|
2491
|
+
return /^[\w-]+$/.test(value) ? `@${value}` : value;
|
|
2492
|
+
}
|
|
2493
|
+
function formatContributors(contributors) {
|
|
2494
|
+
const unique = [...new Set(contributors.map((value) => value.trim()).filter((value) => value && !isAutomationContributor(value)))].sort((a, b) => a.localeCompare(b));
|
|
2495
|
+
return unique.length ? [
|
|
2496
|
+
"## ❤️ Contributors",
|
|
2497
|
+
"",
|
|
2498
|
+
`Thanks to ${unique.map(formatContributor).join(" · ")}`
|
|
2499
|
+
] : [];
|
|
2500
|
+
}
|
|
2501
|
+
function formatVersion(version, npmUrl) {
|
|
2502
|
+
return npmUrl ? `[\`${version}\`](${npmUrl})` : `\`${version}\``;
|
|
2503
|
+
}
|
|
2504
|
+
function formatPackages(packages, linkNpmVersion) {
|
|
2505
|
+
if (!packages.length) return [];
|
|
2506
|
+
return [
|
|
2507
|
+
"## Packages",
|
|
2508
|
+
"",
|
|
2509
|
+
"| Package | From | To |",
|
|
2510
|
+
"| --- | --- | --- |",
|
|
2511
|
+
...packages.map((pkg) => {
|
|
2512
|
+
const previous = pkg.previousVersion ? formatVersion(pkg.previousVersion, pkg.previousNpmUrl) : "—";
|
|
2513
|
+
const current = formatVersion(pkg.version, linkNpmVersion ? pkg.npmUrl : void 0);
|
|
2514
|
+
return `| \`${pkg.name}\` | ${previous} | ${current} |`;
|
|
2515
|
+
})
|
|
2516
|
+
];
|
|
2517
|
+
}
|
|
2518
|
+
function renderReleasePullRequest(document, metadata = {}) {
|
|
2519
|
+
const sections = [
|
|
2520
|
+
"# Release Notes",
|
|
2521
|
+
"",
|
|
2522
|
+
`> ${`${document.packages.length} package${document.packages.length === 1 ? "" : "s"}`} updated · ${`${document.entries.length} change${document.entries.length === 1 ? "" : "s"}`}`
|
|
2523
|
+
];
|
|
2524
|
+
for (const category of categoryOrder.filter((category) => category !== "maintenance")) {
|
|
2525
|
+
const section = formatCategoryEntries(document.entries, category, metadata, 2, false);
|
|
2526
|
+
if (section.length) sections.push("", "", ...section);
|
|
2527
|
+
}
|
|
2528
|
+
const maintenance = formatCategoryEntries(document.entries, "maintenance", metadata, 2, false);
|
|
2529
|
+
if (maintenance.length) sections.push("", "", "<details>", "<summary>🧰 Maintenance</summary>", "", ...maintenance.slice(2), "", "</details>");
|
|
2530
|
+
sections.push("", "", ...formatPackages(document.packages, false));
|
|
2531
|
+
sections.push("", "", ...formatContributors(document.contributors));
|
|
2532
|
+
return sections.join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
2533
|
+
}
|
|
2534
|
+
function renderGitHubRelease(document, metadata = {}) {
|
|
2535
|
+
if (!document.entries.length) return "No significant changes.";
|
|
2536
|
+
const sections = [];
|
|
2537
|
+
for (const category of categoryOrder) {
|
|
2538
|
+
const section = formatCategoryEntries(document.entries, category, metadata, 3, true);
|
|
2539
|
+
if (section.length) sections.push(...sections.length ? ["", ...section] : section);
|
|
2540
|
+
}
|
|
2541
|
+
const contributors = [...new Set(document.contributors)].filter((value) => !isAutomationContributor(value)).sort((a, b) => a.localeCompare(b));
|
|
2542
|
+
if (contributors.length) sections.push("", "### ❤️ Contributors", "", `Thanks to ${contributors.map(formatContributor).join(" · ")}`);
|
|
2543
|
+
if (document.compareUrls.length) sections.push("", `##### [View changes on GitHub](${document.compareUrls[0]})`);
|
|
2544
|
+
return sections.join("\n");
|
|
2545
|
+
}
|
|
2546
|
+
//#endregion
|
|
2547
|
+
//#region src/commands/release/errors.ts
|
|
2141
2548
|
var ReleaseCommandError = class extends Error {
|
|
2142
2549
|
exitCode;
|
|
2143
2550
|
constructor(message, exitCode = 1) {
|
|
@@ -2146,6 +2553,8 @@ var ReleaseCommandError = class extends Error {
|
|
|
2146
2553
|
this.name = "ReleaseCommandError";
|
|
2147
2554
|
}
|
|
2148
2555
|
};
|
|
2556
|
+
//#endregion
|
|
2557
|
+
//#region src/commands/release/shared.ts
|
|
2149
2558
|
function run(command, args, options) {
|
|
2150
2559
|
const result = (options.spawn ?? spawnSync)(command, args, {
|
|
2151
2560
|
cwd: options.cwd,
|
|
@@ -2169,15 +2578,22 @@ function capture(command, args, options) {
|
|
|
2169
2578
|
if (result.status !== 0) throw new ReleaseCommandError(`command failed: ${command} ${args.join(" ")}`, result.status ?? 1);
|
|
2170
2579
|
return result.stdout?.toString().trim() ?? "";
|
|
2171
2580
|
}
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2581
|
+
function getReleaseEnv(options) {
|
|
2582
|
+
return options.env ?? process.env;
|
|
2583
|
+
}
|
|
2584
|
+
function hasGitChanges(options) {
|
|
2585
|
+
return (options.spawn ?? spawnSync)("git", [
|
|
2586
|
+
"diff",
|
|
2587
|
+
"--quiet",
|
|
2588
|
+
"--exit-code"
|
|
2589
|
+
], {
|
|
2590
|
+
cwd: options.cwd,
|
|
2591
|
+
encoding: "utf8",
|
|
2592
|
+
shell: false,
|
|
2593
|
+
stdio: "ignore"
|
|
2594
|
+
}).status !== 0;
|
|
2179
2595
|
}
|
|
2180
|
-
async function
|
|
2596
|
+
async function hasPendingIntents(cwd) {
|
|
2181
2597
|
try {
|
|
2182
2598
|
return (await readdir(path.join(cwd, ".changeset"), { withFileTypes: true })).some((entry) => entry.isFile() && entry.name.endsWith(".md"));
|
|
2183
2599
|
} catch {
|
|
@@ -2185,49 +2601,444 @@ async function hasPendingChangesets(cwd) {
|
|
|
2185
2601
|
}
|
|
2186
2602
|
}
|
|
2187
2603
|
function resolveBranch(options) {
|
|
2188
|
-
return options.branch?.trim() ||
|
|
2604
|
+
return options.branch?.trim() || getReleaseEnv(options)["GITHUB_REF_NAME"]?.trim() || capture("git", [
|
|
2189
2605
|
"rev-parse",
|
|
2190
2606
|
"--abbrev-ref",
|
|
2191
2607
|
"HEAD"
|
|
2192
2608
|
], options);
|
|
2193
2609
|
}
|
|
2194
|
-
async function
|
|
2195
|
-
const
|
|
2196
|
-
|
|
2197
|
-
if (
|
|
2610
|
+
async function getPublishablePackageNames(cwd) {
|
|
2611
|
+
const { packages } = await getWorkspaceData(cwd);
|
|
2612
|
+
const names = packages.map((pkg) => pkg.manifest.name).filter((name) => Boolean(name));
|
|
2613
|
+
if (!names.length) throw new ReleaseCommandError("no publishable workspace packages were found");
|
|
2614
|
+
return names;
|
|
2615
|
+
}
|
|
2616
|
+
function packageFilters(names) {
|
|
2617
|
+
return names.flatMap((name) => ["--filter", name]);
|
|
2618
|
+
}
|
|
2619
|
+
async function runLane(lane, options) {
|
|
2620
|
+
run("pnpm", [
|
|
2621
|
+
"lane",
|
|
2622
|
+
lane,
|
|
2623
|
+
...packageFilters(await getPublishablePackageNames(options.cwd))
|
|
2624
|
+
], options);
|
|
2625
|
+
}
|
|
2626
|
+
async function readLaneAssignments(cwd) {
|
|
2627
|
+
try {
|
|
2628
|
+
const workspaceFile = await readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8");
|
|
2629
|
+
return YAML.parse(workspaceFile).versioning?.lanes ?? {};
|
|
2630
|
+
} catch {
|
|
2631
|
+
return {};
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
async function assertLaneAssignments(lane, options) {
|
|
2635
|
+
const names = await getPublishablePackageNames(options.cwd);
|
|
2636
|
+
const assignments = await readLaneAssignments(options.cwd);
|
|
2637
|
+
const mismatched = names.filter((name) => assignments[name] !== lane);
|
|
2638
|
+
if (mismatched.length) throw new ReleaseCommandError([
|
|
2639
|
+
`all publishable packages must be on the ${lane} lane before prerelease publishing`,
|
|
2640
|
+
`mismatched packages: ${mismatched.join(", ")}`,
|
|
2641
|
+
`Run \`repo release pre enter ${lane}\`, commit pnpm-workspace.yaml, and push again.`
|
|
2642
|
+
].join("\n"));
|
|
2643
|
+
}
|
|
2644
|
+
async function assertStableLaneAssignments(options) {
|
|
2645
|
+
const assignments = await readLaneAssignments(options.cwd);
|
|
2646
|
+
const active = Object.entries(assignments).filter(([, lane]) => lane !== "main");
|
|
2647
|
+
if (active.length) throw new ReleaseCommandError(`stable releases require all packages on the main lane, found ${active.map(([name, lane]) => `${name}:${lane}`).join(", ")}`);
|
|
2648
|
+
}
|
|
2649
|
+
function runQualityChecks(options) {
|
|
2198
2650
|
run("pnpm", ["run", "build"], options);
|
|
2199
2651
|
run("pnpm", ["run", "lint"], options);
|
|
2200
2652
|
run("pnpm", ["run", "test"], options);
|
|
2201
|
-
run("pnpm", [
|
|
2202
|
-
"exec",
|
|
2203
|
-
"changeset",
|
|
2204
|
-
"publish"
|
|
2205
|
-
], options);
|
|
2206
2653
|
}
|
|
2654
|
+
function parsePublishSummary(content) {
|
|
2655
|
+
let parsed;
|
|
2656
|
+
try {
|
|
2657
|
+
parsed = JSON.parse(content);
|
|
2658
|
+
} catch {
|
|
2659
|
+
throw new ReleaseCommandError("pnpm-publish-summary.json is not valid JSON");
|
|
2660
|
+
}
|
|
2661
|
+
if (!parsed || typeof parsed !== "object" || !Array.isArray(parsed.publishedPackages)) throw new ReleaseCommandError("pnpm-publish-summary.json does not contain publishedPackages");
|
|
2662
|
+
return parsed.publishedPackages.map((item) => {
|
|
2663
|
+
if (!item || typeof item !== "object" || typeof item.name !== "string" || typeof item.version !== "string") throw new ReleaseCommandError("pnpm-publish-summary.json contains an invalid package entry");
|
|
2664
|
+
return {
|
|
2665
|
+
name: item.name,
|
|
2666
|
+
version: item.version
|
|
2667
|
+
};
|
|
2668
|
+
});
|
|
2669
|
+
}
|
|
2670
|
+
async function readPublishSummary(cwd) {
|
|
2671
|
+
const summaryPath = path.join(cwd, "pnpm-publish-summary.json");
|
|
2672
|
+
try {
|
|
2673
|
+
await access(summaryPath);
|
|
2674
|
+
return parsePublishSummary(await readFile(summaryPath, "utf8"));
|
|
2675
|
+
} catch (error) {
|
|
2676
|
+
if (error instanceof ReleaseCommandError) throw error;
|
|
2677
|
+
return [];
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
//#endregion
|
|
2681
|
+
//#region src/commands/release/body.ts
|
|
2682
|
+
async function readPackageRelease(name, version, rootDir) {
|
|
2683
|
+
let changelog;
|
|
2684
|
+
try {
|
|
2685
|
+
changelog = await readFile(path.join(rootDir, "CHANGELOG.md"), "utf8");
|
|
2686
|
+
} catch {
|
|
2687
|
+
return;
|
|
2688
|
+
}
|
|
2689
|
+
const section = readVersionSection(changelog, version);
|
|
2690
|
+
if (!section?.content) return;
|
|
2691
|
+
return {
|
|
2692
|
+
name,
|
|
2693
|
+
version,
|
|
2694
|
+
...section.previousVersion ? { previousVersion: section.previousVersion } : {},
|
|
2695
|
+
content: section.content
|
|
2696
|
+
};
|
|
2697
|
+
}
|
|
2698
|
+
/** Captures source commits and package ownership before pnpm consumes intents. */
|
|
2699
|
+
async function readPendingIntentCommits(options) {
|
|
2700
|
+
let entries;
|
|
2701
|
+
try {
|
|
2702
|
+
entries = await readdir(path.join(options.cwd, ".changeset"), { withFileTypes: true });
|
|
2703
|
+
} catch {
|
|
2704
|
+
return [];
|
|
2705
|
+
}
|
|
2706
|
+
const commits = [];
|
|
2707
|
+
for (const entry of entries) {
|
|
2708
|
+
if (!entry.isFile() || entry.name === "README.md" || !entry.name.endsWith(".md")) continue;
|
|
2709
|
+
try {
|
|
2710
|
+
const intentPath = `.changeset/${entry.name}`;
|
|
2711
|
+
const intentContent = await readFile(path.join(options.cwd, intentPath), "utf8");
|
|
2712
|
+
const packages = parseIntentPackages(intentContent);
|
|
2713
|
+
const summary = parseIntentSummary(intentContent);
|
|
2714
|
+
const sha = capture("git", [
|
|
2715
|
+
"log",
|
|
2716
|
+
"-1",
|
|
2717
|
+
"--format=%H",
|
|
2718
|
+
"--",
|
|
2719
|
+
intentPath
|
|
2720
|
+
], options);
|
|
2721
|
+
if (!sha) continue;
|
|
2722
|
+
const [fullSha, subject, body, author] = capture("git", [
|
|
2723
|
+
"show",
|
|
2724
|
+
"-s",
|
|
2725
|
+
"--format=%H%x1F%s%x1F%b%x1F%an",
|
|
2726
|
+
sha
|
|
2727
|
+
], options).split("");
|
|
2728
|
+
if (fullSha) commits.push({
|
|
2729
|
+
sha: fullSha,
|
|
2730
|
+
subject: subject ?? "",
|
|
2731
|
+
body: body ?? "",
|
|
2732
|
+
...author ? { author } : {},
|
|
2733
|
+
...packages.length ? { packages } : {},
|
|
2734
|
+
...summary ? { summary } : {}
|
|
2735
|
+
});
|
|
2736
|
+
} catch {}
|
|
2737
|
+
}
|
|
2738
|
+
return uniqueCommits(commits);
|
|
2739
|
+
}
|
|
2740
|
+
async function readWorkspaceVersions(cwd) {
|
|
2741
|
+
const packages = await getWorkspacePackages(cwd);
|
|
2742
|
+
const versions = /* @__PURE__ */ new Map();
|
|
2743
|
+
for (const pkg of packages) try {
|
|
2744
|
+
const manifest = JSON.parse(await readFile(pkg.pkgJsonPath, "utf8"));
|
|
2745
|
+
if (typeof manifest.name === "string" && typeof manifest.version === "string") versions.set(manifest.name, manifest.version);
|
|
2746
|
+
} catch {}
|
|
2747
|
+
return versions;
|
|
2748
|
+
}
|
|
2749
|
+
function buildReleasePackage(release) {
|
|
2750
|
+
const packageLinks = {};
|
|
2751
|
+
if (!release.private) {
|
|
2752
|
+
packageLinks.npmUrl = release.npmUrl ?? buildNpmPackageUrl(release.name, release.version);
|
|
2753
|
+
if (release.previousVersion) packageLinks.previousNpmUrl = buildNpmPackageUrl(release.name, release.previousVersion);
|
|
2754
|
+
}
|
|
2755
|
+
return {
|
|
2756
|
+
name: release.name,
|
|
2757
|
+
version: release.version,
|
|
2758
|
+
...release.previousVersion ? { previousVersion: release.previousVersion } : {},
|
|
2759
|
+
...packageLinks
|
|
2760
|
+
};
|
|
2761
|
+
}
|
|
2762
|
+
function buildReleaseNoteDocumentFromReleases(releases, metadata) {
|
|
2763
|
+
const entries = releases.flatMap((release) => buildEntries(release, metadata.commits ?? []));
|
|
2764
|
+
const contributors = [.../* @__PURE__ */ new Set([...metadata.contributors ?? [], ...entries.flatMap((entry) => entry.authors)])].filter((value) => !isAutomationContributor(value));
|
|
2765
|
+
const compareUrls = releases.map((release) => buildPackageCompareUrl(release, metadata)).filter((url) => Boolean(url));
|
|
2766
|
+
return {
|
|
2767
|
+
packages: releases.map(buildReleasePackage),
|
|
2768
|
+
entries,
|
|
2769
|
+
contributors,
|
|
2770
|
+
compareUrls
|
|
2771
|
+
};
|
|
2772
|
+
}
|
|
2773
|
+
async function buildReleaseNoteDocument(cwd, previousVersions, metadata = {}) {
|
|
2774
|
+
const workspacePackages = await getWorkspacePackages(cwd);
|
|
2775
|
+
const releases = [];
|
|
2776
|
+
for (const pkg of workspacePackages) {
|
|
2777
|
+
let manifest;
|
|
2778
|
+
try {
|
|
2779
|
+
manifest = JSON.parse(await readFile(pkg.pkgJsonPath, "utf8"));
|
|
2780
|
+
} catch {
|
|
2781
|
+
continue;
|
|
2782
|
+
}
|
|
2783
|
+
if (typeof manifest.name !== "string" || typeof manifest.version !== "string") continue;
|
|
2784
|
+
if (previousVersions?.get(manifest.name) === manifest.version) continue;
|
|
2785
|
+
const release = await readPackageRelease(manifest.name, manifest.version, pkg.rootDir);
|
|
2786
|
+
if (release) {
|
|
2787
|
+
const previousVersion = previousVersions?.get(manifest.name) || release.previousVersion;
|
|
2788
|
+
releases.push({
|
|
2789
|
+
...release,
|
|
2790
|
+
...manifest.private === true ? { private: true } : { npmUrl: buildNpmPackageUrl(manifest.name, manifest.version) },
|
|
2791
|
+
...previousVersion ? { previousVersion } : {}
|
|
2792
|
+
});
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
return buildReleaseNoteDocumentFromReleases(releases, metadata);
|
|
2796
|
+
}
|
|
2797
|
+
function buildGitHubReleaseBodyFromChangelog(packageName, packageVersion, changelog, metadata = {}) {
|
|
2798
|
+
const section = readVersionSection(changelog, packageVersion);
|
|
2799
|
+
if (!section?.content) return "No significant changes.";
|
|
2800
|
+
return renderGitHubRelease(buildReleaseNoteDocumentFromReleases([{
|
|
2801
|
+
name: packageName,
|
|
2802
|
+
version: packageVersion,
|
|
2803
|
+
...section.previousVersion ? { previousVersion: section.previousVersion } : {},
|
|
2804
|
+
npmUrl: buildNpmPackageUrl(packageName, packageVersion),
|
|
2805
|
+
content: section.content
|
|
2806
|
+
}], metadata), metadata);
|
|
2807
|
+
}
|
|
2808
|
+
//#endregion
|
|
2809
|
+
//#region src/commands/release/github.ts
|
|
2810
|
+
var GitHubApiError = class extends ReleaseCommandError {
|
|
2811
|
+
status;
|
|
2812
|
+
responseBody;
|
|
2813
|
+
constructor(message, status, responseBody) {
|
|
2814
|
+
super(message);
|
|
2815
|
+
this.status = status;
|
|
2816
|
+
this.responseBody = responseBody;
|
|
2817
|
+
this.name = "GitHubApiError";
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
var GitHubClient = class {
|
|
2821
|
+
token;
|
|
2822
|
+
repository;
|
|
2823
|
+
apiUrl;
|
|
2824
|
+
requestFetch;
|
|
2825
|
+
constructor(options = {}) {
|
|
2826
|
+
this.token = options.token ?? process.env["GITHUB_TOKEN"];
|
|
2827
|
+
this.repository = options.repository ?? process.env["GITHUB_REPOSITORY"];
|
|
2828
|
+
this.apiUrl = (options.apiUrl ?? process.env["GITHUB_API_URL"] ?? "https://api.github.com").replace(/\/$/, "");
|
|
2829
|
+
this.requestFetch = options.fetch ?? globalThis.fetch;
|
|
2830
|
+
}
|
|
2831
|
+
getRepository() {
|
|
2832
|
+
if (!this.token) throw new GitHubApiError("GITHUB_TOKEN is required for GitHub release orchestration", 0);
|
|
2833
|
+
if (!this.repository || !/^[^/]+\/[^/]+$/.test(this.repository)) throw new GitHubApiError("GITHUB_REPOSITORY must be in owner/name format", 0);
|
|
2834
|
+
return this.repository;
|
|
2835
|
+
}
|
|
2836
|
+
async request(method, endpoint, body) {
|
|
2837
|
+
const repository = this.getRepository();
|
|
2838
|
+
let response;
|
|
2839
|
+
try {
|
|
2840
|
+
response = await this.requestFetch(`${this.apiUrl}/repos/${repository}${endpoint}`, {
|
|
2841
|
+
method,
|
|
2842
|
+
headers: {
|
|
2843
|
+
"Accept": "application/vnd.github+json",
|
|
2844
|
+
"Authorization": `Bearer ${this.token}`,
|
|
2845
|
+
"X-GitHub-Api-Version": "2022-11-28",
|
|
2846
|
+
...body === void 0 ? {} : { "Content-Type": "application/json" }
|
|
2847
|
+
},
|
|
2848
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
2849
|
+
});
|
|
2850
|
+
} catch (error) {
|
|
2851
|
+
throw new GitHubApiError(`GitHub API request ${method} ${endpoint} failed: ${error instanceof Error ? error.message : String(error)}. Check network access and GITHUB_API_URL.`, 0);
|
|
2852
|
+
}
|
|
2853
|
+
const text = await response.text();
|
|
2854
|
+
let data;
|
|
2855
|
+
if (text) try {
|
|
2856
|
+
data = JSON.parse(text);
|
|
2857
|
+
} catch {
|
|
2858
|
+
throw new GitHubApiError(`GitHub API returned invalid JSON for ${method} ${endpoint}`, response.status, text);
|
|
2859
|
+
}
|
|
2860
|
+
if (!response.ok) {
|
|
2861
|
+
const message = typeof data === "object" && data !== null && "message" in data ? String(data.message) : text || response.statusText;
|
|
2862
|
+
throw new GitHubApiError(`GitHub API ${method} ${endpoint} failed (${response.status}): ${message}`, response.status, text);
|
|
2863
|
+
}
|
|
2864
|
+
return {
|
|
2865
|
+
status: response.status,
|
|
2866
|
+
data
|
|
2867
|
+
};
|
|
2868
|
+
}
|
|
2869
|
+
async ensurePullRequest(options) {
|
|
2870
|
+
const [owner] = this.getRepository().split("/");
|
|
2871
|
+
const head = options.head.includes(":") ? options.head : `${owner}:${options.head}`;
|
|
2872
|
+
const query = new URLSearchParams({
|
|
2873
|
+
state: "open",
|
|
2874
|
+
head,
|
|
2875
|
+
base: options.base,
|
|
2876
|
+
per_page: "10"
|
|
2877
|
+
});
|
|
2878
|
+
const existing = (await this.request("GET", `/pulls?${query.toString()}`)).data?.[0];
|
|
2879
|
+
if (existing) {
|
|
2880
|
+
await this.request("PATCH", `/pulls/${existing.number}`, {
|
|
2881
|
+
title: options.title,
|
|
2882
|
+
body: options.body,
|
|
2883
|
+
base: options.base
|
|
2884
|
+
});
|
|
2885
|
+
return existing;
|
|
2886
|
+
}
|
|
2887
|
+
try {
|
|
2888
|
+
const created = await this.request("POST", "/pulls", {
|
|
2889
|
+
title: options.title,
|
|
2890
|
+
body: options.body,
|
|
2891
|
+
head: options.head,
|
|
2892
|
+
base: options.base
|
|
2893
|
+
});
|
|
2894
|
+
if (!created.data) throw new GitHubApiError("GitHub did not return the created pull request", created.status);
|
|
2895
|
+
return created.data;
|
|
2896
|
+
} catch (error) {
|
|
2897
|
+
if (!(error instanceof GitHubApiError) || error.status !== 422) throw error;
|
|
2898
|
+
const recovered = await this.request("GET", `/pulls?${query.toString()}`);
|
|
2899
|
+
if (recovered.data?.[0]) return recovered.data[0];
|
|
2900
|
+
throw error;
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
async closeLegacyReleasePullRequests(options) {
|
|
2904
|
+
const [owner] = this.getRepository().split("/");
|
|
2905
|
+
const head = options.head.includes(":") ? options.head : `${owner}:${options.head}`;
|
|
2906
|
+
const query = new URLSearchParams({
|
|
2907
|
+
state: "open",
|
|
2908
|
+
head,
|
|
2909
|
+
base: options.base,
|
|
2910
|
+
per_page: "100"
|
|
2911
|
+
});
|
|
2912
|
+
const listed = await this.request("GET", `/pulls?${query.toString()}`);
|
|
2913
|
+
for (const pullRequest of listed.data ?? []) if (pullRequest.head?.ref === options.head && (pullRequest.title === "Version Packages" || pullRequest.body?.includes("changesets/action") === true)) await this.request("PATCH", `/pulls/${pullRequest.number}`, { state: "closed" });
|
|
2914
|
+
}
|
|
2915
|
+
async ensureRelease(options) {
|
|
2916
|
+
let existing;
|
|
2917
|
+
try {
|
|
2918
|
+
existing = (await this.request("GET", `/releases/tags/${encodeURIComponent(options.tag)}`)).data;
|
|
2919
|
+
} catch (error) {
|
|
2920
|
+
if (!(error instanceof GitHubApiError) || error.status !== 404) throw error;
|
|
2921
|
+
}
|
|
2922
|
+
if (existing) {
|
|
2923
|
+
if (options.body !== void 0 || options.name !== void 0) return (await this.request("PATCH", `/releases/${existing.id}`, {
|
|
2924
|
+
...options.name === void 0 ? {} : { name: options.name },
|
|
2925
|
+
...options.body === void 0 ? {} : { body: options.body },
|
|
2926
|
+
prerelease: options.prerelease ?? false
|
|
2927
|
+
})).data ?? existing;
|
|
2928
|
+
return existing;
|
|
2929
|
+
}
|
|
2930
|
+
try {
|
|
2931
|
+
const created = await this.request("POST", "/releases", {
|
|
2932
|
+
tag_name: options.tag,
|
|
2933
|
+
target_commitish: options.target,
|
|
2934
|
+
name: options.name ?? options.tag,
|
|
2935
|
+
...options.body === void 0 ? { generate_release_notes: true } : { body: options.body },
|
|
2936
|
+
prerelease: options.prerelease ?? false
|
|
2937
|
+
});
|
|
2938
|
+
if (!created.data) throw new GitHubApiError("GitHub did not return the created release", created.status);
|
|
2939
|
+
return created.data;
|
|
2940
|
+
} catch (error) {
|
|
2941
|
+
if (!(error instanceof GitHubApiError) || error.status !== 422) throw error;
|
|
2942
|
+
const recovered = await this.request("GET", `/releases/tags/${encodeURIComponent(options.tag)}`);
|
|
2943
|
+
if (!recovered.data) throw error;
|
|
2944
|
+
return recovered.data;
|
|
2945
|
+
}
|
|
2946
|
+
}
|
|
2947
|
+
async listReleases() {
|
|
2948
|
+
const releases = [];
|
|
2949
|
+
for (let page = 1;; page++) {
|
|
2950
|
+
const pageReleases = (await this.request("GET", `/releases?per_page=100&page=${page}`)).data ?? [];
|
|
2951
|
+
releases.push(...pageReleases);
|
|
2952
|
+
if (pageReleases.length < 100) break;
|
|
2953
|
+
}
|
|
2954
|
+
return releases;
|
|
2955
|
+
}
|
|
2956
|
+
async updateRelease(options) {
|
|
2957
|
+
const response = await this.request("PATCH", `/releases/${options.id}`, {
|
|
2958
|
+
name: options.name,
|
|
2959
|
+
body: options.body
|
|
2960
|
+
});
|
|
2961
|
+
if (!response.data) throw new GitHubApiError(`GitHub did not return release ${options.id} after update`, response.status);
|
|
2962
|
+
return response.data;
|
|
2963
|
+
}
|
|
2964
|
+
async enrichReleaseNote(document) {
|
|
2965
|
+
try {
|
|
2966
|
+
const commitAuthors = /* @__PURE__ */ new Map();
|
|
2967
|
+
const commitShas = [...new Set(document.entries.flatMap((entry) => entry.commits.map((commit) => commit.sha)))];
|
|
2968
|
+
for (const sha of commitShas) {
|
|
2969
|
+
const response = await this.request("GET", `/commits/${encodeURIComponent(sha)}`);
|
|
2970
|
+
const author = response.data?.author?.login || response.data?.commit?.author?.name;
|
|
2971
|
+
if (author) commitAuthors.set(sha, author);
|
|
2972
|
+
}
|
|
2973
|
+
const referenceNumbers = [...new Set(document.entries.flatMap((entry) => [...entry.pullRequests, ...entry.issues]))];
|
|
2974
|
+
const referenceAuthors = /* @__PURE__ */ new Set();
|
|
2975
|
+
for (const number of referenceNumbers) {
|
|
2976
|
+
const author = (await this.request("GET", `/issues/${number}`)).data?.user?.login;
|
|
2977
|
+
if (author) referenceAuthors.add(author);
|
|
2978
|
+
}
|
|
2979
|
+
const entries = document.entries.map((entry) => {
|
|
2980
|
+
const authors = [.../* @__PURE__ */ new Set([...entry.authors, ...entry.commits.map((commit) => commitAuthors.get(commit.sha)).filter((author) => Boolean(author))])];
|
|
2981
|
+
return authors.length ? {
|
|
2982
|
+
...entry,
|
|
2983
|
+
authors
|
|
2984
|
+
} : entry;
|
|
2985
|
+
});
|
|
2986
|
+
return {
|
|
2987
|
+
...document,
|
|
2988
|
+
entries,
|
|
2989
|
+
contributors: [.../* @__PURE__ */ new Set([
|
|
2990
|
+
...document.contributors,
|
|
2991
|
+
...commitAuthors.values(),
|
|
2992
|
+
...referenceAuthors
|
|
2993
|
+
])].filter((value) => !isAutomationContributor(value))
|
|
2994
|
+
};
|
|
2995
|
+
} catch (error) {
|
|
2996
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2997
|
+
logger.warn(`GitHub release note metadata enrichment skipped: ${message}`);
|
|
2998
|
+
return document;
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
async ensureTag(options) {
|
|
3002
|
+
const endpoint = `/git/ref/tags/${encodeURIComponent(options.tag)}`;
|
|
3003
|
+
try {
|
|
3004
|
+
await this.request("GET", endpoint);
|
|
3005
|
+
return;
|
|
3006
|
+
} catch (error) {
|
|
3007
|
+
if (!(error instanceof GitHubApiError) || error.status !== 404) throw error;
|
|
3008
|
+
}
|
|
3009
|
+
try {
|
|
3010
|
+
await this.request("POST", "/git/refs", {
|
|
3011
|
+
ref: `refs/tags/${options.tag}`,
|
|
3012
|
+
sha: options.target
|
|
3013
|
+
});
|
|
3014
|
+
} catch (error) {
|
|
3015
|
+
if (!(error instanceof GitHubApiError) || error.status !== 422) throw error;
|
|
3016
|
+
await this.request("GET", endpoint);
|
|
3017
|
+
}
|
|
3018
|
+
}
|
|
3019
|
+
};
|
|
3020
|
+
//#endregion
|
|
3021
|
+
//#region src/commands/release/types.ts
|
|
3022
|
+
const prereleaseBranches = /* @__PURE__ */ new Set([
|
|
3023
|
+
"alpha",
|
|
3024
|
+
"beta",
|
|
3025
|
+
"rc",
|
|
3026
|
+
"next"
|
|
3027
|
+
]);
|
|
3028
|
+
//#endregion
|
|
3029
|
+
//#region src/commands/release/prerelease.ts
|
|
2207
3030
|
async function releasePrerelease(options) {
|
|
2208
3031
|
const branch = resolveBranch(options);
|
|
2209
3032
|
if (!prereleaseBranches.has(branch)) throw new ReleaseCommandError(`repo release pre is only allowed on alpha, beta, rc, or next branches, got ${branch}`);
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
run("pnpm", ["run", "lint"], options);
|
|
2214
|
-
run("pnpm", ["run", "test"], options);
|
|
2215
|
-
if (!await hasPendingChangesets(options.cwd)) return;
|
|
3033
|
+
await assertLaneAssignments(branch, options);
|
|
3034
|
+
runQualityChecks(options);
|
|
3035
|
+
if (!await hasPendingIntents(options.cwd)) return;
|
|
2216
3036
|
run("pnpm", [
|
|
2217
|
-
"
|
|
2218
|
-
"
|
|
2219
|
-
"
|
|
3037
|
+
"version",
|
|
3038
|
+
"-r",
|
|
3039
|
+
"--no-git-checks"
|
|
2220
3040
|
], options);
|
|
2221
|
-
if (!(
|
|
2222
|
-
"diff",
|
|
2223
|
-
"--quiet",
|
|
2224
|
-
"--exit-code"
|
|
2225
|
-
], {
|
|
2226
|
-
cwd: options.cwd,
|
|
2227
|
-
encoding: "utf8",
|
|
2228
|
-
shell: false,
|
|
2229
|
-
stdio: "ignore"
|
|
2230
|
-
}).status !== 0)) return;
|
|
3041
|
+
if (!hasGitChanges(options)) return;
|
|
2231
3042
|
run("git", ["add", "-A"], options);
|
|
2232
3043
|
run("git", [
|
|
2233
3044
|
"commit",
|
|
@@ -2235,9 +3046,13 @@ async function releasePrerelease(options) {
|
|
|
2235
3046
|
`chore(release): ${branch} [skip ci]`
|
|
2236
3047
|
], options);
|
|
2237
3048
|
run("pnpm", [
|
|
2238
|
-
"
|
|
2239
|
-
"
|
|
2240
|
-
"
|
|
3049
|
+
"publish",
|
|
3050
|
+
"-r",
|
|
3051
|
+
"--tag",
|
|
3052
|
+
branch,
|
|
3053
|
+
"--report-summary",
|
|
3054
|
+
"--provenance",
|
|
3055
|
+
"--no-git-checks"
|
|
2241
3056
|
], options);
|
|
2242
3057
|
run("git", [
|
|
2243
3058
|
"push",
|
|
@@ -2246,23 +3061,368 @@ async function releasePrerelease(options) {
|
|
|
2246
3061
|
`HEAD:${branch}`
|
|
2247
3062
|
], options);
|
|
2248
3063
|
}
|
|
2249
|
-
function enterPrerelease(tag, options) {
|
|
2250
|
-
if (!prereleaseBranches.has(tag)) throw new ReleaseCommandError(`unknown prerelease
|
|
3064
|
+
async function enterPrerelease(tag, options) {
|
|
3065
|
+
if (!prereleaseBranches.has(tag)) throw new ReleaseCommandError(`unknown prerelease lane ${tag}; expected alpha, beta, rc, or next`);
|
|
3066
|
+
await runLane(tag, options);
|
|
3067
|
+
}
|
|
3068
|
+
async function exitPrerelease(options) {
|
|
3069
|
+
await runLane("main", options);
|
|
3070
|
+
}
|
|
3071
|
+
//#endregion
|
|
3072
|
+
//#region src/commands/release/stable.ts
|
|
3073
|
+
async function prepareStable(options) {
|
|
3074
|
+
const branch = resolveBranch(options);
|
|
3075
|
+
if (branch !== "main") throw new ReleaseCommandError(`repo release stable prepare is only allowed on main, got ${branch}`);
|
|
3076
|
+
await assertStableLaneAssignments(options);
|
|
3077
|
+
runQualityChecks(options);
|
|
3078
|
+
if (!await hasPendingIntents(options.cwd)) return false;
|
|
2251
3079
|
run("pnpm", [
|
|
2252
|
-
"
|
|
2253
|
-
"
|
|
2254
|
-
"
|
|
2255
|
-
"enter",
|
|
2256
|
-
tag
|
|
3080
|
+
"version",
|
|
3081
|
+
"-r",
|
|
3082
|
+
"--no-git-checks"
|
|
2257
3083
|
], options);
|
|
3084
|
+
return hasGitChanges(options);
|
|
2258
3085
|
}
|
|
2259
|
-
function
|
|
3086
|
+
async function publishStable(options) {
|
|
3087
|
+
const branch = resolveBranch(options);
|
|
3088
|
+
if (branch !== "main") throw new ReleaseCommandError(`repo release stable publish is only allowed on main, got ${branch}`);
|
|
3089
|
+
await assertStableLaneAssignments(options);
|
|
3090
|
+
runQualityChecks(options);
|
|
2260
3091
|
run("pnpm", [
|
|
3092
|
+
"publish",
|
|
3093
|
+
"-r",
|
|
3094
|
+
"--report-summary",
|
|
3095
|
+
"--provenance",
|
|
3096
|
+
"--no-git-checks"
|
|
3097
|
+
], options);
|
|
3098
|
+
}
|
|
3099
|
+
/** Compatibility entry point retained for existing generated repositories. */
|
|
3100
|
+
async function releaseStable(options) {
|
|
3101
|
+
await publishStable(options);
|
|
3102
|
+
}
|
|
3103
|
+
//#endregion
|
|
3104
|
+
//#region src/commands/release/ci.ts
|
|
3105
|
+
const releaseBranch = "release/pnpm-version";
|
|
3106
|
+
function gitRefExists(ref, options) {
|
|
3107
|
+
return (options.spawn ?? spawnSync)("git", [
|
|
3108
|
+
"rev-parse",
|
|
3109
|
+
"--verify",
|
|
3110
|
+
"--quiet",
|
|
3111
|
+
ref
|
|
3112
|
+
], {
|
|
3113
|
+
cwd: options.cwd,
|
|
3114
|
+
encoding: "utf8",
|
|
3115
|
+
shell: false,
|
|
3116
|
+
stdio: "ignore"
|
|
3117
|
+
}).status === 0;
|
|
3118
|
+
}
|
|
3119
|
+
function remoteTagExists(tag, options) {
|
|
3120
|
+
return (options.spawn ?? spawnSync)("git", [
|
|
3121
|
+
"ls-remote",
|
|
3122
|
+
"--exit-code",
|
|
3123
|
+
"--refs",
|
|
3124
|
+
"origin",
|
|
3125
|
+
`refs/tags/${tag}`
|
|
3126
|
+
], {
|
|
3127
|
+
cwd: options.cwd,
|
|
3128
|
+
encoding: "utf8",
|
|
3129
|
+
shell: false,
|
|
3130
|
+
stdio: "ignore"
|
|
3131
|
+
}).status === 0;
|
|
3132
|
+
}
|
|
3133
|
+
function resolveGitHub(options) {
|
|
3134
|
+
return options.github ?? new GitHubClient();
|
|
3135
|
+
}
|
|
3136
|
+
function resolveTarget(options) {
|
|
3137
|
+
return getReleaseEnv(options)["GITHUB_SHA"]?.trim() || capture("git", ["rev-parse", "HEAD"], options);
|
|
3138
|
+
}
|
|
3139
|
+
function formatPublishedPackageSummary(packages) {
|
|
3140
|
+
return ["Published packages:", ...packages.length ? packages.map((pkg) => ` - ${pkg.name}@${pkg.version}`) : [" (none)"]].join("\n");
|
|
3141
|
+
}
|
|
3142
|
+
async function publishMetadata(packages, options, prerelease = false) {
|
|
3143
|
+
if (!packages.length) {
|
|
3144
|
+
logger.success(formatPublishedPackageSummary(packages));
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
const github = resolveGitHub(options);
|
|
3148
|
+
const target = resolveTarget(options);
|
|
3149
|
+
const releaseEnv = getReleaseEnv(options);
|
|
3150
|
+
const metadata = {
|
|
3151
|
+
...releaseEnv["GITHUB_REPOSITORY"] ? { repository: releaseEnv["GITHUB_REPOSITORY"] } : {},
|
|
3152
|
+
...releaseEnv["GITHUB_SERVER_URL"] ? { serverUrl: releaseEnv["GITHUB_SERVER_URL"] } : {}
|
|
3153
|
+
};
|
|
3154
|
+
let noteDocument = await buildReleaseNoteDocument(options.cwd, void 0, metadata);
|
|
3155
|
+
if (github.enrichReleaseNote) noteDocument = await github.enrichReleaseNote(noteDocument);
|
|
3156
|
+
for (const pkg of packages) {
|
|
3157
|
+
const tag = `${pkg.name}@${pkg.version}`;
|
|
3158
|
+
const body = renderGitHubRelease({
|
|
3159
|
+
...noteDocument,
|
|
3160
|
+
packages: noteDocument.packages.filter((item) => item.name === pkg.name && item.version === pkg.version),
|
|
3161
|
+
entries: noteDocument.entries.filter((entry) => entry.packageName === pkg.name && entry.version === pkg.version),
|
|
3162
|
+
compareUrls: noteDocument.compareUrls.filter((url) => url.includes(encodeURIComponent(`${pkg.name}@`)))
|
|
3163
|
+
}, metadata);
|
|
3164
|
+
if (github.ensureTag) {
|
|
3165
|
+
await github.ensureTag({
|
|
3166
|
+
tag,
|
|
3167
|
+
target
|
|
3168
|
+
});
|
|
3169
|
+
await github.ensureRelease({
|
|
3170
|
+
tag,
|
|
3171
|
+
target,
|
|
3172
|
+
prerelease,
|
|
3173
|
+
name: tag,
|
|
3174
|
+
body
|
|
3175
|
+
});
|
|
3176
|
+
continue;
|
|
3177
|
+
}
|
|
3178
|
+
if (remoteTagExists(tag, options)) {
|
|
3179
|
+
await github.ensureRelease({
|
|
3180
|
+
tag,
|
|
3181
|
+
target,
|
|
3182
|
+
prerelease,
|
|
3183
|
+
name: tag,
|
|
3184
|
+
body
|
|
3185
|
+
});
|
|
3186
|
+
continue;
|
|
3187
|
+
}
|
|
3188
|
+
if (!gitRefExists(tag, options)) run("git", [
|
|
3189
|
+
"tag",
|
|
3190
|
+
"-a",
|
|
3191
|
+
tag,
|
|
3192
|
+
"-m",
|
|
3193
|
+
tag
|
|
3194
|
+
], options);
|
|
3195
|
+
run("git", [
|
|
3196
|
+
"push",
|
|
3197
|
+
"origin",
|
|
3198
|
+
`refs/tags/${tag}`
|
|
3199
|
+
], options);
|
|
3200
|
+
await github.ensureRelease({
|
|
3201
|
+
tag,
|
|
3202
|
+
target,
|
|
3203
|
+
prerelease,
|
|
3204
|
+
name: tag,
|
|
3205
|
+
body
|
|
3206
|
+
});
|
|
3207
|
+
}
|
|
3208
|
+
logger.success(formatPublishedPackageSummary(packages));
|
|
3209
|
+
}
|
|
3210
|
+
async function createReleasePullRequest(options) {
|
|
3211
|
+
const branch = resolveBranch(options);
|
|
3212
|
+
if (branch !== "main") throw new ReleaseCommandError(`repo release stable prepare is only allowed on main, got ${branch}`);
|
|
3213
|
+
const previousVersions = await readWorkspaceVersions(options.cwd);
|
|
3214
|
+
const sourceCommits = await readPendingIntentCommits(options);
|
|
3215
|
+
if (!await prepareStable(options)) return false;
|
|
3216
|
+
run("git", [
|
|
3217
|
+
"config",
|
|
3218
|
+
"user.name",
|
|
3219
|
+
"github-actions[bot]"
|
|
3220
|
+
], options);
|
|
3221
|
+
run("git", [
|
|
3222
|
+
"config",
|
|
3223
|
+
"user.email",
|
|
3224
|
+
"41898282+github-actions[bot]@users.noreply.github.com"
|
|
3225
|
+
], options);
|
|
3226
|
+
run("git", [
|
|
3227
|
+
"checkout",
|
|
3228
|
+
"-B",
|
|
3229
|
+
releaseBranch
|
|
3230
|
+
], options);
|
|
3231
|
+
run("git", ["add", "-A"], options);
|
|
3232
|
+
run("git", [
|
|
3233
|
+
"commit",
|
|
3234
|
+
"-m",
|
|
3235
|
+
"chore(release): version packages"
|
|
3236
|
+
], options);
|
|
3237
|
+
run("git", [
|
|
3238
|
+
"push",
|
|
3239
|
+
"--force",
|
|
3240
|
+
"origin",
|
|
3241
|
+
`HEAD:${releaseBranch}`
|
|
3242
|
+
], options);
|
|
3243
|
+
const github = resolveGitHub(options);
|
|
3244
|
+
const releaseEnv = getReleaseEnv(options);
|
|
3245
|
+
const metadata = {
|
|
3246
|
+
commits: sourceCommits,
|
|
3247
|
+
...releaseEnv["GITHUB_REPOSITORY"] ? { repository: releaseEnv["GITHUB_REPOSITORY"] } : {},
|
|
3248
|
+
...releaseEnv["GITHUB_SERVER_URL"] ? { serverUrl: releaseEnv["GITHUB_SERVER_URL"] } : {}
|
|
3249
|
+
};
|
|
3250
|
+
let noteDocument = await buildReleaseNoteDocument(options.cwd, previousVersions, metadata);
|
|
3251
|
+
if (github.enrichReleaseNote) noteDocument = await github.enrichReleaseNote(noteDocument);
|
|
3252
|
+
await github.ensurePullRequest({
|
|
3253
|
+
head: releaseBranch,
|
|
3254
|
+
base: "main",
|
|
3255
|
+
title: "chore(release): version packages",
|
|
3256
|
+
body: renderReleasePullRequest(noteDocument, metadata)
|
|
3257
|
+
});
|
|
3258
|
+
await github.closeLegacyReleasePullRequests?.({
|
|
3259
|
+
head: "changeset-release/main",
|
|
3260
|
+
base: "main"
|
|
3261
|
+
});
|
|
3262
|
+
return true;
|
|
3263
|
+
}
|
|
3264
|
+
async function recoverUnpublished(options) {
|
|
3265
|
+
const packageName = options.packageName || getReleaseEnv(options)["REPO_RELEASE_PACKAGE"]?.trim();
|
|
3266
|
+
const packageVersion = options.packageVersion || getReleaseEnv(options)["REPO_RELEASE_VERSION"]?.trim();
|
|
3267
|
+
if (!packageName || !packageVersion) throw new ReleaseCommandError("publish-unpublished requires REPO_RELEASE_PACKAGE and REPO_RELEASE_VERSION");
|
|
3268
|
+
const actualVersion = capture("pnpm", [
|
|
3269
|
+
"--filter",
|
|
3270
|
+
packageName,
|
|
2261
3271
|
"exec",
|
|
2262
|
-
"
|
|
2263
|
-
"
|
|
2264
|
-
"
|
|
3272
|
+
"node",
|
|
3273
|
+
"-p",
|
|
3274
|
+
"require('./package.json').version"
|
|
3275
|
+
], options);
|
|
3276
|
+
if (actualVersion !== packageVersion) throw new ReleaseCommandError(`expected ${packageName}@${packageVersion} in the workspace, found ${actualVersion}`);
|
|
3277
|
+
run("pnpm", [
|
|
3278
|
+
"publish",
|
|
3279
|
+
"-r",
|
|
3280
|
+
"--filter",
|
|
3281
|
+
packageName,
|
|
3282
|
+
"--report-summary",
|
|
3283
|
+
"--provenance",
|
|
3284
|
+
"--no-git-checks"
|
|
2265
3285
|
], options);
|
|
3286
|
+
if (capture("npm", [
|
|
3287
|
+
"view",
|
|
3288
|
+
`${packageName}@${packageVersion}`,
|
|
3289
|
+
"version"
|
|
3290
|
+
], options) !== packageVersion) throw new ReleaseCommandError(`npm did not report ${packageName}@${packageVersion} after recovery`);
|
|
3291
|
+
await publishMetadata(await readPublishSummary(options.cwd), options);
|
|
3292
|
+
}
|
|
3293
|
+
function resolveMode(options) {
|
|
3294
|
+
const requested = options.mode || getReleaseEnv(options)["REPO_RELEASE_MODE"]?.trim();
|
|
3295
|
+
if (requested && requested !== "auto") return requested;
|
|
3296
|
+
return "auto";
|
|
3297
|
+
}
|
|
3298
|
+
async function releaseCi(options) {
|
|
3299
|
+
const mode = resolveMode(options);
|
|
3300
|
+
if (mode === "prepare") {
|
|
3301
|
+
await createReleasePullRequest(options);
|
|
3302
|
+
return;
|
|
3303
|
+
}
|
|
3304
|
+
if (mode === "publish") {
|
|
3305
|
+
await publishStable(options);
|
|
3306
|
+
await publishMetadata(await readPublishSummary(options.cwd), options);
|
|
3307
|
+
return;
|
|
3308
|
+
}
|
|
3309
|
+
if (mode === "publish-unpublished") {
|
|
3310
|
+
await recoverUnpublished(options);
|
|
3311
|
+
return;
|
|
3312
|
+
}
|
|
3313
|
+
if (mode !== "auto") throw new ReleaseCommandError(`unknown release CI mode ${mode}; expected auto, prepare, publish, or publish-unpublished`);
|
|
3314
|
+
const branch = resolveBranch(options);
|
|
3315
|
+
if (prereleaseBranches.has(branch)) {
|
|
3316
|
+
await releasePrerelease(options);
|
|
3317
|
+
await publishMetadata(await readPublishSummary(options.cwd), options, true);
|
|
3318
|
+
return;
|
|
3319
|
+
}
|
|
3320
|
+
if (branch !== "main") throw new ReleaseCommandError(`repo release ci only supports main, alpha, beta, rc, or next branches, got ${branch}`);
|
|
3321
|
+
if (await hasPendingIntents(options.cwd)) {
|
|
3322
|
+
await createReleasePullRequest(options);
|
|
3323
|
+
return;
|
|
3324
|
+
}
|
|
3325
|
+
await publishStable(options);
|
|
3326
|
+
await publishMetadata(await readPublishSummary(options.cwd), options);
|
|
3327
|
+
}
|
|
3328
|
+
//#endregion
|
|
3329
|
+
//#region src/commands/release/repair.ts
|
|
3330
|
+
function parseReleaseTag(tag) {
|
|
3331
|
+
const separator = tag.lastIndexOf("@");
|
|
3332
|
+
if (separator <= 0) return;
|
|
3333
|
+
const packageName = tag.slice(0, separator);
|
|
3334
|
+
const version = tag.slice(separator + 1);
|
|
3335
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9a-z.-]+)?(?:\+[0-9a-z.-]+)?$/i.test(version)) return;
|
|
3336
|
+
return {
|
|
3337
|
+
packageName,
|
|
3338
|
+
version
|
|
3339
|
+
};
|
|
3340
|
+
}
|
|
3341
|
+
function packagePath(cwd, rootDir) {
|
|
3342
|
+
return path.relative(cwd, rootDir).replaceAll("\\", "/");
|
|
3343
|
+
}
|
|
3344
|
+
async function findTaggedPackageDirectory(tag, packageName, currentDirectories, options) {
|
|
3345
|
+
const currentDirectory = currentDirectories.get(packageName);
|
|
3346
|
+
if (currentDirectory) return currentDirectory;
|
|
3347
|
+
let packageFiles;
|
|
3348
|
+
try {
|
|
3349
|
+
packageFiles = capture("git", [
|
|
3350
|
+
"ls-tree",
|
|
3351
|
+
"-r",
|
|
3352
|
+
"--name-only",
|
|
3353
|
+
tag
|
|
3354
|
+
], options).split(/\r?\n/).filter((file) => file === "package.json" || file.endsWith("/package.json"));
|
|
3355
|
+
} catch {
|
|
3356
|
+
return;
|
|
3357
|
+
}
|
|
3358
|
+
for (const packageFile of packageFiles) try {
|
|
3359
|
+
if (JSON.parse(capture("git", ["show", `${tag}:${packageFile}`], options)).name === packageName) return packageFile === "package.json" ? "." : path.dirname(packageFile);
|
|
3360
|
+
} catch {}
|
|
3361
|
+
}
|
|
3362
|
+
async function readTagChangelog(tag, relativePackagePath, options) {
|
|
3363
|
+
const result = (options.spawn ?? spawnSync)("git", ["show", `${tag}:${relativePackagePath}/CHANGELOG.md`], {
|
|
3364
|
+
cwd: options.cwd,
|
|
3365
|
+
encoding: "utf8",
|
|
3366
|
+
shell: false,
|
|
3367
|
+
stdio: [
|
|
3368
|
+
"ignore",
|
|
3369
|
+
"pipe",
|
|
3370
|
+
"ignore"
|
|
3371
|
+
]
|
|
3372
|
+
});
|
|
3373
|
+
if (result.status !== 0) return;
|
|
3374
|
+
return result.stdout?.toString().trim() || void 0;
|
|
3375
|
+
}
|
|
3376
|
+
function releaseMetadata(options) {
|
|
3377
|
+
const env = getReleaseEnv(options);
|
|
3378
|
+
return {
|
|
3379
|
+
...env["GITHUB_REPOSITORY"] ? { repository: env["GITHUB_REPOSITORY"] } : {},
|
|
3380
|
+
...env["GITHUB_SERVER_URL"] ? { serverUrl: env["GITHUB_SERVER_URL"] } : {}
|
|
3381
|
+
};
|
|
3382
|
+
}
|
|
3383
|
+
async function repairReleaseNotes(options) {
|
|
3384
|
+
if (!options.all && !options.tag) throw new ReleaseCommandError("release notes repair requires --all or --tag <package@version>");
|
|
3385
|
+
const github = options.github ?? new GitHubClient();
|
|
3386
|
+
if (!github.listReleases || !github.updateRelease) throw new ReleaseCommandError("GitHub release repair requires listReleases and updateRelease operations");
|
|
3387
|
+
const releases = await github.listReleases();
|
|
3388
|
+
const selected = options.tag ? releases.filter((release) => release.tag_name === options.tag) : releases;
|
|
3389
|
+
const packages = await getWorkspacePackages(options.cwd);
|
|
3390
|
+
const workspaceRoot = await realpath(options.cwd);
|
|
3391
|
+
const packageDirectories = new Map(await Promise.all(packages.filter((pkg) => typeof pkg.manifest.name === "string").map(async (pkg) => {
|
|
3392
|
+
const rootDir = await realpath(pkg.rootDir);
|
|
3393
|
+
return [pkg.manifest.name, packagePath(workspaceRoot, rootDir)];
|
|
3394
|
+
})));
|
|
3395
|
+
const metadata = releaseMetadata(options);
|
|
3396
|
+
const repaired = [];
|
|
3397
|
+
const skipped = [];
|
|
3398
|
+
for (const release of selected) {
|
|
3399
|
+
const parsed = parseReleaseTag(release.tag_name);
|
|
3400
|
+
if (!parsed) {
|
|
3401
|
+
skipped.push(release.tag_name);
|
|
3402
|
+
continue;
|
|
3403
|
+
}
|
|
3404
|
+
let relativePath = await findTaggedPackageDirectory(release.tag_name, parsed.packageName, packageDirectories, options);
|
|
3405
|
+
let changelog = relativePath ? await readTagChangelog(release.tag_name, relativePath, options) : void 0;
|
|
3406
|
+
if (!changelog) {
|
|
3407
|
+
relativePath = await findTaggedPackageDirectory(release.tag_name, parsed.packageName, /* @__PURE__ */ new Map(), options);
|
|
3408
|
+
changelog = relativePath ? await readTagChangelog(release.tag_name, relativePath, options) : void 0;
|
|
3409
|
+
}
|
|
3410
|
+
if (!changelog) {
|
|
3411
|
+
skipped.push(release.tag_name);
|
|
3412
|
+
continue;
|
|
3413
|
+
}
|
|
3414
|
+
const body = buildGitHubReleaseBodyFromChangelog(parsed.packageName, parsed.version, changelog, metadata);
|
|
3415
|
+
if (!options.dryRun && (release.name !== release.tag_name || release.body !== body)) await github.updateRelease({
|
|
3416
|
+
id: release.id,
|
|
3417
|
+
name: release.tag_name,
|
|
3418
|
+
body
|
|
3419
|
+
});
|
|
3420
|
+
repaired.push(release.tag_name);
|
|
3421
|
+
}
|
|
3422
|
+
return {
|
|
3423
|
+
repaired,
|
|
3424
|
+
skipped
|
|
3425
|
+
};
|
|
2266
3426
|
}
|
|
2267
3427
|
//#endregion
|
|
2268
3428
|
//#region src/commands/templates.ts
|
|
@@ -2596,6 +3756,7 @@ const scriptsEntries = Object.entries({
|
|
|
2596
3756
|
//#region src/commands/upgrade/pkg-json.ts
|
|
2597
3757
|
const NON_OVERRIDABLE_PREFIXES = ["workspace:", "catalog:"];
|
|
2598
3758
|
const legacyToolPackageName = "@icebreakers/monorepo";
|
|
3759
|
+
const legacyReleaseDependencies = ["@changesets/cli", "@icebreakers/changelog-github"];
|
|
2599
3760
|
function parseVersion(input) {
|
|
2600
3761
|
if (typeof input !== "string" || input.trim().length === 0) return null;
|
|
2601
3762
|
try {
|
|
@@ -2651,6 +3812,10 @@ function setPkgJson(sourcePkgJson, targetPkgJson, options) {
|
|
|
2651
3812
|
}
|
|
2652
3813
|
}
|
|
2653
3814
|
if (legacyToolPackageName in targetDevDeps && "repoctl" in targetDevDeps) delete targetDevDeps[legacyToolPackageName];
|
|
3815
|
+
for (const dependency of legacyReleaseDependencies) {
|
|
3816
|
+
delete targetDeps[dependency];
|
|
3817
|
+
delete targetDevDeps[dependency];
|
|
3818
|
+
}
|
|
2654
3819
|
if (shouldEnsureRepoctl) {
|
|
2655
3820
|
const nextVersion = `^${version$1}`;
|
|
2656
3821
|
const targetVersion = targetDevDeps["repoctl"];
|
|
@@ -2804,6 +3969,12 @@ async function upgradeMonorepo(opts) {
|
|
|
2804
3969
|
const relPath = toWorkspaceGitignorePath(path.relative(assetsDir, file.path));
|
|
2805
3970
|
if (skipChangesetMarkdown && relPath.startsWith(".changeset/") && relPath.endsWith(".md")) continue;
|
|
2806
3971
|
const targetPath = path.resolve(absOutDir, relPath);
|
|
3972
|
+
if (relPath === ".github/workflows/release.yml" && await fs$1.pathExists(targetPath)) {
|
|
3973
|
+
if (await classifyReleaseWorkflow(absOutDir) === "custom" && !merged.overwriteRelease) {
|
|
3974
|
+
logger.warn("skip custom release workflow; use repo upgrade --overwrite-release to replace it");
|
|
3975
|
+
continue;
|
|
3976
|
+
}
|
|
3977
|
+
}
|
|
2807
3978
|
try {
|
|
2808
3979
|
if (relPath === "package.json") {
|
|
2809
3980
|
if (!await fs$1.pathExists(targetPath)) continue;
|
|
@@ -2881,23 +4052,6 @@ async function upgradeMonorepo(opts) {
|
|
|
2881
4052
|
});
|
|
2882
4053
|
continue;
|
|
2883
4054
|
}
|
|
2884
|
-
if (relPath === ".changeset/config.json" && repoName) {
|
|
2885
|
-
const changesetJson = await fs$1.readJson(file.path);
|
|
2886
|
-
setByPath(changesetJson, "changelog.1.repo", repoName);
|
|
2887
|
-
const data = `${JSON.stringify(changesetJson, void 0, 2)}\n`;
|
|
2888
|
-
const intent = await evaluateWriteIntent(targetPath, buildWriteIntentOptions(data));
|
|
2889
|
-
const action = async () => {
|
|
2890
|
-
await fs$1.outputFile(targetPath, data, "utf8");
|
|
2891
|
-
logger.success(targetPath);
|
|
2892
|
-
};
|
|
2893
|
-
await scheduleOverwrite(intent, {
|
|
2894
|
-
relPath,
|
|
2895
|
-
targetPath,
|
|
2896
|
-
action,
|
|
2897
|
-
pending: pendingOverwrites
|
|
2898
|
-
});
|
|
2899
|
-
continue;
|
|
2900
|
-
}
|
|
2901
4055
|
if (relPath === "LICENSE") {
|
|
2902
4056
|
const source = await fs$1.readFile(file.path);
|
|
2903
4057
|
const intent = await evaluateWriteIntent(targetPath, {
|
|
@@ -2958,11 +4112,14 @@ async function upgradeMonorepo(opts) {
|
|
|
2958
4112
|
...merged.overwrite !== void 0 ? { overwrite: merged.overwrite } : {},
|
|
2959
4113
|
...merged.noOverwrite !== void 0 ? { noOverwrite: merged.noOverwrite } : {}
|
|
2960
4114
|
});
|
|
4115
|
+
await migrateLegacyVersioning(absOutDir);
|
|
2961
4116
|
}
|
|
2962
4117
|
//#endregion
|
|
2963
4118
|
//#region src/commands/index.ts
|
|
2964
4119
|
var commands_exports = /* @__PURE__ */ __exportAll({
|
|
2965
4120
|
GitClient: () => GitClient,
|
|
4121
|
+
GitHubApiError: () => GitHubApiError,
|
|
4122
|
+
GitHubClient: () => GitHubClient,
|
|
2966
4123
|
checkTemplates: () => checkTemplates,
|
|
2967
4124
|
cleanProjects: () => cleanProjects,
|
|
2968
4125
|
collectEnvInfo: () => collectEnvInfo,
|
|
@@ -2970,6 +4127,7 @@ var commands_exports = /* @__PURE__ */ __exportAll({
|
|
|
2970
4127
|
collectEnvSnapshot: () => collectEnvSnapshot,
|
|
2971
4128
|
collectEnvSupportBundle: () => collectEnvSupportBundle,
|
|
2972
4129
|
createNewProject: () => createNewProject,
|
|
4130
|
+
createReleasePullRequest: () => createReleasePullRequest,
|
|
2973
4131
|
createTimestampFolderName: () => createTimestampFolderName,
|
|
2974
4132
|
defaultAgenticBaseDir: () => defaultAgenticBaseDir,
|
|
2975
4133
|
enterPrerelease: () => enterPrerelease,
|
|
@@ -2989,8 +4147,14 @@ var commands_exports = /* @__PURE__ */ __exportAll({
|
|
|
2989
4147
|
inspectMonorepoConfig: () => inspectMonorepoConfig,
|
|
2990
4148
|
loadAgenticTasks: () => loadAgenticTasks,
|
|
2991
4149
|
normalizeInitToolingTargets: () => normalizeInitToolingTargets,
|
|
4150
|
+
parsePublishSummary: () => parsePublishSummary,
|
|
4151
|
+
prepareStable: () => prepareStable,
|
|
4152
|
+
publishStable: () => publishStable,
|
|
4153
|
+
recoverUnpublished: () => recoverUnpublished,
|
|
4154
|
+
releaseCi: () => releaseCi,
|
|
2992
4155
|
releasePrerelease: () => releasePrerelease,
|
|
2993
4156
|
releaseStable: () => releaseStable,
|
|
4157
|
+
repairReleaseNotes: () => repairReleaseNotes,
|
|
2994
4158
|
resolveCreateNewProjectPlan: () => resolveCreateNewProjectPlan,
|
|
2995
4159
|
resolveFullWorkspaceCheckPlan: () => resolveFullWorkspaceCheckPlan,
|
|
2996
4160
|
resolveRecommendedCheckPlan: () => resolveRecommendedCheckPlan,
|
|
@@ -3007,4 +4171,4 @@ var commands_exports = /* @__PURE__ */ __exportAll({
|
|
|
3007
4171
|
verifyStagedTypecheck: () => verifyStagedTypecheck
|
|
3008
4172
|
});
|
|
3009
4173
|
//#endregion
|
|
3010
|
-
export {
|
|
4174
|
+
export { verifyPreCommit as $, getCreateChoices as A, isMatch as B, collectEnvInfo as C, runDoctor as D, collectEnvSupportBundle as E, cleanProjects as F, toPublishGitignorePath as G, getFileHash as H, getSkillTargetPaths as I, getKnownRepoCheckCommands as J, toWorkspaceGitignorePath as K, skillTargets as L, resolveCreateNewProjectPlan as M, templateMap as N, createNewProject as O, inspectMonorepoConfig as P, verifyCommitMsg as Q, syncSkills as R, createContext as S, collectEnvSnapshot as T, isFileChanged as U, setByPath as V, isGitignoreFile as W, resolveRecommendedCheckPlan as X, resolveFullWorkspaceCheckPlan as Y, runRecommendedCheck as Z, setVscodeBinaryMirror as _, createReleasePullRequest as a, generateAgenticTemplates as at, initTooling as b, prepareStable as c, enterPrerelease as d, verifyPrePush as et, exitPrerelease as f, parsePublishSummary as g, GitHubClient as h, repairReleaseNotes as i, generateAgenticTemplate as it, getTemplateMap as j, defaultTemplate as k, publishStable as l, GitHubApiError as m, upgradeMonorepo as n, createTimestampFolderName as nt, recoverUnpublished as o, loadAgenticTasks as ot, releasePrerelease as p, updateIssueTemplateConfig as q, checkTemplates as r, defaultAgenticBaseDir as rt, releaseCi as s, GitClient as st, commands_exports as t, verifyStagedTypecheck as tt, releaseStable as u, init as v, collectEnvPaths as w, normalizeInitToolingTargets as x, initMetadata as y, escapeStringRegexp as z };
|