versionary 0.28.0 → 0.28.2
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 +7 -9
- package/dist/cli/index.js +32 -34
- package/dist/config/load-config.js +16 -23
- package/dist/config/schema.js +45 -48
- package/dist/git/commits.js +23 -42
- package/dist/git/identity.js +7 -11
- package/dist/git/repo-url.js +3 -6
- package/dist/index.js +6 -16
- package/dist/release/artifact-rules.js +15 -21
- package/dist/release/changelog.js +23 -34
- package/dist/release/plan.js +34 -43
- package/dist/release/pr.js +75 -92
- package/dist/release/recovery.js +9 -12
- package/dist/release/release.js +37 -50
- package/dist/release/semver.js +5 -12
- package/dist/release/state.js +22 -31
- package/dist/release/verify-project.js +14 -20
- package/dist/scm/capabilities.js +2 -6
- package/dist/scm/client.js +3 -6
- package/dist/scm/github-plugin.js +6 -9
- package/dist/scm/types.js +1 -2
- package/dist/strategy/composite.js +1 -4
- package/dist/strategy/latex.js +18 -24
- package/dist/strategy/node.js +13 -19
- package/dist/strategy/package-context.js +8 -15
- package/dist/strategy/python.js +35 -41
- package/dist/strategy/r.js +16 -22
- package/dist/strategy/resolve.js +16 -20
- package/dist/strategy/rust.js +80 -89
- package/dist/strategy/simple.js +8 -14
- package/dist/strategy/types.js +1 -2
- package/dist/types/config.js +1 -2
- package/dist/types/plugins.js +1 -2
- package/package.json +3 -3
package/dist/git/identity.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_GIT_AUTHOR_EMAIL = exports.DEFAULT_GIT_AUTHOR_NAME = void 0;
|
|
4
|
-
exports.ensureGitIdentity = ensureGitIdentity;
|
|
5
|
-
const node_child_process_1 = require("node:child_process");
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
6
2
|
/**
|
|
7
3
|
* Default committer identity Versionary uses when a repository has no
|
|
8
4
|
* `user.name`/`user.email` configured (for example a bare CI runner).
|
|
@@ -12,11 +8,11 @@ const node_child_process_1 = require("node:child_process");
|
|
|
12
8
|
* module, so release commits are attributed to the same bot regardless of how
|
|
13
9
|
* Versionary is invoked (composite action vs. running the CLI from source).
|
|
14
10
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export const DEFAULT_GIT_AUTHOR_NAME = "github-actions[bot]";
|
|
12
|
+
export const DEFAULT_GIT_AUTHOR_EMAIL = "41898282+github-actions[bot]@users.noreply.github.com";
|
|
17
13
|
function hasGitConfig(cwd, key) {
|
|
18
14
|
try {
|
|
19
|
-
|
|
15
|
+
execFileSync("git", ["config", key], {
|
|
20
16
|
cwd,
|
|
21
17
|
stdio: ["ignore", "pipe", "ignore"],
|
|
22
18
|
});
|
|
@@ -33,15 +29,15 @@ function hasGitConfig(cwd, key) {
|
|
|
33
29
|
* repository-local default is set so `git commit` does not fail with
|
|
34
30
|
* "Please tell me who you are".
|
|
35
31
|
*/
|
|
36
|
-
function ensureGitIdentity(cwd) {
|
|
32
|
+
export function ensureGitIdentity(cwd) {
|
|
37
33
|
if (!hasGitConfig(cwd, "user.name")) {
|
|
38
|
-
|
|
34
|
+
execFileSync("git", ["config", "user.name", DEFAULT_GIT_AUTHOR_NAME], {
|
|
39
35
|
cwd,
|
|
40
36
|
stdio: ["ignore", "pipe", "ignore"],
|
|
41
37
|
});
|
|
42
38
|
}
|
|
43
39
|
if (!hasGitConfig(cwd, "user.email")) {
|
|
44
|
-
|
|
40
|
+
execFileSync("git", ["config", "user.email", DEFAULT_GIT_AUTHOR_EMAIL], {
|
|
45
41
|
cwd,
|
|
46
42
|
stdio: ["ignore", "pipe", "ignore"],
|
|
47
43
|
});
|
package/dist/git/repo-url.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.resolveRepositoryWebBaseUrl = resolveRepositoryWebBaseUrl;
|
|
4
|
-
const node_child_process_1 = require("node:child_process");
|
|
5
|
-
function resolveRepositoryWebBaseUrl(cwd) {
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
export function resolveRepositoryWebBaseUrl(cwd) {
|
|
6
3
|
const server = process.env.GITHUB_SERVER_URL;
|
|
7
4
|
const slug = process.env.GITHUB_REPOSITORY;
|
|
8
5
|
if (server && slug) {
|
|
9
6
|
return `${server.replace(/\/+$/u, "")}/${slug}`;
|
|
10
7
|
}
|
|
11
8
|
try {
|
|
12
|
-
const remote =
|
|
9
|
+
const remote = execFileSync("git", ["remote", "get-url", "origin"], {
|
|
13
10
|
cwd,
|
|
14
11
|
encoding: "utf8",
|
|
15
12
|
stdio: ["ignore", "pipe", "ignore"],
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "verifyProject", { enumerable: true, get: function () { return verify_project_js_1.verifyProject; } });
|
|
8
|
-
var capabilities_js_1 = require("./scm/capabilities.js");
|
|
9
|
-
Object.defineProperty(exports, "findPluginsByCapability", { enumerable: true, get: function () { return capabilities_js_1.findPluginsByCapability; } });
|
|
10
|
-
Object.defineProperty(exports, "pluginHasCapability", { enumerable: true, get: function () { return capabilities_js_1.pluginHasCapability; } });
|
|
11
|
-
var client_js_1 = require("./scm/client.js");
|
|
12
|
-
Object.defineProperty(exports, "getScmClient", { enumerable: true, get: function () { return client_js_1.getScmClient; } });
|
|
13
|
-
var github_plugin_js_1 = require("./scm/github-plugin.js");
|
|
14
|
-
Object.defineProperty(exports, "createGitHubPlugin", { enumerable: true, get: function () { return github_plugin_js_1.createGitHubPlugin; } });
|
|
15
|
-
var resolve_js_1 = require("./strategy/resolve.js");
|
|
16
|
-
Object.defineProperty(exports, "resolveVersionStrategy", { enumerable: true, get: function () { return resolve_js_1.resolveVersionStrategy; } });
|
|
1
|
+
export { loadConfig } from "./config/load-config.js";
|
|
2
|
+
export { verifyProject } from "./release/verify-project.js";
|
|
3
|
+
export { findPluginsByCapability, pluginHasCapability, } from "./scm/capabilities.js";
|
|
4
|
+
export { getScmClient } from "./scm/client.js";
|
|
5
|
+
export { createGitHubPlugin } from "./scm/github-plugin.js";
|
|
6
|
+
export { resolveVersionStrategy } from "./strategy/resolve.js";
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.applyConfiguredArtifactRules = applyConfiguredArtifactRules;
|
|
7
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
9
|
-
const toml_1 = __importDefault(require("@iarna/toml"));
|
|
10
|
-
const yaml_1 = __importDefault(require("yaml"));
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { parse as parseToml, stringify as stringifyToml } from "smol-toml";
|
|
4
|
+
import YAML from "yaml";
|
|
11
5
|
const WILDCARD = Symbol("wildcard");
|
|
12
6
|
function isRecord(value) {
|
|
13
7
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -192,9 +186,9 @@ function applyRegexRule(content, pattern, version) {
|
|
|
192
186
|
function applyTomlRulePreservingFormatting(content, fieldPath, version) {
|
|
193
187
|
const simplePath = fieldPath.match(/^\$\.([A-Za-z0-9_-]+)$/u);
|
|
194
188
|
if (!simplePath) {
|
|
195
|
-
const parsed =
|
|
189
|
+
const parsed = parseToml(content);
|
|
196
190
|
setVersionAtJsonPath(parsed, fieldPath, version);
|
|
197
|
-
return `${
|
|
191
|
+
return `${stringifyToml(parsed)}\n`;
|
|
198
192
|
}
|
|
199
193
|
const key = simplePath[1];
|
|
200
194
|
if (!key) {
|
|
@@ -387,26 +381,26 @@ function applyArtifactRuleToContent(content, rule, version) {
|
|
|
387
381
|
if (rule.type === "nix") {
|
|
388
382
|
return applyNixRulePreservingFormatting(content, resolveFieldPath(rule), version);
|
|
389
383
|
}
|
|
390
|
-
const parsed =
|
|
384
|
+
const parsed = YAML.parse(content);
|
|
391
385
|
setVersionAtJsonPath(parsed, resolveFieldPath(rule), version);
|
|
392
|
-
return `${
|
|
386
|
+
return `${YAML.stringify(parsed)}`;
|
|
393
387
|
}
|
|
394
388
|
function normalizeRelative(base, target) {
|
|
395
|
-
return
|
|
389
|
+
return path.relative(base, target).replaceAll("\\", "/");
|
|
396
390
|
}
|
|
397
391
|
function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version) {
|
|
398
392
|
const rules = packageConfig["extra-files"] ?? [];
|
|
399
393
|
if (rules.length === 0) {
|
|
400
394
|
return [];
|
|
401
395
|
}
|
|
402
|
-
const packageBase =
|
|
396
|
+
const packageBase = path.join(cwd, packagePath);
|
|
403
397
|
const updated = [];
|
|
404
398
|
for (const rule of rules) {
|
|
405
|
-
const targetPath =
|
|
406
|
-
if (!
|
|
399
|
+
const targetPath = path.join(packageBase, rule.path);
|
|
400
|
+
if (!fs.existsSync(targetPath)) {
|
|
407
401
|
throw new Error(`Artifact rule target missing for package "${packagePath}": ${rule.path}`);
|
|
408
402
|
}
|
|
409
|
-
const existing =
|
|
403
|
+
const existing = fs.readFileSync(targetPath, "utf8");
|
|
410
404
|
let next;
|
|
411
405
|
try {
|
|
412
406
|
next = applyArtifactRuleToContent(existing, rule, version);
|
|
@@ -415,12 +409,12 @@ function applyArtifactRulesForPackage(cwd, packagePath, packageConfig, version)
|
|
|
415
409
|
const message = error instanceof Error ? error.message : String(error);
|
|
416
410
|
throw new Error(`Failed applying artifact rule (${rule.type}) for package "${packagePath}" file "${rule.path}": ${message}`);
|
|
417
411
|
}
|
|
418
|
-
|
|
412
|
+
fs.writeFileSync(targetPath, next, "utf8");
|
|
419
413
|
updated.push(normalizeRelative(cwd, targetPath));
|
|
420
414
|
}
|
|
421
415
|
return updated;
|
|
422
416
|
}
|
|
423
|
-
function applyConfiguredArtifactRules(cwd, config, plan) {
|
|
417
|
+
export function applyConfiguredArtifactRules(cwd, config, plan) {
|
|
424
418
|
const packageConfigs = config.packages ?? {};
|
|
425
419
|
if (!plan.packages || plan.packages.length === 0) {
|
|
426
420
|
return [];
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
exports.renderReleaseNotesSection = renderReleaseNotesSection;
|
|
7
|
-
exports.renderReviewRequestFooter = renderReviewRequestFooter;
|
|
8
|
-
exports.renderReleasePlanChangelog = renderReleasePlanChangelog;
|
|
9
|
-
exports.renderSimpleChangelog = renderSimpleChangelog;
|
|
10
|
-
exports.prependChangelog = prependChangelog;
|
|
11
|
-
exports.renderRNewsReleaseNotes = renderRNewsReleaseNotes;
|
|
12
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
13
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
14
|
-
const commits_js_1 = require("../git/commits.js");
|
|
15
|
-
const repo_url_js_1 = require("../git/repo-url.js");
|
|
16
|
-
const plan_js_1 = require("./plan.js");
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { applyRevertSuppression, inferReleaseTypeFromParsedCommit, parseConventionalCommitMessage, } from "../git/commits.js";
|
|
4
|
+
import { resolveRepositoryWebBaseUrl } from "../git/repo-url.js";
|
|
5
|
+
import { resolvePackageDependencies, } from "./plan.js";
|
|
17
6
|
const REVIEW_REQUEST_FOOTER = "---\n\nThis PR was generated by [Versionary](https://github.com/jolars/versionary).";
|
|
18
7
|
function formatDate() {
|
|
19
8
|
return new Date().toISOString().slice(0, 10);
|
|
@@ -78,7 +67,7 @@ function groupCommitLines(commits, repoUrl) {
|
|
|
78
67
|
const fixes = [];
|
|
79
68
|
const performance = [];
|
|
80
69
|
const reverts = [];
|
|
81
|
-
const effectiveCommits =
|
|
70
|
+
const effectiveCommits = applyRevertSuppression(commits);
|
|
82
71
|
const getRevertedSubject = (commit) => {
|
|
83
72
|
const normalizedDescription = (commit.description ?? "")
|
|
84
73
|
.trim()
|
|
@@ -98,11 +87,11 @@ function groupCommitLines(commits, repoUrl) {
|
|
|
98
87
|
if (revertedSubject.length === 0) {
|
|
99
88
|
return true;
|
|
100
89
|
}
|
|
101
|
-
const revertedCommit =
|
|
102
|
-
return
|
|
90
|
+
const revertedCommit = parseConventionalCommitMessage(revertedSubject);
|
|
91
|
+
return inferReleaseTypeFromParsedCommit(revertedCommit) !== null;
|
|
103
92
|
};
|
|
104
93
|
for (const commit of effectiveCommits) {
|
|
105
|
-
const type =
|
|
94
|
+
const type = inferReleaseTypeFromParsedCommit(commit);
|
|
106
95
|
if (!type) {
|
|
107
96
|
continue;
|
|
108
97
|
}
|
|
@@ -140,8 +129,8 @@ function groupCommitLines(commits, repoUrl) {
|
|
|
140
129
|
}
|
|
141
130
|
return { breaking, features, fixes, performance, reverts };
|
|
142
131
|
}
|
|
143
|
-
function renderReleaseNotesSection(input, options = {}) {
|
|
144
|
-
const repoUrl =
|
|
132
|
+
export function renderReleaseNotesSection(input, options = {}) {
|
|
133
|
+
const repoUrl = resolveRepositoryWebBaseUrl(input.cwd ?? process.cwd());
|
|
145
134
|
const headerLabel = input.headerLabel ?? input.nextVersion;
|
|
146
135
|
const versionPrefix = input.tagPrefix ? `${input.tagPrefix}-v` : "v";
|
|
147
136
|
const header = repoUrl
|
|
@@ -177,10 +166,10 @@ function renderReleaseNotesSection(input, options = {}) {
|
|
|
177
166
|
}
|
|
178
167
|
return body;
|
|
179
168
|
}
|
|
180
|
-
function renderReviewRequestFooter() {
|
|
169
|
+
export function renderReviewRequestFooter() {
|
|
181
170
|
return REVIEW_REQUEST_FOOTER;
|
|
182
171
|
}
|
|
183
|
-
function renderReleasePlanChangelog(plan, options = {}) {
|
|
172
|
+
export function renderReleasePlanChangelog(plan, options = {}) {
|
|
184
173
|
if (!plan.nextVersion) {
|
|
185
174
|
return "";
|
|
186
175
|
}
|
|
@@ -201,7 +190,7 @@ function renderReleasePlanChangelog(plan, options = {}) {
|
|
|
201
190
|
nextVersion: plan.nextVersion,
|
|
202
191
|
commits: dedupedCommits,
|
|
203
192
|
cwd: options.cwd ?? process.cwd(),
|
|
204
|
-
dependencies:
|
|
193
|
+
dependencies: resolvePackageDependencies(plan, "."),
|
|
205
194
|
highlights: options.highlights,
|
|
206
195
|
headerLabel: options.headerLabel,
|
|
207
196
|
}, {
|
|
@@ -209,29 +198,29 @@ function renderReleasePlanChangelog(plan, options = {}) {
|
|
|
209
198
|
});
|
|
210
199
|
}
|
|
211
200
|
/** @deprecated Use renderReleasePlanChangelog. */
|
|
212
|
-
function renderSimpleChangelog(plan) {
|
|
201
|
+
export function renderSimpleChangelog(plan) {
|
|
213
202
|
return renderReleasePlanChangelog(plan);
|
|
214
203
|
}
|
|
215
|
-
function prependChangelog(cwd, changelogFile, section, format = "markdown-changelog") {
|
|
216
|
-
const changelogPath =
|
|
217
|
-
const existing =
|
|
218
|
-
?
|
|
204
|
+
export function prependChangelog(cwd, changelogFile, section, format = "markdown-changelog") {
|
|
205
|
+
const changelogPath = path.join(cwd, changelogFile);
|
|
206
|
+
const existing = fs.existsSync(changelogPath)
|
|
207
|
+
? fs.readFileSync(changelogPath, "utf8")
|
|
219
208
|
: "";
|
|
220
209
|
if (format === "r-news") {
|
|
221
210
|
const bodyWithoutDevHeader = existing.replace(/^#\s+.+\s+\(development version\)\s*(?:\r?\n)*/u, "");
|
|
222
211
|
const separator = bodyWithoutDevHeader.length > 0 ? "\n\n" : "";
|
|
223
212
|
const next = `${`${section}${separator}${bodyWithoutDevHeader}`.trimEnd()}\n`;
|
|
224
|
-
|
|
213
|
+
fs.writeFileSync(changelogPath, next, "utf8");
|
|
225
214
|
return;
|
|
226
215
|
}
|
|
227
216
|
const heading = "# Changelog\n\n";
|
|
228
217
|
const bodyWithoutHeading = existing.replace(/^# Changelog\s*/u, "");
|
|
229
218
|
const separator = bodyWithoutHeading.length > 0 ? "\n\n" : "";
|
|
230
219
|
const next = `${`${heading}${section}${separator}${bodyWithoutHeading}`.trimEnd()}\n`;
|
|
231
|
-
|
|
220
|
+
fs.writeFileSync(changelogPath, next, "utf8");
|
|
232
221
|
}
|
|
233
|
-
function renderRNewsReleaseNotes(input) {
|
|
234
|
-
const repoUrl =
|
|
222
|
+
export function renderRNewsReleaseNotes(input) {
|
|
223
|
+
const repoUrl = resolveRepositoryWebBaseUrl(input.cwd ?? process.cwd());
|
|
235
224
|
const grouped = groupCommitLines(input.commits, repoUrl);
|
|
236
225
|
const normalizedVersion = input.nextVersion.replace(/\.\d+$/u, "");
|
|
237
226
|
const sections = [];
|
package/dist/release/plan.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.resolvePackageDependencies = resolvePackageDependencies;
|
|
10
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
11
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
-
const load_config_js_1 = require("../config/load-config.js");
|
|
13
|
-
const commits_js_1 = require("../git/commits.js");
|
|
14
|
-
const package_context_js_1 = require("../strategy/package-context.js");
|
|
15
|
-
const resolve_js_1 = require("../strategy/resolve.js");
|
|
16
|
-
const semver_js_1 = require("./semver.js");
|
|
17
|
-
const state_js_1 = require("./state.js");
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { loadConfig } from "../config/load-config.js";
|
|
4
|
+
import { analyzeParsedCommits, applyRevertSuppression, getParsedCommitsForPath, getParsedCommitsSinceLastTag, } from "../git/commits.js";
|
|
5
|
+
import { resolvePackageStrategyContext } from "../strategy/package-context.js";
|
|
6
|
+
import { resolveVersionStrategy } from "../strategy/resolve.js";
|
|
7
|
+
import { bumpVersion, maxReleaseType } from "./semver.js";
|
|
8
|
+
import { readBaselineSha, readReleaseTargets } from "./state.js";
|
|
18
9
|
function getMode(configMode) {
|
|
19
10
|
return configMode ?? "independent";
|
|
20
11
|
}
|
|
21
|
-
function getChangelogDefaults(config) {
|
|
12
|
+
export function getChangelogDefaults(config) {
|
|
22
13
|
const changelogFormat = config["changelog-format"] ??
|
|
23
14
|
config.defaultChangelogFormat ??
|
|
24
15
|
"markdown-changelog";
|
|
@@ -40,9 +31,9 @@ function getNormalizedPackages(config) {
|
|
|
40
31
|
}
|
|
41
32
|
return [{ path: ".", config: {}, implicitRoot: true }, ...configured];
|
|
42
33
|
}
|
|
43
|
-
function createReleasePlan(cwd = process.cwd()) {
|
|
44
|
-
const loaded =
|
|
45
|
-
const strategy =
|
|
34
|
+
export function createReleasePlan(cwd = process.cwd()) {
|
|
35
|
+
const loaded = loadConfig(cwd);
|
|
36
|
+
const strategy = resolveVersionStrategy(loaded.config);
|
|
46
37
|
const configuredPackageCount = Object.keys(loaded.config.packages ?? {}).length;
|
|
47
38
|
const hasPackages = configuredPackageCount > 0;
|
|
48
39
|
const hasExplicitRootPackage = Boolean(loaded.config.packages?.["."]);
|
|
@@ -53,28 +44,28 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
53
44
|
defaultChangelogFormat: strategy.getDefaultChangelogFormat?.(),
|
|
54
45
|
});
|
|
55
46
|
const packageName = hasPackages
|
|
56
|
-
?
|
|
57
|
-
: (strategy.readPackageName?.(cwd, loaded.config) ??
|
|
47
|
+
? path.basename(cwd)
|
|
48
|
+
: (strategy.readPackageName?.(cwd, loaded.config) ?? path.basename(cwd));
|
|
58
49
|
const releaseBranchPrefix = loaded.config["release-branch"] ?? "versionary/release";
|
|
59
|
-
const baselineSha =
|
|
60
|
-
const releaseTargetByPath = new Map(
|
|
50
|
+
const baselineSha = readBaselineSha(cwd) ?? loaded.config["bootstrap-sha"] ?? null;
|
|
51
|
+
const releaseTargetByPath = new Map(readReleaseTargets(cwd).map((target) => [target.path, target]));
|
|
61
52
|
const allowStableMajor = loaded.config["allow-stable-major"] ?? false;
|
|
62
53
|
const monorepoMode = getMode(loaded.config["monorepo-mode"]);
|
|
63
54
|
const buildPackagePlan = (pkg) => {
|
|
64
|
-
const packageContext =
|
|
65
|
-
const currentVersionFile =
|
|
66
|
-
if (!
|
|
55
|
+
const packageContext = resolvePackageStrategyContext(loaded.config, pkg.path, pkg.config);
|
|
56
|
+
const currentVersionFile = path.join(cwd, packageContext.versionFile);
|
|
57
|
+
if (!fs.existsSync(currentVersionFile)) {
|
|
67
58
|
throw new Error(`Versionary requires ${packageContext.versionFile} to exist for package "${pkg.path}".`);
|
|
68
59
|
}
|
|
69
60
|
const packageCurrentVersion = packageContext.strategy.readVersion(cwd, packageContext.config);
|
|
70
61
|
const parsedCommits = !hasPackages && pkg.path === "."
|
|
71
|
-
?
|
|
72
|
-
:
|
|
73
|
-
const effectiveCommits =
|
|
62
|
+
? getParsedCommitsSinceLastTag(cwd, baselineSha)
|
|
63
|
+
: getParsedCommitsForPath(cwd, releaseTargetByPath.get(pkg.path)?.tag ?? baselineSha, pkg.path, pkg.config["exclude-paths"] ?? []);
|
|
64
|
+
const effectiveCommits = applyRevertSuppression(parsedCommits);
|
|
74
65
|
const commits = effectiveCommits;
|
|
75
|
-
const releaseType =
|
|
66
|
+
const releaseType = analyzeParsedCommits(parsedCommits);
|
|
76
67
|
const nextVersion = releaseType
|
|
77
|
-
?
|
|
68
|
+
? bumpVersion(packageCurrentVersion, releaseType, { allowStableMajor })
|
|
78
69
|
: null;
|
|
79
70
|
return {
|
|
80
71
|
path: pkg.path,
|
|
@@ -115,7 +106,7 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
115
106
|
const strategyPackagesByName = new Map();
|
|
116
107
|
for (const packagePlan of packagePlans) {
|
|
117
108
|
const packageConfig = loaded.config.packages?.[packagePlan.path] ?? {};
|
|
118
|
-
const packageContext =
|
|
109
|
+
const packageContext = resolvePackageStrategyContext(loaded.config, packagePlan.path, packageConfig);
|
|
119
110
|
const existingGroup = strategyPackagesByName.get(packageContext.strategy.name);
|
|
120
111
|
if (existingGroup) {
|
|
121
112
|
existingGroup.packages.push({
|
|
@@ -194,7 +185,7 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
194
185
|
return {
|
|
195
186
|
...pkgPlan,
|
|
196
187
|
releaseType: "patch",
|
|
197
|
-
nextVersion:
|
|
188
|
+
nextVersion: bumpVersion(current, "patch", { allowStableMajor }),
|
|
198
189
|
bumpReason: "dependency-propagation",
|
|
199
190
|
dependencySourcePaths,
|
|
200
191
|
};
|
|
@@ -215,7 +206,7 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
215
206
|
return pkgPlan;
|
|
216
207
|
}
|
|
217
208
|
const ownReleaseType = pkgPlan.releaseType;
|
|
218
|
-
const combinedReleaseType =
|
|
209
|
+
const combinedReleaseType = maxReleaseType([
|
|
219
210
|
ownReleaseType,
|
|
220
211
|
...bumpingSources.map((sourcePlan) => sourcePlan.releaseType),
|
|
221
212
|
]);
|
|
@@ -230,7 +221,7 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
230
221
|
pkgPlan.bumpReason === undefined;
|
|
231
222
|
const baseVersion = packageCurrentVersionByPath[pkgPlan.path] ?? pkgPlan.currentVersion;
|
|
232
223
|
const nextVersion = combinedReleaseType
|
|
233
|
-
?
|
|
224
|
+
? bumpVersion(baseVersion, combinedReleaseType, { allowStableMajor })
|
|
234
225
|
: null;
|
|
235
226
|
return {
|
|
236
227
|
...pkgPlan,
|
|
@@ -261,10 +252,10 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
261
252
|
};
|
|
262
253
|
}
|
|
263
254
|
if (monorepoMode === "fixed") {
|
|
264
|
-
const fixedType =
|
|
255
|
+
const fixedType = analyzeParsedCommits(adjustedPackages.flatMap((pkgPlan) => pkgPlan.parsedCommits));
|
|
265
256
|
const fixedBaseVersion = rootPackagePlan.currentVersion;
|
|
266
257
|
const fixedNextVersion = fixedType
|
|
267
|
-
?
|
|
258
|
+
? bumpVersion(fixedBaseVersion, fixedType, { allowStableMajor })
|
|
268
259
|
: null;
|
|
269
260
|
const adjusted = adjustedPackages.map((pkgPlan) => ({
|
|
270
261
|
...pkgPlan,
|
|
@@ -288,10 +279,10 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
288
279
|
.map(({ implicitRoot: _implicitRoot, ...pkgPlan }) => pkgPlan),
|
|
289
280
|
};
|
|
290
281
|
}
|
|
291
|
-
const overallType =
|
|
282
|
+
const overallType = analyzeParsedCommits(adjustedPackages.flatMap((pkgPlan) => pkgPlan.parsedCommits));
|
|
292
283
|
const overallBaseVersion = rootPackagePlan.currentVersion;
|
|
293
284
|
const overallNextVersion = overallType
|
|
294
|
-
?
|
|
285
|
+
? bumpVersion(overallBaseVersion, overallType, { allowStableMajor })
|
|
295
286
|
: null;
|
|
296
287
|
return {
|
|
297
288
|
mode: "simple",
|
|
@@ -309,10 +300,10 @@ function createReleasePlan(cwd = process.cwd()) {
|
|
|
309
300
|
};
|
|
310
301
|
}
|
|
311
302
|
/** @deprecated Use createReleasePlan. */
|
|
312
|
-
function createSimplePlan(cwd = process.cwd()) {
|
|
303
|
+
export function createSimplePlan(cwd = process.cwd()) {
|
|
313
304
|
return createReleasePlan(cwd);
|
|
314
305
|
}
|
|
315
|
-
function resolvePackageDependencies(plan, packagePath) {
|
|
306
|
+
export function resolvePackageDependencies(plan, packagePath) {
|
|
316
307
|
const target = plan.packages?.find((pkg) => pkg.path === packagePath);
|
|
317
308
|
if (!target) {
|
|
318
309
|
return [];
|