Skip to content

Commit 6bf85df

Browse files
Show registry URL before publishing (#485)
Co-authored-by: Itai Steinherz <itaisteinherz@gmail.com>
1 parent ccdb8a5 commit 6bf85df

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

source/npm/util.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,18 @@ exports.checkIgnoreStrategy = ({files}) => {
122122

123123
if (!files && !npmignoreExists) {
124124
console.log(`
125-
\n${chalk.bold.yellow('Warning:')} No ${chalk.bold.cyan('files')} field specified in ${chalk.bold.magenta('package.json')} nor is a ${chalk.bold.magenta('.npmignore')} file present. Having one of those will prevent you from accidentally publishing development-specific files along with your package's source code to npm.
125+
\n${chalk.bold.yellow('Warning:')} No ${chalk.bold.cyan('files')} field specified in ${chalk.bold.magenta('package.json')} nor is a ${chalk.bold.magenta('.npmignore')} file present. Having one of those will prevent you from accidentally publishing development-specific files along with your package's source code to npm.
126126
`);
127127
}
128128
};
129+
130+
exports.getRegistryUrl = async (pkgManager, pkg) => {
131+
const args = ['config', 'get', 'registry'];
132+
if (exports.isExternalRegistry(pkg)) {
133+
args.push('--registry');
134+
args.push(pkg.publishConfig.registry);
135+
}
136+
137+
const {stdout} = await execa(pkgManager, args);
138+
return stdout;
139+
};

source/ui.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ const githubUrlFromGit = require('github-url-from-git');
55
const isScoped = require('is-scoped');
66
const util = require('./util');
77
const git = require('./git-util');
8-
const {prereleaseTags, checkIgnoreStrategy} = require('./npm/util');
8+
const {prereleaseTags, checkIgnoreStrategy, getRegistryUrl} = require('./npm/util');
99
const version = require('./version');
1010
const prettyVersionDiff = require('./pretty-version-diff');
1111

12-
const printCommitLog = async repoUrl => {
12+
const printCommitLog = async (repoUrl, registryUrl) => {
1313
const latest = await git.latestTagOrFirstCommit();
1414
const log = await git.commitLogFromRevision(latest);
1515

@@ -41,7 +41,7 @@ const printCommitLog = async repoUrl => {
4141

4242
const commitRange = util.linkifyCommitRange(repoUrl, `${latest}...master`);
4343

44-
console.log(`${chalk.bold('Commits:')}\n${history}\n\n${chalk.bold('Commit Range:')}\n${commitRange}\n`);
44+
console.log(`${chalk.bold('Commits:')}\n${history}\n\n${chalk.bold('Commit Range:')}\n${commitRange}\n\n${chalk.bold('Registry:')}\n${registryUrl}\n`);
4545

4646
return {
4747
hasCommits: true,
@@ -53,6 +53,8 @@ module.exports = async (options, pkg) => {
5353
const oldVersion = pkg.version;
5454
const extraBaseUrls = ['gitlab.com'];
5555
const repoUrl = pkg.repository && githubUrlFromGit(pkg.repository.url, {extraBaseUrls});
56+
const pkgManager = options.yarn ? 'yarn' : 'npm';
57+
const registryUrl = await getRegistryUrl(pkgManager, pkg);
5658
const runPublish = options.publish && !pkg.private;
5759

5860
if (runPublish) {
@@ -143,7 +145,7 @@ module.exports = async (options, pkg) => {
143145
}
144146
];
145147

146-
const {hasCommits, releaseNotes} = await printCommitLog(repoUrl);
148+
const {hasCommits, releaseNotes} = await printCommitLog(repoUrl, registryUrl);
147149

148150
if (options.version) {
149151
return {

0 commit comments

Comments
 (0)