@thisismanta/semantic-version 11.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 CHANGED
@@ -39,6 +39,16 @@ 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
+ "version": "npm run build",
47
+ "postversion": "npm publish"
48
+ }
49
+ }
50
+ ```
51
+
42
52
  ```yml
43
53
  # .github/workflows/push.yml
44
54
  on:
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('../lib/lint-commit-message')(process.argv.at(2))
2
+ require('../lib/lint-commit-message.js')
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- require('../lib/make-next-release').default()
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
- //#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;
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 require_chunk = require("./chunk.js");
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 = require_chunk.__toESM(node_fs_promises);
3
+ node_fs_promises = require_src.__toESM(node_fs_promises);
5
4
  //#region src/lint-commit-message.ts
6
- async function lint_commit_message_default(messageFilePath) {
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 } = require_index.checkConventionalMessage(message);
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 {};