@entro314labs/release-kit 2.9.2 → 2.9.3
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/package.json +1 -1
- package/release.mjs +13 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entro314labs/release-kit",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.3",
|
|
4
4
|
"description": "Single-file, zero-dependency release mechanism for JS/TS/Node projects: version bump, changelog roll, commit, annotated tag, push, publish, GitHub release",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"changelog",
|
package/release.mjs
CHANGED
|
@@ -1405,16 +1405,26 @@ const sectionOffsets = (text) => [...text.matchAll(/^## .*$/gm)].map((m) => m.in
|
|
|
1405
1405
|
*/
|
|
1406
1406
|
function insertChangelogSection(text, version, date, body) {
|
|
1407
1407
|
const entry = `## [${version}] - ${date}\n\n${body}\n`
|
|
1408
|
-
|
|
1408
|
+
const offsets = sectionOffsets(text)
|
|
1409
|
+
let comparable = false
|
|
1410
|
+
for (const offset of offsets) {
|
|
1409
1411
|
const heading = /^## \[?v?([\d.]+(?:-[\w.]+)?)\]?/m.exec(
|
|
1410
1412
|
text.slice(offset, text.indexOf('\n', offset)),
|
|
1411
1413
|
)
|
|
1412
|
-
//
|
|
1413
|
-
|
|
1414
|
+
// Headings that carry no version — [Unreleased], and the date headings a changelog
|
|
1415
|
+
// that never adopted semver is made of — are not positions this can order against.
|
|
1416
|
+
if (!heading || !parseVersion(heading[1])) continue
|
|
1417
|
+
comparable = true
|
|
1414
1418
|
if (compareVersions(version, heading[1]) > 0) {
|
|
1415
1419
|
return `${text.slice(0, offset)}${entry}\n${text.slice(offset)}`
|
|
1416
1420
|
}
|
|
1417
1421
|
}
|
|
1422
|
+
// Falling out of the loop means every version section is newer, so the release belongs
|
|
1423
|
+
// at the foot. With nothing to compare against it belongs at the head instead: appending
|
|
1424
|
+
// to a date-headed changelog would file the release below its oldest entry.
|
|
1425
|
+
if (!comparable && offsets.length) {
|
|
1426
|
+
return `${text.slice(0, offsets[0])}${entry}\n${text.slice(offsets[0])}`
|
|
1427
|
+
}
|
|
1418
1428
|
const trimmed = text.trimEnd()
|
|
1419
1429
|
return `${trimmed}\n\n${entry}`
|
|
1420
1430
|
}
|