@thisismanta/semantic-version 9.1.4 → 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 CHANGED
@@ -1,53 +1,66 @@
1
- # `npx lint-commit-message <path>`
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
- - `<type>` can be either `feat`, `fix`, `test`, `refactor` or `chore`.
10
- - `!` indicates that the commit contains breaking changes.
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
- > Usage example with [**lefthook**](https://www.npmjs.com/package/lefthook)
14
- > ```yml
15
- > # lefthook.yml
16
- > commit-msg:
17
- > commands:
18
- > lint:
19
- > run: npx lint-commit-message {1}
20
- > ```
21
-
22
- # `npx auto-npm-version`
23
-
24
- This command is supposed to be run on CI, such as **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).
25
-
26
- |Commit message type|Post-commit command|
27
- |---|---|
28
- |`!`|`npm version major`|
29
- |`feat`|`npm version minor`|
30
- |`fix`|`npm version patch`|
31
- |Others|Does not run `npm version`|
32
-
33
- > Usage example with **GitHub Actions**
34
- > ```yml
35
- > on:
36
- > push:
37
- > branches: [master]
38
- > jobs:
39
- > release:
40
- > runs-on: ubuntu-latest
41
- > steps:
42
- > - uses: actions/checkout@v4
43
- > with:
44
- > fetch-depth: 0 # Ensure Git tags are fetched
45
- > - uses: actions/setup-node@v4
46
- > with:
47
- > node-version-file: 'package.json'
48
- > cache: npm
49
- > - run: npm ci # Install semantic-version as part of the dependencies
50
- > - run: npx auto-npm-version
51
- > env:
52
- > GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Make it possible to create a new release using GitHub API
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
+ ```
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('../lib/lint-commit-message').default(process.argv.at(2))
2
+ require('../lib/lint-commit-message')(process.argv.at(2))
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require('../lib/make-next-release').default()
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,36 +1,31 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.allowedTypes = void 0;
4
- exports.checkConventionalMessage = checkConventionalMessage;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/index.ts
5
3
  const titlePattern = /^(?<type>\w+)(?<scope>\(.*?\))?(?<breaking>\!)?:(?<subject>.+)/;
6
- exports.allowedTypes = ['feat', 'fix', 'build', 'chore'];
4
+ const allowedTypes = [
5
+ "feat",
6
+ "fix",
7
+ "build",
8
+ "chore"
9
+ ];
7
10
  function checkConventionalMessage(message) {
8
- const pattern = (message.match(titlePattern)?.groups || {});
9
- const { type, scope, breaking, subject } = pattern;
10
- const errors = [
11
- !type &&
12
- '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/',
13
- typeof type === 'string' && exports.allowedTypes.includes(type.toLowerCase()) === false &&
14
- 'The type in a pull request title must be one of ' + exports.allowedTypes.map(name => '"' + name + '"').join(', ') + '.',
15
- typeof type === 'string' && /^[a-z]+$/.test(type) === false &&
16
- 'The type in a pull request title must be in lower case only.',
17
- scope &&
18
- 'A scope in a pull request title is never allowed.',
19
- typeof type === 'string' && typeof subject !== 'string' &&
20
- 'The subject in a pull request title must be provided.',
21
- typeof subject === 'string' && (subject.match(/^ +/)?.[0].length || 0) !== 1 &&
22
- 'A single space must be after ":" symbol.',
23
- typeof subject === 'string' && /^[a-z]/.test(subject.trim()) === false &&
24
- 'The subject must start with a lower case latin alphabet.',
25
- typeof subject === 'string' && /[\s\.]+$/.test(subject) && /\.{3}$/.test(subject.trim()) === false &&
26
- 'The subject must not end with a period or a space.',
27
- ].filter((error) => typeof error === 'string');
28
- return {
29
- type: exports.allowedTypes.includes(type) ? type : undefined,
30
- breaking: !!breaking,
31
- subject: typeof subject === 'string'
32
- ? subject.trim().replace(/[\s\.]+$/, '') + (/\.{3}$/.test(subject.trim()) ? '...' : '')
33
- : message,
34
- errors
35
- };
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
+ };
36
28
  }
29
+ //#endregion
30
+ exports.allowedTypes = allowedTypes;
31
+ exports.checkConventionalMessage = checkConventionalMessage;
@@ -1,48 +1,15 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.default = main;
37
- const fs = __importStar(require("fs/promises"));
38
- const index_1 = require("./index");
39
- async function main(messageFilePath) {
40
- console.log('Verifying the commit message...');
41
- const message = (await fs.readFile(messageFilePath, 'utf-8')).trim();
42
- console.log(' input =', message);
43
- const { errors } = (0, index_1.checkConventionalMessage)(message);
44
- for (const error of errors) {
45
- console.error(' error =', error);
46
- }
47
- process.exitCode = errors.length;
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;
48
13
  }
14
+ //#endregion
15
+ module.exports = lint_commit_message_default;