@release-it/keep-a-changelog 6.0.0 → 7.0.0

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.
@@ -13,6 +13,7 @@ jobs:
13
13
  node:
14
14
  - 18
15
15
  - 20
16
+ - 22
16
17
 
17
18
  runs-on: ${{ matrix.os }}
18
19
  name: ${{ matrix.os }} (Node v${{ matrix.node }})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@release-it/keep-a-changelog",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "description": "Keep-a-changelog plugin for release-it",
5
5
  "type": "module",
6
6
  "exports": "./index.js",
@@ -31,21 +31,21 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "detect-newline": "^4.0.1",
34
- "semver": "^7.6.3",
34
+ "semver": "^7.7.1",
35
35
  "string-template": "^1.0.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "bron": "^2.0.3",
39
39
  "fs-monkey": "^1.0.6",
40
- "memfs": "^4.15.3",
41
- "release-it": "^18.0.0",
42
- "sinon": "^19.0.2"
40
+ "memfs": "^4.17.0",
41
+ "release-it": "^19.0.0",
42
+ "sinon": "^20.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "release-it": "^18.0.0"
45
+ "release-it": "^18.0.0 || ^19.0.0"
46
46
  },
47
47
  "engines": {
48
- "node": ">=18"
48
+ "node": "^20.9.0 || >=22.0.0"
49
49
  },
