release-it 20.0.0-0 → 20.0.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/README.md +12 -11
- package/lib/plugin/npm/npm.js +21 -12
- package/package.json +1 -1
- package/test/npm.js +17 -11
- package/test/tasks.interactive.js +2 -2
package/README.md
CHANGED
|
@@ -44,7 +44,7 @@ npm install -D release-it
|
|
|
44
44
|
"release": "release-it"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"release-it": "^
|
|
47
|
+
"release-it": "^20.0.0"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
```
|
|
@@ -99,7 +99,7 @@ Here's a quick example `.release-it.json`:
|
|
|
99
99
|
|
|
100
100
|
```json
|
|
101
101
|
{
|
|
102
|
-
"$schema": "https://unpkg.com/release-it@
|
|
102
|
+
"$schema": "https://unpkg.com/release-it@20/schema/release-it.json",
|
|
103
103
|
"git": {
|
|
104
104
|
"commitMessage": "chore: release v${version}"
|
|
105
105
|
},
|
|
@@ -280,7 +280,7 @@ Note that arguments need to be quoted properly when used from the command line:
|
|
|
280
280
|
release-it --'hooks.after:release="echo Successfully released ${name} v${version} to ${repo.repository}."'
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
Using
|
|
283
|
+
Using @inquirer/prompts inside custom hook scripts might cause issues (since release-it also uses this itself).
|
|
284
284
|
|
|
285
285
|
## Dry Runs
|
|
286
286
|
|
|
@@ -353,15 +353,16 @@ release-it programmatically][58] for example code.
|
|
|
353
353
|
|
|
354
354
|
## Node.js version support
|
|
355
355
|
|
|
356
|
-
The latest major version is
|
|
356
|
+
The latest major version is v20, supporting Node.js 20 and up:
|
|
357
357
|
|
|
358
|
-
| release-it | Node.js
|
|
359
|
-
| :--------: |
|
|
360
|
-
|
|
|
361
|
-
|
|
|
362
|
-
|
|
|
363
|
-
|
|
|
364
|
-
|
|
|
358
|
+
| release-it | Node.js |
|
|
359
|
+
| :--------: | :------- |
|
|
360
|
+
| v20 | v20.19.0 |
|
|
361
|
+
| v19 | v20.12.0 |
|
|
362
|
+
| v18 | v20 |
|
|
363
|
+
| v17 | v18 |
|
|
364
|
+
| v16 | v16 |
|
|
365
|
+
| v15 | v14 |
|
|
365
366
|
|
|
366
367
|
Also see [CHANGELOG.md][80] for dates and details.
|
|
367
368
|
|
package/lib/plugin/npm/npm.js
CHANGED
|
@@ -187,21 +187,25 @@ class npm extends Plugin {
|
|
|
187
187
|
return this.exec(`npm show ${name}@${tag} version${registryArg}`, { options: getOptions() }).catch(() => null);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
getRegistryDistTags() {
|
|
191
191
|
return this.exec(`npm view ${this.getName()} dist-tags --json`, { options: getOptions() }).then(
|
|
192
192
|
output => {
|
|
193
193
|
try {
|
|
194
|
-
|
|
195
|
-
return Object.keys(tags).filter(tag => tag !== DEFAULT_TAG);
|
|
194
|
+
return JSON.parse(output);
|
|
196
195
|
} catch (err) {
|
|
197
196
|
this.debug(err);
|
|
198
|
-
return
|
|
197
|
+
return {};
|
|
199
198
|
}
|
|
200
199
|
},
|
|
201
|
-
() =>
|
|
200
|
+
() => ({})
|
|
202
201
|
);
|
|
203
202
|
}
|
|
204
203
|
|
|
204
|
+
async getRegistryPreReleaseTags() {
|
|
205
|
+
const tags = await this.getRegistryDistTags();
|
|
206
|
+
return Object.keys(tags).filter(tag => tag !== DEFAULT_TAG);
|
|
207
|
+
}
|
|
208
|
+
|
|
205
209
|
getPackageUrl() {
|
|
206
210
|
const baseUrl = this.getRegistry() || NPM_BASE_URL;
|
|
207
211
|
const publicPath = this.getPublicPath() || NPM_PUBLIC_PATH;
|
|
@@ -226,13 +230,18 @@ class npm extends Plugin {
|
|
|
226
230
|
}
|
|
227
231
|
|
|
228
232
|
async guessPreReleaseTag() {
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
const distTags = await this.getRegistryDistTags();
|
|
234
|
+
const latestVersion = this.getLatestVersion();
|
|
235
|
+
const match = Object.entries(distTags).find(
|
|
236
|
+
([tag, version]) => tag !== DEFAULT_TAG && version === latestVersion
|
|
237
|
+
);
|
|
238
|
+
if (match) return match[0];
|
|
239
|
+
|
|
240
|
+
const [tag] = Object.keys(distTags).filter(tag => tag !== DEFAULT_TAG);
|
|
241
|
+
if (tag) return tag;
|
|
242
|
+
|
|
243
|
+
this.log.warn(`Unable to get pre-release tag(s) from npm registry. Using "${DEFAULT_TAG_PRERELEASE}".`);
|
|
244
|
+
return DEFAULT_TAG_PRERELEASE;
|
|
236
245
|
}
|
|
237
246
|
|
|
238
247
|
async resolveTag(version) {
|
package/package.json
CHANGED
package/test/npm.js
CHANGED
|
@@ -44,14 +44,22 @@ describe('npm', async () => {
|
|
|
44
44
|
|
|
45
45
|
test('should resolve default tag for pre-release', async t => {
|
|
46
46
|
const npmClient = await factory(npm);
|
|
47
|
-
t.mock.method(npmClient, '
|
|
47
|
+
t.mock.method(npmClient, 'getRegistryDistTags', () => ({}));
|
|
48
48
|
const tag = await npmClient.resolveTag('1.0.0-0');
|
|
49
49
|
assert.equal(tag, 'next');
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
test('should guess tag from registry for pre-release', async t => {
|
|
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', () => ({ latest: '0.9.0', alpha: '1.0.0-alpha.1', next: '1.0.0-0' }));
|
|
56
|
+
const tag = await npmClient.resolveTag('1.0.0-1');
|
|
57
|
+
assert.equal(tag, 'next');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('should guess first pre-release tag from registry when no version match', async t => {
|
|
61
|
+
const npmClient = await factory(npm);
|
|
62
|
+
t.mock.method(npmClient, 'getRegistryDistTags', () => ({ latest: '0.9.0', alpha: '1.0.0-alpha.1' }));
|
|
55
63
|
const tag = await npmClient.resolveTag('1.0.0-0');
|
|
56
64
|
assert.equal(tag, 'alpha');
|
|
57
65
|
});
|
|
@@ -112,17 +120,15 @@ describe('npm', async () => {
|
|
|
112
120
|
const exec = t.mock.method(npmClient.shell, 'exec', command => {
|
|
113
121
|
if (command === 'npm whoami --registry registry.example.org') return Promise.resolve('john');
|
|
114
122
|
const re = /npm access (list collaborators --json|ls-collaborators) release-it --registry registry.example.org/;
|
|
115
|
-
if (re.test
|
|
123
|
+
if (re.test(command)) return Promise.resolve(JSON.stringify({ john: ['write'] }));
|
|
116
124
|
return Promise.resolve();
|
|
117
125
|
});
|
|
118
126
|
|
|
119
127
|
await runTasks(npmClient);
|
|
120
|
-
|
|
121
|
-
assert.
|
|
122
|
-
assert.
|
|
123
|
-
|
|
124
|
-
/npm show release-it@[a-z]+ version --registry registry\.example\.org/
|
|
125
|
-
);
|
|
128
|
+
const commands = exec.mock.calls.map(c => c.arguments[0]);
|
|
129
|
+
assert(commands.includes('npm ping --registry registry.example.org'));
|
|
130
|
+
assert(commands.includes('npm whoami --registry registry.example.org'));
|
|
131
|
+
assert(commands.some(c => /npm show release-it@[a-z]+ version --registry registry\.example\.org/.test(c)));
|
|
126
132
|
});
|
|
127
133
|
|
|
128
134
|
test('should not throw when executing tasks', async t => {
|
|
@@ -130,7 +136,7 @@ describe('npm', async () => {
|
|
|
130
136
|
t.mock.method(npmClient.shell, 'exec', command => {
|
|
131
137
|
if (command === 'npm whoami') return Promise.resolve('john');
|
|
132
138
|
const re = /npm access (list collaborators --json|ls-collaborators) release-it/;
|
|
133
|
-
if (re.test
|
|
139
|
+
if (re.test(command)) return Promise.resolve(JSON.stringify({ john: ['write'] }));
|
|
134
140
|
return Promise.resolve();
|
|
135
141
|
});
|
|
136
142
|
await assert.doesNotReject(runTasks(npmClient));
|
|
@@ -113,7 +113,7 @@ describe('tasks.interactive', () => {
|
|
|
113
113
|
});
|
|
114
114
|
|
|
115
115
|
const config = {
|
|
116
|
-
$schema: 'https://unpkg.com/release-it@
|
|
116
|
+
$schema: 'https://unpkg.com/release-it@20/schema/release-it.json',
|
|
117
117
|
extends: 'github:release-it/release-it-configuration',
|
|
118
118
|
config: true
|
|
119
119
|
};
|
|
@@ -137,7 +137,7 @@ describe('tasks.interactive', () => {
|
|
|
137
137
|
renameSync('.git', 'foo');
|
|
138
138
|
|
|
139
139
|
const config = {
|
|
140
|
-
$schema: 'https://unpkg.com/release-it@
|
|
140
|
+
$schema: 'https://unpkg.com/release-it@20/schema/release-it.json',
|
|
141
141
|
extends: false
|
|
142
142
|
};
|
|
143
143
|
|