Files
semantic-release/lib/verify.js
T
Olabode Lawal-Shittabey db8ffaad90 fix(revert): next (#4200)
* Revert "docs: update README to include information about the new core engine integration"

This reverts commit 4e476dee14.

* Revert "fix(code-quality): add missing comma in context object for consistency"

This reverts commit 493d6cdaa1.

* Revert "refactor: replace direct logger and env-ci replacements with a mockCore function for better test organization"

This reverts commit d05e160668.

* Revert "test: add tests for core delegation and dry-run policy handling"

This reverts commit 4f464a72ae.

* Revert "refactor: integrate `core`; remove unused imports and restructuring the main export function"

This reverts commit 3f5d1b785b.

* Revert "refactor: remove obsolete release type constants and notes separator"

This reverts commit 7d71f2eb14.

* Revert "refactor: remove obsolete test files for logger, git, sensitive data handling, and utility functions"

This reverts commit 1ae1a19cdf.

* Revert "refactor: remove obsolete Git-related utilities and logging functions"

This reverts commit bedddc4091.

* Revert "refactor(tests): remove obsolete tests for plugins and verification"

This reverts commit 7172195d12.

* Revert "refactor: remove obsolete branch, error, and plugin definitions"

This reverts commit 51d1f5f9b2.

* Merge branch 'master' of https://github.com/semantic-release/semantic-release into fix(revert)/next

* Revert "Merge branch 'master' of https://github.com/semantic-release/semantic-release into fix(revert)/next"

This reverts commit bbfdc36be6.
2026-06-09 16:08:49 -07:00

44 lines
1.4 KiB
JavaScript

import { isPlainObject, isString, template } from "lodash-es";
import AggregateError from "aggregate-error";
import { isGitRepo, verifyTagName } from "./git.js";
import getError from "./get-error.js";
export default async (context) => {
const {
cwd,
env,
options: { repositoryUrl, tagFormat, branches },
} = context;
const errors = [];
if (!(await isGitRepo({ cwd, env }))) {
errors.push(getError("ENOGITREPO", { cwd }));
} else if (!repositoryUrl) {
errors.push(getError("ENOREPOURL"));
}
// Verify that compiling the `tagFormat` produce a valid Git tag
if (!(await verifyTagName(template(tagFormat)({ version: "0.0.0" })))) {
errors.push(getError("EINVALIDTAGFORMAT", context));
}
// Verify the `tagFormat` contains the variable `version` by compiling the `tagFormat` template
// with a space as the `version` value and verify the result contains the space.
// The space is used as it's an invalid tag character, so it's guaranteed to no be present in the `tagFormat`.
if ((template(tagFormat)({ version: " " }).match(/ /g) || []).length !== 1) {
errors.push(getError("ETAGNOVERSION", context));
}
branches.forEach((branch) => {
if (
!((isString(branch) && branch.trim()) || (isPlainObject(branch) && isString(branch.name) && branch.name.trim()))
) {
errors.push(getError("EINVALIDBRANCH", { branch }));
}
});
if (errors.length > 0) {
throw new AggregateError(errors);
}
};