@thisismanta/semantic-version 9.1.3 → 10.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/lib/index.js CHANGED
@@ -1,36 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.allowedTypes = void 0;
4
- exports.checkConventionalMessage = checkConventionalMessage;
5
- const titlePattern = /^(?<type>\w+)(?<scope>\(.*?\))?(?<breaking>\!)?:(?<subject>.+)/;
6
- exports.allowedTypes = ['feat', 'fix', 'build', 'chore'];
7
- 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
- };
36
- }
1
+ "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var index_exports={};__export(index_exports,{allowedTypes:()=>allowedTypes,checkConventionalMessage:()=>checkConventionalMessage});module.exports=__toCommonJS(index_exports);var titlePattern=/^(?<type>\w+)(?<scope>\(.*?\))?(?<breaking>\!)?:(?<subject>.+)/;var allowedTypes=["feat","fix","build","chore"];function checkConventionalMessage(message){const pattern=message.match(titlePattern)?.groups||{};const{type,scope,breaking,subject}=pattern;const errors=[!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/',typeof type==="string"&&allowedTypes.includes(type.toLowerCase())===false&&"The type in a pull request title must be one of "+allowedTypes.map(name=>'"'+name+'"').join(", ")+".",typeof type==="string"&&/^[a-z]+$/.test(type)===false&&"The type in a pull request title must be in lower case only.",scope&&"A scope in a pull request title is never allowed.",typeof type==="string"&&typeof subject!=="string"&&"The subject in a pull request title must be provided.",typeof subject==="string"&&(subject.match(/^ +/)?.[0].length||0)!==1&&'A single space must be after ":" symbol.',typeof subject==="string"&&/^[a-z]/.test(subject.trim())===false&&"The subject must start with a lower case latin alphabet.",typeof subject==="string"&&/[\s\.]+$/.test(subject)&&/\.{3}$/.test(subject.trim())===false&&"The subject must not end with a period or a space."].filter(error=>typeof error==="string");return{type:allowedTypes.includes(type)?type:void 0,breaking:!!breaking,subject:typeof subject==="string"?subject.trim().replace(/[\s\.]+$/,"")+(/\.{3}$/.test(subject.trim())?"...":""):message,errors}}0&&(module.exports={allowedTypes,checkConventionalMessage});
@@ -1,48 +1 @@
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;
48
- }
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:true}):target,mod));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var lint_commit_message_exports={};__export(lint_commit_message_exports,{default:()=>main});module.exports=__toCommonJS(lint_commit_message_exports);var fs=__toESM(require("fs/promises"));var titlePattern=/^(?<type>\w+)(?<scope>\(.*?\))?(?<breaking>\!)?:(?<subject>.+)/;var allowedTypes=["feat","fix","build","chore"];function checkConventionalMessage(message){const pattern=message.match(titlePattern)?.groups||{};const{type,scope,breaking,subject}=pattern;const errors=[!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/',typeof type==="string"&&allowedTypes.includes(type.toLowerCase())===false&&"The type in a pull request title must be one of "+allowedTypes.map(name=>'"'+name+'"').join(", ")+".",typeof type==="string"&&/^[a-z]+$/.test(type)===false&&"The type in a pull request title must be in lower case only.",scope&&"A scope in a pull request title is never allowed.",typeof type==="string"&&typeof subject!=="string"&&"The subject in a pull request title must be provided.",typeof subject==="string"&&(subject.match(/^ +/)?.[0].length||0)!==1&&'A single space must be after ":" symbol.',typeof subject==="string"&&/^[a-z]/.test(subject.trim())===false&&"The subject must start with a lower case latin alphabet.",typeof subject==="string"&&/[\s\.]+$/.test(subject)&&/\.{3}$/.test(subject.trim())===false&&"The subject must not end with a period or a space."].filter(error=>typeof error==="string");return{type:allowedTypes.includes(type)?type:void 0,breaking:!!breaking,subject:typeof subject==="string"?subject.trim().replace(/[\s\.]+$/,"")+(/\.{3}$/.test(subject.trim())?"...":""):message,errors}}async function main(messageFilePath){console.log("Verifying the commit message...");const message=(await fs.readFile(messageFilePath,"utf-8")).trim();console.log(" input =",message);const{errors}=checkConventionalMessage(message);for(const error of errors){console.error(" error =",error)}process.exitCode=errors.length}
package/lib/run.js CHANGED
@@ -1,56 +1 @@
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.run = run;
37
- const cp = __importStar(require("child_process"));
38
- function run(command) {
39
- return new Promise((resolve, reject) => {
40
- cp.exec(command, (error, stdout, stderr) => {
41
- console.log('::debug::' + command);
42
- console.log('::debug::Output:');
43
- console.log('::debug::=>', stdout);
44
- if (stderr.trim().length > 0) {
45
- console.log('::debug::Error:');
46
- console.log('::debug::=>', stderr);
47
- }
48
- if (error) {
49
- reject(error);
50
- }
51
- else {
52
- resolve(stdout.trim());
53
- }
54
- });
55
- });
56
- }
1
+ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:true}):target,mod));var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var run_exports={};__export(run_exports,{run:()=>run});module.exports=__toCommonJS(run_exports);var cp=__toESM(require("child_process"));function run(command){return new Promise((resolve,reject)=>{cp.exec(command,(error,stdout,stderr)=>{console.log("::debug::"+command);console.log("::debug::Output:");console.log("::debug::=>",stdout);if(stderr.trim().length>0){console.log("::debug::Error:");console.log("::debug::=>",stderr)}if(error){reject(error)}else{resolve(stdout.trim())}})})}0&&(module.exports={run});
package/package.json CHANGED
@@ -1,42 +1,41 @@
1
1
  {
2
2
  "name": "@thisismanta/semantic-version",
3
- "version": "9.1.3",
3
+ "version": "10.0.0",
4
4
  "author": "Anantachai Saothong <thisismanta@gmail.com>",
5
5
  "license": "ISC",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "https://github.com/ThisIsManta/semantic-version.git"
8
+ "url": "git+https://github.com/ThisIsManta/semantic-version.git"
9
9
  },
