Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show registry URL before publishing #485

Merged
merged 2 commits into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion source/npm/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,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)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is the case, then you already know the registry URL ahead of time, and so you should return it (instead of calling ${pkgManager} config get unnecessarily).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TiagoDanin Could you take a look at this?

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
Original file line number Diff line number Diff line change
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) => {
itaisteinherz marked this conversation as resolved.
Show resolved Hide resolved
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