release-it 16.2.1 → 17.0.0

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
@@ -295,10 +295,12 @@ Since v11, release-it can be extended in many, many ways. Here are some plugins:
295
295
  | [@release-it/conventional-changelog][25] | Provides recommended bump, conventional-changelog, and updates `CHANGELOG.md` |
296
296
  | [@release-it/keep-a-changelog][38] | Maintain CHANGELOG.md using the Keep a Changelog standards |
297
297
  | [@release-it-plugins/lerna-changelog][39] | Integrates lerna-changelog into the release-it pipeline |
298
+ | [@jcamp-code/release-it-changelogen][72] | Use [@unjs/changelogen][73] for versioning and changelog |
298
299
  | [@release-it-plugins/workspaces][40] | Releases each of your projects configured workspaces |
299
300
  | [release-it-calver-plugin][26] | Enables Calendar Versioning (calver) with release-it |
300
301
  | [@grupoboticario/news-fragments][41] | An easy way to generate your changelog file |
301
302
  | [@j-ulrich/release-it-regex-bumper][42] | Regular expression based version read/write plugin for release-it |
303
+ | [@jcamp-code/release-it-dotnet][74] | Use .csproj or .props file for versioning, automate NuGet publishing |
302
304
 
303
305
  Internally, release-it uses its own plugin architecture (for Git, GitHub, GitLab, npm).
304
306
 
@@ -419,3 +421,6 @@ environments running Node.js v14. Also see [CHANGELOG.md][67].
419
421
  [69]: ./.github/CONTRIBUTING.md
420
422
  [70]: https://github.com/release-it/release-it/issues/new
421
423
  [71]: ./LICENSE
