release-it 15.10.4 → 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 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
- const action = config.isIncrement ? 'release' : 'update';
78
- const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`;
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 (config.isReleaseVersion) {
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
 
@@ -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
- return urlJoin(baseUrl, 'package', this.getName());
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "15.10.4",
3
+ "version": "15.11.0",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -89,7 +89,7 @@
89
89
  "yargs-parser": "21.1.1"
90
90
  },
91
91
  "devDependencies": {
92
- "@octokit/request-error": "4.0.0",
92
+ "@octokit/request-error": "3.0.3",
93
93
  "ava": "5.3.0",
94
94
  "eslint": "8.41.0",
95
95
  "eslint-config-prettier": "8.8.0",
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();