@vc-shell/release-config 1.2.4-beta.6 → 1.2.4-beta.8
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-Dx-dDlOU.js +538 -0
- package/dist/release-config.js +97 -77
- package/dist/src/changelog.d.ts +38 -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 +16 -0
- 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-ujWf_gXz.js +0 -352
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,538 @@
|
|
|
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(
|
|
8
|
+
"git",
|
|
9
|
+
[
|
|
10
|
+
"describe",
|
|
11
|
+
"--tags",
|
|
12
|
+
"--abbrev=0",
|
|
13
|
+
"--first-parent",
|
|
14
|
+
"--match",
|
|
15
|
+
`${e}${t}.*`
|
|
16
|
+
],
|
|
17
|
+
{
|
|
18
|
+
stdio: "pipe",
|
|
19
|
+
encoding: "utf-8"
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
return o.status === 0 && o.stdout ? o.stdout.toString().trim() : null;
|
|
23
|
+
}
|
|
24
|
+
function O() {
|
|
25
|
+
const t = d("git", ["remote", "get-url", "origin"], {
|
|
26
|
+
stdio: "pipe",
|
|
27
|
+
encoding: "utf-8"
|
|
28
|
+
});
|
|
29
|
+
return t.status === 0 && t.stdout ? t.stdout.toString().trim().replace(/\.git$/, "").replace(/^git@github\.com:/, "https://github.com/") : null;
|
|
30
|
+
}
|
|
31
|
+
function V(t, e, o) {
|
|
32
|
+
const r = ["log", "--format=%H %s", `${t}..${e}`];
|
|
33
|
+
o && r.push("--", o);
|
|
34
|
+
const i = d("git", r, {
|
|
35
|
+
stdio: "pipe",
|
|
36
|
+
encoding: "utf-8"
|
|
37
|
+
});
|
|
38
|
+
if (i.status !== 0 || !i.stdout) return [];
|
|
39
|
+
const n = [], s = i.stdout.toString().trim().split(`
|
|
40
|
+
`).filter(Boolean), c = /^(\w+)(?:\(([^)]+)\))?(!)?\s*:\s*(.+)$/;
|
|
41
|
+
for (const a of s) {
|
|
42
|
+
const g = a.indexOf(" ");
|
|
43
|
+
if (g === -1) continue;
|
|
44
|
+
const u = a.substring(0, g), p = a.substring(g + 1).match(c);
|
|
45
|
+
p && n.push({
|
|
46
|
+
hash: u,
|
|
47
|
+
shortHash: u.substring(0, 7),
|
|
48
|
+
type: p[1],
|
|
49
|
+
scope: p[2] || null,
|
|
50
|
+
subject: p[4],
|
|
51
|
+
breaking: !!p[3]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
return n;
|
|
55
|
+
}
|
|
56
|
+
function it() {
|
|
57
|
+
const t = d("git", ["describe", "--tags", "--abbrev=0"], {
|
|
58
|
+
stdio: "pipe",
|
|
59
|
+
encoding: "utf-8"
|
|
60
|
+
});
|
|
61
|
+
return t.status === 0 && t.stdout ? t.stdout.toString().trim() : null;
|
|
62
|
+
}
|
|
63
|
+
function rt() {
|
|
64
|
+
d("git", ["add", "-u"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
65
|
+
Failed to stage changes
|
|
66
|
+
`)), process.exit(1)), d("git", ["commit", "--amend", "--no-edit"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
67
|
+
Failed to amend commit
|
|
68
|
+
`)), process.exit(1));
|
|
69
|
+
}
|
|
70
|
+
function ct(t) {
|
|
71
|
+
d("git", ["tag", "-f", "-a", t, "-m", t], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
72
|
+
Failed to recreate tag
|
|
73
|
+
`)), process.exit(1));
|
|
74
|
+
}
|
|
75
|
+
function at(t) {
|
|
76
|
+
console.log(l.cyan(`
|
|
77
|
+
Pushing changes to remote...
|
|
78
|
+
`)), d("git", ["push", "origin", "HEAD", "--force-with-lease"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
79
|
+
Failed to push commit
|
|
80
|
+
`)), process.exit(1)), d("git", ["push", "origin", t, "--force"], { stdio: "inherit" }).status !== 0 && (console.error(l.red(`
|
|
81
|
+
Failed to push tag
|
|
82
|
+
`)), process.exit(1));
|
|
83
|
+
}
|
|
84
|
+
function x(t) {
|
|
85
|
+
const e = d("git", ["tag", "-l", `${t}*`], {
|
|
86
|
+
stdio: "pipe",
|
|
87
|
+
encoding: "utf-8"
|
|
88
|
+
});
|
|
89
|
+
return e.status !== 0 || !e.stdout ? [] : e.stdout.toString().trim().split(`
|
|
90
|
+
`).filter(Boolean).sort((r, i) => {
|
|
91
|
+
const n = v(r.startsWith(t) ? r.slice(t.length) : r), s = v(i.startsWith(t) ? i.slice(t.length) : i);
|
|
92
|
+
return n && s ? H(n, s) : i.localeCompare(r);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function w(t, e) {
|
|
96
|
+
const o = x(e), r = `${e}${t}`, i = o.indexOf(r);
|
|
97
|
+
if (i !== -1)
|
|
98
|
+
return i >= o.length - 1 ? null : o[i + 1];
|
|
99
|
+
const n = v(t);
|
|
100
|
+
if (!n)
|
|
101
|
+
return console.warn(l.yellow(` getPreviousVersionTag: invalid version "${t}"`)), null;
|
|
102
|
+
for (const s of o) {
|
|
103
|
+
const c = v(s.startsWith(e) ? s.slice(e.length) : s);
|
|
104
|
+
if (c && H(n, c) < 0)
|
|
105
|
+
return s;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
function ut() {
|
|
110
|
+
const t = d("git", ["log", "-1", "--format=%s"], {
|
|
111
|
+
stdio: "pipe",
|
|
112
|
+
encoding: "utf-8"
|
|
113
|
+
});
|
|
114
|
+
return t.status === 0 && t.stdout ? t.stdout.toString().trim() : null;
|
|
115
|
+
}
|
|
116
|
+
const S = /^#{1,2}\s+(?:\[)?(\d[\da-z.-]*)(?:\])?/i, j = /\*\*Note:\*\*\s+Version bump only[^\n]*/gi;
|
|
117
|
+
function T(t) {
|
|
118
|
+
let e = t;
|
|
119
|
+
return e = e.replace(/^# CHANGELOG\s*\n/gm, ""), e = e.replace(/^# Change Log\s*\n/gm, ""), e = e.replace(
|
|
120
|
+
/^All notable changes to this (project|package) will be documented in this file\.\s*\n/gm,
|
|
121
|
+
""
|
|
122
|
+
), e = e.replace(
|
|
123
|
+
/^See \[Conventional Commits\]\(https:\/\/conventionalcommits\.org\) for commit guidelines\.\s*\n/gm,
|
|
124
|
+
""
|
|
125
|
+
), e = e.replace(/\n{3,}/g, `
|
|
126
|
+
|
|
127
|
+
`), e;
|
|
128
|
+
}
|
|
129
|
+
function L(t) {
|
|
130
|
+
return t.replace(
|
|
131
|
+
/^(#{1,2}\s+(?:\[[^\]]+\]|\d[\da-z.-]*)[^\n]*\n)\n(?=#{1,2}\s+(?:\[|\d)|$)/gim,
|
|
132
|
+
`$1
|
|
133
|
+
**Note:** Version bump only for package
|
|
134
|
+
|
|
135
|
+
`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function lt(t, e = !1) {
|
|
139
|
+
console.log(l.cyan(`
|
|
140
|
+
Enhancing changelogs...
|
|
141
|
+
`));
|
|
142
|
+
for (const o of t) {
|
|
143
|
+
const r = C.join(o.path, "CHANGELOG.md");
|
|
144
|
+
if (!N(r)) continue;
|
|
145
|
+
let i = E(r, "utf-8");
|
|
146
|
+
i = T(i), i = L(i), i = I(i), i = i.trim() + `
|
|
147
|
+
`, e || b(r, i, "utf-8");
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function gt(t, e, o = !1) {
|
|
151
|
+
console.log(l.cyan(`
|
|
152
|
+
Ensuring current version entries for ${e}...
|
|
153
|
+
`));
|
|
154
|
+
let r = 0;
|
|
155
|
+
for (const i of t) {
|
|
156
|
+
const n = C.join(i.path, "CHANGELOG.md");
|
|
157
|
+
if (!N(n)) continue;
|
|
158
|
+
let s = E(n, "utf-8");
|
|
159
|
+
const c = e.replace(/\./g, "\\.");
|
|
160
|
+
if (new RegExp(`^#{1,2}\\s+\\[?${c}\\]?\\b`, "m").test(s)) continue;
|
|
161
|
+
const g = `## ${e}
|
|
162
|
+
|
|
163
|
+
**Note:** Version bump only for package
|
|
164
|
+
|
|
165
|
+
`, u = s.match(/^#{1,2}\s+\[?\d[\da-z.-]*\]?[^\n]*/m);
|
|
166
|
+
u && u.index !== void 0 ? s = s.substring(0, u.index) + g + s.substring(u.index) : s.trim() ? s = s.trimEnd() + `
|
|
167
|
+
|
|
168
|
+
` + g : s = g, r++, o || b(n, s, "utf-8");
|
|
169
|
+
}
|
|
170
|
+
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"));
|
|
171
|
+
}
|
|
172
|
+
function ft(t, e, o = "v", r = !1) {
|
|
173
|
+
console.log(l.cyan(`
|
|
174
|
+
Supplementing current version entries for ${e}...
|
|
175
|
+
`));
|
|
176
|
+
const i = w(e, o);
|
|
177
|
+
if (!i) {
|
|
178
|
+
console.log(l.gray(" No previous release tag found; skipping current version supplementation"));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const n = O();
|
|
182
|
+
let s = 0;
|
|
183
|
+
for (const c of t) {
|
|
184
|
+
const a = C.join(c.path, "CHANGELOG.md");
|
|
185
|
+
if (!N(a)) continue;
|
|
186
|
+
const g = V(i, "HEAD", c.path), u = W(g, n);
|
|
187
|
+
if (!u) continue;
|
|
188
|
+
const f = E(a, "utf-8"), p = B(f, e, u);
|
|
189
|
+
p !== f && (s++, r || b(a, p, "utf-8"));
|
|
190
|
+
}
|
|
191
|
+
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"));
|
|
192
|
+
}
|
|
193
|
+
function y(t) {
|
|
194
|
+
return t.replace(j, "").trim().length === 0;
|
|
195
|
+
}
|
|
196
|
+
function k(t, e, o) {
|
|
197
|
+
if (!e || o.length === 0) return;
|
|
198
|
+
const r = o.join(`
|
|
199
|
+
`).trim();
|
|
200
|
+
if (!r) return;
|
|
201
|
+
const i = t[e];
|
|
202
|
+
(!i || y(i) && !y(r)) && (t[e] = r);
|
|
203
|
+
}
|
|
204
|
+
function I(t) {
|
|
205
|
+
const e = t.split(`
|
|
206
|
+
`), o = [], r = [], i = /* @__PURE__ */ new Map();
|
|
207
|
+
let n = null;
|
|
208
|
+
const s = () => {
|
|
209
|
+
if (!n) return;
|
|
210
|
+
const c = n.lines.slice(1).join(`
|
|
211
|
+
`).trim(), a = i.get(n.version);
|
|
212
|
+
if (a === void 0) {
|
|
213
|
+
i.set(n.version, r.length), r.push(n), n = null;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const u = r[a].lines.slice(1).join(`
|
|
217
|
+
`).trim();
|
|
218
|
+
y(u) && !y(c) && (r[a] = n), n = null;
|
|
219
|
+
};
|
|
220
|
+
for (const c of e) {
|
|
221
|
+
const a = c.match(S);
|
|
222
|
+
if (a) {
|
|
223
|
+
s(), n = { version: a[1], lines: [c] };
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
n ? n.lines.push(c) : o.push(c);
|
|
227
|
+
}
|
|
228
|
+
return s(), [...o, ...r.flatMap((c) => c.lines)].join(`
|
|
229
|
+
`);
|
|
230
|
+
}
|
|
231
|
+
function B(t, e, o) {
|
|
232
|
+
const r = e.replace(/\./g, "\\."), i = new RegExp(
|
|
233
|
+
`(^#{1,2}\\s+\\[?${r}\\]?[^\\n]*\\n)([\\s\\S]*?)(?=^#{1,2}\\s+\\[?\\d[\\da-z.-]*\\]?|$)`,
|
|
234
|
+
"m"
|
|
235
|
+
);
|
|
236
|
+
return t.replace(i, (n, s, c) => y(c) ? `${s}
|
|
237
|
+
${o.trim()}
|
|
238
|
+
|
|
239
|
+
` : n);
|
|
240
|
+
}
|
|
241
|
+
function P(t) {
|
|
242
|
+
const e = {}, o = {}, r = t.split(`
|
|
243
|
+
`);
|
|
244
|
+
let i = null, n = [];
|
|
245
|
+
for (const s of r) {
|
|
246
|
+
const c = s.match(S);
|
|
247
|
+
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);
|
|
248
|
+
}
|
|
249
|
+
return k(e, i, n), { versionContent: e, versionHeaders: o };
|
|
250
|
+
}
|
|
251
|
+
function F(t, e) {
|
|
252
|
+
return [...t].sort((o, r) => {
|
|
253
|
+
const i = R(e?.[o]), n = R(e?.[r]);
|
|
254
|
+
return i !== null && n !== null && i !== n ? n - i : v(o) && v(r) ? H(o, r) : r.localeCompare(o);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
function R(t) {
|
|
258
|
+
if (!t) return null;
|
|
259
|
+
const e = t.match(/\((\d{4}-\d{2}-\d{2})\)\s*$/);
|
|
260
|
+
if (!e) return null;
|
|
261
|
+
const o = Date.parse(`${e[1]}T00:00:00Z`);
|
|
262
|
+
return Number.isNaN(o) ? null : o;
|
|
263
|
+
}
|
|
264
|
+
function D(t, e = !1) {
|
|
265
|
+
const { packages: o, rootDir: r = process.cwd(), includeRootHeader: i = !1 } = t;
|
|
266
|
+
console.log(l.cyan(`
|
|
267
|
+
Generating root CHANGELOG with package grouping...
|
|
268
|
+
`));
|
|
269
|
+
const n = C.join(r, "CHANGELOG.md"), s = {}, c = {};
|
|
270
|
+
for (const u of o) {
|
|
271
|
+
const f = C.join(r, u.path, "CHANGELOG.md");
|
|
272
|
+
if (!N(f)) continue;
|
|
273
|
+
const p = E(f, "utf-8"), m = P(p);
|
|
274
|
+
for (const [h, $] of Object.entries(m.versionContent))
|
|
275
|
+
s[h] || (s[h] = {}), s[h][u.displayName] = $, !c[h] && m.versionHeaders[h] && (c[h] = m.versionHeaders[h]);
|
|
276
|
+
}
|
|
277
|
+
let a = "";
|
|
278
|
+
i && (a = `# CHANGELOG
|
|
279
|
+
|
|
280
|
+
All notable changes to this monorepo will be documented in this file.
|
|
281
|
+
|
|
282
|
+
`);
|
|
283
|
+
const g = F(Object.keys(s), c);
|
|
284
|
+
for (const u of g) {
|
|
285
|
+
const f = s[u], p = Object.values(f).some(
|
|
286
|
+
($) => !!$?.trim() && !y($)
|
|
287
|
+
), m = c[u] || u;
|
|
288
|
+
if (a += `## ${m}
|
|
289
|
+
|
|
290
|
+
`, !p) {
|
|
291
|
+
a += `**Note:** Version bump only for package
|
|
292
|
+
|
|
293
|
+
`;
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
let h = !1;
|
|
297
|
+
for (const $ of o) {
|
|
298
|
+
const G = f[$.displayName];
|
|
299
|
+
G && G.trim() && (y(G) || (h = !0, a += `### ${$.displayName}
|
|
300
|
+
|
|
301
|
+
`, a += `${G}
|
|
302
|
+
|
|
303
|
+
`));
|
|
304
|
+
}
|
|
305
|
+
h || (a += `**Note:** Version bump only for package
|
|
306
|
+
|
|
307
|
+
`);
|
|
308
|
+
}
|
|
309
|
+
a = a.replace(/\n{3,}/g, `
|
|
310
|
+
|
|
311
|
+
`), a = a.trim() + `
|
|
312
|
+
`, 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")));
|
|
313
|
+
}
|
|
314
|
+
const M = {
|
|
315
|
+
feat: "Features",
|
|
316
|
+
fix: "Bug Fixes",
|
|
317
|
+
perf: "Performance Improvements",
|
|
318
|
+
revert: "Reverts",
|
|
319
|
+
docs: "Documentation",
|
|
320
|
+
style: "Styles",
|
|
321
|
+
refactor: "Code Refactoring",
|
|
322
|
+
test: "Tests",
|
|
323
|
+
build: "Build System",
|
|
324
|
+
ci: "Continuous Integration"
|
|
325
|
+
};
|
|
326
|
+
function W(t, e) {
|
|
327
|
+
const o = {};
|
|
328
|
+
for (const n of t) {
|
|
329
|
+
const s = M[n.type];
|
|
330
|
+
s && (o[s] || (o[s] = []), o[s].push(n));
|
|
331
|
+
}
|
|
332
|
+
if (Object.keys(o).length === 0) return "";
|
|
333
|
+
let r = "";
|
|
334
|
+
const i = [
|
|
335
|
+
"Features",
|
|
336
|
+
"Bug Fixes",
|
|
337
|
+
"Performance Improvements",
|
|
338
|
+
"Reverts",
|
|
339
|
+
"Documentation",
|
|
340
|
+
"Styles",
|
|
341
|
+
"Code Refactoring",
|
|
342
|
+
"Tests",
|
|
343
|
+
"Build System",
|
|
344
|
+
"Continuous Integration"
|
|
345
|
+
];
|
|
346
|
+
for (const n of i) {
|
|
347
|
+
const s = o[n];
|
|
348
|
+
if (!(!s || s.length === 0)) {
|
|
349
|
+
r += `### ${n}
|
|
350
|
+
|
|
351
|
+
`;
|
|
352
|
+
for (const c of s) {
|
|
353
|
+
const a = e ? `([${c.shortHash}](${e}/commit/${c.hash}))` : `(${c.shortHash})`;
|
|
354
|
+
r += c.scope ? `- **${c.scope}:** ${c.subject} ${a}
|
|
355
|
+
` : `- ${c.subject} ${a}
|
|
356
|
+
`;
|
|
357
|
+
}
|
|
358
|
+
r += `
|
|
359
|
+
`;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return r.trim();
|
|
363
|
+
}
|
|
364
|
+
const A = [
|
|
365
|
+
{ heading: "Features", types: ["feat"] },
|
|
366
|
+
{ heading: "Bug Fixes", types: ["fix"] },
|
|
367
|
+
{ heading: "Performance Improvements", types: ["perf"] },
|
|
368
|
+
{ heading: "Reverts", types: ["revert"] },
|
|
369
|
+
{ heading: "Documentation", types: ["docs"] },
|
|
370
|
+
{ heading: "Styles", types: ["style"] },
|
|
371
|
+
{ heading: "Code Refactoring", types: ["refactor"] },
|
|
372
|
+
{ heading: "Tests", types: ["test"] },
|
|
373
|
+
{ heading: "Build System", types: ["build"] },
|
|
374
|
+
{ heading: "CI/CD", types: ["ci"] },
|
|
375
|
+
{ heading: "Chores", hidden: !0, types: ["chore"] }
|
|
376
|
+
], _ = new Map(
|
|
377
|
+
A.flatMap(
|
|
378
|
+
(t) => t.types.map((e) => [e, { heading: t.heading, hidden: t.hidden }])
|
|
379
|
+
)
|
|
380
|
+
);
|
|
381
|
+
function z(t, e, o, r) {
|
|
382
|
+
const i = ["log", "--format=%H %s", e ? `${e}..${t}` : t];
|
|
383
|
+
r && i.push("--", r);
|
|
384
|
+
const n = d("git", i, {
|
|
385
|
+
stdio: "pipe",
|
|
386
|
+
encoding: "utf-8",
|
|
387
|
+
cwd: o
|
|
388
|
+
});
|
|
389
|
+
if (n.status !== 0 || !n.stdout) return [];
|
|
390
|
+
const s = [], c = n.stdout.toString().trim().split(`
|
|
391
|
+
`).filter(Boolean), a = /^(\w+)(?:\(([^)]+)\))?(!)?\s*:\s*(.+)$/;
|
|
392
|
+
for (const g of c) {
|
|
393
|
+
const u = g.indexOf(" ");
|
|
394
|
+
if (u === -1) continue;
|
|
395
|
+
const f = g.substring(0, u), m = g.substring(u + 1).match(a);
|
|
396
|
+
m && s.push({
|
|
397
|
+
hash: f,
|
|
398
|
+
shortHash: f.substring(0, 7),
|
|
399
|
+
type: m[1],
|
|
400
|
+
scope: m[2] || null,
|
|
401
|
+
subject: m[4],
|
|
402
|
+
breaking: !!m[3]
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
return s;
|
|
406
|
+
}
|
|
407
|
+
function Y(t, e) {
|
|
408
|
+
const o = d("git", ["tag", "-l", `${e}*`], {
|
|
409
|
+
stdio: "pipe",
|
|
410
|
+
encoding: "utf-8",
|
|
411
|
+
cwd: t
|
|
412
|
+
});
|
|
413
|
+
if (o.status !== 0 || !o.stdout) return [];
|
|
414
|
+
const r = o.stdout.toString().trim().split(`
|
|
415
|
+
`).filter(Boolean), i = /* @__PURE__ */ new Map();
|
|
416
|
+
for (const n of r)
|
|
417
|
+
i.set(n, U(t, n));
|
|
418
|
+
return r.sort((n, s) => {
|
|
419
|
+
const c = i.get(n) || 0, a = i.get(s) || 0;
|
|
420
|
+
return c !== a ? a - c : s.localeCompare(n);
|
|
421
|
+
});
|
|
422
|
+
}
|
|
423
|
+
function K(t) {
|
|
424
|
+
const e = d("git", ["remote", "get-url", "origin"], {
|
|
425
|
+
stdio: "pipe",
|
|
426
|
+
encoding: "utf-8",
|
|
427
|
+
cwd: t
|
|
428
|
+
});
|
|
429
|
+
return e.status !== 0 || !e.stdout ? null : e.stdout.toString().trim().replace(/\.git$/, "").replace(/^git@github\.com:/, "https://github.com/");
|
|
430
|
+
}
|
|
431
|
+
function U(t, e) {
|
|
432
|
+
const o = d("git", ["log", "-1", "--format=%ct", e], {
|
|
433
|
+
stdio: "pipe",
|
|
434
|
+
encoding: "utf-8",
|
|
435
|
+
cwd: t
|
|
436
|
+
});
|
|
437
|
+
return o.status === 0 && o.stdout?.trim() && Number(o.stdout.trim()) || 0;
|
|
438
|
+
}
|
|
439
|
+
function Z(t, e) {
|
|
440
|
+
const o = d("git", ["log", "-1", "--format=%cs", e], {
|
|
441
|
+
stdio: "pipe",
|
|
442
|
+
encoding: "utf-8",
|
|
443
|
+
cwd: t
|
|
444
|
+
});
|
|
445
|
+
return o.status === 0 && o.stdout?.trim() ? o.stdout.trim() : "";
|
|
446
|
+
}
|
|
447
|
+
function q(t, e, o, r, i) {
|
|
448
|
+
const n = Z(t, o);
|
|
449
|
+
return i && r ? `## [${e}](${i}/compare/${r}...${o})${n ? ` (${n})` : ""}` : `## ${e}${n ? ` (${n})` : ""}`;
|
|
450
|
+
}
|
|
451
|
+
function J(t, e) {
|
|
452
|
+
const o = /* @__PURE__ */ new Map(), r = [];
|
|
453
|
+
for (const n of t) {
|
|
454
|
+
const s = _.get(n.type);
|
|
455
|
+
!s || s.hidden || (o.has(s.heading) || o.set(s.heading, []), o.get(s.heading).push(n), n.breaking && r.push(n));
|
|
456
|
+
}
|
|
457
|
+
if (o.size === 0)
|
|
458
|
+
return "";
|
|
459
|
+
const i = [];
|
|
460
|
+
for (const n of A) {
|
|
461
|
+
if (n.hidden) continue;
|
|
462
|
+
const s = o.get(n.heading);
|
|
463
|
+
if (!(!s || s.length === 0)) {
|
|
464
|
+
i.push(`### ${n.heading}`, "");
|
|
465
|
+
for (const c of s) {
|
|
466
|
+
const a = e ? `([${c.shortHash}](${e}/commit/${c.hash}))` : `(${c.shortHash})`;
|
|
467
|
+
i.push(
|
|
468
|
+
c.scope ? `- **${c.scope}:** ${c.subject} ${a}` : `- ${c.subject} ${a}`
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
i.push("");
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
if (r.length > 0) {
|
|
475
|
+
i.push("### BREAKING CHANGES", "");
|
|
476
|
+
for (const n of r)
|
|
477
|
+
i.push(n.scope ? `- **${n.scope}:** ${n.subject}` : `- ${n.subject}`);
|
|
478
|
+
i.push("");
|
|
479
|
+
}
|
|
480
|
+
return i.join(`
|
|
481
|
+
`).trim();
|
|
482
|
+
}
|
|
483
|
+
function Q(t, e, o, r) {
|
|
484
|
+
const i = Y(t, o), n = [];
|
|
485
|
+
for (let s = 0; s < i.length; s++) {
|
|
486
|
+
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(
|
|
487
|
+
c,
|
|
488
|
+
a,
|
|
489
|
+
t,
|
|
490
|
+
C.join(t, e.path)
|
|
491
|
+
), p = J(f, r);
|
|
492
|
+
n.push(u), n.push(""), n.push(p || "**Note:** Version bump only for package"), n.push("");
|
|
493
|
+
}
|
|
494
|
+
return n.join(`
|
|
495
|
+
`).trim() + `
|
|
496
|
+
`;
|
|
497
|
+
}
|
|
498
|
+
async function dt(t) {
|
|
499
|
+
const {
|
|
500
|
+
packages: e,
|
|
501
|
+
rootDir: o = process.cwd(),
|
|
502
|
+
generateRoot: r = !0,
|
|
503
|
+
includeRootHeader: i = !0,
|
|
504
|
+
tagVersionPrefix: n = "v"
|
|
505
|
+
} = t;
|
|
506
|
+
console.log(l.cyan(`
|
|
507
|
+
Generating initial CHANGELOG.md files...
|
|
508
|
+
`));
|
|
509
|
+
const s = K(o);
|
|
510
|
+
for (const c of e) {
|
|
511
|
+
const a = C.join(o, c.path, "CHANGELOG.md");
|
|
512
|
+
if (N(a)) {
|
|
513
|
+
const u = `${a}.backup`, f = E(a, "utf-8");
|
|
514
|
+
b(u, f, "utf-8"), console.log(l.gray(` Backed up ${a} to ${u}`));
|
|
515
|
+
}
|
|
516
|
+
console.log(l.blue(`
|
|
517
|
+
Generating changelog for ${c.name}...`));
|
|
518
|
+
const g = Q(o, c, n, s);
|
|
519
|
+
b(a, g, "utf-8"), console.log(l.green(` Generated ${a}`));
|
|
520
|
+
}
|
|
521
|
+
r && await D({ packages: e, rootDir: o, includeRootHeader: i }), console.log(l.green(`
|
|
522
|
+
Initial changelogs generated successfully!`)), console.log(l.cyan(`
|
|
523
|
+
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
|
|
524
|
+
`));
|
|
525
|
+
}
|
|
526
|
+
export {
|
|
527
|
+
gt as a,
|
|
528
|
+
it as b,
|
|
529
|
+
ut as c,
|
|
530
|
+
rt as d,
|
|
531
|
+
lt as e,
|
|
532
|
+
st as f,
|
|
533
|
+
D as g,
|
|
534
|
+
dt as h,
|
|
535
|
+
at as p,
|
|
536
|
+
ct as r,
|
|
537
|
+
ft as s
|
|
538
|
+
};
|