424
+ [72]: https://github.com/jcamp-code/release-it-changelogen
425
+ [73]: https://github.com/unjs/changelogen
426
+ [74]: https://github.com/jcamp-code/release-it-dotnet
package/lib/index.js CHANGED
@@ -145,8 +145,6 @@ const runTasks = async (opts, di) => {
145
145
 
146
146
  export default runTasks;
147
147
 
148
- /** @public */
149
148
  export { default as Config } from './config.js';
150
149
 
151
- /** @public */
152
150
  export { default as Plugin } from './plugin/Plugin.js';
@@ -56,8 +56,11 @@ class Git extends GitBase {
56
56
  const { tagName } = this.config.getContext();
57
57
  const { isCommitted, isTagged } = this.getContext();
58
58
  if (isTagged) {
59
+ this.log.info(`Deleting local tag ${tagName}`);
59
60
  this.exec(`git tag --delete ${tagName}`);
60
61
  }
62
+
63
+ this.log.info(`Resetting local changes made`);
61
64
  this.exec(`git reset --hard HEAD${isCommitted ? '~1' : ''}`);
62
65
  }
63
66
 
@@ -207,9 +210,23 @@ class Git extends GitBase {
207
210
  async push({ args = this.options.pushArgs } = {}) {
208
211
  const { pushRepo } = this.options;
209
212
  const upstreamArgs = await this.getUpstreamArgs(pushRepo);
210
- const push = await this.exec(['git', 'push', ...fixArgs(args), ...upstreamArgs]);
211
- this.disableRollback();
212
- return push;
213
+ try {
214
+ const push = await this.exec(['git', 'push', ...fixArgs(args), ...upstreamArgs]);
215
+ this.disableRollback();
216
+ return push;
217
+ } catch (error) {
218
+ await this.rollbackTagPush();
219
+ throw error;
220
+ }
221
+ }
222
+
223
+ async rollbackTagPush() {
224
+ const { isTagged } = this.getContext();
225
+ if (isTagged) {
226
+ const { tagName } = this.config.getContext();
227
+ this.log.info(`Rolling back remote tag push ${tagName}`);
228
+ await this.exec(`git push origin --delete ${tagName}`);
229
+ }
213
230
  }
214
231
 
215
232
  afterRelease() {
@@ -10,7 +10,7 @@ const CONTINUATION_TYPES = ['prerelease', 'pre'];
10
10
  const ALL_RELEASE_TYPES = [...RELEASE_TYPES, ...PRERELEASE_TYPES, ...CONTINUATION_TYPES];
11
11
 
12
12
  const CHOICES = {
13
- latestIsPreRelease: [...RELEASE_TYPES, CONTINUATION_TYPES[0]],
13
+ latestIsPreRelease: [CONTINUATION_TYPES[0], ...RELEASE_TYPES],
14
14
  preRelease: PRERELEASE_TYPES,
15
15
  default: [...RELEASE_TYPES, ...PRERELEASE_TYPES]
16
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "16.2.1",
3
+ "version": "17.0.0",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -62,15 +62,15 @@
62
62
  "license": "MIT",
63
63
  "dependencies": {
64
64
  "@iarna/toml": "2.2.5",
65
- "@octokit/rest": "19.0.13",
65
+ "@octokit/rest": "20.0.2",
66
66
  "async-retry": "1.3.3",
67
67
  "chalk": "5.3.0",
68
68
  "cosmiconfig": "8.3.6",
69
- "execa": "7.2.0",
70
- "git-url-parse": "13.1.0",
71
- "globby": "13.2.2",
69
+ "execa": "8.0.1",
70
+ "git-url-parse": "13.1.1",
71
+ "globby": "14.0.0",
72
72
  "got": "13.0.0",
73
- "inquirer": "9.2.11",
73
+ "inquirer": "9.2.12",
74
74
  "is-ci": "3.0.1",
75
75
  "issue-parser": "6.0.0",
76
76
  "lodash": "4.17.21",
@@ -84,35 +84,32 @@
84
84
  "proxy-agent": "6.3.1",
85
85
  "semver": "7.5.4",
86
86
  "shelljs": "0.8.5",
87
- "update-notifier": "6.0.2",
87
+ "update-notifier": "7.0.0",
88
88
  "url-join": "5.0.0",
89
89
  "wildcard-match": "5.1.2",
90
90
  "yargs-parser": "21.1.1"
91
91
  },
92
92
  "devDependencies": {
93
- "@octokit/request-error": "3.0.3",
93
+ "@octokit/request-error": "5.0.1",
94
94
  "ava": "5.3.1",
95
- "eslint": "8.50.0",
95
+ "eslint": "8.53.0",
96
96
  "eslint-config-prettier": "9.0.0",
97
97
  "eslint-plugin-ava": "14.0.0",
98
- "eslint-plugin-import": "2.28.1",
99
- "eslint-plugin-prettier": "5.0.0",
98
+ "eslint-plugin-import": "2.29.0",
99
+ "eslint-plugin-prettier": "5.0.1",
100
100
  "fs-monkey": "1.0.5",
101
- "knip": "2.29.0",
102
- "memfs": "4.5.0",
101
+ "knip": "2.41.0",
102
+ "memfs": "4.6.0",
103
103
  "mock-stdio": "1.0.3",
104
- "nock": "13.3.3",
104
+ "nock": "13.3.8",
105
105
  "prettier": "3.0.3",
106
- "remark-cli": "11.0.0",
107
- "remark-preset-webpro": "0.0.3",
108
- "sinon": "16.0.0",
106
+ "remark-cli": "12.0.0",
107
+ "remark-preset-webpro": "1.0.0",
108
+ "sinon": "17.0.1",
109
109
  "strip-ansi": "7.1.0"
110
110
  },
111
- "overrides": {
112
- "@octokit/plugin-rest-endpoint-methods": "7.2.2"
113
- },
114
111
  "engines": {
115
- "node": ">=16"
112
+ "node": ">=18"
116
113
  },
117
114
  "remarkConfig": {
118
115
  "plugins": [
package/test/git.js CHANGED
@@ -298,6 +298,35 @@ test.serial('should roll back when cancelled', async t => {
298
298
  t.is(exec.args[12][0], 'git reset --hard HEAD~1');
299
299
  });
300
300
 
301
+ test.serial('should remove remote tag when push to branch failed', async t => {
302
+ sh.exec('git init');
303
+ sh.exec(`git remote add origin file://foo`);
304
+ const version = '1.2.3';
305
+ gitAdd(`{"version":"${version}"}`, 'package.json', 'Add package.json');
306
+ const options = { git: { requireCleanWorkingDir: true, commit: true, tag: true, tagName: 'v${version}' } };
307
+ const gitClient = factory(Git, { options });
308
+ const exec = sinon.spy(gitClient.shell, 'execFormattedCommand');
309
+ sh.exec(`git push`);
310
+ sh.exec(`git checkout HEAD~1`);
311
+ gitAdd('line', 'file', 'Add file');
312
+
313
+ await gitClient.init();
314
+
315
+ sh.exec('npm --no-git-tag-version version patch');
316
+
317
+ gitClient.bump('1.2.4');
318
+ await gitClient.beforeRelease();
319
+ await gitClient.stage('package.json');
320
+ await gitClient.commit({ message: 'Add this' });
321
+ await gitClient.tag();
322
+ try {
323
+ await gitClient.push();
324
+ } catch (e) {
325
+ // push would fail with an error since HEAD is behind origin
326
+ }
327
+ t.is(exec.args[15][0], 'git push origin --delete v1.2.4');
328
+ });
329
+
301
330
  test.serial('should not touch existing history when rolling back', async t => {
302
331
  sh.exec('git init');
303
332
  const version = '1.2.3';