@icebreakers/monorepo 5.5.9 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +35 -34
- package/dist/{commands-BCix_gOD.mjs → commands-D4xZQ5t-.mjs} +425 -120
- package/dist/{create-flow-ghL18gPo.mjs → create-flow-CXRhfGbb.mjs} +16 -19
- package/dist/{index-DDQKKYet.d.mts → index-Bl_PB2Ch.d.mts} +54 -40
- package/dist/index.d.mts +18 -12
- package/dist/index.mjs +4 -3
- package/dist/tooling-entry.d.mts +1 -1
- package/dist/tooling-entry.mjs +2 -1
- package/dist/tsconfig-BrjI_5yI.mjs +75 -0
- package/dist/{types-W9fwiyx8.mjs → types-MAUIQpfp.mjs} +2 -2
- package/dist/{tooling-BfXlmCi-.mjs → vitest-Blzbh8xZ.mjs} +108 -167
- package/package.json +5 -5
- package/resources/skills/repoctl/SKILL.md +2 -2
- package/resources/skills/repoctl/references/templates.md +3 -2
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.mjs";
|
|
2
2
|
import { i as getWorkspacePackages, n as getWorkspaceData, r as getWorkspacePackageSummaries, t as clearWorkspaceCache } from "./workspace-MCKewElu.mjs";
|
|
3
|
-
import { b as isIgnorableFsError, c as package_default$1, f as resolveRepoctlLocale, i as packageDir, l as version$1, m as logger, n as assetsDir, o as templatesDir, t as initToolingTargets, u as localize, y as fs$1 } from "./types-
|
|
3
|
+
import { b as isIgnorableFsError, c as package_default$1, f as resolveRepoctlLocale, i as packageDir, l as version$1, m as logger, n as assetsDir, o as templatesDir, t as initToolingTargets, u as localize, y as fs$1 } from "./types-MAUIQpfp.mjs";
|
|
4
4
|
import { a as loadMonorepoConfig, c as resolveToolingConfig, i as getRepoctlConfigCandidates, o as loadMonorepoConfigDetails, s as resolveCommandConfig } from "./config-p842Knhq.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { n as defineTsconfigConfig } from "./tsconfig-BrjI_5yI.mjs";
|
|
6
6
|
import gitUrlParse from "git-url-parse";
|
|
7
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 { access, readFile, readdir, realpath, rename, rm, writeFile } from "node:fs/promises";
|
|
11
|
+
import { access, copyFile, mkdtemp, readFile, readdir, realpath, rename, rm, writeFile } 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";
|
|
@@ -16,9 +16,9 @@ import { checkbox, ensureTemplateAssetsPrepared, getAssetTargets, getTemplateCho
|
|
|
16
16
|
import YAML, { isSeq, parseDocument } from "yaml";
|
|
17
17
|
import { Buffer } from "node:buffer";
|
|
18
18
|
import crypto, { createHash, randomUUID } from "node:crypto";
|
|
19
|
-
import os from "node:os";
|
|
19
|
+
import os, { tmpdir } from "node:os";
|
|
20
20
|
import pc from "picocolors";
|
|
21
|
-
import { coerce, gte, minVersion, satisfies } from "semver";
|
|
21
|
+
import semver, { coerce, gte, minVersion, satisfies } from "semver";
|
|
22
22
|
import { parse, stringify } from "comment-json";
|
|
23
23
|
import { stripVTControlCharacters } from "node:util";
|
|
24
24
|
import { performance } from "node:perf_hooks";
|
|
@@ -161,18 +161,85 @@ async function generateAgenticTemplates(tasks, defaults = {}) {
|
|
|
161
161
|
return results;
|
|
162
162
|
}
|
|
163
163
|
//#endregion
|
|
164
|
-
//#region src/commands/verify/
|
|
165
|
-
|
|
164
|
+
//#region src/commands/verify/run.ts
|
|
165
|
+
function runPnpmCommand(cwd, label, args, spawn) {
|
|
166
|
+
process.stdout.write(`${label}\n`);
|
|
167
|
+
const result = spawn("pnpm", args, {
|
|
168
|
+
cwd,
|
|
169
|
+
stdio: "inherit"
|
|
170
|
+
});
|
|
171
|
+
if (result.status !== 0) process.exit(result.status ?? 1);
|
|
172
|
+
}
|
|
173
|
+
//#endregion
|
|
174
|
+
//#region src/commands/verify/staged.ts
|
|
175
|
+
const gitDirName = ".git";
|
|
166
176
|
const typecheckExtensions = /* @__PURE__ */ new Set([
|
|
167
177
|
".ts",
|
|
168
178
|
".tsx",
|
|
169
179
|
".mts",
|
|
170
180
|
".cts",
|
|
171
|
-
".vue"
|
|
181
|
+
".vue",
|
|
182
|
+
".astro",
|
|
183
|
+
".mdx"
|
|
172
184
|
]);
|
|
173
185
|
const typecheckBasenames = /* @__PURE__ */ new Set(["package.json"]);
|
|
186
|
+
function hasTypecheckScript(dir) {
|
|
187
|
+
const packageJsonPath = path$1.join(dir, "package.json");
|
|
188
|
+
if (!fs.existsSync(packageJsonPath)) return false;
|
|
189
|
+
try {
|
|
190
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
191
|
+
return typeof packageJson.scripts?.typecheck === "string" && packageJson.scripts.typecheck.length > 0;
|
|
192
|
+
} catch {
|
|
193
|
+
return false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
function findRepositoryRoot(startDir) {
|
|
197
|
+
let current = path$1.resolve(startDir);
|
|
198
|
+
while (true) {
|
|
199
|
+
if (fs.existsSync(path$1.join(current, gitDirName))) return current;
|
|
200
|
+
const next = path$1.dirname(current);
|
|
201
|
+
if (next === current) return path$1.resolve(startDir);
|
|
202
|
+
current = next;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function resolveTypecheckWorkspaceDir(filePath, cwd) {
|
|
206
|
+
const workspaceRoot = findRepositoryRoot(cwd);
|
|
207
|
+
let current = path$1.dirname(path$1.resolve(cwd, filePath));
|
|
208
|
+
while (current.startsWith(workspaceRoot)) {
|
|
209
|
+
if (current !== cwd && hasTypecheckScript(current)) return current;
|
|
210
|
+
const next = path$1.dirname(current);
|
|
211
|
+
if (next === current) break;
|
|
212
|
+
current = next;
|
|
213
|
+
}
|
|
214
|
+
return workspaceRoot;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* 对暂存区中涉及类型检查的文件,按最近的 workspace 归属执行 `typecheck`。
|
|
218
|
+
*
|
|
219
|
+
* 当前识别的扩展名:`.ts`、`.tsx`、`.mts`、`.cts`、`.vue`、`.astro`、`.mdx`。
|
|
220
|
+
*
|
|
221
|
+
* @param stagedFiles 暂存区文件路径列表
|
|
222
|
+
* @param options 运行参数
|
|
223
|
+
*/
|
|
224
|
+
function verifyStagedTypecheck(stagedFiles, options = {}) {
|
|
225
|
+
const cwd = options.cwd ?? process.cwd();
|
|
226
|
+
const spawn = options.spawn ?? spawnSync;
|
|
227
|
+
let workspaceDirs = [...new Set(stagedFiles.filter((file) => {
|
|
228
|
+
const basename = path$1.basename(file);
|
|
229
|
+
return typecheckExtensions.has(path$1.extname(file)) || typecheckBasenames.has(basename);
|
|
230
|
+
}).map((file) => resolveTypecheckWorkspaceDir(file, cwd)))];
|
|
231
|
+
if (workspaceDirs.length === 0) return;
|
|
232
|
+
if (workspaceDirs.includes(cwd)) workspaceDirs = [cwd];
|
|
233
|
+
for (const workspaceDir of workspaceDirs) runPnpmCommand(cwd, `[lint-staged:typecheck] ${path$1.relative(cwd, workspaceDir) || "."}`, [
|
|
234
|
+
"--dir",
|
|
235
|
+
workspaceDir,
|
|
236
|
+
"typecheck"
|
|
237
|
+
], spawn);
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/commands/verify/index.ts
|
|
241
|
+
const zeroSha = "0".repeat(40);
|
|
174
242
|
const whitespacePattern = /\s+/;
|
|
175
|
-
const gitDirName = ".git";
|
|
176
243
|
const defaultWorkspaceOrder = [
|
|
177
244
|
"packages/create-icebreaker",
|
|
178
245
|
"packages/create-repoctl",
|
|
@@ -184,6 +251,7 @@ const defaultWorkspaceOrder = [
|
|
|
184
251
|
"templates/server",
|
|
185
252
|
"templates/tsdown",
|
|
186
253
|
"templates/vitepress",
|
|
254
|
+
"templates/nimbus",
|
|
187
255
|
"templates/vue-lib"
|
|
188
256
|
].sort((left, right) => right.length - left.length);
|
|
189
257
|
function getPackageScripts(dir, cwd) {
|
|
@@ -252,14 +320,6 @@ function getChangedFilesForNewRemote(head, cwd, execFile) {
|
|
|
252
320
|
encoding: "utf8"
|
|
253
321
|
}).split("\n").filter(Boolean);
|
|
254
322
|
}
|
|
255
|
-
function runPnpmCommand(cwd, label, args, spawn) {
|
|
256
|
-
process.stdout.write(`${label}\n`);
|
|
257
|
-
const result = spawn("pnpm", args, {
|
|
258
|
-
cwd,
|
|
259
|
-
stdio: "inherit"
|
|
260
|
-
});
|
|
261
|
-
if (result.status !== 0) process.exit(result.status ?? 1);
|
|
262
|
-
}
|
|
263
323
|
function runShellCommand(cwd, label, command, spawn) {
|
|
264
324
|
process.stdout.write(`${label}\n`);
|
|
265
325
|
const result = spawn("sh", ["-lc", command], {
|
|
@@ -279,36 +339,6 @@ async function readHookStdin() {
|
|
|
279
339
|
}
|
|
280
340
|
return output.trim();
|
|
281
341
|
}
|
|
282
|
-
function hasTypecheckScript(dir) {
|
|
283
|
-
const packageJsonPath = path$1.join(dir, "package.json");
|
|
284
|
-
if (!fs.existsSync(packageJsonPath)) return false;
|
|
285
|
-
try {
|
|
286
|
-
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
|
|
287
|
-
return typeof packageJson.scripts?.typecheck === "string" && packageJson.scripts.typecheck.length > 0;
|
|
288
|
-
} catch {
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
function findRepositoryRoot(startDir) {
|
|
293
|
-
let current = path$1.resolve(startDir);
|
|
294
|
-
while (true) {
|
|
295
|
-
if (fs.existsSync(path$1.join(current, gitDirName))) return current;
|
|
296
|
-
const next = path$1.dirname(current);
|
|
297
|
-
if (next === current) return path$1.resolve(startDir);
|
|
298
|
-
current = next;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function resolveTypecheckWorkspaceDir(filePath, cwd) {
|
|
302
|
-
const workspaceRoot = findRepositoryRoot(cwd);
|
|
303
|
-
let current = path$1.dirname(path$1.resolve(cwd, filePath));
|
|
304
|
-
while (current.startsWith(workspaceRoot)) {
|
|
305
|
-
if (current !== cwd && hasTypecheckScript(current)) return current;
|
|
306
|
-
const next = path$1.dirname(current);
|
|
307
|
-
if (next === current) break;
|
|
308
|
-
current = next;
|
|
309
|
-
}
|
|
310
|
-
return workspaceRoot;
|
|
311
|
-
}
|
|
312
342
|
/**
|
|
313
343
|
* 执行 pre-push 校验。
|
|
314
344
|
*
|
|
@@ -375,29 +405,6 @@ async function verifyPrePush(options = {}) {
|
|
|
375
405
|
}
|
|
376
406
|
}
|
|
377
407
|
/**
|
|
378
|
-
* 对暂存区中涉及类型检查的文件,按最近的 workspace 归属执行 `typecheck`。
|
|
379
|
-
*
|
|
380
|
-
* 当前识别的扩展名:`.ts`、`.tsx`、`.mts`、`.cts`、`.vue`。
|
|
381
|
-
*
|
|
382
|
-
* @param stagedFiles 暂存区文件路径列表
|
|
383
|
-
* @param options 运行参数
|
|
384
|
-
*/
|
|
385
|
-
function verifyStagedTypecheck(stagedFiles, options = {}) {
|
|
386
|
-
const cwd = options.cwd ?? process.cwd();
|
|
387
|
-
const spawn = options.spawn ?? spawnSync;
|
|
388
|
-
let workspaceDirs = [...new Set(stagedFiles.filter((file) => {
|
|
389
|
-
const basename = path$1.basename(file);
|
|
390
|
-
return typecheckExtensions.has(path$1.extname(file)) || typecheckBasenames.has(basename);
|
|
391
|
-
}).map((file) => resolveTypecheckWorkspaceDir(file, cwd)))];
|
|
392
|
-
if (workspaceDirs.length === 0) return;
|
|
393
|
-
if (workspaceDirs.includes(cwd)) workspaceDirs = [cwd];
|
|
394
|
-
for (const workspaceDir of workspaceDirs) runPnpmCommand(cwd, `[lint-staged:typecheck] ${path$1.relative(cwd, workspaceDir) || "."}`, [
|
|
395
|
-
"--dir",
|
|
396
|
-
workspaceDir,
|
|
397
|
-
"typecheck"
|
|
398
|
-
], spawn);
|
|
399
|
-
}
|
|
400
|
-
/**
|
|
401
408
|
* 执行 commit-msg 校验。
|
|
402
409
|
*
|
|
403
410
|
* 优先读取 `tooling.husky.commitMsgCommand`;若未配置,则回退到
|
|
@@ -1040,6 +1047,10 @@ const templateMap = {
|
|
|
1040
1047
|
"cli": {
|
|
1041
1048
|
source: "cli",
|
|
1042
1049
|
target: "apps/cli"
|
|
1050
|
+
},
|
|
1051
|
+
"nimbus": {
|
|
1052
|
+
source: "nimbus",
|
|
1053
|
+
target: "apps/docs"
|
|
1043
1054
|
}
|
|
1044
1055
|
};
|
|
1045
1056
|
/**
|
|
@@ -1924,7 +1935,8 @@ var package_default = {
|
|
|
1924
1935
|
"pr:rc": "repo release pre enter rc",
|
|
1925
1936
|
"pr:next": "repo release pre enter next",
|
|
1926
1937
|
"pr:exit": "repo release pre exit",
|
|
1927
|
-
"--------": "----------------"
|
|
1938
|
+
"--------": "----------------",
|
|
1939
|
+
"test:packaged-nimbus": "node scripts/nimbus/index.mjs"
|
|
1928
1940
|
},
|
|
1929
1941
|
devDependencies: {
|
|
1930
1942
|
"@commitlint/cli": "^21.2.3",
|
|
@@ -1934,12 +1946,13 @@ var package_default = {
|
|
|
1934
1946
|
"@icebreakers/monorepo": "workspace:*",
|
|
1935
1947
|
"@icebreakers/stylelint-config": "workspace:*",
|
|
1936
1948
|
"@types/node": "^26.6.3",
|
|
1937
|
-
"@vitest/coverage-v8": "~5.0.
|
|
1949
|
+
"@vitest/coverage-v8": "~5.0.3",
|
|
1938
1950
|
"eslint": "^10.11.0",
|
|
1939
1951
|
"execa": "^10.0.1",
|
|
1940
1952
|
"husky": "^9.1.7",
|
|
1941
1953
|
"lint-staged": "^17.6.0",
|
|
1942
1954
|
"only-allow": "^1.2.2",
|
|
1955
|
+
"playwright": "^1.63.0",
|
|
1943
1956
|
"repoctl": "workspace:*",
|
|
1944
1957
|
"stylelint": "^17.15.0",
|
|
1945
1958
|
"tailwindcss": "^4.3.3",
|
|
@@ -1947,7 +1960,7 @@ var package_default = {
|
|
|
1947
1960
|
"tsdown": "0.23.0",
|
|
1948
1961
|
"turbo": "^2.11.5",
|
|
1949
1962
|
"typescript": "^6.0.3",
|
|
1950
|
-
"vitest": "~5.0.
|
|
1963
|
+
"vitest": "~5.0.3",
|
|
1951
1964
|
"yaml": "^2.9.1"
|
|
1952
1965
|
},
|
|
1953
1966
|
publishConfig: {
|
|
@@ -2663,6 +2676,79 @@ var ReleaseCommandError = class extends Error {
|
|
|
2663
2676
|
}
|
|
2664
2677
|
};
|
|
2665
2678
|
//#endregion
|
|
2679
|
+
//#region src/commands/release/intents/index.ts
|
|
2680
|
+
function parseLedger(content) {
|
|
2681
|
+
const ledger = YAML.parse(content) ?? {};
|
|
2682
|
+
if (!ledger || typeof ledger !== "object" || Array.isArray(ledger)) throw new ReleaseCommandError("Invalid .changeset/ledger.yaml");
|
|
2683
|
+
return Object.fromEntries(Object.entries(ledger).map(([key, value]) => {
|
|
2684
|
+
const entry = value;
|
|
2685
|
+
const intents = Array.isArray(value) ? value : entry?.intents ?? [];
|
|
2686
|
+
if (value != null && !Array.isArray(value) && (typeof value !== "object" || typeof entry?.dir !== "string") || !Array.isArray(intents) || intents.some((id) => typeof id !== "string")) throw new ReleaseCommandError(`Invalid ledger entry: ${key}`);
|
|
2687
|
+
return [key, {
|
|
2688
|
+
...typeof entry?.dir === "string" ? { dir: entry.dir } : {},
|
|
2689
|
+
intents
|
|
2690
|
+
}];
|
|
2691
|
+
}));
|
|
2692
|
+
}
|
|
2693
|
+
async function readLedger(cwd) {
|
|
2694
|
+
try {
|
|
2695
|
+
return parseLedger(await readFile(path.join(cwd, ".changeset/ledger.yaml"), "utf8"));
|
|
2696
|
+
} catch (error) {
|
|
2697
|
+
if (error.code === "ENOENT") return {};
|
|
2698
|
+
throw error;
|
|
2699
|
+
}
|
|
2700
|
+
}
|
|
2701
|
+
function parseIntent(content, filename) {
|
|
2702
|
+
const lines = content.replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
2703
|
+
const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
|
|
2704
|
+
if (lines[0]?.trim() !== "---" || end < 0) throw new ReleaseCommandError(`Invalid change intent frontmatter: ${filename}`);
|
|
2705
|
+
let data;
|
|
2706
|
+
try {
|
|
2707
|
+
data = YAML.parse(lines.slice(1, end).join("\n")) ?? {};
|
|
2708
|
+
} catch {
|
|
2709
|
+
throw new ReleaseCommandError(`Invalid change intent YAML: ${filename}`);
|
|
2710
|
+
}
|
|
2711
|
+
if (!data || typeof data !== "object" || Array.isArray(data) || Object.values(data).some((value) => ![
|
|
2712
|
+
"none",
|
|
2713
|
+
"patch",
|
|
2714
|
+
"minor",
|
|
2715
|
+
"major"
|
|
2716
|
+
].includes(String(value)))) throw new ReleaseCommandError(`Invalid change intent bump type: ${filename}`);
|
|
2717
|
+
return Object.entries(data);
|
|
2718
|
+
}
|
|
2719
|
+
/** Only unconsumed release requests count; declines and resurrected prose do not. */
|
|
2720
|
+
async function readPendingIntents(cwd) {
|
|
2721
|
+
let files;
|
|
2722
|
+
try {
|
|
2723
|
+
files = await readdir(path.join(cwd, ".changeset"), { withFileTypes: true });
|
|
2724
|
+
} catch (error) {
|
|
2725
|
+
if (error.code === "ENOENT") return [];
|
|
2726
|
+
throw error;
|
|
2727
|
+
}
|
|
2728
|
+
const root = await realpath(cwd);
|
|
2729
|
+
const ledger = await readLedger(cwd);
|
|
2730
|
+
const config = YAML.parse(await readFile(path.join(cwd, "pnpm-workspace.yaml"), "utf8"));
|
|
2731
|
+
const workspace = await getWorkspacePackages(cwd, { ignorePrivatePackage: false });
|
|
2732
|
+
const pending = [];
|
|
2733
|
+
for (const file of files.sort((a, b) => a.name.localeCompare(b.name))) {
|
|
2734
|
+
if (!file.isFile() || !file.name.endsWith(".md") || file.name.toLowerCase() === "readme.md") continue;
|
|
2735
|
+
const filename = `.changeset/${file.name}`;
|
|
2736
|
+
const releases = parseIntent(await readFile(path.join(cwd, filename), "utf8"), filename);
|
|
2737
|
+
let active = false;
|
|
2738
|
+
for (const [reference, bump] of releases) {
|
|
2739
|
+
if (bump === "none") continue;
|
|
2740
|
+
const pkg = workspace.find((item) => item.manifest.name === reference || path.relative(root, item.rootDir) === reference.replace(/^\.\//, ""));
|
|
2741
|
+
if (!pkg) throw new ReleaseCommandError(`Unknown package ${reference} in ${filename}`);
|
|
2742
|
+
const dir = path.relative(root, pkg.rootDir);
|
|
2743
|
+
const lane = config.versioning?.lanes?.[pkg.manifest.name ?? ""] ?? config.versioning?.lanes?.[dir];
|
|
2744
|
+
const consumed = Object.entries(ledger).some(([key, entry]) => (entry.dir ? entry.dir.replace(/^\.\//, "") === dir : key.slice(0, key.lastIndexOf("@")) === pkg.manifest.name) && entry.intents.includes(file.name.slice(0, -3)) && (lane && lane !== "main" || !semver.prerelease(key.slice(key.lastIndexOf("@") + 1))));
|
|
2745
|
+
active ||= !consumed;
|
|
2746
|
+
}
|
|
2747
|
+
if (active) pending.push(filename);
|
|
2748
|
+
}
|
|
2749
|
+
return pending;
|
|
2750
|
+
}
|
|
2751
|
+
//#endregion
|
|
2666
2752
|
//#region src/commands/release/shared.ts
|
|
2667
2753
|
function getReleaseEnv(options) {
|
|
2668
2754
|
return options.env ?? process.env;
|
|
@@ -2705,11 +2791,7 @@ function hasGitChanges(options) {
|
|
|
2705
2791
|
}).status !== 0;
|
|
2706
2792
|
}
|
|
2707
2793
|
async function hasPendingIntents(cwd) {
|
|
2708
|
-
|
|
2709
|
-
return (await readdir(path.join(cwd, ".changeset"), { withFileTypes: true })).some((entry) => entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md");
|
|
2710
|
-
} catch {
|
|
2711
|
-
return false;
|
|
2712
|
-
}
|
|
2794
|
+
return (await readPendingIntents(cwd)).length > 0;
|
|
2713
2795
|
}
|
|
2714
2796
|
function resolveBranch(options) {
|
|
2715
2797
|
return options.branch?.trim() || getReleaseEnv(options)["GITHUB_REF_NAME"]?.trim() || capture("git", [
|
|
@@ -3817,6 +3899,15 @@ async function findVersionCommit(pkg, options) {
|
|
|
3817
3899
|
return target;
|
|
3818
3900
|
}
|
|
3819
3901
|
//#endregion
|
|
3902
|
+
//#region src/commands/release/lifecycle/key.ts
|
|
3903
|
+
function releaseStateKey(repository, distTag, candidates) {
|
|
3904
|
+
return createHash("sha256").update(JSON.stringify({
|
|
3905
|
+
repository,
|
|
3906
|
+
distTag,
|
|
3907
|
+
packages: candidates.map(packageKey).sort()
|
|
3908
|
+
})).digest("hex");
|
|
3909
|
+
}
|
|
3910
|
+
//#endregion
|
|
3820
3911
|
//#region src/commands/release/lifecycle/registry.ts
|
|
3821
3912
|
/** 明确的 E404 才代表不存在;其余失败不能作为重新上传的依据。 */
|
|
3822
3913
|
async function inspectRegistry(pkg, options) {
|
|
@@ -3862,12 +3953,7 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
3862
3953
|
const repository = env["GITHUB_REPOSITORY"];
|
|
3863
3954
|
if (!repository || !/^[^/]+\/[^/]+$/.test(repository)) throw new ReleaseCommandError("GITHUB_REPOSITORY is required for durable release recovery");
|
|
3864
3955
|
const candidates = selected ?? await getPublishCandidates(options.cwd);
|
|
3865
|
-
const
|
|
3866
|
-
repository,
|
|
3867
|
-
distTag,
|
|
3868
|
-
packages: candidates.map(packageKey).sort()
|
|
3869
|
-
});
|
|
3870
|
-
const key = createHash("sha256").update(identity).digest("hex");
|
|
3956
|
+
const key = releaseStateKey(repository, distTag, candidates);
|
|
3871
3957
|
const snapshot = await github.readReleaseState(key);
|
|
3872
3958
|
let revision = snapshot?.revision;
|
|
3873
3959
|
const releases = new Map((await github.listReleases()).map((release) => [release.tag_name, release]));
|
|
@@ -4028,6 +4114,82 @@ async function publishLifecycle(options, selected, distTag = "latest") {
|
|
|
4028
4114
|
return packages;
|
|
4029
4115
|
}
|
|
4030
4116
|
//#endregion
|
|
4117
|
+
//#region src/commands/release/preparation/guard.ts
|
|
4118
|
+
/** A prepared version belongs to its original source, even before npm accepts it. */
|
|
4119
|
+
async function assertPreviousReleaseComplete(options, distTag = "latest") {
|
|
4120
|
+
const ledger = await readLedger(options.cwd);
|
|
4121
|
+
const candidates = await getPublishCandidates(options.cwd);
|
|
4122
|
+
const workspace = await getWorkspacePackages(options.cwd);
|
|
4123
|
+
const prepared = [];
|
|
4124
|
+
for (const pkg of candidates) {
|
|
4125
|
+
if (ledger[packageKey(pkg)]) {
|
|
4126
|
+
prepared.push(pkg);
|
|
4127
|
+
continue;
|
|
4128
|
+
}
|
|
4129
|
+
const directory = workspace.find((item) => item.manifest.name === pkg.name).rootDir;
|
|
4130
|
+
try {
|
|
4131
|
+
if (readVersionSection(await readFile(path.join(directory, "CHANGELOG.md"), "utf8"), pkg.version)?.previousVersion) prepared.push(pkg);
|
|
4132
|
+
} catch (error) {
|
|
4133
|
+
if (error.code !== "ENOENT") throw error;
|
|
4134
|
+
}
|
|
4135
|
+
}
|
|
4136
|
+
if (!prepared.length) return;
|
|
4137
|
+
const github = options.github;
|
|
4138
|
+
const releases = github?.listReleases ? await github.listReleases() : void 0;
|
|
4139
|
+
const repository = getReleaseEnv(options)["GITHUB_REPOSITORY"];
|
|
4140
|
+
const sources = /* @__PURE__ */ new Map();
|
|
4141
|
+
const cohorts = /* @__PURE__ */ new Map();
|
|
4142
|
+
for (const pkg of prepared) {
|
|
4143
|
+
const source = await findVersionCommit(pkg, options);
|
|
4144
|
+
sources.set(packageKey(pkg), source);
|
|
4145
|
+
cohorts.set(source, [...cohorts.get(source) ?? [], pkg]);
|
|
4146
|
+
}
|
|
4147
|
+
const unfinished = /* @__PURE__ */ new Set();
|
|
4148
|
+
if (repository && github?.readReleaseState) for (const group of [candidates, ...cohorts.values()]) {
|
|
4149
|
+
const key = releaseStateKey(repository, distTag, group);
|
|
4150
|
+
const checkpoint = await github.readReleaseState(key);
|
|
4151
|
+
if (checkpoint && (!checkpoint.state.complete || checkpoint.state.schemaVersion !== 1)) group.forEach((pkg) => unfinished.add(packageKey(pkg)));
|
|
4152
|
+
}
|
|
4153
|
+
const blocked = [];
|
|
4154
|
+
for (const pkg of prepared) {
|
|
4155
|
+
const published = await inspectRegistry(pkg, options);
|
|
4156
|
+
const release = releases?.find((item) => item.tag_name === packageKey(pkg));
|
|
4157
|
+
const tag = github?.readTagTarget ? await github.readTagTarget(packageKey(pkg)) : void 0;
|
|
4158
|
+
if (!published || unfinished.has(packageKey(pkg)) || releases && (!release || release.draft || Boolean(release.prerelease) !== (distTag !== "latest")) || github?.readTagTarget && (!tag || published.gitHead && tag !== published.gitHead)) {
|
|
4159
|
+
const source = sources.get(packageKey(pkg));
|
|
4160
|
+
const recovery = distTag === "latest" ? `repo release ci --mode publish --source-sha ${source}` : `check out ${source} on ${distTag} and run repo release ci`;
|
|
4161
|
+
blocked.push(`${packageKey(pkg)} (source ${source}); recover with ${recovery}`);
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
if (blocked.length) throw new ReleaseCommandError(`Prepared releases must finish before consuming new intents:\n${blocked.join("\n")}`);
|
|
4165
|
+
}
|
|
4166
|
+
//#endregion
|
|
4167
|
+
//#region src/commands/release/preparation/result.ts
|
|
4168
|
+
async function applyVersions(options) {
|
|
4169
|
+
const before = await readWorkspaceVersions(options.cwd);
|
|
4170
|
+
const output = capture("pnpm", [
|
|
4171
|
+
"version",
|
|
4172
|
+
"-r",
|
|
4173
|
+
"--no-git-checks",
|
|
4174
|
+
"--json"
|
|
4175
|
+
], options);
|
|
4176
|
+
let data;
|
|
4177
|
+
try {
|
|
4178
|
+
data = JSON.parse(output);
|
|
4179
|
+
} catch {
|
|
4180
|
+
throw new ReleaseCommandError("pnpm version returned invalid JSON; no release PR will be pushed");
|
|
4181
|
+
}
|
|
4182
|
+
if (!Array.isArray(data)) throw new ReleaseCommandError("pnpm version must return an applied release array");
|
|
4183
|
+
const after = await readWorkspaceVersions(options.cwd);
|
|
4184
|
+
const names = /* @__PURE__ */ new Set();
|
|
4185
|
+
for (const item of data) {
|
|
4186
|
+
if (!item || typeof item.name !== "string" || names.has(item.name) || typeof item.currentVersion !== "string" || !semver.valid(item.currentVersion) || typeof item.newVersion !== "string" || !semver.valid(item.newVersion) || before.get(item.name) !== item.currentVersion || after.get(item.name) !== item.newVersion) throw new ReleaseCommandError("pnpm version result does not match workspace manifests");
|
|
4187
|
+
names.add(item.name);
|
|
4188
|
+
}
|
|
4189
|
+
for (const [name, version] of after) if (before.get(name) !== version && !names.has(name)) throw new ReleaseCommandError(`pnpm version omitted changed package ${name}`);
|
|
4190
|
+
return data;
|
|
4191
|
+
}
|
|
4192
|
+
//#endregion
|
|
4031
4193
|
//#region src/commands/release/types.ts
|
|
4032
4194
|
const prereleaseBranches$1 = /* @__PURE__ */ new Set([
|
|
4033
4195
|
"alpha",
|
|
@@ -4045,15 +4207,13 @@ async function releasePrerelease(options, publish) {
|
|
|
4045
4207
|
if (publish) await runQualityScripts(options);
|
|
4046
4208
|
return publish?.();
|
|
4047
4209
|
}
|
|
4210
|
+
await assertPreviousReleaseComplete(options, branch);
|
|
4048
4211
|
runReleaseHooks("beforeVersion", options);
|
|
4049
4212
|
await runQualityScripts(options);
|
|
4050
|
-
|
|
4051
|
-
"version",
|
|
4052
|
-
"-r",
|
|
4053
|
-
"--no-git-checks"
|
|
4054
|
-
], options);
|
|
4213
|
+
const releases = await applyVersions(options);
|
|
4055
4214
|
runReleaseHooks("afterVersion", options);
|
|
4056
|
-
if (!
|
|
4215
|
+
if (!releases.length) return;
|
|
4216
|
+
if (!hasGitChanges(options)) throw new ReleaseCommandError("pnpm reported releases without file changes");
|
|
4057
4217
|
run("git", ["add", "-A"], options);
|
|
4058
4218
|
run("git", [
|
|
4059
4219
|
"commit",
|
|
@@ -4179,21 +4339,152 @@ async function reconcileRelease(options) {
|
|
|
4179
4339
|
};
|
|
4180
4340
|
}
|
|
4181
4341
|
//#endregion
|
|
4342
|
+
//#region src/commands/release/recovery/candidates.ts
|
|
4343
|
+
/** Dependency propagation can change manifests without adding ledger entries. */
|
|
4344
|
+
async function readSourceCandidates(options, source) {
|
|
4345
|
+
const ledger = await readLedger(options.cwd);
|
|
4346
|
+
const previous = capture("git", [
|
|
4347
|
+
"ls-tree",
|
|
4348
|
+
`${source}^`,
|
|
4349
|
+
"--",
|
|
4350
|
+
".changeset/ledger.yaml"
|
|
4351
|
+
], options) ? parseLedger(capture("git", ["show", `${source}^:.changeset/ledger.yaml`], options)) : {};
|
|
4352
|
+
const root = await realpath(options.cwd);
|
|
4353
|
+
const candidates = [];
|
|
4354
|
+
for (const pkg of await getWorkspacePackages(options.cwd)) {
|
|
4355
|
+
const { name, version } = pkg.manifest;
|
|
4356
|
+
if (!name || !version) continue;
|
|
4357
|
+
const file = path.relative(root, pkg.pkgJsonPath);
|
|
4358
|
+
const before = capture("git", [
|
|
4359
|
+
"ls-tree",
|
|
4360
|
+
`${source}^`,
|
|
4361
|
+
"--",
|
|
4362
|
+
file
|
|
4363
|
+
], options) ? JSON.parse(capture("git", ["show", `${source}^:${file}`], options)) : void 0;
|
|
4364
|
+
const key = `${name}@${version}`;
|
|
4365
|
+
if (before?.name !== name || before.version !== version || ledger[key] && !previous[key]) candidates.push({
|
|
4366
|
+
name,
|
|
4367
|
+
version
|
|
4368
|
+
});
|
|
4369
|
+
}
|
|
4370
|
+
return candidates;
|
|
4371
|
+
}
|
|
4372
|
+
//#endregion
|
|
4373
|
+
//#region src/commands/release/recovery/source.ts
|
|
4374
|
+
/** Run current tooling against the original source, never today's package contents. */
|
|
4375
|
+
async function recoverSource(options, source) {
|
|
4376
|
+
if (!/^[a-f0-9]{40}$/.test(source)) throw new ReleaseCommandError("source-sha must be a full lowercase commit SHA");
|
|
4377
|
+
const mode = options.mode ?? getReleaseEnv(options)["REPO_RELEASE_MODE"] ?? "auto";
|
|
4378
|
+
if (!["publish", "publish-unpublished"].includes(mode)) throw new ReleaseCommandError("source-sha requires publish or publish-unpublished mode");
|
|
4379
|
+
if (capture("git", ["rev-parse", "--is-shallow-repository"], options) !== "false") throw new ReleaseCommandError("Source recovery requires full Git history");
|
|
4380
|
+
run("git", [
|
|
4381
|
+
"merge-base",
|
|
4382
|
+
"--is-ancestor",
|
|
4383
|
+
source,
|
|
4384
|
+
"origin/main"
|
|
4385
|
+
], options);
|
|
4386
|
+
const origin = capture("git", [
|
|
4387
|
+
"remote",
|
|
4388
|
+
"get-url",
|
|
4389
|
+
"origin"
|
|
4390
|
+
], options);
|
|
4391
|
+
const root = await mkdtemp(path.join(tmpdir(), "repoctl-release-source-"));
|
|
4392
|
+
const cwd = path.join(root, "source");
|
|
4393
|
+
try {
|
|
4394
|
+
run("git", [
|
|
4395
|
+
"clone",
|
|
4396
|
+
"--shared",
|
|
4397
|
+
"--no-checkout",
|
|
4398
|
+
options.cwd,
|
|
4399
|
+
cwd
|
|
4400
|
+
], options);
|
|
4401
|
+
const env = {
|
|
4402
|
+
...getReleaseEnv(options),
|
|
4403
|
+
REPO_RELEASE_SOURCE_SHA: source
|
|
4404
|
+
};
|
|
4405
|
+
let recovery = {
|
|
4406
|
+
...options,
|
|
4407
|
+
cwd,
|
|
4408
|
+
branch: "main",
|
|
4409
|
+
env
|
|
4410
|
+
};
|
|
4411
|
+
run("git", [
|
|
4412
|
+
"remote",
|
|
4413
|
+
"set-url",
|
|
4414
|
+
"origin",
|
|
4415
|
+
origin
|
|
4416
|
+
], recovery);
|
|
4417
|
+
run("git", [
|
|
4418
|
+
"checkout",
|
|
4419
|
+
"--detach",
|
|
4420
|
+
source
|
|
4421
|
+
], recovery);
|
|
4422
|
+
clearWorkspaceCache();
|
|
4423
|
+
const workspaceCandidates = await getPublishCandidates(cwd);
|
|
4424
|
+
const candidates = await readSourceCandidates(recovery, source);
|
|
4425
|
+
if (!candidates.length) throw new ReleaseCommandError("Source commit introduces no prepared release versions");
|
|
4426
|
+
const name = options.packageName ?? env["REPO_RELEASE_PACKAGE"];
|
|
4427
|
+
const version = options.packageVersion ?? env["REPO_RELEASE_VERSION"];
|
|
4428
|
+
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");
|
|
4429
|
+
if (await hasPendingIntents(cwd)) throw new ReleaseCommandError("Source contains unconsumed release requests; select the merged version commit");
|
|
4430
|
+
const github = resolveGitHub(options);
|
|
4431
|
+
let selected = candidates;
|
|
4432
|
+
const repository = env["GITHUB_REPOSITORY"];
|
|
4433
|
+
if (repository && github.readReleaseState) {
|
|
4434
|
+
const checkpoint = await github.readReleaseState(releaseStateKey(repository, "latest", workspaceCandidates));
|
|
4435
|
+
if (checkpoint) {
|
|
4436
|
+
if (checkpoint.state.packages.some((pkg) => pkg.target !== source || !candidates.some((item) => packageKey(item) === packageKey(pkg)))) throw new ReleaseCommandError("Existing checkpoint includes a different source release; recover its original candidate set");
|
|
4437
|
+
selected = workspaceCandidates;
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
if (!(options.dryRun ?? env["REPO_RELEASE_DRY_RUN"] === "true")) {
|
|
4441
|
+
run("pnpm", ["install", "--frozen-lockfile"], recovery);
|
|
4442
|
+
const config = await resolveCommandConfig("release", cwd);
|
|
4443
|
+
recovery = {
|
|
4444
|
+
...recovery,
|
|
4445
|
+
config: config ?? {}
|
|
4446
|
+
};
|
|
4447
|
+
await runQualityScripts(recovery);
|
|
4448
|
+
} else recovery = {
|
|
4449
|
+
...recovery,
|
|
4450
|
+
dryRun: true
|
|
4451
|
+
};
|
|
4452
|
+
return await publishLifecycle({
|
|
4453
|
+
...recovery,
|
|
4454
|
+
github
|
|
4455
|
+
}, selected);
|
|
4456
|
+
} finally {
|
|
4457
|
+
for (const file of [
|
|
4458
|
+
"repoctl-publish-progress.json",
|
|
4459
|
+
"repoctl-release-progress.json",
|
|
4460
|
+
"pnpm-publish-summary.json"
|
|
4461
|
+
]) await copyFile(path.join(cwd, file), path.join(options.cwd, file)).catch((error) => {
|
|
4462
|
+
if (error.code !== "ENOENT") throw error;
|
|
4463
|
+
});
|
|
4464
|
+
clearWorkspaceCache();
|
|
4465
|
+
await rm(root, {
|
|
4466
|
+
recursive: true,
|
|
4467
|
+
force: true
|
|
4468
|
+
});
|
|
4469
|
+
}
|
|
4470
|
+
}
|
|
4471
|
+
//#endregion
|
|
4182
4472
|
//#region src/commands/release/stable.ts
|
|
4183
|
-
async function
|
|
4473
|
+
async function prepareStableReleases(options) {
|
|
4184
4474
|
const branch = resolveBranch(options);
|
|
4185
4475
|
if (branch !== "main") throw new ReleaseCommandError(`repo release stable prepare is only allowed on main, got ${branch}`);
|
|
4186
4476
|
await assertStableLaneAssignments(options);
|
|
4187
|
-
if (!await hasPendingIntents(options.cwd)) return
|
|
4477
|
+
if (!await hasPendingIntents(options.cwd)) return [];
|
|
4478
|
+
await assertPreviousReleaseComplete(options);
|
|
4188
4479
|
runReleaseHooks("beforeVersion", options);
|
|
4189
4480
|
await runQualityScripts(options);
|
|
4190
|
-
|
|
4191
|
-
"version",
|
|
4192
|
-
"-r",
|
|
4193
|
-
"--no-git-checks"
|
|
4194
|
-
], options);
|
|
4481
|
+
const releases = await applyVersions(options);
|
|
4195
4482
|
runReleaseHooks("afterVersion", options);
|
|
4196
|
-
|
|
4483
|
+
if (releases.length && !hasGitChanges(options)) throw new ReleaseCommandError("pnpm reported releases without file changes");
|
|
4484
|
+
return releases;
|
|
4485
|
+
}
|
|
4486
|
+
async function prepareStable(options) {
|
|
4487
|
+
return (await prepareStableReleases(options)).length > 0;
|
|
4197
4488
|
}
|
|
4198
4489
|
async function assertStablePublish(options, quality = true) {
|
|
4199
4490
|
const branch = resolveBranch(options);
|
|
@@ -4269,13 +4560,6 @@ function shouldRunRelease(context) {
|
|
|
4269
4560
|
if (prereleaseBranches.has(context.branch)) return false;
|
|
4270
4561
|
return isReleaseCommitMessage(context.commitMessage) || hasReleaseArtifactPair(context.changedFiles);
|
|
4271
4562
|
}
|
|
4272
|
-
async function readPendingChangesetFiles(cwd) {
|
|
4273
|
-
try {
|
|
4274
|
-
return (await readdir(path.join(cwd, ".changeset"), { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(".md") && entry.name !== "README.md").map((entry) => `.changeset/${entry.name}`);
|
|
4275
|
-
} catch {
|
|
4276
|
-
return [];
|
|
4277
|
-
}
|
|
4278
|
-
}
|
|
4279
4563
|
function readGitOutput(options, args) {
|
|
4280
4564
|
try {
|
|
4281
4565
|
return capture("git", args, options);
|
|
@@ -4311,7 +4595,7 @@ async function readReleaseTriggerContext(options) {
|
|
|
4311
4595
|
return {
|
|
4312
4596
|
eventName,
|
|
4313
4597
|
branch,
|
|
4314
|
-
pendingChangesetFiles: await
|
|
4598
|
+
pendingChangesetFiles: await readPendingIntents(options.cwd),
|
|
4315
4599
|
changedFiles: await readChangedFiles(options),
|
|
4316
4600
|
commitMessage: readGitOutput(options, [
|
|
4317
4601
|
"log",
|
|
@@ -4327,9 +4611,32 @@ const releaseBranch = "release/pnpm-version";
|
|
|
4327
4611
|
async function createReleasePullRequest(options) {
|
|
4328
4612
|
const branch = resolveBranch(options);
|
|
4329
4613
|
if (branch !== "main") throw new ReleaseCommandError(`repo release stable prepare is only allowed on main, got ${branch}`);
|
|
4330
|
-
const previousVersions = await readWorkspaceVersions(options.cwd);
|
|
4331
4614
|
const sourceCommits = await readPendingIntentCommits(options);
|
|
4332
|
-
|
|
4615
|
+
const github = resolveGitHub(options);
|
|
4616
|
+
const releases = await prepareStableReleases({
|
|
4617
|
+
...options,
|
|
4618
|
+
github
|
|
4619
|
+
});
|
|
4620
|
+
if (!releases.length) return false;
|
|
4621
|
+
const releaseEnv = getReleaseEnv(options);
|
|
4622
|
+
const metadata = {
|
|
4623
|
+
locale: resolveReleaseLocale(options),
|
|
4624
|
+
commits: sourceCommits,
|
|
4625
|
+
...releaseEnv["GITHUB_REPOSITORY"] ? { repository: releaseEnv["GITHUB_REPOSITORY"] } : {},
|
|
4626
|
+
...releaseEnv["GITHUB_SERVER_URL"] ? { serverUrl: releaseEnv["GITHUB_SERVER_URL"] } : {}
|
|
4627
|
+
};
|
|
4628
|
+
const names = new Set(releases.map((release) => release.name));
|
|
4629
|
+
const previousVersions = new Map(releases.filter((release) => release.currentVersion !== release.newVersion).map((release) => [release.name, release.currentVersion]));
|
|
4630
|
+
let noteDocument = await buildReleaseNoteDocument(options.cwd, previousVersions, metadata, names);
|
|
4631
|
+
for (const release of releases) {
|
|
4632
|
+
const pkg = noteDocument.packages.find((pkg) => pkg.name === release.name && pkg.version === release.newVersion);
|
|
4633
|
+
if (!pkg || !noteDocument.entries.some((entry) => entry.packageName === pkg.name)) throw new ReleaseCommandError(`Missing release notes for ${release.name}@${release.newVersion}; no PR pushed`);
|
|
4634
|
+
if (release.currentVersion === release.newVersion) {
|
|
4635
|
+
delete pkg.previousVersion;
|
|
4636
|
+
delete pkg.previousNpmUrl;
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
if (github.enrichReleaseNote) noteDocument = await github.enrichReleaseNote(noteDocument);
|
|
4333
4640
|
run("git", [
|
|
4334
4641
|
"config",
|
|
4335
4642
|
"user.name",
|
|
@@ -4357,16 +4664,6 @@ async function createReleasePullRequest(options) {
|
|
|
4357
4664
|
"origin",
|
|
4358
4665
|
`HEAD:${releaseBranch}`
|
|
4359
4666
|
], options);
|
|
4360
|
-
const github = resolveGitHub(options);
|
|
4361
|
-
const releaseEnv = getReleaseEnv(options);
|
|
4362
|
-
const metadata = {
|
|
4363
|
-
locale: resolveReleaseLocale(options),
|
|
4364
|
-
commits: sourceCommits,
|
|
4365
|
-
...releaseEnv["GITHUB_REPOSITORY"] ? { repository: releaseEnv["GITHUB_REPOSITORY"] } : {},
|
|
4366
|
-
...releaseEnv["GITHUB_SERVER_URL"] ? { serverUrl: releaseEnv["GITHUB_SERVER_URL"] } : {}
|
|
4367
|
-
};
|
|
4368
|
-
let noteDocument = await buildReleaseNoteDocument(options.cwd, previousVersions, metadata);
|
|
4369
|
-
if (github.enrichReleaseNote) noteDocument = await github.enrichReleaseNote(noteDocument);
|
|
4370
4667
|
await github.ensurePullRequest({
|
|
4371
4668
|
head: releaseBranch,
|
|
4372
4669
|
base: "main",
|
|
@@ -4422,7 +4719,7 @@ async function recoverUnpublished(options) {
|
|
|
4422
4719
|
return packages;
|
|
4423
4720
|
}
|
|
4424
4721
|
function resolveMode(options) {
|
|
4425
|
-
const requested = options.mode
|
|
4722
|
+
const requested = options.mode && options.mode !== "auto" ? options.mode : getReleaseEnv(options)["REPO_RELEASE_MODE"]?.trim();
|
|
4426
4723
|
if (requested && requested !== "auto") return requested;
|
|
4427
4724
|
return "auto";
|
|
4428
4725
|
}
|
|
@@ -4442,6 +4739,11 @@ async function publishStableCi(options) {
|
|
|
4442
4739
|
}
|
|
4443
4740
|
async function releaseCi(options) {
|
|
4444
4741
|
const mode = resolveMode(options);
|
|
4742
|
+
const source = options.sourceSha ?? getReleaseEnv(options)["REPO_RELEASE_RECOVERY_SOURCE_SHA"]?.trim();
|
|
4743
|
+
if (source) return recoverSource({
|
|
4744
|
+
...options,
|
|
4745
|
+
mode
|
|
4746
|
+
}, source);
|
|
4445
4747
|
if (mode === "prepare") {
|
|
4446
4748
|
await createReleasePullRequest(options);
|
|
4447
4749
|
return;
|
|
@@ -4471,7 +4773,10 @@ async function releaseCi(options) {
|
|
|
4471
4773
|
github
|
|
4472
4774
|
}, void 0, branch);
|
|
4473
4775
|
}
|
|
4474
|
-
return releasePrerelease(
|
|
4776
|
+
return releasePrerelease({
|
|
4777
|
+
...options,
|
|
4778
|
+
github
|
|
4779
|
+
}, () => publishLifecycle({
|
|
4475
4780
|
...options,
|
|
4476
4781
|
github,
|
|
4477
4782
|
env: {
|