fix(deps): bump @semantic-release/npm to ^10.0.0-beta.1 (#2670)

This commit is contained in:
Gregor Martynus
2023-01-14 14:14:04 -08:00
committed by GitHub
parent e607e234f3
commit 6a83cb53e5
39 changed files with 1686 additions and 1453 deletions
+7 -7
View File
@@ -1,18 +1,18 @@
import {isString, mapValues, omit, remove, template} from 'lodash-es';
import micromatch from 'micromatch';
import {getBranches} from '../git.js';
import { isString, mapValues, omit, remove, template } from "lodash-es";
import micromatch from "micromatch";
import { getBranches } from "../git.js";
export default async (repositoryUrl, {cwd}, branches) => {
const gitBranches = await getBranches(repositoryUrl, {cwd});
export default async (repositoryUrl, { cwd }, branches) => {
const gitBranches = await getBranches(repositoryUrl, { cwd });
return branches.reduce(
(branches, branch) => [
...branches,
...remove(gitBranches, (name) => micromatch(gitBranches, branch.name).includes(name)).map((name) => ({
name,
...mapValues(omit(branch, 'name'), (value) => (isString(value) ? template(value)({name}) : value)),
...mapValues(omit(branch, "name"), (value) => (isString(value) ? template(value)({ name }) : value)),
})),
],
[]
);
}
};
+13 -14
View File
@@ -1,36 +1,35 @@
import {escapeRegExp, template} from 'lodash-es';
import semver from 'semver';
import pReduce from 'p-reduce';
import debugTags from 'debug';
import {getNote, getTags} from '../../lib/git.js';
import { escapeRegExp, template } from "lodash-es";
import semver from "semver";
import pReduce from "p-reduce";
import debugTags from "debug";
import { getNote, getTags } from "../../lib/git.js";
const debug = debugTags('semantic-release:get-tags');
const debug = debugTags("semantic-release:get-tags");
export default async ({cwd, env, options: {tagFormat}}, branches) => {
export default async ({ cwd, env, options: { tagFormat } }, branches) => {
// Generate a regex to parse tags formatted with `tagFormat`
// by replacing the `version` variable in the template by `(.+)`.
// The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
// so it's guaranteed to no be present in the `tagFormat`.
const tagRegexp = `^${escapeRegExp(template(tagFormat)({version: ' '})).replace(' ', '(.+)')}`;
const tagRegexp = `^${escapeRegExp(template(tagFormat)({ version: " " })).replace(" ", "(.+)")}`;
return pReduce(
branches,
async (branches, branch) => {
const branchTags = await pReduce(
await getTags(branch.name, {cwd, env}),
await getTags(branch.name, { cwd, env }),
async (branchTags, tag) => {
const [, version] = tag.match(tagRegexp) || [];
return version && semver.valid(semver.clean(version))
? [...branchTags, {gitTag: tag, version, channels: (await getNote(tag, {cwd, env})).channels || [null]}]
? [...branchTags, { gitTag: tag, version, channels: (await getNote(tag, { cwd, env })).channels || [null] }]
: branchTags;
},
[]
);
debug('found tags for branch %s: %o', branch.name, branchTags);
return [...branches, {...branch, tags: branchTags}];
debug("found tags for branch %s: %o", branch.name, branchTags);
return [...branches, { ...branch, tags: branchTags }];
},
[]
);
}
};
+22 -22
View File
@@ -1,51 +1,51 @@
import {isRegExp, isString} from 'lodash-es';
import AggregateError from 'aggregate-error';
import pEachSeries from 'p-each-series';
import * as DEFINITIONS from '../definitions/branches.js';
import getError from '../get-error.js';
import {fetch, fetchNotes, verifyBranchName} from '../git.js';
import expand from './expand.js';
import getTags from './get-tags.js';
import * as normalize from './normalize.js';
import { isRegExp, isString } from "lodash-es";
import AggregateError from "aggregate-error";
import pEachSeries from "p-each-series";
import * as DEFINITIONS from "../definitions/branches.js";
import getError from "../get-error.js";
import { fetch, fetchNotes, verifyBranchName } from "../git.js";
import expand from "./expand.js";
import getTags from "./get-tags.js";
import * as normalize from "./normalize.js";
export default async (repositoryUrl, ciBranch, context) => {
const {cwd, env} = context;
const { cwd, env } = context;
const remoteBranches = await expand(
repositoryUrl,
context,
context.options.branches.map((branch) => (isString(branch) || isRegExp(branch) ? {name: branch} : branch))
context.options.branches.map((branch) => (isString(branch) || isRegExp(branch) ? { name: branch } : branch))
);
await pEachSeries(remoteBranches, async ({name}) => {
await fetch(repositoryUrl, name, ciBranch, {cwd, env});
await pEachSeries(remoteBranches, async ({ name }) => {
await fetch(repositoryUrl, name, ciBranch, { cwd, env });
});
await fetchNotes(repositoryUrl, {cwd, env});
await fetchNotes(repositoryUrl, { cwd, env });
const branches = await getTags(context, remoteBranches);
const errors = [];
const branchesByType = Object.entries(DEFINITIONS).reduce(
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
(branchesByType, [type, {filter}]) => ({[type]: branches.filter(filter), ...branchesByType}),
(branchesByType, [type, { filter }]) => ({ [type]: branches.filter(filter), ...branchesByType }),
{}
);
const result = Object.entries(DEFINITIONS).reduce((result, [type, {branchesValidator, branchValidator}]) => {
const result = Object.entries(DEFINITIONS).reduce((result, [type, { branchesValidator, branchValidator }]) => {
branchesByType[type].forEach((branch) => {
if (branchValidator && !branchValidator(branch)) {
errors.push(getError(`E${type.toUpperCase()}BRANCH`, {branch}));
errors.push(getError(`E${type.toUpperCase()}BRANCH`, { branch }));
}
});
const branchesOfType = normalize[type](branchesByType);
if (!branchesValidator(branchesOfType)) {
errors.push(getError(`E${type.toUpperCase()}BRANCHES`, {branches: branchesOfType}));
errors.push(getError(`E${type.toUpperCase()}BRANCHES`, { branches: branchesOfType }));
}
return {...result, [type]: branchesOfType};
return { ...result, [type]: branchesOfType };
}, {});
const duplicates = [...branches]
@@ -54,12 +54,12 @@ export default async (repositoryUrl, ciBranch, context) => {
.filter((_, idx, array) => array[idx] === array[idx + 1] && array[idx] !== array[idx - 1]);
if (duplicates.length > 0) {
errors.push(getError('EDUPLICATEBRANCHES', {duplicates}));
errors.push(getError("EDUPLICATEBRANCHES", { duplicates }));
}
await pEachSeries(branches, async (branch) => {
if (!(await verifyBranchName(branch.name))) {
errors.push(getError('EINVALIDBRANCHNAME', branch));
errors.push(getError("EINVALIDBRANCHNAME", branch));
}
});
@@ -68,4 +68,4 @@ export default async (repositoryUrl, ciBranch, context) => {
}
return [...result.maintenance, ...result.release, ...result.prerelease];
}
};
+18 -17
View File
@@ -1,27 +1,28 @@
import {isNil, sortBy} from 'lodash-es';
import semverDiff from 'semver-diff';
import {FIRST_RELEASE, RELEASE_TYPE} from '../definitions/constants.js';
import { isNil, sortBy } from "lodash-es";
import semverDiff from "semver-diff";
import { FIRST_RELEASE, RELEASE_TYPE } from "../definitions/constants.js";
import {
getFirstVersion,
getLatestVersion,
getLowerBound, getRange,
getLowerBound,
getRange,
getUpperBound,
highest,
isMajorRange,
lowest,
tagsToVersions
} from '../utils.js';
tagsToVersions,
} from "../utils.js";
export function maintenance({maintenance, release}) {
export function maintenance({ maintenance, release }) {
return sortBy(
maintenance.map(({name, range, channel, ...rest}) => ({
maintenance.map(({ name, range, channel, ...rest }) => ({
...rest,
name,
range: range || name,
channel: isNil(channel) ? name : channel,
})),
'range'
).map(({name, range, tags, ...rest}, idx, branches) => {
"range"
).map(({ name, range, tags, ...rest }, idx, branches) => {
const versions = tagsToVersions(tags);
// Find the lower bound based on Maintenance branches
const maintenanceMin =
@@ -44,7 +45,7 @@ export function maintenance({maintenance, release}) {
const diff = semverDiff(min, max);
return {
...rest,
type: 'maintenance',
type: "maintenance",
name,
tags,
range: getRange(min, max),
@@ -54,7 +55,7 @@ export function maintenance({maintenance, release}) {
});
}
export function release({release}) {
export function release({ release }) {
if (release.length === 0) {
return release;
}
@@ -62,7 +63,7 @@ export function release({release}) {
// The intial lastVersion is the last release from the base branch of `FIRST_RELEASE` (1.0.0)
let lastVersion = getLatestVersion(tagsToVersions(release[0].tags)) || FIRST_RELEASE;
return release.map(({name, tags, channel, ...rest}, idx) => {
return release.map(({ name, tags, channel, ...rest }, idx) => {
const versions = tagsToVersions(tags);
// The new lastVersion is the highest version between the current branch last release and the previous branch lastVersion
lastVersion = highest(getLatestVersion(versions), lastVersion);
@@ -79,7 +80,7 @@ export function release({release}) {
...rest,
channel: idx === 0 ? channel : isNil(channel) ? name : channel,
tags,
type: 'release',
type: "release",
name,
range: getRange(lastVersion, bound),
accept: bound ? RELEASE_TYPE.slice(0, RELEASE_TYPE.indexOf(diff)) : RELEASE_TYPE,
@@ -88,13 +89,13 @@ export function release({release}) {
});
}
export function prerelease({prerelease}) {
return prerelease.map(({name, prerelease, channel, tags, ...rest}) => {
export function prerelease({ prerelease }) {
return prerelease.map(({ name, prerelease, channel, tags, ...rest }) => {
const preid = prerelease === true ? name : prerelease;
return {
...rest,
channel: isNil(channel) ? name : channel,
type: 'prerelease',
type: "prerelease",
name,
prerelease: preid,
tags,