@thisismanta/semantic-version 10.0.0 → 11.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.
- package/README.md +57 -44
- package/bin/lint-commit-message +1 -1
- package/bin/make-next-release +2 -0
- package/lib/chunk.js +35 -0
- package/lib/index.js +31 -1
- package/lib/lint-commit-message.js +15 -1
- package/lib/make-next-release.js +18986 -0
- package/lib/run.js +27 -1
- package/package.json +27 -17
- package/bin/auto-npm-version +0 -2
- package/lib/auto-npm-version.js +0 -54
package/README.md
CHANGED
|
@@ -1,53 +1,66 @@
|
|
|
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
|
+
```yml
|
|
43
|
+
# .github/workflows/push.yml
|
|
44
|
+
on:
|
|
45
|
+
push:
|
|
46
|
+
branches: [master]
|
|
47
|
+
|
|
48
|
+
jobs:
|
|
49
|
+
release:
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
steps:
|
|
52
|
+
- uses: actions/checkout@v6
|
|
53
|
+
with:
|
|
54
|
+
fetch-depth: 0 # Ensure Git tags are fetched
|
|
55
|
+
|
|
56
|
+
- uses: actions/setup-node@v6
|
|
57
|
+
with:
|
|
58
|
+
node-version-file: 'package.json'
|
|
59
|
+
cache: npm
|
|
60
|
+
|
|
61
|
+
- run: npm ci # Install semantic-version as part of the dependencies
|
|
62
|
+
|
|
63
|
+
- run: npx make-next-release
|
|
64
|
+
env:
|
|
65
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make it possible to create a new release using GitHub API
|
|
66
|
+
```
|
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')(process.argv.at(2))
|
package/lib/chunk.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
Object.defineProperty(exports, "__commonJSMin", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function() {
|
|
27
|
+
return __commonJSMin;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "__toESM", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function() {
|
|
33
|
+
return __toESM;
|
|
34
|
+
}
|
|
35
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
const titlePattern = /^(?<type>\w+)(?<scope>\(.*?\))?(?<breaking>\!)?:(?<subject>.+)/;
|
|
4
|
+
const allowedTypes = [
|
|
5
|
+
"feat",
|
|
6
|
+
"fix",
|
|
7
|
+
"build",
|
|
8
|
+
"chore"
|
|
9
|
+
];
|
|
10
|
+
function checkConventionalMessage(message) {
|
|
11
|
+
const { type, scope, breaking, subject } = message.match(titlePattern)?.groups || {};
|
|
12
|
+
const errors = [
|
|
13
|
+
!type && "The pull request title must match the pattern of \"<type>[!]: <subject>\" which is a reduced set of https://www.conventionalcommits.org/en/v1.0.0/",
|
|
14
|
+
typeof type === "string" && allowedTypes.includes(type.toLowerCase()) === false && "The type in a pull request title must be one of " + allowedTypes.map((name) => "\"" + name + "\"").join(", ") + ".",
|
|
15
|
+
typeof type === "string" && /^[a-z]+$/.test(type) === false && "The type in a pull request title must be in lower case only.",
|
|
16
|
+
scope && "A scope in a pull request title is never allowed.",
|
|
17
|
+
typeof type === "string" && typeof subject !== "string" && "The subject in a pull request title must be provided.",
|
|
18
|
+
typeof subject === "string" && (subject.match(/^ +/)?.[0].length || 0) !== 1 && "A single space must be after \":\" symbol.",
|
|
19
|
+
typeof subject === "string" && /^[a-z]/.test(subject.trim()) === false && "The subject must start with a lower case latin alphabet.",
|
|
20
|
+
typeof subject === "string" && /[\s\.]+$/.test(subject) && /\.{3}$/.test(subject.trim()) === false && "The subject must not end with a period or a space."
|
|
21
|
+
].filter((error) => typeof error === "string");
|
|
22
|
+
return {
|
|
23
|
+
type: allowedTypes.includes(type) ? type : void 0,
|
|
24
|
+
breaking: !!breaking,
|
|
25
|
+
subject: typeof subject === "string" ? subject.trim().replace(/[\s\.]+$/, "") + (/\.{3}$/.test(subject.trim()) ? "..." : "") : message,
|
|
26
|
+
errors
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.allowedTypes = allowedTypes;
|
|
31
|
+
exports.checkConventionalMessage = checkConventionalMessage;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
const require_chunk = require("./chunk.js");
|
|
2
|
+
const require_index = require("./index.js");
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
node_fs_promises = require_chunk.__toESM(node_fs_promises);
|
|
5
|
+
//#region src/lint-commit-message.ts
|
|
6
|
+
async function lint_commit_message_default(messageFilePath) {
|
|
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_index.checkConventionalMessage(message);
|
|
11
|
+
for (const error of errors) console.error(" error =", error);
|
|
12
|
+
process.exitCode = errors.length;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
module.exports = lint_commit_message_default;
|