Skip to content

Commit fd8fee4

Browse files
Breaking: Require @semantic-release/commit-analyzer between ^10 and ^13, Node.js >=20, convert to ESM to match commit-analyzer
1 parent 02b200b commit fd8fee4

File tree

13 files changed

+13551
-8990
lines changed

13 files changed

+13551
-8990
lines changed

.eslintrc.cjs

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@ version: 2
22
updates:
33
- package-ecosystem: "npm"
44
directory: "/"
5+
allow:
6+
- dependency-type: production
57
schedule:
6-
interval: "daily"
8+
interval: "weekly"
9+
versioning-strategy: widen
710
commit-message:
8-
prefix: "Upgrade(prod):"
11+
prefix: "Upgrade(npm):"
912
prefix-development: "Upgrade(dev):"
1013
reviewers:
1114
- "evelynhathaway"

.github/workflows/nodejs.yml

Lines changed: 25 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,37 @@ jobs:
88
env:
99
CI: true
1010
steps:
11-
- uses: actions/checkout@v2
12-
- name: Use Node.js 16.x
13-
uses: actions/setup-node@v2
14-
with:
15-
node-version: 16.x
11+
- uses: actions/checkout@v4
12+
- name: Use Node.js 22.x
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: 22.x
16+
cache: npm
1617

17-
# From: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
18-
- name: Cache node modules
19-
uses: actions/cache@v2
20-
env:
21-
cache-name: cache-node-modules
22-
with:
23-
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
24-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
25-
restore-keys: |
26-
${{ runner.os }}-build-${{ env.cache-name }}-
27-
${{ runner.os }}-build-
28-
${{ runner.os }}-
18+
- name: Install Dependencies
19+
run: npm ci
2920

30-
- name: Install Dependencies
31-
run: npm ci
32-
33-
- name: Lint
34-
run: npm run lint
21+
- name: Lint
22+
run: npm run lint
3523

3624
release:
3725
needs: testing
3826
runs-on: ubuntu-latest
3927
env:
4028
CI: true
4129
steps:
42-
- uses: actions/checkout@v2
43-
- name: Use Node.js 16.x
44-
uses: actions/setup-node@v2
45-
with:
46-
node-version: 16.x
47-
48-
# From: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#example-using-the-cache-action
49-
- name: Cache node modules
50-
uses: actions/cache@v2
51-
env:
52-
cache-name: cache-node-modules
53-
with:
54-
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
55-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
56-
restore-keys: |
57-
${{ runner.os }}-build-${{ env.cache-name }}-
58-
${{ runner.os }}-build-
59-
${{ runner.os }}-
60-
61-
- name: Install Dependencies
62-
run: npm ci
63-
64-
- name: Release
65-
run: npx semantic-release
66-
env:
67-
GH_TOKEN: ${{ secrets.GH_TOKEN }}
68-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
30+
- uses: actions/checkout@v4
31+
- name: Use Node.js 22.x
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version: 22.x
35+
cache: npm
36+
37+
- name: Install Dependencies
38+
run: npm ci
39+
40+
- name: Release
41+
run: npx semantic-release
42+
env:
43+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
44+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.husky/commit-msg

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
4-
npx --no-install commitlint --edit "$1"
1+
npx --no -- commitlint --edit "$1"

.husky/pre-commit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
4-
npx --no-install lint-staged
1+
npx --no lint-staged

.vscode/extensions.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"dbaeumer.vscode-eslint",
55
"davidanson.vscode-markdownlint",
66
"pflannery.vscode-versionlens",
7-
"wallabyjs.wallaby-vscode",
87
"redhat.vscode-yaml",
98
],
109
}

