release-it 14.2.1 → 14.2.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "14.2.1",
3
+ "version": "14.2.2",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -56,11 +56,11 @@
56
56
  "license": "MIT",
57
57
  "dependencies": {
58
58
  "@iarna/toml": "2.2.5",
59
- "@octokit/rest": "18.0.7",
59
+ "@octokit/rest": "18.0.9",
60
60
  "async-retry": "1.3.1",
61
61
  "chalk": "4.1.0",
62
62
  "cosmiconfig": "7.0.0",
63
- "debug": "4.2.0",
63
+ "debug": "4.3.1",
64
64
  "deprecated-obj": "2.0.0",
65
65
  "execa": "4.1.0",
66
66
  "find-up": "5.0.0",
@@ -78,17 +78,17 @@
78
78
  "parse-json": "5.1.0",
79
79
  "semver": "7.3.2",
80
80
  "shelljs": "0.8.4",
81
- "update-notifier": "5.0.0",
81
+ "update-notifier": "5.0.1",
82
82
  "url-join": "4.0.1",
83
83
  "uuid": "8.3.1",
84
84
  "yaml": "1.10.0",
85
- "yargs-parser": "20.2.3"
85
+ "yargs-parser": "20.2.4"
86
86
  },
87
87
  "devDependencies": {
88
- "@octokit/request-error": "2.0.2",
88
+ "@octokit/request-error": "2.0.3",
89
89
  "ava": "3.13.0",
90
- "codecov": "3.8.0",
91
- "eslint": "7.12.1",
90
+ "codecov": "3.8.1",
91
+ "eslint": "7.14.0",
92
92
  "eslint-config-prettier": "6.15.0",
93
93
  "eslint-plugin-ava": "11.0.0",
94
94
  "eslint-plugin-import": "2.22.1",
@@ -96,9 +96,9 @@
96
96
  "markdown-toc": "1.2.0",
97
97
  "mock-fs": "4.13.0",
98
98
  "mock-stdio": "1.0.3",
99
- "nock": "13.0.4",
99
+ "nock": "13.0.5",
100
100
  "nyc": "15.1.0",
101
- "prettier": "2.1.2",
101
+ "prettier": "2.2.0",
102
102
  "proxyquire": "2.1.3",
103
103
  "sinon": "9.2.1",
104
104
  "strip-ansi": "6.0.0"
package/test/plugins.js CHANGED
@@ -1,3 +1,4 @@
1
+ const path = require('path');
1
2
  const test = require('ava');
2
3
  const sh = require('shelljs');
3
4
  const proxyquire = require('proxyquire');
@@ -131,3 +132,69 @@ test.serial('should disable core plugins', async t => {
131
132
  version: undefined
132
133
  });
133
134
  });
135
+
136
+ test.serial('should expose context to execute commands', async t => {
137
+ const { bare } = t.context;
138
+ const latestVersion = '1.0.0';
139
+ const project = path.basename(bare);
140
+ const pkgName = 'plugin-context';
141
+ const owner = path.basename(path.dirname(bare));
142
+ gitAdd(`{"name":"${pkgName}","version":"${latestVersion}"}`, 'package.json', 'Add package.json');
143
+
144
+ class MyPlugin extends Plugin {
145
+ init() {
146
+ this.exec('echo ${version.isPreRelease}');
147
+ }
148
+ beforeBump() {
149
+ const context = this.config.getContext();
150
+ t.is(context.name, pkgName);
151
+ this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version}');
152
+ }
153
+ bump() {
154
+ const repo = this.config.getContext('repo');
155
+ t.is(repo.owner, owner);
156
+ t.is(repo.project, project);
157
+ t.is(repo.repository, `${owner}/${project}`);
158
+ this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version}');
159
+ }
160
+ beforeRelease() {
161
+ const context = this.config.getContext();
162
+ t.is(context.name, pkgName);
163
+ this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version} ${tagName}');
164
+ }
165
+ release() {
166
+ const context = this.config.getContext();
167
+ t.is(context.latestVersion, latestVersion);
168
+ t.is(context.version, '1.0.1');
169
+ this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version} ${tagName}');
170
+ }
171
+ afterRelease() {
172
+ const context = this.config.getContext();
173
+ t.is(context.tagName, '1.0.1');
174
+ this.exec('echo ${name} ${repo.owner} ${repo.project} ${latestVersion} ${version} ${tagName}');
175
+ }
176
+ }
177
+ const statics = { isEnabled: () => true, disablePlugin: () => null };
178
+ const options = { '@global': true, '@noCallThru': true };
179
+ const runTasks = proxyquire('../lib/tasks', {
180
+ 'my-plugin': Object.assign(MyPlugin, statics, options)
181
+ });
182
+
183
+ const container = getContainer({ plugins: { 'my-plugin': {} } });
184
+ const exec = sinon.spy(container.shell, 'execFormattedCommand');
185
+
186
+ await runTasks({}, container);
187
+
188
+ const pluginExecArgs = exec.args
189
+ .map(args => args[0])
190
+ .filter(arg => typeof arg === 'string' && arg.startsWith('echo'));
191
+
192
+ t.deepEqual(pluginExecArgs, [
193
+ 'echo false',
194
+ `echo ${pkgName} ${owner} ${project} ${latestVersion} 1.0.1`,
195
+ `echo ${pkgName} ${owner} ${project} ${latestVersion} 1.0.1`,
196
+ `echo ${pkgName} ${owner} ${project} ${latestVersion} 1.0.1 1.0.1`,
197
+ `echo ${pkgName} ${owner} ${project} ${latestVersion} 1.0.1 1.0.1`,
198
+ `echo ${pkgName} ${owner} ${project} ${latestVersion} 1.0.1 1.0.1`
199
+ ]);
200
+ });
@@ -1,7 +1,7 @@
1
1
  const debug = require('debug')('release-it:shell-stub');
