semantic-release 25.0.9 → 26.0.0-alpha.1
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.
- package/README.md +14 -7
- package/index.js +33 -263
- package/lib/definitions/constants.js +11 -12
- package/package.json +14 -13
- package/lib/branches/expand.js +0 -20
- package/lib/branches/get-tags.js +0 -42
- package/lib/branches/index.js +0 -71
- package/lib/branches/normalize.js +0 -104
- package/lib/definitions/branches.js +0 -22
- package/lib/definitions/plugins.js +0 -108
- package/lib/get-commits.js +0 -31
- package/lib/get-config.js +0 -98
- package/lib/get-error.js +0 -7
- package/lib/get-git-auth-url.js +0 -126
- package/lib/get-last-release.js +0 -48
- package/lib/get-logger.js +0 -19
- package/lib/get-next-version.js +0 -35
- package/lib/get-release-to-add.js +0 -59
- package/lib/git.js +0 -387
- package/lib/plugins/index.js +0 -103
- package/lib/plugins/normalize.js +0 -69
- package/lib/plugins/pipeline.js +0 -59
- package/lib/plugins/utils.js +0 -81
- package/lib/utils.js +0 -101
- package/lib/verify.js +0 -47
package/README.md
CHANGED
|
@@ -27,6 +27,13 @@
|
|
|
27
27
|
|
|
28
28
|
This removes the immediate connection between human emotions and version numbers, strictly following the [Semantic Versioning](http://semver.org) specification and communicating the **impact** of changes to consumers.
|
|
29
29
|
|
|
30
|
+
## Core Engine
|
|
31
|
+
|
|
32
|
+
`semantic-release` now uses [`@semantic-release/core`](https://github.com/semantic-release/core) as its release engine.
|
|
33
|
+
For existing users, behavior stays the same: the `semantic-release` CLI, default plugin profile, and current configuration model remain backward compatible.
|
|
34
|
+
|
|
35
|
+
If you want to build a custom CLI or compose your own plugin stack directly, use `@semantic-release/core`.
|
|
36
|
+
|
|
30
37
|
> Trust us, this will change your workflow for the better. – [egghead.io](https://egghead.io/lessons/javascript-how-to-write-a-javascript-library-automating-releases-with-semantic-release)
|
|
31
38
|
|
|
32
39
|
## Highlights
|
|
@@ -57,11 +64,11 @@ Tools such as [commitizen](https://github.com/commitizen/cz-cli) or [commitlint]
|
|
|
57
64
|
|
|
58
65
|
The table below shows which commit message gets you which release type when `semantic-release` runs (using the default configuration):
|
|
59
66
|
|
|
60
|
-
| Commit message | Release type
|
|
61
|
-
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
62
|
-
| `fix(pencil): stop graphite breaking when too much pressure applied` | ~~Patch~~ Fix Release
|
|
63
|
-
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release
|
|
64
|
-
| `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release <br
|
|
67
|
+
| Commit message | Release type |
|
|
68
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
|
|
69
|
+
| `fix(pencil): stop graphite breaking when too much pressure applied` | ~~Patch~~ Fix Release |
|
|
70
|
+
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
|
|
71
|
+
| `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release <br><br> (Note that the `BREAKING CHANGE: ` token must be in the footer of the commit) |
|
|
65
72
|
|
|
66
73
|
### Automation with CI
|
|
67
74
|
|
|
@@ -147,10 +154,10 @@ In order to use **semantic-release** you need:
|
|
|
147
154
|
|
|
148
155
|
Let people know that your package is published using **semantic-release** and which [commit-convention](#commit-message-format) is followed by including this badge in your readme.
|
|
149
156
|
|
|
150
|
-
[](https://github.com/semantic-release/semantic-release)
|
|
151
158
|
|
|
152
159
|
```md
|
|
153
|
-
[](https://github.com/semantic-release/semantic-release)
|
|
154
161
|
```
|
|
155
162
|
|
|
156
163
|
## Team
|
package/index.js
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pick } from "lodash-es";
|
|
1
|
+
import semanticReleaseCore, { resolveConfig, getLogger, resolveEnvCi } from "@semantic-release/core";
|
|
3
2
|
import * as marked from "marked";
|
|
4
|
-
import
|
|
5
|
-
import { hookStd } from "hook-std";
|
|
6
|
-
import semver from "semver";
|
|
7
|
-
import AggregateError from "aggregate-error";
|
|
8
|
-
import hideSensitive from "./lib/hide-sensitive.js";
|
|
9
|
-
import getConfig from "./lib/get-config.js";
|
|
10
|
-
import verify from "./lib/verify.js";
|
|
11
|
-
import getNextVersion from "./lib/get-next-version.js";
|
|
12
|
-
import getCommits from "./lib/get-commits.js";
|
|
13
|
-
import getLastRelease from "./lib/get-last-release.js";
|
|
14
|
-
import getReleaseToAdd from "./lib/get-release-to-add.js";
|
|
15
|
-
import { extractErrors, makeTag } from "./lib/utils.js";
|
|
16
|
-
import getGitAuthUrl from "./lib/get-git-auth-url.js";
|
|
17
|
-
import getBranches from "./lib/branches/index.js";
|
|
18
|
-
import getLogger from "./lib/get-logger.js";
|
|
19
|
-
import { addNote, getGitHead, getTagHead, isBranchUpToDate, push, pushNotes, tag, verifyAuth } from "./lib/git.js";
|
|
20
|
-
import getError from "./lib/get-error.js";
|
|
21
|
-
import { COMMIT_EMAIL, COMMIT_NAME } from "./lib/definitions/constants.js";
|
|
3
|
+
import { SEMANTIC_RELEASE_DEFAULT_CONFIG } from "./lib/definitions/constants.js";
|
|
22
4
|
|
|
23
|
-
|
|
24
|
-
const pkg = require("./package.json");
|
|
5
|
+
import pkg from "./package.json" with { type: "json" };
|
|
25
6
|
|
|
26
7
|
let markedOptionsSet = false;
|
|
27
8
|
async function terminalOutput(text) {
|
|
@@ -34,257 +15,46 @@ async function terminalOutput(text) {
|
|
|
34
15
|
return marked.parse(text);
|
|
35
16
|
}
|
|
36
17
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
18
|
+
export default async (
|
|
19
|
+
cliOptions = {},
|
|
20
|
+
{ cwd = process.cwd(), env = process.env, stdout = process.stdout, stderr = process.stderr } = {}
|
|
21
|
+
) => {
|
|
22
|
+
const envCiResult = resolveEnvCi({ env, cwd });
|
|
23
|
+
const { isCi, branch, prBranch, isPr } = envCiResult;
|
|
41
24
|
const ciBranch = isPr ? prBranch : branch;
|
|
25
|
+
const noCi = Boolean(cliOptions.noCi || cliOptions.ci === false);
|
|
42
26
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} else {
|
|
47
|
-
// When running on CI, set the commits author and committer info and prevent the `git` CLI to prompt for username/password. See #703.
|
|
48
|
-
Object.assign(env, {
|
|
49
|
-
GIT_AUTHOR_NAME: COMMIT_NAME,
|
|
50
|
-
GIT_AUTHOR_EMAIL: COMMIT_EMAIL,
|
|
51
|
-
GIT_COMMITTER_NAME: COMMIT_NAME,
|
|
52
|
-
GIT_COMMITTER_EMAIL: COMMIT_EMAIL,
|
|
53
|
-
...env,
|
|
54
|
-
GIT_ASKPASS: "echo",
|
|
55
|
-
GIT_TERMINAL_PROMPT: 0,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (isCi && isPr && !options.noCi) {
|
|
60
|
-
logger.log("This run was triggered by a pull request and therefore a new version won't be published.");
|
|
61
|
-
return false;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// Verify config
|
|
65
|
-
await verify(context);
|
|
66
|
-
|
|
67
|
-
options.repositoryUrl = await getGitAuthUrl({ ...context, branch: { name: ciBranch } });
|
|
68
|
-
context.branches = await getBranches(options.repositoryUrl, ciBranch, context);
|
|
69
|
-
context.branch = context.branches.find(({ name }) => name === ciBranch);
|
|
70
|
-
|
|
71
|
-
if (!context.branch) {
|
|
72
|
-
logger.log(
|
|
73
|
-
`This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${context.branches
|
|
74
|
-
.map(({ name }) => name)
|
|
75
|
-
.join(", ")}, therefore a new version won’t be published.`
|
|
76
|
-
);
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
logger[options.dryRun ? "warn" : "success"](
|
|
81
|
-
`Run automated release from branch ${ciBranch} on repository ${options.originalRepositoryURL}${
|
|
82
|
-
options.dryRun ? " in dry-run mode" : ""
|
|
83
|
-
}`
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
try {
|
|
88
|
-
await verifyAuth(options.repositoryUrl, context.branch.name, { cwd, env });
|
|
89
|
-
} catch (error) {
|
|
90
|
-
if (!(await isBranchUpToDate(options.repositoryUrl, context.branch.name, { cwd, env }))) {
|
|
91
|
-
logger.log(
|
|
92
|
-
`The local branch ${context.branch.name} is behind the remote one, therefore a new version won't be published.`
|
|
93
|
-
);
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
throw error;
|
|
98
|
-
}
|
|
99
|
-
} catch (error) {
|
|
100
|
-
logger.error(`The command "${error.command}" failed with the error message ${error.stderr}.`);
|
|
101
|
-
throw getError("EGITNOPERMISSION", context);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
logger.success(`Allowed to push to the Git repository`);
|
|
105
|
-
|
|
106
|
-
await plugins.verifyConditions(context);
|
|
107
|
-
|
|
108
|
-
const errors = [];
|
|
109
|
-
context.releases = [];
|
|
110
|
-
const releaseToAdd = getReleaseToAdd(context);
|
|
111
|
-
|
|
112
|
-
if (releaseToAdd) {
|
|
113
|
-
const { lastRelease, currentRelease, nextRelease } = releaseToAdd;
|
|
114
|
-
|
|
115
|
-
nextRelease.gitHead = await getTagHead(nextRelease.gitHead, { cwd, env });
|
|
116
|
-
currentRelease.gitHead = await getTagHead(currentRelease.gitHead, { cwd, env });
|
|
117
|
-
if (context.branch.mergeRange && !semver.satisfies(nextRelease.version, context.branch.mergeRange)) {
|
|
118
|
-
errors.push(getError("EINVALIDMAINTENANCEMERGE", { ...context, nextRelease }));
|
|
119
|
-
} else {
|
|
120
|
-
const commits = await getCommits({ ...context, lastRelease, nextRelease });
|
|
121
|
-
nextRelease.notes = await plugins.generateNotes({ ...context, commits, lastRelease, nextRelease });
|
|
122
|
-
|
|
123
|
-
if (options.dryRun) {
|
|
124
|
-
logger.warn(`Skip ${nextRelease.gitTag} tag creation in dry-run mode`);
|
|
125
|
-
} else {
|
|
126
|
-
await addNote({ channels: [...currentRelease.channels, nextRelease.channel] }, nextRelease.gitTag, {
|
|
127
|
-
cwd,
|
|
128
|
-
env,
|
|
129
|
-
});
|
|
130
|
-
await push(options.repositoryUrl, { cwd, env });
|
|
131
|
-
await pushNotes(options.repositoryUrl, nextRelease.gitTag, {
|
|
132
|
-
cwd,
|
|
133
|
-
env,
|
|
134
|
-
});
|
|
135
|
-
logger.success(
|
|
136
|
-
`Add ${nextRelease.channel ? `channel ${nextRelease.channel}` : "default channel"} to tag ${
|
|
137
|
-
nextRelease.gitTag
|
|
138
|
-
}`
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
context.branch.tags.push({
|
|
143
|
-
version: nextRelease.version,
|
|
144
|
-
channel: nextRelease.channel,
|
|
145
|
-
gitTag: nextRelease.gitTag,
|
|
146
|
-
gitHead: nextRelease.gitHead,
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
const releases = await plugins.addChannel({ ...context, commits, lastRelease, currentRelease, nextRelease });
|
|
150
|
-
context.releases.push(...releases);
|
|
151
|
-
await plugins.success({ ...context, lastRelease, commits, nextRelease, releases });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (errors.length > 0) {
|
|
156
|
-
throw new AggregateError(errors);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
context.lastRelease = getLastRelease(context);
|
|
160
|
-
if (context.lastRelease.gitHead) {
|
|
161
|
-
context.lastRelease.gitHead = await getTagHead(context.lastRelease.gitHead, { cwd, env });
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if (context.lastRelease.gitTag) {
|
|
165
|
-
logger.log(
|
|
166
|
-
`Found git tag ${context.lastRelease.gitTag} associated with version ${context.lastRelease.version} on branch ${context.branch.name}`
|
|
167
|
-
);
|
|
168
|
-
} else {
|
|
169
|
-
logger.log(`No git tag version found on branch ${context.branch.name}`);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
context.commits = await getCommits(context);
|
|
27
|
+
const shouldAutoDryRun = !isCi && !cliOptions.dryRun && !noCi;
|
|
28
|
+
const effectiveCliOptions = shouldAutoDryRun ? { ...cliOptions, dryRun: true } : cliOptions;
|
|
29
|
+
const shouldSkipRelease = isCi && isPr && !noCi;
|
|
173
30
|
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
31
|
+
const context = {
|
|
32
|
+
cwd,
|
|
33
|
+
env,
|
|
34
|
+
stdout,
|
|
35
|
+
stderr,
|
|
36
|
+
envCi: envCiResult,
|
|
178
37
|
};
|
|
179
|
-
if (!nextRelease.type) {
|
|
180
|
-
logger.log("There are no relevant changes, so no new version is released.");
|
|
181
|
-
return context.releases.length > 0 ? { releases: context.releases } : false;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
context.nextRelease = nextRelease;
|
|
185
|
-
nextRelease.version = getNextVersion(context);
|
|
186
|
-
nextRelease.gitTag = makeTag(options.tagFormat, nextRelease.version);
|
|
187
|
-
nextRelease.name = nextRelease.gitTag;
|
|
188
|
-
|
|
189
|
-
if (context.branch.type !== "prerelease" && !semver.satisfies(nextRelease.version, context.branch.range)) {
|
|
190
|
-
throw getError("EINVALIDNEXTVERSION", {
|
|
191
|
-
...context,
|
|
192
|
-
validBranches: context.branches.filter(
|
|
193
|
-
({ type, accept }) => type !== "prerelease" && accept.includes(nextRelease.type)
|
|
194
|
-
),
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
38
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
nextRelease.notes = await plugins.generateNotes(context);
|
|
201
|
-
|
|
202
|
-
await plugins.prepare(context);
|
|
39
|
+
context.logger = getLogger(context);
|
|
203
40
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
// Create the tag before calling the publish plugins as some require the tag to exists
|
|
208
|
-
await tag(nextRelease.gitTag, nextRelease.gitHead, { cwd, env });
|
|
209
|
-
await addNote({ channels: [nextRelease.channel] }, nextRelease.gitTag, { cwd, env });
|
|
210
|
-
await push(options.repositoryUrl, { cwd, env });
|
|
211
|
-
await pushNotes(options.repositoryUrl, nextRelease.gitTag, { cwd, env });
|
|
212
|
-
logger.success(`Created tag ${nextRelease.gitTag}`);
|
|
41
|
+
context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
|
|
42
|
+
if (shouldAutoDryRun) {
|
|
43
|
+
context.logger.warn("This run was not triggered in a known CI environment, running in dry-run mode.");
|
|
213
44
|
}
|
|
214
45
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
await plugins.success({ ...context, releases });
|
|
219
|
-
|
|
220
|
-
logger.success(
|
|
221
|
-
`Published release ${nextRelease.version} on ${nextRelease.channel ? nextRelease.channel : "default"} channel`
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
if (options.dryRun) {
|
|
225
|
-
logger.log(`Release note for version ${nextRelease.version}:`);
|
|
226
|
-
if (nextRelease.notes) {
|
|
227
|
-
context.stdout.write(await terminalOutput(nextRelease.notes));
|
|
228
|
-
}
|
|
46
|
+
if (shouldSkipRelease) {
|
|
47
|
+
context.logger.log("This run was triggered by a pull request and therefore a new version won't be published.");
|
|
48
|
+
return false;
|
|
229
49
|
}
|
|
230
50
|
|
|
231
|
-
|
|
232
|
-
|
|
51
|
+
const { options: resolvedOptions, plugins } = await resolveConfig(context, effectiveCliOptions, {
|
|
52
|
+
baseConfig: SEMANTIC_RELEASE_DEFAULT_CONFIG,
|
|
53
|
+
buildPlugins: true,
|
|
54
|
+
});
|
|
55
|
+
context.options = resolvedOptions;
|
|
233
56
|
|
|
234
|
-
|
|
235
|
-
const errors = extractErrors(err).sort((error) => (error.semanticRelease ? -1 : 0));
|
|
236
|
-
for (const error of errors) {
|
|
237
|
-
if (error.semanticRelease) {
|
|
238
|
-
logger.error(`${error.code} ${error.message}`);
|
|
239
|
-
if (error.details) {
|
|
240
|
-
stderr.write(await terminalOutput(error.details)); // eslint-disable-line no-await-in-loop
|
|
241
|
-
}
|
|
242
|
-
} else {
|
|
243
|
-
logger.error("An error occurred while running semantic-release: %O", error);
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
async function callFail(context, plugins, err) {
|
|
249
|
-
const errors = extractErrors(err).filter((err) => err.semanticRelease);
|
|
250
|
-
if (errors.length > 0) {
|
|
251
|
-
try {
|
|
252
|
-
await plugins.fail({ ...context, errors });
|
|
253
|
-
} catch (error) {
|
|
254
|
-
await logErrors(context, error);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
57
|
+
const result = await semanticReleaseCore({ context, plugins, formatOutput: terminalOutput });
|
|
258
58
|
|
|
259
|
-
|
|
260
|
-
const { unhook } = hookStd(
|
|
261
|
-
{ silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean) },
|
|
262
|
-
hideSensitive(env)
|
|
263
|
-
);
|
|
264
|
-
const context = {
|
|
265
|
-
cwd,
|
|
266
|
-
env,
|
|
267
|
-
stdout: stdout || process.stdout,
|
|
268
|
-
stderr: stderr || process.stderr,
|
|
269
|
-
envCi: envCi({ env, cwd }),
|
|
270
|
-
};
|
|
271
|
-
context.logger = getLogger(context);
|
|
272
|
-
context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
|
|
273
|
-
try {
|
|
274
|
-
const { plugins, options } = await getConfig(context, cliOptions);
|
|
275
|
-
options.originalRepositoryURL = options.repositoryUrl;
|
|
276
|
-
context.options = options;
|
|
277
|
-
try {
|
|
278
|
-
const result = await run(context, plugins);
|
|
279
|
-
unhook();
|
|
280
|
-
return result;
|
|
281
|
-
} catch (error) {
|
|
282
|
-
await callFail(context, plugins, error);
|
|
283
|
-
throw error;
|
|
284
|
-
}
|
|
285
|
-
} catch (error) {
|
|
286
|
-
await logErrors(context, error);
|
|
287
|
-
unhook();
|
|
288
|
-
throw error;
|
|
289
|
-
}
|
|
59
|
+
return result;
|
|
290
60
|
};
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
export const RELEASE_TYPE = ["patch", "minor", "major"];
|
|
2
|
-
|
|
3
|
-
export const FIRST_RELEASE = "1.0.0";
|
|
4
|
-
|
|
5
|
-
export const FIRSTPRERELEASE = "1";
|
|
6
|
-
|
|
7
|
-
export const COMMIT_NAME = "semantic-release-bot";
|
|
8
|
-
|
|
9
|
-
export const COMMIT_EMAIL = "semantic-release-bot@martynus.net";
|
|
10
|
-
|
|
11
|
-
export const RELEASE_NOTES_SEPARATOR = "\n\n";
|
|
12
|
-
|
|
13
1
|
export const SECRET_REPLACEMENT = "[secure]";
|
|
14
2
|
|
|
15
3
|
export const SECRET_MIN_SIZE = 5;
|
|
16
4
|
|
|
17
5
|
export const GIT_NOTE_REF = "semantic-release";
|
|
6
|
+
|
|
7
|
+
export const RELEASE_TYPE = ["patch", "minor", "major"];
|
|
8
|
+
|
|
9
|
+
export const SEMANTIC_RELEASE_DEFAULT_CONFIG = {
|
|
10
|
+
plugins: [
|
|
11
|
+
"@semantic-release/commit-analyzer",
|
|
12
|
+
"@semantic-release/release-notes-generator",
|
|
13
|
+
"@semantic-release/npm",
|
|
14
|
+
"@semantic-release/github",
|
|
15
|
+
],
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "semantic-release",
|
|
3
3
|
"description": "Automated semver compliant package publishing",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "26.0.0-alpha.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
|
7
7
|
"ava": {
|
|
@@ -27,11 +27,12 @@
|
|
|
27
27
|
"Matt Travi <npm@travi.org> (https://matt.travi.org/)"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@semantic-release/commit-analyzer": "^
|
|
30
|
+
"@semantic-release/commit-analyzer": "^14.0.0-beta.4",
|
|
31
|
+
"@semantic-release/core": "^1.0.0-beta.7",
|
|
31
32
|
"@semantic-release/error": "^4.0.0",
|
|
32
33
|
"@semantic-release/github": "^12.0.0",
|
|
33
|
-
"@semantic-release/npm": "^
|
|
34
|
-
"@semantic-release/release-notes-generator": "^
|
|
34
|
+
"@semantic-release/npm": "^14.0.0-beta.2",
|
|
35
|
+
"@semantic-release/release-notes-generator": "^15.0.0-beta.3",
|
|
35
36
|
"aggregate-error": "^5.0.0",
|
|
36
37
|
"cosmiconfig": "^9.0.0",
|
|
37
38
|
"debug": "^4.0.0",
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"yargs": "^18.0.0"
|
|
58
59
|
},
|
|
59
60
|
"devDependencies": {
|
|
60
|
-
"@types/node": "24.13.
|
|
61
|
+
"@types/node": "24.13.4",
|
|
61
62
|
"@types/signale": "1.4.7",
|
|
62
63
|
"ava": "8.0.1",
|
|
63
64
|
"c8": "12.0.0",
|
|
@@ -65,24 +66,24 @@
|
|
|
65
66
|
"cz-conventional-changelog": "3.3.0",
|
|
66
67
|
"file-url": "4.0.0",
|
|
67
68
|
"fs-extra": "11.4.0",
|
|
68
|
-
"got": "
|
|
69
|
-
"js-yaml": "4.3.
|
|
70
|
-
"lockfile-lint": "5.0.
|
|
69
|
+
"got": "16.0.0",
|
|
70
|
+
"js-yaml": "4.3.2",
|
|
71
|
+
"lockfile-lint": "5.0.1",
|
|
71
72
|
"ls-engines": "0.10.1",
|
|
72
|
-
"mockserver-client": "7.
|
|
73
|
+
"mockserver-client": "7.6.0",
|
|
73
74
|
"nock": "14.0.17",
|
|
74
75
|
"npm-run-all2": "9.0.3",
|
|
75
|
-
"p-retry": "8.0.
|
|
76
|
+
"p-retry": "8.0.1",
|
|
76
77
|
"prettier": "3.8.5",
|
|
77
|
-
"publint": "0.3.
|
|
78
|
+
"publint": "0.3.24",
|
|
78
79
|
"sinon": "22.1.0",
|
|
79
80
|
"stream-buffers": "3.0.3",
|
|
80
81
|
"tempy": "3.2.0",
|
|
81
|
-
"testcontainers": "12.0
|
|
82
|
+
"testcontainers": "12.1.0",
|
|
82
83
|
"testdouble": "3.20.2"
|
|
83
84
|
},
|
|
84
85
|
"engines": {
|
|
85
|
-
"node": "
|
|
86
|
+
"node": ">=26.13"
|
|
86
87
|
},
|
|
87
88
|
"files": [
|
|
88
89
|
"bin",
|
package/lib/branches/expand.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isString, mapValues, omit, remove, template } from "lodash-es";
|
|
2
|
-
import micromatch from "micromatch";
|
|
3
|
-
import { getBranches } from "../git.js";
|
|
4
|
-
|
|
5
|
-
export default async (repositoryUrl, { cwd }, branches) => {
|
|
6
|
-
const gitBranches = await getBranches(repositoryUrl, { cwd });
|
|
7
|
-
|
|
8
|
-
return branches.reduce(
|
|
9
|
-
(branches, branch) => [
|
|
10
|
-
...branches,
|
|
11
|
-
...remove(gitBranches, (name) => micromatch(gitBranches, branch.name).includes(name)).map((name) => ({
|
|
12
|
-
name,
|
|
13
|
-
...mapValues(omit(branch, "name"), (value) =>
|
|
14
|
-
isString(value) ? template(value, { evaluate: false, escape: false })({ name }) : value
|
|
15
|
-
),
|
|
16
|
-
})),
|
|
17
|
-
],
|
|
18
|
-
[]
|
|
19
|
-
);
|
|
20
|
-
};
|
package/lib/branches/get-tags.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { escapeRegExp, template } from "lodash-es";
|
|
2
|
-
import semver from "semver";
|
|
3
|
-
import pReduce from "p-reduce";
|
|
4
|
-
import debugTags from "debug";
|
|
5
|
-
import { getTags, getTagsNotes } from "../../lib/git.js";
|
|
6
|
-
|
|
7
|
-
const debug = debugTags("semantic-release:get-tags");
|
|
8
|
-
|
|
9
|
-
export default async ({ cwd, env, options: { tagFormat } }, branches) => {
|
|
10
|
-
// Generate a regex to parse tags formatted with `tagFormat`
|
|
11
|
-
// by replacing the `version` variable in the template by `(.+)`.
|
|
12
|
-
// The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
|
|
13
|
-
// so it's guaranteed to no be present in the `tagFormat`.
|
|
14
|
-
const tagRegexp = `^${escapeRegExp(template(tagFormat, { evaluate: false, escape: false })({ version: " " })).replace(
|
|
15
|
-
" ",
|
|
16
|
-
"(.+)"
|
|
17
|
-
)}`;
|
|
18
|
-
|
|
19
|
-
// Get the tags notes for all the tags in the repository
|
|
20
|
-
const tagsNotesMap = await getTagsNotes({ cwd, env });
|
|
21
|
-
|
|
22
|
-
return pReduce(
|
|
23
|
-
branches,
|
|
24
|
-
async (branches, branch) => {
|
|
25
|
-
const branchTags = await pReduce(
|
|
26
|
-
await getTags(branch.name, { cwd, env }),
|
|
27
|
-
async (branchTags, tag) => {
|
|
28
|
-
const [, version] = tag.match(tagRegexp) || [];
|
|
29
|
-
const channels = tagsNotesMap.has(tag) ? tagsNotesMap.get(tag).channels : [null];
|
|
30
|
-
return version && semver.valid(semver.clean(version))
|
|
31
|
-
? [...branchTags, { gitTag: tag, version, channels }]
|
|
32
|
-
: branchTags;
|
|
33
|
-
},
|
|
34
|
-
[]
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
debug("found tags for branch %s: %o", branch.name, branchTags);
|
|
38
|
-
return [...branches, { ...branch, tags: branchTags }];
|
|
39
|
-
},
|
|
40
|
-
[]
|
|
41
|
-
);
|
|
42
|
-
};
|
package/lib/branches/index.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { isRegExp, isString } from "lodash-es";
|
|
2
|
-
import AggregateError from "aggregate-error";
|
|
3
|
-
import pEachSeries from "p-each-series";
|
|
4
|
-
import * as DEFINITIONS from "../definitions/branches.js";
|
|
5
|
-
import getError from "../get-error.js";
|
|
6
|
-
import { fetch, fetchNotes, verifyBranchName } from "../git.js";
|
|
7
|
-
import expand from "./expand.js";
|
|
8
|
-
import getTags from "./get-tags.js";
|
|
9
|
-
import * as normalize from "./normalize.js";
|
|
10
|
-
|
|
11
|
-
export default async (repositoryUrl, ciBranch, context) => {
|
|
12
|
-
const { cwd, env } = context;
|
|
13
|
-
|
|
14
|
-
const remoteBranches = await expand(
|
|
15
|
-
repositoryUrl,
|
|
16
|
-
context,
|
|
17
|
-
context.options.branches.map((branch) => (isString(branch) || isRegExp(branch) ? { name: branch } : branch))
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
await pEachSeries(remoteBranches, async ({ name }) => {
|
|
21
|
-
await fetch(repositoryUrl, name, ciBranch, { cwd, env });
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
await fetchNotes(repositoryUrl, { cwd, env });
|
|
25
|
-
|
|
26
|
-
const branches = await getTags(context, remoteBranches);
|
|
27
|
-
|
|
28
|
-
const errors = [];
|
|
29
|
-
const branchesByType = Object.entries(DEFINITIONS).reduce(
|
|
30
|
-
// eslint-disable-next-line unicorn/no-fn-reference-in-iterator
|
|
31
|
-
(branchesByType, [type, { filter }]) => ({ [type]: branches.filter(filter), ...branchesByType }),
|
|
32
|
-
{}
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const result = Object.entries(DEFINITIONS).reduce((result, [type, { branchesValidator, branchValidator }]) => {
|
|
36
|
-
branchesByType[type].forEach((branch) => {
|
|
37
|
-
if (branchValidator && !branchValidator(branch)) {
|
|
38
|
-
errors.push(getError(`E${type.toUpperCase()}BRANCH`, { branch }));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
const branchesOfType = normalize[type](branchesByType);
|
|
43
|
-
|
|
44
|
-
if (!branchesValidator(branchesOfType)) {
|
|
45
|
-
errors.push(getError(`E${type.toUpperCase()}BRANCHES`, { branches: branchesOfType }));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return { ...result, [type]: branchesOfType };
|
|
49
|
-
}, {});
|
|
50
|
-
|
|
51
|
-
const duplicates = [...branches]
|
|
52
|
-
.map((branch) => branch.name)
|
|
53
|
-
.sort()
|
|
54
|
-
.filter((_, idx, array) => array[idx] === array[idx + 1] && array[idx] !== array[idx - 1]);
|
|
55
|
-
|
|
56
|
-
if (duplicates.length > 0) {
|
|
57
|
-
errors.push(getError("EDUPLICATEBRANCHES", { duplicates }));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await pEachSeries(branches, async (branch) => {
|
|
61
|
-
if (!(await verifyBranchName(branch.name))) {
|
|
62
|
-
errors.push(getError("EINVALIDBRANCHNAME", branch));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
if (errors.length > 0) {
|
|
67
|
-
throw new AggregateError(errors);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return [...result.maintenance, ...result.release, ...result.prerelease];
|
|
71
|
-
};
|