release-it 15.11.0 → 16.1.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
@@ -334,8 +334,8 @@ release-it programmatically][45] for example code.
334
334
 
335
335
  ## Legacy Node.js
336
336
 
337
- The latest major version is v15, supporting Node.js 14 and up (as Node.js v12 is EOL). Use release-it v14 for
338
- environments running Node.js v10 and v12. Also see [CHANGELOG.md][67].
337
+ The latest major version is v16, supporting Node.js 16 and up (as Node.js v14 is EOL). Use release-it v15 for
338
+ environments running Node.js v14. Also see [CHANGELOG.md][67].
339
339
 
340
340
  ## Links
341
341
 
@@ -16,6 +16,7 @@
16
16
  "tagExclude": null,
17
17
  "tagName": null,
18
18
  "tagMatch": null,
19
+ "getLatestTagFromAllRefs": false,
19
20
  "tagAnnotation": "Release ${version}",
20
21
  "tagArgs": [],
21
22
  "push": true,
@@ -94,10 +94,20 @@ class GitBase extends Plugin {
94
94
  const context = Object.assign({}, this.config.getContext(), { version: '*' });
95
95
  const match = format(this.options.tagMatch || this.options.tagName || '${version}', context);
96
96
  const exclude = this.options.tagExclude ? ` --exclude=${format(this.options.tagExclude, context)}` : '';
97
- return this.exec(`git describe --tags --match=${match} --abbrev=0${exclude}`, { options }).then(
98
- stdout => stdout || null,
99
- () => null
100
- );
97
+ if (this.options.getLatestTagFromAllRefs) {
98
+ return this.exec(
99
+ `git -c "versionsort.suffix=-" for-each-ref --count=1 --sort=-v:refname --format="%(refname:short)" refs/tags/${match}`,
100
+ { options }
101
+ ).then(
102
+ stdout => stdout || null,
103
+ () => null
104
+ );
105
+ } else {
106
+ return this.exec(`git describe --tags --match=${match} --abbrev=0${exclude}`, { options }).then(
107
+ stdout => stdout || null,
108
+ () => null
109
+ );
110
+ }
101
111
  }
102
112
 