10
10
  "engines": {
11
- "node": ">=20.0.0"
11
+ "node": ">=22.0.0"
12
12
  },
13
- "packageManager": "npm@10.9.4",
14
- "main": "./lib/index.js",
15
- "types": "./lib/index.d.ts",
13
+ "packageManager": "npm@11.6.2",
14
+ "main": "lib/index.js",
15
+ "types": "lib/index.d.ts",
16
16
  "bin": {
17
- "lint-commit-message": "./bin/lint-commit-message",
18
- "auto-npm-version": "./bin/auto-npm-version"
17
+ "lint-commit-message": "bin/lint-commit-message",
18
+ "auto-npm-version": "bin/auto-npm-version"
19
19
  },
20
20
  "files": [
21
- "./lib",
22
- "./bin"
21
+ "lib",
22
+ "bin"
23
23
  ],
24
24
  "scripts": {
25
25
  "test": "vitest --no-watch",
26
- "build": "rm -rf lib && tsc",
26
+ "build": "rm -rf lib && find src -name '*.ts' ! -name '*.test.ts' | xargs esbuild --bundle --outdir=lib --platform=node --target=node22 --format=cjs --minify-whitespace",
27
27
  "preversion": "npm run build",
28
- "version": "npm publish --access public"
28
+ "version": "npm publish --provenance --access public"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^20.19.25",
31
+ "@actions/github": "^9.0.0",
32
+ "@types/node": "~22.19.10",
32
33
  "@types/semver": "^7.7.1",
33
- "lefthook": "^2.0.4",
34
+ "esbuild": "^0.27.3",
35
+ "lefthook": "^2.1.0",
36
+ "semver": "^7.7.4",
34
37
  "typescript": "^5.9.3",
35
- "vite": "^7.2.2",
36
- "vitest": "^4.0.10"
37
- },
38
- "dependencies": {
39
- "@actions/github": "^6.0.1",
40
- "semver": "^7.7.2"
38
+ "vite": "^7.3.1",
39
+ "vitest": "^4.0.18"
41
40
  }
42
41
  }
@@ -1,9 +0,0 @@
1
- export default function main(): Promise<void>;
2
- interface GitCommit {
3
- hash: string;
4
- type: string | undefined;
5
- breaking: boolean;
6
- subject: string;
7
- }
8
- export declare function getReleaseType(commits: Array<GitCommit>): string | null;
9
- export {};
package/lib/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- export declare const allowedTypes: readonly ["feat", "fix", "build", "chore"];
2
- export type SemanticType = typeof allowedTypes[number];
3
- export declare function checkConventionalMessage(message: string): {
4
- type: "feat" | "fix" | "build" | "chore" | undefined;
5
- breaking: boolean;
6
- subject: string;
7
- errors: string[];
8
- };
@@ -1 +0,0 @@
1
- export default function main(messageFilePath: string): Promise<void>;
package/lib/run.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function run(command: string): Promise<string>;