@vc-shell/release-config 1.2.4-beta.5 → 1.2.4-beta.7
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 +3 -1
- package/dist/cli-generate-changelogs.js +1 -1
- package/dist/generate-changelogs-BPFwnUNn.js +527 -0
- package/dist/release-config.js +108 -140
- package/dist/src/changelog.d.ts +53 -3
- package/dist/src/changelog.d.ts.map +1 -1
- package/dist/src/generate-changelogs.d.ts.map +1 -1
- package/dist/src/git.d.ts +48 -9
- package/dist/src/git.d.ts.map +1 -1
- package/dist/src/lerna.d.ts.map +1 -1
- package/dist/src/release.d.ts.map +1 -1
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/generate-changelogs-uhMg9Loz.js +0 -148
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Release management system powered by Lerna for VC-Shell monorepo.
|
|
|
13
13
|
- **Root package versioning** - root package.json stays synchronized
|
|
14
14
|
- **Apps synchronization** - automatic @vc-shell/* dependency updates in apps/
|
|
15
15
|
- **Initial changelog generation** - create changelogs from entire git history
|
|
16
|
+
- **Lockstep mode** - optional `forcePublish: true` bumps every package on each release
|
|
16
17
|
- **Backward compatible** - maintains existing release script API
|
|
17
18
|
|
|
18
19
|
## Usage
|
|
@@ -24,6 +25,7 @@ import { release } from "@vc-shell/release-config";
|
|
|
24
25
|
|
|
25
26
|
release({
|
|
26
27
|
packages: [".", "framework", "cli/*", "configs/*"],
|
|
28
|
+
forcePublish: true,
|
|
27
29
|
toTag: (version) => `v${version}`,
|
|
28
30
|
bumpVersion: async (pkgName, version) => {
|
|
29
31
|
// Optional: custom version bump logic (Lerna handles this automatically)
|
|
@@ -44,7 +46,7 @@ release({
|
|
|
44
46
|
**Version bump:**
|
|
45
47
|
4. Lerna analyzes git history using conventional commits
|
|
46
48
|
5. Determines which packages changed
|
|
47
|
-
6. Updates all package versions (
|
|
49
|
+
6. Updates all package versions (or all packages when `forcePublish: true`)
|
|
48
50
|
7. Generates CHANGELOG.md for each package
|
|
49
51
|
8. Synchronizes internal dependencies automatically
|
|
50
52
|
9. Creates git commit and tag
|
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import { sync as d } from "cross-spawn";
|
|
2
|
+
import { existsSync as N, readFileSync as E, writeFileSync as b } from "node:fs";
|
|
3
|
+
import C from "node:path";
|
|
4
|
+
import l from "chalk";
|
|
5
|
+
import { valid as v, rcompare as H } from "semver";
|
|
6
|
+
function st(t, e) {
|
|
7
|
+
const o = d("git", ["describe", "--tags", "--abbrev=0", "--match", `${e}${t}.*`], {
|
|
8
|
+
stdio: "pipe",
|
|
9
|
+
encoding: "utf-8"
|
|
10
|
+
});
|
|
11
|
+
return o.status === 0 && o.stdout ? o.stdout.toString().trim() : null;
|
|
12
|
+
}
|
|
13
|
+
function O() {
|
|
14
|
+
const t = d("git", ["remote", "get-url", "origin"], {
|
|
15
|
+
stdio: "pipe",
|
|
16
|
+
encoding: "utf-8"
|
|
17
|
+
});
|
|
18
|
+
return t.status === 0 && t.stdout ? t.stdout.toString().trim().replace(/\.git$/, "").replace(/^git@github\.com:/, "https://github.com/") : null;
|
|
19
|
+
}
|
|
20
|
+
function V(t, e, o) {
|
|
21
|
+
const r = ["log", "--format=%H %s", `${t}..${e}`];
|
|
22
|
+
o && r.push("--", o);
|
|
23
|
+
const i = d("git", r, {
|
|
24
|
+
stdio: "pipe",
|
|
25
|
+
encoding: "utf-8"
|
|
26
|
+
});
|
|
27
|
+
if (i.status !== 0 || !i.stdout) return [];
|
|
28
|
+
const n = [], s = i.stdout.toString().trim().split(`
|
|
29
|
+
`).filter(Boolean), c = /^(\w+)(?:\(([^)]+)\))?(!)?\s*:\s*(.+)$/;
|
|
30
|
+
for (const a of s) {
|
|
31
|
+
const g = a.indexOf(" ");
|
|
32
|
+
if (g === -1) continue;
|
|
33
|
+
const u = a.substring(0, g), p = a.substring(g + 1).match(c);
|
|
34
|
+
p && n.push({
|
|
35
|
+
hash: u,
|
|
36
|
+
shortHash: u.substring(0, 7),
|
|
37
|
+
type: p[1],
|
|
38
|
+
scope: p[2] || null,
|
|
39
|
+
subject: p[4],
|
|
40
|
+
breaking: !!p[3]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return n;
|
|
44
|
+
}
|
|
45
|
+
function it() {
|
|
46
|
+
const t = d("git", ["describe", "--tags", "--abbrev=0"], {
|
|
47
|
+
stdio: "pipe",
|
|
48
|
+
encoding: "utf-8"
|
|
49
|
+
});
|
|
50
|
+
return t.status === 0 && t.stdout ? t.stdout.toString().trim() : null;
|
|
51
|
+
}
|
|
52
|
+
function rt() {
|
|
53
|
+
d("git", ["add", "-u"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
54
|
+
Failed to stage changes
|
|
55
|
+
`)), process.exit(1)), d("git", ["commit", "--amend", "--no-edit"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
56
|
+
Failed to amend commit
|
|
57
|
+
`)), process.exit(1));
|
|
58
|
+
}
|
|
59
|
+
function ct(t) {
|
|
60
|
+
d("git", ["tag", "-f", "-a", t, "-m", t], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
61
|
+
Failed to recreate tag
|
|
62
|
+
`)), process.exit(1));
|
|
63
|
+
}
|
|
64
|
+
function at(t) {
|
|
65
|
+
console.log(l.cyan(`
|
|
66
|
+
Pushing changes to remote...
|
|
67
|
+
`)), d("git", ["push", "origin", "HEAD", "--force-with-lease"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
68
|
+
Failed to push commit
|
|
69
|
+
`)), process.exit(1)), d("git", ["push", "origin", t, "--force"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
70
|
+
Failed to push tag
|
|
71
|
+
`)), process.exit(1));
|
|
72
|
+
}
|
|
73
|
+
function x(t) {
|
|
74
|
+
const e = d("git", ["tag", "-l", `${t}*`], {
|
|
75
|
+
stdio: "pipe",
|
|
76
|
+
encoding: "utf-8"
|
|
77
|
+
});
|
|
78
|
+
return e.status !== 0 || !e.stdout ? [] : e.stdout.toString().trim().split(`
|
|
79
|
+
`).filter(Boolean).sort((r, i) => {
|
|
80
|
+
const n = v(r.startsWith(t) ? r.slice(t.length) : r), s = v(i.startsWith(t) ? i.slice(t.length) : i);
|
|
81
|
+
return n && s ? H(n, s) : i.localeCompare(r);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function w(t, e) {
|
|
85
|
+
const o = x(e), r = `${e}${t}`, i = o.indexOf(r);
|
|
86
|
+
if (i !== -1)
|
|
87
|
+
return i >= o.length - 1 ? null : o[i + 1];
|
|
88
|
+
const n = v(t);
|
|
89
|
+
if (!n)
|
|
90
|
+
return console.warn(l.yellow(` getPreviousVersionTag: invalid version "${t}"`)), null;
|
|
91
|
+
for (const s of o) {
|
|
92
|
+
const c = v(s.startsWith(e) ? s.slice(e.length) : s);
|
|
93
|
+
if (c && H(n, c) < 0)
|
|
94
|
+
return s;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
function ut() {
|
|
99
|
+
const t = d("git", ["log", "-1", "--format=%s"], {
|
|
100
|
+
stdio: "pipe",
|
|
101
|
+
encoding: "utf-8"
|
|
102
|
+
});
|
|
103
|
+
return t.status === 0 && t.stdout ? t.stdout.toString().trim() : null;
|
|
104
|
+
}
|
|
105
|
+
const S = /^#{1,2}\s+(?:\[)?(\d[\da-z.-]*)(?:\])?/i, j = /\*\*Note:\*\*\s+Version bump only[^\n]*/gi;
|
|
106
|
+
function T(t) {
|
|
107
|
+
let e = t;
|
|
108
|
+
return e = e.replace(/^# CHANGELOG\s*\n/gm, ""), e = e.replace(/^# Change Log\s*\n/gm, ""), e = e.replace(
|
|
109
|
+
/^All notable changes to this (project|package) will be documented in this file\.\s*\n/gm,
|
|
110
|
+
""
|
|
111
|
+
), e = e.replace(
|
|
112
|
+
/^See \[Conventional Commits\]\(https:\/\/conventionalcommits\.org\) for commit guidelines\.\s*\n/gm,
|
|
113
|
+
""
|
|
114
|
+
), e = e.replace(/\n{3,}/g, `
|
|
115
|
+
|
|
116
|
+
`), e;
|
|
117
|
+
}
|
|
118
|
+
function L(t) {
|
|
119
|
+
return t.replace(
|
|
120
|
+
/^(#{1,2}\s+(?:\[[^\]]+\]|\d[\da-z.-]*)[^\n]*\n)\n(?=#{1,2}\s+(?:\[|\d)|$)/gim,
|
|
121
|
+
`$1
|
|
122
|
+
**Note:** Version bump only for package
|
|
123
|
+
|
|
124
|
+
`
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
function lt(t, e = !1) {
|
|
128
|
+
console.log(l.cyan(`
|
|
129
|
+
Enhancing changelogs...
|
|
130
|
+
`));
|
|
131
|
+
for (const o of t) {
|
|
132
|
+
const r = C.join(o.path, "CHANGELOG.md");
|
|
133
|
+
if (!N(r)) continue;
|
|
134
|
+
let i = E(r, "utf-8");
|
|
135
|
+
i = T(i), i = L(i), i = I(i), i = i.trim() + `
|
|
136
|
+
`, e || b(r, i, "utf-8");
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function gt(t, e, o = !1) {
|
|
140
|
+
console.log(l.cyan(`
|
|
141
|
+
Ensuring current version entries for ${e}...
|
|
142
|
+
`));
|
|
143
|
+
let r = 0;
|
|
144
|
+
for (const i of t) {
|
|
145
|
+
const n = C.join(i.path, "CHANGELOG.md");
|
|
146
|
+
if (!N(n)) continue;
|
|
147
|
+
let s = E(n, "utf-8");
|
|
148
|
+
const c = e.replace(/\./g, "\\.");
|
|
149
|
+
if (new RegExp(`^#{1,2}\\s+\\[?${c}\\]?\\b`, "m").test(s)) continue;
|
|
150
|
+
const g = `## ${e}
|
|
151
|
+
|
|
152
|
+
**Note:** Version bump only for package
|
|
153
|
+
|
|
154
|
+
`, u = s.match(/^#{1,2}\s+\[?\d[\da-z.-]*\]?[^\n]*/m);
|
|
155
|
+
u && u.index !== void 0 ? s = s.substring(0, u.index) + g + s.substring(u.index) : s.trim() ? s = s.trimEnd() + `
|
|
156
|
+
|
|
157
|
+
` + g : s = g, r++, o || b(n, s, "utf-8");
|
|
158
|
+
}
|
|
159
|
+
r > 0 ? console.log(l.green(` Inserted ${r} current version entr${r === 1 ? "y" : "ies"}`)) : console.log(l.gray(" All packages already have a current version entry"));
|
|
160
|
+
}
|
|
161
|
+
function ft(t, e, o = "v", r = !1) {
|
|
162
|
+
console.log(l.cyan(`
|
|
163
|
+
Supplementing current version entries for ${e}...
|
|
164
|
+
`));
|
|
165
|
+
const i = w(e, o);
|
|
166
|
+
if (!i) {
|
|
167
|
+
console.log(l.gray(" No previous release tag found; skipping current version supplementation"));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
const n = O();
|
|
171
|
+
let s = 0;
|
|
172
|
+
for (const c of t) {
|
|
173
|
+
const a = C.join(c.path, "CHANGELOG.md");
|
|
174
|
+
if (!N(a)) continue;
|
|
175
|
+
const g = V(i, "HEAD", c.path), u = W(g, n);
|
|
176
|
+
if (!u) continue;
|
|
177
|
+
const f = E(a, "utf-8"), p = B(f, e, u);
|
|
178
|
+
p !== f && (s++, r || b(a, p, "utf-8"));
|
|
179
|
+
}
|
|
180
|
+
s > 0 ? console.log(l.green(` Supplemented ${s} current version entr${s === 1 ? "y" : "ies"}`)) : console.log(l.gray(" No current version entries needed supplementation"));
|
|
181
|
+
}
|
|
182
|
+
function y(t) {
|
|
183
|
+
return t.replace(j, "").trim().length === 0;
|
|
184
|
+
}
|
|
185
|
+
function k(t, e, o) {
|
|
186
|
+
if (!e || o.length === 0) return;
|
|
187
|
+
const r = o.join(`
|
|
188
|
+
`).trim();
|
|
189
|
+
if (!r) return;
|
|
190
|
+
const i = t[e];
|
|
191
|
+
(!i || y(i) && !y(r)) && (t[e] = r);
|
|
192
|
+
}
|
|
193
|
+
function I(t) {
|
|
194
|
+
const e = t.split(`
|
|
195
|
+
`), o = [], r = [], i = /* @__PURE__ */ new Map();
|
|
196
|
+
let n = null;
|
|
197
|
+
const s = () => {
|
|
198
|
+
if (!n) return;
|
|
199
|
+
const c = n.lines.slice(1).join(`
|
|
200
|
+
`).trim(), a = i.get(n.version);
|
|
201
|
+
if (a === void 0) {
|
|
202
|
+
i.set(n.version, r.length), r.push(n), n = null;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
const u = r[a].lines.slice(1).join(`
|
|
206
|
+
`).trim();
|
|
207
|
+
y(u) && !y(c) && (r[a] = n), n = null;
|
|
208
|
+
};
|
|
209
|
+
for (const c of e) {
|
|
210
|
+
const a = c.match(S);
|
|
211
|
+
if (a) {
|
|
212
|
+
s(), n = { version: a[1], lines: [c] };
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
n ? n.lines.push(c) : o.push(c);
|
|
216
|
+
}
|
|
217
|
+
return s(), [...o, ...r.flatMap((c) => c.lines)].join(`
|
|
218
|
+
`);
|
|
219
|
+
}
|
|
220
|
+
function B(t, e, o) {
|
|
221
|
+
const r = e.replace(/\./g, "\\."), i = new RegExp(
|
|
222
|
+
`(^#{1,2}\\s+\\[?${r}\\]?[^\\n]*\\n)([\\s\\S]*?)(?=^#{1,2}\\s+\\[?\\d[\\da-z.-]*\\]?|$)`,
|
|
223
|
+
"m"
|
|
224
|
+
);
|
|
225
|
+
return t.replace(i, (n, s, c) => y(c) ? `${s}
|
|
226
|
+
${o.trim()}
|
|
227
|
+
|
|
228
|
+
` : n);
|
|
229
|
+
}
|
|
230
|
+
function P(t) {
|
|
231
|
+
const e = {}, o = {}, r = t.split(`
|
|
232
|
+
`);
|
|
233
|
+
let i = null, n = [];
|
|
234
|
+
for (const s of r) {
|
|
235
|
+
const c = s.match(S);
|
|
236
|
+
c ? (k(e, i, n), i = c[1], n = [], o[i] || (o[i] = s.replace(/^#{1,2}\s+/, ""))) : i && s.trim() !== "" && !s.startsWith("# CHANGELOG") && !s.startsWith("# Change Log") && !s.startsWith("All notable changes") && !s.startsWith("See [Conventional Commits]") && n.push(s);
|
|
237
|
+
}
|
|
238
|
+
return k(e, i, n), { versionContent: e, versionHeaders: o };
|
|
239
|
+
}
|
|
240
|
+
function F(t, e) {
|
|
241
|
+
return [...t].sort((o, r) => {
|
|
242
|
+
const i = R(e?.[o]), n = R(e?.[r]);
|
|
243
|
+
return i !== null && n !== null && i !== n ? n - i : v(o) && v(r) ? H(o, r) : r.localeCompare(o);
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function R(t) {
|
|
247
|
+
if (!t) return null;
|
|
248
|
+
const e = t.match(/\((\d{4}-\d{2}-\d{2})\)\s*$/);
|
|
249
|
+
if (!e) return null;
|
|
250
|
+
const o = Date.parse(`${e[1]}T00:00:00Z`);
|
|
251
|
+
return Number.isNaN(o) ? null : o;
|
|
252
|
+
}
|
|
253
|
+
function D(t, e = !1) {
|
|
254
|
+
const { packages: o, rootDir: r = process.cwd(), includeRootHeader: i = !1 } = t;
|
|
255
|
+
console.log(l.cyan(`
|
|
256
|
+
Generating root CHANGELOG with package grouping...
|
|
257
|
+
`));
|
|
258
|
+
const n = C.join(r, "CHANGELOG.md"), s = {}, c = {};
|
|
259
|
+
for (const u of o) {
|
|
260
|
+
const f = C.join(r, u.path, "CHANGELOG.md");
|
|
261
|
+
if (!N(f)) continue;
|
|
262
|
+
const p = E(f, "utf-8"), m = P(p);
|
|
263
|
+
for (const [h, $] of Object.entries(m.versionContent))
|
|
264
|
+
s[h] || (s[h] = {}), s[h][u.displayName] = $, !c[h] && m.versionHeaders[h] && (c[h] = m.versionHeaders[h]);
|
|
265
|
+
}
|
|
266
|
+
let a = "";
|
|
267
|
+
i && (a = `# CHANGELOG
|
|
268
|
+
|
|
269
|
+
All notable changes to this monorepo will be documented in this file.
|
|
270
|
+
|
|
271
|
+
`);
|
|
272
|
+
const g = F(Object.keys(s), c);
|
|
273
|
+
for (const u of g) {
|
|
274
|
+
const f = s[u], p = Object.values(f).some(
|
|
275
|
+
($) => !!$?.trim() && !y($)
|
|
276
|
+
), m = c[u] || u;
|
|
277
|
+
if (a += `## ${m}
|
|
278
|
+
|
|
279
|
+
`, !p) {
|
|
280
|
+
a += `**Note:** Version bump only for package
|
|
281
|
+
|
|
282
|
+
`;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
let h = !1;
|
|
286
|
+
for (const $ of o) {
|
|
287
|
+
const G = f[$.displayName];
|
|
288
|
+
G && G.trim() && (y(G) || (h = !0, a += `### ${$.displayName}
|
|
289
|
+
|
|
290
|
+
`, a += `${G}
|
|
291
|
+
|
|
292
|
+
`));
|
|
293
|
+
}
|
|
294
|
+
h || (a += `**Note:** Version bump only for package
|
|
295
|
+
|
|
296
|
+
`);
|
|
297
|
+
}
|
|
298
|
+
a = a.replace(/\n{3,}/g, `
|
|
299
|
+
|
|
300
|
+
`), a = a.trim() + `
|
|
301
|
+
`, e ? console.log(l.yellow(` [dry-run] Would write root CHANGELOG.md (${g.length} versions)`)) : (b(n, a, "utf-8"), console.log(l.green(" Generated root CHANGELOG.md with package grouping")));
|
|
302
|
+
}
|
|
303
|
+
const M = {
|
|
304
|
+
feat: "Features",
|
|
305
|
+
fix: "Bug Fixes",
|
|
306
|
+
perf: "Performance Improvements",
|
|
307
|
+
revert: "Reverts",
|
|
308
|
+
docs: "Documentation",
|
|
309
|
+
style: "Styles",
|
|
310
|
+
refactor: "Code Refactoring",
|
|
311
|
+
test: "Tests",
|
|
312
|
+
build: "Build System",
|
|
313
|
+
ci: "Continuous Integration"
|
|
314
|
+
};
|
|
315
|
+
function W(t, e) {
|
|
316
|
+
const o = {};
|
|
317
|
+
for (const n of t) {
|
|
318
|
+
const s = M[n.type];
|
|
319
|
+
s && (o[s] || (o[s] = []), o[s].push(n));
|
|
320
|
+
}
|
|
321
|
+
if (Object.keys(o).length === 0) return "";
|
|
322
|
+
let r = "";
|
|
323
|
+
const i = [
|
|
324
|
+
"Features",
|
|
325
|
+
"Bug Fixes",
|
|
326
|
+
"Performance Improvements",
|
|
327
|
+
"Reverts",
|
|
328
|
+
"Documentation",
|
|
329
|
+
"Styles",
|
|
330
|
+
"Code Refactoring",
|
|
331
|
+
"Tests",
|
|
332
|
+
"Build System",
|
|
333
|
+
"Continuous Integration"
|
|
334
|
+
];
|
|
335
|
+
for (const n of i) {
|
|
336
|
+
const s = o[n];
|
|
337
|
+
if (!(!s || s.length === 0)) {
|
|
338
|
+
r += `### ${n}
|
|
339
|
+
|
|
340
|
+
`;
|
|
341
|
+
for (const c of s) {
|
|
342
|
+
const a = e ? `([${c.shortHash}](${e}/commit/${c.hash}))` : `(${c.shortHash})`;
|
|
343
|
+
r += c.scope ? `- **${c.scope}:** ${c.subject} ${a}
|
|
344
|
+
` : `- ${c.subject} ${a}
|
|
345
|
+
`;
|
|
346
|
+
}
|
|
347
|
+
r += `
|
|
348
|
+
`;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
return r.trim();
|
|
352
|
+
}
|
|
353
|
+
const A = [
|
|
354
|
+
{ heading: "Features", types: ["feat"] },
|
|
355
|
+
{ heading: "Bug Fixes", types: ["fix"] },
|
|
356
|
+
{ heading: "Performance Improvements", types: ["perf"] },
|
|
357
|
+
{ heading: "Reverts", types: ["revert"] },
|
|
358
|
+
{ heading: "Documentation", types: ["docs"] },
|
|
359
|
+
{ heading: "Styles", types: ["style"] },
|
|
360
|
+
{ heading: "Code Refactoring", types: ["refactor"] },
|
|
361
|
+
{ heading: "Tests", types: ["test"] },
|
|
362
|
+
{ heading: "Build System", types: ["build"] },
|
|
363
|
+
{ heading: "CI/CD", types: ["ci"] },
|
|
364
|
+
{ heading: "Chores", hidden: !0, types: ["chore"] }
|
|
365
|
+
], _ = new Map(
|
|
366
|
+
A.flatMap(
|
|
367
|
+
(t) => t.types.map((e) => [e, { heading: t.heading, hidden: t.hidden }])
|
|
368
|
+
)
|
|
369
|
+
);
|
|
370
|
+
function z(t, e, o, r) {
|
|
371
|
+
const i = ["log", "--format=%H %s", e ? `${e}..${t}` : t];
|
|
372
|
+
r && i.push("--", r);
|
|
373
|
+
const n = d("git", i, {
|
|
374
|
+
stdio: "pipe",
|
|
375
|
+
encoding: "utf-8",
|
|
376
|
+
cwd: o
|
|
377
|
+
});
|
|
378
|
+
if (n.status !== 0 || !n.stdout) return [];
|
|
379
|
+
const s = [], c = n.stdout.toString().trim().split(`
|
|
380
|
+
`).filter(Boolean), a = /^(\w+)(?:\(([^)]+)\))?(!)?\s*:\s*(.+)$/;
|
|
381
|
+
for (const g of c) {
|
|
382
|
+
const u = g.indexOf(" ");
|
|
383
|
+
if (u === -1) continue;
|
|
384
|
+
const f = g.substring(0, u), m = g.substring(u + 1).match(a);
|
|
385
|
+
m && s.push({
|
|
386
|
+
hash: f,
|
|
387
|
+
shortHash: f.substring(0, 7),
|
|
388
|
+
type: m[1],
|
|
389
|
+
scope: m[2] || null,
|
|
390
|
+
subject: m[4],
|
|
391
|
+
breaking: !!m[3]
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
return s;
|
|
395
|
+
}
|
|
396
|
+
function Y(t, e) {
|
|
397
|
+
const o = d("git", ["tag", "-l", `${e}*`], {
|
|
398
|
+
stdio: "pipe",
|
|
399
|
+
encoding: "utf-8",
|
|
400
|
+
cwd: t
|
|
401
|
+
});
|
|
402
|
+
if (o.status !== 0 || !o.stdout) return [];
|
|
403
|
+
const r = o.stdout.toString().trim().split(`
|
|
404
|
+
`).filter(Boolean), i = /* @__PURE__ */ new Map();
|
|
405
|
+
for (const n of r)
|
|
406
|
+
i.set(n, U(t, n));
|
|
407
|
+
return r.sort((n, s) => {
|
|
408
|
+
const c = i.get(n) || 0, a = i.get(s) || 0;
|
|
409
|
+
return c !== a ? a - c : s.localeCompare(n);
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function K(t) {
|
|
413
|
+
const e = d("git", ["remote", "get-url", "origin"], {
|
|
414
|
+
stdio: "pipe",
|
|
415
|
+
encoding: "utf-8",
|
|
416
|
+
cwd: t
|
|
417
|
+
});
|
|
418
|
+
return e.status !== 0 || !e.stdout ? null : e.stdout.toString().trim().replace(/\.git$/, "").replace(/^git@github\.com:/, "https://github.com/");
|
|
419
|
+
}
|
|
420
|
+
function U(t, e) {
|
|
421
|
+
const o = d("git", ["log", "-1", "--format=%ct", e], {
|
|
422
|
+
stdio: "pipe",
|
|
423
|
+
encoding: "utf-8",
|
|
424
|
+
cwd: t
|
|
425
|
+
});
|
|
426
|
+
return o.status === 0 && o.stdout?.trim() && Number(o.stdout.trim()) || 0;
|
|
427
|
+
}
|
|
428
|
+
function Z(t, e) {
|
|
429
|
+
const o = d("git", ["log", "-1", "--format=%cs", e], {
|
|
430
|
+
stdio: "pipe",
|
|
431
|
+
encoding: "utf-8",
|
|
432
|
+
cwd: t
|
|
433
|
+
});
|
|
434
|
+
return o.status === 0 && o.stdout?.trim() ? o.stdout.trim() : "";
|
|
435
|
+
}
|
|
436
|
+
function q(t, e, o, r, i) {
|
|
437
|
+
const n = Z(t, o);
|
|
438
|
+
return i && r ? `## [${e}](${i}/compare/${r}...${o})${n ? ` (${n})` : ""}` : `## ${e}${n ? ` (${n})` : ""}`;
|
|
439
|
+
}
|
|
440
|
+
function J(t, e) {
|
|
441
|
+
const o = /* @__PURE__ */ new Map(), r = [];
|
|
442
|
+
for (const n of t) {
|
|
443
|
+
const s = _.get(n.type);
|
|
444
|
+
!s || s.hidden || (o.has(s.heading) || o.set(s.heading, []), o.get(s.heading).push(n), n.breaking && r.push(n));
|
|
445
|
+
}
|
|
446
|
+
if (o.size === 0)
|
|
447
|
+
return "";
|
|
448
|
+
const i = [];
|
|
449
|
+
for (const n of A) {
|
|
450
|
+
if (n.hidden) continue;
|
|
451
|
+
const s = o.get(n.heading);
|
|
452
|
+
if (!(!s || s.length === 0)) {
|
|
453
|
+
i.push(`### ${n.heading}`, "");
|
|
454
|
+
for (const c of s) {
|
|
455
|
+
const a = e ? `([${c.shortHash}](${e}/commit/${c.hash}))` : `(${c.shortHash})`;
|
|
456
|
+
i.push(
|
|
457
|
+
c.scope ? `- **${c.scope}:** ${c.subject} ${a}` : `- ${c.subject} ${a}`
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
i.push("");
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
if (r.length > 0) {
|
|
464
|
+
i.push("### BREAKING CHANGES", "");
|
|
465
|
+
for (const n of r)
|
|
466
|
+
i.push(n.scope ? `- **${n.scope}:** ${n.subject}` : `- ${n.subject}`);
|
|
467
|
+
i.push("");
|
|
468
|
+
}
|
|
469
|
+
return i.join(`
|
|
470
|
+
`).trim();
|
|
471
|
+
}
|
|
472
|
+
function Q(t, e, o, r) {
|
|
473
|
+
const i = Y(t, o), n = [];
|
|
474
|
+
for (let s = 0; s < i.length; s++) {
|
|
475
|
+
const c = i[s], a = s < i.length - 1 ? i[s + 1] : null, g = c.startsWith(o) ? c.slice(o.length) : c, u = q(t, g, c, a, r), f = z(
|
|
476
|
+
c,
|
|
477
|
+
a,
|
|
478
|
+
t,
|
|
479
|
+
C.join(t, e.path)
|
|
480
|
+
), p = J(f, r);
|
|
481
|
+
n.push(u), n.push(""), n.push(p || "**Note:** Version bump only for package"), n.push("");
|
|
482
|
+
}
|
|
483
|
+
return n.join(`
|
|
484
|
+
`).trim() + `
|
|
485
|
+
`;
|
|
486
|
+
}
|
|
487
|
+
async function dt(t) {
|
|
488
|
+
const {
|
|
489
|
+
packages: e,
|
|
490
|
+
rootDir: o = process.cwd(),
|
|
491
|
+
generateRoot: r = !0,
|
|
492
|
+
includeRootHeader: i = !0,
|
|
493
|
+
tagVersionPrefix: n = "v"
|
|
494
|
+
} = t;
|
|
495
|
+
console.log(l.cyan(`
|
|
496
|
+
Generating initial CHANGELOG.md files...
|
|
497
|
+
`));
|
|
498
|
+
const s = K(o);
|
|
499
|
+
for (const c of e) {
|
|
500
|
+
const a = C.join(o, c.path, "CHANGELOG.md");
|
|
501
|
+
if (N(a)) {
|
|
502
|
+
const u = `${a}.backup`, f = E(a, "utf-8");
|
|
503
|
+
b(u, f, "utf-8"), console.log(l.gray(` Backed up ${a} to ${u}`));
|
|
504
|
+
}
|
|
505
|
+
console.log(l.blue(`
|
|
506
|
+
Generating changelog for ${c.name}...`));
|
|
507
|
+
const g = Q(o, c, n, s);
|
|
508
|
+
b(a, g, "utf-8"), console.log(l.green(` Generated ${a}`));
|
|
509
|
+
}
|
|
510
|
+
r && await D({ packages: e, rootDir: o, includeRootHeader: i }), console.log(l.green(`
|
|
511
|
+
Initial changelogs generated successfully!`)), console.log(l.cyan(`
|
|
512
|
+
Next steps:`)), console.log(l.cyan(" 1. Review the generated CHANGELOG.md files")), console.log(l.cyan(" 2. Make any manual adjustments if needed")), console.log(l.cyan(` 3. Commit the changes
|
|
513
|
+
`));
|
|
514
|
+
}
|
|
515
|
+
export {
|
|
516
|
+
gt as a,
|
|
517
|
+
it as b,
|
|
518
|
+
ut as c,
|
|
519
|
+
rt as d,
|
|
520
|
+
lt as e,
|
|
521
|
+
st as f,
|
|
522
|
+
D as g,
|
|
523
|
+
dt as h,
|
|
524
|
+
at as p,
|
|
525
|
+
ct as r,
|
|
526
|
+
ft as s
|
|
527
|
+
};
|
package/dist/release-config.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { parse as b, valid as
|
|
2
|
-
import { readFileSync as
|
|
1
|
+
import { parse as b, valid as N } from "semver";
|
|
2
|
+
import { readFileSync as P, writeFileSync as $ } from "node:fs";
|
|
3
3
|
import R from "node:path";
|
|
4
|
-
import
|
|
5
|
-
import { argv as
|
|
4
|
+
import T from "mri";
|
|
5
|
+
import { argv as D } from "node:process";
|
|
6
6
|
import n from "chalk";
|
|
7
|
-
import { sync as
|
|
8
|
-
import
|
|
9
|
-
import { e as
|
|
10
|
-
import {
|
|
11
|
-
const c =
|
|
7
|
+
import { sync as h } from "cross-spawn";
|
|
8
|
+
import y from "prompts";
|
|
9
|
+
import { f as E, e as I, a as L, s as S, g as j, b as H, c as U, d as F, r as J, p as M } from "./generate-changelogs-BPFwnUNn.js";
|
|
10
|
+
import { h as ge } from "./generate-changelogs-BPFwnUNn.js";
|
|
11
|
+
const c = T(D.slice(2));
|
|
12
12
|
c.dry;
|
|
13
|
-
function
|
|
14
|
-
const
|
|
15
|
-
return { pkg: JSON.parse(
|
|
13
|
+
function w(t) {
|
|
14
|
+
const o = R.resolve(t), e = R.resolve(o, "package.json");
|
|
15
|
+
return { pkg: JSON.parse(P(e, "utf-8")), pkgDir: o, pkgPath: e };
|
|
16
16
|
}
|
|
17
|
-
async function
|
|
18
|
-
const { releaseType:
|
|
17
|
+
async function O() {
|
|
18
|
+
const { releaseType: t } = await y({
|
|
19
19
|
type: "select",
|
|
20
20
|
name: "releaseType",
|
|
21
21
|
message: "Select release type",
|
|
@@ -26,10 +26,10 @@ async function F() {
|
|
|
26
26
|
{ title: "Custom version", value: "custom" }
|
|
27
27
|
]
|
|
28
28
|
});
|
|
29
|
-
return
|
|
29
|
+
return t;
|
|
30
30
|
}
|
|
31
|
-
async function
|
|
32
|
-
const
|
|
31
|
+
async function G(t) {
|
|
32
|
+
const o = b(t), e = o && o.prerelease.length > 0, s = e ? o.prerelease[0] : null, { preid: a } = await y({
|
|
33
33
|
type: "select",
|
|
34
34
|
name: "preid",
|
|
35
35
|
message: "Select prerelease identifier",
|
|
@@ -51,73 +51,73 @@ async function L(o) {
|
|
|
51
51
|
if (a)
|
|
52
52
|
return e && s === a ? { preid: a, lernaVersionArg: "prerelease", lernaPreidArgs: [] } : { preid: a, lernaVersionArg: "prerelease", lernaPreidArgs: ["--preid", a] };
|
|
53
53
|
}
|
|
54
|
-
async function
|
|
55
|
-
const { customVersion:
|
|
54
|
+
async function B(t) {
|
|
55
|
+
const { customVersion: o } = await y({
|
|
56
56
|
type: "text",
|
|
57
57
|
name: "customVersion",
|
|
58
58
|
message: "Enter custom version",
|
|
59
|
-
initial:
|
|
60
|
-
validate: (e) =>
|
|
59
|
+
initial: t,
|
|
60
|
+
validate: (e) => N(e) ? !0 : "Invalid semver version"
|
|
61
61
|
});
|
|
62
|
-
return
|
|
62
|
+
return o;
|
|
63
63
|
}
|
|
64
|
-
async function
|
|
65
|
-
const { yes:
|
|
64
|
+
async function W() {
|
|
65
|
+
const { yes: t } = await y({
|
|
66
66
|
type: "confirm",
|
|
67
67
|
name: "yes",
|
|
68
68
|
message: "Ready to release. Continue?"
|
|
69
69
|
});
|
|
70
|
-
return !!
|
|
70
|
+
return !!t;
|
|
71
71
|
}
|
|
72
72
|
function d() {
|
|
73
73
|
console.log(n.yellow(`
|
|
74
74
|
Release cancelled
|
|
75
75
|
`));
|
|
76
76
|
}
|
|
77
|
-
function
|
|
78
|
-
const e = ["lerna", "version", ...
|
|
79
|
-
return e.push("--tag-version-prefix",
|
|
77
|
+
function Y(t, o) {
|
|
78
|
+
const e = ["lerna", "version", ...t];
|
|
79
|
+
return e.push("--conventional-commits"), e.push("--tag-version-prefix", o.tagVersionPrefix), e.push("--no-push"), o.isDryRun && e.push("--no-git-tag-version"), o.forcePublish && (e.push("--force-publish"), console.log(n.yellow(`
|
|
80
80
|
Force publish mode - all packages will be versioned
|
|
81
81
|
`))), e;
|
|
82
82
|
}
|
|
83
|
-
function
|
|
83
|
+
function q(t) {
|
|
84
84
|
console.log(n.cyan(`
|
|
85
|
-
Running: npx ${
|
|
85
|
+
Running: npx ${t.join(" ")}
|
|
86
86
|
`));
|
|
87
|
-
const
|
|
88
|
-
|
|
87
|
+
const o = h("npx", t, { stdio: "inherit" });
|
|
88
|
+
o.status !== 0 && (console.error(n.red(`
|
|
89
89
|
Release process failed
|
|
90
|
-
`)), process.exit(
|
|
90
|
+
`)), process.exit(o.status || 1));
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
const
|
|
94
|
-
for (const e of
|
|
95
|
-
const { pkg: s } =
|
|
96
|
-
|
|
92
|
+
function z(t) {
|
|
93
|
+
const o = {};
|
|
94
|
+
for (const e of t) {
|
|
95
|
+
const { pkg: s } = w(e.path);
|
|
96
|
+
o[e.path] = s.version;
|
|
97
97
|
}
|
|
98
|
-
return
|
|
98
|
+
return o;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
for (const e of
|
|
102
|
-
const { pkg: s } =
|
|
103
|
-
if (s.version !==
|
|
100
|
+
function K(t, o) {
|
|
101
|
+
for (const e of t) {
|
|
102
|
+
const { pkg: s } = w(e.path);
|
|
103
|
+
if (s.version !== o[e.path])
|
|
104
104
|
return s.version;
|
|
105
105
|
}
|
|
106
106
|
return null;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function Q(t, o, e) {
|
|
109
109
|
if (console.log(n.gray(`
|
|
110
|
-
--- Release diagnostics ---`)), console.log(n.gray(` tagVersionPrefix: "${
|
|
111
|
-
const s =
|
|
110
|
+
--- Release diagnostics ---`)), console.log(n.gray(` tagVersionPrefix: "${t}"`)), console.log(n.gray(` looking for tags: ${t}${o}.*`)), e) {
|
|
111
|
+
const s = h("git", ["rev-list", "--count", `${e}..HEAD`], {
|
|
112
112
|
stdio: "pipe",
|
|
113
113
|
encoding: "utf-8"
|
|
114
|
-
}), a = s.status === 0 ? s.stdout.trim() : "?",
|
|
114
|
+
}), a = s.status === 0 ? s.stdout.trim() : "?", f = h(
|
|
115
115
|
"git",
|
|
116
116
|
["log", `${e}..HEAD`, "--oneline", "--grep", "^feat\\|^fix\\|^perf\\|^revert"],
|
|
117
117
|
{ stdio: "pipe", encoding: "utf-8" }
|
|
118
|
-
),
|
|
118
|
+
), i = f.status === 0 ? f.stdout.trim().split(`
|
|
119
119
|
`).filter(Boolean).length : 0;
|
|
120
|
-
console.log(n.gray(` last matching tag: ${e}`)), console.log(n.gray(` commits since tag: ${a}`)), console.log(n.gray(` conventional commits: ${
|
|
120
|
+
console.log(n.gray(` last matching tag: ${e}`)), console.log(n.gray(` commits since tag: ${a}`)), console.log(n.gray(` conventional commits: ${i}`)), i === 0 && parseInt(a) > 0 && console.log(
|
|
121
121
|
n.yellow(
|
|
122
122
|
" No conventional commits found. Use --force to publish anyway."
|
|
123
123
|
)
|
|
@@ -127,109 +127,69 @@ function J(o, t, e) {
|
|
|
127
127
|
console.log(n.gray(`---------------------------
|
|
128
128
|
`));
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
const e = i("git", ["describe", "--tags", "--abbrev=0", "--match", `${t}${o}.*`], {
|
|
132
|
-
stdio: "pipe",
|
|
133
|
-
encoding: "utf-8"
|
|
134
|
-
});
|
|
135
|
-
return e.status === 0 && e.stdout ? e.stdout.toString().trim() : null;
|
|
136
|
-
}
|
|
137
|
-
function M() {
|
|
138
|
-
const o = i("git", ["describe", "--tags", "--abbrev=0"], {
|
|
139
|
-
stdio: "pipe",
|
|
140
|
-
encoding: "utf-8"
|
|
141
|
-
});
|
|
142
|
-
return o.status === 0 && o.stdout ? o.stdout.toString().trim() : null;
|
|
143
|
-
}
|
|
144
|
-
function Y(o) {
|
|
145
|
-
const t = ["package.json", "yarn.lock", "CHANGELOG.md"];
|
|
146
|
-
for (const e of o)
|
|
147
|
-
t.push(`${e.path}/package.json`), t.push(`${e.path}/CHANGELOG.md`);
|
|
148
|
-
return t.filter((e) => N(e));
|
|
149
|
-
}
|
|
150
|
-
function q(o) {
|
|
151
|
-
i("git", ["add", ...o], { stdio: "inherit" }).status !== 0 && (console.error(n.red(`
|
|
152
|
-
Failed to stage changes
|
|
153
|
-
`)), process.exit(1)), i("git", ["commit", "--amend", "--no-edit"], { stdio: "inherit" }).status !== 0 && (console.error(n.red(`
|
|
154
|
-
Failed to amend commit
|
|
155
|
-
`)), process.exit(1));
|
|
156
|
-
}
|
|
157
|
-
function z(o) {
|
|
158
|
-
i("git", ["tag", "-f", "-a", o, "-m", o], { stdio: "inherit" }).status !== 0 && (console.error(n.red(`
|
|
159
|
-
Failed to recreate tag
|
|
160
|
-
`)), process.exit(1));
|
|
161
|
-
}
|
|
162
|
-
function K(o) {
|
|
163
|
-
console.log(n.cyan(`
|
|
164
|
-
Pushing changes to remote...
|
|
165
|
-
`)), i("git", ["push", "origin", "HEAD", "--force-with-lease"], { stdio: "inherit" }).status !== 0 && (console.error(n.red(`
|
|
166
|
-
Failed to push commit
|
|
167
|
-
`)), process.exit(1)), i("git", ["push", "origin", o, "--force"], { stdio: "inherit" }).status !== 0 && (console.error(n.red(`
|
|
168
|
-
Failed to push tag
|
|
169
|
-
`)), process.exit(1));
|
|
170
|
-
}
|
|
171
|
-
async function re(o) {
|
|
130
|
+
async function ie(t) {
|
|
172
131
|
const {
|
|
173
|
-
packages:
|
|
132
|
+
packages: o,
|
|
174
133
|
tagVersionPrefix: e = "v",
|
|
175
134
|
customHooks: s,
|
|
176
|
-
updateRootVersion: a = !0
|
|
177
|
-
|
|
178
|
-
|
|
135
|
+
updateRootVersion: a = !0,
|
|
136
|
+
forcePublish: f = !1
|
|
137
|
+
} = t;
|
|
138
|
+
if (o.length === 0)
|
|
179
139
|
throw new Error("No packages to release");
|
|
180
|
-
const
|
|
181
|
-
|
|
140
|
+
const i = !!c.dry;
|
|
141
|
+
i && console.log(n.yellow(`
|
|
182
142
|
DRY RUN MODE - No git operations will be performed
|
|
183
143
|
`));
|
|
184
|
-
const { pkg:
|
|
185
|
-
|
|
186
|
-
const
|
|
187
|
-
if (!
|
|
188
|
-
const
|
|
189
|
-
if (
|
|
190
|
-
g
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
g
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
144
|
+
const { pkg: V } = w(o[0].path), v = V.version, k = v.split(".").slice(0, 2).join("."), A = E(k, e);
|
|
145
|
+
Q(e, k, A);
|
|
146
|
+
const g = await O();
|
|
147
|
+
if (!g) return d();
|
|
148
|
+
const m = [];
|
|
149
|
+
if (g !== "auto") {
|
|
150
|
+
if (g === "prerelease") {
|
|
151
|
+
const r = await G(v);
|
|
152
|
+
if (!r) return d();
|
|
153
|
+
m.push(r.lernaVersionArg, ...r.lernaPreidArgs), c.tag || (c.tag = r.preid);
|
|
154
|
+
} else if (g === "graduate")
|
|
155
|
+
m.push("--conventional-graduate");
|
|
156
|
+
else if (g === "custom") {
|
|
157
|
+
const r = await B(v);
|
|
158
|
+
if (!r) return d();
|
|
159
|
+
m.push(r);
|
|
160
|
+
const l = b(r);
|
|
161
|
+
if (l && l.prerelease.length > 0 && !c.tag) {
|
|
162
|
+
const u = l.prerelease[0];
|
|
163
|
+
typeof u == "string" && (c.tag = u);
|
|
164
|
+
}
|
|
205
165
|
}
|
|
206
166
|
}
|
|
207
|
-
if (!await
|
|
208
|
-
const
|
|
167
|
+
if (!await W()) return d();
|
|
168
|
+
const C = Y(m, {
|
|
209
169
|
tagVersionPrefix: e,
|
|
210
|
-
isDryRun:
|
|
211
|
-
forcePublish: !!c.force
|
|
212
|
-
}),
|
|
213
|
-
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
170
|
+
isDryRun: i,
|
|
171
|
+
forcePublish: f || !!c.force
|
|
172
|
+
}), x = z(o);
|
|
173
|
+
q(C);
|
|
174
|
+
const p = K(o, x);
|
|
175
|
+
if (!p) {
|
|
216
176
|
console.log(n.yellow(`
|
|
217
177
|
No packages were versioned. Nothing to release.
|
|
218
178
|
`));
|
|
219
179
|
return;
|
|
220
180
|
}
|
|
221
|
-
if (a &&
|
|
181
|
+
if (a && X(p), s && (console.log(n.cyan(`
|
|
222
182
|
Running post-version hooks...
|
|
223
|
-
`)), await s(
|
|
183
|
+
`)), await s(p)), !i) {
|
|
224
184
|
console.log(n.cyan(`
|
|
225
185
|
Updating yarn.lock with new package versions...
|
|
226
186
|
`));
|
|
227
|
-
const r =
|
|
187
|
+
const r = h("yarn", ["install"], { stdio: "inherit" });
|
|
228
188
|
r.status !== 0 && (console.error(n.red(`
|
|
229
189
|
Failed to update yarn.lock
|
|
230
190
|
`)), process.exit(r.status || 1));
|
|
231
191
|
}
|
|
232
|
-
if (
|
|
192
|
+
if (I(o, !1), L(o, p, !1), S(o, p, e, !1), j({ packages: o }, !1), i)
|
|
233
193
|
console.log(n.yellow(`
|
|
234
194
|
Dry run completed successfully!
|
|
235
195
|
`)), console.log(n.cyan("Changes made:")), console.log(n.cyan(" - Updated package versions")), console.log(n.cyan(` - Generated/updated CHANGELOG.md files
|
|
@@ -237,24 +197,32 @@ Dry run completed successfully!
|
|
|
237
197
|
`)), console.log(n.yellow("To revert all changes:")), console.log(n.cyan(` git checkout -- .
|
|
238
198
|
`));
|
|
239
199
|
else {
|
|
240
|
-
const r =
|
|
200
|
+
const r = H();
|
|
241
201
|
r || (console.error(n.red(`
|
|
242
202
|
Could not determine the git tag created by Lerna
|
|
243
203
|
`)), process.exit(1));
|
|
244
|
-
const
|
|
245
|
-
|
|
204
|
+
const l = U(), u = `release: ${e}`;
|
|
205
|
+
(!l || !l.startsWith(u)) && (console.error(
|
|
206
|
+
n.red(
|
|
207
|
+
`
|
|
208
|
+
Tag validation failed: HEAD commit message "${l}" does not match expected pattern "${u}*".
|
|
209
|
+
This may indicate extra commits were made after Lerna's release commit.
|
|
210
|
+
Aborting to prevent amending/tagging the wrong commit.
|
|
211
|
+
`
|
|
212
|
+
)
|
|
213
|
+
), process.exit(1)), F(), J(r), M(r), console.log(n.green(`
|
|
246
214
|
Release completed successfully!
|
|
247
215
|
`)), console.log(n.cyan(`npmTag will be automatically determined from git tag in CI
|
|
248
216
|
`));
|
|
249
217
|
}
|
|
250
218
|
}
|
|
251
|
-
function
|
|
252
|
-
const e = "package.json", s = JSON.parse(
|
|
253
|
-
s.version !==
|
|
254
|
-
`, "utf-8"), console.log(n.gray(` Updated root package.json version: ${
|
|
219
|
+
function X(t, o) {
|
|
220
|
+
const e = "package.json", s = JSON.parse(P(e, "utf-8"));
|
|
221
|
+
s.version !== t && (s.version = t, $(e, JSON.stringify(s, null, 2) + `
|
|
222
|
+
`, "utf-8"), console.log(n.gray(` Updated root package.json version: ${t}`)));
|
|
255
223
|
}
|
|
256
224
|
export {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
225
|
+
ge as generateInitialChangelogs,
|
|
226
|
+
j as generateRootChangelog,
|
|
227
|
+
ie as release
|
|
260
228
|
};
|
package/dist/src/changelog.d.ts
CHANGED
|
@@ -13,13 +13,63 @@ export declare function addVersionBumpNotes(content: string): string;
|
|
|
13
13
|
*/
|
|
14
14
|
export declare function enhancePackageChangelogs(packages: PackageConfig[], dryRun?: boolean): void;
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Ensures each package has an entry for the current release version.
|
|
17
|
+
* If Lerna skipped a package because it had no direct changes, we still add
|
|
18
|
+
* a placeholder section for the version so lockstep releases stay aligned.
|
|
18
19
|
*/
|
|
19
|
-
export declare function
|
|
20
|
+
export declare function ensureCurrentVersionEntries(packages: PackageConfig[], version: string, dryRun?: boolean): void;
|
|
21
|
+
/**
|
|
22
|
+
* Replaces "Version bump only" current sections with git-derived changelog
|
|
23
|
+
* entries when a package had only non-default conventional commit types
|
|
24
|
+
* (e.g. refactor/docs/build) that Lerna omitted from the package changelog.
|
|
25
|
+
*/
|
|
26
|
+
export declare function supplementCurrentVersionEntries(packages: PackageConfig[], version: string, tagVersionPrefix?: string, dryRun?: boolean): void;
|
|
27
|
+
/**
|
|
28
|
+
* Sorts version strings in descending order by release date when available.
|
|
29
|
+
* Falls back to semver.rcompare, then string comparison.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sortVersionsDescending(versions: string[], versionHeaders?: Record<string, string>): string[];
|
|
20
32
|
/**
|
|
21
33
|
* Generates a consolidated root CHANGELOG.md from package changelogs,
|
|
22
34
|
* grouped by version with sub-headings per package.
|
|
23
35
|
*/
|
|
24
36
|
export declare function generateRootChangelog(options: RootChangelogOptions, dryRun?: boolean): void;
|
|
37
|
+
/**
|
|
38
|
+
* Scans package changelogs for "Version bump only" entries and fills them
|
|
39
|
+
* with actual conventional commit content from git history.
|
|
40
|
+
*
|
|
41
|
+
* Handles non-ancestor tags (after rebase/force-push) by resolving via merge-base.
|
|
42
|
+
* Deduplicates against commits already present in the changelog.
|
|
43
|
+
*/
|
|
44
|
+
export declare function backfillEmptyVersions(packages: PackageConfig[], tagPrefix: string, dryRun?: boolean): void;
|
|
45
|
+
/**
|
|
46
|
+
* Removes duplicate commit entries across changelog versions.
|
|
47
|
+
* Each commit should only appear in the oldest version that contains it.
|
|
48
|
+
* This handles cases where Lerna attributes commits to a new version
|
|
49
|
+
* that were already recorded in backfilled older versions.
|
|
50
|
+
*/
|
|
51
|
+
export declare function deduplicateChangelog(packages: PackageConfig[], dryRun?: boolean): void;
|
|
52
|
+
/**
|
|
53
|
+
* Inserts missing version entries into package CHANGELOGs.
|
|
54
|
+
*
|
|
55
|
+
* In Lerna fixed-mode, packages with no changes sometimes don't get
|
|
56
|
+
* a CHANGELOG entry even though a version tag exists. This function
|
|
57
|
+
* compares git tags with CHANGELOG headers and inserts missing entries
|
|
58
|
+
* with a "Version bump only" placeholder, so that `backfillEmptyVersions`
|
|
59
|
+
* can then attempt to fill them with actual commits.
|
|
60
|
+
*/
|
|
61
|
+
export declare function insertMissingVersionEntries(packages: PackageConfig[], tagPrefix: string, dryRun?: boolean): void;
|
|
62
|
+
/**
|
|
63
|
+
* Supplements version sections that have SOME content but are missing commits
|
|
64
|
+
* present in the git tag range.
|
|
65
|
+
*
|
|
66
|
+
* For each version section with content, compares commit short hashes in the
|
|
67
|
+
* CHANGELOG against commits in the actual git range (previous_tag..version_tag).
|
|
68
|
+
* Appends any missing commits to the existing section.
|
|
69
|
+
*
|
|
70
|
+
* This handles the case where Lerna recorded some commits but the tag includes
|
|
71
|
+
* additional commits made after the CHANGELOG was generated (e.g. post-release
|
|
72
|
+
* fixes amended into the release commit).
|
|
73
|
+
*/
|
|
74
|
+
export declare function supplementIncompleteVersions(packages: PackageConfig[], tagPrefix: string, dryRun?: boolean): void;
|
|
25
75
|
//# sourceMappingURL=changelog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../src/changelog.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../src/changelog.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAiBjF;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAc7D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAK3D;AAID;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,MAAM,UAAQ,GAAG,IAAI,CAiBxF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,EAAE,MAAM,EACf,MAAM,UAAQ,GACb,IAAI,CAyCN;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,aAAa,EAAE,EACzB,OAAO,EAAE,MAAM,EACf,gBAAgB,SAAM,EACtB,MAAM,UAAQ,GACb,IAAI,CAoCN;AAqJD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,EAAE,EAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACtC,MAAM,EAAE,CAcV;AAcD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAQ,GAAG,IAAI,CAkFzF;AA4ED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,aAAa,EAAE,EACzB,SAAS,EAAE,MAAM,EACjB,MAAM,UAAQ,GACb,IAAI,CAqDN;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,aAAa,EAAE,EAAE,MAAM,UAAQ,GAAG,IAAI,CA6EpF;AAID;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,aAAa,EAAE,EACzB,SAAS,EAAE,MAAM,EACjB,MAAM,UAAQ,GACb,IAAI,CAsEN;AAID;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,aAAa,EAAE,EACzB,SAAS,EAAE,MAAM,EACjB,MAAM,UAAQ,GACb,IAAI,CAmFN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-changelogs.d.ts","sourceRoot":"","sources":["../../src/generate-changelogs.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"generate-changelogs.d.ts","sourceRoot":"","sources":["../../src/generate-changelogs.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAElE,OAAO,KAAK,EAAE,aAAa,EAAE,yBAAyB,EAAE,MAAM,uBAAuB,CAAC;AAGtF,YAAY,EAAE,aAAa,EAAE,yBAAyB,EAAE,CAAC;AAqPzD;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,yBAAyB,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCjG;AAGD,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
package/dist/src/git.d.ts
CHANGED
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
import { PackageConfig } from './types';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Finds the last git tag matching `<prefix><majorMinor>.*`.
|
|
5
3
|
* Returns the tag string or null if none found.
|
|
6
4
|
*/
|
|
7
5
|
export declare function findLastMatchingTag(majorMinor: string, tagPrefix: string): string | null;
|
|
8
6
|
/**
|
|
9
|
-
* Gets the
|
|
7
|
+
* Gets the repo URL for changelog commit links.
|
|
10
8
|
*/
|
|
11
|
-
export declare function
|
|
9
|
+
export declare function getRepoUrl(): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a git tag exists.
|
|
12
|
+
*/
|
|
13
|
+
export declare function tagExists(tag: string): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Checks if a ref (tag/commit) is an ancestor of HEAD.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isAncestorOfHead(ref: string): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Gets the merge base between two refs.
|
|
20
|
+
*/
|
|
21
|
+
export declare function getMergeBase(ref1: string, ref2: string): string | null;
|
|
22
|
+
export interface ConventionalCommit {
|
|
23
|
+
hash: string;
|
|
24
|
+
shortHash: string;
|
|
25
|
+
type: string;
|
|
26
|
+
scope: string | null;
|
|
27
|
+
subject: string;
|
|
28
|
+
breaking: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Gets conventional commits in a range, optionally filtered by path.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getConventionalCommitsInRange(from: string, to: string, commitPath?: string): ConventionalCommit[];
|
|
12
34
|
/**
|
|
13
|
-
*
|
|
14
|
-
* Replaces the unsafe `git add -A` with targeted file staging.
|
|
35
|
+
* Gets the latest tag on current HEAD (created by Lerna).
|
|
15
36
|
*/
|
|
16
|
-
export declare function
|
|
37
|
+
export declare function getLatestTag(): string | null;
|
|
17
38
|
/**
|
|
18
|
-
* Stages
|
|
39
|
+
* Stages all modified tracked files and amends the last commit (created by Lerna).
|
|
40
|
+
* Uses `git add -u` to capture all release changes including custom hook modifications
|
|
41
|
+
* (e.g. boilerplate template versions, app dependency updates).
|
|
19
42
|
* Exits on failure.
|
|
20
43
|
*/
|
|
21
|
-
export declare function stageAndAmendCommit(
|
|
44
|
+
export declare function stageAndAmendCommit(): void;
|
|
22
45
|
/**
|
|
23
46
|
* Deletes and recreates the tag as an annotated tag on the amended commit.
|
|
24
47
|
*/
|
|
@@ -28,4 +51,20 @@ export declare function recreateAnnotatedTag(tag: string): void;
|
|
|
28
51
|
* Uses --force-with-lease for the commit (safe force) and --force for the tag.
|
|
29
52
|
*/
|
|
30
53
|
export declare function pushToRemote(tag: string): void;
|
|
54
|
+
/**
|
|
55
|
+
* Returns all version tags matching the given prefix, sorted by semver descending.
|
|
56
|
+
* Example: getAllVersionTags("v") → ["v1.2.4-beta.6", "v1.2.4-beta.5", ...]
|
|
57
|
+
*/
|
|
58
|
+
export declare function getAllVersionTags(prefix: string): string[];
|
|
59
|
+
/**
|
|
60
|
+
* Given a version string, finds the immediately preceding version TAG.
|
|
61
|
+
* Uses semver sorting on all tags matching the prefix.
|
|
62
|
+
* Works even when the target tag does not exist yet (e.g. during dry-run).
|
|
63
|
+
* Example: getPreviousVersionTag("1.2.4-beta.5", "v") → "v1.2.4-beta.4"
|
|
64
|
+
*/
|
|
65
|
+
export declare function getPreviousVersionTag(version: string, prefix: string): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the commit message of HEAD.
|
|
68
|
+
*/
|
|
69
|
+
export declare function getHeadCommitMessage(): string | null;
|
|
31
70
|
//# sourceMappingURL=git.d.ts.map
|
package/dist/src/git.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/git.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUxF;AAED;;GAEG;AACH,wBAAgB,UAAU,IAAI,MAAM,GAAG,IAAI,CAa1C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAK9C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAKrD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAStE;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,UAAU,CAAC,EAAE,MAAM,GAClB,kBAAkB,EAAE,CAsCtB;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAU5C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAY1C;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAMtD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAc9C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAqB1D;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA2BpF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,GAAG,IAAI,CAUpD"}
|
package/dist/src/lerna.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lerna.d.ts","sourceRoot":"","sources":["../../src/lerna.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,MAAM,EAAE,EACzB,OAAO,EAAE,mBAAmB,GAC3B,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"lerna.d.ts","sourceRoot":"","sources":["../../src/lerna.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,MAAM,EAAE,EACzB,OAAO,EAAE,mBAAmB,GAC3B,MAAM,EAAE,CAsBV;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAQpD;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOvF;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,aAAa,EAAE,EACzB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACrC,MAAM,GAAG,IAAI,CAQf;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAqClG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../src/release.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"release.d.ts","sourceRoot":"","sources":["../../src/release.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA8B3D;;;GAGG;AACH,wBAAsB,OAAO,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAwJlE"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -18,12 +18,16 @@ export interface ReleaseConfig {
|
|
|
18
18
|
customHooks?: (version: string) => void | Promise<void>;
|
|
19
19
|
/** Whether to sync root package.json version with packages (default true). */
|
|
20
20
|
updateRootVersion?: boolean;
|
|
21
|
+
/** Whether to version every package on each release (default false). */
|
|
22
|
+
forcePublish?: boolean;
|
|
21
23
|
}
|
|
22
24
|
export interface ChangelogGeneratorOptions {
|
|
23
25
|
packages: PackageConfig[];
|
|
24
26
|
rootDir?: string;
|
|
25
27
|
generateRoot?: boolean;
|
|
26
28
|
includeRootHeader?: boolean;
|
|
29
|
+
/** Git tag prefix used to identify release tags (default "v"). */
|
|
30
|
+
tagVersionPrefix?: string;
|
|
27
31
|
}
|
|
28
32
|
export interface RootChangelogOptions {
|
|
29
33
|
packages: PackageConfig[];
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IACvE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,2FAA2F;IAC3F,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uEAAuE;IACvE,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,wEAAwE;IACxE,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kEAAkE;IAClE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/release-config",
|
|
3
|
-
"version": "1.2.4-beta.
|
|
3
|
+
"version": "1.2.4-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/release-config.js",
|
|
6
6
|
"types": "./dist/src/index.d.ts",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"access": "public",
|
|
35
35
|
"registry": "https://registry.npmjs.org/"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "cc6ef5c98d3f8b6489126a950e994335016ea35d"
|
|
38
38
|
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { sync as A } from "cross-spawn";
|
|
2
|
-
import { existsSync as G, readFileSync as y, writeFileSync as N } from "node:fs";
|
|
3
|
-
import d from "node:path";
|
|
4
|
-
import i from "chalk";
|
|
5
|
-
import { valid as v, rcompare as O } from "semver";
|
|
6
|
-
function H(a) {
|
|
7
|
-
let e = a;
|
|
8
|
-
return e = e.replace(/^# CHANGELOG\s*\n/gm, ""), e = e.replace(/^# Change Log\s*\n/gm, ""), e = e.replace(
|
|
9
|
-
/^All notable changes to this (project|package) will be documented in this file\.\s*\n/gm,
|
|
10
|
-
""
|
|
11
|
-
), e = e.replace(
|
|
12
|
-
/^See \[Conventional Commits\]\(https:\/\/conventionalcommits\.org\) for commit guidelines\.\s*\n/gm,
|
|
13
|
-
""
|
|
14
|
-
), e = e.replace(/\n{3,}/g, `
|
|
15
|
-
|
|
16
|
-
`), e;
|
|
17
|
-
}
|
|
18
|
-
function w(a) {
|
|
19
|
-
return a.replace(
|
|
20
|
-
/^(##\s+\[[^\]]+\][^\n]*\n)\n(##\s+\[|$)/gm,
|
|
21
|
-
`$1
|
|
22
|
-
**Note:** Version bump only for package
|
|
23
|
-
|
|
24
|
-
$2`
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
function W(a, e = !1) {
|
|
28
|
-
console.log(i.cyan(`
|
|
29
|
-
Enhancing changelogs...
|
|
30
|
-
`));
|
|
31
|
-
for (const s of a) {
|
|
32
|
-
const c = d.join(s.path, "CHANGELOG.md");
|
|
33
|
-
if (!G(c)) continue;
|
|
34
|
-
let t = y(c, "utf-8");
|
|
35
|
-
t = H(t), t = w(t), t = t.trim() + `
|
|
36
|
-
`, e || N(c, t, "utf-8");
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
function b(a) {
|
|
40
|
-
const e = {}, s = {}, c = a.split(`
|
|
41
|
-
`);
|
|
42
|
-
let t = null, r = [];
|
|
43
|
-
for (const n of c) {
|
|
44
|
-
const f = n.match(/^##\s+(?:\[)?([\d.a-z-]+)(?:\])?(?:\s+\([^)]+\))?/i);
|
|
45
|
-
f ? (t && r.length > 0 && (e[t] = r.join(`
|
|
46
|
-
`).trim()), t = f[1], r = [], s[t] || (s[t] = n.replace(/^##\s+/, ""))) : t && n.trim() !== "" && !n.startsWith("# CHANGELOG") && !n.startsWith("# Change Log") && !n.startsWith("All notable changes") && !n.startsWith("See [Conventional Commits]") && r.push(n);
|
|
47
|
-
}
|
|
48
|
-
return t && r.length > 0 && (e[t] = r.join(`
|
|
49
|
-
`).trim()), { versionContent: e, versionHeaders: s };
|
|
50
|
-
}
|
|
51
|
-
function L(a) {
|
|
52
|
-
return [...a].sort((e, s) => v(e) && v(s) ? O(e, s) : s.localeCompare(e));
|
|
53
|
-
}
|
|
54
|
-
function E(a, e = !1) {
|
|
55
|
-
const { packages: s, rootDir: c = process.cwd(), includeRootHeader: t = !1 } = a;
|
|
56
|
-
console.log(i.cyan(`
|
|
57
|
-
Generating root CHANGELOG with package grouping...
|
|
58
|
-
`));
|
|
59
|
-
const r = d.join(c, "CHANGELOG.md"), n = {}, f = {};
|
|
60
|
-
for (const m of s) {
|
|
61
|
-
const p = d.join(c, m.path, "CHANGELOG.md");
|
|
62
|
-
if (!G(p)) continue;
|
|
63
|
-
const k = y(p, "utf-8"), u = b(k);
|
|
64
|
-
for (const [l, g] of Object.entries(u.versionContent))
|
|
65
|
-
n[l] || (n[l] = {}), n[l][m.displayName] = g, !f[l] && u.versionHeaders[l] && (f[l] = u.versionHeaders[l]);
|
|
66
|
-
}
|
|
67
|
-
let o = "";
|
|
68
|
-
t && (o = `# CHANGELOG
|
|
69
|
-
|
|
70
|
-
All notable changes to this monorepo will be documented in this file.
|
|
71
|
-
|
|
72
|
-
`);
|
|
73
|
-
const C = L(Object.keys(n));
|
|
74
|
-
for (const m of C) {
|
|
75
|
-
const p = n[m], k = Object.values(p).some((g) => !g || !g.trim() ? !1 : g.replace(/\*\*Note:\*\*\s+Version bump only[^\n]*/gi, "").trim().length > 0), u = f[m] || m;
|
|
76
|
-
if (o += `## ${u}
|
|
77
|
-
|
|
78
|
-
`, !k) {
|
|
79
|
-
o += `**Note:** Version bump only for package
|
|
80
|
-
|
|
81
|
-
`;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
let l = !1;
|
|
85
|
-
for (const g of s) {
|
|
86
|
-
const h = p[g.displayName];
|
|
87
|
-
h && h.trim() && h.replace(/\*\*Note:\*\*\s+Version bump only[^\n]*/gi, "").trim().length > 0 && (l = !0, o += `### ${g.displayName}
|
|
88
|
-
|
|
89
|
-
`, o += `${h}
|
|
90
|
-
|
|
91
|
-
`);
|
|
92
|
-
}
|
|
93
|
-
l || (o += `**Note:** Version bump only for package
|
|
94
|
-
|
|
95
|
-
`);
|
|
96
|
-
}
|
|
97
|
-
o = o.replace(/\n{3,}/g, `
|
|
98
|
-
|
|
99
|
-
`), o = o.trim() + `
|
|
100
|
-
`, e ? console.log(i.yellow(` [dry-run] Would write root CHANGELOG.md (${C.length} versions)`)) : (N(r, o, "utf-8"), console.log(i.green(" Generated root CHANGELOG.md with package grouping")));
|
|
101
|
-
}
|
|
102
|
-
async function x(a) {
|
|
103
|
-
const { packages: e, rootDir: s = process.cwd(), generateRoot: c = !0, includeRootHeader: t = !0 } = a;
|
|
104
|
-
console.log(i.cyan(`
|
|
105
|
-
Generating initial CHANGELOG.md files...
|
|
106
|
-
`));
|
|
107
|
-
for (const r of e) {
|
|
108
|
-
const n = d.join(s, r.path, "CHANGELOG.md");
|
|
109
|
-
if (G(n)) {
|
|
110
|
-
const o = `${n}.backup`, C = y(n, "utf-8");
|
|
111
|
-
N(o, C, "utf-8"), console.log(i.gray(` Backed up ${n} to ${o}`));
|
|
112
|
-
}
|
|
113
|
-
if (console.log(i.blue(`
|
|
114
|
-
Generating changelog for ${r.name}...`)), A(
|
|
115
|
-
"npx",
|
|
116
|
-
[
|
|
117
|
-
"conventional-changelog",
|
|
118
|
-
"-p",
|
|
119
|
-
"conventionalcommits",
|
|
120
|
-
"-i",
|
|
121
|
-
n,
|
|
122
|
-
"-s",
|
|
123
|
-
"-r",
|
|
124
|
-
"0",
|
|
125
|
-
"--commit-path",
|
|
126
|
-
d.join(s, r.path)
|
|
127
|
-
],
|
|
128
|
-
{ stdio: "inherit", cwd: s }
|
|
129
|
-
).status === 0) {
|
|
130
|
-
if (G(n)) {
|
|
131
|
-
let o = y(n, "utf-8");
|
|
132
|
-
o = H(o), o = w(o), o = o.trim() + `
|
|
133
|
-
`, N(n, o, "utf-8");
|
|
134
|
-
}
|
|
135
|
-
console.log(i.green(` Generated ${n}`));
|
|
136
|
-
} else
|
|
137
|
-
console.log(i.red(` Failed to generate ${n}`));
|
|
138
|
-
}
|
|
139
|
-
c && await E({ packages: e, rootDir: s, includeRootHeader: t }), console.log(i.green(`
|
|
140
|
-
Initial changelogs generated successfully!`)), console.log(i.cyan(`
|
|
141
|
-
Next steps:`)), console.log(i.cyan(" 1. Review the generated CHANGELOG.md files")), console.log(i.cyan(" 2. Make any manual adjustments if needed")), console.log(i.cyan(` 3. Commit the changes
|
|
142
|
-
`));
|
|
143
|
-
}
|
|
144
|
-
export {
|
|
145
|
-
x as a,
|
|
146
|
-
W as e,
|
|
147
|
-
E as g
|
|
148
|
-
};
|