@thisismanta/semantic-version 10.0.0 → 11.1.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.
- package/README.md +67 -44
- package/bin/lint-commit-message +1 -1
- package/bin/make-next-release +2 -0
- package/lib/index.d.ts +22 -0
- package/lib/index.js +11 -1
- package/lib/lint-commit-message.d.ts +1 -0
- package/lib/lint-commit-message.js +14 -1
- package/lib/make-next-release.d.ts +1 -0
- package/lib/make-next-release.js +18593 -0
- package/lib/src.js +609 -0
- package/package.json +31 -19
- package/bin/auto-npm-version +0 -2
- package/lib/auto-npm-version.js +0 -54
- package/lib/run.js +0 -1
package/README.md
CHANGED
|
@@ -1,53 +1,76 @@
|
|
|
1
|
-
# `
|
|
1
|
+
The following commands respect [`packageManager`](https://github.com/nodejs/corepack?tab=readme-ov-file#when-authoring-packages) field first then [`devEngines.packageManager.name`](https://docs.npmjs.com/cli/v10/configuring-npm/package-json#devengines) in _package.json_, but fallback to **npm** if none is specified.
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
### `npx lint-commit-message <path>`
|
|
2
6
|
|
|
3
7
|
The `<path>` must point to a text file containing commit message that complies with the following pattern:
|
|
4
8
|
|
|
5
9
|
```
|
|
6
10
|
<type>[!]: <subject>
|
|
7
11
|
```
|
|
12
|
+
|
|
8
13
|
Where
|
|
9
|
-
|
|
10
|
-
-
|
|
14
|
+
|
|
15
|
+
- `<type>` can be either `feat`, `fix`, `build` or `chore`.
|
|
16
|
+
- `!` indicates that the commit contains a breaking change.
|
|
11
17
|
- `<subject>` is the actual commit message where the first word must be written in lower cases.
|
|
12
18
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
19
|
+
Usage example with [**lefthook**](https://www.npmjs.com/package/lefthook):
|
|
20
|
+
|
|
21
|
+
```yml
|
|
22
|
+
# lefthook.yml
|
|
23
|
+
commit-msg:
|
|
24
|
+
commands:
|
|
25
|
+
lint:
|
|
26
|
+
run: npx lint-commit-message {1}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
### `npx make-next-release`
|
|
32
|
+
|
|
33
|
+
This command is supposed to be run on **GitHub Actions**. It will run `npm version <new-version>`, which `<new-version>` is automatically derived from your commit messages according to the table below and then it creates a new entry on [**GitHub releases**](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases).
|
|
34
|
+
|
|
35
|
+
| Commit message type | Trigger |
|
|
36
|
+
| ------------------- | -------------------------- |
|
|
37
|
+
| `!` | `npm version major` |
|
|
38
|
+
| `feat` | `npm version minor` |
|
|
39
|
+
| `fix` or `build` | `npm version patch` |
|
|
40
|
+
| Others | Does not run `npm version` |
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
// package.json
|
|
44
|
+
{
|
|
45
|
+
"scripts": {
|
|
46
|
+
"version": "npm run build",
|
|
47
|
+
"postversion": "npm publish"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```yml
|
|
53
|
+
# .github/workflows/push.yml
|
|
54
|
+
on:
|
|
55
|
+
push:
|
|
56
|
+
branches: [master]
|
|
57
|
+
|
|
58
|
+
jobs:
|
|
59
|
+
release:
|
|
60
|
+
runs-on: ubuntu-latest
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v6
|
|
63
|
+
with:
|
|
64
|
+
fetch-depth: 0 # Ensure Git tags are fetched
|
|
65
|
+
|
|
66
|
+
- uses: actions/setup-node@v6
|
|
67
|
+
with:
|
|
68
|
+
node-version-file: 'package.json'
|
|
69
|
+
cache: npm
|
|
70
|
+
|
|
71
|
+
- run: npm ci # Install semantic-version as part of the dependencies
|
|
72
|
+
|
|
73
|
+
- run: npx make-next-release
|
|
74
|
+
env:
|
|
75
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make it possible to create a new release using GitHub API
|
|
76
|
+
```
|
package/bin/lint-commit-message
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('../lib/lint-commit-message')
|
|
2
|
+
require('../lib/lint-commit-message.js')
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare function debug(text: string | number): void;
|
|
2
|
+
export declare function run(command: string): Promise<string>;
|
|
3
|
+
export declare const npm: string;
|
|
4
|
+
export declare const allowedTypes: readonly ["feat", "fix", "build", "chore"];
|
|
5
|
+
export type SemanticType = (typeof allowedTypes)[number];
|
|
6
|
+
export declare function checkConventionalMessage(message: string): {
|
|
7
|
+
type: "feat" | "fix" | "build" | "chore" | undefined;
|
|
8
|
+
breaking: boolean;
|
|
9
|
+
subject: string;
|
|
10
|
+
errors: string[];
|
|
11
|
+
};
|
|
12
|
+
interface GitCommit {
|
|
13
|
+
hash: string;
|
|
14
|
+
type: string | undefined;
|
|
15
|
+
breaking: boolean;
|
|
16
|
+
subject: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function getReleaseType(commits: Array<GitCommit>): string | null;
|
|
19
|
+
export declare function getCurrentPackageVersion(): Promise<string>;
|
|
20
|
+
export declare function getGitHistory(version: string): Promise<Array<GitCommit>>;
|
|
21
|
+
export declare function getReleaseNote(commits: Array<GitCommit>): string;
|
|
22
|
+
export {};
|
package/lib/index.js
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_src = require("./src.js");
|
|
3
|
+
exports.allowedTypes = require_src.allowedTypes;
|
|
4
|
+
exports.checkConventionalMessage = require_src.checkConventionalMessage;
|
|
5
|
+
exports.debug = require_src.debug;
|
|
6
|
+
exports.getCurrentPackageVersion = require_src.getCurrentPackageVersion;
|
|
7
|
+
exports.getGitHistory = require_src.getGitHistory;
|
|
8
|
+
exports.getReleaseNote = require_src.getReleaseNote;
|
|
9
|
+
exports.getReleaseType = require_src.getReleaseType;
|
|
10
|
+
exports.npm = require_src.npm;
|
|
11
|
+
exports.run = require_src.run;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
const require_src = require("./src.js");
|
|
2
|
+
let node_fs_promises = require("node:fs/promises");
|
|
3
|
+
node_fs_promises = require_src.__toESM(node_fs_promises);
|
|
4
|
+
//#region src/lint-commit-message.ts
|
|
5
|
+
(async () => {
|
|
6
|
+
const messageFilePath = process.argv[2];
|
|
7
|
+
console.log("Verifying the commit message...");
|
|
8
|
+
const message = (await node_fs_promises.readFile(messageFilePath, "utf-8")).trim();
|
|
9
|
+
console.log(" input =", message);
|
|
10
|
+
const { errors } = require_src.checkConventionalMessage(message);
|
|
11
|
+
for (const error of errors) console.error(" error =", error);
|
|
12
|
+
process.exitCode = errors.length;
|
|
13
|
+
})();
|
|
14
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|