@bongos/core 1.19.410 → 1.19.411
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/.bongos-core.json +30 -20
- package/docs/adr/0203-doorway-changelog-out-of-module-api.md +54 -0
- package/docs/adr/README.md +1 -0
- package/docs/file-map.md +2 -1
- package/docs/module-api-changelog.md +1263 -0
- package/docs/modules-contract.md +2 -0
- package/docs/recipes/core-release-pipeline.md +3 -3
- package/docs/recipes/private-npm-distribution.md +1 -1
- package/package-lock.json +2 -2
- package/package.json +1 -1
- package/scripts/gds/bump-version.js +53 -25
- package/scripts/gds/deploy-divergence.js +1 -1
- package/scripts/gds/publish-manifest.js +6 -0
- package/src/bongos/module-scope-map.js +6 -1
- package/src/module-api.js +10 -1229
- package/tests/bump_version.mjs +72 -13
package/tests/bump_version.mjs
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
// These tests pin the three properties that must survive any refactor:
|
|
5
5
|
// 1. the bumped literal keeps the exact `^const CORE_VERSION = '…';` shape
|
|
6
6
|
// deploy-divergence.js greps and regex-reads;
|
|
7
|
-
// 2. a changelog entry lands
|
|
7
|
+
// 2. a changelog entry lands above the ledger's closing divider in
|
|
8
|
+
// docs/module-api-changelog.md (ADR 0203 moved the ledger out of
|
|
9
|
+
// src/module-api.js — appending to it there grew the file past the
|
|
10
|
+
// oversized-file fitness ratchet and broke `unit` on main);
|
|
8
11
|
// 3. unrecognizable input throws instead of silently mis-editing.
|
|
9
12
|
|
|
10
13
|
import test from 'node:test';
|
|
@@ -22,16 +25,28 @@ const { bumpPatch, CONST_RE } = bump;
|
|
|
22
25
|
const { execFileSync } = require('node:child_process');
|
|
23
26
|
|
|
24
27
|
const SAMPLE = [
|
|
25
|
-
'// prologue',
|
|
26
|
-
'// 1.19.0 — some entry. (task 1)',
|
|
27
|
-
'// 1.19.1 — another entry. (task 2)',
|
|
28
28
|
'// ---------------------------------------------------------------------------',
|
|
29
|
-
|
|
29
|
+
'// CORE_VERSION — the changelog lives in docs/module-api-changelog.md.',
|
|
30
|
+
'// ---------------------------------------------------------------------------',
|
|
31
|
+
"const CORE_VERSION = '1.19.1'; // carrier; changelog: docs/module-api-changelog.md",
|
|
30
32
|
'',
|
|
31
33
|
'module.exports = { CORE_VERSION };',
|
|
32
34
|
'',
|
|
33
35
|
].join('\n');
|
|
34
36
|
|
|
37
|
+
// The ledger's shape: a fenced text block, oldest entry first, closed by the
|
|
38
|
+
// divider each new entry is inserted immediately above.
|
|
39
|
+
const SAMPLE_CHANGELOG = [
|
|
40
|
+
'# `CORE_VERSION` changelog',
|
|
41
|
+
'',
|
|
42
|
+
'```text',
|
|
43
|
+
'1.19.0 — some entry. (task 1)',
|
|
44
|
+
' 1.19.1 — another entry. (task 2)',
|
|
45
|
+
'---------------------------------------------------------------------------',
|
|
46
|
+
'```',
|
|
47
|
+
'',
|
|
48
|
+
].join('\n');
|
|
49
|
+
|
|
35
50
|
test('bumps patch and keeps the exact const line shape', () => {
|
|
36
51
|
const { from, to, text } = bumpPatch(SAMPLE);
|
|
37
52
|
assert.equal(from, '1.19.1');
|
|
@@ -43,13 +58,29 @@ test('bumps patch and keeps the exact const line shape', () => {
|
|
|
43
58
|
assert.equal([...text.matchAll(/^const CORE_VERSION = /gm)].length, 1);
|
|
44
59
|
});
|
|
45
60
|
|
|
61
|
+
test('the const line points a reader at the ledger, wherever it moved to', () => {
|
|
62
|
+
// The pointer is the whole reason moving the changelog out is safe: someone
|
|
63
|
+
// grepping src/module-api.js for the history must be told where it went.
|
|
64
|
+
const { text } = bumpPatch(SAMPLE);
|
|
65
|
+
assert.match(text, /^const CORE_VERSION = .*docs\/module-api-changelog\.md/m);
|
|
66
|
+
});
|
|
67
|
+
|
|
46
68
|
test('inserts the changelog entry above the divider, mentioning both versions', () => {
|
|
47
|
-
const {
|
|
48
|
-
const dividerAt =
|
|
49
|
-
const entryAt =
|
|
69
|
+
const { changelogText } = bumpPatch(SAMPLE, { note: 'run 42', changelog: SAMPLE_CHANGELOG });
|
|
70
|
+
const dividerAt = changelogText.indexOf('\n---------');
|
|
71
|
+
const entryAt = changelogText.indexOf('1.19.2 — CI auto-patch');
|
|
50
72
|
assert.ok(entryAt !== -1, 'entry exists');
|
|
51
|
-
assert.ok(entryAt < dividerAt, 'entry sits inside the
|
|
52
|
-
assert.match(
|
|
73
|
+
assert.ok(entryAt < dividerAt, 'entry sits inside the ledger, above its closing divider');
|
|
74
|
+
assert.match(changelogText, /landed since 1\.19\.1 with no explicit bump\. run 42\./);
|
|
75
|
+
// oldest-first ordering survives: the new entry is the LAST one.
|
|
76
|
+
assert.ok(changelogText.indexOf('1.19.1 — another entry') < entryAt, 'newest entry lands last');
|
|
77
|
+
// the entry is a comment-free ledger line — no `//` scaffolding leaks back in.
|
|
78
|
+
assert.equal(/^\s*\/\//m.test(changelogText.slice(entryAt - 4, entryAt)), false);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test('without a changelog the ledger is untouched, never silently half-written', () => {
|
|
82
|
+
const { changelogText } = bumpPatch(SAMPLE);
|
|
83
|
+
assert.equal(changelogText, null, 'no ledger in, no ledger out — main() refuses this case');
|
|
53
84
|
});
|
|
54
85
|
|
|
55
86
|
test('a 9→10 patch rollover carries, not truncates', () => {
|
|
@@ -61,16 +92,31 @@ test('a 9→10 patch rollover carries, not truncates', () => {
|
|
|
61
92
|
test('unrecognizable input throws loudly instead of mis-editing', () => {
|
|
62
93
|
assert.throws(() => bumpPatch('nothing here'), /could not find the CORE_VERSION literal/);
|
|
63
94
|
assert.throws(
|
|
64
|
-
() => bumpPatch(
|
|
95
|
+
() => bumpPatch(SAMPLE, { changelog: '# a ledger with no closing divider\n' }),
|
|
65
96
|
/changelog closing divider/
|
|
66
97
|
);
|
|
67
98
|
});
|
|
68
99
|
|
|
69
|
-
test('the REAL src/module-api.js
|
|
100
|
+
test('the REAL src/module-api.js + ledger are bumpable right now (shape not drifted)', () => {
|
|
70
101
|
const real = fs.readFileSync(path.join(ROOT, 'src', 'module-api.js'), 'utf8');
|
|
71
|
-
const
|
|
102
|
+
const ledger = fs.readFileSync(path.join(ROOT, 'docs', 'module-api-changelog.md'), 'utf8');
|
|
103
|
+
const { from, to, text, changelogText } = bumpPatch(real, { changelog: ledger });
|
|
72
104
|
assert.match(from, /^\d+\.\d+\.\d+$/);
|
|
73
105
|
assert.ok(text.includes(`const CORE_VERSION = '${to}';`));
|
|
106
|
+
assert.ok(changelogText.includes(`${to} — CI auto-patch`), 'the real ledger takes the entry');
|
|
107
|
+
assert.ok(changelogText.length > ledger.length, 'the real ledger grew');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('the ledger is NOT a .js file — the ratchet that forced the move stays satisfied', () => {
|
|
111
|
+
// ADR 0203: the carrier appends on every release and pushes straight to main.
|
|
112
|
+
// Inside a .js file that growth trips scripts/gds/fitness-ratchets.js's
|
|
113
|
+
// oversized_file_count (it counts `git ls-files '*.js'`) and turns `unit` red
|
|
114
|
+
// for main and every open PR at once. Markdown is the whole fix.
|
|
115
|
+
const rel = 'docs/module-api-changelog.md';
|
|
116
|
+
assert.equal(rel.endsWith('.js'), false);
|
|
117
|
+
assert.ok(fs.existsSync(path.join(ROOT, rel)), 'the ledger exists where the carrier writes it');
|
|
118
|
+
const api = fs.readFileSync(path.join(ROOT, 'src', 'module-api.js'), 'utf8').split('\n').length;
|
|
119
|
+
assert.ok(api <= 1500, `src/module-api.js is ${api} lines — the 1500-line ratchet is the reason the ledger moved`);
|
|
74
120
|
});
|
|
75
121
|
|
|
76
122
|
// ---- isReleaseCommit: the cascade terminator (task 1002636) ----
|
|
@@ -108,6 +154,19 @@ test('work-merge subjects, junk, and empties never match', () => {
|
|
|
108
154
|
assert.equal(RELEASE_COMMIT_RE.source.startsWith('^'), true, 'anchored — a subject QUOTING a release message must not match');
|
|
109
155
|
});
|
|
110
156
|
|
|
157
|
+
test('publish.yml stages BOTH files the bump writes (ADR 0203)', () => {
|
|
158
|
+
// The carrier writes two files now. Staging only src/module-api.js would push
|
|
159
|
+
// a version whose changelog entry never left the runner — the ledger main
|
|
160
|
+
// carries would fall one entry behind on every release, forever, and nobody
|
|
161
|
+
// would see it until someone went looking for a version's history.
|
|
162
|
+
const m = PUBLISH_YML.match(/^\s*git add (.+)$/m);
|
|
163
|
+
assert.ok(m, 'publish.yml must stage the bump');
|
|
164
|
+
const staged = m[1].trim().split(/\s+/);
|
|
165
|
+
for (const f of ['src/module-api.js', 'docs/module-api-changelog.md']) {
|
|
166
|
+
assert.ok(staged.includes(f), `publish.yml must \`git add\` ${f} — it is written by bump-version.js --apply`);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
111
170
|
test('publish.yml wires the terminator: guard step present, every armed step gated', () => {
|
|
112
171
|
assert.ok(PUBLISH_YML.includes('id: relhead'), 'the Already released? guard step exists');
|
|
113
172
|
assert.match(PUBLISH_YML, /isReleaseCommit/, 'the guard delegates to bump-version.js — single source');
|