versionary 1.9.0 → 1.11.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/action/index.js +10 -1
- package/dist/cli/index.js +34 -2
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.js +1 -0
- package/dist/release/artifact-rules.d.ts +1 -1
- package/dist/release/artifact-rules.js +13 -9
- package/dist/release/direct.js +7 -5
- package/dist/release/mode.d.ts +4 -0
- package/dist/release/mode.js +15 -0
- package/dist/release/plan.js +42 -4
- package/dist/release/pr.js +4 -4
- package/dist/release/release.d.ts +5 -1
- package/dist/release/release.js +34 -7
- package/dist/release/state.d.ts +3 -0
- package/dist/release/state.js +32 -5
- package/dist/types/config.d.ts +1 -0
- package/package.json +1 -1
package/dist/action/index.js
CHANGED
|
@@ -99,6 +99,7 @@ function skipRun(action, message) {
|
|
|
99
99
|
setOutput("tag_name", "");
|
|
100
100
|
setOutput("tag_names", "[]");
|
|
101
101
|
setOutput("release_targets", "[]");
|
|
102
|
+
setOutput("external_release_targets", "[]");
|
|
102
103
|
setOutput("review_url", "");
|
|
103
104
|
setOutput("review_requests", "[]");
|
|
104
105
|
setOutput("branch", "");
|
|
@@ -218,10 +219,18 @@ function main() {
|
|
|
218
219
|
setOutput("action", payload.action ?? "");
|
|
219
220
|
setOutput("message", payload.message ?? "");
|
|
220
221
|
setOutput("release_created", releaseCreated);
|
|
221
|
-
setOutput("release_ready", payload.action === "release-ready"
|
|
222
|
+
setOutput("release_ready", (payload.releaseReady ?? payload.action === "release-ready")
|
|
223
|
+
? "true"
|
|
224
|
+
: "false");
|
|
222
225
|
setOutput("tag_name", firstTag);
|
|
223
226
|
setOutput("tag_names", JSON.stringify(tagNames));
|
|
224
227
|
setOutput("release_targets", JSON.stringify(Array.isArray(payload.releaseTargets) ? payload.releaseTargets : []));
|
|
228
|
+
setOutput("external_release_targets", JSON.stringify(Array.isArray(payload.externalReleaseTargets)
|
|
229
|
+
? payload.externalReleaseTargets
|
|
230
|
+
: payload.action === "release-ready" ||
|
|
231
|
+
payload.action === "release-waiting"
|
|
232
|
+
? (payload.releaseTargets ?? [])
|
|
233
|
+
: []));
|
|
225
234
|
setOutput("review_url", payload.reviewUrl ?? "");
|
|
226
235
|
setOutput("review_requests", JSON.stringify(Array.isArray(payload.reviewRequests) ? payload.reviewRequests : []));
|
|
227
236
|
setOutput("branch", payload.branch ?? "");
|
package/dist/cli/index.js
CHANGED
|
@@ -8,9 +8,10 @@ import { loadConfig } from "../config/load-config.js";
|
|
|
8
8
|
import { resolveCommitSha } from "../git/commit-overrides.js";
|
|
9
9
|
import { prependChangelog, renderReleasePlanChangelog, } from "../release/changelog.js";
|
|
10
10
|
import { runDirectRelease } from "../release/direct.js";
|
|
11
|
+
import { hasExternalReleaseMode } from "../release/mode.js";
|
|
11
12
|
import { createReleasePlan } from "../release/plan.js";
|
|
12
13
|
import { closeStaleReviewRequestIfExists, isReleaseCommitMessage, openOrUpdateReviewRequest, preparePendingReleasePr, preparePendingSeparateReleasePrs, prepareReleasePr, prepareSeparateReleasePrs, pushReleaseBranch, reconcileSeparateReviewRequests, resolveReleaseHighlights, } from "../release/pr.js";
|
|
13
|
-
import { runRelease, runReleaseDetailed, } from "../release/release.js";
|
|
14
|
+
import { describeExternalRelease, runRelease, runReleaseDetailed, } from "../release/release.js";
|
|
14
15
|
import { hasFullyUntaggedPendingRelease, hasReleaseStateChangeAtHead, readPendingReleaseTargets, } from "../release/state.js";
|
|
15
16
|
import { verifyProject } from "../release/verify-project.js";
|
|
16
17
|
function recordCommitOverride(command, args) {
|
|
@@ -95,7 +96,18 @@ function parseFlags(args) {
|
|
|
95
96
|
"dry-run": args.includes("--dry-run"),
|
|
96
97
|
};
|
|
97
98
|
}
|
|
99
|
+
let externalAtStart;
|
|
98
100
|
function emitJson(payload) {
|
|
101
|
+
if (payload.action !== "ci-evaluated" &&
|
|
102
|
+
externalAtStart &&
|
|
103
|
+
!payload.externalReleaseTargets) {
|
|
104
|
+
payload = {
|
|
105
|
+
...payload,
|
|
106
|
+
externalReleaseTargets: externalAtStart.releaseTargets,
|
|
107
|
+
releaseReady: payload.action === "release-ready" &&
|
|
108
|
+
externalAtStart.action === "release-ready",
|
|
109
|
+
};
|
|
110
|
+
}
|
|
99
111
|
process.stdout.write(`${JSON.stringify(payload)}\n`);
|
|
100
112
|
}
|
|
101
113
|
function printExternalRelease(result, flags) {
|
|
@@ -106,6 +118,8 @@ function printExternalRelease(result, flags) {
|
|
|
106
118
|
releaseCreated: false,
|
|
107
119
|
tagNames: [],
|
|
108
120
|
releaseTargets: result.releaseTargets,
|
|
121
|
+
externalReleaseTargets: result.releaseTargets,
|
|
122
|
+
releaseReady: result.action === "release-ready",
|
|
109
123
|
});
|
|
110
124
|
}
|
|
111
125
|
else {
|
|
@@ -156,7 +170,9 @@ async function prepareCurrentSeparateReviewRequests(flags, logger) {
|
|
|
156
170
|
async function recoverPendingReleaseIfNeeded(flags, logger) {
|
|
157
171
|
const cwd = process.cwd();
|
|
158
172
|
const loaded = loadConfig(cwd);
|
|
159
|
-
if (loaded.config
|
|
173
|
+
if (hasExternalReleaseMode(loaded.config) &&
|
|
174
|
+
!hasFullyUntaggedPendingRelease(cwd) &&
|
|
175
|
+
!createReleasePlan(cwd).nextVersion) {
|
|
160
176
|
const result = await runReleaseDetailed(cwd, {
|
|
161
177
|
logger,
|
|
162
178
|
"dry-run": flags["dry-run"],
|
|
@@ -277,6 +293,14 @@ async function recoverPendingReleaseIfNeeded(flags, logger) {
|
|
|
277
293
|
async function main() {
|
|
278
294
|
const [, , command, ...args] = process.argv;
|
|
279
295
|
const flags = parseFlags(args);
|
|
296
|
+
if ((command === "run" || command === "pr") &&
|
|
297
|
+
hasExternalReleaseMode(loadConfig(process.cwd()).config)) {
|
|
298
|
+
// Preparing a PR can check out its branch; only hand off already-merged intent.
|
|
299
|
+
const external = describeExternalRelease(process.cwd(), loadConfig(process.cwd()).config, {});
|
|
300
|
+
if (external.action === "release-ready" ||
|
|
301
|
+
external.action === "release-waiting")
|
|
302
|
+
externalAtStart = external;
|
|
303
|
+
}
|
|
280
304
|
const logger = flags.json ? undefined : console;
|
|
281
305
|
if (command === "ci") {
|
|
282
306
|
const decision = evaluateCi();
|
|
@@ -298,6 +322,10 @@ async function main() {
|
|
|
298
322
|
if (flags.json) {
|
|
299
323
|
emitJson({
|
|
300
324
|
action: release.action,
|
|
325
|
+
externalReleaseTargets: "externalReleaseTargets" in release
|
|
326
|
+
? release.externalReleaseTargets
|
|
327
|
+
: undefined,
|
|
328
|
+
releaseReady: "releaseReady" in release ? release.releaseReady : undefined,
|
|
301
329
|
message,
|
|
302
330
|
releaseCreated: release.action === "release-published" &&
|
|
303
331
|
release.releases.length > 0,
|
|
@@ -352,6 +380,8 @@ async function main() {
|
|
|
352
380
|
if (flags.json) {
|
|
353
381
|
emitJson({
|
|
354
382
|
action: "release-dry-run",
|
|
383
|
+
externalReleaseTargets: release.externalReleaseTargets,
|
|
384
|
+
releaseReady: false,
|
|
355
385
|
message: release.message,
|
|
356
386
|
releaseCreated: false,
|
|
357
387
|
tagNames: release.targets.map((target) => target.tag),
|
|
@@ -372,6 +402,8 @@ async function main() {
|
|
|
372
402
|
const primary = reviewRequests[0];
|
|
373
403
|
emitJson({
|
|
374
404
|
action: "release-published",
|
|
405
|
+
externalReleaseTargets: release.externalReleaseTargets,
|
|
406
|
+
releaseReady: release.releaseReady,
|
|
375
407
|
message: release.message,
|
|
376
408
|
releaseCreated: release.releases.length > 0,
|
|
377
409
|
tagNames: release.releases.map((target) => target.tag),
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -50,6 +50,10 @@ export declare const configSchema: z.ZodObject<{
|
|
|
50
50
|
packages: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
51
51
|
"release-type": z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
52
52
|
"package-name": z.ZodOptional<z.ZodString>;
|
|
53
|
+
"release-mode": z.ZodOptional<z.ZodEnum<{
|
|
54
|
+
external: "external";
|
|
55
|
+
versionary: "versionary";
|
|
56
|
+
}>>;
|
|
53
57
|
"changelog-file": z.ZodOptional<z.ZodString>;
|
|
54
58
|
"changelog-format": z.ZodOptional<z.ZodEnum<{
|
|
55
59
|
"markdown-changelog": "markdown-changelog";
|
package/dist/config/schema.js
CHANGED
|
@@ -83,6 +83,7 @@ const packageSchema = z
|
|
|
83
83
|
.union([z.string().min(1), z.array(z.string().min(1)).min(1)])
|
|
84
84
|
.optional(),
|
|
85
85
|
"package-name": z.string().optional(),
|
|
86
|
+
"release-mode": z.enum(["versionary", "external"]).optional(),
|
|
86
87
|
"changelog-file": z.string().optional(),
|
|
87
88
|
"changelog-format": z.enum(["markdown-changelog", "r-news"]).optional(),
|
|
88
89
|
"release-draft": z.boolean().optional(),
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { VersionaryConfig } from "../types/config.js";
|
|
2
2
|
import type { ReleasePlan } from "./plan.js";
|
|
3
|
-
export declare function applyConfiguredArtifactRules(cwd: string, config: VersionaryConfig, plan: ReleasePlan): string[];
|
|
3
|
+
export declare function applyConfiguredArtifactRules(cwd: string, config: VersionaryConfig, plan: ReleasePlan, releaseDate?: string): string[];
|
|
@@ -162,9 +162,10 @@ function parseRegexPattern(pattern) {
|
|
|
162
162
|
return new RegExp(pattern, "m");
|
|
163
163
|
}
|
|
164
164
|
const REPLACEMENT_TOKEN_PATTERN = /\{\{\s*([A-Za-z]+)\s*\}\}/gu;
|
|
165
|
-
function renderReplacementTemplate(template, version) {
|
|
165
|
+
function renderReplacementTemplate(template, version, releaseDate) {
|
|
166
166
|
const parsed = parseVersion(version);
|
|
167
167
|
const tokens = {
|
|
168
|
+
date: releaseDate,
|
|
168
169
|
version,
|
|
169
170
|
major: String(parsed.major),
|
|
170
171
|
minor: String(parsed.minor),
|
|
@@ -174,6 +175,9 @@ function renderReplacementTemplate(template, version) {
|
|
|
174
175
|
};
|
|
175
176
|
return template.replace(REPLACEMENT_TOKEN_PATTERN, (_whole, name) => {
|
|
176
177
|
const key = name.toLowerCase();
|
|
178
|
+
if (key === "date" && releaseDate === undefined) {
|
|
179
|
+
throw new Error("The {{date}} replacement token requires a release date.");
|
|
180
|
+
}
|
|
177
181
|
const value = tokens[key];
|
|
178
182
|
if (value === undefined) {
|
|
179
183
|
throw new Error(`Unknown replacement token "{{${name}}}". Supported tokens: ${Object.keys(tokens)
|
|
@@ -183,7 +187,7 @@ function renderReplacementTemplate(template, version) {
|
|
|
183
187
|
return value;
|
|
184
188
|
});
|
|
185
189
|
}
|
|
186
|
-
function applyRegexRule(content, pattern, version, expectedMatches, replacementTemplate) {
|
|
190
|
+
function applyRegexRule(content, pattern, version, expectedMatches, replacementTemplate, releaseDate) {
|
|
187
191
|
const regex = parseRegexPattern(pattern);
|
|
188
192
|
const matchFlags = regex.flags.includes("g")
|
|
189
193
|
? regex.flags
|
|
@@ -195,7 +199,7 @@ function applyRegexRule(content, pattern, version, expectedMatches, replacementT
|
|
|
195
199
|
}
|
|
196
200
|
const renderedReplacement = replacementTemplate === undefined
|
|
197
201
|
? undefined
|
|
198
|
-
: renderReplacementTemplate(replacementTemplate, version);
|
|
202
|
+
: renderReplacementTemplate(replacementTemplate, version, releaseDate);
|
|
199
203
|
let updated = content;
|
|
200
204
|
for (let index = matches.length - 1; index >= 0; index -= 1) {
|
|
201
205
|
const match = matches[index];
|
|
@@ -397,12 +401,12 @@ function applyNixRulePreservingFormatting(content, fieldPath, version) {
|
|
|
397
401
|
}
|
|
398
402
|
return `${content.slice(0, target.start)}${target.replacement}${content.slice(target.end)}`;
|
|
399
403
|
}
|
|
400
|
-
function applyArtifactRuleToContent(content, rule, version) {
|
|
404
|
+
function applyArtifactRuleToContent(content, rule, version, releaseDate) {
|
|
401
405
|
if (rule.type === "regex") {
|
|
402
406
|
if (!rule.pattern) {
|
|
403
407
|
throw new Error('regex artifact rules require "pattern".');
|
|
404
408
|
}
|
|
405
|
-
return applyRegexRule(content, rule.pattern, version, rule["expected-matches"] ?? 1, rule.replacement);
|
|
409
|
+
return applyRegexRule(content, rule.pattern, version, rule["expected-matches"] ?? 1, rule.replacement, releaseDate);
|
|
406
410
|
}
|
|
407
411
|
if (rule.type === "json") {
|
|
408
412
|
const parsed = JSON.parse(content);
|
|
@@ -422,7 +426,7 @@ function applyArtifactRuleToContent(content, rule, version) {
|
|
|
422
426
|
function normalizeRelative(base, target) {
|
|
423
427
|
return path.relative(base, target).replaceAll("\\", "/");
|
|
424
428
|
}
|
|
425
|
-
function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version) {
|
|
429
|
+
function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version, releaseDate) {
|
|
426
430
|
const rules = packageConfig["extra-files"] ?? [];
|
|
427
431
|
if (rules.length === 0) {
|
|
428
432
|
return [];
|
|
@@ -437,7 +441,7 @@ function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version)
|
|
|
437
441
|
const existing = fs.readFileSync(targetPath, "utf8");
|
|
438
442
|
let next;
|
|
439
443
|
try {
|
|
440
|
-
next = applyArtifactRuleToContent(existing, rule, version);
|
|
444
|
+
next = applyArtifactRuleToContent(existing, rule, version, releaseDate);
|
|
441
445
|
}
|
|
442
446
|
catch (error) {
|
|
443
447
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -448,7 +452,7 @@ function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version)
|
|
|
448
452
|
}
|
|
449
453
|
return updated;
|
|
450
454
|
}
|
|
451
|
-
export function applyConfiguredArtifactRules(cwd, config, plan) {
|
|
455
|
+
export function applyConfiguredArtifactRules(cwd, config, plan, releaseDate) {
|
|
452
456
|
const packageConfigs = config.packages ?? {};
|
|
453
457
|
if (!plan.packages || plan.packages.length === 0) {
|
|
454
458
|
return [];
|
|
@@ -462,7 +466,7 @@ export function applyConfiguredArtifactRules(cwd, config, plan) {
|
|
|
462
466
|
if (!packageConfig?.["extra-files"]?.length) {
|
|
463
467
|
continue;
|
|
464
468
|
}
|
|
465
|
-
const files = applyArtifactRulesForPackage(cwd, packagePlan.path, packageConfig, packagePlan.nextVersion);
|
|
469
|
+
const files = applyArtifactRulesForPackage(cwd, packagePlan.path, packageConfig, packagePlan.nextVersion, releaseDate);
|
|
466
470
|
for (const file of files) {
|
|
467
471
|
updated.add(file);
|
|
468
472
|
}
|
package/dist/release/direct.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFileSync } from "node:child_process";
|
|
2
2
|
import { loadConfig } from "../config/load-config.js";
|
|
3
|
+
import { hasExternalReleaseMode } from "./mode.js";
|
|
3
4
|
import { createReleasePlan } from "./plan.js";
|
|
4
5
|
import { buildReleaseTargets, isReleaseCommitMessage, preparePendingReleasePr, prepareReleasePr, } from "./pr.js";
|
|
5
6
|
import { runReleaseDetailed, } from "./release.js";
|
|
@@ -44,11 +45,12 @@ export async function runDirectRelease(cwd = process.cwd(), options = {}) {
|
|
|
44
45
|
const releaseContext = isReleaseCommitMessage(git(cwd, "log", "-1", "--pretty=%B")) ||
|
|
45
46
|
hasReleaseStateChangeAtHead(cwd);
|
|
46
47
|
if (!releaseContext) {
|
|
47
|
-
const external = loadConfig(cwd).config
|
|
48
|
-
const pending =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const external = hasExternalReleaseMode(loadConfig(cwd).config);
|
|
49
|
+
const pending = hasFullyUntaggedPendingRelease(cwd);
|
|
50
|
+
if (external &&
|
|
51
|
+
!pending &&
|
|
52
|
+
readExternalReleaseTargets(cwd).length > 0 &&
|
|
53
|
+
!createReleasePlan(cwd).nextVersion) {
|
|
52
54
|
return runReleaseDetailed(cwd, options);
|
|
53
55
|
}
|
|
54
56
|
const plan = pending ? undefined : createReleasePlan(cwd);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VersionaryConfig } from "../types/config.js";
|
|
2
|
+
export declare function resolveTargetReleaseMode(config: VersionaryConfig, packagePath: string): "versionary" | "external";
|
|
3
|
+
export declare function hasExternalReleaseMode(config: VersionaryConfig): boolean;
|
|
4
|
+
export declare function hasManagedReleaseMode(config: VersionaryConfig): boolean;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function resolveTargetReleaseMode(config, packagePath) {
|
|
2
|
+
return (config.packages?.[packagePath]?.["release-mode"] ??
|
|
3
|
+
config["release-mode"] ??
|
|
4
|
+
"versionary");
|
|
5
|
+
}
|
|
6
|
+
export function hasExternalReleaseMode(config) {
|
|
7
|
+
return (Object.keys(config.packages ?? {}).length > 0
|
|
8
|
+
? Object.keys(config.packages ?? {})
|
|
9
|
+
: ["."]).some((packagePath) => resolveTargetReleaseMode(config, packagePath) === "external");
|
|
10
|
+
}
|
|
11
|
+
export function hasManagedReleaseMode(config) {
|
|
12
|
+
return (Object.keys(config.packages ?? {}).length > 0
|
|
13
|
+
? Object.keys(config.packages ?? {})
|
|
14
|
+
: ["."]).some((packagePath) => resolveTargetReleaseMode(config, packagePath) === "versionary");
|
|
15
|
+
}
|
package/dist/release/plan.js
CHANGED
|
@@ -7,7 +7,7 @@ import { resolvePackageStrategyContext } from "../strategy/package-context.js";
|
|
|
7
7
|
import { resolveVersionStrategy } from "../strategy/resolve.js";
|
|
8
8
|
import { releaseTypeBetween, resolveReleaseAsOverride } from "./release-as.js";
|
|
9
9
|
import { bumpVersion, maxReleaseType } from "./semver.js";
|
|
10
|
-
import { readBaselineSha, readReleaseTargets } from "./state.js";
|
|
10
|
+
import { readBaselineSha, readExternalReleaseWaitPaths, readReleaseTargets, } from "./state.js";
|
|
11
11
|
function getMode(configMode) {
|
|
12
12
|
return configMode ?? "independent";
|
|
13
13
|
}
|
|
@@ -43,6 +43,7 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
43
43
|
const loaded = loadConfig(cwd);
|
|
44
44
|
const overrides = resolveCommitOverrides(cwd, options.commitOverrides ?? loaded.config["commit-overrides"] ?? {});
|
|
45
45
|
const originalCommits = new Map();
|
|
46
|
+
const originalCommitPaths = new Map();
|
|
46
47
|
// Keep the original revert relationships even when either commit is excluded.
|
|
47
48
|
const effectiveCommits = (commits) => applyCommitOverrides(applyRevertSuppression(commits), overrides);
|
|
48
49
|
const strategy = resolveVersionStrategy(loaded.config);
|
|
@@ -64,6 +65,11 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
64
65
|
const allowStableMajor = resolveAllowStableMajor(loaded.config);
|
|
65
66
|
const allowStableMajorForPath = (packagePath) => resolveAllowStableMajor(loaded.config, loaded.config.packages?.[packagePath]);
|
|
66
67
|
const monorepoMode = getMode(loaded.config["monorepo-mode"]);
|
|
68
|
+
const waitingPaths = readExternalReleaseWaitPaths(cwd);
|
|
69
|
+
if (monorepoMode === "fixed" && waitingPaths.size > 0) {
|
|
70
|
+
for (const pkg of normalizedPackages)
|
|
71
|
+
waitingPaths.add(pkg.path);
|
|
72
|
+
}
|
|
67
73
|
const buildPackagePlan = (pkg) => {
|
|
68
74
|
const packageContext = resolvePackageStrategyContext(loaded.config, pkg.path, pkg.config);
|
|
69
75
|
const currentVersionFile = path.join(cwd, packageContext.versionFile);
|
|
@@ -79,7 +85,10 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
79
85
|
];
|
|
80
86
|
const isImplicitRoot = !hasPackages && pkg.path === ".";
|
|
81
87
|
let parsedCommits;
|
|
82
|
-
if (
|
|
88
|
+
if (waitingPaths.has(pkg.path)) {
|
|
89
|
+
parsedCommits = [];
|
|
90
|
+
}
|
|
91
|
+
else if (isImplicitRoot && excludePaths.length === 0) {
|
|
83
92
|
parsedCommits = getParsedCommitsSinceLastTag(cwd, baselineSha);
|
|
84
93
|
}
|
|
85
94
|
else {
|
|
@@ -89,6 +98,9 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
89
98
|
}
|
|
90
99
|
for (const commit of parsedCommits) {
|
|
91
100
|
originalCommits.set(commit.hash, commit);
|
|
101
|
+
const paths = originalCommitPaths.get(commit.hash) ?? new Set();
|
|
102
|
+
paths.add(pkg.path);
|
|
103
|
+
originalCommitPaths.set(commit.hash, paths);
|
|
92
104
|
overrides.get(commit.hash)?.report.packages.push(pkg.path);
|
|
93
105
|
}
|
|
94
106
|
parsedCommits = effectiveCommits(parsedCommits);
|
|
@@ -247,6 +259,28 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
247
259
|
dependenciesByPath.set(dependentPath, new Set([pkgPlan.path]));
|
|
248
260
|
}
|
|
249
261
|
}
|
|
262
|
+
// A dependent cannot publish against a sibling version still awaiting acceptance.
|
|
263
|
+
for (let iteration = 0; iteration < workingPlans.length; iteration += 1) {
|
|
264
|
+
for (const [dependent, dependencies] of dependenciesByPath) {
|
|
265
|
+
if ([...dependencies].some((dependency) => waitingPaths.has(dependency)))
|
|
266
|
+
waitingPaths.add(dependent);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
for (const pkg of workingPlans) {
|
|
270
|
+
if (waitingPaths.has(pkg.path)) {
|
|
271
|
+
pkg.nextVersion = null;
|
|
272
|
+
pkg.releaseType = null;
|
|
273
|
+
pkg.commits = [];
|
|
274
|
+
pkg.parsedCommits = [];
|
|
275
|
+
const context = strategyContextByPath.get(pkg.path);
|
|
276
|
+
if (context)
|
|
277
|
+
context.nextVersion = null;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
for (const [hash, paths] of originalCommitPaths) {
|
|
281
|
+
if ([...paths].every((packagePath) => waitingPaths.has(packagePath)))
|
|
282
|
+
originalCommits.delete(hash);
|
|
283
|
+
}
|
|
250
284
|
/**
|
|
251
285
|
* Every package reachable by following dependency edges down from a
|
|
252
286
|
* publishable package that is currently releasing. Staleness matters
|
|
@@ -331,7 +365,7 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
331
365
|
const impacted = strategyGroup.strategy.propagateDependentPatchImpacts?.(cwd, strategyGroup.packages) ?? [];
|
|
332
366
|
for (const impactedPath of impacted) {
|
|
333
367
|
const target = workingPlanByPath.get(impactedPath);
|
|
334
|
-
if (!target || target.nextVersion) {
|
|
368
|
+
if (!target || target.nextVersion || waitingPaths.has(target.path)) {
|
|
335
369
|
continue;
|
|
336
370
|
}
|
|
337
371
|
forcePatchBump(target, "dependency-propagation");
|
|
@@ -344,7 +378,9 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
344
378
|
// from the change existing, not from how it was labeled.
|
|
345
379
|
const reachableDependencies = collectReleasingDependencyClosure();
|
|
346
380
|
for (const candidate of workingPlans) {
|
|
347
|
-
if (candidate.nextVersion ||
|
|
381
|
+
if (candidate.nextVersion ||
|
|
382
|
+
candidate.commits.length === 0 ||
|
|
383
|
+
waitingPaths.has(candidate.path)) {
|
|
348
384
|
continue;
|
|
349
385
|
}
|
|
350
386
|
if (!reachableDependencies.has(candidate.path)) {
|
|
@@ -371,6 +407,8 @@ export function createReleasePlan(cwd = process.cwd(), options = {}) {
|
|
|
371
407
|
}
|
|
372
408
|
}
|
|
373
409
|
const adjustedPackages = propagatedPackages.map((pkgPlan) => {
|
|
410
|
+
if (waitingPaths.has(pkgPlan.path))
|
|
411
|
+
return pkgPlan;
|
|
374
412
|
if (pkgPlan.bumpReason === "release-as") {
|
|
375
413
|
// An explicit override pins this package's version; do not let a
|
|
376
414
|
// followed source recompute it out from under the requested version.
|
package/dist/release/pr.js
CHANGED
|
@@ -12,7 +12,7 @@ import { applyConfiguredArtifactRules } from "./artifact-rules.js";
|
|
|
12
12
|
import { extractUnreleasedNotes, prependChangelog, renderReleaseNotesSection, renderReleasePlanChangelog, renderReviewRequestFooter, renderRNewsReleaseNotes, } from "./changelog.js";
|
|
13
13
|
import { buildInitialReleaseCohorts, resolveSeparateReleaseBranch, resolveSeparateReleaseBranchPrefix, stabilizeReleaseCohorts, } from "./cohorts.js";
|
|
14
14
|
import { createReleasePlan, getChangelogDefaults, resolvePackageDependencies, } from "./plan.js";
|
|
15
|
-
import { hasFullyUntaggedPendingRelease, readPendingReleaseCohorts,
|
|
15
|
+
import { hasFullyUntaggedPendingRelease, readPendingReleaseCohorts, writeBaselineSha, writePackageReleaseState, } from "./state.js";
|
|
16
16
|
const SAFE_DIRTY_FILES = new Set([
|
|
17
17
|
"pnpm-lock.yaml",
|
|
18
18
|
"package-lock.json",
|
|
@@ -234,7 +234,7 @@ export function renderPendingReleaseReviewRequestBody(targets) {
|
|
|
234
234
|
* changelog changes were already reviewed in the original release PR.
|
|
235
235
|
*/
|
|
236
236
|
export function preparePendingReleasePr(cwd = process.cwd(), options = {}) {
|
|
237
|
-
const targets =
|
|
237
|
+
const targets = readPendingReleaseCohorts(cwd).flatMap((cohort) => cohort.targets);
|
|
238
238
|
if (!hasFullyUntaggedPendingRelease(cwd)) {
|
|
239
239
|
throw new Error("No unpublished pending release found to recover.");
|
|
240
240
|
}
|
|
@@ -417,7 +417,7 @@ export function prepareReleasePr(cwd = process.cwd(), options = {}) {
|
|
|
417
417
|
for (const strategyGroup of writesByStrategy.values()) {
|
|
418
418
|
updatedVersionFiles.push(...(strategyGroup.strategy.finalizeVersionWrites?.(cwd, strategyGroup.writes, finalizeContext) ?? []));
|
|
419
419
|
}
|
|
420
|
-
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan);
|
|
420
|
+
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan, finalizeContext.releaseDate);
|
|
421
421
|
const packageReleaseMetadata = buildPackageReleaseMetadata(cwd, plan, loaded.config);
|
|
422
422
|
const highlightsResult = resolveReleaseHighlights(cwd, plan.changelogFile, plan.changelogFormat);
|
|
423
423
|
const highlights = highlightsResult.highlights;
|
|
@@ -575,7 +575,7 @@ function materializeCandidateChanges(cwd, plan, options) {
|
|
|
575
575
|
for (const strategyGroup of writesByStrategy.values()) {
|
|
576
576
|
updatedVersionFiles.push(...(strategyGroup.strategy.finalizeVersionWrites?.(cwd, strategyGroup.writes, finalizeContext) ?? []));
|
|
577
577
|
}
|
|
578
|
-
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan);
|
|
578
|
+
const updatedArtifactFiles = applyConfiguredArtifactRules(cwd, loaded.config, plan, finalizeContext.releaseDate);
|
|
579
579
|
const packageReleaseMetadata = buildPackageReleaseMetadata(cwd, plan, loaded.config);
|
|
580
580
|
const rootIsReleasing = Boolean(plan.packages?.find((pkg) => pkg.path === ".")?.nextVersion);
|
|
581
581
|
const highlights = rootIsReleasing
|
|
@@ -7,7 +7,7 @@ export declare function extractReleaseNotes(content: string, version: string, ch
|
|
|
7
7
|
export declare function extractClosingReferencesFromNotes(notes: string): number[];
|
|
8
8
|
export declare function resolveTargetChangelogFile(config: VersionaryConfig, rootChangelogFile: string, targetPath: string): string;
|
|
9
9
|
export declare function runRelease(cwd?: string): Promise<string>;
|
|
10
|
-
export type RunReleaseResult = {
|
|
10
|
+
export type RunReleaseResult = ({
|
|
11
11
|
action: "release-skipped";
|
|
12
12
|
reason: string;
|
|
13
13
|
} | ExternalReleaseResult | {
|
|
@@ -38,6 +38,9 @@ export type RunReleaseResult = {
|
|
|
38
38
|
version: string;
|
|
39
39
|
dependencies: string[];
|
|
40
40
|
}[];
|
|
41
|
+
}) & {
|
|
42
|
+
releaseReady?: boolean;
|
|
43
|
+
externalReleaseTargets?: ExternalReleaseResult["releaseTargets"];
|
|
41
44
|
};
|
|
42
45
|
export type ExternalReleaseResult = {
|
|
43
46
|
message: string;
|
|
@@ -54,6 +57,7 @@ export type ExternalReleaseResult = {
|
|
|
54
57
|
} | {
|
|
55
58
|
action: "release-waiting";
|
|
56
59
|
});
|
|
60
|
+
export declare function describeExternalRelease(cwd: string, config: VersionaryConfig, options: RunReleaseOptions): RunReleaseResult;
|
|
57
61
|
export interface RunReleaseOptions {
|
|
58
62
|
logger?: VersionaryPluginContext["logger"];
|
|
59
63
|
"dry-run"?: boolean;
|
package/dist/release/release.js
CHANGED
|
@@ -5,10 +5,11 @@ import { loadConfig } from "../config/load-config.js";
|
|
|
5
5
|
import { getScmClient } from "../scm/client.js";
|
|
6
6
|
import { resolvePackageStrategyContext, resolveReleaseName, } from "../strategy/package-context.js";
|
|
7
7
|
import { resolveVersionStrategy } from "../strategy/resolve.js";
|
|
8
|
+
import { hasManagedReleaseMode, resolveTargetReleaseMode } from "./mode.js";
|
|
8
9
|
import { getChangelogDefaults } from "./plan.js";
|
|
9
10
|
import { isReleaseCommitMessage } from "./pr.js";
|
|
10
11
|
import { executeIdempotentReleaseTarget } from "./recovery.js";
|
|
11
|
-
import { hasReleaseStateChangeAtHead, readExternalReleaseTargets, readPendingReleaseTargets, readRecordedPendingReleaseTargets, } from "./state.js";
|
|
12
|
+
import { hasLocalTag, hasReleaseStateChangeAtHead, readExternalReleaseTargets, readExternalReleaseWaitPaths, readPendingReleaseTargets, readRecordedPendingReleaseTargets, } from "./state.js";
|
|
12
13
|
import { releaseTargetHandoff } from "./targets.js";
|
|
13
14
|
function escapeRegExp(input) {
|
|
14
15
|
return input.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
@@ -141,7 +142,7 @@ export async function runRelease(cwd = process.cwd()) {
|
|
|
141
142
|
}
|
|
142
143
|
return result.message;
|
|
143
144
|
}
|
|
144
|
-
function describeExternalRelease(cwd, config, options) {
|
|
145
|
+
export function describeExternalRelease(cwd, config, options) {
|
|
145
146
|
const targets = readExternalReleaseTargets(cwd);
|
|
146
147
|
if (targets.length === 0) {
|
|
147
148
|
return {
|
|
@@ -188,9 +189,26 @@ function describeExternalRelease(cwd, config, options) {
|
|
|
188
189
|
}
|
|
189
190
|
export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
190
191
|
const loaded = loadConfig(cwd);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
const external = describeExternalRelease(cwd, loaded.config, options);
|
|
193
|
+
if (!hasManagedReleaseMode(loaded.config))
|
|
194
|
+
return external;
|
|
195
|
+
const waitingPaths = readExternalReleaseWaitPaths(cwd);
|
|
196
|
+
const managed = (target) => resolveTargetReleaseMode(loaded.config, target.path) === "versionary" &&
|
|
197
|
+
!waitingPaths.has(target.path);
|
|
198
|
+
const pendingManaged = readPendingReleaseTargets(cwd).filter((target) => managed(target) && !hasLocalTag(cwd, target.tag));
|
|
199
|
+
if (pendingManaged.length === 0 && external.action !== "release-skipped")
|
|
200
|
+
return external;
|
|
201
|
+
const externalHandoff = external.action === "release-ready" || external.action === "release-waiting"
|
|
202
|
+
? {
|
|
203
|
+
externalReleaseTargets: external.releaseTargets,
|
|
204
|
+
releaseReady: external.action === "release-ready",
|
|
205
|
+
}
|
|
206
|
+
: external.action === "release-dry-run"
|
|
207
|
+
? {
|
|
208
|
+
externalReleaseTargets: external.releaseTargets,
|
|
209
|
+
releaseReady: false,
|
|
210
|
+
}
|
|
211
|
+
: {};
|
|
194
212
|
const commitMessage = getHeadCommitMessage(cwd);
|
|
195
213
|
if (!isReleaseCommitMessage(commitMessage) &&
|
|
196
214
|
!hasReleaseStateChangeAtHead(cwd)) {
|
|
@@ -205,7 +223,7 @@ export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
|
205
223
|
defaultChangelogFormat: strategy.getDefaultChangelogFormat?.(),
|
|
206
224
|
});
|
|
207
225
|
const referenceCommentMode = loaded.config["release-reference-comments"] ?? "off";
|
|
208
|
-
const releaseTargets = readPendingReleaseTargets(cwd);
|
|
226
|
+
const releaseTargets = readPendingReleaseTargets(cwd).filter(managed);
|
|
209
227
|
if (loaded.config["separate-release-prs"] && releaseTargets.length === 0) {
|
|
210
228
|
return {
|
|
211
229
|
action: "release-skipped",
|
|
@@ -218,7 +236,14 @@ export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
|
218
236
|
// tagging the root package.
|
|
219
237
|
const recordedTargets = releaseTargets.length > 0
|
|
220
238
|
? releaseTargets
|
|
221
|
-
: readRecordedPendingReleaseTargets(cwd);
|
|
239
|
+
: readRecordedPendingReleaseTargets(cwd).filter(managed);
|
|
240
|
+
if (recordedTargets.length === 0 &&
|
|
241
|
+
readRecordedPendingReleaseTargets(cwd).length > 0) {
|
|
242
|
+
return {
|
|
243
|
+
action: "release-skipped",
|
|
244
|
+
reason: "No Versionary-managed release targets found.",
|
|
245
|
+
};
|
|
246
|
+
}
|
|
222
247
|
const version = recordedTargets.length === 0
|
|
223
248
|
? strategy.readVersion(cwd, loaded.config)
|
|
224
249
|
: undefined;
|
|
@@ -241,6 +266,7 @@ export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
|
241
266
|
version: target.version,
|
|
242
267
|
})),
|
|
243
268
|
releaseTargets: releaseTargetPlan,
|
|
269
|
+
...externalHandoff,
|
|
244
270
|
message: `Dry run: would publish releases ${targetList.join(", ")}`,
|
|
245
271
|
};
|
|
246
272
|
}
|
|
@@ -298,6 +324,7 @@ export async function runReleaseDetailed(cwd = process.cwd(), options = {}) {
|
|
|
298
324
|
const published = releases.map((outcome) => `${outcome.tag}: ${outcome.url} (tag=${outcome.tagStatus}, metadata=${outcome.metadataStatus})`);
|
|
299
325
|
return {
|
|
300
326
|
action: "release-published",
|
|
327
|
+
...externalHandoff,
|
|
301
328
|
releases,
|
|
302
329
|
releaseTargets: releaseTargetPlan,
|
|
303
330
|
message: `Published releases ${published.join(", ")}`,
|
package/dist/release/state.d.ts
CHANGED
|
@@ -13,11 +13,14 @@ export declare function getPackageStateDirectory(cwd: string): string;
|
|
|
13
13
|
export declare function readBaselineSha(cwd?: string): string | null;
|
|
14
14
|
export declare function readReleaseTargets(cwd?: string): ReleaseTargetState[];
|
|
15
15
|
export declare function readPendingReleaseTargets(cwd?: string): ReleaseTargetState[];
|
|
16
|
+
export declare function readPendingExternalReleaseTargets(cwd?: string): ReleaseTargetState[];
|
|
17
|
+
export declare function readExternalReleaseWaitPaths(cwd?: string): Set<string>;
|
|
16
18
|
export declare function readExternalReleaseTargets(cwd?: string): (ReleaseTargetState & {
|
|
17
19
|
sha: string;
|
|
18
20
|
})[];
|
|
19
21
|
export declare function readRecordedPendingReleaseTargets(cwd?: string): ReleaseTargetState[];
|
|
20
22
|
export declare function readPendingReleaseCohorts(cwd?: string): PendingReleaseCohort[];
|
|
23
|
+
export declare function hasLocalTag(cwd: string, tag: string): boolean;
|
|
21
24
|
/**
|
|
22
25
|
* Pending targets remain in the manifest after publishing, so the tag set is
|
|
23
26
|
* the durable evidence that the pending release actually completed.
|
package/dist/release/state.js
CHANGED
|
@@ -3,6 +3,7 @@ import { createHash } from "node:crypto";
|
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { loadConfig } from "../config/load-config.js";
|
|
6
|
+
import { resolveTargetReleaseMode } from "./mode.js";
|
|
6
7
|
const MANIFEST_VERSION_KEY = "manifest-version";
|
|
7
8
|
const BASELINE_SHA_KEY = "baseline-sha";
|
|
8
9
|
const RELEASE_TARGETS_KEY = "release-targets";
|
|
@@ -140,10 +141,26 @@ export function readPendingReleaseTargets(cwd = process.cwd()) {
|
|
|
140
141
|
allowPartiallyTagged: true,
|
|
141
142
|
}).flatMap((cohort) => cohort.targets);
|
|
142
143
|
}
|
|
144
|
+
export function readPendingExternalReleaseTargets(cwd = process.cwd()) {
|
|
145
|
+
const { config } = loadConfig(cwd);
|
|
146
|
+
return readPendingReleaseTargets(cwd).filter((target) => resolveTargetReleaseMode(config, target.path) === "external" &&
|
|
147
|
+
!hasLocalTag(cwd, target.tag));
|
|
148
|
+
}
|
|
149
|
+
export function readExternalReleaseWaitPaths(cwd = process.cwd()) {
|
|
150
|
+
const targets = readPendingReleaseTargets(cwd);
|
|
151
|
+
const waiting = new Set(readPendingExternalReleaseTargets(cwd).map((target) => target.path));
|
|
152
|
+
for (let iteration = 0; iteration < targets.length; iteration += 1) {
|
|
153
|
+
for (const target of targets) {
|
|
154
|
+
if (!hasLocalTag(cwd, target.tag) &&
|
|
155
|
+
target.dependencies?.some((dependency) => waiting.has(dependency))) {
|
|
156
|
+
waiting.add(target.path);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return waiting;
|
|
161
|
+
}
|
|
143
162
|
export function readExternalReleaseTargets(cwd = process.cwd()) {
|
|
144
|
-
return
|
|
145
|
-
.filter((target) => !hasLocalTag(cwd, target.tag))
|
|
146
|
-
.map((target) => {
|
|
163
|
+
return readPendingExternalReleaseTargets(cwd).map((target) => {
|
|
147
164
|
const sidecar = path.join(getPackageStateDirectory(cwd), packageStateFileName(target.path));
|
|
148
165
|
const statePath = fs.existsSync(sidecar)
|
|
149
166
|
? sidecar
|
|
@@ -206,9 +223,13 @@ export function readRecordedPendingReleaseTargets(cwd = process.cwd()) {
|
|
|
206
223
|
}).flatMap((cohort) => cohort.targets);
|
|
207
224
|
}
|
|
208
225
|
export function readPendingReleaseCohorts(cwd = process.cwd()) {
|
|
209
|
-
return collectPendingReleaseCohorts(cwd, {
|
|
226
|
+
return collectPendingReleaseCohorts(cwd, {
|
|
227
|
+
excludeExternal: true,
|
|
228
|
+
excludedPaths: readExternalReleaseWaitPaths(cwd),
|
|
229
|
+
});
|
|
210
230
|
}
|
|
211
231
|
function collectPendingReleaseCohorts(cwd, options) {
|
|
232
|
+
const { config } = loadConfig(cwd);
|
|
212
233
|
const filePath = getBaselineStatePath(cwd);
|
|
213
234
|
const packageStates = readPackageStates(cwd);
|
|
214
235
|
const sidecarPaths = new Set(packageStates.map((state) => state.path));
|
|
@@ -216,6 +237,12 @@ function collectPendingReleaseCohorts(cwd, options) {
|
|
|
216
237
|
// The baseline separates completed releases from the next release on it.
|
|
217
238
|
const byBranch = new Map();
|
|
218
239
|
const addTargets = (branch, baselineSha, targets) => {
|
|
240
|
+
if (options.excludeExternal) {
|
|
241
|
+
targets = targets.filter((target) => resolveTargetReleaseMode(config, target.path) === "versionary" &&
|
|
242
|
+
!options.excludedPaths?.has(target.path));
|
|
243
|
+
}
|
|
244
|
+
if (targets.length === 0)
|
|
245
|
+
return;
|
|
219
246
|
const byBaseline = byBranch.get(branch) ??
|
|
220
247
|
new Map();
|
|
221
248
|
byBaseline.set(baselineSha, [
|
|
@@ -267,7 +294,7 @@ function collectPendingReleaseCohorts(cwd, options) {
|
|
|
267
294
|
}
|
|
268
295
|
return pending.sort((a, b) => a.branch.localeCompare(b.branch));
|
|
269
296
|
}
|
|
270
|
-
function hasLocalTag(cwd, tag) {
|
|
297
|
+
export function hasLocalTag(cwd, tag) {
|
|
271
298
|
try {
|
|
272
299
|
execFileSync("git", ["show-ref", "--verify", "--quiet", `refs/tags/${tag}`], {
|
|
273
300
|
cwd,
|
package/dist/types/config.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface VersionaryArtifactRule {
|
|
|
19
19
|
"expected-matches"?: number;
|
|
20
20
|
}
|
|
21
21
|
export interface VersionaryPackage {
|
|
22
|
+
"release-mode"?: "versionary" | "external";
|
|
22
23
|
"release-type"?: string | string[];
|
|
23
24
|
"package-name"?: string;
|
|
24
25
|
"changelog-file"?: string;
|