2
2
  const Shell = require('../../lib/shell');
3
3
 
4
- module.exports = class ShellStub extends Shell {
4
+ class ShellStub extends Shell {
5
5
  exec(command) {
6
6
  if (/^(npm (ping|publish|show)|git fetch)/.test(command)) {
7
7
  debug(command);
@@ -17,4 +17,6 @@ module.exports = class ShellStub extends Shell {
17
17
  }
18
18
  return super.exec(...arguments);
19
19
  }
20
- };
20
+ }
21
+
22
+ module.exports = ShellStub;
package/test/tasks.js CHANGED
@@ -398,22 +398,11 @@ test.serial('should propagate errors', async t => {
398
398
  });
399
399
 
400
400
  {
401
- const myPlugin = sandbox.createStubInstance(Plugin);
402
- myPlugin.namespace = 'my-plugin';
403
- const MyPlugin = sandbox.stub().callsFake(() => myPlugin);
404
- const myLocalPlugin = sandbox.createStubInstance(Plugin);
405
- const MyLocalPlugin = sandbox.stub().callsFake(() => myLocalPlugin);
406
- const replacePlugin = sandbox.createStubInstance(Plugin);
407
- const ReplacePlugin = sandbox.stub().callsFake(() => replacePlugin);
408
-
401
+ class MyPlugin extends Plugin {}
409
402
  const statics = { isEnabled: () => true, disablePlugin: () => null };
410
403
  const options = { '@global': true, '@noCallThru': true };
411
404
  const runTasks = proxyquire('../lib/tasks', {
412
- 'my-plugin': Object.assign(MyPlugin, statics, options),
413
- '/my/plugin': Object.assign(MyLocalPlugin, statics, options),
414
- 'replace-plugin': Object.assign(ReplacePlugin, statics, options, {
415
- disablePlugin: () => ['version', 'git']
416
- })
405
+ 'my-plugin': Object.assign(MyPlugin, statics, options)
417
406
  });
418
407
 
419
408
  test.serial('should run all hooks', async t => {
@@ -421,9 +410,9 @@ test.serial('should propagate errors', async t => {
421
410
  const hooks = {};
422
411
  ['before', 'after'].forEach(prefix => {
423
412
  ['version', 'git', 'npm', 'my-plugin'].forEach(ns => {
424
- ['init', 'beforeBump', 'bump', 'beforeRelease', 'release', 'afterRelease'].forEach(lifecycle => {
425
- hooks[`${prefix}:${lifecycle}`] = `echo ${prefix}:${lifecycle}`;
426
- hooks[`${prefix}:${ns}:${lifecycle}`] = `echo ${prefix}:${ns}:${lifecycle}`;
413
+ ['init', 'beforeBump', 'bump', 'beforeRelease', 'release', 'afterRelease'].forEach(cycle => {
414
+ hooks[`${prefix}:${cycle}`] = `echo ${prefix}:${cycle}`;
415
+ hooks[`${prefix}:${ns}:${cycle}`] = `echo ${prefix}:${ns}:${cycle}`;
427
416
  });
428
417
  });
429
418
  });