@ossjs/release
Advanced tools
@@ -5,8 +5,13 @@ "use strict"; | ||
| /** | ||
| * Determine if the given commit describes a breaking change. | ||
| * @note For now, this only analyzes the "BREAKING CHANGE" comment | ||
| * in the commit's body. | ||
| * Returns true if the given parsed commit represents a breaking change. | ||
| * @see https://www.conventionalcommits.org/en/v1.0.0/#summary | ||
| */ | ||
| function isBreakingChange(commit) { | ||
| return commit.notes.some((note) => note.title === 'BREAKING CHANGE'); | ||
| if (commit.typeAppendix === '!') { | ||
| return true; | ||
| } | ||
| if (commit.footer && commit.footer.includes('BREAKING CHANGE:')) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
@@ -13,0 +18,0 @@ exports.isBreakingChange = isBreakingChange; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"getNextReleaseType.js","sourceRoot":"","sources":["../../../src/utils/getNextReleaseType.ts"],"names":[],"mappings":";;;AAOA;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,MAA4B;IAC3D,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,KAAK,iBAAiB,CAAC,CAAA;AACtE,CAAC;AAFD,4CAEC;AAED,SAAgB,kBAAkB,CAChC,OAA+B,EAC/B,OAAmC;IAEnC,MAAM,MAAM,GAAqC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAE7D,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,IAAI,gBAAgB,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAA;SAC/C;QAED,oEAAoE;QACpE,QAAQ,MAAM,CAAC,IAAI,EAAE;YACnB,KAAK,MAAM,CAAC,CAAC;gBACX,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAA;gBACnB,MAAK;aACN;YAED,KAAK,KAAK,CAAC,CAAC;gBACV,MAAM,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} |
@@ -7,10 +7,13 @@ "use strict"; | ||
| exports.parseCommits = void 0; | ||
| const stream_1 = require("stream"); | ||
| const node_stream_1 = require("node:stream"); | ||
| const outvariant_1 = require("outvariant"); | ||
| const deferred_promise_1 = require("@open-draft/deferred-promise"); | ||
| const conventional_commits_parser_1 = __importDefault(require("conventional-commits-parser")); | ||
| const COMMIT_HEADER_APPENDIX_REGEXP = /^(.+)(!)(:)/g; | ||
| async function parseCommits(commits) { | ||
| const through = new stream_1.PassThrough(); | ||
| const commitMap = {}; | ||
| const through = new node_stream_1.PassThrough(); | ||
| const commitMap = new Map(); | ||
| for (const commit of commits) { | ||
| commitMap[commit.subject] = commit; | ||
| const message = [commit.subject, commit.body].filter(Boolean).join('\n'); | ||
| commitMap.set(commit.subject, commit); | ||
| const message = joinCommit(commit.subject, commit.body); | ||
| through.write(message, 'utf8'); | ||
@@ -20,24 +23,36 @@ } | ||
| const commitParser = (0, conventional_commits_parser_1.default)(); | ||
| const results = await new Promise((resolve, reject) => { | ||
| const commits = []; | ||
| through | ||
| .pipe(commitParser) | ||
| .on('error', (error) => reject(error)) | ||
| .on('data', (parsedCommit) => { | ||
| const { header } = parsedCommit; | ||
| if (!header) { | ||
| return; | ||
| } | ||
| const originalCommit = commitMap[header]; | ||
| const commit = Object.assign({}, parsedCommit, { | ||
| hash: originalCommit.hash, | ||
| }); | ||
| commits.push(commit); | ||
| }) | ||
| .on('end', () => resolve(commits)); | ||
| const parsingStreamPromise = new deferred_promise_1.DeferredPromise(); | ||
| parsingStreamPromise.finally(() => { | ||
| through.destroy(); | ||
| }); | ||
| through.destroy(); | ||
| return results; | ||
| const parsedCommits = []; | ||
| through | ||
| .pipe(commitParser) | ||
| .on('error', (error) => parsingStreamPromise.reject(error)) | ||
| .on('data', (parsedCommit) => { | ||
| let resolvedParsingResult = parsedCommit; | ||
| if (!parsedCommit.header) { | ||
| return; | ||
| } | ||
| let typeAppendix; | ||
| if (COMMIT_HEADER_APPENDIX_REGEXP.test(parsedCommit.header)) { | ||
| const headerWithoutAppendix = parsedCommit.header.replace(COMMIT_HEADER_APPENDIX_REGEXP, '$1$3'); | ||
| resolvedParsingResult = conventional_commits_parser_1.default.sync(joinCommit(headerWithoutAppendix, parsedCommit.body)); | ||
| typeAppendix = '!'; | ||
| } | ||
| const originalCommit = commitMap.get(parsedCommit.header); | ||
| (0, outvariant_1.invariant)(originalCommit, 'Failed to parse commit "%s": no original commit found associated with header', parsedCommit.header); | ||
| const commit = Object.assign({}, resolvedParsingResult, { | ||
| hash: originalCommit.hash, | ||
| typeAppendix, | ||
| }); | ||
| parsedCommits.push(commit); | ||
| }) | ||
| .on('end', () => parsingStreamPromise.resolve(parsedCommits)); | ||
| return parsingStreamPromise; | ||
| } | ||
| exports.parseCommits = parseCommits; | ||
| function joinCommit(subject, body) { | ||
| return [subject, body].filter(Boolean).join('\n'); | ||
| } | ||
| //# sourceMappingURL=parseCommits.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"parseCommits.js","sourceRoot":"","sources":["../../../../src/utils/git/parseCommits.ts"],"names":[],"mappings":";;;;;;AAAA,mCAAoC;AAEpC,8FAAqD;AAO9C,KAAK,UAAU,YAAY,CAChC,OAAiB;IAEjB,MAAM,OAAO,GAAG,IAAI,oBAAW,EAAE,CAAA;IACjC,MAAM,SAAS,GAA2B,EAAE,CAAA;IAE5C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;QAC5B,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAA;QAClC,MAAM,OAAO,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAExE,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;KAC/B;IAED,OAAO,CAAC,GAAG,EAAE,CAAA;IAEb,MAAM,YAAY,GAAG,IAAA,qCAAW,GAAE,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ACP,cAAc,EACd,8EAA8E,EAC9E,YAAY,CAAC,MAAM,CACpB,CAAA;QAED,MAAM,MAAM,GAAyB,MAAM,CAAC,MAAM,CAChD,EAAE,EACF,qBAAqB,EACrB;YACE,IAAI,EAAE,cAAc,CAAC,IAAI;YACzB,YAAY;SACb,CACF,CAAA;QACD,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC5B,CAAC,CAAC;SACD,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;IAE/D,OAAO,oBAAoB,CAAA;AAC7B,CAAC;AArED,oCAqEC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,IAA+B;IAClE,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACnD,CAAC"} |
+2
-2
| { | ||
| "name": "@ossjs/release", | ||
| "version": "0.7.3", | ||
| "version": "0.8.0", | ||
| "description": "Minimalistic, opinionated, and predictable release automation tool.", | ||
@@ -38,3 +38,3 @@ "main": "./bin/build/index.js", | ||
| "@types/yargs": "^17.0.10", | ||
| "conventional-commits-parser": "^3.2.4", | ||
| "conventional-commits-parser": "^5.0.0", | ||
| "get-stream": "^6.0.1", | ||
@@ -41,0 +41,0 @@ "git-log-parser": "^1.2.0", |
+0
-4
@@ -67,6 +67,2 @@ <p align="center"> | ||
| ## Limitations | ||
| - This tool does not support `!` (exclamation mark) as a commit message modifier indicating breaking changes. Please always include the `BREAKING CHANGE` indicator in the commit's body if you wish to indicate a breaking change. | ||
| ## Getting started | ||
@@ -73,0 +69,0 @@ |
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
136439
1.09%1636
1.24%411
-0.96%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed