@thisismanta/semantic-version 11.0.0 → 11.2.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 +22 -7
- package/bin/lint-commit-message +1 -1
- package/bin/make-next-release +1 -1
- package/lib/index.d.ts +22 -0
- package/lib/index.js +10 -30
- package/lib/lint-commit-message.d.ts +1 -0
- package/lib/lint-commit-message.js +6 -7
- package/lib/make-next-release.d.ts +1 -0
- package/lib/make-next-release.js +154 -542
- package/lib/src.js +609 -0
- package/package.json +9 -7
- package/lib/chunk.js +0 -35
- package/lib/run.js +0 -27
package/README.md
CHANGED
|
@@ -28,9 +28,9 @@ commit-msg:
|
|
|
28
28
|
|
|
29
29
|
---
|
|
30
30
|
|
|
31
|
-
### `npx make-next-release`
|
|
31
|
+
### `npx make-next-release [--dry-run]`
|
|
32
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
|
|
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
34
|
|
|
35
35
|
| Commit message type | Trigger |
|
|
36
36
|
| ------------------- | -------------------------- |
|
|
@@ -39,28 +39,43 @@ This command is supposed to be run on **GitHub Actions**. It will run `npm versi
|
|
|
39
39
|
| `fix` or `build` | `npm version patch` |
|
|
40
40
|
| Others | Does not run `npm version` |
|
|
41
41
|
|
|
42
|
+
```json
|
|
43
|
+
// package.json
|
|
44
|
+
{
|
|
45
|
+
"scripts": {
|
|
46
|
+
"preversion": "npm run test",
|
|
47
|
+
"version": "npm run build && git add lib",
|
|
48
|
+
"postversion": "npm publish"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
By supplying `--dry-run` argument, it uses `git push --dry-run`, `npm version --ignore-scripts` and creates a new _draft_ **GitHub Release** entry instead, which you may want to [manually delete the _draft_ release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository#deleting-a-release) afterward.
|
|
54
|
+
|
|
42
55
|
```yml
|
|
43
56
|
# .github/workflows/push.yml
|
|
44
57
|
on:
|
|
45
58
|
push:
|
|
46
59
|
branches: [master]
|
|
47
60
|
|
|
61
|
+
permissions:
|
|
62
|
+
contents: write # Grant Git push and GitHub Release write access to GITHUB_TOKEN
|
|
63
|
+
|
|
48
64
|
jobs:
|
|
49
65
|
release:
|
|
50
66
|
runs-on: ubuntu-latest
|
|
51
67
|
steps:
|
|
52
68
|
- uses: actions/checkout@v6
|
|
53
69
|
with:
|
|
54
|
-
fetch-depth: 0 # Ensure Git tags are
|
|
70
|
+
fetch-depth: 0 # Ensure entire Git history and Git tags are accessible
|
|
55
71
|
|
|
56
72
|
- uses: actions/setup-node@v6
|
|
57
73
|
with:
|
|
58
|
-
node-version
|
|
59
|
-
cache: npm
|
|
74
|
+
node-version: 22
|
|
60
75
|
|
|
61
|
-
- run: npm
|
|
76
|
+
- run: npm install @thisismanta/semantic-version@11
|
|
62
77
|
|
|
63
78
|
- run: npx make-next-release
|
|
64
79
|
env:
|
|
65
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
80
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
66
81
|
```
|
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/bin/make-next-release
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
require('../lib/make-next-release')
|
|
2
|
+
require('../lib/make-next-release.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,31 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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;
|
|
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,15 +1,14 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_index = require("./index.js");
|
|
1
|
+
const require_src = require("./src.js");
|
|
3
2
|
let node_fs_promises = require("node:fs/promises");
|
|
4
|
-
node_fs_promises =
|
|
3
|
+
node_fs_promises = require_src.__toESM(node_fs_promises);
|
|
5
4
|
//#region src/lint-commit-message.ts
|
|
6
|
-
async
|
|
5
|
+
(async () => {
|
|
6
|
+
const messageFilePath = process.argv[2];
|
|
7
7
|
console.log("Verifying the commit message...");
|
|
8
8
|
const message = (await node_fs_promises.readFile(messageFilePath, "utf-8")).trim();
|
|
9
9
|
console.log(" input =", message);
|
|
10
|
-
const { errors } =
|
|
10
|
+
const { errors } = require_src.checkConventionalMessage(message);
|
|
11
11
|
for (const error of errors) console.error(" error =", error);
|
|
12
12
|
process.exitCode = errors.length;
|
|
13
|
-
}
|
|
13
|
+
})();
|
|
14
14
|
//#endregion
|
|
15
|
-
module.exports = lint_commit_message_default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|