release-it 20.0.0-1 → 20.0.1
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/config.js +9 -2
- package/lib/plugin/npm/npm.js +2 -4
- package/lib/prompt.js +1 -3
- package/lib/util.js +1 -1
- package/package.json +4 -4
- package/test/config.js +13 -0
- package/test/npm.js +17 -1
- package/types/config.d.ts +1 -1
package/lib/config.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import util from 'node:util';
|
|
2
2
|
import assert from 'node:assert';
|
|
3
3
|
import { isCI } from 'ci-info';
|
|
4
|
-
import
|
|
4
|
+
import { createDefu } from 'defu';
|
|
5
5
|
import { isObjectStrict } from '@phun-ky/typeof';
|
|
6
6
|
import merge from 'lodash.merge';
|
|
7
7
|
import { loadConfig as loadC12 } from 'c12';
|
|
@@ -10,6 +10,13 @@ import { get, getSystemInfo, readJSON } from './util.js';
|
|
|
10
10
|
const debug = util.debug('release-it:config');
|
|
11
11
|
const defaultConfig = readJSON(new URL('../config/release-it.json', import.meta.url));
|
|
12
12
|
|
|
13
|
+
const defu = createDefu((obj, key, value) => {
|
|
14
|
+
if (Array.isArray(obj[key]) && Array.isArray(value)) {
|
|
15
|
+
obj[key] = value;
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
|
|
13
20
|
class Config {
|
|
14
21
|
constructor(config = {}) {
|
|
15
22
|
this.constructorConfig = config;
|
|
@@ -92,7 +99,7 @@ class Config {
|
|
|
92
99
|
|
|
93
100
|
async function loadOptions(constructorConfig) {
|
|
94
101
|
const localConfig = await loadLocalConfig(constructorConfig);
|
|
95
|
-
const merged =
|
|
102
|
+
const merged = defu(
|
|
96
103
|
{},
|
|
97
104
|
constructorConfig,
|
|
98
105
|
{
|
package/lib/plugin/npm/npm.js
CHANGED
|
@@ -91,7 +91,7 @@ class npm extends Plugin {
|
|
|
91
91
|
allowSameVersion && '--allow-same-version',
|
|
92
92
|
...fixArgs(versionArgs)
|
|
93
93
|
];
|
|
94
|
-
const task = () => this.exec(`npm version ${args.filter(Boolean).join(' ')}`, { options:
|
|
94
|
+
const task = () => this.exec(`npm version ${args.filter(Boolean).join(' ')}`, { options: { env: getNpmEnv() } });
|
|
95
95
|
return this.spinner.show({ task, label: 'npm version' });
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -232,9 +232,7 @@ class npm extends Plugin {
|
|
|
232
232
|
async guessPreReleaseTag() {
|
|
233
233
|
const distTags = await this.getRegistryDistTags();
|
|
234
234
|
const latestVersion = this.getLatestVersion();
|
|
235
|
-
const match = Object.entries(distTags).find(
|
|
236
|
-
([tag, version]) => tag !== DEFAULT_TAG && version === latestVersion
|
|
237
|
-
);
|
|
235
|
+
const match = Object.entries(distTags).find(([tag, version]) => tag !== DEFAULT_TAG && version === latestVersion);
|
|
238
236
|
if (match) return match[0];
|
|
239
237
|
|
|
240
238
|
const [tag] = Object.keys(distTags).filter(tag => tag !== DEFAULT_TAG);
|
package/lib/prompt.js
CHANGED
|
@@ -27,9 +27,7 @@ class Prompt {
|
|
|
27
27
|
if ('validate' in prompt) options.validate = prompt.validate;
|
|
28
28
|
if ('pageSize' in prompt) options.pageSize = prompt.pageSize;
|
|
29
29
|
|
|
30
|
-
const answer = await (this.createPrompt
|
|
31
|
-
? this.createPrompt(prompt.type, options)
|
|
32
|
-
: types[prompt.type](options));
|
|
30
|
+
const answer = await (this.createPrompt ? this.createPrompt(prompt.type, options) : types[prompt.type](options));
|
|
33
31
|
|
|
34
32
|
const doExecute = prompt.type === 'confirm' ? answer : true;
|
|
35
33
|
|
package/lib/util.js
CHANGED
|
@@ -95,7 +95,7 @@ export const parseGitUrl = remoteUrl => {
|
|
|
95
95
|
.replace(/\\+/g, '/'); // Replace forward with backslashes
|
|
96
96
|
const parsedUrl = gitUrlParse(normalizedUrl);
|
|
97
97
|
const { resource: host, name: project, protocol, href: remote } = parsedUrl;
|
|
98
|
-
const owner = protocol === 'file' ? parsedUrl.owner.split('/').at(-1) : parsedUrl.owner; // Fix owner for file protocol
|
|
98
|
+
const owner = protocol === 'file' ? parsedUrl.owner.split('/').at(-1) : parsedUrl.owner?.replace(/^\/+/, ''); // Fix owner for file protocol
|
|
99
99
|
const repository = `${owner}/${project}`;
|
|
100
100
|
return { host, owner, project, protocol, remote, repository };
|
|
101
101
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-it",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.1",
|
|
4
4
|
"description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"build",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
},
|
|
79
79
|
"license": "MIT",
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@inquirer/prompts": "8.
|
|
82
|
-
"
|
|
81
|
+
"@inquirer/prompts": "8.4.2",
|
|
82
|
+
"defu": "^6.1.7",
|
|
83
83
|
"@octokit/rest": "22.0.1",
|
|
84
84
|
"@phun-ky/typeof": "2.0.3",
|
|
85
85
|
"async-retry": "1.3.3",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"eslint-plugin-import-x": "4.16.2",
|
|
111
111
|
"globals": "17.4.0",
|
|
112
112
|
"installed-check": "10.0.1",
|
|
113
|
-
"knip": "6.
|
|
113
|
+
"knip": "6.6.2",
|
|
114
114
|
"mentoss": "0.13.0",
|
|
115
115
|
"mock-stdio": "1.0.3",
|
|
116
116
|
"prettier": "3.8.1",
|
package/test/config.js
CHANGED
|
@@ -65,6 +65,19 @@ describe('config', async () => {
|
|
|
65
65
|
assert.equal(config.options.npm.publish, false);
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
+
test('should replace (not concatenate) array options with user-provided arrays', async () => {
|
|
69
|
+
const config = new Config({ git: { pushArgs: ['--force'] }, npm: { publishArgs: ['--tag=next'] } });
|
|
70
|
+
await config.init();
|
|
71
|
+
assert.deepEqual(config.options.git.pushArgs, ['--force']);
|
|
72
|
+
assert.deepEqual(config.options.npm.publishArgs, ['--tag=next']);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('should allow empty array to clear default array option', async () => {
|
|
76
|
+
const config = new Config({ git: { pushArgs: [] } });
|
|
77
|
+
await config.init();
|
|
78
|
+
assert.deepEqual(config.options.git.pushArgs, []);
|
|
79
|
+
});
|
|
80
|
+
|
|
68
81
|
test('should read YAML config', async () => {
|
|
69
82
|
const config = new Config({ configDir: './test/stub/config/yaml' });
|
|
70
83
|
await config.init();
|
package/test/npm.js
CHANGED
|
@@ -52,7 +52,11 @@ describe('npm', async () => {
|
|
|
52
52
|
test('should guess tag from registry for pre-release matching current version', async t => {
|
|
53
53
|
const npmClient = await factory(npm);
|
|
54
54
|
npmClient.setContext({ latestVersion: '1.0.0-0' });
|
|
55
|
-
t.mock.method(npmClient, 'getRegistryDistTags', () => ({
|
|
55
|
+
t.mock.method(npmClient, 'getRegistryDistTags', () => ({
|
|
56
|
+
latest: '0.9.0',
|
|
57
|
+
alpha: '1.0.0-alpha.1',
|
|
58
|
+
next: '1.0.0-0'
|
|
59
|
+
}));
|
|
56
60
|
const tag = await npmClient.resolveTag('1.0.0-1');
|
|
57
61
|
assert.equal(tag, 'next');
|
|
58
62
|
});
|
|
@@ -407,4 +411,16 @@ describe('npm', async () => {
|
|
|
407
411
|
const versionArgs = getArgs(exec, 'npm version');
|
|
408
412
|
assert.match(versionArgs[0], / --workspaces-update=false --allow-same-version/);
|
|
409
413
|
});
|
|
414
|
+
|
|
415
|
+
test('should not bypass dry-run guard for `npm version`', async t => {
|
|
416
|
+
const options = { 'dry-run': true, npm: { skipChecks: true } };
|
|
417
|
+
const npmClient = await factory(npm, { options });
|
|
418
|
+
const exec = t.mock.method(npmClient.shell, 'exec', () => Promise.resolve());
|
|
419
|
+
await runTasks(npmClient);
|
|
420
|
+
const versionCall = exec.mock.calls.find(call =>
|
|
421
|
+
(typeof call.arguments[0] === 'string' ? call.arguments[0] : '').startsWith('npm version')
|
|
422
|
+
);
|
|
423
|
+
assert.ok(versionCall, 'expected `npm version` to be invoked');
|
|
424
|
+
assert.notEqual(versionCall.arguments[1]?.write, false);
|
|
425
|
+
});
|
|
410
426
|
});
|