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
+18 -18
View File
@@ -1,13 +1,13 @@
import {castArray, identity, isNil, isPlainObject, isString, omit} from 'lodash-es';
import AggregateError from 'aggregate-error';
import getError from '../get-error.js';
import PLUGINS_DEFINITIONS from '../definitions/plugins.js';
import {loadPlugin, parseConfig, validatePlugin, validateStep} from './utils.js';
import pipeline from './pipeline.js';
import normalize from './normalize.js';
import { castArray, identity, isNil, isPlainObject, isString, omit } from "lodash-es";
import AggregateError from "aggregate-error";
import getError from "../get-error.js";
import PLUGINS_DEFINITIONS from "../definitions/plugins.js";
import { loadPlugin, parseConfig, validatePlugin, validateStep } from "./utils.js";
import pipeline from "./pipeline.js";
import normalize from "./normalize.js";
export default async (context, pluginsPath) => {
let {options, logger} = context;
let { options, logger } = context;
const errors = [];
const plugins = options.plugins
@@ -20,8 +20,8 @@ export default async (context, pluginsPath) => {
if (isPlainObject(plugin)) {
Object.entries(plugin).forEach(([type, func]) => {
if (PLUGINS_DEFINITIONS[type]) {
Reflect.defineProperty(func, 'pluginName', {
value: isPlainObject(name) ? 'Inline plugin' : name,
Reflect.defineProperty(func, "pluginName", {
value: isPlainObject(name) ? "Inline plugin" : name,
writable: false,
enumerable: true,
});
@@ -29,10 +29,10 @@ export default async (context, pluginsPath) => {
}
});
} else {
errors.push(getError('EPLUGINSCONF', {plugin}));
errors.push(getError("EPLUGINSCONF", { plugin }));
}
} else {
errors.push(getError('EPLUGINSCONF', {plugin}));
errors.push(getError("EPLUGINSCONF", { plugin }));
}
return pluginsList;
@@ -43,12 +43,12 @@ export default async (context, pluginsPath) => {
throw new AggregateError(errors);
}
options = {...plugins, ...options};
options = { ...plugins, ...options };
const pluginsConfig = await Object.entries(PLUGINS_DEFINITIONS).reduce(
async (
eventualPluginsConfigAccumulator,
[type, {required, default: def, pipelineConfig, postprocess = identity, preprocess = identity}]
[type, { required, default: def, pipelineConfig, postprocess = identity, preprocess = identity }]
) => {
let pluginOptions;
const pluginsConfigAccumulator = await eventualPluginsConfigAccumulator;
@@ -63,8 +63,8 @@ export default async (context, pluginsPath) => {
);
}
if (!validateStep({required}, options[type])) {
errors.push(getError('EPLUGINCONF', {type, required, pluginConf: options[type]}));
if (!validateStep({ required }, options[type])) {
errors.push(getError("EPLUGINCONF", { type, required, pluginConf: options[type] }));
return pluginsConfigAccumulator;
}
@@ -74,7 +74,7 @@ export default async (context, pluginsPath) => {
const steps = await Promise.all(
castArray(pluginOptions).map(async (pluginOpt) =>
normalize(
{...context, options: omit(options, Object.keys(PLUGINS_DEFINITIONS), 'plugins')},
{ ...context, options: omit(options, Object.keys(PLUGINS_DEFINITIONS), "plugins") },
type,
pluginOpt,
pluginsPath
@@ -100,4 +100,4 @@ export default async (context, pluginsPath) => {
}
return pluginsConfig;
}
};
+17 -17
View File
@@ -1,14 +1,14 @@
import {cloneDeep, isFunction, isPlainObject, noop, omit} from 'lodash-es';
import debugPlugins from 'debug';
import getError from '../get-error.js';
import {extractErrors} from '../utils.js';
import PLUGINS_DEFINITIONS from '../definitions/plugins.js';
import {loadPlugin, parseConfig} from './utils.js';
import { cloneDeep, isFunction, isPlainObject, noop, omit } from "lodash-es";
import debugPlugins from "debug";
import getError from "../get-error.js";
import { extractErrors } from "../utils.js";
import PLUGINS_DEFINITIONS from "../definitions/plugins.js";
import { loadPlugin, parseConfig } from "./utils.js";
const debug = debugPlugins('semantic-release:plugins');
const debug = debugPlugins("semantic-release:plugins");
export default async (context, type, pluginOpt, pluginsPath) => {
const {stdout, stderr, options, logger} = context;
const { stdout, stderr, options, logger } = context;
if (!pluginOpt) {
return noop;
}
@@ -21,26 +21,26 @@ export default async (context, type, pluginOpt, pluginsPath) => {
let func;
if (isFunction(plugin)) {
func = plugin.bind(null, cloneDeep({...options, ...config}));
func = plugin.bind(null, cloneDeep({ ...options, ...config }));
} else if (isPlainObject(plugin) && plugin[type] && isFunction(plugin[type])) {
func = plugin[type].bind(null, cloneDeep({...options, ...config}));
func = plugin[type].bind(null, cloneDeep({ ...options, ...config }));
} else {
throw getError('EPLUGIN', {type, pluginName});
throw getError("EPLUGIN", { type, pluginName });
}
const validator = async (input) => {
const {dryRun, outputValidator} = PLUGINS_DEFINITIONS[type] || {};
const { dryRun, outputValidator } = PLUGINS_DEFINITIONS[type] || {};
try {
if (!input.options.dryRun || dryRun) {
logger.log(`Start step "${type}" of plugin "${pluginName}"`);
const result = await func({
...cloneDeep(omit(input, ['stdout', 'stderr', 'logger'])),
...cloneDeep(omit(input, ["stdout", "stderr", "logger"])),
stdout,
stderr,
logger: logger.scope(logger.scopeName, pluginName),
});
if (outputValidator && !outputValidator(result)) {
throw getError(`E${type.toUpperCase()}OUTPUT`, {result, pluginName});
throw getError(`E${type.toUpperCase()}OUTPUT`, { result, pluginName });
}
logger.success(`Completed step "${type}" of plugin "${pluginName}"`);
@@ -50,12 +50,12 @@ export default async (context, type, pluginOpt, pluginsPath) => {
logger.warn(`Skip step "${type}" of plugin "${pluginName}" in dry-run mode`);
} catch (error) {
logger.error(`Failed step "${type}" of plugin "${pluginName}"`);
extractErrors(error).forEach((err) => Object.assign(err, {pluginName}));
extractErrors(error).forEach((err) => Object.assign(err, { pluginName }));
throw error;
}
};
Reflect.defineProperty(validator, 'pluginName', {value: pluginName, writable: false, enumerable: true});
Reflect.defineProperty(validator, "pluginName", { value: pluginName, writable: false, enumerable: true });
if (!isFunction(pluginOpt)) {
if (pluginsPath[name]) {
@@ -66,4 +66,4 @@ export default async (context, type, pluginOpt, pluginsPath) => {
}
return validator;
}
};
+33 -32
View File
@@ -1,7 +1,7 @@
import {identity} from 'lodash-es';
import pReduce from 'p-reduce';
import AggregateError from 'aggregate-error';
import {extractErrors} from '../utils.js';
import { identity } from "lodash-es";
import pReduce from "p-reduce";
import AggregateError from "aggregate-error";
import { extractErrors } from "../utils.js";
/**
* A Function that execute a list of function sequencially. If at least one Function ins the pipeline throws an Error or rejects, the pipeline function rejects as well.
@@ -25,34 +25,35 @@ import {extractErrors} from '../utils.js';
*
* @return {Pipeline} A Function that execute the `steps` sequentially
*/
export default (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async (input) => {
const results = [];
const errors = [];
await pReduce(
steps,
async (lastInput, step) => {
let result;
try {
// Call the step with the input computed at the end of the previous iteration and save intermediary result
result = await transform(await step(lastInput), step, lastInput);
results.push(result);
} catch (error) {
if (settleAll) {
errors.push(...extractErrors(error));
result = error;
} else {
throw error;
export default (steps, { settleAll = false, getNextInput = identity, transform = identity } = {}) =>
async (input) => {
const results = [];
const errors = [];
await pReduce(
steps,
async (lastInput, step) => {
let result;
try {
// Call the step with the input computed at the end of the previous iteration and save intermediary result
result = await transform(await step(lastInput), step, lastInput);
results.push(result);
} catch (error) {
if (settleAll) {
errors.push(...extractErrors(error));
result = error;
} else {
throw error;
}
}
}
// Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one
return getNextInput(lastInput, result);
},
input
);
if (errors.length > 0) {
throw new AggregateError(errors);
}
// Prepare input for the next step, passing the input of the last iteration (or initial parameter for the first iteration) and the result of the current one
return getNextInput(lastInput, result);
},
input
);
if (errors.length > 0) {
throw new AggregateError(errors);
}
return results;
}
return results;
};
+20 -9
View File
@@ -1,7 +1,7 @@
import {dirname} from 'node:path';
import {fileURLToPath} from 'node:url';
import {castArray, isArray, isFunction, isNil, isPlainObject, isString} from 'lodash-es';
import resolveFrom from 'resolve-from';
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { castArray, isArray, isFunction, isNil, isPlainObject, isString } from "lodash-es";
import resolveFrom from "resolve-from";
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -38,7 +38,7 @@ export function validatePlugin(conf) {
);
}
export function validateStep({required}, conf) {
export function validateStep({ required }, conf) {
conf = castArray(conf).filter(Boolean);
if (required) {
return conf.length >= 1 && validateSteps(conf);
@@ -47,14 +47,25 @@ export function validateStep({required}, conf) {
return conf.length === 0 || validateSteps(conf);
}
export async function loadPlugin({cwd}, name, pluginsPath) {
export async function loadPlugin({ cwd }, name, pluginsPath) {
const basePath = pluginsPath[name]
? dirname(resolveFrom.silent(__dirname, pluginsPath[name]) || resolveFrom(cwd, pluginsPath[name]))
: __dirname;
// See https://github.com/mysticatea/eslint-plugin-node/issues/250
// eslint-disable-next-line node/no-unsupported-features/es-syntax
return isFunction(name) ? name : (await import(resolveFrom.silent(basePath, name) || resolveFrom(cwd, name))).default;
if (isFunction(name)) {
return name;
}
const { default: cjsExport, ...esmNamedExports } = await import(
resolveFrom.silent(basePath, name) || resolveFrom(cwd, name)
);
if (cjsExport) {
return cjsExport;
}
return esmNamedExports;
}
export function parseConfig(plugin) {
@@ -63,7 +74,7 @@ export function parseConfig(plugin) {
if (isArray(plugin)) {
[path, config] = plugin;
} else if (isPlainObject(plugin) && !isNil(plugin.path)) {
({path, ...config} = plugin);
({ path, ...config } = plugin);
} else {
path = plugin;
}