should-semantic-release
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -1,2 +0,2 @@ | ||
const tester = /^(?:chore(?:\(.*\))?:?)?\s*release|v?\d+\.\d+\.\d+/; | ||
const tester = /^(?:chore(?:\(.*\))?:?)?\s*release/; | ||
export function isReleaseCommit(message) { | ||
@@ -3,0 +3,0 @@ return tester.test(message); |
@@ -1,5 +0,3 @@ | ||
import conventionalCommitsParser from "conventional-commits-parser"; | ||
import { isReleaseCommit } from "./isReleaseCommit.js"; | ||
import { getCommitMeaning } from "./getCommitMeaning.js"; | ||
import { execOrThrow } from "./utils.js"; | ||
const ignoredTypes = new Set(["chore", "docs"]); | ||
export async function shouldSemanticRelease({ verbose, }) { | ||
@@ -15,14 +13,13 @@ const rawHistory = await execOrThrow(`git log --pretty=format:"%s"`); | ||
log(`Checking commit: ${message}`); | ||
// If we've hit a release commit, we know we don't need to release | ||
if (isReleaseCommit(message)) { | ||
log(`Found a release commit. Returning false.`); | ||
return false; | ||
const meaning = getCommitMeaning(message); | ||
switch (meaning) { | ||
case "release": | ||
log(`Found a release commit. Returning false.`); | ||
return false; | ||
case "meaningful": | ||
log(`Found a meaningful commit. Returning true.`); | ||
return true; | ||
default: | ||
log(`Found type ${meaning.type}. Continuing.`); | ||
} | ||
// Otherwise, we should release if a non-ignored commit type is found | ||
const { type } = conventionalCommitsParser.sync(message); | ||
if (type && !ignoredTypes.has(type)) { | ||
log(`Found a meaningful commit. Returning true.`); | ||
return true; | ||
} | ||
log(`Found type ${type}. Continuing.`); | ||
} | ||
@@ -29,0 +26,0 @@ // If we've seen every commit in the history and none match, don't release |
@@ -6,3 +6,3 @@ { | ||
"@pkgjs/parseargs": "^0.11.0", | ||
"conventional-commits-parser": "^3.2.4" | ||
"conventional-commits-parser": "^5.0.0" | ||
}, | ||
@@ -15,7 +15,7 @@ "description": "Checks whether a semantic release should be run for a commit.", | ||
"@typescript-eslint/parser": "^5.48.0", | ||
"@vitest/coverage-istanbul": "^0.29.0", | ||
"@vitest/coverage-istanbul": "^0.33.0", | ||
"cspell": "^6.18.1", | ||
"eslint": "^8.31.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-plugin-deprecation": "^1.3.3", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-deprecation": "^2.0.0", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
@@ -28,10 +28,10 @@ "eslint-plugin-jsonc": "^2.6.0", | ||
"eslint-plugin-typescript-sort-keys": "^2.1.0", | ||
"eslint-plugin-vitest": "^0.0.57", | ||
"eslint-plugin-vitest": "^0.2.0", | ||
"husky": "^8.0.3", | ||
"jsonc-eslint-parser": "^2.1.0", | ||
"lint-staged": "^13.1.0", | ||
"markdownlint": "^0.28.0", | ||
"markdownlint-cli": "^0.33.0", | ||
"markdownlint": "^0.31.0", | ||
"markdownlint-cli": "^0.35.0", | ||
"npm-package-json-lint": "^6.4.0", | ||
"npm-package-json-lint-config-default": "^5.0.0", | ||
"npm-package-json-lint-config-default": "^6.0.0", | ||
"pnpm-deduplicate": "^0.4.1", | ||
@@ -54,3 +54,3 @@ "prettier": "^2.8.2", | ||
"name": "should-semantic-release", | ||
"packageManager": "pnpm@7.30.5", | ||
"packageManager": "pnpm@7.33.6", | ||
"repository": { | ||
@@ -73,3 +73,3 @@ "type": "git", | ||
"type": "module", | ||
"version": "0.1.1" | ||
"version": "0.2.0" | ||
} |
@@ -9,3 +9,3 @@ <h1 align="center">Should Semantic Release</h1> | ||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> | ||
<img alt="All Contributors: 1" src="https://img.shields.io/badge/all_contributors-5-21bb42.svg" /> | ||
<img alt="All Contributors: 2" src="https://img.shields.io/badge/all_contributors-2-21bb42.svg" /> | ||
<!-- ALL-CONTRIBUTORS-BADGE:END --> | ||
@@ -32,4 +32,4 @@ <!-- prettier-ignore-end --> | ||
This CLI script determines whether a semantic release should occur for a package based on Git history. | ||
Specifically, it returns truthy only if a commit whose type _isn't_ `chore` or `docs` has come since the most recent release commit. | ||
This function determines whether a semantic release should occur for a package based on Git history. | ||
It returns true if a "meaningful" commit has come since the most recent release commit. | ||
@@ -58,2 +58,12 @@ ```shell | ||
### Commit Purposes | ||
Based on a commit's conventional commit message type: | ||
1. If the type is `feat` `fix`, or `perf`, it's considered "meaningful" | ||
2. If the type is `docs`, `refactor`, `style`, or `test`, it's ignored | ||
3. If the message looks like `v1.2.3`, `chore: release 1.2.3`, or similar, it's considered a "release" | ||
See [`getCommitMeaning`](./src/getCommitMeaning.ts) for the exact logic used. | ||
### Node API | ||
@@ -95,7 +105,4 @@ | ||
<tr> | ||
<td align="center"><a href="http://www.joshuakgoldberg.com"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg"/><br /><sub><b>Josh Goldberg</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/should-semantic-release/issues?q=author%3AJoshuaKGoldberg" title="Bug reports">🐛</a> <a href="https://github.com/JoshuaKGoldberg/should-semantic-release/commits?author=JoshuaKGoldberg" title="Code">💻</a> <a href="#content-JoshuaKGoldberg" title="Content">🖋</a> <a href="#example-JoshuaKGoldberg" title="Examples">💡</a> <a href="#ideas-JoshuaKGoldberg" title="Ideas, Planning, & Feedback">🤔</a> <a href="#infra-JoshuaKGoldberg" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="#maintenance-JoshuaKGoldberg" title="Maintenance">🚧</a> <a href="#platform-JoshuaKGoldberg" title="Packaging/porting to new platform">📦</a> <a href="#projectManagement-JoshuaKGoldberg" title="Project Management">📆</a> <a href="https://github.com/JoshuaKGoldberg/should-semantic-release/pulls?q=is%3Apr+reviewed-by%3AJoshuaKGoldberg" title="Reviewed Pull Requests">👀</a> <a href="#security-JoshuaKGoldberg" title="Security">🛡️</a> <a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a> <a href="https://github.com/JoshuaKGoldberg/should-semantic-release/commits?author=JoshuaKGoldberg" title="Tests">⚠️</a></td> | ||
<td align="center"><a href="https://sinchang.me"><img src="https://avatars.githubusercontent.com/u/3297859?v=4?s=100" width="100px;" alt="Jeff Wen"/><br /><sub><b>Jeff Wen</b></sub></a><br /><a href="#tool-sinchang" title="Tools">🔧</a></td> | ||
<td align="center"><a href="https://paulisaweso.me/"><img src="https://avatars.githubusercontent.com/u/6335792?v=4?s=100" width="100px;" alt="Paul Esch-Laurent"/><br /><sub><b>Paul Esch-Laurent</b></sub></a><br /><a href="#tool-Pinjasaur" title="Tools">🔧</a></td> | ||
<td align="center"><a href="https://github.com/NazCodeland"><img src="https://avatars.githubusercontent.com/u/113494366?v=4?s=100" width="100px;" alt="NazCodeland"/><br /><sub><b>NazCodeland</b></sub></a><br /><a href="#tool-NazCodeland" title="Tools">🔧</a></td> | ||
<td align="center"><a href="https://blog.johnnyreilly.com/"><img src="https://avatars.githubusercontent.com/u/1010525?v=4?s=100" width="100px;" alt="John Reilly"/><br /><sub><b>John Reilly</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/should-semantic-release/issues?q=author%3Ajohnnyreilly" title="Bug reports">🐛</a> <a href="#ideas-johnnyreilly" title="Ideas, Planning, & Feedback">🤔</a> <a href="#promotion-johnnyreilly" title="Promotion">📣</a> <a href="#maintenance-johnnyreilly" title="Maintenance">🚧</a> <a href="https://github.com/JoshuaKGoldberg/should-semantic-release/commits?author=johnnyreilly" title="Code">💻</a> <a href="https://github.com/JoshuaKGoldberg/should-semantic-release/pulls?q=is%3Apr+reviewed-by%3Ajohnnyreilly" title="Reviewed Pull Requests">👀</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="http://www.joshuakgoldberg.com"><img src="https://avatars.githubusercontent.com/u/3335181?v=4?s=100" width="100px;" alt="Josh Goldberg"/><br /><sub><b>Josh Goldberg</b></sub></a><br /><a href="#tool-JoshuaKGoldberg" title="Tools">🔧</a></td> | ||
<td align="center" valign="top" width="14.28%"><a href="https://medium.com/@cakeinpanic/latest"><img src="https://avatars.githubusercontent.com/u/588916?v=4?s=100" width="100px;" alt="Katya Pavlenko"/><br /><sub><b>Katya Pavlenko</b></sub></a><br /><a href="https://github.com/JoshuaKGoldberg/should-semantic-release/commits?author=cakeinpanic" title="Code">💻</a></td> | ||
</tr> | ||
@@ -102,0 +109,0 @@ </tbody> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33
104
119
17099
+ Addedconventional-commits-parser@5.0.0(transitive)
+ Addedis-text-path@2.0.0(transitive)
+ Addedmeow@12.1.1(transitive)
+ Addedsplit2@4.2.0(transitive)
+ Addedtext-extensions@2.4.0(transitive)
- Removed@babel/code-frame@7.26.2(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@types/minimist@1.2.5(transitive)
- Removed@types/normalize-package-data@2.4.4(transitive)
- Removedarrify@1.0.1(transitive)
- Removedcamelcase@5.3.1(transitive)
- Removedcamelcase-keys@6.2.2(transitive)
- Removedconventional-commits-parser@3.2.4(transitive)
- Removeddecamelize@1.2.0(transitive)
- Removeddecamelize-keys@1.1.1(transitive)
- Removederror-ex@1.3.2(transitive)
- Removedfind-up@4.1.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedhard-rejection@2.1.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedhosted-git-info@2.8.94.1.0(transitive)
- Removedindent-string@4.0.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-arrayish@0.2.1(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedis-text-path@1.0.1(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedjson-parse-even-better-errors@2.3.1(transitive)
- Removedkind-of@6.0.3(transitive)
- Removedlines-and-columns@1.2.4(transitive)
- Removedlocate-path@5.0.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlru-cache@6.0.0(transitive)
- Removedmap-obj@1.0.14.3.0(transitive)
- Removedmeow@8.1.2(transitive)
- Removedmin-indent@1.0.1(transitive)
- Removedminimist-options@4.1.0(transitive)
- Removednormalize-package-data@2.5.03.0.3(transitive)
- Removedp-limit@2.3.0(transitive)
- Removedp-locate@4.1.0(transitive)
- Removedp-try@2.2.0(transitive)
- Removedparse-json@5.2.0(transitive)
- Removedpath-exists@4.0.0(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedquick-lru@4.0.1(transitive)
- Removedread-pkg@5.2.0(transitive)
- Removedread-pkg-up@7.0.1(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedredent@3.0.0(transitive)
- Removedresolve@1.22.8(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsemver@5.7.27.6.3(transitive)
- Removedspdx-correct@3.2.0(transitive)
- Removedspdx-exceptions@2.5.0(transitive)
- Removedspdx-expression-parse@3.0.1(transitive)
- Removedspdx-license-ids@3.0.20(transitive)
- Removedsplit2@3.2.2(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedstrip-indent@3.0.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedtext-extensions@1.9.0(transitive)
- Removedthrough2@4.0.2(transitive)
- Removedtrim-newlines@3.0.1(transitive)
- Removedtype-fest@0.18.10.6.00.8.1(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removedvalidate-npm-package-license@3.0.4(transitive)
- Removedyallist@4.0.0(transitive)
- Removedyargs-parser@20.2.9(transitive)