changelog-tool 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
package/changelog.md CHANGED
@@ -1,6 +1,15 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ 0.6.0 (2023-02-14)
5
+ ------------------
6
+
7
+ * The release command now automatically calls "npm version" if a package.json
8
+ was found in the project directory
9
+ * Bug fix: the --major and --minor arguments were ignored when using "add" to
10
+ create a new version log
11
+
12
+
4
13
  0.5.0 (2023-02-12)
5
14
  ------------------
6
15
 
@@ -8,8 +17,6 @@ Changelog
8
17
  `--minor` arguments.
9
18
  * The `add` command now uses the -m argument instead of a positional for the
10
19
  message.
11
- * bla
12
- * bla
13
20
 
14
21
 
15
22
  0.4.1 (2023-02-12)
package/changelog.mjs CHANGED
@@ -38,13 +38,13 @@ export class Changelog {
38
38
  * Adds a new version to the log. Version string is automatically increased
39
39
  * from the previous one
40
40
  *
41
- * @params {'patch'|'minor'|'major'} changeType
41
+ * @param {'patch'|'minor'|'major'} changeType
42
42
  * @returns {VersionLog}
43
43
  */
44
44
  newVersion(changeType = 'patch') {
45
45
 
46
46
  const lastVersion = this.versions[0].version;
47
- const newVersion = calculateNextVersion(lastVersion);
47
+ const newVersion = calculateNextVersion(lastVersion, changeType);
48
48
  const versionLog = new VersionLog(newVersion);
49
49
 
50
50
  return this.add(versionLog);
package/cli.mjs CHANGED
@@ -6,6 +6,7 @@ import * as url from 'node:url';
6
6
  import { readPackageVersion, exists, calculateNextVersion } from './util.mjs';
7
7
  import { Changelog, VersionLog, LogItem } from './changelog.mjs';
8
8
  import { parseFile } from './parse.mjs';
9
+ import { execSync } from 'node:child_process';
9
10
 
10
11
  const filename = 'changelog.md';
11
12
 
@@ -78,7 +79,7 @@ async function main() {
78
79
  changeType = 'major';
79
80
  }
80
81
  if (!values.message) {
81
- throw new Error('The "-m" or "-message" argument is required');
82
+ throw new Error('The "-m" or "--message" argument is required');
82
83
  }
83
84
  await add({
84
85
  message: values.message,
@@ -238,6 +239,12 @@ async function release() {
238
239
  await fs.writeFile(filename, changelog.toString());
239
240
  console.log(`${changelog.versions.length} changelogs saved to ${filename}`);
240
241
 
242
+ if (await exists('package.json')) {
243
+ const command = `npm version "${lastVersion.version}" --no-git-tag-version`;
244
+ console.log(command);
245
+ execSync(command);
246
+ }
247
+
241
248
  }
242
249
 
243
250
  /**
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "changelog-tool",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "A CLI tool for manipulating changelogs",
5
+ "type": "module",
5
6
  "main": "index.mjs",
6
7
  "scripts": {
7
- "test": "node --test"
8
+ "test": "node --test",
9
+ "watch": "tsc --watch"
8
10
  },
9
11
  "keywords": [
10
12
  "changelog",
package/readme.md CHANGED
@@ -26,7 +26,7 @@ Installation
26
26
  ------------
27
27
 
28
28
  ```sh
29
- npm install changelog-tool --save-dev
29
+ npm install changelog-tool --global
30
30
  ```
31
31
 
32
32
  CLI
@@ -36,33 +36,55 @@ To tool can be used programmatically and with the CLI. The CLI has the
36
36
  following commands:
37
37
 
38
38
  ```
39
- npx changelog init - Create a new, empty npx changelog.
40
- npx changelog add -m [message] - Adds a new line to the npx changelog.
41
- npx changelog release - Marks the current npx changelog as released.
42
- npx changelog show - Show the last npx changelog.
43
- npx changelog show [version] - Show the npx changelog of a specific version.
44
- npx changelog list - List all versions in the npx changelog.
45
- npx changelog format - Reformats the npx changelog in the standard format.
39
+ changelog init - Create a new, empty npx changelog.
40
+ changelog add -m [message] - Adds a new line to the npx changelog.
41
+ changelog release - Marks the current npx changelog as released.
42
+ changelog show - Show the last npx changelog.
43
+ changelog show [version] - Show the npx changelog of a specific version.
44
+ changelog list - List all versions in the npx changelog.
45
+ changelog format - Reformats the npx changelog in the standard format.
46
46
  ```
47
47
 
48
- ### Invoking add
48
+ ### 'add' command
49
49
 
50
- Easiest is to just run:
50
+ The add comment lets you add a new message at the bottom of the last unreleased
51
+ version.
52
+
53
+ To use it, just run:
51
54
 
52
55
  ```
53
- npx changelog add -m "Bug fix"
56
+ changelog add -m "Bug fix"
54
57
  ```
55
58
 
56
- This will automatically add a line to the latest unreleased version. If there
57
- is no unreleased version, it will create a new patch version.
59
+ If there is no unreleased version, it will create a new section and increase
60
+ the version number.
58
61
 
59
- If the change should cause a minor or major version bump, you can specify the
60
- these options too:
62
+ If the current change should result in a new major or minor version number, you
63
+ can use the following arguments.
61
64
 
62
65
  ```
63
- npx changelog add --minor -m "New feature"
64
- npx changelog add --major -m "Backwards compatibility break"
66
+ changelog add --minor -m "New feature"
67
+ changelog add --major -m "Backwards compatibility break"
65
68
  ```
66
69
 
67
70
  These settings will automatically adjust the version string of the most recent
68
71
  unreleased version.
72
+
73
+ ### 'release' command
74
+
75
+ The release command will look for a recent unreleased version in the changelog
76
+ (where the date is marked `????-??-??`) and change it to the current date:
77
+
78
+ ```
79
+ changelog release
80
+ ```
81
+
82
+ If the tool detects a `package.json` file in the current directory, it will
83
+ also call:
84
+
85
+ ```
86
+ npm version [version] --no-git-tag-version
87
+ ```
88
+
89
+ This command adjust the `version` field in `package.json` to match the latest
90
+ changelog version.
package/test/parse.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import { test } from 'node:test';
2
3
  import { parse } from '../parse.mjs';
3
4
  import * as assert from 'node:assert';
package/tsconfig.json CHANGED
@@ -7,7 +7,6 @@
7
7
  "checkJs": true,
8
8
 
9
9
  "moduleResolution": "node",
10
- "resolveJsonModule": true,
11
10
 
12
11
  "noEmit": true,
13
12
  "strict": true,