Skip to content

Commit

Permalink
Show registry URL before publishing (#485)
Browse files Browse the repository at this point in the history
Co-authored-by: Itai Steinherz <itaisteinherz@gmail.com>
  • Loading branch information
TiagoDanin and itaisteinherz committed Feb 7, 2020
1 parent ccdb8a5 commit 6bf85df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 12 additions & 1 deletion source/npm/util.js
Expand Up @@ -122,7 +122,18 @@ exports.checkIgnoreStrategy = ({files}) => {

if (!files && !npmignoreExists) {
console.log(`
\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.
\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.
`);
}
};

exports.getRegistryUrl = async (pkgManager, pkg) => {
const args = ['config', 'get', 'registry'];
if (exports.isExternalRegistry(pkg)) {
args.push('--registry');
args.push(pkg.publishConfig.registry);
}

const {stdout} = await execa(pkgManager, args);
return stdout;
};
10 changes: 6 additions & 4 deletions source/ui.js
Expand Up @@ -5,11 +5,11 @@ const githubUrlFromGit = require('github-url-from-git');
const isScoped = require('is-scoped');
const util = require('./util');
const git = require('./git-util');
const {prereleaseTags, checkIgnoreStrategy} = require('./npm/util');
const {prereleaseTags, checkIgnoreStrategy, getRegistryUrl} = require('./npm/util');
const version = require('./version');
const prettyVersionDiff = require('./pretty-version-diff');

const printCommitLog = async repoUrl => {
const printCommitLog = async (repoUrl, registryUrl) => {
const latest = await git.latestTagOrFirstCommit();
const log = await git.commitLogFromRevision(latest);

Expand Down Expand Up @@ -41,7 +41,7 @@ const printCommitLog = async repoUrl => {

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

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

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

if (runPublish) {
Expand Down Expand Up @@ -143,7 +145,7 @@ module.exports = async (options, pkg) => {
}
];

const {hasCommits, releaseNotes} = await printCommitLog(repoUrl);
const {hasCommits, releaseNotes} = await printCommitLog(repoUrl, registryUrl);

if (options.version) {
return {
Expand Down

0 comments on commit 6bf85df

Please sign in to comment.