.vscode/settings.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
{
2-
"editor.formatOnSave": true,
2+
"editor.formatOnSave": false,
33
"eslint.format.enable": true,
44
"eslint.lintTask.enable": true,
5+
// Format using ESLint on save
6+
// - Source: https://eslint.style/guide/faq#how-to-auto-format-on-save
7+
"editor.codeActionsOnSave": {
8+
"source.fixAll.eslint": "explicit"
9+
},
10+
// Hide fixable style ESLint problems
11+
// - Source: https://eslint.style/guide/faq#the-error-messages-squiggly-lines-for-code-style-are-annoying
12+
"eslint.rules.customizations": [
13+
{
14+
"rule": "@stylistic/*",
15+
"fixable": true,
16+
"severity": "off"
17+
}
18+
],
519
"files.associations": {
620
".env": "shellscript",
721
".env.*": "shellscript",

README.md

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,43 @@ npm install --save-dev commit-analyzer-fail-on-no-release
2424

2525
## Usage
2626

27-
In your [**semantic-release** configuration file](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration), replace the default commit analyzer with `commit-analyzer-fail-on-no-release`. All configuration options pass through to the default plugin.
27+
In your [**semantic-release** configuration file](https://semantic-release.gitbook.io/semantic-release/usage/configuration#configuration-file), replace the default commit analyzer with `commit-analyzer-fail-on-no-release`. All configuration options pass through to the default plugin.
2828

29-
**`.releaserc`**
29+
**`release.config.mjs`**
3030

3131
```diff
32-
{
33-
"plugins": [
34-
[
35-
- "@semantic-release/commit-analyzer",
36-
+ "commit-analyzer-fail-on-no-release",
37-
{
38-
"preset": "angular",
39-
"releaseRules": [
40-
{"type": "docs", "scope":"README", "release": "patch"},
41-
{"type": "refactor", "release": "patch"},
42-
{"type": "style", "release": "patch"}
43-
],
44-
"parserOpts": {
45-
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
46-
}
47-
}
48-
]
49-
]
50-
}
32+
export default {
33+
plugins: [
34+
[
35+
- "@semantic-release/commit-analyzer",
36+
+ "commit-analyzer-fail-on-no-release",
37+
{
38+
"preset": "angular",
39+
"releaseRules": [
40+
{"type": "docs", "scope": "README", "release": "patch"},
41+
{"type": "refactor", "release": "patch"},
42+
{"type": "style", "release": "patch"},
43+
],
44+
"parserOpts": {
45+
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"],
46+
},
47+
},
48+
],
49+
],
50+
};
51+
```
52+
53+
## Development
54+
55+
### Testing
56+
57+
Make a either a no commit, a typed commit that will release, or one that won't and then see if the error was thrown if
58+
expected while running a dummy dry-run release.
59+
60+
```bash
61+
npm link
62+
npm link commit-analyzer-fail-on-no-release
63+
npm run test-release
5164
```
5265

5366
## License

eslint.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import eslintPluginEvelyn from "eslint-plugin-evelyn";
2+
3+
export default [
4+
...eslintPluginEvelyn.configs.base,
5+
...eslintPluginEvelyn.configs.node,
6+
...eslintPluginEvelyn.configs.esm,
7+
];

lib/index.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
// Proxy all methods on the commit analyzer exports
2-
module.exports = new Proxy(require("@semantic-release/commit-analyzer"), {
3-
get (target, property, receiver) {
4-
// If looking for the analyze commits plugin lifecycle method, return a proxy
5-
if (property === "analyzeCommits") {
6-
return new Proxy(target.analyzeCommits, {
7-
async apply (target, thisArgument, argumentsList) {
8-
// Await for the analysis from the proxy target to complete
9-
const result = await Reflect.apply(target, thisArgument, argumentsList);
10-
// It's gonna make a release
11-
if (result != null) return result;
12-
// Nullish means it's not making a release, let's throw a fit!
13-
throw new Error("There are no relevant changes and you are using commit-analyzer-fail-on-no-release.");
14-
},
15-
});
16-
}
17-
// Otherwise just return whatever it would've anyways
18-
return Reflect.get(target, property, receiver);
1+
// This file replaces an existing export by exporting twice
2+
/* eslint-disable import/export */
3+
import {analyzeCommits as originalAnalyzeCommits} from "@semantic-release/commit-analyzer";
4+
5+
// Re-export all the commit analyzer exports in case they add another export in the future
6+
export * from "@semantic-release/commit-analyzer";
7+
8+
// Proxy analyzeCommits so we can intercept the result and throw an error
9+
export const analyzeCommits = new Proxy(originalAnalyzeCommits, {
10+
async apply (target, thisArgument, argumentsList) {
11+
// Await for the analysis from the proxy target to complete
12+
const result = await Reflect.apply(target, thisArgument, argumentsList);
13+
// It's gonna make a release
14+
if (result != null) return result;
15+
// Nullish means it's not making a release, let's throw a fit!
16+
throw new Error("There are no relevant changes and you are using commit-analyzer-fail-on-no-release.");
1917
},
2018
});

0 commit comments

Comments
 (0)