release-it 15.10.5 → 15.11.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/index.js +13 -12
- package/lib/plugin/npm/npm.js +8 -1
- package/package.json +1 -1
- package/test/npm.js +17 -0
package/lib/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const runTasks = async (opts, di) => {
|
|
|
15
15
|
container.config = container.config || new Config(opts);
|
|
16
16
|
|
|
17
17
|
const { config } = container;
|
|
18
|
-
const { isCI, isVerbose, verbosityLevel, isDryRun } = config;
|
|
18
|
+
const { isCI, isVerbose, verbosityLevel, isDryRun, isChangelog, isReleaseVersion } = config;
|
|
19
19
|
|
|
20
20
|
container.log = container.log || new Logger({ isCI, isVerbose, verbosityLevel, isDryRun });
|
|
21
21
|
container.spinner = container.spinner || new Spinner({ container, config });
|
|
@@ -62,6 +62,11 @@ const runTasks = async (opts, di) => {
|
|
|
62
62
|
const latestVersion = (await reduceUntil(plugins, plugin => plugin.getLatestVersion())) || '0.0.0';
|
|
63
63
|
const changelog = await reduceUntil(plugins, plugin => plugin.getChangelog(latestVersion));
|
|
64
64
|
|
|
65
|
+
if (isChangelog) {
|
|
66
|
+
console.log(changelog);
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
const incrementBase = { latestVersion, increment, isPreRelease, preReleaseId };
|
|
66
71
|
|
|
67
72
|
let version;
|
|
@@ -74,8 +79,12 @@ const runTasks = async (opts, di) => {
|
|
|
74
79
|
|
|
75
80
|
config.setContext({ name, latestVersion, version, changelog });
|
|
76
81
|
|
|
77
|
-
|
|
78
|
-
|
|
82
|
+
if (!isReleaseVersion) {
|
|
83
|
+
const action = config.isIncrement ? 'release' : 'update';
|
|
84
|
+
const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`;
|
|
85
|
+
log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`);
|
|
86
|
+
log.preview({ title: 'changelog', text: changelog });
|
|
87
|
+
}
|
|
79
88
|
|
|
80
89
|
if (config.isIncrement) {
|
|
81
90
|
version = version || (await reduceUntil(plugins, plugin => plugin.getIncrementedVersion(incrementBase)));
|
|
@@ -83,21 +92,13 @@ const runTasks = async (opts, di) => {
|
|
|
83
92
|
|
|
84
93
|
if (!version) {
|
|
85
94
|
log.obtrusive(`No new version to release`);
|
|
86
|
-
} else if (!config.isReleaseVersion && !config.isChangelog) {
|
|
87
|
-
log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`);
|
|
88
|
-
log.preview({ title: 'changelog', text: changelog });
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
if (
|
|
97
|
+
if (isReleaseVersion) {
|
|
92
98
|
console.log(version);
|
|
93
99
|
process.exit(0);
|
|
94
100
|
}
|
|
95
101
|
|
|
96
|
-
if (config.isChangelog) {
|
|
97
|
-
console.log(changelog);
|
|
98
|
-
process.exit(0);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
102
|
if (version) {
|
|
102
103
|
config.setContext(parseVersion(version));
|
|
103
104
|
|
package/lib/plugin/npm/npm.js
CHANGED
|
@@ -13,6 +13,7 @@ const MANIFEST_PATH = './package.json';
|
|
|
13
13
|
const DEFAULT_TAG = 'latest';
|
|
14
14
|
const DEFAULT_TAG_PRERELEASE = 'next';
|
|
15
15
|
const NPM_BASE_URL = 'https://www.npmjs.com';
|
|
16
|
+
const NPM_PUBLIC_PATH = '/package';
|
|
16
17
|
|
|
17
18
|
const fixArgs = args => (args ? (typeof args === 'string' ? args.split(' ') : args) : []);
|
|
18
19
|
|
|
@@ -198,7 +199,8 @@ class npm extends Plugin {
|
|
|
198
199
|
|
|
199
200
|
getPackageUrl() {
|
|
200
201
|
const baseUrl = this.getRegistry() || NPM_BASE_URL;
|
|
201
|
-
|
|
202
|
+
const publicPath = this.getPublicPath() || NPM_PUBLIC_PATH;
|
|
203
|
+
return urlJoin(baseUrl, publicPath, this.getName());
|
|
202
204
|
}
|
|
203
205
|
|
|
204
206
|
getRegistry() {
|
|
@@ -213,6 +215,11 @@ class npm extends Plugin {
|
|
|
213
215
|
return registries[0];
|
|
214
216
|
}
|
|
215
217
|
|
|
218
|
+
getPublicPath() {
|
|
219
|
+
const { publishConfig } = this.getContext();
|
|
220
|
+
return (publishConfig && publishConfig.publicPath) ?? '';
|
|
221
|
+
}
|
|
222
|
+
|
|
216
223
|
async guessPreReleaseTag() {
|
|
217
224
|
const [tag] = await this.getRegistryPreReleaseTags();
|
|
218
225
|
if (tag) {
|
package/package.json
CHANGED
package/test/npm.js
CHANGED
|
@@ -18,6 +18,23 @@ test('should return npm package url (custom registry)', t => {
|
|
|
18
18
|
t.is(npmClient.getPackageUrl(), 'https://registry.example.org/package/my-cool-package');
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
test('should return npm package url (custom publicPath)', t => {
|
|
22
|
+
const options = { npm: { name: 'my-cool-package', publishConfig: { publicPath: '/custom/public-path' } } };
|
|
23
|
+
const npmClient = factory(npm, { options });
|
|
24
|
+
t.is(npmClient.getPackageUrl(), 'https://www.npmjs.com/custom/public-path/my-cool-package');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('should return npm package url (custom registry and publicPath)', t => {
|
|
28
|
+
const options = {
|
|
29
|
+
npm: {
|
|
30
|
+
name: 'my-cool-package',
|
|
31
|
+
publishConfig: { registry: 'https://registry.example.org/', publicPath: '/custom/public-path' }
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const npmClient = factory(npm, { options });
|
|
35
|
+
t.is(npmClient.getPackageUrl(), 'https://registry.example.org/custom/public-path/my-cool-package');
|
|
36
|
+
});
|
|
37
|
+
|
|
21
38
|
test('should return default tag', async t => {
|
|
22
39
|
const npmClient = factory(npm);
|
|
23
40
|
const tag = await npmClient.resolveTag();
|