Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: semantic-release/commit-analyzer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v11.0.0
Choose a base ref
...
head repository: semantic-release/commit-analyzer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v11.1.0
Choose a head ref
Loading
Showing with 554 additions and 819 deletions.
  1. +2 −2 .github/workflows/release.yml
  2. +4 −4 .github/workflows/test.yml
  3. +1 −1 .nvmrc
  4. +2 −2 index.js
  5. +6 −5 lib/load-parser-config.js
  6. +4 −4 lib/load-release-rules.js
  7. +502 −779 package-lock.json
  8. +4 −4 package.json
  9. +11 −0 test/load-parser-config.test.js
  10. +18 −18 test/load-release-rules.test.js
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -18,8 +18,8 @@ jobs:
name: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: lts/*
cache: npm
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -22,9 +22,9 @@ jobs:
- windows-latest
runs-on: "${{ matrix.os }}"
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: "Use Node.js ${{ matrix.node-version }}"
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: "${{ matrix.node-version }}"
cache: npm
@@ -35,8 +35,8 @@ jobs:
needs: test_matrix
if: always()
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
- uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d # v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-node@8f152de45cc393bb48ce5d89d36b731f54556e65 # v4
with:
node-version: "lts/*"
cache: npm
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18
20
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -23,11 +23,11 @@ const debug = debugFactory("semantic-release:commit-analyzer");
* @param {Array<Object>} context.commits The commits to analyze.
* @param {String} context.cwd The current working directory.
*
* @returns {String|null} the type of release to create based on the list of commits or `null` if no release has to be done.
* @returns {Promise<String|null>} the type of release to create based on the list of commits or `null` if no release has to be done.
*/
export async function analyzeCommits(pluginConfig, context) {
const { commits, logger } = context;
const releaseRules = loadReleaseRules(pluginConfig, context);
const releaseRules = await loadReleaseRules(pluginConfig, context);
const config = await loadParserConfig(pluginConfig, context);
let releaseType = null;

11 changes: 6 additions & 5 deletions lib/load-parser-config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import { isPlainObject } from "lodash-es";
import importFrom from "import-from";
import importFrom from "import-from-esm";
import conventionalChangelogAngular from "conventional-changelog-angular";

/**
@@ -14,6 +12,7 @@ import conventionalChangelogAngular from "conventional-changelog-angular";
* @param {Object} pluginConfig.parserOpts Additional `conventional-changelog-parser` options that will overwrite ones loaded by `preset` or `config`.
* @param {Object} context The semantic-release context.
* @param {String} context.cwd The current working directory.
*
* @return {Promise<Object>} a `Promise` that resolve to the `conventional-changelog-parser` options.
*/
export default async ({ preset, config, parserOpts, presetConfig }, { cwd }) => {
@@ -22,9 +21,11 @@ export default async ({ preset, config, parserOpts, presetConfig }, { cwd }) =>

if (preset) {
const presetPackage = `conventional-changelog-${preset.toLowerCase()}`;
loadedConfig = await (importFrom.silent(__dirname, presetPackage) || importFrom(cwd, presetPackage))(presetConfig);
loadedConfig = await (
(await importFrom.silent(__dirname, presetPackage)) || (await importFrom(cwd, presetPackage))
)(presetConfig);
} else if (config) {
loadedConfig = await (importFrom.silent(__dirname, config) || importFrom(cwd, config))();
loadedConfig = await ((await importFrom.silent(__dirname, config)) || (await importFrom(cwd, config)))();
} else {
loadedConfig = await conventionalChangelogAngular();
}
8 changes: 4 additions & 4 deletions lib/load-release-rules.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { isUndefined } from "lodash-es";
import importFrom from "import-from";
import importFrom from "import-from-esm";
import RELEASE_TYPES from "./default-release-types.js";

/**
@@ -15,16 +15,16 @@ import RELEASE_TYPES from "./default-release-types.js";
* @param {Object} context The semantic-release context.
* @param {String} context.cwd The current working directory.
*
* @return {Array} the loaded and validated `releaseRules`.
* @return {Promise<Array>} the loaded and validated `releaseRules`.
*/
export default ({ releaseRules }, { cwd }) => {
export default async ({ releaseRules }, { cwd }) => {
let loadedReleaseRules;
const __dirname = dirname(fileURLToPath(import.meta.url));

if (releaseRules) {
loadedReleaseRules =
typeof releaseRules === "string"
? importFrom.silent(__dirname, releaseRules) || importFrom(cwd, releaseRules)
? (await importFrom.silent(__dirname, releaseRules)) || (await importFrom(cwd, releaseRules))
: releaseRules;

if (!Array.isArray(loadedReleaseRules)) {
Loading