release-it 17.4.2 → 17.6.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.
@@ -63,6 +63,7 @@
63
63
  "tokenRef": "GITLAB_TOKEN",
64
64
  "tokenHeader": "Private-Token",
65
65
  "certificateAuthorityFile": null,
66
+ "secure": null,
66
67
  "assets": null,
67
68
  "origin": null,
68
69
  "skipChecks": false
package/lib/config.js CHANGED
@@ -50,14 +50,15 @@ class Config {
50
50
  }
51
51
 
52
52
  expandPreReleaseShorthand(options) {
53
- const { increment, preRelease, preReleaseId, snapshot } = options;
53
+ const { increment, preRelease, preReleaseId, snapshot, preReleaseBase } = options;
54
54
  const isPreRelease = Boolean(preRelease) || Boolean(snapshot);
55
55
  const inc = snapshot ? 'prerelease' : increment;
56
56
  const preId = typeof preRelease === 'string' ? preRelease : typeof snapshot === 'string' ? snapshot : preReleaseId;
57
57
  options.version = {
58
58
  increment: inc,
59
59
  isPreRelease,
60
- preReleaseId: preId
60
+ preReleaseId: preId,
61
+ preReleaseBase
61
62
  };
62
63
  if (typeof snapshot === 'string' && options.git) {
63
64
  // Pre set and hard code some options
package/lib/index.js CHANGED
@@ -56,7 +56,7 @@ const runTasks = async (opts, di) => {
56
56
  await runLifeCycleHook(plugin, 'init');
57
57
  }
58
58
 
59
- const { increment, isPreRelease, preReleaseId } = options.version;
59
+ const { increment, isPreRelease, preReleaseId, preReleaseBase } = options.version;
60
60
 
61
61
  const name = await reduceUntil(plugins, plugin => plugin.getName());
62
62
  const latestVersion = (await reduceUntil(plugins, plugin => plugin.getLatestVersion())) || '0.0.0';
@@ -67,7 +67,7 @@ const runTasks = async (opts, di) => {
67
67
  process.exit(0);
68
68
  }
69
69
 
70
- const incrementBase = { latestVersion, increment, isPreRelease, preReleaseId };
70
+ const incrementBase = { latestVersion, increment, isPreRelease, preReleaseId, preReleaseBase };
71
71
 
72
72
  const { snapshot } = config.options;
73
73
  if (snapshot && (!incrementBase.latestVersion.startsWith('0.0.0') || incrementBase.latestVersion === '0.0.0')) {
@@ -17,10 +17,17 @@ class GitLab extends Release {
17
17
  super(...args);
18
18
  this.registerPrompts(prompts);
19
19
  this.assets = [];
20
- const { certificateAuthorityFile } = this.options;
21
- this.certificateAuthorityOption = certificateAuthorityFile
22
- ? { https: { certificateAuthority: fs.readFileSync(certificateAuthorityFile) } }
23
- : {};
20
+ const { certificateAuthorityFile, secure } = this.options;
21
+
22
+ const httpsOptions = {
23
+ certificateAuthority: certificateAuthorityFile ? fs.readFileSync(certificateAuthorityFile) : undefined,
24
+ rejectUnauthorized: typeof secure === 'boolean' ? secure : undefined
25
+ };
26
+
27
+ // Remove keys with undefined values
28
+ const https = _.pickBy(httpsOptions, value => value !== undefined);
29
+
30
+ this.certificateAuthorityOption = _.isEmpty(https) ? {} : { https };
24
31
  }
25
32
 
26
33
  get client() {
@@ -16,10 +16,10 @@ const CHOICES = {
16
16
  };
17
17
 
18
18
  const getIncrementChoices = context => {
19
- const { latestIsPreRelease, isPreRelease, preReleaseId } = context.version;
19
+ const { latestIsPreRelease, isPreRelease, preReleaseId, preReleaseBase } = context.version;
20
20
  const types = latestIsPreRelease ? CHOICES.latestIsPreRelease : isPreRelease ? CHOICES.preRelease : CHOICES.default;
21
21
  const choices = types.map(increment => ({
22
- name: `${increment} (${semver.inc(context.latestVersion, increment, preReleaseId)})`,
22
+ name: `${increment} (${semver.inc(context.latestVersion, increment, preReleaseId, preReleaseBase)})`,
23
23
  value: increment
24
24
  }));
25
25
  const otherChoice = {
@@ -87,7 +87,7 @@ class Version extends Plugin {
87
87
  return Boolean(semver.valid(version));
88
88
  }
89
89
 
90
- incrementVersion({ latestVersion, increment, isPreRelease, preReleaseId }) {
90
+ incrementVersion({ latestVersion, increment, isPreRelease, preReleaseId, preReleaseBase }) {
91
91
  if (increment === false) return latestVersion;
92
92
 
93
93
  const latestIsPreRelease = this.isPreRelease(latestVersion);
@@ -102,12 +102,12 @@ class Version extends Plugin {
102
102
  }
103
103
 
104
104
  if (isPreRelease && !increment && latestIsPreRelease) {
105
- return semver.inc(latestVersion, 'prerelease', preReleaseId);
105
+ return semver.inc(latestVersion, 'prerelease', preReleaseId, preReleaseBase);
106
106
  }
107
107
 
108
108
  if (this.config.isCI && !increment) {
109
109
  if (isPreRelease) {
110
- return semver.inc(latestVersion, 'prepatch', preReleaseId);
110
+ return semver.inc(latestVersion, 'prepatch', preReleaseId, preReleaseBase);
111
111
  } else {
112
112
  return semver.inc(latestVersion, 'patch');
113
113
  }
@@ -115,7 +115,7 @@ class Version extends Plugin {
115
115
 
116
116
  const normalizedType = RELEASE_TYPES.includes(increment) && isPreRelease ? `pre${increment}` : increment;
117
117
  if (ALL_RELEASE_TYPES.includes(normalizedType)) {
118
- return semver.inc(latestVersion, normalizedType, preReleaseId);
118
+ return semver.inc(latestVersion, normalizedType, preReleaseId, preReleaseBase);
119
119
  }
120
120
 
121
121
  const coercedVersion = !isValidVersion && semver.coerce(increment);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "17.4.2",
3
+ "version": "17.6.0",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -100,36 +100,36 @@
100
100
  "proxy-agent": "6.4.0",
101
101
  "semver": "7.6.2",
102
102
  "shelljs": "0.8.5",
103
- "update-notifier": "7.0.0",
103
+ "update-notifier": "7.1.0",
104
104
  "url-join": "5.0.0",
105
105
  "wildcard-match": "5.1.3",
106
106
  "yargs-parser": "21.1.1"
107
107
  },
108
108
  "devDependencies": {
109
- "@eslint/compat": "1.1.0",
109
+ "@eslint/compat": "1.1.1",
110
110
  "@eslint/eslintrc": "3.1.0",
111
- "@eslint/js": "9.6.0",
111
+ "@eslint/js": "9.7.0",
112
112
  "@octokit/request-error": "5.1.0",
113
- "@types/node": "20.14.9",
113
+ "@types/node": "20.14.10",
114
114
  "ava": "6.1.3",
115
- "eslint": "9.6.0",
115
+ "eslint": "9.7.0",
116
116
  "eslint-config-prettier": "9.1.0",
117
117
  "eslint-plugin-ava": "15.0.1",
118
- "eslint-plugin-import": "2.29.1",
118
+ "eslint-plugin-import-x": "3.0.1",
119
119
  "eslint-plugin-prettier": "5.1.3",
120
120
  "fs-monkey": "1.0.6",
121
- "globals": "15.7.0",
121
+ "globals": "15.8.0",
122
122
  "installed-check": "9.3.0",
123
- "knip": "5.23.2",
123
+ "knip": "5.26.0",
124
124
  "memfs": "4.9.3",
125
125
  "mock-stdio": "1.0.3",
126
126
  "nock": "13.5.4",
127
- "prettier": "3.3.2",
127
+ "prettier": "3.3.3",
128
128
  "remark-cli": "12.0.1",
129
129
  "remark-preset-webpro": "1.1.0",
130
130
  "sinon": "18.0.0",
131
131
  "strip-ansi": "7.1.0",
132
- "typescript": "5.5.2"
132
+ "typescript": "5.5.3"
133
133
  },
134
134
  "overrides": {
135
135
  "pac-resolver": "7.0.1",
@@ -46,6 +46,9 @@
46
46
  "certificateAuthorityFile": {
47
47
  "default": null
48
48
  },
49
+ "secure": {
50
+ "default": null
51
+ },
49
52
  "assets": {
50
53
  "default": null
51
54
  },
package/test/config.js CHANGED
@@ -101,6 +101,7 @@ test('should expand pre-release shortcut', t => {
101
101
  t.deepEqual(config.options.version, {
102
102
  increment: 'major',
103
103
  isPreRelease: true,
104
+ preReleaseBase: undefined,
104
105
  preReleaseId: 'beta'
105
106
  });
106
107
  });
@@ -110,6 +111,7 @@ test('should expand pre-release shortcut (preRelease boolean)', t => {
110
111
  t.deepEqual(config.options.version, {
111
112
  increment: undefined,
112
113
  isPreRelease: true,
114
+ preReleaseBase: undefined,
113
115
  preReleaseId: undefined
114
116
  });
115
117
  });
@@ -119,6 +121,7 @@ test('should expand pre-release shortcut (without increment)', t => {
119
121
  t.deepEqual(config.options.version, {
120
122
  increment: undefined,
121
123
  isPreRelease: true,
124
+ preReleaseBase: undefined,
122
125
  preReleaseId: 'alpha'
123
126
  });
124
127
  });
@@ -128,15 +131,27 @@ test('should expand pre-release shortcut (including increment and npm.tag)', t =
128
131
  t.deepEqual(config.options.version, {
129
132
  increment: 'minor',
130
133
  isPreRelease: true,
134
+ preReleaseBase: undefined,
131
135
  preReleaseId: 'rc'
132
136
  });
133
137
  });
134
138
 
139
+ test('should use pre-release base', t => {
140
+ const config = new Config({ increment: 'minor', preRelease: 'next', preReleaseBase: '1' });
141
+ t.deepEqual(config.options.version, {
142
+ increment: 'minor',
143
+ isPreRelease: true,
144
+ preReleaseBase: '1',
145
+ preReleaseId: 'next'
146
+ });
147
+ });
148
+
135
149
  test('should expand pre-release shortcut (snapshot)', t => {
136
150
  const config = new Config({ snapshot: 'feat' });
137
151
  t.deepEqual(config.options.version, {
138
152
  increment: 'prerelease',
139
153
  isPreRelease: true,
154
+ preReleaseBase: undefined,
140
155
  preReleaseId: 'feat'
141
156
  });
142
157
  t.is(config.options.git.tagMatch, '0.0.0-feat.[0-9]*');
package/test/gitlab.js CHANGED
@@ -1,3 +1,4 @@
1
+ import fs from 'node:fs';
1
2
  import test from 'ava';
2
3
  import sinon from 'sinon';
3
4
  import nock from 'nock';
@@ -250,3 +251,50 @@ test('should skip checks', async t => {
250
251
 
251
252
  t.is(gitlab.log.exec.args.filter(entry => /checkReleaseMilestones/.test(entry[0])).length, 0);
252
253
  });
254
+
255
+ test('should handle certificate authority options', t => {
256
+ const sandbox = sinon.createSandbox();
257
+ sandbox.stub(fs, 'readFileSync').returns('test certificate');
258
+
259
+ {
260
+ const options = { gitlab: {} };
261
+ const gitlab = factory(GitLab, { options });
262
+ t.deepEqual(gitlab.certificateAuthorityOption, {});
263
+ }
264
+
265
+ {
266
+ const options = { gitlab: { certificateAuthorityFile: 'cert.crt' } };
267
+ const gitlab = factory(GitLab, { options });
268
+ t.deepEqual(gitlab.certificateAuthorityOption, { https: { certificateAuthority: 'test certificate' } });
269
+ }
270
+
271
+ {
272
+ const options = { gitlab: { secure: false } };
273
+ const gitlab = factory(GitLab, { options });
274
+ t.deepEqual(gitlab.certificateAuthorityOption, { https: { rejectUnauthorized: false } });
275
+ }
276
+
277
+ {
278
+ const options = { gitlab: { secure: true } };
279
+ const gitlab = factory(GitLab, { options });
280
+ t.deepEqual(gitlab.certificateAuthorityOption, { https: { rejectUnauthorized: true } });
281
+ }
282
+
283
+ {
284
+ const options = { gitlab: { certificateAuthorityFile: 'cert.crt', secure: true } };
285
+ const gitlab = factory(GitLab, { options });
286
+ t.deepEqual(gitlab.certificateAuthorityOption, {
287
+ https: { certificateAuthority: 'test certificate', rejectUnauthorized: true }
288
+ });
289
+ }
290
+
291
+ {
292
+ const options = { gitlab: { certificateAuthorityFile: 'cert.crt', secure: false } };
293
+ const gitlab = factory(GitLab, { options });
294
+ t.deepEqual(gitlab.certificateAuthorityOption, {
295
+ https: { certificateAuthority: 'test certificate', rejectUnauthorized: false }
296
+ });
297
+ }
298
+
299
+ sandbox.restore();
300
+ });
package/test/version.js CHANGED
@@ -138,6 +138,34 @@ test('should increment version (patch release after pre-release)', t => {
138
138
  t.is(v.incrementVersion({ latestVersion: '1.2.3-alpha.1', increment: 'patch' }), '1.2.3');
139
139
  });
140
140
 
141
+ test('should increment version and start at base 1', t => {
142
+ const v = factory(Version);
143
+ t.is(
144
+ v.incrementVersion({
145
+ latestVersion: '1.3.0',
146
+ increment: 'major',
147
+ isPreRelease: true,
148
+ preReleaseId: 'beta',
149
+ preReleaseBase: '1'
150
+ }),
151
+ '2.0.0-beta.1'
152
+ );
153
+ });
154
+
155
+ test('should increment prerelease version and ignore prelease base 1', t => {
156
+ const v = factory(Version);
157
+ t.is(
158
+ v.incrementVersion({
159
+ latestVersion: '1.2.3-alpha.5',
160
+ increment: 'prerelease',
161
+ preReleaseId: 'alpha',
162
+ isPreRelease: true,
163
+ preReleaseBase: '1'
164
+ }),
165
+ '1.2.3-alpha.6'
166
+ );
167
+ });
168
+
141
169
  test('should run tasks without errors', async t => {
142
170
  const options = { version: { increment: 'minor' } };
143
171
  const v = factory(Version, { options });
package/types/config.d.ts CHANGED
@@ -170,6 +170,9 @@ export interface Config {
170
170
 
171
171
  /** @default null */
172
172
  certificateAuthorityFile?: any;
173
+
174
+ /** @default null */
175
+ secure?: boolean;
173
176
 
174
177
  /** @default null */
175
178
  assets?: any;