semantic-release 12.2.4 → 12.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cli.js CHANGED
@@ -1,6 +1,5 @@
1
1
  const program = require('commander');
2
2
  const {pickBy, isUndefined} = require('lodash');
3
- const logger = require('./lib/logger');
4
3
 
5
4
  function list(values) {
6
5
  return values.split(',').map(value => value.trim());
@@ -48,15 +47,13 @@ module.exports = async () => {
48
47
  program.outputHelp();
49
48
  process.exitCode = 1;
50
49
  } else {
50
+ const opts = program.opts();
51
+ // Set the `noCi` options as commander.js sets the `ci` options instead (becasue args starts with `--no`)
52
+ opts.noCi = opts.ci === false ? true : undefined;
51
53
  // Remove option with undefined values, as commander.js sets non defined options as `undefined`
52
- await require('.')(pickBy(program.opts(), value => !isUndefined(value)));
54
+ await require('.')(pickBy(opts, value => !isUndefined(value)));
53
55
  }
54
56
  } catch (err) {
55
57
  process.exitCode = 1;
56
- if (err.semanticRelease) {
57
- logger.log(`%s ${err.message}`, err.code);
58
- } else {
59
- logger.error('An error occurred while running semantic-release: %O', err);
60
- }
61
58
  }
62
59
  };