50
50
  "release-it": {
51
51
  "github": {
package/test.js CHANGED
@@ -13,7 +13,8 @@ const initialDryRunFileContents =
13
13
  vol.fromJSON({
14
14
  './CHANGELOG-FOO.md': '## [FOO]\n\n* Item A\n* Item B',
15
15
  './CHANGELOG-MULTIPLE_UNRELEASED.md': '## [Unreleased]\n* Item A\n\n## [Unreleased]* Item B\nB\n* Item C\n* Item D',
16
- './CHANGELOG-INVALID_ORDER.md': '## [Unreleased]\n\n## [0.2.0]\n* Item A\n\n## [0.3.0]* Item B\nB\n\n## [0.1.0]\n* Item C\n* Item D',
16
+ './CHANGELOG-INVALID_ORDER.md':
17
+ '## [Unreleased]\n\n## [0.2.0]\n* Item A\n\n## [0.3.0]* Item B\nB\n\n## [0.1.0]\n* Item C\n* Item D',
17
18
  './CHANGELOG-EMPTY.md': '## [Unreleased]\n\n\n\n## [1.0.0]\n\n* Item A\n* Item B',
18
19
  './CHANGELOG-FULL.md':
19
20
  '# Changelog\n\n## [Unreleased]\n\n* Item A\n* Item B\n\n## [1.0.0] - 2020-05-02\n\n* Item C\n* Item D',
@@ -43,63 +44,63 @@ const namespace = 'keep-a-changelog';
43
44
 
44
45
  test('should throw for missing changelog file', async t => {
45
46
  const options = { [namespace]: {} };
46
- const plugin = factory(Plugin, { namespace, options });
47
+ const plugin = await factory(Plugin, { namespace, options });
47
48
  await assert.rejects(runTasks(plugin), /ENOENT: no such file or directory/);
48
49
  });
49
50
 
50
51
  test('should throw for missing "unreleased" section', async t => {
51
52
  const options = { [namespace]: { filename: 'CHANGELOG-FOO.md' } };
52
- const plugin = factory(Plugin, { namespace, options });
53
+ const plugin = await factory(Plugin, { namespace, options });
53
54
  await assert.rejects(runTasks(plugin), /Missing "Unreleased" section in CHANGELOG-FOO.md/);
54
55
  });
55
56
 
56
57
  test('should throw for empty "unreleased" section', async t => {
57
58
  const options = { [namespace]: { filename: 'CHANGELOG-EMPTY.md' } };
58
- const plugin = factory(Plugin, { namespace, options });
59
+ const plugin = await factory(Plugin, { namespace, options });
59
60
  await assert.rejects(runTasks(plugin), /There are no entries under "Unreleased" section in CHANGELOG-EMPTY\.md/);
60
61
  });
61
62
 
62
63
  test('should throw for missing "unreleased" section when no-increment flag is set if changelog is misformatted', async t => {
63
64
  const options = { increment: false, [namespace]: { filename: 'CHANGELOG-FOO.md' } };
64
- const plugin = factory(Plugin, { namespace, options });
65
+ const plugin = await factory(Plugin, { namespace, options });
65
66
  await assert.rejects(runTasks(plugin), /Missing "Unreleased" section in CHANGELOG-FOO.md/);
66
67
  });
67
68
 
68
69
  test('should throw for multiple "unreleased" sections', async t => {
69
70
  const options = { [namespace]: { filename: 'CHANGELOG-MULTIPLE_UNRELEASED.md' } };
70
- const plugin = factory(Plugin, { namespace, options });
71
+ const plugin = await factory(Plugin, { namespace, options });
71
72
  await assert.rejects(runTasks(plugin), /Too many "Unreleased" sections in CHANGELOG-MULTIPLE_UNRELEASED.md: \d+./);
72
73
  });
73
74
  test('should throw for invalid order', async t => {
74
75
  const options = { [namespace]: { filename: 'CHANGELOG-INVALID_ORDER.md' } };
75
- const plugin = factory(Plugin, { namespace, options });
76
+ const plugin = await factory(Plugin, { namespace, options });
76
77
  await assert.rejects(runTasks(plugin), /Invalid sections order in CHANGELOG-INVALID_ORDER.md: 0.2.0, 0.3.0./);
77
78
  });
78
79
 
79
80
  test('should find "1.0.0" section when no-increment flag is set when items under version', async t => {
80
81
  const options = { increment: false, [namespace]: { filename: 'CHANGELOG-EMPTY.md' } };
81
- const plugin = factory(Plugin, { namespace, options });
82
+ const plugin = await factory(Plugin, { namespace, options });
82
83
  await runTasks(plugin);
83
84
  assert.equal(plugin.getChangelog('1.0.0'), '* Item A\n* Item B');
84
85
  });
85
86
 
86
87
  test('should find "1.0.0" section when no-increment flag is set when items under unreleased and version', async t => {
87
88
  const options = { increment: false, [namespace]: { filename: 'CHANGELOG-FULL.md' } };
88
- const plugin = factory(Plugin, { namespace, options });
89
+ const plugin = await factory(Plugin, { namespace, options });
89
90
  await runTasks(plugin);
90
91
  assert.equal(plugin.getChangelog('1.0.0'), '* Item C\n* Item D');
91
92
  });
92
93
 
93
94
  test('should find very first changelog with disabled strict latest option', async t => {
94
95
  const options = { [namespace]: { filename: 'CHANGELOG-UNRELEASED.md', strictLatest: false } };
95
- const plugin = factory(Plugin, { namespace, options });
96
+ const plugin = await factory(Plugin, { namespace, options });
96
97
  await runTasks(plugin);
97
98
  assert.equal(plugin.getChangelog(), '* Item A\n* Item B');
98
99
  });
99
100
 
100
101
  test('should write changelog', async t => {
101
102
  const options = { [namespace]: { filename: 'CHANGELOG-FULL.md' } };
102
- const plugin = factory(Plugin, { namespace, options });
103
+ const plugin = await factory(Plugin, { namespace, options });
103
104
  await runTasks(plugin);
104
105
  assert.equal(plugin.getChangelog(), '* Item A\n* Item B');
105
106
  assert.match(
@@ -110,28 +111,28 @@ test('should write changelog', async t => {
110
111
 
111
112
  test('should not write changelog in dry run', async t => {
112
113
  const options = { 'dry-run': true, [namespace]: { filename: 'CHANGELOG-DRYRUN.md' } };
113
- const plugin = factory(Plugin, { namespace, options });
114
+ const plugin = await factory(Plugin, { namespace, options });
114
115
  await runTasks(plugin);
115
116
  assert.equal(readFile('./CHANGELOG-DRYRUN.md'), initialDryRunFileContents);
116
117
  });
117
118
 
118
119
  test('should not write changelog with keep unreleased option', async t => {
119
120
  const options = { [namespace]: { filename: 'CHANGELOG-DRYRUN.md', keepUnreleased: true } };
120
- const plugin = factory(Plugin, { namespace, options });
121
+ const plugin = await factory(Plugin, { namespace, options });
121
122
  await runTasks(plugin);
122
123
  assert.equal(readFile('./CHANGELOG-DRYRUN.md'), initialDryRunFileContents);
123
124
  });
124
125
 
125
126
  test('should find changelog even if less new lines is used', async t => {
126
127
  const options = { [namespace]: { filename: 'CHANGELOG-LESS_NEW_LINES.md' } };
127
- const plugin = factory(Plugin, { namespace, options });
128
+ const plugin = await factory(Plugin, { namespace, options });
128
129
  await runTasks(plugin);
129
130
  assert.equal(plugin.getChangelog(), '* Item A\n* Item B');
130
131
  });
131
132
 
132
133
  test('should write changelog with different EOL', async t => {
133
134
  const options = { [namespace]: { filename: 'CHANGELOG-EOL.md' } };
134
- const plugin = factory(Plugin, { namespace, options });
135
+ const plugin = await factory(Plugin, { namespace, options });
135
136
  await runTasks(plugin);
136
137
  assert.equal(plugin.getChangelog(), '* Item A\r\n* Item B');
137
138
  assert.match(
@@ -142,7 +143,7 @@ test('should write changelog with different EOL', async t => {
142
143
 
143
144
  test('should write changelog and add unreleased section', async t => {
144
145
  const options = { [namespace]: { filename: 'CHANGELOG-UNRELEASED.md', addUnreleased: true } };
145
- const plugin = factory(Plugin, { namespace, options });
146
+ const plugin = await factory(Plugin, { namespace, options });
146
147
  await runTasks(plugin);
147
148
  assert.equal(plugin.getChangelog(), '* Item A\n* Item B');
148
149
  assert.match(
@@ -153,7 +154,7 @@ test('should write changelog and add unreleased section', async t => {
153
154
 
154
155
  test('should add links to the end of the file', async t => {
155
156
  const options = { [namespace]: { filename: 'CHANGELOG-VERSION_URL.md', addVersionUrl: true } };
156
- const plugin = factory(Plugin, { namespace, options });
157
+ const plugin = await factory(Plugin, { namespace, options });
157
158
  plugin.config.setContext({
158
159
  latestTag: '1.0.0',
159
160
  repo: {
@@ -181,7 +182,7 @@ test('should add links with custom URL formats to the end of the file', async t
181
182
  }
182
183
  }
183
184
  };
184
- const plugin = factory(Plugin, { namespace, options });
185
+ const plugin = await factory(Plugin, { namespace, options });
185
186
  plugin.config.setContext({
186
187
  latestTag: '1.0.0',
187
188
  repo: {
@@ -199,7 +200,7 @@ test('should add links with custom URL formats to the end of the file', async t
199
200
 
200
201
  test('should add links with custom head to the end of the file', async t => {
201
202
  const options = { [namespace]: { filename: 'CHANGELOG-VERSION_URL_HEAD.md', addVersionUrl: true, head: 'main' } };
202
- const plugin = factory(Plugin, { namespace, options });
203
+ const plugin = await factory(Plugin, { namespace, options });
203
204
  plugin.config.setContext({
204
205
  latestTag: '1.0.0',
205
206
  repo: {
@@ -219,7 +220,7 @@ test('should add unreleased section and links to the end of the file', async t =
219
220
  const options = {
220
221
  [namespace]: { filename: 'CHANGELOG-VERSION_URL_UNRELEASED.md', addVersionUrl: true, addUnreleased: true }
221
222
  };
222
- const plugin = factory(Plugin, { namespace, options });
223
+ const plugin = await factory(Plugin, { namespace, options });
223
224
  plugin.config.setContext({
224
225
  latestTag: '1.0.0',
225
226
  repo: {
@@ -239,7 +240,7 @@ test('should match an existing unreleased link in title case', async t => {
239
240
  const options = {
240
241
  [namespace]: { filename: 'CHANGELOG-VERSION_URL_UNRELEASED_TITLE_CASE.md', addVersionUrl: true, addUnreleased: true }
241
242
  };
242
- const plugin = factory(Plugin, { namespace, options });
243
+ const plugin = await factory(Plugin, { namespace, options });
243
244
  plugin.config.setContext({
244
245
  latestTag: '1.0.0',
245
246
  repo: {
@@ -259,7 +260,7 @@ test('should add links to the end of a new changelog', async t => {
259
260
  const options = {
260
261
  [namespace]: { filename: 'CHANGELOG-VERSION_URL_NEW.md', addVersionUrl: true, strictLatest: false }
261
262
  };
262
- const plugin = factory(Plugin, { namespace, options });
263
+ const plugin = await factory(Plugin, { namespace, options });
263
264
  sinon.stub(plugin, 'getLatestVersion').returns('0.0.0');
264
265
  plugin.config.setContext({
265
266
  latestTag: undefined,