release-it 18.0.0-next.1 → 18.0.0-next.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/lib/plugin/github/GitHub.js +12 -3
- package/lib/plugin/github/util.js +4 -2
- package/package.json +9 -9
- package/schema/github.json +4 -0
- package/test/github.js +23 -0
- package/test/stub/github.js +11 -2
- package/types/config.d.ts +8 -1
|
@@ -13,6 +13,10 @@ import Release from '../GitRelease.js';
|
|
|
13
13
|
import prompts from './prompts.js';
|
|
14
14
|
import { getCommitsFromChangelog, getResolvedIssuesFromChangelog, searchQueries } from './util.js';
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {import('@octokit/rest').RestEndpointMethodTypes['repos']['createRelease']['parameters']} CreateReleaseOptions
|
|
18
|
+
*/
|
|
19
|
+
|
|
16
20
|
const pkg = readJSON(new URL('../../../package.json', import.meta.url));
|
|
17
21
|
|
|
18
22
|
const docs = 'https://git.io/release-it-github';
|
|
@@ -205,15 +209,19 @@ class GitHub extends Release {
|
|
|
205
209
|
|
|
206
210
|
getOctokitReleaseOptions(options = {}) {
|
|
207
211
|
const { owner, project: repo } = this.getContext('repo');
|
|
208
|
-
const { releaseName, draft = false, preRelease = false, autoGenerate = false } = this.options;
|
|
212
|
+
const { releaseName, draft = false, preRelease = false, autoGenerate = false, makeLatest = true } = this.options;
|
|
209
213
|
const { tagName } = this.config.getContext();
|
|
210
214
|
const { version, releaseNotes, isUpdate } = this.getContext();
|
|
211
215
|
const { isPreRelease } = parseVersion(version);
|
|
212
216
|
const name = format(releaseName, this.config.getContext());
|
|
213
217
|
const body = autoGenerate ? (isUpdate ? null : '') : truncateBody(releaseNotes);
|
|
214
218
|
|
|
215
|
-
|
|
219
|
+
/**
|
|
220
|
+
* @type {CreateReleaseOptions}
|
|
221
|
+
*/
|
|
222
|
+
const contextOptions = {
|
|
216
223
|
owner,
|
|
224
|
+
make_latest: makeLatest.toString(),
|
|
217
225
|
repo,
|
|
218
226
|
tag_name: tagName,
|
|
219
227
|
name,
|
|
@@ -221,7 +229,8 @@ class GitHub extends Release {
|
|
|
221
229
|
draft,
|
|
222
230
|
prerelease: isPreRelease || preRelease,
|
|
223
231
|
generate_release_notes: autoGenerate
|
|
224
|
-
}
|
|
232
|
+
};
|
|
233
|
+
return Object.assign(options, contextOptions);
|
|
225
234
|
}
|
|
226
235
|
|
|
227
236
|
retry(fn) {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// Totally much borrowed from https://github.com/semantic-release/github/blob/master/lib/success.js
|
|
2
2
|
import issueParser from 'issue-parser';
|
|
3
3
|
|
|
4
|
-
const getSearchQueries = (base, commits, separator = '+') => {
|
|
4
|
+
export const getSearchQueries = (base, commits, separator = '+') => {
|
|
5
|
+
const encodedSeparator = encodeURIComponent(separator);
|
|
6
|
+
|
|
5
7
|
return commits.reduce((searches, commit) => {
|
|
6
8
|
const lastSearch = searches[searches.length - 1];
|
|
7
|
-
if (lastSearch && lastSearch.length + commit.length <= 256 -
|
|
9
|
+
if (lastSearch && encodeURIComponent(lastSearch).length + commit.length <= 256 - encodedSeparator.length) {
|
|
8
10
|
searches[searches.length - 1] = `${lastSearch}${separator}${commit}`;
|
|
9
11
|
} else {
|
|
10
12
|
searches.push(`${base}${separator}${commit}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-it",
|
|
3
|
-
"version": "18.0.0-next.
|
|
3
|
+
"version": "18.0.0-next.3",
|
|
4
4
|
"description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build",
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"chalk": "5.3.0",
|
|
85
85
|
"ci-info": "^4.0.0",
|
|
86
86
|
"cosmiconfig": "9.0.0",
|
|
87
|
-
"execa": "9.
|
|
87
|
+
"execa": "9.4.0",
|
|
88
88
|
"git-url-parse": "15.0.0",
|
|
89
89
|
"globby": "14.0.2",
|
|
90
|
-
"inquirer": "
|
|
90
|
+
"inquirer": "11.0.2",
|
|
91
91
|
"issue-parser": "7.0.1",
|
|
92
92
|
"lodash": "4.17.21",
|
|
93
93
|
"mime-types": "2.1.35",
|
|
@@ -106,11 +106,11 @@
|
|
|
106
106
|
"devDependencies": {
|
|
107
107
|
"@eslint/compat": "1.1.1",
|
|
108
108
|
"@eslint/eslintrc": "3.1.0",
|
|
109
|
-
"@eslint/js": "9.
|
|
109
|
+
"@eslint/js": "9.11.0",
|
|
110
110
|
"@octokit/request-error": "6.1.4",
|
|
111
|
-
"@types/node": "22.5.
|
|
111
|
+
"@types/node": "22.5.5",
|
|
112
112
|
"ava": "6.1.3",
|
|
113
|
-
"eslint": "9.
|
|
113
|
+
"eslint": "9.11.0",
|
|
114
114
|
"eslint-config-prettier": "9.1.0",
|
|
115
115
|
"eslint-plugin-ava": "15.0.1",
|
|
116
116
|
"eslint-plugin-import-x": "4.2.1",
|
|
@@ -118,14 +118,14 @@
|
|
|
118
118
|
"fs-monkey": "1.0.6",
|
|
119
119
|
"globals": "15.9.0",
|
|
120
120
|
"installed-check": "9.3.0",
|
|
121
|
-
"knip": "5.30.
|
|
122
|
-
"memfs": "4.
|
|
121
|
+
"knip": "5.30.2",
|
|
122
|
+
"memfs": "4.12.0",
|
|
123
123
|
"mock-stdio": "1.0.3",
|
|
124
124
|
"nock": "14.0.0-beta.8",
|
|
125
125
|
"prettier": "3.3.3",
|
|
126
126
|
"remark-cli": "12.0.1",
|
|
127
127
|
"remark-preset-webpro": "1.1.0",
|
|
128
|
-
"sinon": "
|
|
128
|
+
"sinon": "19.0.2",
|
|
129
129
|
"strip-ansi": "7.1.0",
|
|
130
130
|
"typescript": "5.6.2"
|
|
131
131
|
},
|
package/schema/github.json
CHANGED
package/test/github.js
CHANGED
|
@@ -2,6 +2,7 @@ import test from 'ava';
|
|
|
2
2
|
import sinon from 'sinon';
|
|
3
3
|
import { RequestError } from '@octokit/request-error';
|
|
4
4
|
import GitHub from '../lib/plugin/github/GitHub.js';
|
|
5
|
+
import { getSearchQueries } from '../lib/plugin/github/util.js';
|
|
5
6
|
import { factory, runTasks } from './util/index.js';
|
|
6
7
|
import {
|
|
7
8
|
interceptAuthentication,
|
|
@@ -485,3 +486,25 @@ test.skip('should truncate long body', async t => {
|
|
|
485
486
|
t.is(releaseUrl, 'https://github.com/user/repo/releases/tag/2.0.2');
|
|
486
487
|
exec.restore();
|
|
487
488
|
});
|
|
489
|
+
|
|
490
|
+
test('should generate search queries correctly', t => {
|
|
491
|
+
const generateCommit = () => Math.random().toString(36).substring(2, 9);
|
|
492
|
+
const base = 'repo:owner/repo+type:pr+is:merged';
|
|
493
|
+
const commits = Array.from({ length: 5 }, generateCommit);
|
|
494
|
+
const separator = '+';
|
|
495
|
+
|
|
496
|
+
const result = getSearchQueries(base, commits, separator);
|
|
497
|
+
|
|
498
|
+
// Test case 1: Check if all commits are included in the search queries
|
|
499
|
+
const allCommitsIncluded = commits.every(commit => result.some(query => query.includes(commit)));
|
|
500
|
+
t.true(allCommitsIncluded, 'All commits should be included in the search queries');
|
|
501
|
+
|
|
502
|
+
// Test case 2: Check if the function respects the 256 character limit
|
|
503
|
+
const manyCommits = Array.from({ length: 100 }, generateCommit);
|
|
504
|
+
const longResult = getSearchQueries(base, manyCommits, separator);
|
|
505
|
+
t.true(longResult.length > 1, 'Many commits should be split into multiple queries');
|
|
506
|
+
t.true(
|
|
507
|
+
longResult.every(query => encodeURIComponent(query).length <= 256),
|
|
508
|
+
'Each query should not exceed 256 characters after encoding'
|
|
509
|
+
);
|
|
510
|
+
});
|
package/test/stub/github.js
CHANGED
|
@@ -53,7 +53,8 @@ const interceptCreate = ({
|
|
|
53
53
|
body,
|
|
54
54
|
prerelease,
|
|
55
55
|
draft,
|
|
56
|
-
generate_release_notes
|
|
56
|
+
generate_release_notes,
|
|
57
|
+
make_latest: 'true'
|
|
57
58
|
})
|
|
58
59
|
.reply(() => {
|
|
59
60
|
const id = 1;
|
|
@@ -80,7 +81,15 @@ const interceptUpdate = ({
|
|
|
80
81
|
body: { tag_name, name = '', body = null, prerelease = false, draft = false, generate_release_notes = false }
|
|
81
82
|
} = {}) => {
|
|
82
83
|
nock(api)
|
|
83
|
-
.patch(`/repos/${owner}/${project}/releases/1`, {
|
|
84
|
+
.patch(`/repos/${owner}/${project}/releases/1`, {
|
|
85
|
+
tag_name,
|
|
86
|
+
name,
|
|
87
|
+
body,
|
|
88
|
+
draft,
|
|
89
|
+
prerelease,
|
|
90
|
+
generate_release_notes,
|
|
91
|
+
make_latest: 'true'
|
|
92
|
+
})
|
|
84
93
|
.reply(200, {
|
|
85
94
|
id: 1,
|
|
86
95
|
tag_name,
|
package/types/config.d.ts
CHANGED
|
@@ -132,6 +132,13 @@ export interface Config {
|
|
|
132
132
|
/** @default null */
|
|
133
133
|
proxy?: any;
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* @default true
|
|
137
|
+
* 'legacy' - Github determines the latest release based on the release creation date and higher semantic version.
|
|
138
|
+
* See https://docs.github.com/en/rest/releases/releases?apiVersion=latest#create-a-release
|
|
139
|
+
*/
|
|
140
|
+
makeLatest?: boolean | 'legacy';
|
|
141
|
+
|
|
135
142
|
/** @default false */
|
|
136
143
|
skipChecks?: boolean;
|
|
137
144
|
|
|
@@ -170,7 +177,7 @@ export interface Config {
|
|
|
170
177
|
|
|
171
178
|
/** @default null */
|
|
172
179
|
certificateAuthorityFile?: any;
|
|
173
|
-
|
|
180
|
+
|
|
174
181
|
/** @default null */
|
|
175
182
|
secure?: boolean;
|
|
176
183
|
|