mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-01 14:38:47 +00:00
test: add & configure Jest
Fixes #153 Signed-off-by: Ardalan Amini <[email protected]>
This commit is contained in:
11 files changed
+2600
-24
No files matched your search
@@ -35,6 +35,6 @@ jobs:
|
||||
env :
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
prerelease: ${{ steps.changelog.outputs.prerelease }}
|
||||
body : |
|
||||
${{ steps.changelog.outputs.changelog }}
|
||||
prerelease: ${{ steps.changelog.outputs.prerelease }}
|
||||
@@ -33,6 +33,9 @@ jobs:
|
||||
- name: Check code styles
|
||||
run : pnpm lint
|
||||
|
||||
- name: Run unit tests
|
||||
run : pnpm test
|
||||
|
||||
- name: Build using TypeScript
|
||||
run : pnpm build
|
||||
|
||||
@@ -50,7 +53,7 @@ jobs:
|
||||
- name: Changelog
|
||||
uses: ./
|
||||
with:
|
||||
semver: ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
semver : ${{ startsWith(github.ref, 'refs/tags/') }}
|
||||
mention-new-contributors: ${{ github.ref_protected }}
|
||||
|
||||
test-with-inputs: # make sure the action works on a clean machine without building
|
||||
|
||||
@@ -252,23 +252,23 @@ Using with default inputs:
|
||||
Using with custom inputs:
|
||||
|
||||
```yaml
|
||||
- name: Changelog
|
||||
uses: ardalanamini/auto-changelog@v4
|
||||
- uses: ardalanamini/auto-changelog@v4
|
||||
id : changelog
|
||||
name: Changelog
|
||||
with:
|
||||
github-token : ${{ github.token }}
|
||||
commit-types : |
|
||||
feat: New Features
|
||||
fix: Bug Fixes
|
||||
build: Build System & Dependencies
|
||||
perf: Performance Improvements
|
||||
docs: Documentation
|
||||
test: Tests
|
||||
feat : New Features
|
||||
fix : Bug Fixes
|
||||
build : Build System & Dependencies
|
||||
perf : Performance Improvements
|
||||
docs : Documentation
|
||||
test : Tests
|
||||
refactor: Refactors
|
||||
chore: Chores
|
||||
ci: CI
|
||||
style: Code Style
|
||||
revert: Reverts
|
||||
chore : Chores
|
||||
ci : CI
|
||||
style : Code Style
|
||||
revert : Reverts
|
||||
default-commit-type : Other Changes
|
||||
release-name : v1.0.0
|
||||
release-name-prefix : ""
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
require('./sourcemap-register.js');(()=>{var e={252:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateChangelog=generateChangelog;const s=A(4708);const r=A(3820);function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}function sortBy(e,t){return e.sort(((e,A)=>e[t].localeCompare(A[t])))}async function generateChangelog(e){const{paginate:t,rest:A}=(0,r.octokit)();const{owner:o,repo:n,url:i}=(0,r.repository)();const a=(0,r.defaultCommitType)();const c=(0,r.commitTypes)();const l=(0,r.includePRLinks)();const g=(0,r.includeCommitLinks)();const u=(0,r.mentionAuthors)();const E=(0,r.useGithubAutolink)();const h=t.iterator(A.repos.listCommits,{per_page:100,sha:(0,r.sha)(),owner:o,repo:n});const d=[];e:for await(const{data:t}of h){for(const A of t){if(A.sha===e)break e;const t=A.commit.message.split("\n")[0];(0,s.debug)(`commit message -> ${t}`);let{type:o,scope:n,description:h,pr:p,flag:C,breaking:Q}=(0,r.parseCommitMessage)(t);if(!h)continue;h=trim(h);C=trim(C);if(C==="ignore")continue;o=c[trim(o??"")]??a;let I=d.find((e=>e.type===o));if(I==null){I={type:o,scopes:[]};d.push(I)}n=trim(n??"");let B=I.scopes.find((e=>e.scope===n));if(B==null){B={scope:n,logs:[]};I.scopes.push(B)}let m=B.logs.find((e=>e.description===h));if(m==null){m={breaking:Q,description:h,references:[]};B.logs.push(m)}const y=[];if(p&&l)y.push(E?`#${p}`:`[#${p}](${i}/issues/${p})`);else if(g)y.push(E?A.sha:`\`[${A.sha}](${i}/commit/${A.sha})\``);const w=A.author?.login;if(w&&u){const e=`by @${w}`;y.push(e);const t=m.references[m.references.length-1];if(t?.endsWith(e)){m.references.push(m.references.pop().replace(e,`& ${y.join(" ")}`));continue}}if(y.length>0)m.references.push(y.join(" "))}}const p=unique(Object.values(c).concat(a));const C=[];for(const e of p){const t=d.find((t=>t.type===e));if(t==null)continue;C.push(`## ${e}`);sortBy(t.scopes,"scope");for(const{scope:e,logs:A}of t.scopes){let t="";if(e.length>0){C.push(`* **${e}:**`);t=" "}for(const{breaking:e,description:s,references:r}of A){let A=`${t}* ${e?"***breaking:*** ":""}${s}`;if(r.length>0)A+=` (${r.join(", ")})`;C.push(A)}}C.push("")}return C.join("\n")}},6351:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateFooter=generateFooter;const s=A(6087);const r=A(3820);async function generateFooter(e){const{owner:t,repo:A,url:o}=(0,r.repository)();const n=(0,r.releaseName)();const i=[];if((0,r.mentionNewContributors)()){const{rest:o}=(0,r.octokit)();const{data:a}=await o.repos.generateReleaseNotes({owner:t,repo:A,tag_name:n,previous_tag_name:e});const c=s.marked.lexer(a.body);const l=c.findIndex((e=>e.type==="heading"&&e.text==="New Contributors"));const g=c[l+1];if(g.type==="list")i.push(`## New Contributors\n${g.raw}\n`)}if((0,r.includeCompareLink)()&&e){let t=`${o}/compare/${e}...${n}`;if(!(0,r.useGithubAutolink)()||(0,r.releaseNamePrefix)())t=`\`[${e}...${n}](${o}/compare/${e}...${n})\``;i.push(`**Full Changelog**: ${t}`)}if(i.length>0)i.unshift("");return i.join("\n\n")}},146:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getTagInfo=getTagInfo;const s=A(3820);async function getTagInfo(){const{paginate:e,rest:t}=(0,s.octokit)();const{owner:A,repo:r}=(0,s.repository)();const o={releaseId:"latest",prerelease:false};let n=null;if((0,s.semver)()){n=(0,s.parseSemVer)();if(n==null)throw new Error(`Expected a semver compatible releaseName, got "${(0,s.releaseName)()}" instead.`);o.prerelease=n.prerelease.length>0;if(o.prerelease)o.releaseId=`${n.prerelease[0]}`}const i=e.iterator(t.repos.listTags,{per_page:100,owner:A,repo:r});e:for await(const{data:e}of i){for(const{name:t,commit:A}of e){if((0,s.sha)()===A.sha)continue;if(n==null){o.previous={name:t,sha:A.sha};break e}const e=(0,s.parseSemVer)(t);if(e==null||n.compare(e)<=0)continue;if(e.prerelease.length>0&&!o.prerelease)continue;o.previous={name:t,sha:A.sha};break e}}return o}},3545:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.booleanInput=booleanInput;const s=A(4708);const r=A(1506);function booleanInput(e,t=true){return(0,r.cache)(e,(()=>(0,s.getBooleanInput)(e,{required:t})))}},1506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.cache=cache;const A=new Map;function cache(e,t,s=false){if(!A.has(e)||s)A.set(e,t());return A.get(e)}},3820:function(e,t,A){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,A,s){if(s===undefined)s=A;var r=Object.getOwnPropertyDescriptor(t,A);if(!r||("get"in r?!t.__esModule:r.writable||r.configurable)){r={enumerable:true,get:function(){return t[A]}}}Object.defineProperty(e,s,r)}:function(e,t,A,s){if(s===undefined)s=A;e[s]=t[A]});var r=this&&this.__exportStar||function(e,t){for(var A in e)if(A!=="default"&&!Object.prototype.hasOwnProperty.call(t,A))s(t,e,A)};Object.defineProperty(t,"__esModule",{value:true});r(A(6956),t);r(A(273),t);r(A(3545),t);r(A(1506),t);r(A(5020),t);r(ALine truncated
|
||||
require('./sourcemap-register.js');(()=>{var e={252:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateChangelog=generateChangelog;const s=A(4708);const r=A(3820);function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}function sortBy(e,t){return e.sort(((e,A)=>e[t].localeCompare(A[t])))}async function generateChangelog(e){const{paginate:t,rest:A}=(0,r.octokit)();const{owner:o,repo:n,url:i}=(0,r.repository)();const a=(0,r.defaultCommitType)();const c=(0,r.commitTypes)();const l=(0,r.includePRLinks)();const g=(0,r.includeCommitLinks)();const u=(0,r.mentionAuthors)();const E=(0,r.useGithubAutolink)();const h=t.iterator(A.repos.listCommits,{per_page:100,sha:(0,r.sha)(),owner:o,repo:n});const d=[];e:for await(const{data:t}of h){for(const A of t){if(A.sha===e)break e;const t=A.commit.message.split("\n")[0];(0,s.debug)(`commit message -> ${t}`);let{type:o,scope:n,description:h,pr:p,flag:C,breaking:Q}=(0,r.parseCommitMessage)(t);if(!h)continue;h=trim(h);C=trim(C);if(C==="ignore")continue;o=c[trim(o??"")]??a;let I=d.find((e=>e.type===o));if(I==null){I={type:o,scopes:[]};d.push(I)}n=trim(n??"");let B=I.scopes.find((e=>e.scope===n));if(B==null){B={scope:n,logs:[]};I.scopes.push(B)}let m=B.logs.find((e=>e.description===h));if(m==null){m={breaking:Q,description:h,references:[]};B.logs.push(m)}const y=[];if(p&&l)y.push(E?`#${p}`:`[#${p}](${i}/issues/${p})`);else if(g)y.push(E?A.sha:`\`[${A.sha}](${i}/commit/${A.sha})\``);const w=A.author?.login;if(w&&u){const e=`by @${w}`;y.push(e);const t=m.references[m.references.length-1];if(t?.endsWith(e)){m.references.push(m.references.pop().replace(e,`& ${y.join(" ")}`));continue}}if(y.length>0)m.references.push(y.join(" "))}}const p=unique(Object.values(c).concat(a));const C=[];for(const e of p){const t=d.find((t=>t.type===e));if(t==null)continue;C.push(`## ${e}`);sortBy(t.scopes,"scope");for(const{scope:e,logs:A}of t.scopes){let t="";if(e.length>0){C.push(`* **${e}:**`);t=" "}for(const{breaking:e,description:s,references:r}of A){let A=`${t}* ${e?"***breaking:*** ":""}${s}`;if(r.length>0)A+=` (${r.join(", ")})`;C.push(A)}}C.push("")}return C.join("\n")}},6351:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generateFooter=generateFooter;const s=A(6087);const r=A(3820);async function generateFooter(e){const{owner:t,repo:A,url:o}=(0,r.repository)();const n=(0,r.releaseName)();const i=[];if((0,r.mentionNewContributors)()){const{rest:o}=(0,r.octokit)();const{data:a}=await o.repos.generateReleaseNotes({owner:t,repo:A,tag_name:n,previous_tag_name:e});const c=s.marked.lexer(a.body);const l=c.findIndex((e=>e.type==="heading"&&e.text==="New Contributors"));const g=c[l+1];if(g.type==="list")i.push(`## New Contributors\n${g.raw}\n`)}if((0,r.includeCompareLink)()&&e){let t=`${o}/compare/${e}...${n}`;if(!(0,r.useGithubAutolink)()||(0,r.releaseNamePrefix)())t=`\`[${e}...${n}](${o}/compare/${e}...${n})\``;i.push(`**Full Changelog**: ${t}`)}if(i.length>0)i.unshift("");return i.join("\n\n")}},146:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.getTagInfo=getTagInfo;const s=A(3820);async function getTagInfo(){const{paginate:e,rest:t}=(0,s.octokit)();const{owner:A,repo:r}=(0,s.repository)();const o={releaseId:"latest",prerelease:false};let n=null;if((0,s.semver)()){n=(0,s.parseSemVer)();if(n==null)throw new Error(`Expected a semver compatible releaseName, got "${(0,s.releaseName)()}" instead.`);o.prerelease=n.prerelease.length>0;if(o.prerelease)o.releaseId=`${n.prerelease[0]}`}const i=e.iterator(t.repos.listTags,{per_page:100,owner:A,repo:r});e:for await(const{data:e}of i){for(const{name:t,commit:A}of e){if((0,s.sha)()===A.sha)continue;if(n==null){o.previous={name:t,sha:A.sha};break e}const e=(0,s.parseSemVer)(t);if(e==null||n.compare(e)<=0)continue;if(e.prerelease.length>0&&!o.prerelease)continue;o.previous={name:t,sha:A.sha};break e}}return o}},3545:(e,t,A)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.booleanInput=booleanInput;const s=A(4708);const r=A(1506);function booleanInput(e,t=true){return(0,r.cache)(e,(()=>(0,s.getBooleanInput)(e,{required:t})))}},1506:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.cache=cache;const A=new Map;function cache(e,t,s=false){if(!A.has(e)||s)A.set(e,t());return A.get(e)}},3820:function(e,t,A){"use strict";var s=this&&this.__createBinding||(Object.create?function(e,t,A,s){if(s===undefined)s=A;var r=Object.getOwnPropertyDescriptor(t,A);if(!r||("get"in r?!t.__esModule:r.writable||r.configurable)){r={enumerable:true,get:function(){return t[A]}}}Object.defineProperty(e,s,r)}:function(e,t,A,s){if(s===undefined)s=A;e[s]=t[A]});var r=this&&this.__exportStar||function(e,t){for(var A in e)if(A!=="default"&&!Object.prototype.hasOwnProperty.call(t,A))s(t,e,A)};Object.defineProperty(t,"__esModule",{value:true});r(A(6956),t);r(A(273),t);r(A(3545),t);r(A(1506),t);r(A(5020),t);r(ALine truncated
|
||||
/*! formdata-polyfill. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> */;const escape=e=>e.replace(/\n/g,"%0A").replace(/\r/g,"%0D").replace(/"/g,"%22");const normalizeLinefeeds=e=>e.replace(/\r?\n|\r/g,"\r\n");const s=[];const r=new Uint8Array([13,10]);g=0;let o=false;for(const[t,n]of e){if(typeof n==="string"){const e=S.encode(A+`; name="${escape(normalizeLinefeeds(t))}"`+`\r\n\r\n${normalizeLinefeeds(n)}\r\n`);s.push(e);g+=e.byteLength}else{const e=S.encode(`${A}; name="${escape(normalizeLinefeeds(t))}"`+(n.name?`; filename="${escape(n.name)}"`:"")+"\r\n"+`Content-Type: ${n.type||"application/octet-stream"}\r\n\r\n`);s.push(e,n,r);if(typeof n.size==="number"){g+=e.byteLength+n.size+r.byteLength}else{o=true}}}const n=S.encode(`--${t}--`);s.push(n);g+=n.byteLength;if(o){g=null}l=e;c=async function*(){for(const e of s){if(e.stream){yield*e.stream()}else{yield e}}};u="multipart/form-data; boundary="+t}else if(n(e)){l=e;g=e.size;if(e.type){u=e.type}}else if(typeof e[Symbol.asyncIterator]==="function"){if(t){throw new TypeError("keepalive")}if(r.isDisturbed(e)||e.locked){throw new TypeError("Response body object should not be disturbed or locked")}s=e instanceof R?e:o(e)}if(typeof l==="string"||r.isBuffer(l)){g=Buffer.byteLength(l)}if(c!=null){let t;s=new R({async start(){t=c(e)[Symbol.asyncIterator]()},async pull(e){const{value:A,done:r}=await t.next();if(r){queueMicrotask((()=>{e.close()}))}else{if(!B(s)){e.enqueue(new Uint8Array(A))}}return e.desiredSize>0},async cancel(e){await t.return()},type:undefined})}const E={stream:s,source:l,length:g};return[E,u]}function safelyExtractBody(e,t=false){if(!R){R=A(3774).ReadableStream}if(e instanceof R){I(!r.isDisturbed(e),"The body has already been consumed.");I(!e.locked,"The stream is locked.")}return extractBody(e,t)}function cloneBody(e){const[t,A]=e.stream.tee();const s=d(A,{transfer:[A]});const[,r]=s.tee();e.stream=t;return{stream:r,length:e.length,source:e.source}}async function*consumeBody(e){if(e){if(m(e)){yield e}else{const t=e.stream;if(r.isDisturbed(t)){throw new TypeError("The body has already been consumed.")}if(t.locked){throw new TypeError("The stream is locked.")}t[Q]=true;yield*t}}}function throwIfAborted(e){if(e.aborted){throw new h("The operation was aborted.","AbortError")}}function bodyMixinMethods(e){const t={blob(){return specConsumeBody(this,(e=>{let t=bodyMimeType(this);if(t==="failure"){t=""}else if(t){t=k(t)}return new p([e],{type:t})}),e)},arrayBuffer(){return specConsumeBody(this,(e=>new Uint8Array(e).buffer),e)},text(){return specConsumeBody(this,utf8DecodeBytes,e)},json(){return specConsumeBody(this,parseJSONFromBytes,e)},async formData(){E.brandCheck(this,e);throwIfAborted(this[u]);const t=this.headers.get("Content-Type");if(/multipart\/form-data/.test(t)){const e={};for(const[t,A]of this.headers)e[t.toLowerCase()]=A;const t=new g;let A;try{A=new s({headers:e,preservePath:true})}catch(e){throw new h(`${e}`,"AbortError")}A.on("field",((e,A)=>{t.append(e,A)}));A.on("file",((e,A,s,r,o)=>{const n=[];if(r==="base64"||r.toLowerCase()==="base64"){let r="";A.on("data",(e=>{r+=e.toString().replace(/[\r\n]/gm,"");const t=r.length-r.length%4;n.push(Buffer.from(r.slice(0,t),"base64"));r=r.slice(t)}));A.on("end",(()=>{n.push(Buffer.from(r,"base64"));t.append(e,new D(n,s,{type:o}))}))}else{A.on("data",(e=>{n.push(e)}));A.on("end",(()=>{t.append(e,new D(n,s,{type:o}))}))}}));const r=new Promise(((e,t)=>{A.on("finish",e);A.on("error",(e=>t(new TypeError(e))))}));if(this.body!==null)for await(const e of consumeBody(this[u].body))A.write(e);A.end();await r;return t}else if(/application\/x-www-form-urlencoded/.test(t)){let e;try{let t="";const A=new TextDecoder("utf-8",{ignoreBOM:true});for await(const e of consumeBody(this[u].body)){if(!m(e)){throw new TypeError("Expected Uint8Array chunk")}t+=A.decode(e,{stream:true})}t+=A.decode();e=new URLSearchParams(t)}catch(e){throw Object.assign(new TypeError,{cause:e})}const t=new g;for(const[A,s]of e){t.append(A,s)}return t}else{await Promise.resolve();throwIfAborted(this[u]);throw E.errors.exception({header:`${e.name}.formData`,message:"Could not parse content as FormData."})}}};return t}function mixinBody(e){Object.assign(e.prototype,bodyMixinMethods(e))}async function specConsumeBody(e,t,A){E.brandCheck(e,A);throwIfAborted(e[u]);if(bodyUnusable(e[u].body)){throw new TypeError("Body is unusable")}const s=c();const errorSteps=e=>s.reject(e);const successSteps=e=>{try{s.resolve(t(e))}catch(e){errorSteps(e)}};if(e[u].body==null){successSteps(new Uint8Array);return s.promise}await l(e[u].body,successSteps,errorSteps);return s.promise}function bodyUnusable(e){return e!=null&&(e.stream.locked||r.isDisturbed(e.stream))}function utf8DecodeBytes(e){if(e.length===0){return""}if(e[0]===239&&e[1]===187&&e[2]===191){e=e.subarray(3)}const t=T.decode(e);return t}function parseJSONFromBytes(e){return JSON.parse(utf8DecodeBytes(e))}function bodyMimeType(e){const{headersList:t}=e[u];const A=t.get("content-Line truncated
|
||||
/*! ws. MIT License. Einar Otto Stangvik <[email protected]> */o[r-4]=this.maskKey[0];o[r-3]=this.maskKey[1];o[r-2]=this.maskKey[2];o[r-1]=this.maskKey[3];o[1]=A;if(A===126){o.writeUInt16BE(t,2)}else if(A===127){o[2]=o[3]=0;o.writeUIntBE(t,4,6)}o[1]|=128;for(let e=0;e<t;e++){o[r+e]=this.frameData[e]^this.maskKey[e%4]}return o}}e.exports={WebsocketFrameSend:WebsocketFrameSend}},7560:(e,t,A)=>{"use strict";const{Writable:s}=A(2203);const r=A(1637);const{parserStates:o,opcodes:n,states:i,emptyBuffer:a}=A(4580);const{kReadyState:c,kSentClose:l,kResponse:g,kReceivedClose:u}=A(5396);const{isValidStatusCode:E,failWebsocketConnection:h,websocketMessageReceived:d}=A(2813);const{WebsocketFrameSend:p}=A(9924);const C={};C.ping=r.channel("undici:websocket:ping");C.pong=r.channel("undici:websocket:pong");class ByteParser extends s{#n=[];#i=0;#a=o.INFO;#c={};#l=[];constructor(e){super();this.ws=e}_write(e,t,A){this.#n.push(e);this.#i+=e.length;this.run(A)}run(e){while(true){if(this.#a===o.INFO){if(this.#i<2){return e()}const t=this.consume(2);this.#c.fin=(t[0]&128)!==0;this.#c.opcode=t[0]&15;this.#c.originalOpcode??=this.#c.opcode;this.#c.fragmented=!this.#c.fin&&this.#c.opcode!==n.CONTINUATION;if(this.#c.fragmented&&this.#c.opcode!==n.BINARY&&this.#c.opcode!==n.TEXT){h(this.ws,"Invalid frame type was fragmented.");return}const A=t[1]&127;if(A<=125){this.#c.payloadLength=A;this.#a=o.READ_DATA}else if(A===126){this.#a=o.PAYLOADLENGTH_16}else if(A===127){this.#a=o.PAYLOADLENGTH_64}if(this.#c.fragmented&&A>125){h(this.ws,"Fragmented frame exceeded 125 bytes.");return}else if((this.#c.opcode===n.PING||this.#c.opcode===n.PONG||this.#c.opcode===n.CLOSE)&&A>125){h(this.ws,"Payload length for control frame exceeded 125 bytes.");return}else if(this.#c.opcode===n.CLOSE){if(A===1){h(this.ws,"Received close frame with a 1-byte body.");return}const e=this.consume(A);this.#c.closeInfo=this.parseCloseBody(false,e);if(!this.ws[l]){const e=Buffer.allocUnsafe(2);e.writeUInt16BE(this.#c.closeInfo.code,0);const t=new p(e);this.ws[g].socket.write(t.createFrame(n.CLOSE),(e=>{if(!e){this.ws[l]=true}}))}this.ws[c]=i.CLOSING;this.ws[u]=true;this.end();return}else if(this.#c.opcode===n.PING){const t=this.consume(A);if(!this.ws[u]){const e=new p(t);this.ws[g].socket.write(e.createFrame(n.PONG));if(C.ping.hasSubscribers){C.ping.publish({payload:t})}}this.#a=o.INFO;if(this.#i>0){continue}else{e();return}}else if(this.#c.opcode===n.PONG){const t=this.consume(A);if(C.pong.hasSubscribers){C.pong.publish({payload:t})}if(this.#i>0){continue}else{e();return}}}else if(this.#a===o.PAYLOADLENGTH_16){if(this.#i<2){return e()}const t=this.consume(2);this.#c.payloadLength=t.readUInt16BE(0);this.#a=o.READ_DATA}else if(this.#a===o.PAYLOADLENGTH_64){if(this.#i<8){return e()}const t=this.consume(8);const A=t.readUInt32BE(0);if(A>2**31-1){h(this.ws,"Received payload length > 2^31 bytes.");return}const s=t.readUInt32BE(4);this.#c.payloadLength=(A<<8)+s;this.#a=o.READ_DATA}else if(this.#a===o.READ_DATA){if(this.#i<this.#c.payloadLength){return e()}else if(this.#i>=this.#c.payloadLength){const e=this.consume(this.#c.payloadLength);this.#l.push(e);if(!this.#c.fragmented||this.#c.fin&&this.#c.opcode===n.CONTINUATION){const e=Buffer.concat(this.#l);d(this.ws,this.#c.originalOpcode,e);this.#c={};this.#l.length=0}this.#a=o.INFO}}if(this.#i>0){continue}else{e();break}}}consume(e){if(e>this.#i){return null}else if(e===0){return a}if(this.#n[0].length===e){this.#i-=this.#n[0].length;return this.#n.shift()}const t=Buffer.allocUnsafe(e);let A=0;while(A!==e){const s=this.#n[0];const{length:r}=s;if(r+A===e){t.set(this.#n.shift(),A);break}else if(r+A>e){t.set(s.subarray(0,e-A),A);this.#n[0]=s.subarray(e-A);break}else{t.set(this.#n.shift(),A);A+=s.length}}this.#i-=e;return t}parseCloseBody(e,t){let A;if(t.length>=2){A=t.readUInt16BE(0)}if(e){if(!E(A)){return null}return{code:A}}let s=t.subarray(2);if(s[0]===239&&s[1]===187&&s[2]===191){s=s.subarray(3)}if(A!==undefined&&!E(A)){return null}try{s=new TextDecoder("utf-8",{fatal:true}).decode(s)}catch{return null}return{code:A,reason:s}}get closingInfo(){return this.#c.closeInfo}}e.exports={ByteParser:ByteParser}},5396:e=>{"use strict";e.exports={kWebSocketURL:Symbol("url"),kReadyState:Symbol("ready state"),kController:Symbol("controller"),kResponse:Symbol("response"),kBinaryType:Symbol("binary type"),kSentClose:Symbol("sent close"),kReceivedClose:Symbol("received close"),kByteParser:Symbol("byte parser")}},2813:(e,t,A)=>{"use strict";const{kReadyState:s,kController:r,kResponse:o,kBinaryType:n,kWebSocketURL:i}=A(5396);const{states:a,opcodes:c}=A(4580);const{MessageEvent:l,ErrorEvent:g}=A(1728);function isEstablished(e){return e[s]===a.OPEN}function isClosing(e){return e[s]===a.CLOSING}function isClosed(e){return e[s]===a.CLOSED}function fireEvent(e,t,A=Event,s){const r=new A(e,s);t.dispatchEvent(r)}function websocketMessageReceived(e,t,A){if(e[s]!==a.OPEN){return}let r;if(t===c.TEXT){try{r=new TextDecoder("utf-8",{fatal:true}).decode(A)Line truncated
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","names":["Object","defineProperty","exports","value","generateChangelog","core_1","__webpack_require__","index_js_1","trim","replace","unique","Set","sortBy","array","property","sort","a","b","localeCompare","async","lastSha","paginate","rest","octokit","owner","repo","url","repository","defaultType","defaultCommitType","typeMap","commitTypes","shouldIncludePRLinks","includePRLinks","shouldIncludeCommitLinks","includeCommitLinks","shouldMentionAuthors","mentionAuthors","shouldUseGithubAutolink","useGithubAutolink","iterator","repos","listCommits","per_page","sha","typeGroups","paginator","data","commit","message","split","debug","type","scope","description","pr","flag","breaking","parseCommitMessage","typeGroup","find","record","scopes","push","scopeGroup","logs","log","references","reference","username","author","login","mention","lastReference","length","endsWith","pop","join","types","values","concat","changelog","prefix","line","generateFooter","marked_1","previousTagName","tagName","releaseName","footer","mentionNewContributors","generateReleaseNotes","tag_name","previous_tag_name","tokens","marked","lexer","body","index","findIndex","markdownToken","text","raw","includeCompareLink","link","releaseNamePrefix","unshift","getTagInfo","info","releaseId","prerelease","semVer","semver","parseSemVer","Error","listTags","loop","name","previous","version","compare","booleanInput","cache_js_1","required","cache","getBooleanInput","CACHE","Map","key","overwrite","has","set","get","__createBinding","this","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","__exportStar","p","prototype","hasOwnProperty","call","input","parser","getInput","__importDefault","mod","default","yaml_1","input_js_1","parse","boolean_input_js_1","token","github_1","getOctokit","output","setOutput","setChangelog","output_js_1","setPrerelease","setReleaseId","REGEX","exec","groups","semver_1","RegExp","includePrerelease","serverUrl","context","__setModuleDefault","v","__importStar","result","issue","issueCommand","os","utils_1","command","properties","cmd","Command","process","stdout","write","toString","EOL","CMD_STRING","constructor","cmdStr","keys","first","val","escapeProperty","escapeData","s","toCommandValue","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","done","then","apply","platform","toPlatformPath","toWin32Path","toPosixPath","markdownSummary","summary","getIDToken","getState","saveState","group","endGroup","startGroup","notice","warning","error","isDebug","setFailed","setCommandEcho","getMultilineInput","addPath","setSecret","exportVariable","ExitCode","command_1","file_command_1","path","oidc_utils_1","convertedVal","env","filePath","issueFileCommand","prepareKeyValueMessage","secret","inputPath","delimiter","options","toUpperCase","trimWhitespace","inputs","filter","x","map","trueValue","falseValue","includes","TypeError","enabled","exitCode","Failure","toCommandProperties","fn","aud","OidcClient","summary_1","summary_2","path_utils_1","crypto","fs","existsSync","appendFileSync","encoding","randomUUID","convertedValue","http_client_1","auth_1","createHttpClient","allowRetry","maxRetry","requestOptions","allowRetries","maxRetries","HttpClient","BearerCredentialHandler","getRequestToken","getIDTokenUrl","runtimeUrl","getCall","id_token_url","_a","httpclient","res","getJson","catch","statusCode","id_token","audience","encodedAudience","encodeURIComponent","pth","sep","getDetails","isLinux","isMacOS","isWindows","arch","os_1","getWindowsInfo","getExecOutput","silent","getMacOsInfo","_b","_c","_d","match","getLinuxInfo","assign","SUMMARY_DOCS_URL","SUMMARY_ENV_VAR","fs_1","access","appendFile","writeFile","promises","Summary","_buffer","_filePath","pathFromEnv","constants","R_OK","W_OK","wrap","tag","content","attrs","htmlAttrs","entries","writeFunc","emptyBuffer","clear","stringify","isEmptyBuffer","addRaw","addEOL","addCodeBlock","code","lang","element","addList","items","ordered","listItems","item","addTable","rows","tableBody","row","cells","cell","header","colspan","rowspan","addDetails","label","addImage","src","alt","width","height","addHeading","level","allowedTag","addSeparator","addBreak","addQuote","cite","addLink","href","_summary","String","JSON","annotationProperties","title","file","startLine","endLine","col","startColumn","endColumn","string_decoder_1","tr","commandLine","args","commandArgs","argStringToArray","toolPath","slice","runner","ToolRunner","stderr","stdoutDecoder","StringDecoder","stderrDecoder","originalStdoutListener","listeners","originalStdErrListener","stdErrListener","stdOutListener","end","events","child","io","ioUtil","timers_1","IS_WINDOWS","EventEmitter","super","_debug","_getCommandString","noPrefix","_getSpawnFileName","_getSpawnArgs","_isCmdFile","windowsVerbatimArguments","_windowsQuoteCmdArg","_processLineLine truncated
|
||||
{"version":3,"file":"index.js","names":["Object","defineProperty","exports","value","generateChangelog","core_1","__webpack_require__","index_js_1","trim","replace","unique","Set","sortBy","array","property","sort","a","b","localeCompare","async","lastSha","paginate","rest","octokit","owner","repo","url","repository","defaultType","defaultCommitType","typeMap","commitTypes","shouldIncludePRLinks","includePRLinks","shouldIncludeCommitLinks","includeCommitLinks","shouldMentionAuthors","mentionAuthors","shouldUseGithubAutolink","useGithubAutolink","iterator","repos","listCommits","per_page","sha","typeGroups","paginator","data","commit","message","split","debug","type","scope","description","pr","flag","breaking","parseCommitMessage","typeGroup","find","record","scopes","push","scopeGroup","logs","log","references","reference","username","author","login","mention","lastReference","length","endsWith","pop","join","types","values","concat","changelog","prefix","line","generateFooter","marked_1","previousTagName","tagName","releaseName","footer","mentionNewContributors","generateReleaseNotes","tag_name","previous_tag_name","tokens","marked","lexer","body","index","findIndex","markdownToken","text","raw","includeCompareLink","link","releaseNamePrefix","unshift","getTagInfo","info","releaseId","prerelease","semVer","semver","parseSemVer","Error","listTags","loop","name","previous","version","compare","booleanInput","cache_js_1","required","cache","getBooleanInput","CACHE","Map","key","overwrite","has","set","get","__createBinding","this","create","o","m","k","k2","undefined","desc","getOwnPropertyDescriptor","__esModule","writable","configurable","enumerable","__exportStar","p","prototype","hasOwnProperty","call","input","parser","getInput","__importDefault","mod","default","yaml_1","input_js_1","parse","boolean_input_js_1","token","github_1","getOctokit","output","setOutput","setChangelog","output_js_1","setPrerelease","setReleaseId","REGEX","exec","groups","semver_1","RegExp","includePrerelease","serverUrl","context","__setModuleDefault","v","__importStar","result","issue","issueCommand","os","utils_1","command","properties","cmd","Command","process","stdout","write","toString","EOL","CMD_STRING","constructor","cmdStr","keys","first","val","escapeProperty","escapeData","s","toCommandValue","__awaiter","thisArg","_arguments","P","generator","adopt","resolve","Promise","reject","fulfilled","step","next","e","rejected","done","then","apply","platform","toPlatformPath","toWin32Path","toPosixPath","markdownSummary","summary","getIDToken","getState","saveState","group","endGroup","startGroup","notice","warning","error","isDebug","setFailed","setCommandEcho","getMultilineInput","addPath","setSecret","exportVariable","ExitCode","command_1","file_command_1","path","oidc_utils_1","convertedVal","env","filePath","issueFileCommand","prepareKeyValueMessage","secret","inputPath","delimiter","options","toUpperCase","trimWhitespace","inputs","filter","x","map","trueValue","falseValue","includes","TypeError","enabled","exitCode","Failure","toCommandProperties","fn","aud","OidcClient","summary_1","summary_2","path_utils_1","crypto","fs","existsSync","appendFileSync","encoding","randomUUID","convertedValue","http_client_1","auth_1","createHttpClient","allowRetry","maxRetry","requestOptions","allowRetries","maxRetries","HttpClient","BearerCredentialHandler","getRequestToken","getIDTokenUrl","runtimeUrl","getCall","id_token_url","_a","httpclient","res","getJson","catch","statusCode","id_token","audience","encodedAudience","encodeURIComponent","pth","sep","getDetails","isLinux","isMacOS","isWindows","arch","os_1","getWindowsInfo","getExecOutput","silent","getMacOsInfo","_b","_c","_d","match","getLinuxInfo","assign","SUMMARY_DOCS_URL","SUMMARY_ENV_VAR","fs_1","access","appendFile","writeFile","promises","Summary","_buffer","_filePath","pathFromEnv","constants","R_OK","W_OK","wrap","tag","content","attrs","htmlAttrs","entries","writeFunc","emptyBuffer","clear","stringify","isEmptyBuffer","addRaw","addEOL","addCodeBlock","code","lang","element","addList","items","ordered","listItems","item","addTable","rows","tableBody","row","cells","cell","header","colspan","rowspan","addDetails","label","addImage","src","alt","width","height","addHeading","level","allowedTag","addSeparator","addBreak","addQuote","cite","addLink","href","_summary","String","JSON","annotationProperties","title","file","startLine","endLine","col","startColumn","endColumn","string_decoder_1","tr","commandLine","args","commandArgs","argStringToArray","toolPath","slice","runner","ToolRunner","stderr","stdoutDecoder","StringDecoder","stderrDecoder","originalStdoutListener","listeners","originalStdErrListener","stdErrListener","stdOutListener","end","events","child","io","ioUtil","timers_1","IS_WINDOWS","EventEmitter","super","_debug","_getCommandString","noPrefix","_getSpawnFileName","_getSpawnArgs","_isCmdFile","windowsVerbatimArguments","_windowsQuoteCmdArg","_processLineLine truncated
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2024 Ardalan Amini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* For a detailed explanation regarding each configuration property, visit:
|
||||
* https://jestjs.io/docs/configuration
|
||||
*/
|
||||
|
||||
import { type Config } from "jest";
|
||||
|
||||
export default {
|
||||
// All imported modules in your tests should be mocked automatically
|
||||
// automock: false,
|
||||
|
||||
// Stop running tests after `n` failures
|
||||
// bail: 0,
|
||||
|
||||
// The directory where Jest should store its cached dependency information
|
||||
// cacheDirectory: "/private/var/folders/dp/t3bs9gd575qfbxts2_vk6cm80000gn/T/jest_dx",
|
||||
|
||||
// Automatically clear mock calls, instances, contexts and results before every test
|
||||
clearMocks: true,
|
||||
|
||||
// Indicates whether the coverage information should be collected while executing the test
|
||||
// collectCoverage: false,
|
||||
|
||||
// An array of glob patterns indicating a set of files for which coverage information should be collected
|
||||
collectCoverageFrom: ["<rootDir>/src/**/*.ts"],
|
||||
|
||||
// The directory where Jest should output its coverage files
|
||||
// coverageDirectory: undefined,
|
||||
|
||||
// An array of regexp pattern strings used to skip coverage collection
|
||||
// coveragePathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// Indicates which provider should be used to instrument code for coverage
|
||||
coverageProvider: "babel",
|
||||
|
||||
// A list of reporter names that Jest uses when writing coverage reports
|
||||
// coverageReporters: [
|
||||
// "json",
|
||||
// "text",
|
||||
// "lcov",
|
||||
// "clover"
|
||||
// ],
|
||||
|
||||
// An object that configures minimum threshold enforcement for coverage results
|
||||
// coverageThreshold: undefined,
|
||||
|
||||
// A path to a custom dependency extractor
|
||||
// dependencyExtractor: undefined,
|
||||
|
||||
// Make calling deprecated APIs throw helpful error messages
|
||||
// errorOnDeprecated: false,
|
||||
|
||||
// The default configuration for fake timers
|
||||
// fakeTimers: {
|
||||
// "enableGlobally": false
|
||||
// },
|
||||
|
||||
// Force coverage collection from ignored files using an array of glob patterns
|
||||
// forceCoverageMatch: [],
|
||||
|
||||
// A path to a module which exports an async function that is triggered once before all test suites
|
||||
// globalSetup: undefined,
|
||||
|
||||
// A path to a module which exports an async function that is triggered once after all test suites
|
||||
// globalTeardown: undefined,
|
||||
|
||||
// A set of global variables that need to be available in all test environments
|
||||
// globals: {},
|
||||
|
||||
// The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
|
||||
// maxWorkers: "50%",
|
||||
|
||||
// An array of directory names to be searched recursively up from the requiring module's location
|
||||
// moduleDirectories: [
|
||||
// "node_modules"
|
||||
// ],
|
||||
|
||||
// An array of file extensions your modules use
|
||||
// moduleFileExtensions: [
|
||||
// "js",
|
||||
// "mjs",
|
||||
// "cjs",
|
||||
// "jsx",
|
||||
// "ts",
|
||||
// "tsx",
|
||||
// "json",
|
||||
// "node"
|
||||
// ],
|
||||
|
||||
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
||||
moduleNameMapper: {
|
||||
"^(\\.{1,2}/.*)\\.js$": "$1",
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
||||
// modulePathIgnorePatterns: [],
|
||||
|
||||
// Activates notifications for test results
|
||||
// notify: false,
|
||||
|
||||
// An enum that specifies notification mode. Requires { notify: true }
|
||||
// notifyMode: "failure-change",
|
||||
|
||||
// A preset that is used as a base for Jest's configuration
|
||||
// preset: undefined,
|
||||
|
||||
// Run tests from one or more projects
|
||||
// projects: undefined,
|
||||
|
||||
// Use this configuration option to add custom reporters to Jest
|
||||
reporters: ["default", "github-actions"],
|
||||
|
||||
// Automatically reset mock state before every test
|
||||
// resetMocks: false,
|
||||
|
||||
// Reset the module registry before running each individual test
|
||||
// resetModules: false,
|
||||
|
||||
// A path to a custom resolver
|
||||
// resolver: undefined,
|
||||
|
||||
// Automatically restore mock state and implementation before every test
|
||||
// restoreMocks: false,
|
||||
|
||||
// The root directory that Jest should scan for tests and modules within
|
||||
// rootDir: undefined,
|
||||
|
||||
// A list of paths to directories that Jest should use to search for files in
|
||||
// roots: [
|
||||
// "<rootDir>"
|
||||
// ],
|
||||
|
||||
// Allows you to use a custom runner instead of Jest's default test runner
|
||||
// runner: "jest-runner",
|
||||
|
||||
// The paths to modules that run some code to configure or set up the testing environment before each test
|
||||
// setupFiles: [],
|
||||
|
||||
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
||||
// setupFilesAfterEnv: [],
|
||||
|
||||
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
||||
// slowTestThreshold: 5,
|
||||
|
||||
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
||||
// snapshotSerializers: [],
|
||||
|
||||
// The test environment that will be used for testing
|
||||
// testEnvironment: "jest-environment-node",
|
||||
|
||||
// Options that will be passed to the testEnvironment
|
||||
// testEnvironmentOptions: {},
|
||||
|
||||
// Adds a location field to test results
|
||||
// testLocationInResults: false,
|
||||
|
||||
// The glob patterns Jest uses to detect test files
|
||||
testMatch: [
|
||||
"<rootDir>/tests/**/*.test.ts",
|
||||
|
||||
// "**/__tests__/**/*.[jt]s?(x)",
|
||||
// "**/?(*.)+(spec|test).[tj]s?(x)",
|
||||
],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
// testPathIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
|
||||
// This option allows the use of a custom results processor
|
||||
// testResultsProcessor: undefined,
|
||||
|
||||
// This option allows use of a custom test runner
|
||||
// testRunner: "jest-circus/runner",
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
transform: {
|
||||
"^.+\\.[cm]?[jt]sx?$": "@swc/jest",
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
// transformIgnorePatterns: [
|
||||
// "/node_modules/",
|
||||
// "\\.pnp\\.[^\\/]+$"
|
||||
// ],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
|
||||
// Indicates whether each individual test should be reported during the run
|
||||
// verbose: undefined,
|
||||
|
||||
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
|
||||
// watchPathIgnorePatterns: [],
|
||||
|
||||
// Whether to use watchman for file crawling
|
||||
// watchman: true,
|
||||
|
||||
logHeapUsage: true,
|
||||
|
||||
workerIdleMemoryLimit: "512MB",
|
||||
} satisfies Config;
|
||||
+7
-1
@@ -31,7 +31,8 @@
|
||||
"build:watch": "pnpm build --watch",
|
||||
"package": "ncc build --out action --minify --source-map --license licenses.txt",
|
||||
"all": "pnpm lint:fix && pnpm build && pnpm package",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "node --expose-gc node_modules/jest/bin/jest -c jest.config.ts",
|
||||
"test:coverage": "pnpm test -- --coverage"
|
||||
},
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.11.1",
|
||||
@@ -44,6 +45,9 @@
|
||||
"@commitlint/cli": "^19.5.0",
|
||||
"@commitlint/config-conventional": "^19.5.0",
|
||||
"@commitlint/types": "^19.5.0",
|
||||
"@swc/core": "^1.7.40",
|
||||
"@swc/jest": "^0.2.36",
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/semver": "^7.5.8",
|
||||
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
||||
"@typescript-eslint/parser": "^6.21.0",
|
||||
@@ -54,7 +58,9 @@
|
||||
"eslint-plugin-import": "^2.31.0",
|
||||
"husky": "^9.1.6",
|
||||
"is-ci": "^3.0.1",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.3.3",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
Generated
+2226
-5
File diff suppressed because it is too large.
Load diff
@@ -23,7 +23,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
const REGEX = /^(?<type>[^!:()]*)(?:\((?<scope>[^!()]*?)\)|)(?<breaking>!?): *(?<description>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;
|
||||
const REGEX = /^(?<type>[^!:() ]*)(?:\((?<scope>[^!()]*?)\)|)(?<breaking>!?): *(?<description>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;
|
||||
|
||||
export function parseCommitMessage(message: string): ParsedCommitMessageI {
|
||||
const { description, flag, pr, scope, type, breaking } = REGEX.exec(message)?.groups ?? {};
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2024 Ardalan Amini
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*
|
||||
*/
|
||||
|
||||
/* eslint-disable no-undefined */
|
||||
import { parseCommitMessage } from "../../src/utils";
|
||||
|
||||
describe("acceptable commit message formats", () => {
|
||||
it("should parse the commit message with breaking false", () => {
|
||||
expect(parseCommitMessage("type(scope): the description [flag]")).toEqual({
|
||||
breaking : false,
|
||||
description: "the description",
|
||||
flag : "flag",
|
||||
pr : undefined,
|
||||
scope : "scope",
|
||||
type : "type",
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse the commit message with breaking true", () => {
|
||||
expect(parseCommitMessage("type(scope)!: the description [flag]")).toEqual({
|
||||
breaking : true,
|
||||
description: "the description",
|
||||
flag : "flag",
|
||||
pr : undefined,
|
||||
scope : "scope",
|
||||
type : "type",
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse the commit message with PR number", () => {
|
||||
expect(parseCommitMessage("type(scope): the description (#1) [flag]")).toEqual({
|
||||
breaking : false,
|
||||
description: "the description",
|
||||
flag : "flag",
|
||||
pr : "1",
|
||||
scope : "scope",
|
||||
type : "type",
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse the commit message with without flag", () => {
|
||||
expect(parseCommitMessage("type(scope): the description")).toEqual({
|
||||
breaking : false,
|
||||
description: "the description",
|
||||
flag : undefined,
|
||||
pr : undefined,
|
||||
scope : "scope",
|
||||
type : "type",
|
||||
});
|
||||
});
|
||||
|
||||
it("should parse the commit message with without scope", () => {
|
||||
expect(parseCommitMessage("type: the description")).toEqual({
|
||||
breaking : false,
|
||||
description: "the description",
|
||||
flag : undefined,
|
||||
pr : undefined,
|
||||
scope : undefined,
|
||||
type : "type",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("unacceptable (ignored) commit message formats", () => {
|
||||
it.each(["1.0.0", "1.0.0-alpha.1"])("should not parse the npm versioning commit message: \"%s\"", (message) => {
|
||||
expect(parseCommitMessage(message)).toEqual({
|
||||
breaking : false,
|
||||
description: undefined,
|
||||
flag : undefined,
|
||||
pr : undefined,
|
||||
scope : undefined,
|
||||
type : undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
"Merge branch 'development'",
|
||||
"Merge branch 'development' into main",
|
||||
"Merge pull request #1 from auto-changelog/main",
|
||||
"Merge branch 'main' of github.com:auto-changelog/main",
|
||||
"Merge branch 'main' of https://github.com/auto-changelog/main",
|
||||
])("should not parse the merge commit message: \"%s\"", (message) => {
|
||||
expect(parseCommitMessage(message)).toEqual({
|
||||
breaking : false,
|
||||
description: undefined,
|
||||
flag : undefined,
|
||||
pr : undefined,
|
||||
scope : undefined,
|
||||
type : undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["commitlint.config.cts"]
|
||||
"exclude": ["commitlint.config.cts", "jest.config.ts", "tests"]
|
||||
}
|
||||
Reference in new issue
Block a user