@vc-shell/release-config 1.2.4-beta.4 → 1.2.4-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-generate-changelogs.js +1 -1
- package/dist/generate-changelogs-ujWf_gXz.js +352 -0
- package/dist/release-config.js +182 -269
- package/dist/src/changelog.d.ts +40 -0
- package/dist/src/changelog.d.ts.map +1 -0
- package/dist/src/generate-changelogs.d.ts +7 -23
- package/dist/src/generate-changelogs.d.ts.map +1 -1
- package/dist/src/git.d.ts +54 -0
- package/dist/src/git.d.ts.map +1 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/lerna.d.ts +30 -0
- package/dist/src/lerna.d.ts.map +1 -0
- package/dist/src/prompts.d.ts +29 -0
- package/dist/src/prompts.d.ts.map +1 -0
- package/dist/src/release.d.ts +5 -25
- package/dist/src/release.d.ts.map +1 -1
- package/dist/src/types.d.ts +33 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/utils.d.ts +0 -12
- package/dist/src/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/dist/generate-changelogs-_wYT4v6U.js +0 -139
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { sync as p } from "cross-spawn";
|
|
2
|
+
import { existsSync as v, readFileSync as G, writeFileSync as H } from "node:fs";
|
|
3
|
+
import $ from "node:path";
|
|
4
|
+
import a from "chalk";
|
|
5
|
+
import { valid as R, rcompare as j } from "semver";
|
|
6
|
+
function _(e, t) {
|
|
7
|
+
const s = p("git", ["describe", "--tags", "--abbrev=0", "--match", `${t}${e}.*`], {
|
|
8
|
+
stdio: "pipe",
|
|
9
|
+
encoding: "utf-8"
|
|
10
|
+
});
|
|
11
|
+
return s.status === 0 && s.stdout ? s.stdout.toString().trim() : null;
|
|
12
|
+
}
|
|
13
|
+
function x() {
|
|
14
|
+
const e = p("git", ["remote", "get-url", "origin"], {
|
|
15
|
+
stdio: "pipe",
|
|
16
|
+
encoding: "utf-8"
|
|
17
|
+
});
|
|
18
|
+
return e.status === 0 && e.stdout ? e.stdout.toString().trim().replace(/\.git$/, "").replace(/^git@github\.com:/, "https://github.com/") : null;
|
|
19
|
+
}
|
|
20
|
+
function V(e) {
|
|
21
|
+
return p("git", ["rev-parse", "--verify", `refs/tags/${e}`], {
|
|
22
|
+
stdio: "pipe"
|
|
23
|
+
}).status === 0;
|
|
24
|
+
}
|
|
25
|
+
function F(e) {
|
|
26
|
+
return p("git", ["merge-base", "--is-ancestor", e, "HEAD"], {
|
|
27
|
+
stdio: "pipe"
|
|
28
|
+
}).status === 0;
|
|
29
|
+
}
|
|
30
|
+
function P(e, t) {
|
|
31
|
+
const s = p("git", ["merge-base", e, t], {
|
|
32
|
+
stdio: "pipe",
|
|
33
|
+
encoding: "utf-8"
|
|
34
|
+
});
|
|
35
|
+
return s.status === 0 && s.stdout ? s.stdout.toString().trim() : null;
|
|
36
|
+
}
|
|
37
|
+
function S(e, t, s) {
|
|
38
|
+
const l = ["log", "--format=%H %s", `${e}..${t}`];
|
|
39
|
+
s && l.push("--", s);
|
|
40
|
+
const r = p("git", l, {
|
|
41
|
+
stdio: "pipe",
|
|
42
|
+
encoding: "utf-8"
|
|
43
|
+
});
|
|
44
|
+
if (r.status !== 0 || !r.stdout) return [];
|
|
45
|
+
const i = [], n = r.stdout.toString().trim().split(`
|
|
46
|
+
`).filter(Boolean), c = /^(\w+)(?:\(([^)]+)\))?(!)?\s*:\s*(.+)$/;
|
|
47
|
+
for (const o of n) {
|
|
48
|
+
const h = o.indexOf(" ");
|
|
49
|
+
if (h === -1) continue;
|
|
50
|
+
const d = o.substring(0, h), m = o.substring(h + 1).match(c);
|
|
51
|
+
m && i.push({
|
|
52
|
+
hash: d,
|
|
53
|
+
shortHash: d.substring(0, 7),
|
|
54
|
+
type: m[1],
|
|
55
|
+
scope: m[2] || null,
|
|
56
|
+
subject: m[4],
|
|
57
|
+
breaking: !!m[3]
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
return i;
|
|
61
|
+
}
|
|
62
|
+
function J() {
|
|
63
|
+
const e = p("git", ["describe", "--tags", "--abbrev=0"], {
|
|
64
|
+
stdio: "pipe",
|
|
65
|
+
encoding: "utf-8"
|
|
66
|
+
});
|
|
67
|
+
return e.status === 0 && e.stdout ? e.stdout.toString().trim() : null;
|
|
68
|
+
}
|
|
69
|
+
function K() {
|
|
70
|
+
p("git", ["add", "-u"], { stdio: "inherit" }).status !== 0 && (console.error(a.red(`
|
|
71
|
+
Failed to stage changes
|
|
72
|
+
`)), process.exit(1)), p("git", ["commit", "--amend", "--no-edit"], { stdio: "inherit" }).status !== 0 && (console.error(a.red(`
|
|
73
|
+
Failed to amend commit
|
|
74
|
+
`)), process.exit(1));
|
|
75
|
+
}
|
|
76
|
+
function Q(e) {
|
|
77
|
+
p("git", ["tag", "-f", "-a", e, "-m", e], { stdio: "inherit" }).status !== 0 && (console.error(a.red(`
|
|
78
|
+
Failed to recreate tag
|
|
79
|
+
`)), process.exit(1));
|
|
80
|
+
}
|
|
81
|
+
function X(e) {
|
|
82
|
+
console.log(a.cyan(`
|
|
83
|
+
Pushing changes to remote...
|
|
84
|
+
`)), p("git", ["push", "origin", "HEAD", "--force-with-lease"], { stdio: "inherit" }).status !== 0 && (console.error(a.red(`
|
|
85
|
+
Failed to push commit
|
|
86
|
+
`)), process.exit(1)), p("git", ["push", "origin", e, "--force"], { stdio: "inherit" }).status !== 0 && (console.error(a.red(`
|
|
87
|
+
Failed to push tag
|
|
88
|
+
`)), process.exit(1));
|
|
89
|
+
}
|
|
90
|
+
function O(e) {
|
|
91
|
+
let t = e;
|
|
92
|
+
return t = t.replace(/^# CHANGELOG\s*\n/gm, ""), t = t.replace(/^# Change Log\s*\n/gm, ""), t = t.replace(
|
|
93
|
+
/^All notable changes to this (project|package) will be documented in this file\.\s*\n/gm,
|
|
94
|
+
""
|
|
95
|
+
), t = t.replace(
|
|
96
|
+
/^See \[Conventional Commits\]\(https:\/\/conventionalcommits\.org\) for commit guidelines\.\s*\n/gm,
|
|
97
|
+
""
|
|
98
|
+
), t = t.replace(/\n{3,}/g, `
|
|
99
|
+
|
|
100
|
+
`), t;
|
|
101
|
+
}
|
|
102
|
+
function L(e) {
|
|
103
|
+
return e.replace(
|
|
104
|
+
/^(##\s+\[[^\]]+\][^\n]*\n)\n(##\s+\[|$)/gm,
|
|
105
|
+
`$1
|
|
106
|
+
**Note:** Version bump only for package
|
|
107
|
+
|
|
108
|
+
$2`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
function Z(e, t = !1) {
|
|
112
|
+
console.log(a.cyan(`
|
|
113
|
+
Enhancing changelogs...
|
|
114
|
+
`));
|
|
115
|
+
for (const s of e) {
|
|
116
|
+
const l = $.join(s.path, "CHANGELOG.md");
|
|
117
|
+
if (!v(l)) continue;
|
|
118
|
+
let r = G(l, "utf-8");
|
|
119
|
+
r = O(r), r = L(r), r = r.trim() + `
|
|
120
|
+
`, t || H(l, r, "utf-8");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function B(e) {
|
|
124
|
+
const t = {}, s = {}, l = e.split(`
|
|
125
|
+
`);
|
|
126
|
+
let r = null, i = [];
|
|
127
|
+
for (const n of l) {
|
|
128
|
+
const c = n.match(/^##\s+(?:\[)?([\d.a-z-]+)(?:\])?(?:\s+\([^)]+\))?/i);
|
|
129
|
+
c ? (r && i.length > 0 && (t[r] = i.join(`
|
|
130
|
+
`).trim()), r = c[1], i = [], s[r] || (s[r] = n.replace(/^##\s+/, ""))) : r && n.trim() !== "" && !n.startsWith("# CHANGELOG") && !n.startsWith("# Change Log") && !n.startsWith("All notable changes") && !n.startsWith("See [Conventional Commits]") && i.push(n);
|
|
131
|
+
}
|
|
132
|
+
return r && i.length > 0 && (t[r] = i.join(`
|
|
133
|
+
`).trim()), { versionContent: t, versionHeaders: s };
|
|
134
|
+
}
|
|
135
|
+
function D(e) {
|
|
136
|
+
return [...e].sort((t, s) => R(t) && R(s) ? j(t, s) : s.localeCompare(t));
|
|
137
|
+
}
|
|
138
|
+
function I(e, t = !1) {
|
|
139
|
+
const { packages: s, rootDir: l = process.cwd(), includeRootHeader: r = !1 } = e;
|
|
140
|
+
console.log(a.cyan(`
|
|
141
|
+
Generating root CHANGELOG with package grouping...
|
|
142
|
+
`));
|
|
143
|
+
const i = $.join(l, "CHANGELOG.md"), n = {}, c = {};
|
|
144
|
+
for (const d of s) {
|
|
145
|
+
const f = $.join(l, d.path, "CHANGELOG.md");
|
|
146
|
+
if (!v(f)) continue;
|
|
147
|
+
const m = G(f, "utf-8"), y = B(m);
|
|
148
|
+
for (const [u, b] of Object.entries(y.versionContent))
|
|
149
|
+
n[u] || (n[u] = {}), n[u][d.displayName] = b, !c[u] && y.versionHeaders[u] && (c[u] = y.versionHeaders[u]);
|
|
150
|
+
}
|
|
151
|
+
let o = "";
|
|
152
|
+
r && (o = `# CHANGELOG
|
|
153
|
+
|
|
154
|
+
All notable changes to this monorepo will be documented in this file.
|
|
155
|
+
|
|
156
|
+
`);
|
|
157
|
+
const h = D(Object.keys(n));
|
|
158
|
+
for (const d of h) {
|
|
159
|
+
const f = n[d], m = Object.values(f).some((b) => !b || !b.trim() ? !1 : b.replace(/\*\*Note:\*\*\s+Version bump only[^\n]*/gi, "").trim().length > 0), y = c[d] || d;
|
|
160
|
+
if (o += `## ${y}
|
|
161
|
+
|
|
162
|
+
`, !m) {
|
|
163
|
+
o += `**Note:** Version bump only for package
|
|
164
|
+
|
|
165
|
+
`;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
let u = !1;
|
|
169
|
+
for (const b of s) {
|
|
170
|
+
const C = f[b.displayName];
|
|
171
|
+
C && C.trim() && C.replace(/\*\*Note:\*\*\s+Version bump only[^\n]*/gi, "").trim().length > 0 && (u = !0, o += `### ${b.displayName}
|
|
172
|
+
|
|
173
|
+
`, o += `${C}
|
|
174
|
+
|
|
175
|
+
`);
|
|
176
|
+
}
|
|
177
|
+
u || (o += `**Note:** Version bump only for package
|
|
178
|
+
|
|
179
|
+
`);
|
|
180
|
+
}
|
|
181
|
+
o = o.replace(/\n{3,}/g, `
|
|
182
|
+
|
|
183
|
+
`), o = o.trim() + `
|
|
184
|
+
`, t ? console.log(a.yellow(` [dry-run] Would write root CHANGELOG.md (${h.length} versions)`)) : (H(i, o, "utf-8"), console.log(a.green(" Generated root CHANGELOG.md with package grouping")));
|
|
185
|
+
}
|
|
186
|
+
const T = {
|
|
187
|
+
feat: "Features",
|
|
188
|
+
fix: "Bug Fixes",
|
|
189
|
+
perf: "Performance Improvements",
|
|
190
|
+
revert: "Reverts"
|
|
191
|
+
};
|
|
192
|
+
function N(e) {
|
|
193
|
+
return V(e) ? F(e) ? e : P(e, "HEAD") : null;
|
|
194
|
+
}
|
|
195
|
+
function W(e, t) {
|
|
196
|
+
const s = {};
|
|
197
|
+
for (const i of e) {
|
|
198
|
+
const n = T[i.type];
|
|
199
|
+
n && (s[n] || (s[n] = []), s[n].push(i));
|
|
200
|
+
}
|
|
201
|
+
if (Object.keys(s).length === 0) return "";
|
|
202
|
+
let l = "";
|
|
203
|
+
const r = ["Features", "Bug Fixes", "Performance Improvements", "Reverts"];
|
|
204
|
+
for (const i of r) {
|
|
205
|
+
const n = s[i];
|
|
206
|
+
if (!(!n || n.length === 0)) {
|
|
207
|
+
l += `### ${i}
|
|
208
|
+
|
|
209
|
+
`;
|
|
210
|
+
for (const c of n) {
|
|
211
|
+
const o = t ? `([${c.shortHash}](${t}/commit/${c.hash}))` : `(${c.shortHash})`;
|
|
212
|
+
l += c.scope ? `- **${c.scope}:** ${c.subject} ${o}
|
|
213
|
+
` : `- ${c.subject} ${o}
|
|
214
|
+
`;
|
|
215
|
+
}
|
|
216
|
+
l += `
|
|
217
|
+
`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return l.trim();
|
|
221
|
+
}
|
|
222
|
+
function ee(e, t, s = !1) {
|
|
223
|
+
console.log(a.cyan(`
|
|
224
|
+
Backfilling empty changelog versions...
|
|
225
|
+
`));
|
|
226
|
+
const l = x();
|
|
227
|
+
let r = 0;
|
|
228
|
+
for (const i of e) {
|
|
229
|
+
const n = $.join(i.path, "CHANGELOG.md");
|
|
230
|
+
if (!v(n)) continue;
|
|
231
|
+
let c = G(n, "utf-8");
|
|
232
|
+
const o = [];
|
|
233
|
+
for (const f of c.matchAll(/^##\s+\[?([\d.a-z-]+)\]?/gm))
|
|
234
|
+
o.push(f[1]);
|
|
235
|
+
const h = /^(##\s+\[?([\d.a-z-]+)\]?[^\n]*\n)\n\*\*Note:\*\*\s+Version bump only[^\n]*/gm;
|
|
236
|
+
let d = !1;
|
|
237
|
+
c = c.replace(h, (f, m, y) => {
|
|
238
|
+
const u = o.indexOf(y);
|
|
239
|
+
if (u === -1) return f;
|
|
240
|
+
const b = u < o.length - 1 ? o[u + 1] : null;
|
|
241
|
+
if (!b) return f;
|
|
242
|
+
const C = N(`${t}${b}`);
|
|
243
|
+
if (!C) return f;
|
|
244
|
+
let g = N(`${t}${y}`);
|
|
245
|
+
if (!g) {
|
|
246
|
+
const A = u > 0 ? o[u - 1] : null;
|
|
247
|
+
g = A ? N(`${t}${A}`) : null, g || (g = "HEAD");
|
|
248
|
+
}
|
|
249
|
+
if (C === g) return f;
|
|
250
|
+
const w = S(C, g, i.path).filter((A) => !c.includes(A.shortHash)), E = W(w, l);
|
|
251
|
+
return E ? (d = !0, r++, console.log(a.gray(` Backfilled ${i.name} v${y} (${w.length} commits)`)), `${m}
|
|
252
|
+
${E}`) : f;
|
|
253
|
+
}), d && !s && H(n, c, "utf-8");
|
|
254
|
+
}
|
|
255
|
+
r > 0 ? console.log(a.green(` Backfilled ${r} empty changelog version(s)`)) : console.log(a.gray(" No empty versions to backfill"));
|
|
256
|
+
}
|
|
257
|
+
function te(e, t = !1) {
|
|
258
|
+
for (const s of e) {
|
|
259
|
+
const l = $.join(s.path, "CHANGELOG.md");
|
|
260
|
+
if (!v(l)) continue;
|
|
261
|
+
const r = G(l, "utf-8"), i = [], n = /^(##\s+\[?[\d.a-z-]+\]?[^\n]*)\n/gm;
|
|
262
|
+
let c = 0, o = "";
|
|
263
|
+
for (const g of r.matchAll(n))
|
|
264
|
+
o && i.push({ header: o, body: r.substring(c, g.index) }), o = g[1], c = g.index + g[0].length;
|
|
265
|
+
if (o && i.push({ header: o, body: r.substring(c) }), i.length < 2) continue;
|
|
266
|
+
const h = /\[([a-f0-9]{7})\]\(/g, d = /* @__PURE__ */ new Set();
|
|
267
|
+
for (let g = 1; g < i.length; g++)
|
|
268
|
+
for (const k of i[g].body.matchAll(h))
|
|
269
|
+
d.add(k[1]);
|
|
270
|
+
if (d.size === 0) continue;
|
|
271
|
+
const f = i[0].body, m = f.split(`
|
|
272
|
+
`).filter((g) => {
|
|
273
|
+
if (!g.startsWith("- ")) return !0;
|
|
274
|
+
const k = g.match(/\[([a-f0-9]{7})\]\(/);
|
|
275
|
+
return !k || !d.has(k[1]);
|
|
276
|
+
}), y = m.join(`
|
|
277
|
+
`);
|
|
278
|
+
if (y === f) continue;
|
|
279
|
+
i[0].body = y;
|
|
280
|
+
let u = "";
|
|
281
|
+
for (const g of i)
|
|
282
|
+
u += `${g.header}
|
|
283
|
+
${g.body}`;
|
|
284
|
+
u = u.replace(/\n{3,}/g, `
|
|
285
|
+
|
|
286
|
+
`).trim() + `
|
|
287
|
+
`, i[0].body.replace(/###[^\n]*/g, "").trim() || (u = u.replace(
|
|
288
|
+
i[0].body,
|
|
289
|
+
`
|
|
290
|
+
**Note:** Version bump only for package
|
|
291
|
+
|
|
292
|
+
`
|
|
293
|
+
)), t || H(l, u, "utf-8");
|
|
294
|
+
const C = f.split(`
|
|
295
|
+
`).length - m.length;
|
|
296
|
+
C > 0 && console.log(a.gray(` Deduplicated ${s.name}: removed ${C} duplicate entries`));
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
async function ne(e) {
|
|
300
|
+
const { packages: t, rootDir: s = process.cwd(), generateRoot: l = !0, includeRootHeader: r = !0 } = e;
|
|
301
|
+
console.log(a.cyan(`
|
|
302
|
+
Generating initial CHANGELOG.md files...
|
|
303
|
+
`));
|
|
304
|
+
for (const i of t) {
|
|
305
|
+
const n = $.join(s, i.path, "CHANGELOG.md");
|
|
306
|
+
if (v(n)) {
|
|
307
|
+
const o = `${n}.backup`, h = G(n, "utf-8");
|
|
308
|
+
H(o, h, "utf-8"), console.log(a.gray(` Backed up ${n} to ${o}`));
|
|
309
|
+
}
|
|
310
|
+
if (console.log(a.blue(`
|
|
311
|
+
Generating changelog for ${i.name}...`)), p(
|
|
312
|
+
"npx",
|
|
313
|
+
[
|
|
314
|
+
"conventional-changelog",
|
|
315
|
+
"-p",
|
|
316
|
+
"conventionalcommits",
|
|
317
|
+
"-i",
|
|
318
|
+
n,
|
|
319
|
+
"-s",
|
|
320
|
+
"-r",
|
|
321
|
+
"0",
|
|
322
|
+
"--commit-path",
|
|
323
|
+
$.join(s, i.path)
|
|
324
|
+
],
|
|
325
|
+
{ stdio: "inherit", cwd: s }
|
|
326
|
+
).status === 0) {
|
|
327
|
+
if (v(n)) {
|
|
328
|
+
let o = G(n, "utf-8");
|
|
329
|
+
o = O(o), o = L(o), o = o.trim() + `
|
|
330
|
+
`, H(n, o, "utf-8");
|
|
331
|
+
}
|
|
332
|
+
console.log(a.green(` Generated ${n}`));
|
|
333
|
+
} else
|
|
334
|
+
console.log(a.red(` Failed to generate ${n}`));
|
|
335
|
+
}
|
|
336
|
+
l && await I({ packages: t, rootDir: s, includeRootHeader: r }), console.log(a.green(`
|
|
337
|
+
Initial changelogs generated successfully!`)), console.log(a.cyan(`
|
|
338
|
+
Next steps:`)), console.log(a.cyan(" 1. Review the generated CHANGELOG.md files")), console.log(a.cyan(" 2. Make any manual adjustments if needed")), console.log(a.cyan(` 3. Commit the changes
|
|
339
|
+
`));
|
|
340
|
+
}
|
|
341
|
+
export {
|
|
342
|
+
J as a,
|
|
343
|
+
ee as b,
|
|
344
|
+
ne as c,
|
|
345
|
+
te as d,
|
|
346
|
+
Z as e,
|
|
347
|
+
_ as f,
|
|
348
|
+
I as g,
|
|
349
|
+
X as p,
|
|
350
|
+
Q as r,
|
|
351
|
+
K as s
|
|
352
|
+
};
|