release-it 18.0.0-next.3 → 18.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.
@@ -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
@@ -139,6 +139,9 @@ export interface Config {
139
139
  */
140
140
  makeLatest?: boolean | 'legacy';
141
141
 
142
+ /** @default false */
143
+ discussionCategoryName?: boolean | string;
144
+
142
145
  /** @default false */
143
146
  skipChecks?: boolean;
144
147
 
@@ -184,6 +187,15 @@ export interface Config {
184
187
  /** @default null */
185
188
  assets?: any;
186
189
 
190
+ /** @default false */
191
+ useIdsForUrls?: boolean;
192
+
193
+ /** @default false */
194
+ useGenericPackageRepositoryForAssets?: boolean;
195
+
196
+ /** @default "release-it" */
197
+ genericPackageRepositoryName?: string;
198
+
187
199
  /** @default null */
188
200
  origin?: any;
189
201