semantic-release 26.0.0-beta.6 → 26.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,81 +0,0 @@
1
- import { dirname } from "node:path";
2
- import { fileURLToPath } from "node:url";
3
- import { castArray, isArray, isFunction, isNil, isPlainObject, isString } from "lodash-es";
4
- import resolveFrom from "resolve-from";
5
-
6
- const __dirname = dirname(fileURLToPath(import.meta.url));
7
-
8
- const validateSteps = (conf) => {
9
- return conf.every((conf) => {
10
- if (
11
- isArray(conf) &&
12
- (conf.length === 1 || conf.length === 2) &&
13
- (isString(conf[0]) || isFunction(conf[0])) &&
14
- (isNil(conf[1]) || isPlainObject(conf[1]))
15
- ) {
16
- return true;
17
- }
18
-
19
- conf = castArray(conf);
20
-
21
- if (conf.length !== 1) {
22
- return false;
23
- }
24
-
25
- const [name, config] = parseConfig(conf[0]);
26
- return (isString(name) || isFunction(name)) && isPlainObject(config);
27
- });
28
- };
29
-
30
- export function validatePlugin(conf) {
31
- return (
32
- isString(conf) ||
33
- (isArray(conf) &&
34
- (conf.length === 1 || conf.length === 2) &&
35
- (isString(conf[0]) || isPlainObject(conf[0])) &&
36
- (isNil(conf[1]) || isPlainObject(conf[1]))) ||
37
- (isPlainObject(conf) && (isNil(conf.path) || isString(conf.path) || isPlainObject(conf.path)))
38
- );
39
- }
40
-
41
- export function validateStep({ required }, conf) {
42
- conf = castArray(conf).filter(Boolean);
43
- if (required) {
44
- return conf.length >= 1 && validateSteps(conf);
45
- }
46
-
47
- return conf.length === 0 || validateSteps(conf);
48
- }
49
-
50
- export async function loadPlugin({ cwd }, name, pluginsPath) {
51
- const basePath = pluginsPath[name]
52
- ? dirname(resolveFrom.silent(__dirname, pluginsPath[name]) || resolveFrom(cwd, pluginsPath[name]))
53
- : __dirname;
54
-
55
- if (isFunction(name)) {
56
- return name;
57
- }
58
-
59
- const file = resolveFrom.silent(basePath, name) || resolveFrom(cwd, name);
60
- const { default: cjsExport, ...esmNamedExports } = await import(`file://${file}`);
61
-
62
- if (cjsExport) {
63
- return cjsExport;
64
- }
65
-
66
- return esmNamedExports;
67
- }
68
-
69
- export function parseConfig(plugin) {
70
- let path;
71
- let config;
72
- if (isArray(plugin)) {
73
- [path, config] = plugin;
74
- } else if (isPlainObject(plugin) && !isNil(plugin.path)) {
75
- ({ path, ...config } = plugin);
76
- } else {
77
- path = plugin;
78
- }
79
-
80
- return [path, config || {}];
81
- }
package/lib/utils.js DELETED
@@ -1,101 +0,0 @@
1
- import { template, union } from "lodash-es";
2
- import semver from "semver";
3
- import hideSensitive from "./hide-sensitive.js";
4
-
5
- export function extractErrors(err) {
6
- return err && err.errors ? [...err.errors] : [err];
7
- }
8
-
9
- export function hideSensitiveValues(env, objs) {
10
- const hideFunction = hideSensitive(env);
11
- return objs.map((object) => {
12
- Object.getOwnPropertyNames(object).forEach((prop) => {
13
- if (object[prop]) {
14
- object[prop] = hideFunction(object[prop]);
15
- }
16
- });
17
- return object;
18
- });
19
- }
20
-
21
- export function tagsToVersions(tags) {
22
- return tags.map(({ version }) => version);
23
- }
24
-
25
- export function isMajorRange(range) {
26
- return /^\d+\.x(?:\.x)?$/i.test(range);
27
- }
28
-
29
- export function isMaintenanceRange(range) {
30
- return /^\d+(?:\.(?:\d+|x))?\.x$/i.test(range);
31
- }
32
-
33
- export function getUpperBound(range) {
34
- const result = semver.valid(range)
35
- ? range
36
- : ((semver.validRange(range) || "").match(/<(?<upperBound>\d+\.\d+\.\d+(-\d+)?)$/) || [])[1];
37
-
38
- return result
39
- ? // https://github.com/npm/node-semver/issues/322
40
- result.replace(/-\d+$/, "")
41
- : result;
42
- }
43
-
44
- export function getLowerBound(range) {
45
- return ((semver.validRange(range) || "").match(/(?<lowerBound>\d+\.\d+\.\d+)/) || [])[1];
46
- }
47
-
48
- export function highest(version1, version2) {
49
- return version1 && version2 ? (semver.gt(version1, version2) ? version1 : version2) : version1 || version2;
50
- }
51
-
52
- export function lowest(version1, version2) {
53
- return version1 && version2 ? (semver.lt(version1, version2) ? version1 : version2) : version1 || version2;
54
- }
55
-
56
- export function getLatestVersion(versions, { withPrerelease } = {}) {
57
- return versions.filter((version) => withPrerelease || !semver.prerelease(version)).sort(semver.rcompare)[0];
58
- }
59
-
60
- export function getEarliestVersion(versions, { withPrerelease } = {}) {
61
- return versions.filter((version) => withPrerelease || !semver.prerelease(version)).sort(semver.compare)[0];
62
- }
63
-
64
- export function getFirstVersion(versions, lowerBranches) {
65
- const lowerVersion = union(...lowerBranches.map(({ tags }) => tagsToVersions(tags))).sort(semver.rcompare);
66
- if (lowerVersion[0]) {
67
- return versions.sort(semver.compare).find((version) => semver.gt(version, lowerVersion[0]));
68
- }
69
-
70
- return getEarliestVersion(versions);
71
- }
72
-
73
- export function getRange(min, max) {
74
- return `>=${min}${max ? ` <${max}` : ""}`;
75
- }
76
-
77
- export function makeTag(tagFormat, version) {
78
- return template(tagFormat, { evaluate: false, escape: false })({ version });
79
- }
80
-
81
- export function isSameChannel(channel, otherChannel) {
82
- return channel === otherChannel || (!channel && !otherChannel);
83
- }
84
-
85
- export function getVersionDiff(version1, version2) {
86
- if (semver.gte(version1, version2)) {
87
- return undefined;
88
- }
89
-
90
- return semver.diff(version1, version2);
91
- }
92
-
93
- export function extractGitLogTags(tagsString) {
94
- const regex = /tag: ([^,)]+)/g;
95
- let match;
96
- const tags = [];
97
- while ((match = regex.exec(tagsString)) !== null) {
98
- tags.push(match[1]);
99
- }
100
- return tags;
101
- }
package/lib/verify.js DELETED
@@ -1,47 +0,0 @@
1
- import { isPlainObject, isString, template } from "lodash-es";
2
- import AggregateError from "aggregate-error";
3
- import { isGitRepo, verifyTagName } from "./git.js";
4
- import getError from "./get-error.js";
5
-
6
- export default async (context) => {
7
- const {
8
- cwd,
9
- env,
10
- options: { repositoryUrl, tagFormat, branches },
11
- } = context;
12
- const errors = [];
13
-
14
- if (!(await isGitRepo({ cwd, env }))) {
15
- errors.push(getError("ENOGITREPO", { cwd }));
16
- } else if (!repositoryUrl) {
17
- errors.push(getError("ENOREPOURL"));
18
- } else if (repositoryUrl.startsWith("-")) {
19
- // A `repositoryUrl` beginning with `-` would be interpreted by `git` as a
20
- // command-line option rather than a URL, enabling argument injection.
21
- errors.push(getError("EINVALIDREPOURL", { repositoryUrl }));
22
- }
23
-
24
- // Verify that compiling the `tagFormat` produce a valid Git tag
25
- if (!(await verifyTagName(template(tagFormat, { evaluate: false, escape: false })({ version: "0.0.0" })))) {
26
- errors.push(getError("EINVALIDTAGFORMAT", context));
27
- }
28
-
29
- // Verify the `tagFormat` contains the variable `version` by compiling the `tagFormat` template
30
- // with a space as the `version` value and verify the result contains the space.
31
- // The space is used as it's an invalid tag character, so it's guaranteed to no be present in the `tagFormat`.
32
- if ((template(tagFormat, { evaluate: false, escape: false })({ version: " " }).match(/ /g) || []).length !== 1) {
33
- errors.push(getError("ETAGNOVERSION", context));
34
- }
35
-
36
- branches.forEach((branch) => {
37
- if (
38
- !((isString(branch) && branch.trim()) || (isPlainObject(branch) && isString(branch.name) && branch.name.trim()))
39
- ) {
40
- errors.push(getError("EINVALIDBRANCH", { branch }));
41
- }
42
- });
43
-
44
- if (errors.length > 0) {
45
- throw new AggregateError(errors);
46
- }
47
- };