release-it 12.3.6 → 12.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -287,7 +287,7 @@ overridden. To customize the release notes for the GitHub or GitLab release, use
287
287
  `gitlab.releaseNotes`. Make sure any of these commands output the changelog to `stdout`.
288
288
 
289
289
  Instead of executing a shell command, a (Handlebars) template can be used to generate the changelog. See
290
- [auto-changelog](./docs/changelogs#auto-changelog) for more details. If your project follows conventions, such as the
290
+ [auto-changelog](./docs/changelog.md#auto-changelog) for more details. If your project follows conventions, such as the
291
291
  [Angular commit guidelines](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits), the
292
292
  [@release-it/conventional-changelog](https://github.com/release-it/conventional-changelog) plugin is useful.
293
293
 
@@ -355,6 +355,8 @@ repo.remote, repo.protocol, repo.host, repo.owner, repo.repository, repo.project
355
355
  All variables are available in all hooks. The only exception is that the additional variables listed above are not
356
356
  available in the `init` hook.
357
357
 
358
+ Use `--verbose` to also log the output of the commands.
359
+
358
360
  ## Scripts (deprecated)
359
361
 
360
362
  Please use [hooks](#hooks) instead, as hooks are more flexible. The `scripts` will stay for a while, but will be removed
@@ -389,7 +391,8 @@ Use `--disable-metrics` to opt-out of sending some anonymous statistical data to
389
391
 
390
392
  ## Troubleshooting & debugging
391
393
 
392
- - With `release-it --verbose`, release-it prints every command and its output.
394
+ - With `release-it --verbose` (or `-V`), release-it prints every custom script/hook and its output.
395
+ - With `release-it -VV`, release-it prints every command (also internal) and its output.
393
396
  - Prepend `DEBUG=release-it:* release-it [...]` to print configuration and more error details.
394
397
  - Use `DEBUG=* release-it [...]` to include debug output for dependencies, such as
395
398
  [@octokit/rest](https://github.com/octokit/rest.js).
@@ -403,6 +406,7 @@ While mostly used as a CLI tool, release-it can be used as a dependency to ingra
403
406
 
404
407
  - [react-navigation/react-navigation](https://github.com/react-navigation/react-navigation)
405
408
  - [swagger-api/swagger-ui](https://github.com/swagger-api/swagger-ui)
409
+ - [js-cookie/js-cookie](https://github.com/js-cookie/js-cookie)
406
410
  - [StevenBlack/hosts](https://github.com/StevenBlack/hosts)
407
411
  - [react-native-community/react-native-tab-view](https://github.com/react-native-community/react-native-tab-view)
408
412
  - [callstack/linaria](https://github.com/callstack/linaria)
package/bin/release-it.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  const updater = require('update-notifier');
4
- const pkg = require('../package.json');
5
4
  const parseArgs = require('yargs-parser');
5
+ const pkg = require('../package.json');
6
6
  const release = require('../lib');
7
7
 
8
8
  const aliases = {
@@ -17,12 +17,13 @@ const aliases = {
17
17
 
18
18
  const parseCliArguments = args => {
19
19
  const options = parseArgs(args, {
20
- boolean: ['dry-run', 'ci', 'non-interactive', 'verbose'],
20
+ boolean: ['dry-run', 'ci', 'non-interactive'],
21
21
  alias: aliases,
22
22
  default: {
23
23
  'dry-run': false,
24
- verbose: false
24
+ verbose: 0
25
25
  },
26
+ count: ['verbose'],
26
27
  configuration: {
27
28
  'parse-numbers': false
28
29
  }
package/lib/config.js CHANGED
@@ -86,6 +86,10 @@ class Config {
86
86
  return Boolean(this.options.verbose);
87
87
  }
88
88
 
89
+ get verbosityLevel() {
90
+ return this.options.verbose;
91
+ }
92
+
89
93
  get isDebug() {
90
94
  return debug.enabled;
91
95
  }
package/lib/log.js CHANGED
@@ -1,11 +1,12 @@
1
1
  const { EOL } = require('os');
2
2
  const chalk = require('chalk');
3
- const _ = require('lodash');
3
+ const { isObject, last, filter, isString, lowerCase, upperFirst } = require('lodash');
4
4
 
5
5
  class Logger {
6
- constructor({ isCI = true, isVerbose = false, isDryRun = false } = {}) {
6
+ constructor({ isCI = true, isVerbose = false, verbosityLevel = 0, isDryRun = false } = {}) {
7
7
  this.isCI = isCI;
8
8
  this.isVerbose = isVerbose;
9
+ this.verbosityLevel = verbosityLevel;
9
10
  this.isDryRun = isDryRun;
10
11
  }
11
12
  log(...args) {
@@ -21,13 +22,16 @@ class Logger {
21
22
  this.log(chalk.yellow('WARNING'), ...args);
22
23
  }
23
24
  verbose(...args) {
24
- this.isVerbose && this.log(...args);
25
+ const { isExternal } = isObject(last(args)) ? last(args) : {};
26
+ if (this.verbosityLevel === 2 || (this.isVerbose && (isExternal || this.isDryRun))) {
27
+ this.log(...filter(args, isString));
28
+ }
25
29
  }
26
30
  exec(...args) {
27
- if (this.isVerbose || this.isDryRun) {
28
- const isNotExecuted = typeof _.last(args) === 'boolean' && _.last(args) === true;
29
- const prefix = isNotExecuted ? '!' : '$';
30
- this.log(prefix, ..._.filter(args, _.isString));
31
+ const { isDryRun: isExecutedInDryRun, isExternal } = isObject(last(args)) ? last(args) : {};
32
+ if (this.verbosityLevel === 2 || this.isDryRun || (this.isVerbose && isExternal)) {
33
+ const prefix = isExecutedInDryRun == null ? '$' : '!';
34
+ this.log(prefix, ...filter(args, isString));
31
35
  }
32
36
  }
33
37
  obtrusive(...args) {
@@ -37,11 +41,11 @@ class Logger {
37
41
  }
38
42
  preview({ title, text }) {
39
43
  if (text) {
40
- const header = chalk.bold(_.upperFirst(title));
44
+ const header = chalk.bold(upperFirst(title));
41
45
  const body = text.replace(new RegExp(EOL + EOL, 'g'), EOL);
42
46
  this.obtrusive(`${header}:${EOL}${body}`);
43
47
  } else {
44
- this.obtrusive(`Empty ${_.lowerCase(title)}`);
48
+ this.obtrusive(`Empty ${lowerCase(title)}`);
45
49
  }
46
50
  }
47
51
  }
@@ -74,7 +74,7 @@ class Git extends GitBase {
74
74
 
75
75
  async getCommitsSinceLatestTag() {
76
76
  const latestTagName = await this.getLatestTagName();
77
- return this.exec(`git rev-list ${latestTagName}..HEAD --count`, { options }).then(Number);
77
+ return this.exec(`git rev-list ${latestTagName ? `${latestTagName}..` : ''}HEAD --count`, { options }).then(Number);
78
78
  }
79
79
 
80
80
  stage(file) {
@@ -92,7 +92,7 @@ class GitHub extends Release {
92
92
  const name = format(releaseName, { version });
93
93
  const body = releaseNotes;
94
94
 
95
- this.log.exec(`octokit releases#draftRelease "${name}" (${tagName})`, isDryRun);
95
+ this.log.exec(`octokit releases#draftRelease "${name}" (${tagName})`, { isDryRun });
96
96
 
97
97
  if (isDryRun) {
98
98
  this.releaseUrl = this.getReleaseUrlFallback(tagName);
@@ -161,7 +161,7 @@ class GitHub extends Release {
161
161
  const { assets } = this.options;
162
162
  const { isDryRun } = this.global;
163
163
 
164
- this.log.exec('octokit releases#uploadAssets', assets, isDryRun);
164
+ this.log.exec('octokit releases#uploadAssets', assets, { isDryRun });
165
165
 
166
166
  if (!assets || !this.isReleased || isDryRun) {
167
167
  return noop;
@@ -187,7 +187,7 @@ class GitHub extends Release {
187
187
  const { isDryRun } = this.global;
188
188
  const tag_name = format(tagName, { version });
189
189
 
190
- this.log.exec(`octokit releases#publishRelease (${tagName})`, isDryRun);
190
+ this.log.exec(`octokit releases#publishRelease (${tagName})`, { isDryRun });
191
191
 
192
192
  if (isDryRun || draft) return;
193
193
 
@@ -71,7 +71,7 @@ class GitLab extends Release {
71
71
  const name = format(releaseName, { version });
72
72
  const description = releaseNotes || '-';
73
73
 
74
- this.log.exec(`gitlab releases#createRelease "${name}" (${tagName})`, isDryRun);
74
+ this.log.exec(`gitlab releases#createRelease "${name}" (${tagName})`, { isDryRun });
75
75
 
76
76
  if (isDryRun) {
77
77
  this.releaseUrl = `${this.origin}/${repo.repository}/releases`;
@@ -148,7 +148,7 @@ class GitLab extends Release {
148
148
  const { assets } = this.options;
149
149
  const { isDryRun } = this.global;
150
150
 
151
- this.log.exec('gitlab releases#uploadAssets', assets, isDryRun);
151
+ this.log.exec('gitlab releases#uploadAssets', assets, { isDryRun });
152
152
 
153
153
  if (!assets || isDryRun) {
154
154
  return noop;
@@ -118,10 +118,12 @@ class npm extends Plugin {
118
118
  }
119
119
 
120
120
  async getLatestRegistryVersion() {
121
+ const registry = this.getRegistry();
122
+ const registryArg = registry !== NPM_DEFAULT_REGISTRY ? ` --registry ${registry}` : '';
121
123
  const name = this.getName();
122
124
  const latestVersion = this.getLatestVersion();
123
125
  const tag = await this.resolveTag(latestVersion);
124
- return this.exec(`npm show ${name}@${tag} version`, { options }).catch(() => null);
126
+ return this.exec(`npm show ${name}@${tag} version${registryArg}`, { options }).catch(() => null);
125
127
  }
126
128
 
127
129
  getRegistryPreReleaseTags() {
package/lib/shell.js CHANGED
@@ -20,11 +20,13 @@ class Shell {
20
20
  const normalizedCmd = command.replace(forcedCmdRe, '').trim();
21
21
  const program = normalizedCmd.split(' ')[0];
22
22
  const programArgs = normalizedCmd.split(' ').slice(1);
23
+ const isDryRun = this.global.isDryRun;
23
24
  const isWrite = options.write !== false;
24
25
  const cacheable = options.cache === true;
26
+ const isExternal = options.external === true;
25
27
 
26
- if (this.global.isDryRun && isWrite) {
27
- this.log.exec(normalizedCmd, this.global.isDryRun);
28
+ if (isDryRun && isWrite) {
29
+ this.log.exec(normalizedCmd, { isDryRun });
28
30
  return noop;
29
31
  }
30
32
 
@@ -33,10 +35,10 @@ class Shell {
33
35
  }
34
36
 
35
37
  const awaitExec = new Promise((resolve, reject) => {
38
+ this.log.exec(normalizedCmd, { isExternal });
36
39
  const cb = (code, stdout, stderr) => {
37
40
  stdout = stdout.toString().trim();
38
- this.log.exec(normalizedCmd);
39
- this.log.verbose(stdout);
41
+ this.log.verbose(stdout, { isExternal });
40
42
  debug({ command, options, code, stdout, stderr });
41
43
  if (code === 0) {
42
44
  resolve(stdout);
package/lib/spinner.js CHANGED
@@ -9,10 +9,10 @@ class Spinner {
9
9
  this.canForce = !global.isCI && !global.isVerbose && !global.isDryRun && !global.isDebug;
10
10
  this.ora = container.ora || ora;
11
11
  }
12
- show({ enabled = true, task, label, forced = false, context }) {
12
+ show({ enabled = true, task, label, external = false, context }) {
13
13
  if (!enabled) return noop;
14
14
  const awaitTask = task();
15
- if (!this.isSpinnerDisabled || (forced && this.canForce)) {
15
+ if (!this.isSpinnerDisabled || (external && this.canForce)) {
16
16
  const text = format(label, context);
17
17
  this.ora.promise(awaitTask, text);
18
18
  }
package/lib/tasks.js CHANGED
@@ -18,8 +18,8 @@ const runTasks = async (opts, di) => {
18
18
  container.config = container.config || new Config(opts);
19
19
 
20
20
  const { config } = container;
21
- const { isCI, isVerbose, isDryRun, isDebug } = config;
22
- const global = { isCI, isVerbose, isDryRun, isDebug };
21
+ const { isCI, isVerbose, verbosityLevel, isDryRun, isDebug } = config;
22
+ const global = { isCI, isVerbose, verbosityLevel, isDryRun, isDebug };
23
23
 
24
24
  container.log = container.log || new Logger(global);
25
25
  container.spinner = container.spinner || new Spinner({ global, container, config });
@@ -41,9 +41,10 @@ const runTasks = async (opts, di) => {
41
41
  const runScript = async scripts => {
42
42
  if (!scripts || !scripts.length) return;
43
43
  const context = config.getContext();
44
+ const external = true;
44
45
  for (const script of _.castArray(scripts)) {
45
- const task = () => shell.exec(script, {}, context);
46
- await spinner.show({ task, label: script, context, forced: true });
46
+ const task = () => shell.exec(script, { external }, context);
47
+ await spinner.show({ task, label: script, context, external });
47
48
  }
48
49
  };
49
50
 
package/lib/util.js CHANGED
@@ -3,13 +3,22 @@ const { EOL } = require('os');
3
3
  const _ = require('lodash');
4
4
  const gitUrlParse = require('git-url-parse');
5
5
  const semver = require('semver');
6
+ const Log = require('./log');
6
7
  const { TimeoutError } = require('./errors');
7
8
 
9
+ const log = new Log();
10
+
8
11
  const format = (template = '', context = {}) => {
9
- template = template.startsWith('git log')
10
- ? template.replace('[REV_RANGE]', '${latestTag}...HEAD')
11
- : template.replace(/%s/g, '${version}');
12
- return _.template(template)(context);
12
+ try {
13
+ template = template.startsWith('git log')
14
+ ? template.replace('[REV_RANGE]', '${latestTag}...HEAD')
15
+ : template.replace(/%s/g, '${version}');
16
+ return _.template(template)(context);
17
+ } catch (error) {
18
+ log.error(`Unable to render template with context:\n${template}\n${JSON.stringify(context)}`);
19
+ log.error(error);
20
+ throw error;
21
+ }
13
22
  };
14
23
 
15
24
  const truncateLines = (input, maxLines = 10, surplusText = null) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "12.3.6",
3
+ "version": "12.4.3",
4
4
  "description": "CLI release tool for Git repos and npm packages.",
5
5
  "keywords": [
6
6
  "build",
@@ -56,7 +56,7 @@
56
56
  "license": "MIT",
57
57
  "dependencies": {
58
58
  "@iarna/toml": "2.2.3",
59
- "@octokit/rest": "16.28.7",
59
+ "@octokit/rest": "16.33.0",
60
60
  "async-retry": "1.2.3",
61
61
  "chalk": "2.4.2",
62
62
  "cosmiconfig": "5.2.1",
@@ -64,7 +64,7 @@
64
64
  "deprecated-obj": "1.0.1",
65
65
  "detect-repo-changelog": "1.0.1",
66
66
  "find-up": "4.1.0",
67
- "form-data": "2.5.0",
67
+ "form-data": "2.5.1",
68
68
  "git-url-parse": "11.1.2",
69
69
  "globby": "10.0.1",
70
70
  "got": "9.6.0",
@@ -73,34 +73,34 @@
73
73
  "is-ci": "2.0.0",
74
74
  "lodash": "4.17.15",
75
75
  "mime-types": "2.1.24",
76
- "ora": "3.4.0",
76
+ "ora": "4.0.2",
77
77
  "os-name": "3.1.0",
78
78
  "semver": "6.3.0",
79
79
  "shelljs": "0.8.3",
80
- "supports-color": "7.0.0",
80
+ "supports-color": "7.1.0",
81
81
  "update-notifier": "3.0.1",
82
82
  "url-join": "4.0.1",
83
83
  "uuid": "3.3.3",
84
84
  "window-size": "1.1.1",
85
- "yargs-parser": "13.1.1"
85
+ "yargs-parser": "15.0.0"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@octokit/request-error": "1.0.4",
89
- "ava": "2.3.0",
90
- "codecov": "3.5.0",
91
- "eslint": "6.2.2",
92
- "eslint-config-prettier": "6.1.0",
93
- "eslint-plugin-ava": "8.0.0",
89
+ "ava": "2.4.0",
90
+ "codecov": "3.6.1",
91
+ "eslint": "6.5.1",
92
+ "eslint-config-prettier": "6.4.0",
93
+ "eslint-plugin-ava": "9.0.0",
94
94
  "eslint-plugin-import": "2.18.2",
95
- "eslint-plugin-prettier": "3.1.0",
95
+ "eslint-plugin-prettier": "3.1.1",
96
96
  "markdown-toc": "1.2.0",
97
97
  "mock-fs": "4.10.1",
98
98
  "mock-stdio": "1.0.3",
99
- "nock": "10.0.6",
99
+ "nock": "11.4.0",
100
100
  "nyc": "14.1.1",
101
101
  "prettier": "1.18.2",
102
102
  "proxyquire": "2.1.3",
103
- "sinon": "7.4.1",
103
+ "sinon": "7.5.0",
104
104
  "strip-ansi": "5.2.0"
105
105
  },
106
106
  "engines": {
@@ -20,7 +20,8 @@ const gitAdd = (content, file, message) => {
20
20
  sh.ShellString(content).toEnd(file);
21
21
  sh.exec(`git add ${file}`);
22
22
  const { stdout } = sh.exec(`git commit -m "${message}"`);
23
- return stdout.match(/\[.+([a-z0-9]{7})\]/)[1];
23
+ const match = stdout.match(/\[.+([a-z0-9]{7})\]/);
24
+ return match ? match[1] : null;
24
25
  };
25
26
 
26
27
  module.exports = {