release-it 18.0.0-next.2 → 18.0.0-next.4
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 +41 -38
- package/config/release-it.json +3 -0
- package/lib/plugin/GitBase.js +1 -1
- package/lib/plugin/GitRelease.js +4 -1
- package/lib/plugin/github/GitHub.js +40 -7
- package/lib/plugin/gitlab/GitLab.js +89 -43
- package/package.json +25 -24
- package/schema/github.json +8 -0
- package/schema/gitlab.json +13 -1
- package/test/github.js +37 -0
- package/test/gitlab.js +165 -43
- package/test/stub/github.js +35 -5
- package/test/stub/gitlab.js +22 -3
- package/test/tasks.interactive.js +7 -0
- package/test/tasks.js +7 -1
- package/test/util/https-server/client/my-private-root-ca.cert.pem +22 -0
- package/test/util/https-server/client/my-private-root-ca.crt +0 -0
- package/test/util/https-server/gen-cert.sh +65 -0
- package/test/util/https-server/server/cert.pem +20 -0
- package/test/util/https-server/server/fullchain.pem +20 -0
- package/test/util/https-server/server/my-private-root-ca.cert.pem +22 -0
- package/test/util/https-server/server/privkey.pem +28 -0
- package/test/util/https-server/server.js +150 -0
- package/types/config.d.ts +20 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createServer } from 'node:https';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { debug } from 'node:util';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import('http').IncomingMessage} IncomingMessage
|
|
9
|
+
* @typedef {import('http').ServerResponse} ServerResponse
|
|
10
|
+
* @typedef {ServerResponse & { req: IncomingMessage;}} RequestResponse
|
|
11
|
+
* @typedef {import('https').ServerOptions} ServerOptions
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const DIRNAME = getDirname();
|
|
15
|
+
|
|
16
|
+
/** @type {ServerOptions} */
|
|
17
|
+
const options = {
|
|
18
|
+
key: readFileSync(join(DIRNAME, './server/privkey.pem')),
|
|
19
|
+
cert: readFileSync(join(DIRNAME, './server/fullchain.pem'))
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Basic https server to use for the Gitlab tests.
|
|
24
|
+
* Uses a self-signed HTTPS certificate to allow testing gitlab release options
|
|
25
|
+
* like `insecure` or `certificateAuthorityFile`.
|
|
26
|
+
*
|
|
27
|
+
* The certicates were generated using the gen-cert.sh script in this folder
|
|
28
|
+
* with the following command:
|
|
29
|
+
*
|
|
30
|
+
* `./gen-cert.sh localhost`
|
|
31
|
+
*
|
|
32
|
+
*/
|
|
33
|
+
export class GitlabTestServer {
|
|
34
|
+
constructor() {
|
|
35
|
+
this.server = createServer(options, (req, res) => this._requestHandler(req, res));
|
|
36
|
+
this.debug = debug('release-it:gitlab-test-server');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Starts the server with the given port and host
|
|
41
|
+
*
|
|
42
|
+
* @param {number} [port]
|
|
43
|
+
* @param {string} [host]
|
|
44
|
+
* @returns {Promise<void>}
|
|
45
|
+
*/
|
|
46
|
+
run(port = 3000, host) {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
if (this.server.listening) {
|
|
49
|
+
resolve();
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
this.server.listen(port, host, () => {
|
|
54
|
+
const address = this.server.address();
|
|
55
|
+
this.debug('Server listening on https://' + address.address + ':' + address.port);
|
|
56
|
+
resolve();
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
this.server.on('error', e => {
|
|
60
|
+
if (e.code === 'EADDRINUSE') {
|
|
61
|
+
reject(e);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
this.debug(e.message);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Closes the server
|
|
72
|
+
*
|
|
73
|
+
* @returns {Promise<void>}
|
|
74
|
+
*/
|
|
75
|
+
stop() {
|
|
76
|
+
return new Promise((resolve, reject) => {
|
|
77
|
+
if (!this.server.listening) {
|
|
78
|
+
resolve();
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
this.server.removeAllListeners();
|
|
83
|
+
|
|
84
|
+
this.server.close(err => {
|
|
85
|
+
if (err) {
|
|
86
|
+
reject(err);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
this.debug('Server successfully closed.');
|
|
91
|
+
resolve();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @private
|
|
98
|
+
*
|
|
99
|
+
* Server's main request handler
|
|
100
|
+
*
|
|
101
|
+
* @param {IncomingMessage} req
|
|
102
|
+
* @param {RequestResponse} res
|
|
103
|
+
* @returns {void}
|
|
104
|
+
*/
|
|
105
|
+
_requestHandler(req, res) {
|
|
106
|
+
if (req.url === '/api/v4/user') {
|
|
107
|
+
this._json(res, { id: '1234', username: 'release_bot' });
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (req.url.startsWith('/api/v4/projects') && req.url.endsWith('/members/all/1234')) {
|
|
112
|
+
this._json(res, { access_level: 50 });
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this._text(res, 'Ok');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @private
|
|
121
|
+
*
|
|
122
|
+
* Sends out a JSON response
|
|
123
|
+
*
|
|
124
|
+
* @param {RequestResponse} res
|
|
125
|
+
* @param {object} payload
|
|
126
|
+
*/
|
|
127
|
+
_json(res, payload) {
|
|
128
|
+
res.writeHead(200, { 'content-type': 'application/json' });
|
|
129
|
+
res.end(JSON.stringify(payload));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* @private
|
|
134
|
+
*
|
|
135
|
+
* Sends out a text response
|
|
136
|
+
*
|
|
137
|
+
* @param {RequestResponse} res
|
|
138
|
+
* @param {string} message
|
|
139
|
+
*/
|
|
140
|
+
_text(res, message) {
|
|
141
|
+
res.writeHead(200, { 'content-type': 'text/plan' });
|
|
142
|
+
res.end(message);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function getDirname() {
|
|
147
|
+
if (import.meta.dirname) return import.meta.dirname;
|
|
148
|
+
|
|
149
|
+
return fileURLToPath(new URL('.', import.meta.url));
|
|
150
|
+
}
|
package/types/config.d.ts
CHANGED
|
@@ -132,6 +132,16 @@ 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
|
+
|
|
142
|
+
/** @default false */
|
|
143
|
+
discussionCategoryName?: boolean | string;
|
|
144
|
+
|
|
135
145
|
/** @default false */
|
|
136
146
|
skipChecks?: boolean;
|
|
137
147
|
|
|
@@ -170,13 +180,22 @@ export interface Config {
|
|
|
170
180
|
|
|
171
181
|
/** @default null */
|
|
172
182
|
certificateAuthorityFile?: any;
|
|
173
|
-
|
|
183
|
+
|
|
174
184
|
/** @default null */
|
|
175
185
|
secure?: boolean;
|
|
176
186
|
|
|
177
187
|
/** @default null */
|
|
178
188
|
assets?: any;
|
|
179
189
|
|
|
190
|
+
/** @default false */
|
|
191
|
+
useIdsForUrls?: boolean;
|
|
192
|
+
|
|
193
|
+
/** @default false */
|
|
194
|
+
useGenericPackageRepositoryForAssets?: boolean;
|
|
195
|
+
|
|
196
|
+
/** @default "release-it" */
|
|
197
|
+
genericPackageRepositoryName?: string;
|
|
198
|
+
|
|
180
199
|
/** @default null */
|
|
181
200
|
origin?: any;
|
|
182
201
|
|