feat(esm): convert to esm (#2569)
for #2543 BREAKING CHANGE: semantic-release is now ESM-only. since it is used through its own executable, the impact on consuming projects should be minimal BREAKING CHANGE: references to plugin files in configs need to include the file extension because of executing in an ESM context
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
const {isString, remove, omit, mapValues, template} = require('lodash');
|
||||
const micromatch = require('micromatch');
|
||||
const {getBranches} = require('../git');
|
||||
import {isString, mapValues, omit, remove, template} from 'lodash-es';
|
||||
import micromatch from 'micromatch';
|
||||
import {getBranches} from '../git.js';
|
||||
|
||||
module.exports = async (repositoryUrl, {cwd}, branches) => {
|
||||
export default async (repositoryUrl, {cwd}, branches) => {
|
||||
const gitBranches = await getBranches(repositoryUrl, {cwd});
|
||||
|
||||
return branches.reduce(
|
||||
@@ -15,4 +15,4 @@ module.exports = async (repositoryUrl, {cwd}, branches) => {
|
||||
],
|
||||
[]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
const {template, escapeRegExp} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const pReduce = require('p-reduce');
|
||||
const debug = require('debug')('semantic-release:get-tags');
|
||||
const {getTags, getNote} = require('../../lib/git');
|
||||
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';
|
||||
|
||||
module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
|
||||
const debug = debugTags('semantic-release:get-tags');
|
||||
|
||||
|
||||
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,
|
||||
@@ -30,4 +33,4 @@ module.exports = async ({cwd, env, options: {tagFormat}}, branches) => {
|
||||
},
|
||||
[]
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
+11
-11
@@ -1,14 +1,14 @@
|
||||
const {isString, isRegExp} = require('lodash');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const pEachSeries = require('p-each-series');
|
||||
const DEFINITIONS = require('../definitions/branches');
|
||||
const getError = require('../get-error');
|
||||
const {fetch, fetchNotes, verifyBranchName} = require('../git');
|
||||
const expand = require('./expand');
|
||||
const getTags = require('./get-tags');
|
||||
const normalize = require('./normalize');
|
||||
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';
|
||||
|
||||
module.exports = async (repositoryUrl, ciBranch, context) => {
|
||||
export default async (repositoryUrl, ciBranch, context) => {
|
||||
const {cwd, env} = context;
|
||||
|
||||
const remoteBranches = await expand(
|
||||
@@ -68,4 +68,4 @@ module.exports = async (repositoryUrl, ciBranch, context) => {
|
||||
}
|
||||
|
||||
return [...result.maintenance, ...result.release, ...result.prerelease];
|
||||
};
|
||||
}
|
||||
|
||||
+15
-18
@@ -1,19 +1,18 @@
|
||||
const {sortBy, isNil} = require('lodash');
|
||||
const semverDiff = require('semver-diff');
|
||||
const {FIRST_RELEASE, RELEASE_TYPE} = require('../definitions/constants');
|
||||
const {
|
||||
tagsToVersions,
|
||||
isMajorRange,
|
||||
getUpperBound,
|
||||
getLowerBound,
|
||||
highest,
|
||||
lowest,
|
||||
getLatestVersion,
|
||||
import {isNil, sortBy} from 'lodash-es';
|
||||
import semverDiff from 'semver-diff';
|
||||
import {FIRST_RELEASE, RELEASE_TYPE} from '../definitions/constants.js';
|
||||
import {
|
||||
getFirstVersion,
|
||||
getRange,
|
||||
} = require('../utils');
|
||||
getLatestVersion,
|
||||
getLowerBound, getRange,
|
||||
getUpperBound,
|
||||
highest,
|
||||
isMajorRange,
|
||||
lowest,
|
||||
tagsToVersions
|
||||
} from '../utils.js';
|
||||
|
||||
function maintenance({maintenance, release}) {
|
||||
export function maintenance({maintenance, release}) {
|
||||
return sortBy(
|
||||
maintenance.map(({name, range, channel, ...rest}) => ({
|
||||
...rest,
|
||||
@@ -55,7 +54,7 @@ function maintenance({maintenance, release}) {
|
||||
});
|
||||
}
|
||||
|
||||
function release({release}) {
|
||||
export function release({release}) {
|
||||
if (release.length === 0) {
|
||||
return release;
|
||||
}
|
||||
@@ -89,7 +88,7 @@ function release({release}) {
|
||||
});
|
||||
}
|
||||
|
||||
function prerelease({prerelease}) {
|
||||
export function prerelease({prerelease}) {
|
||||
return prerelease.map(({name, prerelease, channel, tags, ...rest}) => {
|
||||
const preid = prerelease === true ? name : prerelease;
|
||||
return {
|
||||
@@ -102,5 +101,3 @@ function prerelease({prerelease}) {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {maintenance, release, prerelease};
|
||||
|
||||
Reference in New Issue
Block a user