@varlock/bumpy 1.2.0 → 1.2.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/README.md +49 -34
- package/dist/{add-yP81c9_q.mjs → add-DEqGa5gI.mjs} +8 -8
- package/dist/apply-release-plan-Bi9OSWks.mjs +57 -0
- package/dist/{bump-file-Br2bTaWp.mjs → bump-file-BTsntOO-.mjs} +63 -24
- package/dist/{changelog-github-DkACMj0j.mjs → changelog-github-CEaDCtTk.mjs} +49 -18
- package/dist/changelog-xKuL0IKx.mjs +109 -0
- package/dist/{check-D_0exKi6.mjs → check-D3eXRyKJ.mjs} +12 -7
- package/dist/{ci-CvaikKX1.mjs → ci-BVTwTUUK.mjs} +131 -40
- package/dist/{ci-setup-CARJFhcE.mjs → ci-setup-D1NCzbNH.mjs} +3 -3
- package/dist/cli.mjs +14 -14
- package/dist/{config-D7Umr-fT.mjs → config-CJIj8xG3.mjs} +2 -80
- package/dist/{generate-BOLrTYWR.mjs → generate-wHN6Ll6p.mjs} +6 -6
- package/dist/{git-YDedMddc.mjs → git-D0__HP86.mjs} +11 -2
- package/dist/index.d.mts +14 -4
- package/dist/index.mjs +10 -8
- package/dist/{init-DJhMaceS.mjs → init-DND7zRGD.mjs} +3 -3
- package/dist/{publish-CPZwqyWh.mjs → publish-BwidFqbo.mjs} +9 -9
- package/dist/{publish-pipeline-BFt96o_h.mjs → publish-pipeline-BvLIu7WF.mjs} +4 -4
- package/dist/{release-plan-CNOuSI-d.mjs → release-plan-21H89Cx1.mjs} +3 -2
- package/dist/{status-skGX8uU7.mjs → status-CDGxgXWd.mjs} +39 -18
- package/dist/types-CSM0c2-m.mjs +80 -0
- package/dist/{version-CnXcbqi1.mjs → version-ClkaCNTE.mjs} +14 -10
- package/dist/{workspace-BHsAPUmC.mjs → workspace-c9-TqXed.mjs} +2 -2
- package/package.json +1 -1
- package/dist/apply-release-plan-CPzu6JcF.mjs +0 -146
- /package/dist/{ai-STKnq09z.mjs → ai-C66IfTzs.mjs} +0 -0
- /package/dist/{clack-C6bVkGxf.mjs → clack-CJT1JFFa.mjs} +0 -0
- /package/dist/{commit-message-BwsowSds.mjs → commit-message-DOIfDxfj.mjs} +0 -0
- /package/dist/{dep-graph-DiLeAhl9.mjs → dep-graph-E-9-eQ2J.mjs} +0 -0
- /package/dist/{names-C-TuOPbd.mjs → names-CBy7d8K_.mjs} +0 -0
- /package/dist/{package-manager-ByJ0wKYh.mjs → package-manager-CClZtIHP.mjs} +0 -0
- /package/dist/{picomatch-DMmqYjgq.mjs → picomatch-TGJi--_I.mjs} +0 -0
- /package/dist/{semver-BJzWIuRz.mjs → semver-DfQyVLM_.mjs} +0 -0
- /package/dist/{shell-CY7OD48z.mjs → shell-u3bYGxNy.mjs} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
1
|
+
import { a as DEP_TYPES, c as maxBump, i as DEFAULT_PUBLISH_CONFIG, n as DEFAULT_BUMP_RULES, o as bumpLevel, r as DEFAULT_CONFIG, s as hasCascade, t as BUMP_LEVELS } from "./types-CSM0c2-m.mjs";
|
|
2
|
+
import { a as loadConfig, n as findRoot, r as getBumpyDir, s as matchGlob } from "./config-CJIj8xG3.mjs";
|
|
3
|
+
import { t as discoverPackages } from "./workspace-c9-TqXed.mjs";
|
|
4
|
+
import { t as DependencyGraph } from "./dep-graph-E-9-eQ2J.mjs";
|
|
5
|
+
import { i as writeBumpFile, n as parseBumpFile, r as readBumpFiles } from "./bump-file-BTsntOO-.mjs";
|
|
6
|
+
import { n as satisfies, r as stripProtocol, t as bumpVersion } from "./semver-DfQyVLM_.mjs";
|
|
7
|
+
import { t as assembleReleasePlan } from "./release-plan-21H89Cx1.mjs";
|
|
8
|
+
import { a as prependToChangelog, i as loadFormatter, n as generateChangelogEntry, t as defaultFormatter } from "./changelog-xKuL0IKx.mjs";
|
|
9
|
+
import { t as applyReleasePlan } from "./apply-release-plan-Bi9OSWks.mjs";
|
|
10
|
+
import { t as publishPackages } from "./publish-pipeline-BvLIu7WF.mjs";
|
|
9
11
|
export { BUMP_LEVELS, DEFAULT_BUMP_RULES, DEFAULT_CONFIG, DEFAULT_PUBLISH_CONFIG, DEP_TYPES, DependencyGraph, applyReleasePlan, assembleReleasePlan, bumpLevel, bumpVersion, defaultFormatter, discoverPackages, findRoot, generateChangelogEntry, getBumpyDir, hasCascade, loadConfig, loadFormatter, matchGlob, maxBump, parseBumpFile, prependToChangelog, publishPackages, readBumpFiles, satisfies, stripProtocol, writeBumpFile };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { n as log, o as __toESM, r as require_picocolors } from "./logger-C2dEe5Su.mjs";
|
|
2
2
|
import { a as readJson, d as writeJson, f as writeText, i as listFiles, n as exists, s as readText, t as ensureDir } from "./fs-DnDogVn-.mjs";
|
|
3
|
-
import { t as detectPackageManager } from "./package-manager-
|
|
4
|
-
import { t as run } from "./shell-
|
|
5
|
-
import { c as ot, o as gt, s as mt, t as unwrap } from "./clack-
|
|
3
|
+
import { t as detectPackageManager } from "./package-manager-CClZtIHP.mjs";
|
|
4
|
+
import { t as run } from "./shell-u3bYGxNy.mjs";
|
|
5
|
+
import { c as ot, o as gt, s as mt, t as unwrap } from "./clack-CJT1JFFa.mjs";
|
|
6
6
|
import { resolve } from "node:path";
|
|
7
7
|
import { readdir, rename, rm } from "node:fs/promises";
|
|
8
8
|
//#region ../../.bumpy/README.md
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as log, t as colorize } from "./logger-C2dEe5Su.mjs";
|
|
2
|
-
import { a as loadConfig } from "./config-
|
|
3
|
-
import { n as detectWorkspaces } from "./package-manager-
|
|
4
|
-
import { n as discoverWorkspace } from "./workspace-
|
|
5
|
-
import { t as DependencyGraph } from "./dep-graph-
|
|
6
|
-
import { r as runArgsAsync, s as tryRunArgs } from "./shell-
|
|
7
|
-
import {
|
|
8
|
-
import { t as publishPackages } from "./publish-pipeline-
|
|
2
|
+
import { a as loadConfig } from "./config-CJIj8xG3.mjs";
|
|
3
|
+
import { n as detectWorkspaces } from "./package-manager-CClZtIHP.mjs";
|
|
4
|
+
import { n as discoverWorkspace } from "./workspace-c9-TqXed.mjs";
|
|
5
|
+
import { t as DependencyGraph } from "./dep-graph-E-9-eQ2J.mjs";
|
|
6
|
+
import { r as runArgsAsync, s as tryRunArgs } from "./shell-u3bYGxNy.mjs";
|
|
7
|
+
import { c as pushWithTags, o as hasUncommittedChanges, s as listTags } from "./git-D0__HP86.mjs";
|
|
8
|
+
import { t as publishPackages } from "./publish-pipeline-BvLIu7WF.mjs";
|
|
9
9
|
//#region src/core/github-release.ts
|
|
10
10
|
/** Get the current HEAD commit SHA */
|
|
11
11
|
function getHeadSha(rootDir) {
|
|
@@ -148,7 +148,7 @@ async function publishCommand(rootDir, opts) {
|
|
|
148
148
|
}
|
|
149
149
|
let toPublish = await findUnpublishedPackages(packages, config);
|
|
150
150
|
if (opts.filter) {
|
|
151
|
-
const { matchGlob } = await import("./config-
|
|
151
|
+
const { matchGlob } = await import("./config-CJIj8xG3.mjs").then((n) => n.t);
|
|
152
152
|
const patterns = opts.filter.split(",").map((p) => p.trim());
|
|
153
153
|
toPublish = toPublish.filter((r) => patterns.some((p) => matchGlob(r.name, p)));
|
|
154
154
|
}
|
|
@@ -220,7 +220,7 @@ async function findUnpublishedPackages(packages, _config) {
|
|
|
220
220
|
return unpublished;
|
|
221
221
|
}
|
|
222
222
|
async function checkIfPublished(name, version, pkgConfig) {
|
|
223
|
-
const { runAsync, runArgsAsync, tryRunArgs } = await import("./shell-
|
|
223
|
+
const { runAsync, runArgsAsync, tryRunArgs } = await import("./shell-u3bYGxNy.mjs").then((n) => n.a);
|
|
224
224
|
if (pkgConfig?.checkPublished) try {
|
|
225
225
|
return (await runAsync(pkgConfig.checkPublished)).trim() === version;
|
|
226
226
|
} catch {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { n as log, t as colorize } from "./logger-C2dEe5Su.mjs";
|
|
2
2
|
import { a as readJson, u as updateJsonNestedField } from "./fs-DnDogVn-.mjs";
|
|
3
|
-
import { r as resolveCatalogDep } from "./package-manager-
|
|
4
|
-
import { i as runAsync, o as sq, r as runArgsAsync, s as tryRunArgs } from "./shell-
|
|
5
|
-
import { r as stripProtocol } from "./semver-
|
|
6
|
-
import {
|
|
3
|
+
import { r as resolveCatalogDep } from "./package-manager-CClZtIHP.mjs";
|
|
4
|
+
import { i as runAsync, o as sq, r as runArgsAsync, s as tryRunArgs } from "./shell-u3bYGxNy.mjs";
|
|
5
|
+
import { r as stripProtocol } from "./semver-DfQyVLM_.mjs";
|
|
6
|
+
import { l as tagExists, t as createTag } from "./git-D0__HP86.mjs";
|
|
7
7
|
import { resolve } from "node:path";
|
|
8
8
|
import { unlink } from "node:fs/promises";
|
|
9
9
|
import { appendFileSync, existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { c as maxBump, n as DEFAULT_BUMP_RULES, o as bumpLevel, s as hasCascade } from "./types-CSM0c2-m.mjs";
|
|
2
|
+
import { s as matchGlob } from "./config-CJIj8xG3.mjs";
|
|
3
|
+
import { n as satisfies, t as bumpVersion } from "./semver-DfQyVLM_.mjs";
|
|
3
4
|
//#region src/core/release-plan.ts
|
|
4
5
|
/**
|
|
5
6
|
* Build a release plan from pending bump files, the dependency graph, and config.
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { n as log, t as colorize } from "./logger-C2dEe5Su.mjs";
|
|
2
|
-
import { a as loadConfig } from "./config-
|
|
3
|
-
import { t as discoverPackages } from "./workspace-
|
|
4
|
-
import { t as DependencyGraph } from "./dep-graph-
|
|
5
|
-
import { r as readBumpFiles } from "./bump-file-
|
|
6
|
-
import { t as assembleReleasePlan } from "./release-plan-
|
|
2
|
+
import { a as loadConfig } from "./config-CJIj8xG3.mjs";
|
|
3
|
+
import { t as discoverPackages } from "./workspace-c9-TqXed.mjs";
|
|
4
|
+
import { t as DependencyGraph } from "./dep-graph-E-9-eQ2J.mjs";
|
|
5
|
+
import { r as readBumpFiles, t as filterBranchBumpFiles } from "./bump-file-BTsntOO-.mjs";
|
|
6
|
+
import { t as assembleReleasePlan } from "./release-plan-21H89Cx1.mjs";
|
|
7
|
+
import { i as getCurrentBranch, r as getChangedFiles } from "./git-D0__HP86.mjs";
|
|
7
8
|
//#region src/commands/status.ts
|
|
8
9
|
async function statusCommand(rootDir, opts) {
|
|
9
10
|
const config = await loadConfig(rootDir);
|
|
10
11
|
const packages = await discoverPackages(rootDir, config);
|
|
11
12
|
const depGraph = new DependencyGraph(packages);
|
|
12
|
-
const bumpFiles = await readBumpFiles(rootDir);
|
|
13
|
+
const { bumpFiles, errors: parseErrors } = await readBumpFiles(rootDir);
|
|
14
|
+
if (parseErrors.length > 0) for (const err of parseErrors) log.error(err);
|
|
13
15
|
if (bumpFiles.length === 0) {
|
|
14
16
|
if (opts.json) console.log(JSON.stringify({
|
|
15
17
|
bumpFiles: [],
|
|
@@ -20,13 +22,16 @@ async function statusCommand(rootDir, opts) {
|
|
|
20
22
|
process.exit(1);
|
|
21
23
|
}
|
|
22
24
|
const plan = assembleReleasePlan(bumpFiles, packages, depGraph, config);
|
|
25
|
+
let branchBumpFileIds;
|
|
26
|
+
const currentBranch = getCurrentBranch({ cwd: rootDir });
|
|
27
|
+
if (currentBranch && currentBranch !== config.baseBranch) branchBumpFileIds = filterBranchBumpFiles(bumpFiles, getChangedFiles(rootDir, config.baseBranch), rootDir).branchBumpFileIds;
|
|
23
28
|
let releases = plan.releases;
|
|
24
29
|
if (opts.bumpType) {
|
|
25
30
|
const types = opts.bumpType.split(",").map((t) => t.trim());
|
|
26
31
|
releases = releases.filter((r) => types.includes(r.type));
|
|
27
32
|
}
|
|
28
33
|
if (opts.filter) {
|
|
29
|
-
const { matchGlob } = await import("./config-
|
|
34
|
+
const { matchGlob } = await import("./config-CJIj8xG3.mjs").then((n) => n.t);
|
|
30
35
|
const patterns = opts.filter.split(",").map((p) => p.trim());
|
|
31
36
|
releases = releases.filter((r) => patterns.some((p) => matchGlob(r.name, p)));
|
|
32
37
|
}
|
|
@@ -38,18 +43,25 @@ async function statusCommand(rootDir, opts) {
|
|
|
38
43
|
releases: bf.releases.map((r) => ({
|
|
39
44
|
name: r.name,
|
|
40
45
|
type: r.type
|
|
41
|
-
}))
|
|
42
|
-
|
|
43
|
-
releases: releases.map((r) => ({
|
|
44
|
-
name: r.name,
|
|
45
|
-
type: r.type,
|
|
46
|
-
oldVersion: r.oldVersion,
|
|
47
|
-
newVersion: r.newVersion,
|
|
48
|
-
dir: packages.get(r.name)?.relativeDir,
|
|
49
|
-
bumpFiles: r.bumpFiles,
|
|
50
|
-
isDependencyBump: r.isDependencyBump,
|
|
51
|
-
isCascadeBump: r.isCascadeBump
|
|
46
|
+
})),
|
|
47
|
+
...branchBumpFileIds ? { inCurrentBranch: branchBumpFileIds.has(bf.id) } : {}
|
|
52
48
|
})),
|
|
49
|
+
releases: releases.map((r) => {
|
|
50
|
+
const pkg = packages.get(r.name);
|
|
51
|
+
const pkgConfig = pkg?.bumpy || {};
|
|
52
|
+
return {
|
|
53
|
+
name: r.name,
|
|
54
|
+
type: r.type,
|
|
55
|
+
oldVersion: r.oldVersion,
|
|
56
|
+
newVersion: r.newVersion,
|
|
57
|
+
dir: pkg?.relativeDir,
|
|
58
|
+
bumpFiles: r.bumpFiles,
|
|
59
|
+
isDependencyBump: r.isDependencyBump,
|
|
60
|
+
isCascadeBump: r.isCascadeBump,
|
|
61
|
+
...branchBumpFileIds ? { inCurrentBranch: r.bumpFiles.some((id) => branchBumpFileIds.has(id)) } : {},
|
|
62
|
+
publishTargets: getPublishTargets(pkg, pkgConfig, config)
|
|
63
|
+
};
|
|
64
|
+
}),
|
|
53
65
|
packageNames: releases.map((r) => r.name)
|
|
54
66
|
};
|
|
55
67
|
console.log(JSON.stringify(jsonOutput, null, 2));
|
|
@@ -106,5 +118,14 @@ function printRelease(r, packages) {
|
|
|
106
118
|
const suffix = r.isDependencyBump ? colorize(" ← dependency bump", "dim") : r.isCascadeBump ? colorize(" ← cascade", "dim") : "";
|
|
107
119
|
console.log(` ${r.name}: ${r.oldVersion} → ${colorize(r.newVersion, "cyan")}${suffix}${dir}`);
|
|
108
120
|
}
|
|
121
|
+
/** Determine which publish targets a package will use */
|
|
122
|
+
function getPublishTargets(pkg, pkgConfig, _config) {
|
|
123
|
+
if (!pkg) return [];
|
|
124
|
+
if (pkg.private && !pkgConfig.publishCommand) return [];
|
|
125
|
+
const targets = [];
|
|
126
|
+
if (pkgConfig.publishCommand) targets.push("custom");
|
|
127
|
+
if (!pkgConfig.publishCommand && !pkgConfig.skipNpmPublish) targets.push("npm");
|
|
128
|
+
return targets;
|
|
129
|
+
}
|
|
109
130
|
//#endregion
|
|
110
131
|
export { statusCommand };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
const BUMP_LEVELS = {
|
|
3
|
+
patch: 0,
|
|
4
|
+
minor: 1,
|
|
5
|
+
major: 2
|
|
6
|
+
};
|
|
7
|
+
function bumpLevel(type) {
|
|
8
|
+
return BUMP_LEVELS[type];
|
|
9
|
+
}
|
|
10
|
+
function maxBump(a, b) {
|
|
11
|
+
if (!a) return b;
|
|
12
|
+
return bumpLevel(a) >= bumpLevel(b) ? a : b;
|
|
13
|
+
}
|
|
14
|
+
const DEFAULT_BUMP_RULES = {
|
|
15
|
+
dependencies: {
|
|
16
|
+
trigger: "patch",
|
|
17
|
+
bumpAs: "patch"
|
|
18
|
+
},
|
|
19
|
+
peerDependencies: {
|
|
20
|
+
trigger: "major",
|
|
21
|
+
bumpAs: "match"
|
|
22
|
+
},
|
|
23
|
+
devDependencies: false,
|
|
24
|
+
optionalDependencies: {
|
|
25
|
+
trigger: "minor",
|
|
26
|
+
bumpAs: "patch"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const DEP_TYPES = [
|
|
30
|
+
"dependencies",
|
|
31
|
+
"devDependencies",
|
|
32
|
+
"peerDependencies",
|
|
33
|
+
"optionalDependencies"
|
|
34
|
+
];
|
|
35
|
+
const DEFAULT_PUBLISH_CONFIG = {
|
|
36
|
+
packManager: "auto",
|
|
37
|
+
publishManager: "npm",
|
|
38
|
+
publishArgs: [],
|
|
39
|
+
protocolResolution: "pack"
|
|
40
|
+
};
|
|
41
|
+
const DEFAULT_CONFIG = {
|
|
42
|
+
baseBranch: "main",
|
|
43
|
+
access: "public",
|
|
44
|
+
versionCommitMessage: void 0,
|
|
45
|
+
changedFilePatterns: ["**"],
|
|
46
|
+
changelog: "default",
|
|
47
|
+
fixed: [],
|
|
48
|
+
linked: [],
|
|
49
|
+
ignore: [],
|
|
50
|
+
include: [],
|
|
51
|
+
updateInternalDependencies: "out-of-range",
|
|
52
|
+
dependencyBumpRules: {},
|
|
53
|
+
privatePackages: {
|
|
54
|
+
version: false,
|
|
55
|
+
tag: false
|
|
56
|
+
},
|
|
57
|
+
allowCustomCommands: false,
|
|
58
|
+
packages: {},
|
|
59
|
+
publish: { ...DEFAULT_PUBLISH_CONFIG },
|
|
60
|
+
aggregateRelease: false,
|
|
61
|
+
gitUser: {
|
|
62
|
+
name: "bumpy-bot",
|
|
63
|
+
email: "276066384+bumpy-bot@users.noreply.github.com"
|
|
64
|
+
},
|
|
65
|
+
versionPr: {
|
|
66
|
+
title: "🐸 Versioned release",
|
|
67
|
+
branch: "bumpy/version-packages",
|
|
68
|
+
preamble: [
|
|
69
|
+
`<a href="https://bumpy.varlock.dev"><img src="https://raw.githubusercontent.com/dmno-dev/bumpy/main/images/frog-party.png" alt="bumpy-frog" width="60" align="left" style="image-rendering: pixelated;" title="Hi! I'm bumpy!" /></a>`,
|
|
70
|
+
"",
|
|
71
|
+
`This PR was created and will be kept in sync by [bumpy](https://bumpy.varlock.dev) based on your bump files (in \`.bumpy/\`). Merge it when you are ready to release the packages listed below:`,
|
|
72
|
+
"<br clear=\"left\" />"
|
|
73
|
+
].join("\n")
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
function hasCascade(r) {
|
|
77
|
+
return "cascade" in r && Object.keys(r.cascade).length > 0;
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { DEP_TYPES as a, maxBump as c, DEFAULT_PUBLISH_CONFIG as i, DEFAULT_BUMP_RULES as n, bumpLevel as o, DEFAULT_CONFIG as r, hasCascade as s, BUMP_LEVELS as t };
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { n as log, t as colorize } from "./logger-C2dEe5Su.mjs";
|
|
2
|
-
import { a as loadConfig } from "./config-
|
|
3
|
-
import { n as detectWorkspaces } from "./package-manager-
|
|
4
|
-
import { t as discoverPackages } from "./workspace-
|
|
5
|
-
import { t as DependencyGraph } from "./dep-graph-
|
|
6
|
-
import { n as runArgs, s as tryRunArgs } from "./shell-
|
|
7
|
-
import { r as readBumpFiles } from "./bump-file-
|
|
8
|
-
import { t as assembleReleasePlan } from "./release-plan-
|
|
9
|
-
import { t as applyReleasePlan } from "./apply-release-plan-
|
|
10
|
-
import { t as resolveCommitMessage } from "./commit-message-
|
|
2
|
+
import { a as loadConfig } from "./config-CJIj8xG3.mjs";
|
|
3
|
+
import { n as detectWorkspaces } from "./package-manager-CClZtIHP.mjs";
|
|
4
|
+
import { t as discoverPackages } from "./workspace-c9-TqXed.mjs";
|
|
5
|
+
import { t as DependencyGraph } from "./dep-graph-E-9-eQ2J.mjs";
|
|
6
|
+
import { n as runArgs, s as tryRunArgs } from "./shell-u3bYGxNy.mjs";
|
|
7
|
+
import { r as readBumpFiles } from "./bump-file-BTsntOO-.mjs";
|
|
8
|
+
import { t as assembleReleasePlan } from "./release-plan-21H89Cx1.mjs";
|
|
9
|
+
import { t as applyReleasePlan } from "./apply-release-plan-Bi9OSWks.mjs";
|
|
10
|
+
import { t as resolveCommitMessage } from "./commit-message-DOIfDxfj.mjs";
|
|
11
11
|
//#region src/commands/version.ts
|
|
12
12
|
async function versionCommand(rootDir, opts = {}) {
|
|
13
13
|
const config = await loadConfig(rootDir);
|
|
14
14
|
const packages = await discoverPackages(rootDir, config);
|
|
15
15
|
const depGraph = new DependencyGraph(packages);
|
|
16
|
-
const bumpFiles = await readBumpFiles(rootDir);
|
|
16
|
+
const { bumpFiles, errors: parseErrors } = await readBumpFiles(rootDir);
|
|
17
|
+
if (parseErrors.length > 0) {
|
|
18
|
+
for (const err of parseErrors) log.error(err);
|
|
19
|
+
throw new Error("Bump file parse errors must be fixed before versioning.");
|
|
20
|
+
}
|
|
17
21
|
if (bumpFiles.length === 0) {
|
|
18
22
|
log.info("No pending bump files.");
|
|
19
23
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as readJson, n as exists } from "./fs-DnDogVn-.mjs";
|
|
2
|
-
import { i as isPackageManaged, o as loadPackageConfig } from "./config-
|
|
3
|
-
import { n as detectWorkspaces } from "./package-manager-
|
|
2
|
+
import { i as isPackageManaged, o as loadPackageConfig } from "./config-CJIj8xG3.mjs";
|
|
3
|
+
import { n as detectWorkspaces } from "./package-manager-CClZtIHP.mjs";
|
|
4
4
|
import { relative, resolve } from "node:path";
|
|
5
5
|
import { readdir, stat } from "node:fs/promises";
|
|
6
6
|
//#region src/core/workspace.ts
|
package/package.json
CHANGED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { n as log } from "./logger-C2dEe5Su.mjs";
|
|
2
|
-
import { a as readJson, c as removeFile, f as writeText, i as listFiles, l as updateJsonFields, n as exists, s as readText, u as updateJsonNestedField } from "./fs-DnDogVn-.mjs";
|
|
3
|
-
import { r as getBumpyDir } from "./config-D7Umr-fT.mjs";
|
|
4
|
-
import { relative, resolve } from "node:path";
|
|
5
|
-
import { realpathSync } from "node:fs";
|
|
6
|
-
//#region src/core/changelog.ts
|
|
7
|
-
/** Default formatter — version heading, date, bullet points */
|
|
8
|
-
const defaultFormatter = (ctx) => {
|
|
9
|
-
const { release, bumpFiles, date } = ctx;
|
|
10
|
-
const lines = [];
|
|
11
|
-
lines.push(`## ${release.newVersion}`);
|
|
12
|
-
lines.push("");
|
|
13
|
-
lines.push(`_${date}_`);
|
|
14
|
-
lines.push("");
|
|
15
|
-
const relevantBumpFiles = bumpFiles.filter((bf) => release.bumpFiles.includes(bf.id));
|
|
16
|
-
if (relevantBumpFiles.length > 0) {
|
|
17
|
-
for (const bf of relevantBumpFiles) if (bf.summary) {
|
|
18
|
-
const summaryLines = bf.summary.split("\n");
|
|
19
|
-
lines.push(`- ${summaryLines[0]}`);
|
|
20
|
-
for (let i = 1; i < summaryLines.length; i++) if (summaryLines[i].trim()) lines.push(` ${summaryLines[i]}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (release.isDependencyBump && relevantBumpFiles.length === 0) lines.push("- Updated dependencies");
|
|
24
|
-
if (release.isCascadeBump && !release.isDependencyBump && relevantBumpFiles.length === 0) lines.push("- Version bump via cascade rule");
|
|
25
|
-
lines.push("");
|
|
26
|
-
return lines.join("\n");
|
|
27
|
-
};
|
|
28
|
-
const BUILTIN_FORMATTERS = {
|
|
29
|
-
default: defaultFormatter,
|
|
30
|
-
github: async () => {
|
|
31
|
-
const { createGithubFormatter } = await import("./changelog-github-DkACMj0j.mjs");
|
|
32
|
-
return createGithubFormatter();
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Load a changelog formatter from config.
|
|
37
|
-
* Supports: "default", "./path/to/formatter.ts", or a module name.
|
|
38
|
-
*/
|
|
39
|
-
async function loadFormatter(changelog, rootDir) {
|
|
40
|
-
const [name, options] = Array.isArray(changelog) ? changelog : [changelog, {}];
|
|
41
|
-
if (name === "github") {
|
|
42
|
-
const { createGithubFormatter } = await import("./changelog-github-DkACMj0j.mjs");
|
|
43
|
-
return createGithubFormatter(options);
|
|
44
|
-
}
|
|
45
|
-
if (typeof name === "string" && BUILTIN_FORMATTERS[name]) {
|
|
46
|
-
const builtin = BUILTIN_FORMATTERS[name];
|
|
47
|
-
if (typeof builtin === "function" && builtin.length === 0) return builtin();
|
|
48
|
-
return builtin;
|
|
49
|
-
}
|
|
50
|
-
if (typeof name === "string") try {
|
|
51
|
-
let modulePath;
|
|
52
|
-
if (name.startsWith(".")) {
|
|
53
|
-
modulePath = resolve(rootDir, name);
|
|
54
|
-
try {
|
|
55
|
-
modulePath = realpathSync(modulePath);
|
|
56
|
-
} catch {}
|
|
57
|
-
const rel = relative(realpathSync(rootDir), modulePath);
|
|
58
|
-
if (rel.startsWith("..") || resolve("/", rel) === resolve("/")) throw new Error(`Changelog formatter path "${name}" resolves outside the project root`);
|
|
59
|
-
} else modulePath = name;
|
|
60
|
-
const mod = await import(modulePath);
|
|
61
|
-
const exported = mod.default || mod.changelogFormatter;
|
|
62
|
-
if (typeof exported === "function") {
|
|
63
|
-
const result = exported(options);
|
|
64
|
-
if (typeof result === "function") return result;
|
|
65
|
-
return exported;
|
|
66
|
-
}
|
|
67
|
-
throw new Error(`Changelog module "${name}" does not export a function`);
|
|
68
|
-
} catch (err) {
|
|
69
|
-
log.warn(`Failed to load changelog formatter "${name}": ${err instanceof Error ? err.message : err}`);
|
|
70
|
-
log.warn("Falling back to default formatter");
|
|
71
|
-
return defaultFormatter;
|
|
72
|
-
}
|
|
73
|
-
return defaultFormatter;
|
|
74
|
-
}
|
|
75
|
-
/** Generate a changelog entry using the configured formatter */
|
|
76
|
-
async function generateChangelogEntry(release, bumpFiles, formatter = defaultFormatter, date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0]) {
|
|
77
|
-
return formatter({
|
|
78
|
-
release,
|
|
79
|
-
bumpFiles,
|
|
80
|
-
date
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
/** Prepend a new entry to an existing CHANGELOG.md content */
|
|
84
|
-
function prependToChangelog(existingContent, newEntry) {
|
|
85
|
-
const headerMatch = existingContent.match(/^# /m);
|
|
86
|
-
if (headerMatch && headerMatch.index !== void 0) {
|
|
87
|
-
const afterTitle = existingContent.indexOf("\n##");
|
|
88
|
-
if (afterTitle !== -1) return existingContent.slice(0, afterTitle + 1) + "\n" + newEntry + existingContent.slice(afterTitle + 1);
|
|
89
|
-
return existingContent.trimEnd() + "\n\n" + newEntry;
|
|
90
|
-
}
|
|
91
|
-
return "# Changelog\n\n" + newEntry;
|
|
92
|
-
}
|
|
93
|
-
//#endregion
|
|
94
|
-
//#region src/core/apply-release-plan.ts
|
|
95
|
-
/** Apply the release plan: bump versions, update changelogs, delete bump files */
|
|
96
|
-
async function applyReleasePlan(releasePlan, packages, rootDir, config) {
|
|
97
|
-
const releaseMap = new Map(releasePlan.releases.map((r) => [r.name, r]));
|
|
98
|
-
const formatter = config.changelog !== false ? await loadFormatter(config.changelog, rootDir) : null;
|
|
99
|
-
for (const release of releasePlan.releases) {
|
|
100
|
-
const pkgJsonPath = resolve(packages.get(release.name).dir, "package.json");
|
|
101
|
-
const pkgJson = await readJson(pkgJsonPath);
|
|
102
|
-
await updateJsonFields(pkgJsonPath, { version: release.newVersion });
|
|
103
|
-
for (const depField of [
|
|
104
|
-
"dependencies",
|
|
105
|
-
"devDependencies",
|
|
106
|
-
"peerDependencies",
|
|
107
|
-
"optionalDependencies"
|
|
108
|
-
]) {
|
|
109
|
-
const deps = pkgJson[depField];
|
|
110
|
-
if (!deps) continue;
|
|
111
|
-
for (const [depName, range] of Object.entries(deps)) {
|
|
112
|
-
const depRelease = releaseMap.get(depName);
|
|
113
|
-
if (!depRelease) continue;
|
|
114
|
-
await updateJsonNestedField(pkgJsonPath, depField, depName, updateRange(range, depRelease.newVersion));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (formatter) for (const release of releasePlan.releases) {
|
|
119
|
-
const changelogPath = resolve(packages.get(release.name).dir, "CHANGELOG.md");
|
|
120
|
-
const entry = await generateChangelogEntry(release, releasePlan.bumpFiles, formatter);
|
|
121
|
-
let existingContent = "";
|
|
122
|
-
if (await exists(changelogPath)) existingContent = await readText(changelogPath);
|
|
123
|
-
await writeText(changelogPath, prependToChangelog(existingContent, entry));
|
|
124
|
-
}
|
|
125
|
-
const bumpyDir = getBumpyDir(rootDir);
|
|
126
|
-
const allBumpFiles = await listFiles(bumpyDir, ".md");
|
|
127
|
-
for (const file of allBumpFiles) {
|
|
128
|
-
if (file === "README.md") continue;
|
|
129
|
-
await removeFile(resolve(bumpyDir, file));
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/** Update a version range to include a new version, preserving the range prefix */
|
|
133
|
-
function updateRange(range, newVersion) {
|
|
134
|
-
let protocol = "";
|
|
135
|
-
let cleanRange = range;
|
|
136
|
-
const protoMatch = range.match(/^(workspace:|catalog:)/);
|
|
137
|
-
if (protoMatch) {
|
|
138
|
-
protocol = protoMatch[1];
|
|
139
|
-
cleanRange = range.slice(protocol.length);
|
|
140
|
-
}
|
|
141
|
-
const prefix = cleanRange.match(/^(\^|~|>=|>|<=|<|=)?/)?.[1] ?? "^";
|
|
142
|
-
if (cleanRange === "*" || cleanRange === "") return range;
|
|
143
|
-
return `${protocol}${prefix}${newVersion}`;
|
|
144
|
-
}
|
|
145
|
-
//#endregion
|
|
146
|
-
export { prependToChangelog as a, loadFormatter as i, defaultFormatter as n, generateChangelogEntry as r, applyReleasePlan as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|