103
113
  async getSecondLatestTagName(latestTag) {
@@ -12,7 +12,14 @@ class GitRelease extends GitBase {
12
12
  getInitialOptions(options) {
13
13
  const baseOptions = super.getInitialOptions(...arguments);
14
14
  const git = options.git || defaultConfig.git;
15
- const gitOptions = _.pick(git, ['tagExclude', 'tagName', 'tagMatch', 'pushRepo', 'changelog']);
15
+ const gitOptions = _.pick(git, [
16
+ 'tagExclude',
17
+ 'tagName',
18
+ 'tagMatch',
19
+ 'getLatestTagFromAllRefs',
20
+ 'pushRepo',
21
+ 'changelog'
22
+ ]);
16
23
  return _.defaults(baseOptions, gitOptions);
17
24
  }
18
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "15.11.0",
3
+ "version": "16.1.0",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -48,6 +48,7 @@
48
48
  "test"
49
49
  ],
50
50
  "scripts": {
51
+ "knip": "knip",
51
52
  "lint": "eslint lib test",
52
53
  "format": "prettier --write \"{lib,test}/**/*.js\"",
53
54
  "docs": "remark README.md 'docs/**/*.md' '.github/*.md' -o",
@@ -61,15 +62,15 @@
61
62
  "license": "MIT",
62
63
  "dependencies": {
63
64
  "@iarna/toml": "2.2.5",
64
- "@octokit/rest": "19.0.11",
65
+ "@octokit/rest": "19.0.13",
65
66
  "async-retry": "1.3.3",
66
- "chalk": "5.2.0",
67
- "cosmiconfig": "8.1.3",
67
+ "chalk": "5.3.0",
68
+ "cosmiconfig": "8.2.0",
68
69
  "execa": "7.1.1",
69
70
  "git-url-parse": "13.1.0",
70
- "globby": "13.1.4",
71
- "got": "12.6.1",
72
- "inquirer": "9.2.6",
71
+ "globby": "13.2.1",
72
+ "got": "13.0.0",
73
+ "inquirer": "9.2.7",
73
74
  "is-ci": "3.0.1",
74
75
  "issue-parser": "6.0.0",
75
76
  "lodash": "4.17.21",
@@ -81,7 +82,7 @@
81
82
  "os-name": "5.1.0",
82
83
  "promise.allsettled": "1.0.6",
83
84
  "proxy-agent": "6.2.1",
84
- "semver": "7.5.1",
85
+ "semver": "7.5.3",
85
86
  "shelljs": "0.8.5",
86
87
  "update-notifier": "6.0.2",
87
88
  "url-join": "5.0.0",
@@ -90,23 +91,27 @@
90
91
  },
91
92
  "devDependencies": {
92
93
  "@octokit/request-error": "3.0.3",
93
- "ava": "5.3.0",
94
- "eslint": "8.41.0",
94
+ "ava": "5.3.1",
95
+ "eslint": "8.44.0",
95
96
  "eslint-config-prettier": "8.8.0",
96
97
  "eslint-plugin-ava": "14.0.0",
97
98
  "eslint-plugin-import": "2.27.5",
98
99
  "eslint-plugin-prettier": "4.2.1",
100
+ "knip": "2.14.3",
99
101
  "mock-fs": "5.2.0",
100
102
  "mock-stdio": "1.0.3",
101
103
  "nock": "13.3.1",
102
104
  "prettier": "2.8.8",
103
105
  "remark-cli": "11.0.0",
104
- "remark-preset-webpro": "0.0.2",
105
- "sinon": "15.1.0",
106
+ "remark-preset-webpro": "0.0.3",
107
+ "sinon": "15.2.0",
106
108
  "strip-ansi": "7.1.0"
107
109
  },
110
+ "overrides": {
111
+ "@octokit/plugin-rest-endpoint-methods": "7.2.2"
112
+ },
108
113
  "engines": {
109
- "node": ">=14.9"
114
+ "node": ">=16"
110
115
  },
111
116
  "remarkConfig": {
112
117
  "plugins": [
package/test/git.js CHANGED
@@ -322,3 +322,37 @@ test.serial('should not roll back with risky config', async t => {
322
322
  await gitClient.beforeRelease();
323
323
  t.is('rollbackOnce' in gitClient, false);
324
324
  });
325
+
326
+ test.serial('should return latest tag from default branch (not parent commit)', async t => {
327
+ sh.exec('git init');
328
+
329
+ {
330
+ const options = { git: { getLatestTagFromAllRefs: true } };
331
+ const gitClient = factory(Git, { options });
332
+ gitAdd('main', 'file', 'Add file in main');
333
+ const defaultBranchName = await gitClient.getBranchName();
334
+ const developBranchName = 'develop';
335
+ const featureBranchPrefix = 'feature';
336
+ await gitClient.tag({ name: '1.0.0' });
337
+ sh.exec(`git branch ${developBranchName} ${defaultBranchName}`);
338
+ sh.exec(`git checkout -b ${featureBranchPrefix}/first ${developBranchName}`);
339
+ gitAdd('feature/1', 'file', 'Update file in feature branch (1)');
340
+ sh.exec(`git checkout ${developBranchName}`);
341
+ sh.exec(`git merge --no-ff ${featureBranchPrefix}/first`);
342
+ await gitClient.tag({ name: '1.1.0-rc.1' });
343
+ sh.exec(`git checkout ${defaultBranchName}`);
344
+ sh.exec(`git merge --no-ff ${developBranchName}`);
345
+ await gitClient.tag({ name: '1.1.0' });
346
+ sh.exec(`git checkout -b ${featureBranchPrefix}/second ${developBranchName}`);
347
+ gitAdd('feature/2', 'file', 'Update file again, in feature branch (2)');
348
+ sh.exec(`git checkout ${developBranchName}`);
349
+ sh.exec(`git merge --no-ff ${featureBranchPrefix}/second`);
350
+ t.is(await gitClient.getLatestTagName(), '1.1.0');
351
+ }
352
+
353
+ {
354
+ const options = { git: { getLatestTagFromAllRefs: false } };
355
+ const gitClient = factory(Git, { options });
356
+ t.is(await gitClient.getLatestTagName(), '1.1.0-rc.1');
357
+ }
358
+ });