release-it 20.0.0-1 → 20.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.
- package/lib/plugin/npm/npm.js +2 -4
- package/lib/prompt.js +1 -3
- package/lib/util.js +1 -1
- package/package.json +1 -1
- package/test/npm.js +17 -1
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
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
|
});
|