release-it 14.11.4 → 14.11.7

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
@@ -321,7 +321,7 @@ While mostly used as a CLI tool, release-it can be used as a dependency to integ
321
321
  - [blockchain/blockchain-wallet-v4-frontend](https://github.com/blockchain/blockchain-wallet-v4-frontend)
322
322
  - [callstack/linaria](https://github.com/callstack/linaria)
323
323
  - [ember-cli/ember-cli](https://github.com/ember-cli/ember-cli)
324
- [react-native-paper](https://github.com/callstack/react-native-paper)
324
+ - [react-native-paper](https://github.com/callstack/react-native-paper)
325
325
  - [js-cookie/js-cookie](https://github.com/js-cookie/js-cookie)
326
326
  - [mirumee/saleor](https://github.com/mirumee/saleor)
327
327
  - [mozilla/readability](https://github.com/mozilla/readability)
@@ -99,7 +99,7 @@ class GitBase extends Plugin {
99
99
  const sha = await this.exec(`git rev-list ${latestTag || '--skip=1'} --tags --max-count=1`, {
100
100
  options
101
101
  });
102
- return this.exec(`git describe --tags --abbrev=0 ${sha}^`, { options }).catch(() => null);
102
+ return this.exec(`git describe --tags --abbrev=0 "${sha}^"`, { options }).catch(() => null);
103
103
  }
104
104
  }
105
105
 
@@ -1,6 +1,6 @@
1
1
  const { EOL } = require('os');
2
2
  const _ = require('lodash');
3
- const findUp = require('find-up');
3
+ const execa = require('execa');
4
4
  const { format, e } = require('../../util');
5
5
  const GitBase = require('../GitBase');
6
6
  const prompts = require('./prompts');
@@ -12,6 +12,12 @@ const fixArgs = args => (args ? (typeof args === 'string' ? args.split(' ') : ar
12
12
 
13
13
  const docs = 'https://git.io/release-it-git';
14
14
 
15
+ const isGitRepo = () =>
16
+ execa('git', ['rev-parse', '--git-dir']).then(
17
+ () => true,
18
+ () => false
19
+ );
20
+
15
21
  class Git extends GitBase {
16
22
  constructor(...args) {
17
23
  super(...args);
@@ -19,7 +25,7 @@ class Git extends GitBase {
19
25
  }
20
26
 
21
27
  static async isEnabled(options) {
22
- return options !== false && (await findUp('.git', { type: 'directory' }));
28
+ return options !== false && (await isGitRepo());
23
29
  }
24
30
 
25
31
  async init() {
@@ -22,7 +22,7 @@ const parseErrormsg = err => {
22
22
  let msg = err;
23
23
  if (err instanceof Error) {
24
24
  const { status, message } = err;
25
- const { headers } = err.response;
25
+ const headers = err.response ? err.response.headers : {};
26
26
  msg = `${_.get(headers, 'status', status)} (${message})`;
27
27
  }
28
28
  return msg;
@@ -308,7 +308,7 @@ class GitHub extends Release {
308
308
 
309
309
  async createWebRelease() {
310
310
  const { isCI } = this.config;
311
- const { tagName } = this.getContext();
311
+ const { tagName } = this.config.getContext();
312
312
  const url = this.generateWebUrl();
313
313
  if (isCI) {
314
314
  this.setContext({ isReleased: true, releaseUrl: url });
package/lib/tasks.js CHANGED
@@ -65,7 +65,7 @@ const runTasks = async (opts, di) => {
65
65
 
66
66
  const name = await reduceUntil(plugins, plugin => plugin.getName());
67
67
  const latestVersion = (await reduceUntil(plugins, plugin => plugin.getLatestVersion())) || '0.0.0';
68
- const changelog = await reduceUntil(plugins, plugin => plugin.getChangelog(latestVersion));
68
+ const changelog = await reduceUntil(plugins, plugin => plugin.getChangelog());
69
69
 
70
70
  const incrementBase = { latestVersion, increment, isPreRelease, preReleaseId };
71
71
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "14.11.4",
3
+ "version": "14.11.7",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -58,20 +58,19 @@
58
58
  "license": "MIT",
59
59
  "dependencies": {
60
60
  "@iarna/toml": "2.2.5",
61
- "@octokit/rest": "18.9.0",
62
- "async-retry": "1.3.1",
61
+ "@octokit/rest": "18.10.0",
62
+ "async-retry": "1.3.3",
63
63
  "chalk": "4.1.2",
64
- "cosmiconfig": "7.0.0",
64
+ "cosmiconfig": "7.0.1",
65
65
  "debug": "4.3.2",
66
66
  "deprecated-obj": "2.0.0",
67
67
  "execa": "5.1.1",
68
- "find-up": "5.0.0",
69
68
  "form-data": "4.0.0",
70
- "git-url-parse": "11.5.0",
69
+ "git-url-parse": "11.6.0",
71
70
  "globby": "11.0.4",
72
71
  "got": "11.8.2",
73
72
  "import-cwd": "3.0.0",
74
- "inquirer": "8.1.2",
73
+ "inquirer": "8.1.5",
75
74
  "is-ci": "3.0.0",
76
75
  "lodash": "4.17.21",
77
76
  "mime-types": "2.1.32",
@@ -95,14 +94,14 @@
95
94
  "eslint": "7.32.0",
96
95
  "eslint-config-prettier": "8.3.0",
97
96
  "eslint-plugin-ava": "12.0.0",
98
- "eslint-plugin-import": "2.24.0",
97
+ "eslint-plugin-import": "2.24.2",
99
98
  "eslint-plugin-prettier": "3.4.0",
100
99
  "markdown-toc": "1.2.0",
101
- "mock-fs": "5.0.0",
100
+ "mock-fs": "5.1.0",
102
101
  "mock-stdio": "1.0.3",
103
- "nock": "13.1.1",
102
+ "nock": "13.1.3",
104
103
  "nyc": "15.1.0",
105
- "prettier": "2.3.2",
104
+ "prettier": "2.4.1",
106
105
  "proxyquire": "2.1.3",
107
106
  "sinon": "11.1.2",
108
107
  "strip-ansi": "6.0.0"
package/test/github.js CHANGED
@@ -117,8 +117,8 @@ test('should update release and upload assets', async t => {
117
117
  const github = factory(GitHub, { options });
118
118
  const exec = sinon.stub(github.shell, 'exec').callThrough();
119
119
  exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');
120
- exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('71f1812');
121
- exec.withArgs('git describe --tags --match=* --abbrev=0 71f1812').resolves('2.0.1');
120
+ exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('a123456');
121
+ exec.withArgs('git describe --tags --abbrev=0 "a123456^"').resolves('2.0.1');
122
122
 
123
123
  interceptAuthentication();
124
124
  interceptCollaborator();
@@ -150,8 +150,8 @@ test('should create new release for unreleased tag', async t => {
150
150
  const github = factory(GitHub, { options });
151
151
  const exec = sinon.stub(github.shell, 'exec').callThrough();
152
152
  exec.withArgs('git describe --tags --match=* --abbrev=0').resolves('2.0.1');
153
- exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('71f1812');
154
- exec.withArgs('git describe --tags --match=* --abbrev=0 71f1812').resolves('2.0.1');
153
+ exec.withArgs('git rev-list 2.0.1 --tags --max-count=1').resolves('b123456');
154
+ exec.withArgs('git describe --tags --abbrev=0 "b123456^"').resolves('2.0.1');
155
155
 
156
156
  interceptAuthentication();
157
157
  interceptCollaborator();
package/test/tasks.js CHANGED
@@ -397,6 +397,47 @@ test.serial('should propagate errors', async t => {
397
397
  t.is(log.error.callCount, 1);
398
398
  });
399
399
 
400
+ test.serial('should use custom changelog command with context', async t => {
401
+ const { bare } = t.context;
402
+ const project = path.basename(bare);
403
+ const owner = path.basename(path.dirname(bare));
404
+ sh.exec('git tag v1.0.0');
405
+ gitAdd('line', 'file', 'More file');
406
+
407
+ interceptGitHubAuthentication();
408
+ interceptGitHubCollaborator({ owner, project });
409
+ interceptGitHubCreate({
410
+ owner,
411
+ project,
412
+ body: {
413
+ tag_name: 'v1.1.0',
414
+ name: 'Release 1.1.0',
415
+ body: 'custom-changelog-generator --from=v1.0.0 --to=v1.1.0',
416
+ draft: false,
417
+ prerelease: false
418
+ }
419
+ });
420
+
421
+ const container = getContainer({
422
+ increment: 'minor',
423
+ github: {
424
+ release: true,
425
+ releaseNotes: 'echo custom-changelog-generator --from=${latestTag} --to=${tagName}',
426
+ pushRepo: `https://github.com/${owner}/${project}`
427
+ }
428
+ });
429
+
430
+ const exec = sinon.spy(container.shell, 'execStringCommand');
431
+
432
+ await runTasks({}, container);
433
+
434
+ const command = exec.args.find(([command]) => command.includes('custom-changelog-generator'));
435
+
436
+ t.is(command[0], 'echo custom-changelog-generator --from=v1.0.0 --to=v1.1.0');
437
+
438
+ exec.restore();
439
+ });
440
+
400
441
  {
401
442
  class MyPlugin extends Plugin {}
402
443
  const statics = { isEnabled: () => true, disablePlugin: () => null };
@@ -56,7 +56,7 @@ module.exports.runTasks = async plugin => {
56
56
 
57
57
  const name = (await plugin.getName()) || '__test__';
58
58
  const latestVersion = (await plugin.getLatestVersion()) || '1.0.0';
59
- const changelog = (await plugin.getChangelog(latestVersion)) || null;
59
+ const changelog = (await plugin.getChangelog()) || null;
60
60
  const increment = getIncrement(plugin, { latestVersion });
61
61
 
62
62
  plugin.config.setContext({ name, latestVersion, latestTag: latestVersion, changelog });