Compare commits
86
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e72d201afe | ||
|
|
ab7a428102 | ||
|
|
ce263c5f4a | ||
|
|
d9605a5e45 | ||
|
|
e1c00e2531 | ||
|
|
88e423b828 | ||
|
|
a4f0ff70fe | ||
|
|
ee3068eb6a | ||
|
|
04b6046e1f | ||
|
|
fa847e2b87 | ||
|
|
413ffd2a4b | ||
|
|
143c8981bf | ||
|
|
cf000687c4 | ||
|
|
1463eb42cb | ||
|
|
80e1665037 | ||
|
|
37765ef36d | ||
|
|
a7a1e6d28f | ||
|
|
59bf862d4a | ||
|
|
78a63a7de0 | ||
|
|
61f94c00ab | ||
|
|
7452eaf2cd | ||
|
|
c229888cc0 | ||
|
|
29d34788ff | ||
|
|
fe0ac417cf | ||
|
|
3edc917c7c | ||
|
|
8bc98c33c9 | ||
|
|
6427210b83 | ||
|
|
4c1c992869 | ||
|
|
a3a9907368 | ||
|
|
7fbab56a98 | ||
|
|
7dae2a9f43 | ||
|
|
13f6a725a1 | ||
|
|
55194c106e | ||
|
|
e24ef71e33 | ||
|
|
0435e35fee | ||
|
|
1d1b52a7dc | ||
|
|
72522c3570 | ||
|
|
5489489dda | ||
|
|
12337175c6 | ||
|
|
8fa4f9a750 | ||
|
|
f668935993 | ||
|
|
0f3c4148c7 | ||
|
|
2e4b901c4f | ||
|
|
971a5e0d16 | ||
|
|
44b3344b91 | ||
|
|
046a845a9e | ||
|
|
48def0c4cc | ||
|
|
2b6c9ba093 | ||
|
|
07f12b9df2 | ||
|
|
2272ce3059 | ||
|
|
3ecc196d8a | ||
|
|
acf8bc4d21 | ||
|
|
67dfb676bc | ||
|
|
f25c3527df | ||
|
|
6013a5633e | ||
|
|
d2782484c8 | ||
|
|
34e5ddad12 | ||
|
|
a9be97b56b | ||
|
|
85bc213f04 | ||
|
|
8e3a6cbef2 | ||
|
|
a2eaed086f | ||
|
|
b22e591c96 | ||
|
|
fc32afa776 | ||
|
|
8ea81ae6c9 | ||
|
|
e4002c8bd7 | ||
|
|
d738dd0fb7 | ||
|
|
4c7222d648 | ||
|
|
54bf761f7e | ||
|
|
ea5e813192 | ||
|
|
a7f008253c | ||
|
|
ece7275743 | ||
|
|
16a9fb00e9 | ||
|
|
854d643bed | ||
|
|
969e460948 | ||
|
|
ab227451fa | ||
|
|
0f37fc3aa6 | ||
|
|
fa7080e0d4 | ||
|
|
0a86d61a00 | ||
|
|
d53e2066cc | ||
|
|
47450fb3b1 | ||
|
|
fb5db83adc | ||
|
|
8262832cda | ||
|
|
cc74a4c890 | ||
|
|
a3c49428e3 | ||
|
|
d95d80a0aa | ||
|
|
b5aa853b22 |
@@ -0,0 +1,23 @@
|
||||
name: Release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- next
|
||||
- beta
|
||||
- "*.x" # maintenance releases branches
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npx semantic-release
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.SEMANTIC_RELEASE_BOT_NPM_TOKEN }}
|
||||
@@ -0,0 +1,50 @@
|
||||
name: Test
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
# renovate/** branches are generated by https://github.com/apps/renovate
|
||||
- renovate/**
|
||||
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
test_matrix:
|
||||
strategy:
|
||||
matrix:
|
||||
node-version:
|
||||
- 14.17
|
||||
- 16
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: git config --global user.name github-actions
|
||||
- run: git config --global user.email github-actions@github.com
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
- name: Ensure dependencies are compatible with the version of node
|
||||
run: echo 'engine-strict=true' >> .npmrc
|
||||
- run: npm ci
|
||||
- run: npm run test:ci
|
||||
|
||||
# separate job to set as required in branch protection,
|
||||
# as the build names above change each time Node versions change
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test_matrix
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
with:
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
@@ -125,10 +125,6 @@ $RECYCLE.BIN/
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
# Lockfiles
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
# Gitbook
|
||||
_book
|
||||
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
version: ~> 1.0
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
import:
|
||||
- .travis/node.yml
|
||||
- .travis/node-versions.yml
|
||||
- .travis/semantic-release.yml
|
||||
- .travis/greenkeeper.yml
|
||||
- .travis/codecov.yml
|
||||
@@ -1,2 +0,0 @@
|
||||
after_success:
|
||||
- npm run codecov
|
||||
@@ -1,3 +0,0 @@
|
||||
branches:
|
||||
only:
|
||||
- /^greenkeeper.*$/
|
||||
@@ -1,3 +0,0 @@
|
||||
node_js:
|
||||
- 12
|
||||
- 10.18
|
||||
@@ -1,11 +0,0 @@
|
||||
language: node_js
|
||||
|
||||
cache:
|
||||
npm: false
|
||||
|
||||
# Retry install on fail to avoid failing a build on network/disk/external errors
|
||||
install:
|
||||
- travis_retry npm install
|
||||
|
||||
script:
|
||||
- npm run test
|
||||
@@ -1,15 +0,0 @@
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- next
|
||||
- beta
|
||||
- /^\d+\.(\d+|x)(\.x)?$/
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: release
|
||||
node_js: lts/*
|
||||
install:
|
||||
- travis_retry npm install
|
||||
script:
|
||||
- npm run semantic-release
|
||||
@@ -1,17 +1,11 @@
|
||||
<h1 align="center" style="border-bottom: none;">📦🚀 semantic-release</h1>
|
||||
<h3 align="center">Fully automated version management and package publishing</h3>
|
||||
<p align="center">
|
||||
<a href="https://spectrum.chat/semantic-release">
|
||||
<img alt="Join the community on Spectrum" src="https://withspectrum.github.io/badge/badge.svg">
|
||||
<a href="https://github.com/semantic-release/semantic-release/discussions">
|
||||
<img alt="Join the community on GitHub Discussions" src="https://img.shields.io/badge/Join%20the%20community-on%20GitHub%20Discussions-blue">
|
||||
</a>
|
||||
<a href="https://travis-ci.org/semantic-release/semantic-release">
|
||||
<img alt="Travis" src="https://img.shields.io/travis/semantic-release/semantic-release/master.svg">
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/semantic-release/semantic-release">
|
||||
<img alt="Codecov" src="https://img.shields.io/codecov/c/github/semantic-release/semantic-release/master.svg">
|
||||
</a>
|
||||
<a href="https://greenkeeper.io">
|
||||
<img alt="Greenkeeper" src="https://badges.greenkeeper.io/semantic-release/semantic-release.svg">
|
||||
<a href="https://github.com/semantic-release/semantic-release/actions?query=workflow%3ATest+branch%3Amaster">
|
||||
<img alt="Build states" src="https://github.com/semantic-release/semantic-release/workflows/Test/badge.svg">
|
||||
</a>
|
||||
<a href="#badge">
|
||||
<img alt="semantic-release" src="https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg">
|
||||
@@ -54,14 +48,14 @@ This removes the immediate connection between human emotions and version numbers
|
||||
|
||||
**semantic-release** uses the commit messages to determine the type of changes in the codebase. Following formalized conventions for commit messages, **semantic-release** automatically determines the next [semantic version](https://semver.org) number, generates a changelog and publishes the release.
|
||||
|
||||
By default **semantic-release** uses [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines). The commit message format can be changed with the [`preset` or `config` options](docs/usage/configuration.md#options) of the [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer#options) and [@semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator#options) plugins.
|
||||
By default **semantic-release** uses [Angular Commit Message Conventions](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format). The commit message format can be changed with the [`preset` or `config` options](docs/usage/configuration.md#options) of the [@semantic-release/commit-analyzer](https://github.com/semantic-release/commit-analyzer#options) and [@semantic-release/release-notes-generator](https://github.com/semantic-release/release-notes-generator#options) plugins.
|
||||
|
||||
Tools such as [commitizen](https://github.com/commitizen/cz-cli) or [commitlint](https://github.com/conventional-changelog/commitlint) can be used to help contributors and enforce valid commit messages.
|
||||
|
||||
Here is an example of the release type that will be done based on a commit messages:
|
||||
The table below shows which commit message gets you which release type when `semantic-release` runs (using the default configuration):
|
||||
|
||||
| Commit message | Release type |
|
||||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------|
|
||||
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- |
|
||||
| `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
|
||||
| `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
|
||||
| `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 |
|
||||
@@ -75,6 +69,7 @@ Here is an example of the release type that will be done based on a commit messa
|
||||
For each new commits added to one of the release branches (for example `master`, `next`, `beta`), with `git push` or by merging a pull request or merging from another branch, a CI build is triggered and runs the `semantic-release` command to make a release if there are codebase changes since the last release that affect the package functionalities.
|
||||
|
||||
**semantic-release** offers various ways to control the timing, the content and the audience of published releases. See example workflows in the following recipes:
|
||||
|
||||
- [Using distribution channels](docs/recipes/distribution-channels.md#publishing-on-distribution-channels)
|
||||
- [Maintenance releases](docs/recipes/maintenance-releases.md#publishing-maintenance-releases)
|
||||
- [Pre-releases](docs/recipes/pre-releases.md#publishing-pre-releases)
|
||||
@@ -84,7 +79,7 @@ For each new commits added to one of the release branches (for example `master`,
|
||||
After running the tests, the command `semantic-release` will execute the following steps:
|
||||
|
||||
| Step | Description |
|
||||
|-------------------|---------------------------------------------------------------------------------------------------------------------------------|
|
||||
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Verify Conditions | Verify all the conditions to proceed with the release. |
|
||||
| Get last release | Obtain the commit corresponding to the last release by analyzing [Git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). |
|
||||
| Analyze commits | Determine the type of release based on the commits added since the last release. |
|
||||
@@ -98,10 +93,11 @@ After running the tests, the command `semantic-release` will execute the followi
|
||||
## Requirements
|
||||
|
||||
In order to use **semantic-release** you need:
|
||||
|
||||
- To host your code in a [Git repository](https://git-scm.com)
|
||||
- Use a Continuous Integration service that allows you to [securely set up credentials](docs/usage/ci-configuration.md#authentication)
|
||||
- Git CLI version [2.7.1 or higher](docs/support/FAQ.md#why-does-semantic-release-require-git-version--271) installed in your Continuous Integration environment
|
||||
- [Node.js](https://nodejs.org) version [10.18 or higher](docs/support/FAQ.md#why-does-semantic-release-require-node-version--1018) installed in your Continuous Integration environment
|
||||
- [Node.js](https://nodejs.org) version [14.17 or higher](docs/support/FAQ.md#why-does-semantic-release-require-node-version--1417) installed in your Continuous Integration environment
|
||||
|
||||
## Documentation
|
||||
|
||||
@@ -135,7 +131,7 @@ In order to use **semantic-release** you need:
|
||||
## Get help
|
||||
|
||||
- [Stack Overflow](https://stackoverflow.com/questions/tagged/semantic-release)
|
||||
- [Spectrum community](https://spectrum.chat/semantic-release)
|
||||
- [GitHub Discussions](https://github.com/semantic-release/semantic-release/discussions)
|
||||
- [Twitter](https://twitter.com/SemanticRelease)
|
||||
|
||||
## Badge
|
||||
@@ -160,7 +156,6 @@ Let people know that your package is published using **semantic-release** by inc
|
||||
| ------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
||||
| [Stephan Bönnemann](https://github.com/boennemann) | [Rolf Erik Lekang](https://github.com/relekang) | [Johannes Jörg Schmidt](https://github.com/jo) | [Finn Pauls](https://github.com/finnp) | [Christoph Witzko](https://github.com/christophwitzko) |
|
||||
|
||||
|
||||
<p align="center">
|
||||
<img alt="Kill all humans" src="media/bender.png">
|
||||
</p>
|
||||
|
||||
+7
-12
@@ -1,16 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
#!/usr/bin/env node// Bad news: We have to write plain ES5 in this file
|
||||
import semver from 'semver';
|
||||
|
||||
// Bad news: We have to write plain ES5 in this file
|
||||
// Good news: It's the only file of the entire project
|
||||
import execa from 'execa';
|
||||
import findVersions from 'find-versions';
|
||||
import pkg from '../package.json';
|
||||
|
||||
/* eslint-disable no-var */
|
||||
|
||||
var semver = require('semver');
|
||||
var execa = require('execa');
|
||||
var findVersions = require('find-versions');
|
||||
var pkg = require('../package.json');
|
||||
|
||||
var MIN_GIT_VERSION = '2.7.1';
|
||||
const MIN_GIT_VERSION = '2.7.1';
|
||||
|
||||
if (!semver.satisfies(process.version, pkg.engines.node)) {
|
||||
console.error(
|
||||
@@ -23,7 +18,7 @@ See https://github.com/semantic-release/semantic-release/blob/master/docs/suppor
|
||||
|
||||
execa('git', ['--version'])
|
||||
.then(({stdout}) => {
|
||||
var gitVersion = findVersions(stdout)[0];
|
||||
const gitVersion = findVersions(stdout)[0];
|
||||
if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
|
||||
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
|
||||
process.exit(1);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
const {argv, env, stderr} = require('process'); // eslint-disable-line node/prefer-global/process
|
||||
const util = require('util');
|
||||
const hideSensitive = require('./lib/hide-sensitive');
|
||||
import util from 'util';
|
||||
import hideSensitive from './lib/hide-sensitive';
|
||||
import yargs from 'yargs';
|
||||
import debug from 'debug';
|
||||
|
||||
import run from '.';
|
||||
|
||||
const stringList = {
|
||||
type: 'string',
|
||||
@@ -11,8 +14,8 @@ const stringList = {
|
||||
: values.reduce((values, value) => values.concat(value.split(',').map((value) => value.trim())), []),
|
||||
};
|
||||
|
||||
module.exports = async () => {
|
||||
const cli = require('yargs')
|
||||
export default async () => {
|
||||
const cli = yargs
|
||||
.command('$0', 'Run automated package publishing', (yargs) => {
|
||||
yargs.demandCommand(0, 0).usage(`Run automated package publishing
|
||||
|
||||
@@ -41,7 +44,7 @@ Usage:
|
||||
.exitProcess(false);
|
||||
|
||||
try {
|
||||
const {help, version, ...options} = cli.parse(argv.slice(2));
|
||||
const {help, version, ...options} = cli.parse(process.argv.slice(2));
|
||||
|
||||
if (Boolean(help) || Boolean(version)) {
|
||||
return 0;
|
||||
@@ -49,14 +52,14 @@ Usage:
|
||||
|
||||
if (options.debug) {
|
||||
// Debug must be enabled before other requires in order to work
|
||||
require('debug').enable('semantic-release:*');
|
||||
debug.enable('semantic-release:*');
|
||||
}
|
||||
|
||||
await require('.')(options);
|
||||
await run(options);
|
||||
return 0;
|
||||
} catch (error) {
|
||||
if (error.name !== 'YError') {
|
||||
stderr.write(hideSensitive(env)(util.inspect(error, {colors: true})));
|
||||
process.stderr.write(hideSensitive(process.env)(util.inspect(error, {colors: true})));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
# semantic-release documentation
|
||||
|
||||
- [Usage](usage/README.md) - **semantic-release** installation and configuration
|
||||
- [Extending](extending/README.md)- Extending **semantic-release** with plugins and shareable configurations
|
||||
- [Extending](extending/README.md) - Extending **semantic-release** with plugins and shareable configurations
|
||||
- [Recipes](recipes/README.md) - Community written recipes for common **semantic-release** use-cases
|
||||
- [Developer Guide](developer-guide/README.md) - The essentials of writing a **semantic-release** plugin or shareable configurations
|
||||
- [Support](support/README.md) - FAQ and troubleshooting
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
# Plugin Developer Guide
|
||||
|
||||
To create a plugin for `semantic-release`, you need to decide which parts of the release lifecycle are important to that plugin. For example, it is best to always have a `verify` step because you may be receiving inputs from a user and want to make sure they exist. A plugin can abide by any of the following lifecycles:
|
||||
To create a plugin for `semantic-release`, you need to decide which parts of the release lifecycle are important to that plugin. For example, it is best to always have a `verifyConditions` step because you may be receiving inputs from a user and want to make sure they exist. A plugin can abide by any of the following lifecycles:
|
||||
|
||||
- `verify`
|
||||
- `verifyConditions`
|
||||
- `analyzeCommits`
|
||||
- `verifyRelease`
|
||||
- `generateNotes`
|
||||
- `addChannel`
|
||||
- `prepare`
|
||||
- `publish`
|
||||
- `success`
|
||||
- `fail`
|
||||
|
||||
`semantic-release` will require the plugin via `node` and look through the required object for methods named like the lifecyles stated above. For example, if your plugin only had a `verify` and `success` step, the `main` file for your object would need to `export` an object with `verify` and `success` functions.
|
||||
`semantic-release` will require the plugin via `node` and look through the required object for methods named like the lifecyles stated above. For example, if your plugin only had a `verifyConditions` and `success` step, the `main` file for your object would need to `export` an object with `verifyConditions` and `success` functions.
|
||||
|
||||
In addition to the lifecycle methods, each lifecyle is passed two objects:
|
||||
|
||||
@@ -93,7 +97,136 @@ if (message.length) {
|
||||
}
|
||||
```
|
||||
|
||||
## Supporting Environment Variables
|
||||
## Context
|
||||
|
||||
### Common context keys
|
||||
|
||||
* `stdout`
|
||||
* `stderr`
|
||||
* `logger`
|
||||
|
||||
### Context object keys by lifecycle
|
||||
|
||||
#### verifyConditions
|
||||
|
||||
Initially the context object contains the following keys (`verifyConditions` lifecycle):
|
||||
* `cwd`
|
||||
* Current working directory
|
||||
* `env`
|
||||
* Environment variables
|
||||
* `envCi`
|
||||
* Information about CI environment
|
||||
* Contains (at least) the following keys:
|
||||
* `isCi`
|
||||
* Boolean, true if the environment is a CI environment
|
||||
* `commit`
|
||||
* Commit hash
|
||||
* `branch`
|
||||
* Current branch
|
||||
* `options`
|
||||
* Options passed to `semantic-release` via CLI, configuration files etc.
|
||||
* `branch`
|
||||
* Information on the current branch
|
||||
* Object keys:
|
||||
* `channel`
|
||||
* `tags`
|
||||
* `type`
|
||||
* `name`
|
||||
* `range`
|
||||
* `accept`
|
||||
* `main`
|
||||
* `branches`
|
||||
* Information on branches
|
||||
* List of branch objects (see above)
|
||||
|
||||
#### analyzeCommits
|
||||
|
||||
Compared to the verifyConditions, `analyzeCommits` lifecycle context has keys
|
||||
|
||||
* `commits` (List)
|
||||
* List of commits taken into account when determining the new version.
|
||||
* Keys:
|
||||
* `commit` (Object)
|
||||
* Keys:
|
||||
* `long` (String, Commit hash)
|
||||
* `short` (String, Commit hash)
|
||||
* `tree` (Object)
|
||||
* Keys:
|
||||
* `long` (String, Commit hash)
|
||||
* `short` (String, Commit hash)
|
||||
* `author` (Object)
|
||||
* Keys:
|
||||
* `name` (String)
|
||||
* `email` (String)
|
||||
* `date` (String, ISO 8601 timestamp)
|
||||
* `committer` (Object)
|
||||
* Keys:
|
||||
* `name` (String)
|
||||
* `email` (String)
|
||||
* `date` (String, ISO 8601 timestamp)
|
||||
* `subject` (String, Commit message subject)
|
||||
* `body` (String, Commit message body)
|
||||
* `hash` (String, Commit hash)
|
||||
* `committerDate` (String, ISO 8601 timestamp)
|
||||
* `message` (String)
|
||||
* `gitTags` (String, List of git tags)
|
||||
* `releases` (List)
|
||||
* `lastRelease` (Object)
|
||||
* Keys
|
||||
* `version` (String)
|
||||
* `gitTag` (String)
|
||||
* `channels` (List)
|
||||
* `gitHead` (String, Commit hash)
|
||||
* `name` (String)
|
||||
|
||||
#### verifyRelease
|
||||
|
||||
Additional keys:
|
||||
|
||||
* `nextRelease` (Object)
|
||||
* `type` (String)
|
||||
* `channel` (String)
|
||||
* `gitHead` (String, Git hash)
|
||||
* `version` (String, version without `v`)
|
||||
* `gitTag` (String, version with `v`)
|
||||
* `name` (String)
|
||||
|
||||
#### generateNotes
|
||||
|
||||
No new content in the context.
|
||||
|
||||
#### addChannel
|
||||
|
||||
*This is run only if there are releases that have been merged from a higher branch but not added on the channel of the current branch.*
|
||||
|
||||
Context content is similar to lifecycle `verifyRelease`.
|
||||
|
||||
#### prepare
|
||||
|
||||
Only change is that `generateNotes` has populated `nextRelease.notes`.
|
||||
|
||||
#### publish
|
||||
|
||||
No new content in the context.
|
||||
|
||||
#### success
|
||||
|
||||
Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
|
||||
|
||||
Additional keys:
|
||||
|
||||
* `releases`
|
||||
* Populated by `publish` lifecycle
|
||||
|
||||
#### fail
|
||||
|
||||
Lifecycles `success` and `fail` are mutually exclusive, only one of them will be run.
|
||||
|
||||
Additional keys:
|
||||
|
||||
* `errors`
|
||||
|
||||
### Supporting Environment Variables
|
||||
|
||||
Similar to `options`, environment variables exist to allow users to pass tokens and set special URLs. These are set on the `context` object instead of the `pluginConfig` object. Let's say we wanted to check for `GITHUB_TOKEN` in the environment because we want to post to GitHub on the user's behalf. To do this, we can add the following to our `verify` command:
|
||||
|
||||
@@ -101,6 +234,33 @@ Similar to `options`, environment variables exist to allow users to pass tokens
|
||||
const { env } = context;
|
||||
|
||||
if (env.GITHUB_TOKEN) {
|
||||
//...
|
||||
//...
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
## Execution order
|
||||
|
||||
For the lifecycles, the list at the top of the readme contains the order. If there are multiple plugins for the same lifecycle, then the order of the plugins determines the order in which they are executed.
|
||||
|
||||
## Handling errors
|
||||
|
||||
In order to be able to detect and handle errors properly, the errors thrown from the must be of type [SemanticReleaseError](https://github.com/semantic-release/error) or extend it as described in the package readme. This way the errors are handled properly and plugins using the `fail` lifecycle receive the errors correctly. For any other types of errors the internal error handling does nothing, lets them through up until the final catch and does not call any `fail` plugins.
|
||||
|
||||
## Advanced
|
||||
|
||||
Knowledge that might be useful for plugin developers.
|
||||
|
||||
### Multiple analyzeCommits plugins
|
||||
|
||||
While it may be trivial that multiple analyzeCommits (or any lifecycle plugins) can be defined, it is not that self-evident that the plugins executed AFTER the first one (for example, the default one: `commit-analyzer`) can change the result. This way it is possible to create more advanced rules or situations, e.g. if none of the commits would result in new release, then a default can be defined.
|
||||
|
||||
The commit must be a known release type, for example the commit-analyzer has the following default types:
|
||||
* major
|
||||
* premajor
|
||||
* minor
|
||||
* preminor
|
||||
* patch
|
||||
* prepatch
|
||||
* prerelease
|
||||
|
||||
If the analyzeCommits-lifecycle plugin does not return anything, then the earlier result is used, but if it returns a supported string value, then that overrides the previous result.
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
- `publish`: Publish the package on the npm registry
|
||||
- [@semantic-release/gitlab](https://github.com/semantic-release/gitlab)
|
||||
- `verifyConditions`: Verify the presence and the validity of the GitLab authentication and release configuration
|
||||
- `publish`: Publish a [GitLab release](https://docs.gitlab.com/ce/workflow/releases.html)
|
||||
- `publish`: Publish a [GitLab release](https://docs.gitlab.com/ee/user/project/releases/)
|
||||
- [@semantic-release/git](https://github.com/semantic-release/git)
|
||||
- `verifyConditions`: Verify the presence and the validity of the Git authentication and release configuration
|
||||
- `prepare`: Push a release commit and tag, including configurable files
|
||||
@@ -52,6 +52,9 @@
|
||||
- [semantic-release-docker](https://github.com/felixfbecker/semantic-release-docker)
|
||||
- `verifyConditions`: Verify that all needed configuration is present and login to the Docker registry.
|
||||
- `publish`: Tag the image specified by `name` with the new version, push it to Docker Hub and update the latest tag
|
||||
- [@semantic-release-plus/docker](https://github.com/semantic-release-plus/semantic-release-plus/tree/master/packages/plugins/docker)
|
||||
- `verifyConditions`: Verify that all needed configuration is present and login to the configured docker registry.
|
||||
- `publish`: Tag the image specified by `name` with the new version, push it to the configured docker registry and update the `latest`, `major`, `minor` tags based on the configuration settings.
|
||||
- [semantic-release-gcr](https://github.com/carlos-cubas/semantic-release-gcr)
|
||||
- `verifyConditions`: Verify that all needed configuration is present and login to the Docker registry
|
||||
- `publish`: Tag the image specified by `name` with the new version, push it to Docker Hub and update the latest tag
|
||||
@@ -91,6 +94,9 @@
|
||||
- [semantic-release-github-pages](https://github.com/qiwi/semantic-release-gh-pages-plugin)
|
||||
- `verifyConditions`: Verify the presence of the auth token set via environment variables.
|
||||
- `publish`: Pushes commit to the documentation branch.
|
||||
- [semantic-release-github-pullrequest](https://github.com/asbiin/semantic-release-github-pullrequest)
|
||||
- `verifyConditions`: Verify the presence and the validity of the GitHub authentication and other configuration.
|
||||
- `publish`: Create a branch to upload all assets and create the pull request on the base branch on GitHub.
|
||||
- [leiningen-semantic-release](https://github.com/NoxHarmonium/leiningen-semantic-release)
|
||||
- `verifyConditions`: Checks the project.clj is syntactically valid.
|
||||
- `prepare`: Update the project.clj version and package the output jar file.
|
||||
@@ -124,3 +130,13 @@
|
||||
- `verifyConditions`: Validate configuration and (if present) credentials
|
||||
- `prepare`: Update version and appVersion in ```Chart.yaml```
|
||||
- `publish`: Publish the chart to a registry (if configured)
|
||||
- [semantic-release-codeartifact](https://github.com/ryansonshine/semantic-release-codeartifact)
|
||||
- `verifyConditions`: Validate configuration, get AWS CodeArtifact authentication and repository, validate `publishConfig` or `.npmrc` (if they exist), then pass the configuration to the associated plugins.
|
||||
- [semantic-release-telegram](https://github.com/pustovitDmytro/semantic-release-telegram)
|
||||
- `verifyConditions`: Validate configuration and verify ```TELEGRAM_BOT_ID``` and ```TELEGRAM_BOT_TOKEN```
|
||||
- `success`: Publish a message about the successful release to a telegram chat
|
||||
- `fail`: publish a message about failure to a telegram chat
|
||||
- [semantic-release-heroku](https://github.com/pustovitDmytro/semantic-release-heroku)
|
||||
- `verifyConditions`: Validate configuration and verify ```HEROKU_API_KEY```
|
||||
- `prepare`: Update the package.json version and create release tarball
|
||||
- `publish`: Publish version to heroku
|
||||
|
||||
@@ -10,46 +10,39 @@ Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with
|
||||
|
||||
### `.circleci/config.yml` configuration for multiple Node jobs
|
||||
|
||||
This example is a minimal configuration for **semantic-release** with a build running Node 6 and 8. See [CircleCI documentation](https://circleci.com/docs/2.0) for additional configuration options.
|
||||
This example is a minimal configuration for **semantic-release** with tests running against Node 16 and 14. See [CircleCI documentation](https://circleci.com/docs/2.0) for additional configuration options.
|
||||
|
||||
This example create the workflows `test_node_4`, `test_node_6`, `test_node_8` and `release`. The release workflows will [run `semantic-release` only after the all the `test_node_*` are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
|
||||
In this example, the [`circleci/node`](https://circleci.com/developer/orbs/orb/circleci/node) orb is imported (Which makes some node operations easier), then a `release` job is defined which will run `semantic-release`.
|
||||
|
||||
To run our `release` job, we have created a workflow named `test_and_release` which will run two jobs, `node/test`, which comes from the node orb and will test our application, and our release job. Here, we are actually making use of [matrix jobs](https://circleci.com/blog/circleci-matrix-jobs/) so that our single `node/test` job will actually be executed twice, once for Node version 16, and once for version 14. Finally, we call our release job with a `requires` parameter so that `release` will only run after `node/test` has successfully tested against v14 and v16.
|
||||
|
||||
```yaml
|
||||
version: 2
|
||||
version: 2.1
|
||||
orbs:
|
||||
node: circleci/node@4.5
|
||||
jobs:
|
||||
test_node_6:
|
||||
docker:
|
||||
- image: circleci/node:6
|
||||
steps:
|
||||
# Configure your test steps here (checkout, npm install, cache management, tests etc...)
|
||||
|
||||
test_node_8:
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
steps:
|
||||
# Configure your test steps here (checkout, npm install, cache management, tests etc...)
|
||||
|
||||
release:
|
||||
docker:
|
||||
- image: circleci/node:8
|
||||
executor: node/default
|
||||
steps:
|
||||
- checkout
|
||||
- run: npm install
|
||||
- node/install-packages # Install and automatically cache packages
|
||||
# Run optional required steps before releasing
|
||||
# - run: npm run build-script
|
||||
- run: npx semantic-release
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
test_and_release:
|
||||
# Run the test jobs first, then the release only when all the test jobs are successful
|
||||
jobs:
|
||||
- test_node_6
|
||||
- test_node_8
|
||||
- node/test:
|
||||
matrix:
|
||||
parameters:
|
||||
version:
|
||||
- 16.1.0
|
||||
- 14.17.0
|
||||
- release:
|
||||
requires:
|
||||
- test_node_6
|
||||
- test_node_8
|
||||
- node/test
|
||||
```
|
||||
|
||||
### `package.json` configuration for multiple Node jobs
|
||||
@@ -59,7 +52,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
|
||||
```json
|
||||
{
|
||||
"devDependencies": {
|
||||
"semantic-release": "^15.0.0"
|
||||
"semantic-release": "^18.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -97,7 +97,7 @@ The Git history of the repository is now:
|
||||
|
||||
After a period of feedback from our users using the `@next` dist-tag we feel confident to make our big feature available to all users. To do so we merge the `next` branch into `master`. There should be no conflict as `next` is strictly ahead of `master`.
|
||||
|
||||
Once the merge commit is pushed to `next`, **semantic-release** will add the version `2.1.0` to the dist-tag `@latest` so all users will receive it when installing out module with `npm install example-module`.
|
||||
Once the merge commit is pushed to `master`, **semantic-release** will add the version `2.1.0` to the dist-tag `@latest` so all users will receive it when installing out module with `npm install example-module`.
|
||||
|
||||
The Git history of the repository is now:
|
||||
|
||||
|
||||
@@ -10,11 +10,12 @@ In this example a publish type [`NPM_TOKEN`](https://docs.npmjs.com/creating-and
|
||||
|
||||
[GitHub Actions](https://github.com/features/actions) support [Workflows](https://help.github.com/en/articles/configuring-workflows), allowing to run tests on multiple Node versions and publish a release only when all test pass.
|
||||
|
||||
**Note**: The publish pipeline must run on [Node version >= 10.18](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
|
||||
**Note**: The publish pipeline must run on [Node version >= 14.17](../support/FAQ.md#why-does-semantic-release-require-node-version--1417).
|
||||
|
||||
### `.github/workflows/release.yml` configuration for Node projects
|
||||
|
||||
The following is a minimal configuration for [`semantic-release`](https://github.com/semantic-release/semantic-release) with a build running on Node 12 when a new commit is pushed to a `master` branch. See [Configuring a Workflow](https://help.github.com/en/articles/configuring-a-workflow) for additional configuration options.
|
||||
The following is a minimal configuration for [`semantic-release`](https://github.com/semantic-release/semantic-release) with a build running on Node 14.17 when a new commit is pushed to a `master` branch.
|
||||
See [Configuring a Workflow](https://help.github.com/en/articles/configuring-a-workflow) for additional configuration options.
|
||||
|
||||
```yaml
|
||||
name: Release
|
||||
@@ -25,7 +26,7 @@ on:
|
||||
jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
@@ -34,7 +35,7 @@ jobs:
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 12
|
||||
node-version: '14.17'
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Release
|
||||
|
||||
@@ -10,7 +10,7 @@ The [Authentication](../usage/ci-configuration.md#authentication) environment va
|
||||
|
||||
GitLab CI supports [Pipelines](https://docs.gitlab.com/ee/ci/pipelines.html) allowing to test on multiple Node versions and publishing a release only when all test pass.
|
||||
|
||||
**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
|
||||
**Note**: The publish pipeline must run a [Node >= 14.17 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1417).
|
||||
|
||||
### `.gitlab-ci.yml` configuration for Node projects
|
||||
|
||||
@@ -54,7 +54,7 @@ This example is a minimal configuration for **semantic-release** with a build ru
|
||||
|
||||
|
||||
```yaml
|
||||
# The release pipeline will run only on the master branch a commit is triggered
|
||||
# The release pipeline will run only on the master branch a commit is triggered
|
||||
stages:
|
||||
- release
|
||||
|
||||
|
||||
@@ -10,16 +10,16 @@ Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with
|
||||
|
||||
### `Jenkinsfile (Declarative Pipeline)` configuration for a Node.js job
|
||||
|
||||
**Note**: The publish pipeline must run a [Node >= 10.18 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1018).
|
||||
**Note**: The publish pipeline must run a [Node >= 14.17 version](../support/FAQ.md#why-does-semantic-release-require-node-version--1417).
|
||||
|
||||
This example is a minimal configuration for **semantic-release** with a build running Node 10.18. See [Jenkins documentation](https://www.jenkins.io/doc/) for additional configuration options.
|
||||
This example is a minimal configuration for **semantic-release** with a build running Node 14.17. See [Jenkins documentation](https://www.jenkins.io/doc/) for additional configuration options.
|
||||
|
||||
The`semantic-release` execution command varies depending if you are using a [local](../usage/installation.md#local-installation) or [global](../usage/installation.md#global-installation) **semantic-release** installation.
|
||||
|
||||
```yaml
|
||||
// The release stage in the pipeline will run only if the test stage in the pipeline is successful
|
||||
pipeline {
|
||||
agent any
|
||||
agent any
|
||||
environment {
|
||||
GH_TOKEN = credentials('some-id')
|
||||
}
|
||||
@@ -35,14 +35,14 @@ pipeline {
|
||||
}
|
||||
stage('Release') {
|
||||
tools {
|
||||
nodejs "node 10.18"
|
||||
nodejs "node 14.17"
|
||||
}
|
||||
steps {
|
||||
sh '''
|
||||
# Run optional required steps before releasing
|
||||
npx semantic-release
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
|
||||
```json
|
||||
{
|
||||
"devDependencies": {
|
||||
"semantic-release": "^15.0.0"
|
||||
"semantic-release": "^18.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ The Git history of the repository is now:
|
||||
|
||||
One of our users request a new feature, however they cannot migrate to Node.js 8 or higher due to corporate policies.
|
||||
|
||||
If we were to push that feature on `master` and release it, the new version would require Node.js 8 or higher as the release would also contains the commit `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required`.
|
||||
If we were to push that feature on `master` and release it, the new version would require Node.js 8 or higher as the release would also contain the commit `feat: drop Node.js 6 support \n\n BREAKING CHANGE: Node.js >= 8 required`.
|
||||
|
||||
Instead, we create the branch `1.x` from the tag `v1.0.0` with the command `git checkout -b 1.x v1.0.0` and we commit that feature with the message `feat: a feature` to the branch `1.x`. When pushing that commit, **semantic-release** will release the version `1.1.0` on the dist-tag `@release-1.x` so users who can't migrate to Node.js 8 or higher can benefit from it.
|
||||
|
||||
@@ -48,7 +48,7 @@ The Git history of the repository is now:
|
||||
|
||||
## Releasing a bug fix for version 1.0.x users
|
||||
|
||||
Another user currently using version `1.0.0` reports a bug. They cannot migrate to Node.js 8 or higher and they also cannot migrate to `1.1.0` as they do not use the feature developed in `feat: a feature` and their corporate policies require to go through a costly quality insurance process for each `minor` upgrades.
|
||||
Another user currently using version `1.0.0` reports a bug. They cannot migrate to Node.js 8 or higher and they also cannot migrate to `1.1.0` as they do not use the feature developed in `feat: a feature` and their corporate policies require to go through a costly quality assurance process for each `minor` upgrades.
|
||||
|
||||
In order to deliver the bug fix in a `patch` release, we create the branch `1.0.x` from the tag `v1.0.0` with the command `git checkout -b 1.0.x v1.0.0` and we commit that fix with the message `fix: a fix` to the branch `1.0.x`. When pushing that commit, **semantic-release** will release the version `1.0.1` on the dist-tag `@release-1.0.x` so users who can't migrate to `1.1.x` or `2.x` can benefit from it.
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with
|
||||
|
||||
### `.travis.yml` configuration for multiple Node.js jobs
|
||||
|
||||
This example is a minimal configuration for **semantic-release** with a build running Node 6 and 8. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
|
||||
This example is a minimal configuration for **semantic-release** with a build running Node 14 and 16. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
|
||||
|
||||
This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
|
||||
|
||||
@@ -24,8 +24,8 @@ It's recommended to run the `semantic-release` command in the [Travis `deploy` s
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- 8
|
||||
- 6
|
||||
- 14
|
||||
- 16
|
||||
|
||||
jobs:
|
||||
include:
|
||||
@@ -48,7 +48,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
|
||||
```json
|
||||
{
|
||||
"devDependencies": {
|
||||
"semantic-release": "^15.0.0"
|
||||
"semantic-release": "^18.0.0"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
+4
-34
@@ -38,44 +38,14 @@ If using npm hook scripts is not possible, and alternative solution is to [`@sem
|
||||
|
||||
Yes with the [dry-run options](../usage/configuration.md#dryrun) which prints to the console the next version to be published and the release notes.
|
||||
|
||||
## Can I use semantic-release with Yarn?
|
||||
|
||||
If you are using a [local](../usage/installation.md#local-installation) **semantic-release** installation and run multiple CI jobs with different versions, the `yarn install` command will fail on jobs running with Node < 8 as **semantic-release** requires [Node >= 10.18](#why-does-semantic-release-require-node-version--1018) and specifies it in its `package.json`s [`engines`](https://docs.npmjs.com/files/package.json#engines) key.
|
||||
|
||||
The recommended solution is to use the [Yarn](https://yarnpkg.com) [--ignore-engines](https://yarnpkg.com/en/docs/cli/install#toc-yarn-install-ignore-engines) option to install the project dependencies on the CI environment, so Yarn will ignore the **semantic-release**'s `engines` key:
|
||||
|
||||
```bash
|
||||
$ yarn install --ignore-engines
|
||||
```
|
||||
|
||||
**Note**: Several CI services use Yarn by default if your repository contains a `yarn.lock` file. So you should override the install step to specify `yarn install --ignore-engines`.
|
||||
|
||||
Alternatively you can use a [global](../usage/installation.md#global-installation) **semantic-release** installation and make sure to install and run the `semantic-release` command only in a CI jobs running with Node >= 10.18.
|
||||
|
||||
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can switch to Node 8 before installing and running the `semantic-release` command:
|
||||
|
||||
```bash
|
||||
$ nvm install 8 && yarn global add semantic-release && semantic-release
|
||||
```
|
||||
|
||||
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
|
||||
|
||||
As `semantic-release` is recommended to be executed with [`npx`](https://www.npmjs.com/package/npx) an alternative is required for usage with Yarn. Even though it is possible to install npx with Yarn, it's not recommended. Yarn and npx would be using different cache locations.
|
||||
|
||||
For [local installation](../usage/installation.md#local-installation) replace
|
||||
`npx semantic-release` with `yarn run semantic-release`.
|
||||
|
||||
For [global installation](../usage/installation.md#global-installation) replace
|
||||
`npx semantic-release` with `yarn global add semantic-release && semantic-release`.
|
||||
|
||||
## Can I use semantic-release to publish non-JavaScript packages?
|
||||
|
||||
Yes, **semantic-release** is a Node CLI application but it can be used to publish any type of packages.
|
||||
Yes, **semantic-release** is a Node CLI application, but it can be used to publish any type of packages.
|
||||
|
||||
To publish a non-Node package (without a `package.json`) you would need to:
|
||||
- Use a [global](../usage/installation.md#global-installation) **semantic-release** installation
|
||||
- Set **semantic-release** [options](../usage/configuration.md#options) via [CLI arguments or rc file](../usage/configuration.md#configuration)
|
||||
- Make sure your CI job executing the `semantic-release` command has access to [Node >= 10.18](#why-does-semantic-release-require-node-version--1018) to execute the `semantic-release` command
|
||||
- Make sure your CI job executing the `semantic-release` command has access to [Node >= 14.17](#why-does-semantic-release-require-node-version--1417) to execute the `semantic-release` command
|
||||
|
||||
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
|
||||
|
||||
@@ -234,9 +204,9 @@ See [“Introduction to SemVer” - Irina Gebauer](https://blog.greenkeeper.io/i
|
||||
|
||||
In addition the [verify conditions step](../../README.md#release-steps) verifies that all necessary conditions for proceeding with a release are met, and a new release will be performed [only if all your tests pass](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
|
||||
|
||||
## Why does semantic-release require Node version >= 10.18?
|
||||
## Why does semantic-release require Node version >= 14.17?
|
||||
|
||||
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which **requires Node version 10.18 or higher**.
|
||||
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which **requires Node version 14.17 or higher**.
|
||||
|
||||
See [Node version requirement](./node-version.md#node-version-requirement) for more details and solutions.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Node Support Policy
|
||||
|
||||
We only support [Long-Term Support](https://github.com/nodejs/Release) versions of Node starting with [Node 8.9.0 (LTS)](https://nodejs.org/en/blog/release/v8.9.0).
|
||||
We only support [Long-Term Support](https://github.com/nodejs/Release) versions of Node starting with [Node 14.17.0 (LTS)](https://nodejs.org/en/blog/release/v14.17.0).
|
||||
|
||||
We specifically limit our support to LTS versions of Node, not because this package won't work on other versions, but because we have a limited amount of time, and supporting LTS offers the greatest return on that investment.
|
||||
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
# Node version requirement
|
||||
|
||||
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which requires **requires Node version 10 or higher**.
|
||||
**semantic-release** is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which requires **requires Node version 14.17 or higher**.
|
||||
|
||||
**semantic-release** is meant to be used in a CI environment as a development support tool, not as a production dependency. Therefore the only constraint is to run the `semantic-release` in a CI environment providing Node 8 or higher.
|
||||
**semantic-release** is meant to be used in a CI environment as a development support tool, not as a production dependency. Therefore the only constraint is to run the `semantic-release` in a CI environment providing Node 14.17 or higher.
|
||||
|
||||
See our [Node Support Policy](node-support-policy.md) for our long-term promise regarding Node version support.
|
||||
|
||||
## Recommended solution
|
||||
|
||||
### Run at least one CI job with Node >= 10.18
|
||||
### Run at least one CI job with Node >= 14.17
|
||||
|
||||
The recommended approach is to run the `semantic-release` command from a CI job running on Node 10.18 or higher. This can either be a job used by your project to test on Node >= 10.18 or a dedicated job for the release steps.
|
||||
The recommended approach is to run the `semantic-release` command from a CI job running on Node 14.17 or higher.
|
||||
This can either be a job used by your project to test on Node >= 14.17 or a dedicated job for the release steps.
|
||||
|
||||
See [CI configuration](../usage/ci-configuration.md) and [CI configuration recipes](../recipes/README.md#ci-configurations) for more details.
|
||||
|
||||
@@ -18,18 +19,19 @@ See [CI configuration](../usage/ci-configuration.md) and [CI configuration recip
|
||||
|
||||
### Use `npx`
|
||||
|
||||
`npx` is included with npm >= 5.2 and can be used to download the latest [Node 8 package published on npm](https://www.npmjs.com/package/node). Use it to execute the `semantic-release` command.
|
||||
`npx` is included with npm >= 5.2 and can be used to download the latest [Node 14 package published on npm](https://www.npmjs.com/package/node).
|
||||
Use it to execute the `semantic-release` command.
|
||||
|
||||
```bash
|
||||
$ npx -p node@8 -c "npx semantic-release"
|
||||
$ npx -p node@14 -c "npx semantic-release"
|
||||
```
|
||||
|
||||
**Note:**: See [What is npx](./FAQ.md#what-is-npx) for more details.
|
||||
|
||||
### Use `nvm`
|
||||
|
||||
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can use it to switch to Node 8 before running the `semantic-release` command.
|
||||
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can use it to switch to Node 14.17 before running the `semantic-release` command.
|
||||
|
||||
```bash
|
||||
$ nvm install 8 && npx semantic-release
|
||||
$ nvm install 14.17 && npx semantic-release
|
||||
```
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
- ["Introduction to SemVer" - Irina Gebauer](https://blog.greenkeeper.io/introduction-to-semver-d272990c44f2)
|
||||
- ["Introduction to Semantic Release" - liv](https://blog.greenkeeper.io/introduction-to-semantic-release-33f73b117c8)
|
||||
- ["Series - Semantic Release Automation" - Abdelrahman Wahdan](https://dev.to/abdelrahmanahmed/semantic-release-and-how-to-automate-it-part-1-4pa2)
|
||||
- ["Explain semantic release and how to use it on GitLab pipeline"](https://regoo707.medium.com/auto-bump-apps-versions-and-releases-using-gitlab-pipeline-e32f1d7fa3ee)
|
||||
|
||||
## Tutorials
|
||||
|
||||
|
||||
@@ -65,5 +65,5 @@ To recover from that situation, do the following:
|
||||
|
||||
1. Delete the tag(s) for the release(s) that have been lost from the git history. You can delete each tag from remote using `git push origin :[TAG NAME]`, e.g. `git push origin :v2.0.0-beta.1`. You can delete tags locally using `git tag -d [TAG NAME]`, e.g. `git tag -d v2.0.0-beta.1`.
|
||||
2. Re-create the tags locally: `git tag [TAG NAME] [COMMIT HASH]`, where `[COMMIT HASH]` is the new commit that created the release for the lost tag. E.g. `git tag v2.0.0-beta.1 abcdef0`
|
||||
3. Re-create the git notes for each release tag, e.g. `git notes --ref semantic-release add -f -m '{"channels":["beta"]}' v3.0.0-beta.1`. If the release was also published in the default channel (usually `master`), then set the first channel to `null`, e.g. `git notes --ref semantic-release add -f -m '{"channels":[null, "beta"]}'
|
||||
3. Re-create the git notes for each release tag, e.g. `git notes --ref semantic-release add -f -m '{"channels":["beta"]}' v2.0.0-beta.1`. If the release was also published in the default channel (usually `master`), then set the first channel to `null`, e.g. `git notes --ref semantic-release add -f -m '{"channels":[null, "beta"]}'
|
||||
4. Push the local notes: `git push --force origin refs/notes/semantic-release`. The `--force` is needed after the rebase. Be careful.
|
||||
|
||||
@@ -8,7 +8,7 @@ Here is a few example of the CI services that can be used to achieve this:
|
||||
- [CircleCI Workflows](https://circleci.com/docs/2.0/workflows)
|
||||
- [GitHub Actions](https://github.com/features/actions)
|
||||
- [Codeship Deployment Pipelines](https://documentation.codeship.com/basic/builds-and-configuration/deployment-pipelines)
|
||||
- [GitLab Pipelines](https://docs.gitlab.com/ee/ci/pipelines.html#introduction-to-pipelines-and-jobs)
|
||||
- [GitLab Pipelines](https://docs.gitlab.com/ce/ci/introduction/)
|
||||
- [Codefresh Pipelines](https://codefresh.io/docs/docs/configure-ci-cd-pipeline/introduction-to-codefresh-pipelines)
|
||||
- [Wercker Workflows](http://devcenter.wercker.com/docs/workflows)
|
||||
- [GoCD Pipelines](https://docs.gocd.org/current/introduction/concepts_in_go.html#pipeline).
|
||||
|
||||
@@ -24,6 +24,7 @@ For other type of projects we recommend installing **semantic-release** directly
|
||||
$ npx semantic-release
|
||||
```
|
||||
|
||||
**Note**: For a global installation, it's recommended to specify the major **semantic-release** version to install (for example with with `npx semantic-release@15`). This way your build will not automatically use the next major **semantic-release** release that could possibly break your build. You will have to upgrade manually when a new major version is released.
|
||||
**Note**: For a global installation, it's recommended to specify the major **semantic-release** version to install (for example with with `npx semantic-release@18`).
|
||||
This way your build will not automatically use the next major **semantic-release** release that could possibly break your build. You will have to upgrade manually when a new major version is released.
|
||||
|
||||
**Note**: `npx` is a tool bundled with `npm@>=5.2.0`. It is used to conveniently install the semantic-release binary and to execute it. See [What is npx](../support/FAQ.md#what-is-npx) for more details.
|
||||
|
||||
@@ -16,6 +16,8 @@ A plugin is a npm module that can implement one or more of the following steps:
|
||||
| `success` | No | Responsible for notifying of a new release. |
|
||||
| `fail` | No | Responsible for notifying of a failed release. |
|
||||
|
||||
Release steps will run in that order. At each step, **semantic-release** will run every plugin in the [`plugins` array](#plugins-declaration-and-execution-order), as long as the plugin implements the step.
|
||||
|
||||
**Note:** If no plugin with a `analyzeCommits` step is defined `@semantic-release/commit-analyzer` will be used.
|
||||
|
||||
## Plugins installation
|
||||
@@ -70,6 +72,8 @@ With this configuration **semantic-release** will:
|
||||
- execute the `prepare` implementation of `@semantic-release/npm` then `@semantic-release/git`
|
||||
- execute the `publish` implementation of `@semantic-release/npm`
|
||||
|
||||
Order is first determined by release steps (such as `verifyConditions` → `anayzeCommits`). At each release step, plugins are executed in the order in which they are defined.
|
||||
|
||||
## Plugin options configuration
|
||||
|
||||
A plugin configuration can be specified by wrapping the name and an options object in an array. Options configured this way will be passed only to that specific plugin.
|
||||
|
||||
@@ -13,7 +13,7 @@ Each branch can be defined either as a string, a [glob](https://github.com/micro
|
||||
|
||||
A branch can defined as one of three types:
|
||||
- [release](#release-branches): to make releases on top of the last version released
|
||||
- [maintenance](#maintenance-branches): to make release on top of an old release
|
||||
- [maintenance](#maintenance-branches): to make releases on top of an old release
|
||||
- [pre-release](#pre-release-branches): to make pre-releases
|
||||
|
||||
The type of the branch is automatically determined based on naming convention and/or [properties](#branches-properties).
|
||||
@@ -25,7 +25,7 @@ The type of the branch is automatically determined based on naming convention an
|
||||
| `name` | All | **Required.** The Git branch holding the commits to analyze and the code to release. See [name](#name). | - The value itself if defined as a `String` or the matching branches name if defined as a glob. |
|
||||
| `channel` | All | The distribution channel on which to publish releases from this branch. Set to `false` to force the default distribution channel instead of using the default. See [channel](#channel). | `undefined` for the first release branch, the value of `name` for subsequent ones. |
|
||||
| `range` | [maintenance](#maintenance-branches) only | **Required unless `name` is formatted like `N.N.x` or `N.x` (`N` is a number).** The range of [semantic versions](https://semver.org) to support on this branch. See [range](#range). | The value of `name`. |
|
||||
| `prerelease` | [pre-release](#pre-release-branches) only | **Required.** The pre-release detonation to append to [semantic versions](https://semver.org) released from this branch. See [prerelease](#prerelease). | - |
|
||||
| `prerelease` | [pre-release](#pre-release-branches) only | **Required.** The pre-release denotation to append to [semantic versions](https://semver.org) released from this branch. See [prerelease](#prerelease). | - |
|
||||
|
||||
### name
|
||||
|
||||
@@ -162,7 +162,7 @@ With the configuration `"branches": ["1.0.x", "1.x", "master"]`, if the last rel
|
||||
### Pre-release branches
|
||||
|
||||
A pre-release branch is a type of branch used by **semantic-release** that allows to publish releases with a [pre-release version](https://semver.org/#spec-item-9).
|
||||
Using a pre-release version allow to publish multiple releases with the same version. Those release will be differentiated via there identifiers (in `1.0.0-alpha.1` the identifier is `alpha.1`).
|
||||
Using a pre-release version allow to publish multiple releases with the same version. Those release will be differentiated via their identifiers (in `1.0.0-alpha.1` the identifier is `alpha.1`).
|
||||
This is useful when you need to work on a future major release that will include many breaking changes but you do not want to increment the version number for each breaking change commit.
|
||||
|
||||
A pre-release branch is characterized by the `prerelease` property that defines the static part of the version released (in `1.0.0-alpha.1` the static part fo the identifier is `alpha`). The [`prerelease`](#prerelease) value of each pre-release branch must be unique across the project.
|
||||
|
||||
@@ -1,25 +1,28 @@
|
||||
const {pick} = require('lodash');
|
||||
const marked = require('marked');
|
||||
const TerminalRenderer = require('marked-terminal');
|
||||
const envCi = require('env-ci');
|
||||
const hookStd = require('hook-std');
|
||||
const semver = require('semver');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const pkg = require('./package.json');
|
||||
const hideSensitive = require('./lib/hide-sensitive');
|
||||
const getConfig = require('./lib/get-config');
|
||||
const verify = require('./lib/verify');
|
||||
const getNextVersion = require('./lib/get-next-version');
|
||||
const getCommits = require('./lib/get-commits');
|
||||
const getLastRelease = require('./lib/get-last-release');
|
||||
const getReleaseToAdd = require('./lib/get-release-to-add');
|
||||
const {extractErrors, makeTag} = require('./lib/utils');
|
||||
const getGitAuthUrl = require('./lib/get-git-auth-url');
|
||||
const getBranches = require('./lib/branches');
|
||||
const getLogger = require('./lib/get-logger');
|
||||
const {verifyAuth, isBranchUpToDate, getGitHead, tag, push, pushNotes, getTagHead, addNote} = require('./lib/git');
|
||||
const getError = require('./lib/get-error');
|
||||
const {COMMIT_NAME, COMMIT_EMAIL} = require('./lib/definitions/constants');
|
||||
import lodash from 'lodash'
|
||||
const {pick} = lodash
|
||||
import marked from 'marked';
|
||||
import TerminalRenderer from 'marked-terminal';
|
||||
import envCi from 'env-ci';
|
||||
import hookStd from 'hook-std';
|
||||
import semver from 'semver';
|
||||
import AggregateError from 'aggregate-error';
|
||||
import pkg from './package.json';
|
||||
import hideSensitive from './lib/hide-sensitive';
|
||||
import getConfig from './lib/get-config';
|
||||
import verify from './lib/verify';
|
||||
import getNextVersion from './lib/get-next-version';
|
||||
import getCommits from './lib/get-commits';
|
||||
import getLastRelease from './lib/get-last-release';
|
||||
import getReleaseToAdd from './lib/get-release-to-add';
|
||||
import {extractErrors, makeTag} from './lib/utils';
|
||||
import getGitAuthUrl from './lib/get-git-auth-url';
|
||||
import getBranches from './lib/branches';
|
||||
import getLogger from './lib/get-logger';
|
||||
|
||||
import {verifyAuth, isBranchUpToDate, getGitHead, tag, push, pushNotes, getTagHead, addNote} from './lib/git';
|
||||
|
||||
import getError from './lib/get-error';
|
||||
import {COMMIT_NAME, COMMIT_EMAIL} from './lib/definitions/constants';
|
||||
|
||||
marked.setOptions({renderer: new TerminalRenderer()});
|
||||
|
||||
@@ -239,7 +242,7 @@ async function callFail(context, plugins, err) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = async (cliOptions = {}, {cwd = process.cwd(), env = process.env, stdout, stderr} = {}) => {
|
||||
export default async (cliOptions = {}, {cwd = process.cwd(), env = process.env, stdout, stderr} = {}) => {
|
||||
const {unhook} = hookStd(
|
||||
{silent: false, streams: [process.stdout, process.stderr, stdout, stderr].filter(Boolean)},
|
||||
hideSensitive(env)
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const {isString, remove, omit, mapValues, template} = require('lodash');
|
||||
const micromatch = require('micromatch');
|
||||
const {getBranches} = require('../git');
|
||||
import lodash from 'lodash'
|
||||
const {isString, remove, omit, mapValues, template} = lodash
|
||||
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(
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
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 lodash from 'lodash'
|
||||
const {template, escapeRegExp} = lodash
|
||||
import semver from 'semver';
|
||||
import pReduce from 'p-reduce';
|
||||
import debugFactory from 'debug';
|
||||
const debug = debugFactory('semantic-release:get-tags');
|
||||
import {getTags, getNote} from '../../lib/git.js';
|
||||
|
||||
module.exports = 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,
|
||||
|
||||
+11
-10
@@ -1,14 +1,15 @@
|
||||
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 lodash from 'lodash'
|
||||
const {isString, isRegExp} = lodash
|
||||
import AggregateError from 'aggregate-error';
|
||||
import pEachSeries from 'p-each-series';
|
||||
import 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 normalize from './normalize.js';
|
||||
|
||||
module.exports = async (repositoryUrl, ciBranch, context) => {
|
||||
export default async (repositoryUrl, ciBranch, context) => {
|
||||
const {cwd, env} = context;
|
||||
|
||||
const remoteBranches = await expand(
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
const {sortBy, isNil} = require('lodash');
|
||||
const semverDiff = require('semver-diff');
|
||||
const {FIRST_RELEASE, RELEASE_TYPE} = require('../definitions/constants');
|
||||
const {
|
||||
import lodash from 'lodash'
|
||||
const {sortBy, isNil} = lodash
|
||||
import semverDiff from 'semver-diff';
|
||||
import {FIRST_RELEASE, RELEASE_TYPE} from '../definitions/constants.js';
|
||||
|
||||
import {
|
||||
tagsToVersions,
|
||||
isMajorRange,
|
||||
getUpperBound,
|
||||
@@ -11,7 +13,7 @@ const {
|
||||
getLatestVersion,
|
||||
getFirstVersion,
|
||||
getRange,
|
||||
} = require('../utils');
|
||||
} from '../utils.js';
|
||||
|
||||
function maintenance({maintenance, release}) {
|
||||
return sortBy(
|
||||
@@ -103,4 +105,11 @@ function prerelease({prerelease}) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = {maintenance, release, prerelease};
|
||||
const exported = {
|
||||
maintenance,
|
||||
release,
|
||||
prerelease,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {maintenance, release, prerelease};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const {isNil, uniqBy} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const {isMaintenanceRange} = require('../utils');
|
||||
import lodash from 'lodash'
|
||||
const {isNil, uniqBy} = lodash
|
||||
import semver from 'semver';
|
||||
import {isMaintenanceRange} from '../utils.js';
|
||||
|
||||
const maintenance = {
|
||||
filter: ({name, range}) => (!isNil(range) && range !== false) || isMaintenanceRange(name),
|
||||
@@ -20,4 +21,11 @@ const release = {
|
||||
branchesValidator: (branches) => branches.length <= 3 && branches.length > 0,
|
||||
};
|
||||
|
||||
module.exports = {maintenance, prerelease, release};
|
||||
const exported = {
|
||||
maintenance,
|
||||
prerelease,
|
||||
release,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {maintenance, prerelease, release};
|
||||
|
||||
@@ -16,7 +16,20 @@ const SECRET_MIN_SIZE = 5;
|
||||
|
||||
const GIT_NOTE_REF = 'semantic-release';
|
||||
|
||||
module.exports = {
|
||||
const exported = {
|
||||
RELEASE_TYPE,
|
||||
FIRST_RELEASE,
|
||||
FIRSTPRERELEASE,
|
||||
COMMIT_NAME,
|
||||
COMMIT_EMAIL,
|
||||
RELEASE_NOTES_SEPARATOR,
|
||||
SECRET_REPLACEMENT,
|
||||
SECRET_MIN_SIZE,
|
||||
GIT_NOTE_REF,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {
|
||||
RELEASE_TYPE,
|
||||
FIRST_RELEASE,
|
||||
FIRSTPRERELEASE,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const {inspect} = require('util');
|
||||
const {toLower, isString, trim} = require('lodash');
|
||||
const pkg = require('../../package.json');
|
||||
const {RELEASE_TYPE} = require('./constants');
|
||||
import {inspect} from 'util';
|
||||
import lodash from 'lodash'
|
||||
const {toLower, isString, trim} = lodash
|
||||
import pkg from '../../package.json';
|
||||
import {RELEASE_TYPE} from './constants.js';
|
||||
|
||||
const [homepage] = pkg.homepage.split('#');
|
||||
const stringify = (object) =>
|
||||
@@ -10,7 +11,7 @@ const linkify = (file) => `${homepage}/blob/master/${file}`;
|
||||
const wordsList = (words) =>
|
||||
`${words.slice(0, -1).join(', ')}${words.length > 1 ? ` or ${words[words.length - 1]}` : trim(words[0])}`;
|
||||
|
||||
module.exports = {
|
||||
const exported = {
|
||||
ENOGITREPO: ({cwd}) => ({
|
||||
message: 'Not running from a git repository.',
|
||||
details: `The \`semantic-release\` command must be executed from a Git repository.
|
||||
@@ -19,6 +20,7 @@ The current working directory is \`${cwd}\`.
|
||||
|
||||
Please verify your CI configuration to make sure the \`semantic-release\` command is executed from the root of the cloned repository.`,
|
||||
}),
|
||||
|
||||
ENOREPOURL: () => ({
|
||||
message: 'The `repositoryUrl` option is required.',
|
||||
details: `The [repositoryUrl option](${linkify(
|
||||
@@ -29,6 +31,7 @@ Please make sure to add the \`repositoryUrl\` to the [semantic-release configura
|
||||
'docs/usage/configuration.md'
|
||||
)}).`,
|
||||
}),
|
||||
|
||||
EGITNOPERMISSION: ({options: {repositoryUrl}, branch: {name}}) => ({
|
||||
message: 'Cannot push to the Git repository.',
|
||||
details: `**semantic-release** cannot push the version tag to the branch \`${name}\` on the remote Git repository with URL \`${repositoryUrl}\`.
|
||||
@@ -40,6 +43,7 @@ This can be caused by:
|
||||
'docs/usage/ci-configuration.md#authentication'
|
||||
)})`,
|
||||
}),
|
||||
|
||||
EINVALIDTAGFORMAT: ({options: {tagFormat}}) => ({
|
||||
message: 'Invalid `tagFormat` option.',
|
||||
details: `The [tagFormat](${linkify(
|
||||
@@ -48,6 +52,7 @@ This can be caused by:
|
||||
|
||||
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
||||
}),
|
||||
|
||||
ETAGNOVERSION: ({options: {tagFormat}}) => ({
|
||||
message: 'Invalid `tagFormat` option.',
|
||||
details: `The [tagFormat](${linkify(
|
||||
@@ -56,22 +61,25 @@ Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`
|
||||
|
||||
Your configuration for the \`tagFormat\` option is \`${stringify(tagFormat)}\`.`,
|
||||
}),
|
||||
|
||||
EPLUGINCONF: ({type, required, pluginConf}) => ({
|
||||
message: `The \`${type}\` plugin configuration is invalid.`,
|
||||
details: `The [${type} plugin configuration](${linkify(`docs/usage/plugins.md#${toLower(type)}-plugin`)}) ${
|
||||
required ? 'is required and ' : ''
|
||||
} must be a single or an array of plugins definition. A plugin definition is an npm module name, optionnaly wrapped in an array with an object.
|
||||
} must be a single or an array of plugins definition. A plugin definition is an npm module name, optionally wrapped in an array with an object.
|
||||
|
||||
Your configuration for the \`${type}\` plugin is \`${stringify(pluginConf)}\`.`,
|
||||
}),
|
||||
|
||||
EPLUGINSCONF: ({plugin}) => ({
|
||||
message: 'The `plugins` configuration is invalid.',
|
||||
details: `The [plugins](${linkify(
|
||||
'docs/usage/configuration.md#plugins'
|
||||
)}) option must be an array of plugin definions. A plugin definition is an npm module name, optionnaly wrapped in an array with an object.
|
||||
)}) option must be an array of plugin definions. A plugin definition is an npm module name, optionally wrapped in an array with an object.
|
||||
|
||||
The invalid configuration is \`${stringify(plugin)}\`.`,
|
||||
}),
|
||||
|
||||
EPLUGIN: ({pluginName, type}) => ({
|
||||
message: `A plugin configured in the step ${type} is not a valid semantic-release plugin.`,
|
||||
details: `A valid \`${type}\` **semantic-release** plugin must be a function or an object with a function in the property \`${type}\`.
|
||||
@@ -82,6 +90,7 @@ Please refer to the \`${pluginName}\` and [semantic-release plugins configuratio
|
||||
'docs/usage/plugins.md'
|
||||
)}) documentation for more details.`,
|
||||
}),
|
||||
|
||||
EANALYZECOMMITSOUTPUT: ({result, pluginName}) => ({
|
||||
message: 'The `analyzeCommits` plugin returned an invalid value. It must return a valid semver release type.',
|
||||
details: `The \`analyzeCommits\` plugin must return a valid [semver](https://semver.org) release type. The valid values are: ${RELEASE_TYPE.map(
|
||||
@@ -98,6 +107,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
||||
'docs/developer-guide/plugin.md'
|
||||
)})`,
|
||||
}),
|
||||
|
||||
EGENERATENOTESOUTPUT: ({result, pluginName}) => ({
|
||||
message: 'The `generateNotes` plugin returned an invalid value. It must return a `String`.',
|
||||
details: `The \`generateNotes\` plugin must return a \`String\`.
|
||||
@@ -112,6 +122,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
||||
'docs/developer-guide/plugin.md'
|
||||
)})`,
|
||||
}),
|
||||
|
||||
EPUBLISHOUTPUT: ({result, pluginName}) => ({
|
||||
message: 'A `publish` plugin returned an invalid value. It must return an `Object`.',
|
||||
details: `The \`publish\` plugins must return an \`Object\`.
|
||||
@@ -126,6 +137,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
||||
'docs/developer-guide/plugin.md'
|
||||
)})`,
|
||||
}),
|
||||
|
||||
EADDCHANNELOUTPUT: ({result, pluginName}) => ({
|
||||
message: 'A `addChannel` plugin returned an invalid value. It must return an `Object`.',
|
||||
details: `The \`addChannel\` plugins must return an \`Object\`.
|
||||
@@ -140,6 +152,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
||||
'docs/developer-guide/plugin.md'
|
||||
)})`,
|
||||
}),
|
||||
|
||||
EINVALIDBRANCH: ({branch}) => ({
|
||||
message: 'A branch is invalid in the `branches` configuration.',
|
||||
details: `Each branch in the [branches configuration](${linkify(
|
||||
@@ -148,6 +161,7 @@ We recommend to report the issue to the \`${pluginName}\` authors, providing the
|
||||
|
||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
}),
|
||||
|
||||
EINVALIDBRANCHNAME: ({branch}) => ({
|
||||
message: 'A branch name is invalid in the `branches` configuration.',
|
||||
details: `Each branch in the [branches configuration](${linkify(
|
||||
@@ -156,6 +170,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
|
||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
}),
|
||||
|
||||
EDUPLICATEBRANCHES: ({duplicates}) => ({
|
||||
message: 'The `branches` configuration has duplicate branches.',
|
||||
details: `Each branch in the [branches configuration](${linkify(
|
||||
@@ -164,6 +179,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
|
||||
Your configuration contains duplicates for the following branch names: \`${stringify(duplicates)}\`.`,
|
||||
}),
|
||||
|
||||
EMAINTENANCEBRANCH: ({branch}) => ({
|
||||
message: 'A maintenance branch is invalid in the `branches` configuration.',
|
||||
details: `Each maintenance branch in the [branches configuration](${linkify(
|
||||
@@ -172,6 +188,7 @@ Your configuration contains duplicates for the following branch names: \`${strin
|
||||
|
||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
}),
|
||||
|
||||
EMAINTENANCEBRANCHES: ({branches}) => ({
|
||||
message: 'The maintenance branches are invalid in the `branches` configuration.',
|
||||
details: `Each maintenance branch in the [branches configuration](${linkify(
|
||||
@@ -180,6 +197,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
|
||||
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
||||
}),
|
||||
|
||||
ERELEASEBRANCHES: ({branches}) => ({
|
||||
message: 'The release branches are invalid in the `branches` configuration.',
|
||||
details: `A minimum of 1 and a maximum of 3 release branches are required in the [branches configuration](${linkify(
|
||||
@@ -190,6 +208,7 @@ This may occur if your repository does not have a release branch, such as \`mast
|
||||
|
||||
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
||||
}),
|
||||
|
||||
EPRERELEASEBRANCH: ({branch}) => ({
|
||||
message: 'A pre-release branch configuration is invalid in the `branches` configuration.',
|
||||
details: `Each pre-release branch in the [branches configuration](${linkify(
|
||||
@@ -198,6 +217,7 @@ Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
||||
|
||||
Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
}),
|
||||
|
||||
EPRERELEASEBRANCHES: ({branches}) => ({
|
||||
message: 'The pre-release branches are invalid in the `branches` configuration.',
|
||||
details: `Each pre-release branch in the [branches configuration](${linkify(
|
||||
@@ -206,6 +226,7 @@ Your configuration for the problematic branch is \`${stringify(branch)}\`.`,
|
||||
|
||||
Your configuration for the problematic branches is \`${stringify(branches)}\`.`,
|
||||
}),
|
||||
|
||||
EINVALIDNEXTVERSION: ({nextRelease: {version}, branch: {name, range}, commits, validBranches}) => ({
|
||||
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
||||
details: `Based on the releases published on other branches, only versions within the range \`${range}\` can be published from branch \`${name}\`.
|
||||
@@ -221,6 +242,7 @@ A valid branch could be ${wordsList(validBranches.map(({name}) => `\`${name}\``)
|
||||
|
||||
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
||||
}),
|
||||
|
||||
EINVALIDMAINTENANCEMERGE: ({nextRelease: {channel, gitTag, version}, branch: {mergeRange, name}}) => ({
|
||||
message: `The release \`${version}\` on branch \`${name}\` cannot be published as it is out of range.`,
|
||||
details: `Only releases within the range \`${mergeRange}\` can be merged into the maintenance branch \`${name}\` and published to the \`${channel}\` distribution channel.
|
||||
@@ -230,3 +252,30 @@ The branch \`${name}\` head should be [reset](https://git-scm.com/docs/git-reset
|
||||
See the [workflow configuration documentation](${linkify('docs/usage/workflow-configuration.md')}) for more details.`,
|
||||
}),
|
||||
};
|
||||
|
||||
export default exported;
|
||||
|
||||
export const {
|
||||
ENOGITREPO,
|
||||
ENOREPOURL,
|
||||
EGITNOPERMISSION,
|
||||
EINVALIDTAGFORMAT,
|
||||
ETAGNOVERSION,
|
||||
EPLUGINCONF,
|
||||
EPLUGINSCONF,
|
||||
EPLUGIN,
|
||||
EANALYZECOMMITSOUTPUT,
|
||||
EGENERATENOTESOUTPUT,
|
||||
EPUBLISHOUTPUT,
|
||||
EADDCHANNELOUTPUT,
|
||||
EINVALIDBRANCH,
|
||||
EINVALIDBRANCHNAME,
|
||||
EDUPLICATEBRANCHES,
|
||||
EMAINTENANCEBRANCH,
|
||||
EMAINTENANCEBRANCHES,
|
||||
ERELEASEBRANCHES,
|
||||
EPRERELEASEBRANCH,
|
||||
EPRERELEASEBRANCHES,
|
||||
EINVALIDNEXTVERSION,
|
||||
EINVALIDMAINTENANCEMERGE,
|
||||
} = exported;
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
/* eslint require-atomic-updates: off */
|
||||
import lodash from 'lodash'
|
||||
const {isString, isPlainObject} = lodash
|
||||
|
||||
const {isString, isPlainObject} = require('lodash');
|
||||
const {getGitHead} = require('../git');
|
||||
const hideSensitive = require('../hide-sensitive');
|
||||
const {hideSensitiveValues} = require('../utils');
|
||||
const {RELEASE_TYPE, RELEASE_NOTES_SEPARATOR} = require('./constants');
|
||||
import {getGitHead} from '../git.js';
|
||||
import hideSensitive from '../hide-sensitive.js';
|
||||
import {hideSensitiveValues} from '../utils.js';
|
||||
import {RELEASE_TYPE, RELEASE_NOTES_SEPARATOR} from './constants.js';
|
||||
|
||||
module.exports = {
|
||||
const exported = {
|
||||
verifyConditions: {
|
||||
required: false,
|
||||
dryRun: true,
|
||||
pipelineConfig: () => ({settleAll: true}),
|
||||
},
|
||||
|
||||
analyzeCommits: {
|
||||
default: ['@semantic-release/commit-analyzer'],
|
||||
required: true,
|
||||
@@ -29,11 +30,13 @@ module.exports = {
|
||||
}, -1)
|
||||
],
|
||||
},
|
||||
|
||||
verifyRelease: {
|
||||
required: false,
|
||||
dryRun: true,
|
||||
pipelineConfig: () => ({settleAll: true}),
|
||||
},
|
||||
|
||||
generateNotes: {
|
||||
required: false,
|
||||
dryRun: true,
|
||||
@@ -49,6 +52,7 @@ module.exports = {
|
||||
}),
|
||||
postprocess: (results, {env}) => hideSensitive(env)(results.filter(Boolean).join(RELEASE_NOTES_SEPARATOR)),
|
||||
},
|
||||
|
||||
prepare: {
|
||||
required: false,
|
||||
dryRun: false,
|
||||
@@ -67,6 +71,7 @@ module.exports = {
|
||||
},
|
||||
}),
|
||||
},
|
||||
|
||||
publish: {
|
||||
required: false,
|
||||
dryRun: false,
|
||||
@@ -80,6 +85,7 @@ module.exports = {
|
||||
}),
|
||||
}),
|
||||
},
|
||||
|
||||
addChannel: {
|
||||
required: false,
|
||||
dryRun: false,
|
||||
@@ -93,12 +99,14 @@ module.exports = {
|
||||
}),
|
||||
}),
|
||||
},
|
||||
|
||||
success: {
|
||||
required: false,
|
||||
dryRun: false,
|
||||
pipelineConfig: () => ({settleAll: true}),
|
||||
preprocess: ({releases, env, ...inputs}) => ({...inputs, env, releases: hideSensitiveValues(env, releases)}),
|
||||
},
|
||||
|
||||
fail: {
|
||||
required: false,
|
||||
dryRun: false,
|
||||
@@ -106,3 +114,17 @@ module.exports = {
|
||||
preprocess: ({errors, env, ...inputs}) => ({...inputs, env, errors: hideSensitiveValues(env, errors)}),
|
||||
},
|
||||
};
|
||||
|
||||
export default exported;
|
||||
|
||||
export const {
|
||||
verifyConditions,
|
||||
analyzeCommits,
|
||||
verifyRelease,
|
||||
generateNotes,
|
||||
prepare,
|
||||
publish,
|
||||
addChannel,
|
||||
success,
|
||||
fail,
|
||||
} = exported;
|
||||
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
const debug = require('debug')('semantic-release:get-commits');
|
||||
const {getCommits} = require('./git');
|
||||
import debugFactory from 'debug';
|
||||
const debug = debugFactory('semantic-release:get-commits');
|
||||
import {getCommits} from './git.js';
|
||||
|
||||
/**
|
||||
* Retrieve the list of commits on the current branch since the commit sha associated with the last release, or all the commits of the current branch if there is no last released version.
|
||||
@@ -8,7 +9,7 @@ const {getCommits} = require('./git');
|
||||
*
|
||||
* @return {Promise<Array<Object>>} The list of commits on the branch `branch` since the last release.
|
||||
*/
|
||||
module.exports = async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
|
||||
export default async ({cwd, env, lastRelease: {gitHead: from}, nextRelease: {gitHead: to = 'HEAD'} = {}, logger}) => {
|
||||
if (from) {
|
||||
debug('Use from: %s', from);
|
||||
} else {
|
||||
|
||||
+13
-20
@@ -1,27 +1,20 @@
|
||||
const {castArray, pickBy, isNil, isString, isPlainObject} = require('lodash');
|
||||
const readPkgUp = require('read-pkg-up');
|
||||
const {cosmiconfig} = require('cosmiconfig');
|
||||
const resolveFrom = require('resolve-from');
|
||||
const debug = require('debug')('semantic-release:config');
|
||||
const {repoUrl} = require('./git');
|
||||
const PLUGINS_DEFINITIONS = require('./definitions/plugins');
|
||||
const plugins = require('./plugins');
|
||||
const {validatePlugin, parseConfig} = require('./plugins/utils');
|
||||
import lodash from 'lodash'
|
||||
const {castArray, pickBy, isNil, isString, isPlainObject} = lodash
|
||||
import readPkgUp from 'read-pkg-up';
|
||||
import {cosmiconfig} from 'cosmiconfig';
|
||||
import resolveFrom from 'resolve-from';
|
||||
import debugFactory from 'debug';
|
||||
const debug = debugFactory('semantic-release:config');
|
||||
import {repoUrl} from './git.js';
|
||||
import PLUGINS_DEFINITIONS from './definitions/plugins.js';
|
||||
import plugins from './plugins';
|
||||
import {validatePlugin, parseConfig} from './plugins/utils.js';
|
||||
|
||||
const CONFIG_NAME = 'release';
|
||||
const CONFIG_FILES = [
|
||||
'package.json',
|
||||
`.${CONFIG_NAME}rc`,
|
||||
`.${CONFIG_NAME}rc.json`,
|
||||
`.${CONFIG_NAME}rc.yaml`,
|
||||
`.${CONFIG_NAME}rc.yml`,
|
||||
`.${CONFIG_NAME}rc.js`,
|
||||
`${CONFIG_NAME}.config.js`,
|
||||
];
|
||||
|
||||
module.exports = async (context, cliOptions) => {
|
||||
export default async (context, cliOptions) => {
|
||||
const {cwd, env} = context;
|
||||
const {config, filepath} = (await cosmiconfig(CONFIG_NAME, {searchPlaces: CONFIG_FILES}).search(cwd)) || {};
|
||||
const {config, filepath} = (await cosmiconfig(CONFIG_NAME).search(cwd)) || {};
|
||||
|
||||
debug('load config from: %s', filepath);
|
||||
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
const SemanticReleaseError = require('@semantic-release/error');
|
||||
const ERROR_DEFINITIONS = require('./definitions/errors');
|
||||
import SemanticReleaseError from '@semantic-release/error';
|
||||
import ERROR_DEFINITIONS from './definitions/errors.js';
|
||||
|
||||
module.exports = (code, ctx = {}) => {
|
||||
export default (code, ctx = {}) => {
|
||||
const {message, details} = ERROR_DEFINITIONS[code](ctx);
|
||||
return new SemanticReleaseError(message, code, details);
|
||||
};
|
||||
|
||||
+10
-8
@@ -1,8 +1,10 @@
|
||||
const {parse, format} = require('url'); // eslint-disable-line node/no-deprecated-api
|
||||
const {isNil} = require('lodash');
|
||||
const hostedGitInfo = require('hosted-git-info');
|
||||
const {verifyAuth} = require('./git');
|
||||
const debug = require('debug')('semantic-release:get-git-auth-url');
|
||||
import {format} from 'url';
|
||||
import lodash from 'lodash'
|
||||
const {isNil} = lodash
|
||||
import hostedGitInfo from 'hosted-git-info';
|
||||
import {verifyAuth} from './git.js';
|
||||
import debugFactory from 'debug';
|
||||
const debug = debugFactory('semantic-release:get-git-auth-url');
|
||||
|
||||
/**
|
||||
* Machinery to format a repository URL with the given credentials
|
||||
@@ -16,7 +18,7 @@ const debug = require('debug')('semantic-release:get-git-auth-url');
|
||||
function formatAuthUrl(protocol, repositoryUrl, gitCredentials) {
|
||||
const [match, auth, host, basePort, path] =
|
||||
/^(?!.+:\/\/)(?:(?<auth>.*)@)?(?<host>.*?):(?<port>\d+)?:?\/?(?<path>.*)$/.exec(repositoryUrl) || [];
|
||||
const {port, hostname, ...parsed} = parse(
|
||||
const {port, hostname, ...parsed} = new URL(
|
||||
match ? `ssh://${auth ? `${auth}@` : ''}${host}${basePort ? `:${basePort}` : ''}/${path}` : repositoryUrl
|
||||
);
|
||||
|
||||
@@ -57,7 +59,7 @@ async function ensureValidAuthUrl({cwd, env, branch}, authUrl) {
|
||||
*
|
||||
* @return {String} The formatted Git repository URL.
|
||||
*/
|
||||
module.exports = async (context) => {
|
||||
export default async (context) => {
|
||||
const {cwd, env, branch} = context;
|
||||
const GIT_TOKENS = {
|
||||
GIT_CREDENTIALS: undefined,
|
||||
@@ -75,7 +77,7 @@ module.exports = async (context) => {
|
||||
|
||||
let {repositoryUrl} = context.options;
|
||||
const info = hostedGitInfo.fromUrl(repositoryUrl, {noGitPlus: true});
|
||||
const {protocol, ...parsed} = parse(repositoryUrl);
|
||||
const {protocol, ...parsed} = new URL(repositoryUrl);
|
||||
|
||||
if (info && info.getDefaultRepresentation() === 'shortcut') {
|
||||
// Expand shorthand URLs (such as `owner/repo` or `gitlab:owner/repo`)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const {isUndefined} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const {makeTag, isSameChannel} = require('./utils');
|
||||
import lodash from 'lodash'
|
||||
const {isUndefined} = lodash
|
||||
import semver from 'semver';
|
||||
import {makeTag, isSameChannel} from './utils.js';
|
||||
|
||||
/**
|
||||
* Last release.
|
||||
@@ -26,7 +27,7 @@ const {makeTag, isSameChannel} = require('./utils');
|
||||
*
|
||||
* @return {LastRelease} The last tagged release or empty object if none is found.
|
||||
*/
|
||||
module.exports = ({branch, options: {tagFormat}}, {before} = {}) => {
|
||||
export default ({branch, options: {tagFormat}}, {before} = {}) => {
|
||||
const [{version, gitTag, channels} = {}] = branch.tags
|
||||
.filter(
|
||||
(tag) =>
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
const {Signale} = require('signale');
|
||||
const figures = require('figures');
|
||||
import {Signale} from 'signale';
|
||||
import figures from 'figures';
|
||||
|
||||
module.exports = ({stdout, stderr}) =>
|
||||
export default ({stdout, stderr}) =>
|
||||
new Signale({
|
||||
config: {displayTimestamp: true, underlineMessage: false, displayLabel: false},
|
||||
disabled: false,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const semver = require('semver');
|
||||
const {FIRST_RELEASE, FIRSTPRERELEASE} = require('./definitions/constants');
|
||||
const {isSameChannel, getLatestVersion, tagsToVersions, highest} = require('./utils');
|
||||
import semver from 'semver';
|
||||
import {FIRST_RELEASE, FIRSTPRERELEASE} from './definitions/constants.js';
|
||||
import {isSameChannel, getLatestVersion, tagsToVersions, highest} from './utils.js';
|
||||
|
||||
module.exports = ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
|
||||
export default ({branch, nextRelease: {type, channel}, lastRelease, logger}) => {
|
||||
let version;
|
||||
if (lastRelease.version) {
|
||||
const {major, minor, patch} = semver.parse(lastRelease.version);
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
const {uniqBy, intersection} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const semverDiff = require('semver-diff');
|
||||
const getLastRelease = require('./get-last-release');
|
||||
const {makeTag, getLowerBound} = require('./utils');
|
||||
import lodash from 'lodash'
|
||||
const {uniqBy, intersection} = lodash
|
||||
import semver from 'semver';
|
||||
import semverDiff from 'semver-diff';
|
||||
import getLastRelease from './get-last-release.js';
|
||||
import {makeTag, getLowerBound} from './utils.js';
|
||||
|
||||
/**
|
||||
* Find releases that have been merged from from a higher branch but not added on the channel of the current branch.
|
||||
@@ -11,7 +12,7 @@ const {makeTag, getLowerBound} = require('./utils');
|
||||
*
|
||||
* @return {Array<Object>} Last release and next release to be added on the channel of the current branch.
|
||||
*/
|
||||
module.exports = (context) => {
|
||||
export default (context) => {
|
||||
const {
|
||||
branch,
|
||||
branches,
|
||||
|
||||
+31
-7
@@ -1,8 +1,9 @@
|
||||
const gitLogParser = require('git-log-parser');
|
||||
const getStream = require('get-stream');
|
||||
const execa = require('execa');
|
||||
const debug = require('debug')('semantic-release:git');
|
||||
const {GIT_NOTE_REF} = require('./definitions/constants');
|
||||
import gitLogParser from 'git-log-parser';
|
||||
import getStream from 'get-stream';
|
||||
import execa from 'execa';
|
||||
import debugFactory from 'debug';
|
||||
const debug = debugFactory('semantic-release:git');
|
||||
import {GIT_NOTE_REF} from './definitions/constants.js';
|
||||
|
||||
Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
|
||||
|
||||
@@ -318,7 +319,7 @@ async function getNote(ref, execaOptions) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get and parse the JSON note of a given reference.
|
||||
* Add JSON note to a given reference.
|
||||
*
|
||||
* @param {Object} note The object to save in the reference note.
|
||||
* @param {String} ref The Git reference to add the note to.
|
||||
@@ -328,7 +329,30 @@ async function addNote(note, ref, execaOptions) {
|
||||
await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'add', '-f', '-m', JSON.stringify(note), ref], execaOptions);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
const exported = {
|
||||
getTagHead,
|
||||
getTags,
|
||||
getCommits,
|
||||
getBranches,
|
||||
isRefExists,
|
||||
fetch,
|
||||
fetchNotes,
|
||||
getGitHead,
|
||||
repoUrl,
|
||||
isGitRepo,
|
||||
verifyAuth,
|
||||
tag,
|
||||
push,
|
||||
pushNotes,
|
||||
verifyTagName,
|
||||
isBranchUpToDate,
|
||||
verifyBranchName,
|
||||
getNote,
|
||||
addNote,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {
|
||||
getTagHead,
|
||||
getTags,
|
||||
getCommits,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const {escapeRegExp, size, isString} = require('lodash');
|
||||
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('./definitions/constants');
|
||||
import lodash from 'lodash'
|
||||
const {escapeRegExp, size, isString} = lodash
|
||||
import {SECRET_REPLACEMENT, SECRET_MIN_SIZE} from './definitions/constants.js';
|
||||
|
||||
module.exports = (env) => {
|
||||
export default (env) => {
|
||||
const toReplace = Object.keys(env).filter((envVar) => {
|
||||
// https://github.com/semantic-release/semantic-release/issues/1558
|
||||
if (envVar === 'GOPRIVATE') {
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
const {identity, isPlainObject, omit, castArray, isNil, isString} = require('lodash');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const getError = require('../get-error');
|
||||
const PLUGINS_DEFINITIONS = require('../definitions/plugins');
|
||||
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('./utils');
|
||||
const pipeline = require('./pipeline');
|
||||
const normalize = require('./normalize');
|
||||
import lodash from 'lodash'
|
||||
const {identity, isPlainObject, omit, castArray, isNil, isString} = lodash
|
||||
import AggregateError from 'aggregate-error';
|
||||
import getError from '../get-error.js';
|
||||
import PLUGINS_DEFINITIONS from '../definitions/plugins.js';
|
||||
import {validatePlugin, validateStep, loadPlugin, parseConfig} from './utils.js';
|
||||
import pipeline from './pipeline.js';
|
||||
import normalize from './normalize.js';
|
||||
|
||||
module.exports = (context, pluginsPath) => {
|
||||
export default (context, pluginsPath) => {
|
||||
let {options, logger} = context;
|
||||
const errors = [];
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
const {isPlainObject, isFunction, noop, cloneDeep, omit} = require('lodash');
|
||||
const debug = require('debug')('semantic-release:plugins');
|
||||
const getError = require('../get-error');
|
||||
const {extractErrors} = require('../utils');
|
||||
const PLUGINS_DEFINITIONS = require('../definitions/plugins');
|
||||
const {loadPlugin, parseConfig} = require('./utils');
|
||||
import lodash from 'lodash'
|
||||
const {isPlainObject, isFunction, noop, cloneDeep, omit} = lodash
|
||||
import debugFactory from 'debug';
|
||||
const debug = debugFactory('semantic-release:plugins');
|
||||
import getError from '../get-error.js';
|
||||
import {extractErrors} from '../utils.js';
|
||||
import PLUGINS_DEFINITIONS from '../definitions/plugins.js';
|
||||
import {loadPlugin, parseConfig} from './utils.js';
|
||||
|
||||
module.exports = (context, type, pluginOpt, pluginsPath) => {
|
||||
export default (context, type, pluginOpt, pluginsPath) => {
|
||||
const {stdout, stderr, options, logger} = context;
|
||||
if (!pluginOpt) {
|
||||
return noop;
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const {identity} = require('lodash');
|
||||
const pReduce = require('p-reduce');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const {extractErrors} = require('../utils');
|
||||
import lodash from 'lodash'
|
||||
const {identity} = lodash
|
||||
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,7 +26,7 @@ const {extractErrors} = require('../utils');
|
||||
*
|
||||
* @return {Pipeline} A Function that execute the `steps` sequencially
|
||||
*/
|
||||
module.exports = (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async (input) => {
|
||||
export default (steps, {settleAll = false, getNextInput = identity, transform = identity} = {}) => async (input) => {
|
||||
const results = [];
|
||||
const errors = [];
|
||||
await pReduce(
|
||||
|
||||
+13
-4
@@ -1,6 +1,7 @@
|
||||
const {dirname} = require('path');
|
||||
const {isString, isFunction, castArray, isArray, isPlainObject, isNil} = require('lodash');
|
||||
const resolveFrom = require('resolve-from');
|
||||
import {dirname} from 'path';
|
||||
import lodash from 'lodash'
|
||||
const {isString, isFunction, castArray, isArray, isPlainObject, isNil} = lodash
|
||||
import resolveFrom from 'resolve-from';
|
||||
|
||||
const validateSteps = (conf) => {
|
||||
return conf.every((conf) => {
|
||||
@@ -65,4 +66,12 @@ function parseConfig(plugin) {
|
||||
return [path, config || {}];
|
||||
}
|
||||
|
||||
module.exports = {validatePlugin, validateStep, loadPlugin, parseConfig};
|
||||
const exported = {
|
||||
validatePlugin,
|
||||
validateStep,
|
||||
loadPlugin,
|
||||
parseConfig,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {validatePlugin, validateStep, loadPlugin, parseConfig};
|
||||
|
||||
+24
-4
@@ -1,6 +1,7 @@
|
||||
const {isFunction, union, template} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const hideSensitive = require('./hide-sensitive');
|
||||
import lodash from 'lodash'
|
||||
const {isFunction, union, template} = lodash
|
||||
import semver from 'semver';
|
||||
import hideSensitive from './hide-sensitive.js';
|
||||
|
||||
function extractErrors(err) {
|
||||
return err && isFunction(err[Symbol.iterator]) ? [...err] : [err];
|
||||
@@ -82,7 +83,26 @@ function isSameChannel(channel, otherChannel) {
|
||||
return channel === otherChannel || (!channel && !otherChannel);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
const exported = {
|
||||
extractErrors,
|
||||
hideSensitiveValues,
|
||||
tagsToVersions,
|
||||
isMajorRange,
|
||||
isMaintenanceRange,
|
||||
getUpperBound,
|
||||
getLowerBound,
|
||||
highest,
|
||||
lowest,
|
||||
getLatestVersion,
|
||||
getEarliestVersion,
|
||||
getFirstVersion,
|
||||
getRange,
|
||||
makeTag,
|
||||
isSameChannel,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {
|
||||
extractErrors,
|
||||
hideSensitiveValues,
|
||||
tagsToVersions,
|
||||
|
||||
+6
-5
@@ -1,9 +1,10 @@
|
||||
const {template, isString, isPlainObject} = require('lodash');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const {isGitRepo, verifyTagName} = require('./git');
|
||||
const getError = require('./get-error');
|
||||
import lodash from 'lodash'
|
||||
const {template, isString, isPlainObject} = lodash
|
||||
import AggregateError from 'aggregate-error';
|
||||
import {isGitRepo, verifyTagName} from './git.js';
|
||||
import getError from './get-error.js';
|
||||
|
||||
module.exports = async (context) => {
|
||||
export default async (context) => {
|
||||
const {
|
||||
cwd,
|
||||
env,
|
||||
|
||||
Generated
+17214
File diff suppressed because it is too large
Load Diff
+38
-29
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"name": "semantic-release",
|
||||
"type": "module",
|
||||
"description": "Automated semver compliant package publishing",
|
||||
"version": "0.0.0-development",
|
||||
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
|
||||
@@ -26,19 +27,19 @@
|
||||
"@semantic-release/npm": "^7.0.0",
|
||||
"@semantic-release/release-notes-generator": "^9.0.0",
|
||||
"aggregate-error": "^3.0.0",
|
||||
"cosmiconfig": "^6.0.0",
|
||||
"cosmiconfig": "^7.0.0",
|
||||
"debug": "^4.0.0",
|
||||
"env-ci": "^5.0.0",
|
||||
"execa": "^4.0.0",
|
||||
"execa": "^5.0.0",
|
||||
"figures": "^3.0.0",
|
||||
"find-versions": "^4.0.0",
|
||||
"get-stream": "^5.0.0",
|
||||
"get-stream": "^6.0.0",
|
||||
"git-log-parser": "^1.2.0",
|
||||
"hook-std": "^2.0.0",
|
||||
"hosted-git-info": "^3.0.0",
|
||||
"lodash": "^4.17.15",
|
||||
"marked": "^1.0.0",
|
||||
"marked-terminal": "^4.0.0",
|
||||
"hosted-git-info": "^4.0.0",
|
||||
"lodash": "^4.17.21",
|
||||
"marked": "^2.0.0",
|
||||
"marked-terminal": "^4.1.1",
|
||||
"micromatch": "^4.0.2",
|
||||
"p-each-series": "^2.1.0",
|
||||
"p-reduce": "^2.0.0",
|
||||
@@ -50,27 +51,28 @@
|
||||
"yargs": "^16.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^3.1.0",
|
||||
"clear-module": "^4.0.0",
|
||||
"codecov": "^3.0.0",
|
||||
"delay": "^4.0.0",
|
||||
"dockerode": "^3.0.0",
|
||||
"file-url": "^3.0.0",
|
||||
"fs-extra": "^9.0.0",
|
||||
"got": "^11.0.0",
|
||||
"js-yaml": "^3.10.0",
|
||||
"mockserver-client": "^5.1.1",
|
||||
"nock": "^12.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"p-retry": "^4.0.0",
|
||||
"proxyquire": "^2.0.0",
|
||||
"sinon": "^9.0.0",
|
||||
"stream-buffers": "^3.0.2",
|
||||
"tempy": "^0.5.0",
|
||||
"xo": "^0.29.0"
|
||||
"ava": "3.15.0",
|
||||
"cjs2esm": "^2.0.0",
|
||||
"clear-module": "4.1.1",
|
||||
"codecov": "3.8.2",
|
||||
"delay": "5.0.0",
|
||||
"dockerode": "3.3.0",
|
||||
"file-url": "3.0.0",
|
||||
"fs-extra": "10.0.0",
|
||||
"got": "11.8.2",
|
||||
"js-yaml": "4.1.0",
|
||||
"mockserver-client": "5.11.2",
|
||||
"nock": "13.1.1",
|
||||
"nyc": "15.1.0",
|
||||
"p-retry": "4.6.1",
|
||||
"proxyquire": "2.1.3",
|
||||
"sinon": "11.1.1",
|
||||
"stream-buffers": "3.0.2",
|
||||
"tempy": "1.0.1",
|
||||
"xo": "0.29.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.18"
|
||||
"node": ">=14.17"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
@@ -92,7 +94,7 @@
|
||||
"version"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"exports": "./index.js",
|
||||
"nyc": {
|
||||
"include": [
|
||||
"lib/**/*.js",
|
||||
@@ -122,13 +124,20 @@
|
||||
"lint": "xo",
|
||||
"pretest": "npm run lint",
|
||||
"semantic-release": "./bin/semantic-release.js",
|
||||
"test": "nyc ava -v"
|
||||
"test": "nyc ava -v",
|
||||
"test:ci": "nyc ava -v"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"space": true,
|
||||
"rules": {
|
||||
"unicorn/string-content": "off"
|
||||
"unicorn/string-content": "off",
|
||||
"import/extensions": "off"
|
||||
}
|
||||
},
|
||||
"renovate": {
|
||||
"extends": [
|
||||
"github>semantic-release/.github"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const test = require('ava');
|
||||
const {union} = require('lodash');
|
||||
const semver = require('semver');
|
||||
const proxyquire = require('proxyquire');
|
||||
import test from 'ava';
|
||||
import lodash from 'lodash'
|
||||
const {union} = lodash
|
||||
import semver from 'semver';
|
||||
import proxyquire from 'proxyquire';
|
||||
|
||||
const getBranch = (branches, branch) => branches.find(({name}) => name === branch);
|
||||
const release = (branches, name, version) => getBranch(branches, name).tags.push({version});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const expand = require('../../lib/branches/expand');
|
||||
const {gitRepo, gitCommits, gitCheckout, gitPush} = require('../helpers/git-utils');
|
||||
import test from 'ava';
|
||||
import expand from '../../lib/branches/expand.js';
|
||||
import {gitRepo, gitCommits, gitCheckout, gitPush} from '../helpers/git-utils.js';
|
||||
|
||||
test('Expand branches defined with globs', async (t) => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const getTags = require('../../lib/branches/get-tags');
|
||||
const {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} = require('../helpers/git-utils');
|
||||
import test from 'ava';
|
||||
import getTags from '../../lib/branches/get-tags.js';
|
||||
import {gitRepo, gitCommits, gitTagVersion, gitCheckout, gitAddNote} from '../helpers/git-utils.js';
|
||||
|
||||
test('Get the valid tags', async (t) => {
|
||||
const {cwd} = await gitRepo();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const test = require('ava');
|
||||
const normalize = require('../../lib/branches/normalize');
|
||||
import test from 'ava';
|
||||
import normalize from '../../lib/branches/normalize.js';
|
||||
|
||||
const toTags = (versions) => versions.map((version) => ({version}));
|
||||
|
||||
|
||||
+17
-16
@@ -1,16 +1,17 @@
|
||||
const test = require('ava');
|
||||
const {escapeRegExp} = require('lodash');
|
||||
import test from 'ava';
|
||||
import lodash from 'lodash'
|
||||
const {escapeRegExp} = lodash
|
||||
const proxyquire = require('proxyquire').noPreserveCache();
|
||||
const {stub} = require('sinon');
|
||||
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
||||
import sinon from 'sinon';
|
||||
import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
|
||||
|
||||
test.beforeEach((t) => {
|
||||
t.context.logs = '';
|
||||
t.context.errors = '';
|
||||
t.context.stdout = stub(process.stdout, 'write').callsFake((value) => {
|
||||
t.context.stdout = sinon.stubprocess.stdout, 'write').callsFake((value) => {
|
||||
t.context.logs += value.toString();
|
||||
});
|
||||
t.context.stderr = stub(process.stderr, 'write').callsFake((value) => {
|
||||
t.context.stderr = sinon.stubprocess.stderr, 'write').callsFake((value) => {
|
||||
t.context.errors += value.toString();
|
||||
});
|
||||
});
|
||||
@@ -21,7 +22,7 @@ test.afterEach.always((t) => {
|
||||
});
|
||||
|
||||
test.serial('Pass options to semantic-release API', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = [
|
||||
'',
|
||||
'',
|
||||
@@ -87,7 +88,7 @@ test.serial('Pass options to semantic-release API', async (t) => {
|
||||
});
|
||||
|
||||
test.serial('Pass options to semantic-release API with alias arguments', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = [
|
||||
'',
|
||||
'',
|
||||
@@ -120,7 +121,7 @@ test.serial('Pass options to semantic-release API with alias arguments', async (
|
||||
});
|
||||
|
||||
test.serial('Pass unknown options to semantic-release API', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = ['', '', '--bool', '--first-option', 'value1', '--second-option', 'value2', '--second-option', 'value3'];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||
|
||||
@@ -134,7 +135,7 @@ test.serial('Pass unknown options to semantic-release API', async (t) => {
|
||||
});
|
||||
|
||||
test.serial('Pass empty Array to semantic-release API for list option set to "false"', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = ['', '', '--publish', 'false'];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||
|
||||
@@ -146,7 +147,7 @@ test.serial('Pass empty Array to semantic-release API for list option set to "fa
|
||||
});
|
||||
|
||||
test.serial('Do not set properties in option for which arg is not in command line', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = ['', '', '-b', 'master'];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||
|
||||
@@ -163,7 +164,7 @@ test.serial('Do not set properties in option for which arg is not in command lin
|
||||
});
|
||||
|
||||
test.serial('Display help', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = ['', '', '--help'];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||
|
||||
@@ -174,7 +175,7 @@ test.serial('Display help', async (t) => {
|
||||
});
|
||||
|
||||
test.serial('Return error exitCode and prints help if called with a command', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = ['', '', 'pre'];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||
|
||||
@@ -186,7 +187,7 @@ test.serial('Return error exitCode and prints help if called with a command', as
|
||||
});
|
||||
|
||||
test.serial('Return error exitCode if multiple plugin are set for single plugin', async (t) => {
|
||||
const run = stub().resolves(true);
|
||||
const run = sinon.stub).resolves(true);
|
||||
const argv = ['', '', '--analyze-commits', 'analyze1', 'analyze2'];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||
|
||||
@@ -198,7 +199,7 @@ test.serial('Return error exitCode if multiple plugin are set for single plugin'
|
||||
});
|
||||
|
||||
test.serial('Return error exitCode if semantic-release throw error', async (t) => {
|
||||
const run = stub().rejects(new Error('semantic-release error'));
|
||||
const run = sinon.stub).rejects(new Error('semantic-release error'));
|
||||
const argv = ['', ''];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv}});
|
||||
|
||||
@@ -210,7 +211,7 @@ test.serial('Return error exitCode if semantic-release throw error', async (t) =
|
||||
|
||||
test.serial('Hide sensitive environment variable values from the logs', async (t) => {
|
||||
const env = {MY_TOKEN: 'secret token'};
|
||||
const run = stub().rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`));
|
||||
const run = sinon.stub).rejects(new Error(`Throw error: Exposing token ${env.MY_TOKEN}`));
|
||||
const argv = ['', ''];
|
||||
const cli = proxyquire('../cli', {'.': run, process: {...process, argv, env: {...process.env, ...env}}});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const test = require('ava');
|
||||
const {maintenance, prerelease, release} = require('../../lib/definitions/branches');
|
||||
import test from 'ava';
|
||||
import {maintenance, prerelease, release} from '../../lib/definitions/branches.js';
|
||||
|
||||
test('A "maintenance" branch is identified by having a "range" property or a "name" formatted like "N.x", "N.x.x" or "N.N.x"', (t) => {
|
||||
t.true(maintenance.filter({name: '1.x.x'}));
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const plugins = require('../../lib/definitions/plugins');
|
||||
const {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} = require('../../lib/definitions/constants');
|
||||
import test from 'ava';
|
||||
import plugins from '../../lib/definitions/plugins.js';
|
||||
import {RELEASE_NOTES_SEPARATOR, SECRET_REPLACEMENT} from '../../lib/definitions/constants.js';
|
||||
|
||||
test('The "analyzeCommits" plugin output must be either undefined or a valid semver release type', (t) => {
|
||||
t.false(plugins.analyzeCommits.outputValidator('invalid'));
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
module.exports = () => {};
|
||||
export default () => {};
|
||||
|
||||
Vendored
+5
-1
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
const exported = {
|
||||
verifyConditions: () => {},
|
||||
getLastRelease: () => {},
|
||||
analyzeCommits: () => {},
|
||||
@@ -6,3 +6,7 @@ module.exports = {
|
||||
generateNotes: () => {},
|
||||
publish: () => {},
|
||||
};
|
||||
|
||||
export default exported;
|
||||
|
||||
export const {verifyConditions, getLastRelease, analyzeCommits, verifyRelease, generateNotes, publish} = exported;
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
const SemanticReleaseError = require('@semantic-release/error');
|
||||
import SemanticReleaseError from '@semantic-release/error';
|
||||
|
||||
class InheritedError extends SemanticReleaseError {
|
||||
constructor(message, code) {
|
||||
@@ -9,6 +9,6 @@ class InheritedError extends SemanticReleaseError {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = () => {
|
||||
export default () => {
|
||||
throw new InheritedError('Inherited error', 'EINHERITED');
|
||||
};
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
module.exports = () => {
|
||||
export default () => {
|
||||
const error = new Error('a');
|
||||
error.errorProperty = 'errorProperty';
|
||||
throw error;
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
const AggregateError = require('aggregate-error');
|
||||
import AggregateError from 'aggregate-error';
|
||||
|
||||
module.exports = () => {
|
||||
export default () => {
|
||||
throw new AggregateError([new Error('a'), new Error('b')]);
|
||||
};
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
module.exports = (pluginConfig, context) => context;
|
||||
export default (pluginConfig, context) => context;
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
module.exports = (pluginConfig, {env, logger}) => {
|
||||
export default (pluginConfig, {env, logger}) => {
|
||||
console.log(`Console: Exposing token ${env.MY_TOKEN}`);
|
||||
logger.log(`Log: Exposing token ${env.MY_TOKEN}`);
|
||||
logger.error(`Error: Console token ${env.MY_TOKEN}`);
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
module.exports = () => {};
|
||||
export default () => {};
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
module.exports = (pluginConfig, context) => ({pluginConfig, context});
|
||||
export default (pluginConfig, context) => ({pluginConfig, context});
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const test = require('ava');
|
||||
const {stub} = require('sinon');
|
||||
const getCommits = require('../lib/get-commits');
|
||||
const {gitRepo, gitCommits, gitDetachedHead} = require('./helpers/git-utils');
|
||||
import test from 'ava';
|
||||
import sinon from 'sinon';
|
||||
import getCommits from '../lib/get-commits.js';
|
||||
import {gitRepo, gitCommits, gitDetachedHead} from './helpers/git-utils.js';
|
||||
|
||||
test.beforeEach((t) => {
|
||||
// Stub the logger functions
|
||||
t.context.log = stub();
|
||||
t.context.error = stub();
|
||||
t.context.log = sinon.stub();
|
||||
t.context.error = sinon.stub();
|
||||
t.context.logger = {log: t.context.log, error: t.context.error};
|
||||
});
|
||||
|
||||
|
||||
+56
-11
@@ -1,12 +1,13 @@
|
||||
const path = require('path');
|
||||
const {format} = require('util');
|
||||
const test = require('ava');
|
||||
const {writeFile, outputJson} = require('fs-extra');
|
||||
const {omit} = require('lodash');
|
||||
const proxyquire = require('proxyquire');
|
||||
const {stub} = require('sinon');
|
||||
const yaml = require('js-yaml');
|
||||
const {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} = require('./helpers/git-utils');
|
||||
import path from 'path';
|
||||
import {format} from 'util';
|
||||
import test from 'ava';
|
||||
import {writeFile, outputJson} from 'fs-extra';
|
||||
import lodash from 'lodash'
|
||||
const {omit} = lodash
|
||||
import proxyquire from 'proxyquire';
|
||||
import sinon from 'sinon';
|
||||
import yaml from 'js-yaml';
|
||||
import {gitRepo, gitTagVersion, gitCommits, gitShallowClone, gitAddConfig} from './helpers/git-utils.js';
|
||||
|
||||
const DEFAULT_PLUGINS = [
|
||||
'@semantic-release/commit-analyzer',
|
||||
@@ -16,7 +17,7 @@ const DEFAULT_PLUGINS = [
|
||||
];
|
||||
|
||||
test.beforeEach((t) => {
|
||||
t.context.plugins = stub().returns({});
|
||||
t.context.plugins = sinon.stub).returns({});
|
||||
t.context.getConfig = proxyquire('../lib/get-config', {'./plugins': t.context.plugins});
|
||||
});
|
||||
|
||||
@@ -136,7 +137,7 @@ test('Read options from .releaserc.yml', async (t) => {
|
||||
plugins: false,
|
||||
};
|
||||
// Create package.json in repository root
|
||||
await writeFile(path.resolve(cwd, '.releaserc.yml'), yaml.safeDump(options));
|
||||
await writeFile(path.resolve(cwd, '.releaserc.yml'), yaml.dump(options));
|
||||
|
||||
const {options: result} = await t.context.getConfig({cwd});
|
||||
|
||||
@@ -191,6 +192,28 @@ test('Read options from .releaserc.js', async (t) => {
|
||||
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
|
||||
});
|
||||
|
||||
test('Read options from .releaserc.cjs', async (t) => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
const {cwd} = await gitRepo();
|
||||
const options = {
|
||||
analyzeCommits: {path: 'analyzeCommits', param: 'analyzeCommits_param'},
|
||||
branches: ['test_branch'],
|
||||
repositoryUrl: 'https://host.null/owner/module.git',
|
||||
tagFormat: `v\${version}`,
|
||||
plugins: false,
|
||||
};
|
||||
// Create .releaserc.cjs in repository root
|
||||
await writeFile(path.resolve(cwd, '.releaserc.cjs'), `module.exports = ${JSON.stringify(options)}`);
|
||||
|
||||
const {options: result} = await t.context.getConfig({cwd});
|
||||
|
||||
const expected = {...options, branches: ['test_branch']};
|
||||
// Verify the options contains the plugin config from .releaserc.cjs
|
||||
t.deepEqual(result, expected);
|
||||
// Verify the plugins module is called with the plugin options from .releaserc.cjs
|
||||
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
|
||||
});
|
||||
|
||||
test('Read options from release.config.js', async (t) => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
const {cwd} = await gitRepo();
|
||||
@@ -213,6 +236,28 @@ test('Read options from release.config.js', async (t) => {
|
||||
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
|
||||
});
|
||||
|
||||
test('Read options from release.config.cjs', async (t) => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
const {cwd} = await gitRepo();
|
||||
const options = {
|
||||
analyzeCommits: {path: 'analyzeCommits', param: 'analyzeCommits_param'},
|
||||
branches: ['test_branch'],
|
||||
repositoryUrl: 'https://host.null/owner/module.git',
|
||||
tagFormat: `v\${version}`,
|
||||
plugins: false,
|
||||
};
|
||||
// Create release.config.cjs in repository root
|
||||
await writeFile(path.resolve(cwd, 'release.config.cjs'), `module.exports = ${JSON.stringify(options)}`);
|
||||
|
||||
const {options: result} = await t.context.getConfig({cwd});
|
||||
|
||||
const expected = {...options, branches: ['test_branch']};
|
||||
// Verify the options contains the plugin config from release.config.cjs
|
||||
t.deepEqual(result, expected);
|
||||
// Verify the plugins module is called with the plugin options from release.config.cjs
|
||||
t.deepEqual(t.context.plugins.args[0][0], {options: expected, cwd});
|
||||
});
|
||||
|
||||
test('Prioritise CLI/API parameters over file configuration and git repo', async (t) => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
let {cwd, repositoryUrl} = await gitRepo();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const getAuthUrl = require('../lib/get-git-auth-url');
|
||||
const {gitRepo} = require('./helpers/git-utils');
|
||||
import test from 'ava';
|
||||
import getAuthUrl from '../lib/get-git-auth-url.js';
|
||||
import {gitRepo} from './helpers/git-utils.js';
|
||||
|
||||
const env = {GIT_ASKPASS: 'echo', GIT_TERMINAL_PROMPT: 0};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const test = require('ava');
|
||||
const getLastRelease = require('../lib/get-last-release');
|
||||
import test from 'ava';
|
||||
import getLastRelease from '../lib/get-last-release.js';
|
||||
|
||||
test('Get the highest non-prerelease valid tag', (t) => {
|
||||
const result = getLastRelease({
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
const test = require('ava');
|
||||
const {spy} = require('sinon');
|
||||
const getLogger = require('../lib/get-logger');
|
||||
import test from 'ava';
|
||||
import {spy} from 'sinon';
|
||||
import getLogger from '../lib/get-logger.js';
|
||||
|
||||
test('Expose "error", "success" and "log" functions', (t) => {
|
||||
const stdout = spy();
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const test = require('ava');
|
||||
const {stub} = require('sinon');
|
||||
const getNextVersion = require('../lib/get-next-version');
|
||||
import test from 'ava';
|
||||
import sinon from 'sinon';
|
||||
import getNextVersion from '../lib/get-next-version.js';
|
||||
|
||||
test.beforeEach((t) => {
|
||||
// Stub the logger functions
|
||||
t.context.log = stub();
|
||||
t.context.log = sinon.stub);
|
||||
t.context.logger = {log: t.context.log};
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const test = require('ava');
|
||||
const getReleaseToAdd = require('../lib/get-release-to-add');
|
||||
import test from 'ava';
|
||||
import getReleaseToAdd from '../lib/get-release-to-add.js';
|
||||
|
||||
test('Return versions merged from release to maintenance branch, excluding lower than branch start range', (t) => {
|
||||
const result = getReleaseToAdd({
|
||||
|
||||
+8
-6
@@ -1,6 +1,7 @@
|
||||
const test = require('ava');
|
||||
const tempy = require('tempy');
|
||||
const {
|
||||
import test from 'ava';
|
||||
import tempy from 'tempy';
|
||||
|
||||
import {
|
||||
getTagHead,
|
||||
isRefExists,
|
||||
fetch,
|
||||
@@ -16,8 +17,9 @@ const {
|
||||
getNote,
|
||||
addNote,
|
||||
fetchNotes,
|
||||
} = require('../lib/git');
|
||||
const {
|
||||
} from '../lib/git.js';
|
||||
|
||||
import {
|
||||
gitRepo,
|
||||
gitCommits,
|
||||
gitCheckout,
|
||||
@@ -34,7 +36,7 @@ const {
|
||||
gitGetNote,
|
||||
gitFetch,
|
||||
initGit,
|
||||
} = require('./helpers/git-utils');
|
||||
} from './helpers/git-utils.js';
|
||||
|
||||
test('Get the last commit sha', async (t) => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
const tempy = require('tempy');
|
||||
const execa = require('execa');
|
||||
const fileUrl = require('file-url');
|
||||
const pEachSeries = require('p-each-series');
|
||||
const gitLogParser = require('git-log-parser');
|
||||
const getStream = require('get-stream');
|
||||
const {GIT_NOTE_REF} = require('../../lib/definitions/constants');
|
||||
import tempy from 'tempy';
|
||||
import execa from 'execa';
|
||||
import fileUrl from 'file-url';
|
||||
import pEachSeries from 'p-each-series';
|
||||
import gitLogParser from 'git-log-parser';
|
||||
import getStream from 'get-stream';
|
||||
import {GIT_NOTE_REF} from '../../lib/definitions/constants.js';
|
||||
|
||||
/**
|
||||
* Commit message information.
|
||||
@@ -323,7 +323,33 @@ async function gitGetNote(ref, execaOptions) {
|
||||
return (await execa('git', ['notes', '--ref', GIT_NOTE_REF, 'show', ref], execaOptions)).stdout;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
const exported = {
|
||||
initGit,
|
||||
gitRepo,
|
||||
initBareRepo,
|
||||
gitCommits,
|
||||
gitGetCommits,
|
||||
gitCheckout,
|
||||
gitFetch,
|
||||
gitHead,
|
||||
gitTagVersion,
|
||||
gitShallowClone,
|
||||
gitDetachedHead,
|
||||
gitDetachedHeadFromBranch,
|
||||
gitAddConfig,
|
||||
gitTagHead,
|
||||
gitRemoteTagHead,
|
||||
gitCommitTag,
|
||||
gitPush,
|
||||
merge,
|
||||
mergeFf,
|
||||
rebase,
|
||||
gitAddNote,
|
||||
gitGetNote,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {
|
||||
initGit,
|
||||
gitRepo,
|
||||
initBareRepo,
|
||||
|
||||
+14
-6
@@ -1,7 +1,7 @@
|
||||
const Docker = require('dockerode');
|
||||
const getStream = require('get-stream');
|
||||
const pRetry = require('p-retry');
|
||||
const {initBareRepo, gitShallowClone} = require('./git-utils');
|
||||
import Docker from 'dockerode';
|
||||
import getStream from 'get-stream';
|
||||
import pRetry from 'p-retry';
|
||||
import {initBareRepo, gitShallowClone} from './git-utils.js';
|
||||
|
||||
const IMAGE = 'pvdlg/docker-gitbox:latest';
|
||||
const SERVER_PORT = 80;
|
||||
@@ -63,10 +63,18 @@ async function createRepo(name, branch = 'master', description = `Repository ${n
|
||||
const authUrl = `http://${gitCredential}@${SERVER_HOST}:${HOST_PORT}/git/${name}.git`;
|
||||
|
||||
// Retry as the server might take a few ms to make the repo available push
|
||||
await pRetry(() => initBareRepo(authUrl, branch), {retries: 3, minTimeout: 500, factor: 2});
|
||||
await pRetry(() => initBareRepo(authUrl, branch), {retries: 5, minTimeout: 500, factor: 2});
|
||||
const cwd = await gitShallowClone(authUrl);
|
||||
|
||||
return {cwd, repositoryUrl, authUrl};
|
||||
}
|
||||
|
||||
module.exports = {start, stop, gitCredential, createRepo};
|
||||
const exported = {
|
||||
start,
|
||||
stop,
|
||||
gitCredential,
|
||||
createRepo,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {start, stop, gitCredential, createRepo};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const Docker = require('dockerode');
|
||||
const getStream = require('get-stream');
|
||||
const got = require('got');
|
||||
const pRetry = require('p-retry');
|
||||
const {mockServerClient} = require('mockserver-client');
|
||||
import Docker from 'dockerode';
|
||||
import getStream from 'get-stream';
|
||||
import got from 'got';
|
||||
import pRetry from 'p-retry';
|
||||
import {mockServerClient} from 'mockserver-client';
|
||||
|
||||
const IMAGE = 'jamesdbloom/mockserver:latest';
|
||||
const MOCK_SERVER_PORT = 1080;
|
||||
@@ -100,4 +100,13 @@ function verify(expectation) {
|
||||
return client.verify(expectation);
|
||||
}
|
||||
|
||||
module.exports = {start, stop, mock, verify, url};
|
||||
const exported = {
|
||||
start,
|
||||
stop,
|
||||
mock,
|
||||
verify,
|
||||
url,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {start, stop, mock, verify, url};
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
const Docker = require('dockerode');
|
||||
const getStream = require('get-stream');
|
||||
const got = require('got');
|
||||
const delay = require('delay');
|
||||
const pRetry = require('p-retry');
|
||||
import Docker from 'dockerode';
|
||||
import getStream from 'get-stream';
|
||||
import got from 'got';
|
||||
import delay from 'delay';
|
||||
import pRetry from 'p-retry';
|
||||
|
||||
const IMAGE = 'semanticrelease/npm-registry-docker:latest';
|
||||
const SERVER_PORT = 15986;
|
||||
@@ -76,4 +76,12 @@ async function stop() {
|
||||
await container.remove();
|
||||
}
|
||||
|
||||
module.exports = {start, stop, authEnv, url};
|
||||
const exported = {
|
||||
start,
|
||||
stop,
|
||||
authEnv,
|
||||
url,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {start, stop, authEnv, url};
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
const execa = require('execa');
|
||||
import execa from 'execa';
|
||||
|
||||
async function npmView(packageName, env) {
|
||||
return JSON.parse((await execa('npm', ['view', packageName, '--json'], {env})).stdout);
|
||||
}
|
||||
|
||||
module.exports = {npmView};
|
||||
const exported = {
|
||||
npmView,
|
||||
};
|
||||
|
||||
export default exported;
|
||||
export {npmView};
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
const test = require('ava');
|
||||
const {repeat} = require('lodash');
|
||||
const hideSensitive = require('../lib/hide-sensitive');
|
||||
const {SECRET_REPLACEMENT, SECRET_MIN_SIZE} = require('../lib/definitions/constants');
|
||||
import test from 'ava';
|
||||
import lodash from 'lodash'
|
||||
const {repeat} = lodash
|
||||
import hideSensitive from '../lib/hide-sensitive.js';
|
||||
import {SECRET_REPLACEMENT, SECRET_MIN_SIZE} from '../lib/definitions/constants.js';
|
||||
|
||||
test('Replace multiple sensitive environment variable values', (t) => {
|
||||
const env = {SOME_PASSWORD: 'password', SOME_TOKEN: 'secret'};
|
||||
|
||||
+216
-214
@@ -1,13 +1,15 @@
|
||||
const test = require('ava');
|
||||
const {escapeRegExp, isString, sortBy, omit} = require('lodash');
|
||||
const proxyquire = require('proxyquire');
|
||||
const {spy, stub} = require('sinon');
|
||||
const {WritableStreamBuffer} = require('stream-buffers');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const SemanticReleaseError = require('@semantic-release/error');
|
||||
const {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
||||
const {
|
||||
gitHead: getGitHead,
|
||||
import test from 'ava';
|
||||
import lodash from 'lodash'
|
||||
const {escapeRegExp, isString, sortBy, omit} = lodash
|
||||
import proxyquire from 'proxyquire';
|
||||
import sinon from 'sinon';
|
||||
import {WritableStreamBuffer} from 'stream-buffers';
|
||||
import AggregateError from 'aggregate-error';
|
||||
import SemanticReleaseError from '@semantic-release/error';
|
||||
import {COMMIT_NAME, COMMIT_EMAIL, SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
|
||||
|
||||
import {
|
||||
gitHead as getGitHead,
|
||||
gitCheckout,
|
||||
gitTagHead,
|
||||
gitRepo,
|
||||
@@ -21,17 +23,17 @@ const {
|
||||
rebase,
|
||||
gitAddNote,
|
||||
gitGetNote,
|
||||
} = require('./helpers/git-utils');
|
||||
} from './helpers/git-utils.js';
|
||||
|
||||
const requireNoCache = proxyquire.noPreserveCache();
|
||||
const pluginNoop = require.resolve('./fixtures/plugin-noop');
|
||||
|
||||
test.beforeEach((t) => {
|
||||
// Stub the logger functions
|
||||
t.context.log = spy();
|
||||
t.context.error = spy();
|
||||
t.context.success = spy();
|
||||
t.context.warn = spy();
|
||||
t.context.log = sinon.spy();
|
||||
t.context.error = sinon.spy();
|
||||
t.context.success = sinon.spy();
|
||||
t.context.warn = sinon.spy();
|
||||
t.context.logger = {
|
||||
log: t.context.log,
|
||||
error: t.context.error,
|
||||
@@ -73,19 +75,19 @@ test('Plugins are called with expected values', async (t) => {
|
||||
const notes1 = 'Release notes 1';
|
||||
const notes2 = 'Release notes 2';
|
||||
const notes3 = 'Release notes 3';
|
||||
const verifyConditions1 = stub().resolves();
|
||||
const verifyConditions2 = stub().resolves();
|
||||
const analyzeCommits = stub().resolves(nextRelease.type);
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes1 = stub().resolves(notes1);
|
||||
const generateNotes2 = stub().resolves(notes2);
|
||||
const generateNotes3 = stub().resolves(notes3);
|
||||
const verifyConditions1 = sinon.stub().resolves();
|
||||
const verifyConditions2 = sinon.stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves(nextRelease.type);
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes1 = sinon.stub().resolves(notes1);
|
||||
const generateNotes2 = sinon.stub().resolves(notes2);
|
||||
const generateNotes3 = sinon.stub().resolves(notes3);
|
||||
const release1 = {name: 'Release 1', url: 'https://release1.com'};
|
||||
const release2 = {name: 'Release 2', url: 'https://release2.com'};
|
||||
const addChannel = stub().resolves(release1);
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves(release2);
|
||||
const success = stub().resolves();
|
||||
const addChannel = sinon.stub().resolves(release1);
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves(release2);
|
||||
const success = sinon.stub().resolves();
|
||||
const env = {};
|
||||
const config = {
|
||||
branches: [{name: 'master'}, {name: 'next'}],
|
||||
@@ -408,15 +410,15 @@ test('Use custom tag format', async (t) => {
|
||||
const config = {branches: 'master', repositoryUrl, globalOpt: 'global', tagFormat: `test-\${version}`};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
analyzeCommits: stub().resolves(nextRelease.type),
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(notes),
|
||||
addChannel: stub().resolves(),
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
analyzeCommits: sinon.stub().resolves(nextRelease.type),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes: sinon.stub().resolves(notes),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish: sinon.stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -458,24 +460,24 @@ test('Use new gitHead, and recreate release notes if a prepare plugin create a c
|
||||
};
|
||||
const notes = 'Release notes';
|
||||
|
||||
const generateNotes = stub().resolves(notes);
|
||||
const prepare1 = stub().callsFake(async () => {
|
||||
const generateNotes = sinon.stub().resolves(notes);
|
||||
const prepare1 = sinon.stub().callsFake(async () => {
|
||||
commits = (await gitCommits(['Third'], {cwd})).concat(commits);
|
||||
});
|
||||
const prepare2 = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const prepare2 = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const options = {
|
||||
branches: ['master'],
|
||||
repositoryUrl,
|
||||
verifyConditions: stub().resolves(),
|
||||
analyzeCommits: stub().resolves(nextRelease.type),
|
||||
verifyRelease: stub().resolves(),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
analyzeCommits: sinon.stub().resolves(nextRelease.type),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes,
|
||||
addChannel: stub().resolves(),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: [prepare1, prepare2],
|
||||
publish,
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -527,12 +529,12 @@ test('Make a new release when a commit is forward-ported to an upper branch', as
|
||||
await merge('1.0.x', {cwd});
|
||||
await gitPush('origin', 'master', {cwd});
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
const addChannel = stub().resolves();
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const addChannel = sinon.stub().resolves();
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const config = {branches: [{name: '1.0.x'}, {name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
|
||||
const options = {
|
||||
@@ -570,14 +572,14 @@ test('Publish a pre-release version', async (t) => {
|
||||
const config = {branches: ['master', {name: 'beta', prerelease: true}], repositoryUrl};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(''),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes: sinon.stub().resolves(''),
|
||||
addChannel: false,
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish: sinon.stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -620,17 +622,17 @@ test('Publish releases from different branch on the same channel', async (t) =>
|
||||
branches: ['master', {name: 'next', channel: false}, {name: 'next-major', channel: false}],
|
||||
repositoryUrl,
|
||||
};
|
||||
const addChannel = stub().resolves({});
|
||||
const addChannel = sinon.stub().resolves({});
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(''),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes: sinon.stub().resolves(''),
|
||||
addChannel,
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish: sinon.stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
let semanticRelease = requireNoCache('..', {
|
||||
@@ -683,14 +685,14 @@ test('Publish pre-releases the same channel as regular releases', async (t) => {
|
||||
};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(''),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes: sinon.stub().resolves(''),
|
||||
addChannel: false,
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish: sinon.stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -733,14 +735,14 @@ test('Do not add pre-releases to a different channel', async (t) => {
|
||||
await merge('beta', {cwd});
|
||||
await gitPush('origin', 'master', {cwd});
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes = stub().resolves('Release notes');
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes = sinon.stub().resolves('Release notes');
|
||||
const release1 = {name: 'Release 1', url: 'https://release1.com'};
|
||||
const addChannel = stub().resolves(release1);
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const addChannel = sinon.stub().resolves(release1);
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const config = {
|
||||
branches: [{name: 'master'}, {name: 'beta', prerelease: 'beta'}],
|
||||
@@ -791,15 +793,15 @@ async function addChannelMacro(t, mergeFunction) {
|
||||
await gitPush('origin', 'master', {cwd});
|
||||
|
||||
const notes = 'Release notes';
|
||||
const verifyConditions = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes = stub().resolves(notes);
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes = sinon.stub().resolves(notes);
|
||||
const release1 = {name: 'Release 1', url: 'https://release1.com'};
|
||||
const addChannel1 = stub().resolves(release1);
|
||||
const addChannel2 = stub().resolves();
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const addChannel1 = sinon.stub().resolves(release1);
|
||||
const addChannel2 = sinon.stub().resolves();
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const config = {
|
||||
branches: [
|
||||
@@ -870,14 +872,14 @@ test('Call all "success" plugins even if one errors out', async (t) => {
|
||||
channel: null,
|
||||
};
|
||||
const notes = 'Release notes';
|
||||
const verifyConditions1 = stub().resolves();
|
||||
const verifyConditions2 = stub().resolves();
|
||||
const analyzeCommits = stub().resolves(nextRelease.type);
|
||||
const generateNotes = stub().resolves(notes);
|
||||
const verifyConditions1 = sinon.stub().resolves();
|
||||
const verifyConditions2 = sinon.stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves(nextRelease.type);
|
||||
const generateNotes = sinon.stub().resolves(notes);
|
||||
const release = {name: 'Release', url: 'https://release.com'};
|
||||
const publish = stub().resolves(release);
|
||||
const success1 = stub().rejects();
|
||||
const success2 = stub().resolves();
|
||||
const publish = sinon.stub().resolves(release);
|
||||
const success1 = sinon.stub().rejects();
|
||||
const success2 = sinon.stub().resolves();
|
||||
const config = {
|
||||
branches: [{name: 'master'}],
|
||||
repositoryUrl,
|
||||
@@ -889,8 +891,8 @@ test('Call all "success" plugins even if one errors out', async (t) => {
|
||||
verifyConditions: [verifyConditions1, verifyConditions2],
|
||||
analyzeCommits,
|
||||
generateNotes,
|
||||
addChannel: stub().resolves(),
|
||||
prepare: stub().resolves(),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish,
|
||||
success: [success1, success2],
|
||||
};
|
||||
@@ -926,12 +928,12 @@ test('Log all "verifyConditions" errors', async (t) => {
|
||||
const error1 = new Error('error 1');
|
||||
const error2 = new SemanticReleaseError('error 2', 'ERR2');
|
||||
const error3 = new SemanticReleaseError('error 3', 'ERR3');
|
||||
const fail = stub().resolves();
|
||||
const fail = sinon.stub().resolves();
|
||||
const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
|
||||
const options = {
|
||||
...config,
|
||||
plugins: false,
|
||||
verifyConditions: [stub().rejects(new AggregateError([error1, error2])), stub().rejects(error3)],
|
||||
verifyConditions: [sinon.stub().rejects(new AggregateError([error1, error2])), sinon.stub().rejects(error3)],
|
||||
fail,
|
||||
};
|
||||
|
||||
@@ -970,13 +972,13 @@ test('Log all "verifyRelease" errors', async (t) => {
|
||||
|
||||
const error1 = new SemanticReleaseError('error 1', 'ERR1');
|
||||
const error2 = new SemanticReleaseError('error 2', 'ERR2');
|
||||
const fail = stub().resolves();
|
||||
const fail = sinon.stub().resolves();
|
||||
const config = {branches: [{name: 'master'}], repositoryUrl, tagFormat: `v\${version}`};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
analyzeCommits: stub().resolves('major'),
|
||||
verifyRelease: [stub().rejects(error1), stub().rejects(error2)],
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
analyzeCommits: sinon.stub().resolves('major'),
|
||||
verifyRelease: [sinon.stub().rejects(error1), sinon.stub().rejects(error2)],
|
||||
fail,
|
||||
};
|
||||
|
||||
@@ -1011,14 +1013,14 @@ test('Dry-run skips addChannel, prepare, publish and success', async (t) => {
|
||||
await gitCheckout('next', true, {cwd});
|
||||
await gitPush('origin', 'next', {cwd});
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const analyzeCommits = stub().resolves('minor');
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes = stub().resolves();
|
||||
const addChannel = stub().resolves();
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves('minor');
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes = sinon.stub().resolves();
|
||||
const addChannel = sinon.stub().resolves();
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
dryRun: true,
|
||||
@@ -1077,13 +1079,13 @@ test('Dry-run skips fail', async (t) => {
|
||||
|
||||
const error1 = new SemanticReleaseError('error 1', 'ERR1');
|
||||
const error2 = new SemanticReleaseError('error 2', 'ERR2');
|
||||
const fail = stub().resolves();
|
||||
const fail = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
dryRun: true,
|
||||
branches: ['master'],
|
||||
repositoryUrl,
|
||||
verifyConditions: [stub().rejects(error1), stub().rejects(error2)],
|
||||
verifyConditions: [sinon.stub().rejects(error1), sinon.stub().rejects(error2)],
|
||||
fail,
|
||||
};
|
||||
|
||||
@@ -1125,12 +1127,12 @@ test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t
|
||||
};
|
||||
const notes = 'Release notes';
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const analyzeCommits = stub().resolves(nextRelease.type);
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes = stub().resolves(notes);
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves(nextRelease.type);
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes = sinon.stub().resolves(notes);
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
dryRun: false,
|
||||
@@ -1140,11 +1142,11 @@ test('Force a dry-run if not on a CI and "noCi" is not explicitly set', async (t
|
||||
analyzeCommits,
|
||||
verifyRelease,
|
||||
generateNotes,
|
||||
addChannel: stub().resolves(),
|
||||
prepare: stub().resolves(),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish,
|
||||
success,
|
||||
fail: stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1181,8 +1183,8 @@ test('Dry-run does not print changelog if "generateNotes" return "undefined"', a
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
|
||||
const nextRelease = {type: 'major', version: '2.0.0', gitHead: await getGitHead({cwd}), gitTag: 'v2.0.0'};
|
||||
const analyzeCommits = stub().resolves(nextRelease.type);
|
||||
const generateNotes = stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves(nextRelease.type);
|
||||
const generateNotes = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
dryRun: true,
|
||||
@@ -1234,12 +1236,12 @@ test('Allow local releases with "noCi" option', async (t) => {
|
||||
};
|
||||
const notes = 'Release notes';
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const analyzeCommits = stub().resolves(nextRelease.type);
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes = stub().resolves(notes);
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves(nextRelease.type);
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes = sinon.stub().resolves(notes);
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
noCi: true,
|
||||
@@ -1249,11 +1251,11 @@ test('Allow local releases with "noCi" option', async (t) => {
|
||||
analyzeCommits,
|
||||
verifyRelease,
|
||||
generateNotes,
|
||||
addChannel: stub().resolves(),
|
||||
prepare: stub().resolves(),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish,
|
||||
success,
|
||||
fail: stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1303,27 +1305,27 @@ test('Accept "undefined" value returned by "generateNotes" and "false" by "publi
|
||||
gitTag: 'v1.2.0',
|
||||
channel: null,
|
||||
};
|
||||
const analyzeCommits = stub().resolves(nextRelease.type);
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes1 = stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves(nextRelease.type);
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes1 = sinon.stub().resolves();
|
||||
const notes2 = 'Release notes 2';
|
||||
const generateNotes2 = stub().resolves(notes2);
|
||||
const publish = stub().resolves(false);
|
||||
const addChannel = stub().resolves(false);
|
||||
const success = stub().resolves();
|
||||
const generateNotes2 = sinon.stub().resolves(notes2);
|
||||
const publish = sinon.stub().resolves(false);
|
||||
const addChannel = sinon.stub().resolves(false);
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
branches: ['master', 'next'],
|
||||
repositoryUrl,
|
||||
verifyConditions: stub().resolves(),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
analyzeCommits,
|
||||
verifyRelease,
|
||||
generateNotes: [generateNotes1, generateNotes2],
|
||||
addChannel,
|
||||
prepare: stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish,
|
||||
success,
|
||||
fail: stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1386,12 +1388,12 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren
|
||||
await gitCommits(['feat: feature on maintenance version 1.x'], {cwd});
|
||||
await gitPush('origin', 'master', {cwd});
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
const addChannel = stub().resolves();
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const addChannel = sinon.stub().resolves();
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const config = {
|
||||
branches: [{name: '1.x'}, {name: 'master'}],
|
||||
@@ -1438,12 +1440,12 @@ test('Throws "EINVALIDNEXTVERSION" if next release is out of range of the curren
|
||||
await gitCommits(['feat: new feature on master', 'fix: new fix on master'], {cwd});
|
||||
await gitPush('origin', 'master', {cwd});
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
const addChannel = stub().resolves();
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const addChannel = sinon.stub().resolves();
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
|
||||
const config = {
|
||||
branches: [{name: 'master'}, {name: 'next'}, {name: 'next-major'}],
|
||||
@@ -1496,15 +1498,15 @@ test('Throws "EINVALIDMAINTENANCEMERGE" if merge an out of range release in a ma
|
||||
await gitPush('origin', '1.1.x', {cwd});
|
||||
|
||||
const notes = 'Release notes';
|
||||
const verifyConditions = stub().resolves();
|
||||
const analyzeCommits = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes = stub().resolves(notes);
|
||||
const addChannel = stub().resolves();
|
||||
const prepare = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const success = stub().resolves();
|
||||
const fail = stub().resolves();
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves();
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes = sinon.stub().resolves(notes);
|
||||
const addChannel = sinon.stub().resolves();
|
||||
const prepare = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
const fail = sinon.stub().resolves();
|
||||
|
||||
const config = {branches: [{name: 'master'}, {name: '1.1.x'}], repositoryUrl, tagFormat: `v\${version}`};
|
||||
const options = {
|
||||
@@ -1579,15 +1581,15 @@ test('Returns false if not running from the configured branch', async (t) => {
|
||||
const options = {
|
||||
branches: ['master'],
|
||||
repositoryUrl,
|
||||
verifyConditions: stub().resolves(),
|
||||
analyzeCommits: stub().resolves(),
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(),
|
||||
addChannel: stub().resolves(),
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
analyzeCommits: sinon.stub().resolves(),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes: sinon.stub().resolves(),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish: sinon.stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1616,23 +1618,23 @@ test('Returns false if there is no relevant changes', async (t) => {
|
||||
await gitCommits(['First'], {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
|
||||
const analyzeCommits = stub().resolves();
|
||||
const verifyRelease = stub().resolves();
|
||||
const generateNotes = stub().resolves();
|
||||
const publish = stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves();
|
||||
const verifyRelease = sinon.stub().resolves();
|
||||
const generateNotes = sinon.stub().resolves();
|
||||
const publish = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
branches: ['master'],
|
||||
repositoryUrl,
|
||||
verifyConditions: [stub().resolves()],
|
||||
verifyConditions: [sinon.stub().resolves()],
|
||||
analyzeCommits,
|
||||
verifyRelease,
|
||||
generateNotes,
|
||||
addChannel: stub().resolves(),
|
||||
prepare: stub().resolves(),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish,
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1676,19 +1678,19 @@ test('Exclude commits with [skip release] or [release skip] from analysis', asyn
|
||||
{cwd}
|
||||
);
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
const analyzeCommits = stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves();
|
||||
const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: [stub().resolves(), stub().resolves()],
|
||||
verifyConditions: [sinon.stub().resolves(), sinon.stub().resolves()],
|
||||
analyzeCommits,
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(),
|
||||
addChannel: stub().resolves(),
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes: sinon.stub().resolves(),
|
||||
addChannel: sinon.stub().resolves(),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish: sinon.stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1716,8 +1718,8 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async (t) =>
|
||||
const options = {
|
||||
branches: ['master'],
|
||||
repositoryUrl,
|
||||
verifyConditions: stub().rejects(pluginError),
|
||||
fail: [stub().rejects(failError1), stub().rejects(failError2)],
|
||||
verifyConditions: sinon.stub().rejects(pluginError),
|
||||
fail: [sinon.stub().rejects(failError1), sinon.stub().rejects(failError2)],
|
||||
};
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
'./lib/get-logger': () => t.context.logger,
|
||||
@@ -1736,12 +1738,12 @@ test('Log both plugins errors and errors thrown by "fail" plugin', async (t) =>
|
||||
test('Call "fail" only if a plugin returns a SemanticReleaseError', async (t) => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
const pluginError = new Error('Plugin error');
|
||||
const fail = stub().resolves();
|
||||
const fail = sinon.stub().resolves();
|
||||
|
||||
const options = {
|
||||
branches: ['master'],
|
||||
repositoryUrl,
|
||||
verifyConditions: stub().rejects(pluginError),
|
||||
verifyConditions: sinon.stub().rejects(pluginError),
|
||||
fail,
|
||||
};
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1789,16 +1791,16 @@ test('Throw an Error if plugin returns an unexpected value', async (t) => {
|
||||
await gitCommits(['Second'], {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
|
||||
const verifyConditions = stub().resolves();
|
||||
const analyzeCommits = stub().resolves('string');
|
||||
const verifyConditions = sinon.stub().resolves();
|
||||
const analyzeCommits = sinon.stub().resolves('string');
|
||||
|
||||
const options = {
|
||||
branches: ['master'],
|
||||
repositoryUrl,
|
||||
verifyConditions: [verifyConditions],
|
||||
analyzeCommits,
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1815,19 +1817,19 @@ test('Throw an Error if plugin returns an unexpected value', async (t) => {
|
||||
test('Hide sensitive information passed to "fail" plugin', async (t) => {
|
||||
const {cwd, repositoryUrl} = await gitRepo(true);
|
||||
|
||||
const fail = stub().resolves();
|
||||
const fail = sinon.stub().resolves();
|
||||
const env = {MY_TOKEN: 'secret token'};
|
||||
const options = {
|
||||
branch: 'master',
|
||||
repositoryUrl,
|
||||
verifyConditions: stub().throws(
|
||||
verifyConditions: sinon.stub().throws(
|
||||
new SemanticReleaseError(
|
||||
`Message: Exposing token ${env.MY_TOKEN}`,
|
||||
'ERR',
|
||||
`Details: Exposing token ${env.MY_TOKEN}`
|
||||
)
|
||||
),
|
||||
success: stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail,
|
||||
};
|
||||
|
||||
@@ -1858,7 +1860,7 @@ test('Hide sensitive information passed to "success" plugin', async (t) => {
|
||||
await gitCommits(['feat: new feature'], {cwd});
|
||||
await gitPush(repositoryUrl, 'master', {cwd});
|
||||
|
||||
const success = stub().resolves();
|
||||
const success = sinon.stub().resolves();
|
||||
const env = {MY_TOKEN: 'secret token'};
|
||||
const options = {
|
||||
branch: 'master',
|
||||
@@ -1866,14 +1868,14 @@ test('Hide sensitive information passed to "success" plugin', async (t) => {
|
||||
verifyConditions: false,
|
||||
verifyRelease: false,
|
||||
prepare: false,
|
||||
generateNotes: stub().resolves(`Exposing token ${env.MY_TOKEN}`),
|
||||
publish: stub().resolves({
|
||||
generateNotes: sinon.stub().resolves(`Exposing token ${env.MY_TOKEN}`),
|
||||
publish: sinon.stub().resolves({
|
||||
name: `Name: Exposing token ${env.MY_TOKEN}`,
|
||||
url: `URL: Exposing token ${env.MY_TOKEN}`,
|
||||
}),
|
||||
addChannel: false,
|
||||
success,
|
||||
fail: stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
@@ -1911,19 +1913,19 @@ test('Get all commits including the ones not in the shallow clone', async (t) =>
|
||||
channel: undefined,
|
||||
};
|
||||
const notes = 'Release notes';
|
||||
const analyzeCommits = stub().resolves(nextRelease.type);
|
||||
const analyzeCommits = sinon.stub().resolves(nextRelease.type);
|
||||
|
||||
const config = {branches: ['master'], repositoryUrl, globalOpt: 'global'};
|
||||
const options = {
|
||||
...config,
|
||||
verifyConditions: stub().resolves(),
|
||||
verifyConditions: sinon.stub().resolves(),
|
||||
analyzeCommits,
|
||||
verifyRelease: stub().resolves(),
|
||||
generateNotes: stub().resolves(notes),
|
||||
prepare: stub().resolves(),
|
||||
publish: stub().resolves(),
|
||||
success: stub().resolves(),
|
||||
fail: stub().resolves(),
|
||||
verifyRelease: sinon.stub().resolves(),
|
||||
generateNotes: sinon.stub().resolves(notes),
|
||||
prepare: sinon.stub().resolves(),
|
||||
publish: sinon.stub().resolves(),
|
||||
success: sinon.stub().resolves(),
|
||||
fail: sinon.stub().resolves(),
|
||||
};
|
||||
|
||||
const semanticRelease = requireNoCache('..', {
|
||||
|
||||
+57
-47
@@ -1,14 +1,16 @@
|
||||
const path = require('path');
|
||||
const test = require('ava');
|
||||
const proxyquire = require('proxyquire');
|
||||
const {escapeRegExp} = require('lodash');
|
||||
const {writeJson, readJson} = require('fs-extra');
|
||||
const execa = require('execa');
|
||||
const {WritableStreamBuffer} = require('stream-buffers');
|
||||
const delay = require('delay');
|
||||
const getAuthUrl = require('../lib/get-git-auth-url');
|
||||
const {SECRET_REPLACEMENT} = require('../lib/definitions/constants');
|
||||
const {
|
||||
import path from 'path';
|
||||
import test from 'ava';
|
||||
import proxyquire from 'proxyquire';
|
||||
import lodash from 'lodash'
|
||||
const {escapeRegExp} = lodash
|
||||
import {writeJson, readJson} from 'fs-extra';
|
||||
import execa from 'execa';
|
||||
import {WritableStreamBuffer} from 'stream-buffers';
|
||||
import delay from 'delay';
|
||||
import getAuthUrl from '../lib/get-git-auth-url.js';
|
||||
import {SECRET_REPLACEMENT} from '../lib/definitions/constants.js';
|
||||
|
||||
import {
|
||||
gitHead,
|
||||
gitTagHead,
|
||||
gitRepo,
|
||||
@@ -18,28 +20,32 @@ const {
|
||||
gitCheckout,
|
||||
merge,
|
||||
gitGetNote,
|
||||
} = require('./helpers/git-utils');
|
||||
const {npmView} = require('./helpers/npm-utils');
|
||||
const gitbox = require('./helpers/gitbox');
|
||||
const mockServer = require('./helpers/mockserver');
|
||||
const npmRegistry = require('./helpers/npm-registry');
|
||||
} from './helpers/git-utils.js';
|
||||
|
||||
import {npmView} from './helpers/npm-utils.js';
|
||||
import gitbox from './helpers/gitbox.js';
|
||||
import mockServer from './helpers/mockserver.js';
|
||||
import npmRegistry from './helpers/npm-registry.js';
|
||||
|
||||
/* eslint camelcase: ["error", {properties: "never"}] */
|
||||
|
||||
const requireNoCache = proxyquire.noPreserveCache();
|
||||
|
||||
// Environment variables used with semantic-release cli (similar to what a user would setup)
|
||||
const {GITHUB_ACTION, GITHUB_TOKEN, ...processEnvWithoutGitHubActionsVariables} = process.env;
|
||||
const env = {
|
||||
...processEnvWithoutGitHubActionsVariables,
|
||||
...npmRegistry.authEnv,
|
||||
GH_TOKEN: gitbox.gitCredential,
|
||||
GITHUB_URL: mockServer.url,
|
||||
TRAVIS: 'true',
|
||||
CI: 'true',
|
||||
GH_TOKEN: gitbox.gitCredential,
|
||||
TRAVIS: 'true',
|
||||
TRAVIS_BRANCH: 'master',
|
||||
TRAVIS_PULL_REQUEST: 'false',
|
||||
GITHUB_API_URL: mockServer.url,
|
||||
};
|
||||
|
||||
// Environment variables used only for the local npm command used to do verification
|
||||
const testEnv = {
|
||||
const npmTestEnv = {
|
||||
...process.env,
|
||||
...npmRegistry.authEnv,
|
||||
npm_config_registry: npmRegistry.url,
|
||||
@@ -74,7 +80,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
release: {branches: ['master', 'next'], success: false, fail: false},
|
||||
});
|
||||
// Create a npm-shrinkwrap.json file
|
||||
await execa('npm', ['shrinkwrap'], {env: testEnv, cwd});
|
||||
await execa('npm', ['shrinkwrap'], {env: npmTestEnv, cwd, extendEnv: false});
|
||||
|
||||
/* No release */
|
||||
let verifyMock = await mockServer.mock(
|
||||
@@ -85,7 +91,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
t.log('Commit a chore');
|
||||
await gitCommits(['chore: Init repository'], {cwd});
|
||||
t.log('$ semantic-release');
|
||||
let {stdout, exitCode} = await execa(cli, [], {env, cwd});
|
||||
let {stdout, exitCode} = await execa(cli, [], {env, cwd, extendEnv: false});
|
||||
t.regex(stdout, /There are no relevant changes, so no new version is released/);
|
||||
t.is(exitCode, 0);
|
||||
|
||||
@@ -108,7 +114,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: Initial commit'], {cwd});
|
||||
t.log('$ semantic-release');
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd}));
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd, extendEnv: false}));
|
||||
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
|
||||
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
|
||||
t.is(exitCode, 0);
|
||||
@@ -120,7 +126,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
let {
|
||||
'dist-tags': {latest: releasedVersion},
|
||||
} = await npmView(packageName, testEnv);
|
||||
} = await npmView(packageName, npmTestEnv);
|
||||
let head = await gitHead({cwd});
|
||||
t.is(releasedVersion, version);
|
||||
t.is(await gitTagHead(`v${version}`, {cwd}), head);
|
||||
@@ -149,7 +155,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
t.log('Commit a fix');
|
||||
await gitCommits(['fix: bar'], {cwd});
|
||||
t.log('$ semantic-release');
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd}));
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd, extendEnv: false}));
|
||||
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
|
||||
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
|
||||
t.is(exitCode, 0);
|
||||
@@ -161,7 +167,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
({
|
||||
'dist-tags': {latest: releasedVersion},
|
||||
} = await npmView(packageName, testEnv));
|
||||
} = await npmView(packageName, npmTestEnv));
|
||||
head = await gitHead({cwd});
|
||||
t.is(releasedVersion, version);
|
||||
t.is(await gitTagHead(`v${version}`, {cwd}), head);
|
||||
@@ -190,7 +196,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: baz'], {cwd});
|
||||
t.log('$ semantic-release');
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd}));
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd, extendEnv: false}));
|
||||
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
|
||||
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
|
||||
t.is(exitCode, 0);
|
||||
@@ -202,7 +208,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
({
|
||||
'dist-tags': {latest: releasedVersion},
|
||||
} = await npmView(packageName, testEnv));
|
||||
} = await npmView(packageName, npmTestEnv));
|
||||
head = await gitHead({cwd});
|
||||
t.is(releasedVersion, version);
|
||||
t.is(await gitTagHead(`v${version}`, {cwd}), head);
|
||||
@@ -233,7 +239,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
await gitPush('origin', 'next', {cwd});
|
||||
await gitCommits(['feat: foo\n\n BREAKING CHANGE: bar'], {cwd});
|
||||
t.log('$ semantic-release');
|
||||
({stdout, exitCode} = await execa(cli, [], {env: {...env, TRAVIS_BRANCH: 'next'}, cwd}));
|
||||
({stdout, exitCode} = await execa(cli, [], {env: {...env, TRAVIS_BRANCH: 'next'}, cwd, extendEnv: false}));
|
||||
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
|
||||
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
|
||||
t.is(exitCode, 0);
|
||||
@@ -245,7 +251,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
({
|
||||
'dist-tags': {next: releasedVersion},
|
||||
} = await npmView(packageName, testEnv));
|
||||
} = await npmView(packageName, npmTestEnv));
|
||||
head = await gitHead({cwd});
|
||||
t.is(releasedVersion, version);
|
||||
t.is(await gitGetNote(`v${version}`, {cwd}), '{"channels":["next"]}');
|
||||
@@ -283,7 +289,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
await merge('next', {cwd});
|
||||
await gitPush('origin', 'master', {cwd});
|
||||
t.log('$ semantic-release');
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd}));
|
||||
({stdout, exitCode} = await execa(cli, [], {env, cwd, extendEnv: false}));
|
||||
t.regex(stdout, new RegExp(`Updated GitHub release: release-url/${version}`));
|
||||
t.regex(stdout, new RegExp(`Adding version ${version} to npm registry on dist-tag latest`));
|
||||
t.is(exitCode, 0);
|
||||
@@ -293,7 +299,7 @@ test('Release patch, minor and major versions', async (t) => {
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
({
|
||||
'dist-tags': {latest: releasedVersion},
|
||||
} = await npmView(packageName, testEnv));
|
||||
} = await npmView(packageName, npmTestEnv));
|
||||
t.is(releasedVersion, version);
|
||||
t.is(await gitGetNote(`v${version}`, {cwd}), '{"channels":["next",null]}');
|
||||
t.is(await gitTagHead(`v${version}`, {cwd}), await gitTagHead(`v${version}`, {cwd}));
|
||||
@@ -318,7 +324,7 @@ test('Exit with 1 if a plugin is not found', async (t) => {
|
||||
release: {analyzeCommits: 'non-existing-path', success: false, fail: false},
|
||||
});
|
||||
|
||||
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd}));
|
||||
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd, extendEnv: false}));
|
||||
t.is(exitCode, 1);
|
||||
t.regex(stderr, /Cannot find module/);
|
||||
});
|
||||
@@ -336,7 +342,7 @@ test('Exit with 1 if a shareable config is not found', async (t) => {
|
||||
release: {extends: 'non-existing-path', success: false, fail: false},
|
||||
});
|
||||
|
||||
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd}));
|
||||
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd, extendEnv: false}));
|
||||
t.is(exitCode, 1);
|
||||
t.regex(stderr, /Cannot find module/);
|
||||
});
|
||||
@@ -357,7 +363,7 @@ test('Exit with 1 if a shareable config reference a not found plugin', async (t)
|
||||
});
|
||||
await writeJson(path.resolve(cwd, 'shareable.json'), shareable);
|
||||
|
||||
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd}));
|
||||
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd, extendEnv: false}));
|
||||
t.is(exitCode, 1);
|
||||
t.regex(stderr, /Cannot find module/);
|
||||
});
|
||||
@@ -387,7 +393,7 @@ test('Dry-run', async (t) => {
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: Initial commit'], {cwd});
|
||||
t.log('$ semantic-release -d');
|
||||
const {stdout, exitCode} = await execa(cli, ['-d'], {env, cwd});
|
||||
const {stdout, exitCode} = await execa(cli, ['-d'], {env, cwd, extendEnv: false});
|
||||
t.regex(stdout, new RegExp(`There is no previous release, the next release version is ${version}`));
|
||||
t.regex(stdout, new RegExp(`Release note for version ${version}`));
|
||||
t.regex(stdout, /Initial commit/);
|
||||
@@ -400,7 +406,6 @@ test('Dry-run', async (t) => {
|
||||
|
||||
test('Allow local releases with "noCi" option', async (t) => {
|
||||
const envNoCi = {...env};
|
||||
delete envNoCi.TRAVIS;
|
||||
delete envNoCi.CI;
|
||||
const packageName = 'test-no-ci';
|
||||
const owner = 'git';
|
||||
@@ -435,7 +440,7 @@ test('Allow local releases with "noCi" option', async (t) => {
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: Initial commit'], {cwd});
|
||||
t.log('$ semantic-release --no-ci');
|
||||
const {stdout, exitCode} = await execa(cli, ['--no-ci'], {env: envNoCi, cwd});
|
||||
const {stdout, exitCode} = await execa(cli, ['--no-ci'], {env: envNoCi, cwd, extendEnv: false});
|
||||
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
|
||||
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
|
||||
t.is(exitCode, 0);
|
||||
@@ -444,7 +449,7 @@ test('Allow local releases with "noCi" option', async (t) => {
|
||||
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
|
||||
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
const {version: releasedVersion, gitHead: releasedGitHead} = await npmView(packageName, testEnv);
|
||||
const {version: releasedVersion, gitHead: releasedGitHead} = await npmView(packageName, npmTestEnv);
|
||||
|
||||
const head = await gitHead({cwd});
|
||||
t.is(releasedVersion, version);
|
||||
@@ -488,7 +493,7 @@ test('Pass options via CLI arguments', async (t) => {
|
||||
false,
|
||||
'--debug',
|
||||
],
|
||||
{env, cwd}
|
||||
{env, cwd, extendEnv: false}
|
||||
);
|
||||
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
|
||||
t.is(exitCode, 0);
|
||||
@@ -497,7 +502,7 @@ test('Pass options via CLI arguments', async (t) => {
|
||||
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
|
||||
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
const {version: releasedVersion, gitHead: releasedGitHead} = await npmView(packageName, testEnv);
|
||||
const {version: releasedVersion, gitHead: releasedGitHead} = await npmView(packageName, npmTestEnv);
|
||||
const head = await gitHead({cwd});
|
||||
t.is(releasedVersion, version);
|
||||
t.is(releasedGitHead, head);
|
||||
@@ -553,7 +558,7 @@ test('Run via JS API', async (t) => {
|
||||
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
|
||||
|
||||
// Retrieve the published package from the registry and check version and gitHead
|
||||
const {version: releasedVersion, gitHead: releasedGitHead} = await npmView(packageName, testEnv);
|
||||
const {version: releasedVersion, gitHead: releasedGitHead} = await npmView(packageName, npmTestEnv);
|
||||
const head = await gitHead({cwd});
|
||||
t.is(releasedVersion, version);
|
||||
t.is(releasedGitHead, head);
|
||||
@@ -582,7 +587,7 @@ test('Log unexpected errors from plugins and exit with 1', async (t) => {
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: Initial commit'], {cwd});
|
||||
t.log('$ semantic-release');
|
||||
const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false});
|
||||
const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false, extendEnv: false});
|
||||
// Verify the type and message are logged
|
||||
t.regex(stderr, /Error: a/);
|
||||
// Verify the the stacktrace is logged
|
||||
@@ -609,7 +614,7 @@ test('Log errors inheriting SemanticReleaseError and exit with 1', async (t) =>
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: Initial commit'], {cwd});
|
||||
t.log('$ semantic-release');
|
||||
const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false});
|
||||
const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false, extendEnv: false});
|
||||
// Verify the type and message are logged
|
||||
t.regex(stderr, /EINHERITED Inherited error/);
|
||||
t.is(exitCode, 1);
|
||||
@@ -630,7 +635,7 @@ test('Exit with 1 if missing permission to push to the remote repository', async
|
||||
const {stderr, exitCode} = await execa(
|
||||
cli,
|
||||
['--repository-url', 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'],
|
||||
{env: {...env, GH_TOKEN: 'user:wrong_pass'}, cwd, reject: false}
|
||||
{env: {...env, GH_TOKEN: 'user:wrong_pass'}, cwd, reject: false, extendEnv: false}
|
||||
);
|
||||
// Verify the type and message are logged
|
||||
t.regex(stderr, /EGITNOPERMISSION/);
|
||||
@@ -650,7 +655,12 @@ test('Hide sensitive environment variable values from the logs', async (t) => {
|
||||
});
|
||||
|
||||
t.log('$ semantic-release');
|
||||
const {stdout, stderr} = await execa(cli, [], {env: {...env, MY_TOKEN: 'secret token'}, cwd, reject: false});
|
||||
const {stdout, stderr} = await execa(cli, [], {
|
||||
env: {...env, MY_TOKEN: 'secret token'},
|
||||
cwd,
|
||||
reject: false,
|
||||
extendEnv: false,
|
||||
});
|
||||
|
||||
t.regex(stdout, new RegExp(`Console: Exposing token ${escapeRegExp(SECRET_REPLACEMENT)}`));
|
||||
t.regex(stdout, new RegExp(`Log: Exposing token ${escapeRegExp(SECRET_REPLACEMENT)}`));
|
||||
@@ -680,7 +690,7 @@ test('Use the valid git credentials when multiple are provided', async (t) => {
|
||||
|
||||
test('Use the repository URL as is if none of the given git credentials are valid', async (t) => {
|
||||
const {cwd} = await gitbox.createRepo('test-invalid-auth');
|
||||
const dummyUrl = 'http://toto@localhost:2080/git/test-auth.git';
|
||||
const dummyUrl = 'http://toto@localhost:2080/git/test-invalid-auth.git';
|
||||
|
||||
t.is(
|
||||
await getAuthUrl({
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
const test = require('ava');
|
||||
const {noop} = require('lodash');
|
||||
const {stub} = require('sinon');
|
||||
const normalize = require('../../lib/plugins/normalize');
|
||||
import test from 'ava';
|
||||
import lodash from 'lodash'
|
||||
const {noop} = lodash
|
||||
import sinon from 'sinon';
|
||||
import normalize from '../../lib/plugins/normalize.js';
|
||||
|
||||
const cwd = process.cwd();
|
||||
|
||||
test.beforeEach((t) => {
|
||||
// Stub the logger functions
|
||||
t.context.log = stub();
|
||||
t.context.error = stub();
|
||||
t.context.success = stub();
|
||||
t.context.stderr = {write: stub()};
|
||||
t.context.log = sinon.stub);
|
||||
t.context.error = sinon.stub);
|
||||
t.context.success = sinon.stub);
|
||||
t.context.stderr = {write: sinon.stub)};
|
||||
t.context.logger = {
|
||||
log: t.context.log,
|
||||
error: t.context.error,
|
||||
@@ -99,7 +100,7 @@ test('Normalize and load plugin that retuns multiple functions', (t) => {
|
||||
});
|
||||
|
||||
test('Wrap "analyzeCommits" plugin in a function that validate the output of the plugin', async (t) => {
|
||||
const analyzeCommits = stub().resolves(2);
|
||||
const analyzeCommits = sinon.stub).resolves(2);
|
||||
const plugin = normalize(
|
||||
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
|
||||
'analyzeCommits',
|
||||
@@ -117,7 +118,7 @@ test('Wrap "analyzeCommits" plugin in a function that validate the output of the
|
||||
});
|
||||
|
||||
test('Wrap "generateNotes" plugin in a function that validate the output of the plugin', async (t) => {
|
||||
const generateNotes = stub().resolves(2);
|
||||
const generateNotes = sinon.stub).resolves(2);
|
||||
const plugin = normalize(
|
||||
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
|
||||
'generateNotes',
|
||||
@@ -135,7 +136,7 @@ test('Wrap "generateNotes" plugin in a function that validate the output of the
|
||||
});
|
||||
|
||||
test('Wrap "publish" plugin in a function that validate the output of the plugin', async (t) => {
|
||||
const publish = stub().resolves(2);
|
||||
const publish = sinon.stub).resolves(2);
|
||||
const plugin = normalize(
|
||||
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
|
||||
'publish',
|
||||
@@ -153,7 +154,7 @@ test('Wrap "publish" plugin in a function that validate the output of the plugin
|
||||
});
|
||||
|
||||
test('Wrap "addChannel" plugin in a function that validate the output of the plugin', async (t) => {
|
||||
const addChannel = stub().resolves(2);
|
||||
const addChannel = sinon.stub).resolves(2);
|
||||
const plugin = normalize(
|
||||
{cwd, options: {}, stderr: t.context.stderr, logger: t.context.logger},
|
||||
'addChannel',
|
||||
@@ -171,7 +172,7 @@ test('Wrap "addChannel" plugin in a function that validate the output of the plu
|
||||
});
|
||||
|
||||
test('Plugin is called with "pluginConfig" (with object definition) and input', async (t) => {
|
||||
const pluginFunction = stub().resolves();
|
||||
const pluginFunction = sinon.stub).resolves();
|
||||
const pluginConf = {path: pluginFunction, conf: 'confValue'};
|
||||
const options = {global: 'globalValue'};
|
||||
const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {});
|
||||
@@ -186,7 +187,7 @@ test('Plugin is called with "pluginConfig" (with object definition) and input',
|
||||
});
|
||||
|
||||
test('Plugin is called with "pluginConfig" (with array definition) and input', async (t) => {
|
||||
const pluginFunction = stub().resolves();
|
||||
const pluginFunction = sinon.stub).resolves();
|
||||
const pluginConf = [pluginFunction, {conf: 'confValue'}];
|
||||
const options = {global: 'globalValue'};
|
||||
const plugin = normalize({cwd, options, logger: t.context.logger}, '', pluginConf, {});
|
||||
@@ -201,7 +202,7 @@ test('Plugin is called with "pluginConfig" (with array definition) and input', a
|
||||
});
|
||||
|
||||
test('Prevent plugins to modify "pluginConfig"', async (t) => {
|
||||
const pluginFunction = stub().callsFake((pluginConfig) => {
|
||||
const pluginFunction = sinon.stub).callsFake((pluginConfig) => {
|
||||
pluginConfig.conf.subConf = 'otherConf';
|
||||
});
|
||||
const pluginConf = {path: pluginFunction, conf: {subConf: 'originalConf'}};
|
||||
@@ -214,7 +215,7 @@ test('Prevent plugins to modify "pluginConfig"', async (t) => {
|
||||
});
|
||||
|
||||
test('Prevent plugins to modify its input', async (t) => {
|
||||
const pluginFunction = stub().callsFake((pluginConfig, options) => {
|
||||
const pluginFunction = sinon.stub).callsFake((pluginConfig, options) => {
|
||||
options.param.subParam = 'otherParam';
|
||||
});
|
||||
const input = {param: {subParam: 'originalSubParam'}, options: {}};
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const test = require('ava');
|
||||
const {stub} = require('sinon');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const pipeline = require('../../lib/plugins/pipeline');
|
||||
import test from 'ava';
|
||||
import sinon from 'sinon';
|
||||
import AggregateError from 'aggregate-error';
|
||||
import pipeline from '../../lib/plugins/pipeline.js';
|
||||
|
||||
test('Execute each function in series passing the same input', async (t) => {
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().resolves(2);
|
||||
const step3 = stub().resolves(3);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).resolves(2);
|
||||
const step3 = sinon.stub).resolves(3);
|
||||
|
||||
const result = await pipeline([step1, step2, step3])(0);
|
||||
t.deepEqual(result, [1, 2, 3]);
|
||||
@@ -19,10 +19,10 @@ test('Execute each function in series passing the same input', async (t) => {
|
||||
});
|
||||
|
||||
test('Execute each function in series passing a transformed input from "getNextInput"', async (t) => {
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().resolves(2);
|
||||
const step3 = stub().resolves(3);
|
||||
const step4 = stub().resolves(4);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).resolves(2);
|
||||
const step3 = sinon.stub).resolves(3);
|
||||
const step4 = sinon.stub).resolves(4);
|
||||
const getNextInput = (lastResult, result) => lastResult + result;
|
||||
|
||||
const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(0);
|
||||
@@ -38,11 +38,11 @@ test('Execute each function in series passing a transformed input from "getNextI
|
||||
});
|
||||
|
||||
test('Execute each function in series passing the "lastResult" and "result" to "getNextInput"', async (t) => {
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().resolves(2);
|
||||
const step3 = stub().resolves(3);
|
||||
const step4 = stub().resolves(4);
|
||||
const getNextInput = stub().returnsArg(0);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).resolves(2);
|
||||
const step3 = sinon.stub).resolves(3);
|
||||
const step4 = sinon.stub).resolves(4);
|
||||
const getNextInput = sinon.stub).returnsArg(0);
|
||||
|
||||
const result = await pipeline([step1, step2, step3, step4], {settleAll: false, getNextInput})(5);
|
||||
|
||||
@@ -56,12 +56,12 @@ test('Execute each function in series passing the "lastResult" and "result" to "
|
||||
});
|
||||
|
||||
test('Execute each function in series calling "transform" to modify the results', async (t) => {
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().resolves(2);
|
||||
const step3 = stub().resolves(3);
|
||||
const step4 = stub().resolves(4);
|
||||
const getNextInput = stub().returnsArg(0);
|
||||
const transform = stub().callsFake((result) => result + 1);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).resolves(2);
|
||||
const step3 = sinon.stub).resolves(3);
|
||||
const step4 = sinon.stub).resolves(4);
|
||||
const getNextInput = sinon.stub).returnsArg(0);
|
||||
const transform = sinon.stub).callsFake((result) => result + 1);
|
||||
|
||||
const result = await pipeline([step1, step2, step3, step4], {getNextInput, transform})(5);
|
||||
|
||||
@@ -75,12 +75,12 @@ test('Execute each function in series calling "transform" to modify the results'
|
||||
});
|
||||
|
||||
test('Execute each function in series calling "transform" to modify the results with "settleAll"', async (t) => {
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().resolves(2);
|
||||
const step3 = stub().resolves(3);
|
||||
const step4 = stub().resolves(4);
|
||||
const getNextInput = stub().returnsArg(0);
|
||||
const transform = stub().callsFake((result) => result + 1);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).resolves(2);
|
||||
const step3 = sinon.stub).resolves(3);
|
||||
const step4 = sinon.stub).resolves(4);
|
||||
const getNextInput = sinon.stub).returnsArg(0);
|
||||
const transform = sinon.stub).callsFake((result) => result + 1);
|
||||
|
||||
const result = await pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput, transform})(5);
|
||||
|
||||
@@ -94,9 +94,9 @@ test('Execute each function in series calling "transform" to modify the results
|
||||
});
|
||||
|
||||
test('Stop execution and throw error if a step rejects', async (t) => {
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().rejects(new Error('test error'));
|
||||
const step3 = stub().resolves(3);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).rejects(new Error('test error'));
|
||||
const step3 = sinon.stub).resolves(3);
|
||||
|
||||
const error = await t.throwsAsync(pipeline([step1, step2, step3])(0), {
|
||||
instanceOf: Error,
|
||||
@@ -112,9 +112,9 @@ test('Throw all errors from the first step throwing an AggregateError', async (t
|
||||
const error1 = new Error('test error 1');
|
||||
const error2 = new Error('test error 2');
|
||||
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().rejects(new AggregateError([error1, error2]));
|
||||
const step3 = stub().resolves(3);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).rejects(new AggregateError([error1, error2]));
|
||||
const step3 = sinon.stub).resolves(3);
|
||||
|
||||
const errors = await t.throwsAsync(pipeline([step1, step2, step3])(0));
|
||||
|
||||
@@ -127,9 +127,9 @@ test('Throw all errors from the first step throwing an AggregateError', async (t
|
||||
test('Execute all even if a Promise rejects', async (t) => {
|
||||
const error1 = new Error('test error 1');
|
||||
const error2 = new Error('test error 2');
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().rejects(error1);
|
||||
const step3 = stub().rejects(error2);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).rejects(error1);
|
||||
const step3 = sinon.stub).rejects(error2);
|
||||
|
||||
const errors = await t.throwsAsync(pipeline([step1, step2, step3], {settleAll: true})(0));
|
||||
|
||||
@@ -144,8 +144,8 @@ test('Throw all errors from all steps throwing an AggregateError', async (t) =>
|
||||
const error2 = new Error('test error 2');
|
||||
const error3 = new Error('test error 3');
|
||||
const error4 = new Error('test error 4');
|
||||
const step1 = stub().rejects(new AggregateError([error1, error2]));
|
||||
const step2 = stub().rejects(new AggregateError([error3, error4]));
|
||||
const step1 = sinon.stub).rejects(new AggregateError([error1, error2]));
|
||||
const step2 = sinon.stub).rejects(new AggregateError([error3, error4]));
|
||||
|
||||
const errors = await t.throwsAsync(pipeline([step1, step2], {settleAll: true})(0));
|
||||
|
||||
@@ -157,10 +157,10 @@ test('Throw all errors from all steps throwing an AggregateError', async (t) =>
|
||||
test('Execute each function in series passing a transformed input even if a step rejects', async (t) => {
|
||||
const error2 = new Error('test error 2');
|
||||
const error3 = new Error('test error 3');
|
||||
const step1 = stub().resolves(1);
|
||||
const step2 = stub().rejects(error2);
|
||||
const step3 = stub().rejects(error3);
|
||||
const step4 = stub().resolves(4);
|
||||
const step1 = sinon.stub).resolves(1);
|
||||
const step2 = sinon.stub).rejects(error2);
|
||||
const step3 = sinon.stub).rejects(error3);
|
||||
const step4 = sinon.stub).resolves(4);
|
||||
const getNextInput = (previousResult, result) => previousResult + result;
|
||||
|
||||
const errors = await t.throwsAsync(pipeline([step1, step2, step3, step4], {settleAll: true, getNextInput})(0));
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
const path = require('path');
|
||||
const test = require('ava');
|
||||
const {copy, outputFile} = require('fs-extra');
|
||||
const {stub} = require('sinon');
|
||||
const tempy = require('tempy');
|
||||
const getPlugins = require('../../lib/plugins');
|
||||
import path from 'path';
|
||||
import test from 'ava';
|
||||
import {copy, outputFile} from 'fs-extra';
|
||||
import sinon from 'sinon';
|
||||
import tempy from 'tempy';
|
||||
import getPlugins from '../../lib/plugins';
|
||||
|
||||
// Save the current working diretory
|
||||
const cwd = process.cwd();
|
||||
|
||||
test.beforeEach((t) => {
|
||||
// Stub the logger functions
|
||||
t.context.log = stub();
|
||||
t.context.success = stub();
|
||||
t.context.log = sinon.stub);
|
||||
t.context.success = sinon.stub);
|
||||
t.context.logger = {log: t.context.log, success: t.context.success, scope: () => t.context.logger};
|
||||
});
|
||||
|
||||
@@ -56,8 +56,8 @@ test('Export plugins based on steps config', (t) => {
|
||||
});
|
||||
|
||||
test('Export plugins based on "plugins" config (array)', async (t) => {
|
||||
const plugin1 = {verifyConditions: stub(), publish: stub()};
|
||||
const plugin2 = {verifyConditions: stub(), verifyRelease: stub()};
|
||||
const plugin1 = {verifyConditions: sinon.stub), publish: sinon.stub)};
|
||||
const plugin2 = {verifyConditions: sinon.stub), verifyRelease: sinon.stub)};
|
||||
const plugins = getPlugins(
|
||||
{cwd, logger: t.context.logger, options: {plugins: [plugin1, [plugin2, {}]], verifyRelease: () => {}}},
|
||||
{}
|
||||
@@ -85,7 +85,7 @@ test('Export plugins based on "plugins" config (array)', async (t) => {
|
||||
});
|
||||
|
||||
test('Export plugins based on "plugins" config (single definition)', async (t) => {
|
||||
const plugin1 = {verifyConditions: stub(), publish: stub()};
|
||||
const plugin1 = {verifyConditions: sinon.stub), publish: sinon.stub)};
|
||||
const plugins = getPlugins({cwd, logger: t.context.logger, options: {plugins: plugin1}}, {});
|
||||
|
||||
await plugins.verifyConditions({options: {}});
|
||||
@@ -106,8 +106,8 @@ test('Export plugins based on "plugins" config (single definition)', async (t) =
|
||||
});
|
||||
|
||||
test('Merge global options, "plugins" options and step options', async (t) => {
|
||||
const plugin1 = [{verifyConditions: stub(), publish: stub()}, {pluginOpt1: 'plugin1'}];
|
||||
const plugin2 = [{verifyConditions: stub()}, {pluginOpt2: 'plugin2'}];
|
||||
const plugin1 = [{verifyConditions: sinon.stub), publish: sinon.stub)}, {pluginOpt1: 'plugin1'}];
|
||||
const plugin2 = [{verifyConditions: sinon.stub)}, {pluginOpt2: 'plugin2'}];
|
||||
const plugin3 = [stub(), {pluginOpt3: 'plugin3'}];
|
||||
const plugins = getPlugins(
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const test = require('ava');
|
||||
const {validatePlugin, validateStep, loadPlugin, parseConfig} = require('../../lib/plugins/utils');
|
||||
import test from 'ava';
|
||||
import {validatePlugin, validateStep, loadPlugin, parseConfig} from '../../lib/plugins/utils.js';
|
||||
|
||||
test('validatePlugin', (t) => {
|
||||
const path = 'plugin-module';
|
||||
|
||||
+5
-4
@@ -1,6 +1,7 @@
|
||||
const test = require('ava');
|
||||
const AggregateError = require('aggregate-error');
|
||||
const {
|
||||
import test from 'ava';
|
||||
import AggregateError from 'aggregate-error';
|
||||
|
||||
import {
|
||||
extractErrors,
|
||||
tagsToVersions,
|
||||
isMajorRange,
|
||||
@@ -15,7 +16,7 @@ const {
|
||||
getRange,
|
||||
makeTag,
|
||||
isSameChannel,
|
||||
} = require('../lib/utils');
|
||||
} from '../lib/utils.js';
|
||||
|
||||
test('extractErrors', (t) => {
|
||||
const errors = [new Error('Error 1'), new Error('Error 2')];
|
||||
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
const test = require('ava');
|
||||
const tempy = require('tempy');
|
||||
const verify = require('../lib/verify');
|
||||
const {gitRepo} = require('./helpers/git-utils');
|
||||
import test from 'ava';
|
||||
import tempy from 'tempy';
|
||||
import verify from '../lib/verify.js';
|
||||
import {gitRepo} from './helpers/git-utils.js';
|
||||
|
||||
test('Throw a AggregateError', async (t) => {
|
||||
const {cwd} = await gitRepo();
|
||||
|
||||
Reference in New Issue
Block a user