@@ -16,7 +16,9 @@ For projects that require to be tested only with a single [Node version](https:/
16
16
 
17
17
  This example is a minimal configuration for semantic-release with a build running Node 8 on Linux. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
18
18
 
19
- It's recommended to run the `semantic-release` command in the [Travis `script` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error happen the build will fail and Travis will send a notification.
19
+ It's recommended to run the `semantic-release` command in the [Travis `deploy` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error occurs the build will fail and Travis will send a notification.
20
+
21
+ **Note**: It's not recommended to run the `semantic-release` command in the Travis `script` step as each script in this step will be executed regardless of the outcome of the previous one. See [travis-ci/travis-ci#1066](https://github.com/travis-ci/travis-ci/issues/1066).
20
22
 
21
23
  **Note**: 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.
22
24
 
@@ -29,12 +31,14 @@ script:
29
31
  # Run tests
30
32
  - npm run test
31
33
 
32
- # Only for a local semantic-release installation
33
- - npm run semantic-release
34
-
35
- # Only for a global semantic-release installation
36
- - npm install -g semantic-release
37
- - semantic-release
34
+ deploy:
35
+ provider: script
36
+ skip_cleanup: true
37
+ script:
38
+ # Only for a local semantic-release installation
39
+ - npm run semantic-release
40
+ # Only for a global semantic-release installation
41
+ - npm install -g semantic-release && semantic-release
38
42
  ```
39
43
 
40
44
  ### `package.json` configuration for single Node job
@@ -56,7 +60,7 @@ A `package.json` is required only for [local](../usage/installation.md#local-ins
56
60
 
57
61
  For projects that require to be tested with multiple [Node versions](https://docs.travis-ci.com/user/languages/javascript-with-nodejs/#Specifying-Node.js-versions) and/or on multiple [Operating Systems](https://docs.travis-ci.com/user/multi-os).
58
62
 
59
- **Note**: At least one job must run a [Node >= 8 version](../support/FAQ.md#why-does-semantic-release-require-node-version--8).
63
+ **Note**: At least one job must run a [Node >= 8 version](../support/FAQ.md#why-does-semantic-release-require-node-version--83).
60
64
 
61
65
  ### `.travis.yml` configuration for multiple Node jobs
62
66
 
@@ -64,7 +68,9 @@ This example is a minimal configuration for **semantic-release** with a build ru
64
68
 
65
69
  This example uses [`travis-deploy-once`](https://github.com/semantic-release/travis-deploy-once) in order to command [Run `semantic-release` only after all tests succeeded](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded). Alternatively you can use [Travis CI Build Stages recipe](travis-build-stages.md).
66
70
 
67
- It's recommended to run the `semantic-release` command in the [Travis `script` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error happen the build will fail and Travis will send a notification.
71
+ It's recommended to run the `semantic-release` command in the [Travis `deploy` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error occurs the build will fail and Travis will send a notification.
72
+
73
+ **Note**: It's not recommended to run the `semantic-release` command in the Travis `script` step as each script in this step will be executed regardless of the outcome of the previous one. See [travis-ci/travis-ci#1066](https://github.com/travis-ci/travis-ci/issues/1066).
68
74
 
69
75
  **Note**: 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.
70
76
 
@@ -84,12 +90,14 @@ script:
84
90
  # Run tests
85
91
  - npm run test
86
92
 
87
- # Only for a local semantic-release installation
88
- - npm run travis-deploy-once "npm run semantic-release"
89
-
90
- # Only for a global semantic-release installation
91
- - npm install -g travis-deploy-once semantic-release
92
- - travis-deploy-once "semantic-release"
93
+ deploy:
94
+ provider: script
95
+ skip_cleanup: true
96
+ script:
97
+ # Only for a local semantic-release installation
98
+ - npm run travis-deploy-once "npm run semantic-release"
99
+ # Only for a global semantic-release installation
100
+ - npm install -g travis-deploy-once semantic-release && travis-deploy-once "semantic-release"
93
101
  ```
94
102
 
95
103
  **Note**: See the `travis-deploy-once` [`pro`](https://github.com/semantic-release/travis-deploy-once#-p---pro) and [`travis-url`](https://github.com/semantic-release/travis-deploy-once#-u---travis-url) options for using with [Travis Pro](https://docs.travis-ci.com/user/travis-pro) and [Travis Enterprise](https://enterprise.travis-ci.com).
@@ -123,7 +131,9 @@ This example is a minimal configuration for semantic-release with a build runnin
123
131
 
124
132
  This example uses [`travis-deploy-once`](https://github.com/semantic-release/travis-deploy-once) in order to [run `semantic-release` only after all tests succeeded](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded). Alternatively you can use [Travis CI Build Stages recipe](travis-build-stages.md).
125
133
 
126
- It's recommended to run the `semantic-release` command in the [Travis `script` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error happen the build will fail and Travis will send a notification.
134
+ It's recommended to run the `semantic-release` command in the [Travis `deploy` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error occurs the build will fail and Travis will send a notification.
135
+
136
+ **Note**: It's not recommended to run the `semantic-release` command in the Travis `script` step as each script in this step will be executed regardless of the outcome of the previous one. See [travis-ci/travis-ci#1066](https://github.com/travis-ci/travis-ci/issues/1066).
127
137
 
128
138
  ```yaml
129
139
  language: go
@@ -140,12 +150,16 @@ script:
140
150
  # Run tests
141
151
  - go test -v ./...
142
152
 
143
- # Use nvm to install and use the Node LTS version (nvm is installed on Travis images)
144
- - nvm install lts/*
145
- # Install travis-deploy-once and semantic-release
146
- - npm install -g travis-deploy-once semantic-release
147
- # Run semantic-release only on job, after all other are successful
148
- - travis-deploy-once "semantic-release"
153
+ deploy:
154
+ provider: script
155
+ skip_cleanup: true
156
+ script:
157
+ # Use nvm to install and use the Node LTS version (nvm is installed on all Travis images)
158
+ - nvm install lts/*
159
+ # Install travis-deploy-once and semantic-release
160
+ - npm install -g travis-deploy-once semantic-release
161
+ # Run semantic-release only on job, after all other are successful
162
+ - travis-deploy-once "semantic-release"
149
163
  ```
150
164
 
151
165
  **Note**: See the `travis-deploy-once` [`pro`](https://github.com/semantic-release/travis-deploy-once#-p---pro) and [`travis-url`](https://github.com/semantic-release/travis-deploy-once#-u---travis-url) options for using with [Travis Pro](https://docs.travis-ci.com/user/travis-pro) and [Travis Enterprise](https://enterprise.travis-ci.com).
package/index.js CHANGED
@@ -1,21 +1,25 @@
1
1
  const marked = require('marked');
2
2
  const TerminalRenderer = require('marked-terminal');
3
3
  const envCi = require('env-ci');
4
+ const hookStd = require('hook-std');
5
+ const hideSensitive = require('./lib/hide-sensitive');
4
6
  const getConfig = require('./lib/get-config');
5
7
  const getNextVersion = require('./lib/get-next-version');
6
8
  const getCommits = require('./lib/get-commits');
7
9
  const logger = require('./lib/logger');
8
10
  const {gitHead: getGitHead, isGitRepo} = require('./lib/git');
9
11
 
10
- module.exports = async opts => {
12
+ async function run(opts) {
11
13
  const {isCi, branch, isPr} = envCi();
14
+ const config = await getConfig(opts, logger);
15
+ const {plugins, options} = config;
12
16
 
13
- if (!isCi && !opts.dryRun && !opts.noCi) {
17
+ if (!isCi && !options.dryRun && !options.noCi) {
14
18
  logger.log('This run was not triggered in a known CI environment, running in dry-run mode.');
15
- opts.dryRun = true;
19
+ options.dryRun = true;
16
20
  }
17
21
 
18
- if (isCi && isPr && !opts.noCi) {
22
+ if (isCi && isPr && !options.noCi) {
19
23
  logger.log("This run was triggered by a pull request and therefore a new version won't be published.");
20
24
  return;
21
25
  }
@@ -25,9 +29,6 @@ module.exports = async opts => {
25
29
  return;
26
30
  }
27
31
 
28
- const config = await getConfig(opts, logger);
29
- const {plugins, options} = config;
30
-
31
32
  if (branch !== options.branch) {
32
33
  logger.log(
33
34
  `This test run was triggered on the branch ${branch}, while semantic-release is configured to only publish from ${
@@ -40,7 +41,7 @@ module.exports = async opts => {
40
41
  logger.log('Run automated release from branch %s', options.branch);
41
42
 
42
43
  logger.log('Call plugin %s', 'verify-conditions');
43
- await plugins.verifyConditions({options, logger});
44
+ await plugins.verifyConditions({options, logger}, true);
44
45
 
45
46
  logger.log('Call plugin %s', 'get-last-release');
46
47
  const {commits, lastRelease} = await getCommits(
@@ -64,7 +65,7 @@ module.exports = async opts => {
64
65
  const nextRelease = {type, version, gitHead: await getGitHead(), gitTag: `v${version}`};
65
66
 
66
67
  logger.log('Call plugin %s', 'verify-release');
67
- await plugins.verifyRelease({options, logger, lastRelease, commits, nextRelease});
68
+ await plugins.verifyRelease({options, logger, lastRelease, commits, nextRelease}, true);
68
69
 
69
70
  const generateNotesParam = {options, logger, lastRelease, commits, nextRelease};
70
71
 
@@ -79,7 +80,7 @@ module.exports = async opts => {
79
80
  nextRelease.notes = await plugins.generateNotes(generateNotesParam);
80
81
 
81
82
  logger.log('Call plugin %s', 'publish');
82
- await plugins.publish({options, logger, lastRelease, commits, nextRelease}, async prevInput => {
83
+ await plugins.publish({options, logger, lastRelease, commits, nextRelease}, false, async prevInput => {
83
84
  const newGitHead = await getGitHead();
84
85
  // If previous publish plugin has created a commit (gitHead changed)
85
86
  if (prevInput.nextRelease.gitHead !== newGitHead) {
@@ -94,4 +95,24 @@ module.exports = async opts => {
94
95
  logger.log('Published release: %s', nextRelease.version);
95
96
  }
96
97
  return true;
98
+ }
99
+
100
+ module.exports = async opts => {
101
+ const unhook = hookStd({silent: false}, hideSensitive);
102
+ try {
103
+ const result = await run(opts);
104
+ unhook();
105
+ return result;
106
+ } catch (err) {
107
+ const errors = err.name === 'AggregateError' ? Array.from(err).sort(error => !error.semanticRelease) : [err];
108
+ for (const error of errors) {
109
+ if (error.semanticRelease) {
110
+ logger.log(`%s ${error.message}`, error.code);
111
+ } else {
112
+ logger.error('An error occurred while running semantic-release: %O', error);
113
+ }
114
+ }
115
+ unhook();
116
+ throw err;
117
+ }
97
118
  };
@@ -0,0 +1,8 @@
1
+ const {escapeRegExp} = require('lodash');
2
+
3
+ const toReplace = Object.keys(process.env).filter(envVar => /token|password|credential|secret|private/i.test(envVar));
4
+ const regexp = new RegExp(toReplace.map(envVar => escapeRegExp(process.env[envVar])).join('|'), 'g');
5
+
6
+ module.exports = output => {
7
+ return output && toReplace.length > 0 ? output.toString().replace(regexp, '[secure]') : output;
8
+ };
@@ -1,19 +1,33 @@
1
1
  const {identity} = require('lodash');
2
+ const pReflect = require('p-reflect');
2
3
  const pReduce = require('p-reduce');
4
+ const AggregateError = require('aggregate-error');
3
5
 
4
- module.exports = steps => async (input, getNextInput = identity) => {
6
+ module.exports = steps => async (input, settleAll = false, getNextInput = identity) => {
5
7
  const results = [];
8
+ const errors = [];
6
9
  await pReduce(
7
10
  steps,
8
11
  async (prevResult, nextStep) => {
9
- // Call the next step with the input computed at the end of the previous iteration
10
- const result = await nextStep(prevResult);
11
- // Save intermediary result
12
- results.push(result);
12
+ let result;
13
+
14
+ // Call the next step with the input computed at the end of the previous iteration and save intermediary result
15
+ if (settleAll) {
16
+ const {isFulfilled, value, reason} = await pReflect(nextStep(prevResult));
17
+ result = isFulfilled ? value : reason;
18
+ (isFulfilled ? results : errors).push(result);
19
+ } else {
20
+ result = await nextStep(prevResult);
21
+ results.push(result);
22
+ }
23
+
13
24
  // Prepare input for next step, passing the result of the previous iteration and the current one
14
25
  return getNextInput(prevResult, result);
15
26
  },
16
27
  input
17
28
  );
29
+ if (errors.length > 0) {
30
+ throw new AggregateError(errors);
31
+ }
18
32
  return results;
19
33
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "semantic-release",
3
3
  "description": "Automated semver compliant package publishing",
4
- "version": "12.2.4",
4
+ "version": "12.4.1",
5
5
  "author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
6
6
  "bin": {
7
7
  "semantic-release": "bin/semantic-release.js"
@@ -24,6 +24,7 @@
24
24
  "@semantic-release/github": "^3.0.1",
25
25
  "@semantic-release/npm": "^2.0.0",
26
26
  "@semantic-release/release-notes-generator": "^6.0.0",
27
+ "aggregate-error": "^1.0.0",
27
28
  "chalk": "^2.3.0",
28
29
  "commander": "^2.11.0",
29
30
  "cosmiconfig": "^4.0.0",
@@ -32,16 +33,19 @@
32
33
  "execa": "^0.9.0",
33
34
  "get-stream": "^3.0.0",
34
35
  "git-log-parser": "^1.2.0",
36
+ "hook-std": "^0.4.0",
35
37
  "lodash": "^4.17.4",
36
38
  "marked": "^0.3.9",
37
39
  "marked-terminal": "^2.0.0",
38
40
  "p-reduce": "^1.0.0",
41
+ "p-reflect": "^1.0.0",
39
42
  "read-pkg-up": "^3.0.0",
40
43
  "resolve-from": "^4.0.0",
41
44
  "semver": "^5.4.1"
42
45
  },
43
46
  "devDependencies": {
44
- "ava": "^0.24.0",
47
+ "ava": "^0.25.0",
48
+ "clear-module": "^2.1.0",
45
49
  "codecov": "^3.0.0",
46
50
  "commitizen": "^2.9.6",
47
51
  "cz-conventional-changelog": "^2.0.0",
@@ -107,7 +111,7 @@
107
111
  "trailingComma": "es5"
108
112
  },
109
113
  "publishConfig": {
110
- "tag": "next"
114
+ "tag": "latest"
111
115
  },
112
116
  "release": {
113
117
  "branch": "caribou"