@webywz/vibe-commit 0.1.6 → 0.1.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/dist/heuristic.js +28 -12
- package/package.json +1 -1
package/dist/heuristic.js
CHANGED
|
@@ -260,12 +260,13 @@ export function breakingFooterDetail(diff) {
|
|
|
260
260
|
if (removed.length > 0) {
|
|
261
261
|
const names = removed.slice(0, 3).join(", ");
|
|
262
262
|
return removed.length === 1
|
|
263
|
-
? `remove public export ${names}`
|
|
264
|
-
: `remove public exports ${names}`;
|
|
263
|
+
? `remove public export ${names} · 删除公开 export ${names}`
|
|
264
|
+
: `remove public exports ${names} · 删除公开 exports ${names}`;
|
|
265
265
|
}
|
|
266
266
|
const bump = detectMajorVersionBump(diff);
|
|
267
|
-
if (bump)
|
|
268
|
-
return `bump major version to ${bump.to}`;
|
|
267
|
+
if (bump) {
|
|
268
|
+
return `bump major version to ${bump.to} · 主版本升至 ${bump.to}`;
|
|
269
|
+
}
|
|
269
270
|
return undefined;
|
|
270
271
|
}
|
|
271
272
|
/**
|
|
@@ -280,7 +281,7 @@ export function ensureBreakingFooter(message, reason) {
|
|
|
280
281
|
return body === (message.body ?? "") ? message : { ...message, body };
|
|
281
282
|
}
|
|
282
283
|
const detail = (reason ?? message.subject).replace(/\s+/g, " ").trim() ||
|
|
283
|
-
"incompatible API change";
|
|
284
|
+
"incompatible API change · 不兼容的 API 变更";
|
|
284
285
|
const footer = `BREAKING CHANGE: ${detail}`;
|
|
285
286
|
return {
|
|
286
287
|
...message,
|
|
@@ -297,7 +298,7 @@ function detectBreakingFooter(diff) {
|
|
|
297
298
|
}
|
|
298
299
|
// Presence of the token alone still counts as breaking.
|
|
299
300
|
if (diff.hunks.some((hunk) => hunk.lines.some((line) => /^\+\s*BREAKING CHANGE:/i.test(line)))) {
|
|
300
|
-
return "incompatible API change";
|
|
301
|
+
return "incompatible API change · 不兼容的 API 变更";
|
|
301
302
|
}
|
|
302
303
|
return undefined;
|
|
303
304
|
}
|
|
@@ -340,6 +341,20 @@ function exportNameFromDeletedLine(line) {
|
|
|
340
341
|
return def[1];
|
|
341
342
|
return undefined;
|
|
342
343
|
}
|
|
344
|
+
/** Collect every `"version": "..."` value on a +/- diff line (incl. minified JSON). */
|
|
345
|
+
function versionsOnDiffLine(line) {
|
|
346
|
+
if (!(line.startsWith("-") || line.startsWith("+")))
|
|
347
|
+
return [];
|
|
348
|
+
if (line.startsWith("---") || line.startsWith("+++"))
|
|
349
|
+
return [];
|
|
350
|
+
const versions = [];
|
|
351
|
+
const re = /"version"\s*:\s*"([^"]+)"/g;
|
|
352
|
+
for (const match of line.slice(1).matchAll(re)) {
|
|
353
|
+
if (match[1])
|
|
354
|
+
versions.push(match[1]);
|
|
355
|
+
}
|
|
356
|
+
return versions;
|
|
357
|
+
}
|
|
343
358
|
function detectMajorVersionBump(diff) {
|
|
344
359
|
for (const hunk of diff.hunks) {
|
|
345
360
|
if (!/(^|\/)package\.json$/i.test(hunk.path))
|
|
@@ -347,12 +362,13 @@ function detectMajorVersionBump(diff) {
|
|
|
347
362
|
const removed = [];
|
|
348
363
|
const added = [];
|
|
349
364
|
for (const line of hunk.lines) {
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
365
|
+
const versions = versionsOnDiffLine(line);
|
|
366
|
+
if (versions.length === 0)
|
|
367
|
+
continue;
|
|
368
|
+
if (line.startsWith("-"))
|
|
369
|
+
removed.push(...versions);
|
|
370
|
+
else if (line.startsWith("+"))
|
|
371
|
+
added.push(...versions);
|
|
356
372
|
}
|
|
357
373
|
for (const from of removed) {
|
|
358
374
|
for (const to of added) {
|