changelog-tool 0.7.0 → 0.7.2

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/changelog.md CHANGED
@@ -1,6 +1,22 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 0.7.2 (2023-02-17)
5
+ ------------------
6
+
7
+ * Added a `--nowrap` option to `show`, which doesn't wrap long lines. This is
8
+ useful for copy-pasting changelog into places where linebreaks are
9
+ significant, such as the Github releases section.
10
+ * Support multiple digits for the alpha/beta release string.
11
+ * Also allows setting the changelog message as positional arguments.
12
+
13
+
14
+ 0.7.1 (2023-02-14)
15
+ ------------------
16
+
17
+ * Bug: forgot to commit the release
18
+
19
+
4
20
  0.7.0 (2023-02-14)
5
21
  ------------------
6
22
 
package/changelog.mjs CHANGED
@@ -116,15 +116,28 @@ export class VersionLog {
116
116
 
117
117
  toString() {
118
118
 
119
+ return this.output();
120
+
121
+ }
122
+
123
+ /**
124
+ * Renders the changelog as a string.
125
+ *
126
+ * @param {boolean} lineWrap
127
+ * @returns {string}
128
+ */
129
+ output(lineWrap = true) {
130
+
131
+ const lineLength = lineWrap ? 79 : Infinity;
119
132
  const title = this.version + ' (' + (this.date ?? '????-??-??') + ')';
120
133
  return (
121
134
  title + '\n' +
122
135
  ('-'.repeat(title.length)) + '\n' +
123
- (this.preface ? '\n' + wrap(this.preface) : '') +
136
+ (this.preface ? '\n' + wrap(this.preface, 0, lineLength) : '') +
124
137
  '\n' +
125
- this.items.map(version => version.toString()).join('\n') +
138
+ this.items.map(version => version.output(lineWrap)).join('\n') +
126
139
  '\n' +
127
- (this.postface ? '\n' + wrap(this.postface) + '\n' : '')
140
+ (this.postface ? '\n' + wrap(this.postface, 0, lineLength) + '\n' : '')
128
141
  );
129
142
 
130
143
  }
@@ -145,6 +158,17 @@ export class LogItem {
145
158
  this.message = message;
146
159
  }
147
160
 
161
+ /**
162
+ * Renders the changelog as a string.
163
+ *
164
+ * @param {boolean} lineWrap
165
+ * @returns {string}
166
+ */
167
+ output(lineWrap = true) {
168
+ const lineLength = lineWrap ? 79 : Infinity;
169
+ return wrap('* ' + this.message, 2, lineLength);
170
+ }
171
+
148
172
  toString() {
149
173
 
150
174
  return wrap('* ' + this.message, 2);
package/cli.mjs CHANGED
@@ -49,6 +49,10 @@ async function main() {
49
49
  type: 'boolean',
50
50
  description: 'Indicates that the current change is a major change.',
51
51
  },
52
+ nowrap: {
53
+ type: 'boolean',
54
+ description: 'Don\'t wrap "show" output'
55
+ }
52
56
  },
53
57
  allowPositionals: true,
54
58
  });
@@ -79,7 +83,12 @@ async function main() {
79
83
  changeType = 'major';
80
84
  }
81
85
  if (!values.message) {
82
- throw new Error('The "-m" or "--message" argument is required');
86
+ if (positionals.length>1) {
87
+ // We also support setting a message after the command instead of -m
88
+ values.message = positionals.slice(1).join(' ');
89
+ } else {
90
+ throw new Error('The "-m" or "--message" argument is required');
91
+ }
83
92
  }
84
93
  await add({
85
94
  message: values.message,
@@ -93,7 +102,11 @@ async function main() {
93
102
  await format();
94
103
  break;
95
104
  case 'show' :
96
- await show({ all: !!values.all, version: positionals[1]});
105
+ await show({
106
+ all: !!values.all,
107
+ version: positionals[1],
108
+ noWrap: !!values.nowrap
109
+ });
97
110
  break;
98
111
  case 'list' :
99
112
  await list();
@@ -170,8 +183,9 @@ async function list() {
170
183
  * @param {Object} showOptions
171
184
  * @param {boolean} showOptions.all Show all versions
172
185
  * @param {string?} showOptions.version show a specific version
186
+ * @param {boolean?} showOptions.noWrap don't line-wrap output
173
187
  */
174
- async function show({all, version}) {
188
+ async function show({all, version, noWrap}) {
175
189
 
176
190
  const changelog = await parseChangelog();
177
191
 
@@ -186,7 +200,7 @@ async function show({all, version}) {
186
200
 
187
201
  console.log(
188
202
  toRender
189
- .map( log => log.toString())
203
+ .map( log => log.output(!noWrap))
190
204
  .join('\n\n')
191
205
  );
192
206
 
@@ -255,6 +269,7 @@ async function release() {
255
269
  }
256
270
  if (useGit) {
257
271
  runCommand(`git add --all`);
272
+ runCommand(`git commit -m "Releasing ${lastVersion.version}"`);
258
273
  runCommand(`git tag v${lastVersion.version}`);
259
274
  }
260
275
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "changelog-tool",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "A CLI tool for manipulating changelogs",
5
5
  "type": "module",
6
6
  "main": "index.mjs",
package/parse.mjs CHANGED
@@ -54,7 +54,7 @@ export function parse(changelogInput) {
54
54
  // Look to the next line for ----
55
55
  if (lines[idx+1]?.match(/^-{1,}$/)) {
56
56
  // Found a new Version
57
- const matches = line.match(/^([0-9\.]{3,}(?:-(?:alpha|beta)\.[0-9])?) \(([0-9]{4}-[0-9]{2}-[0-9]{2}|\?\?\?\?-\?\?-\?\?)\)$/);
57
+ const matches = line.match(/^([0-9\.]{3,}(?:-(?:alpha|beta)\.[0-9]+)?) \(([0-9]{4}-[0-9]{2}-[0-9]{2}|\?\?\?\?-\?\?-\?\?)\)$/);
58
58
 
59
59
  if (!matches) {
60
60
  throw new Error(`A version title must have the format "1.0.0 (YYYY-MM-DD)" or "1.0.0 (????-??-??)" for unreleased versions. We found: "${line}"`);