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

Check package name availability in custom registry #429

Merged
merged 2 commits into from
Nov 30, 2019
Merged

Check package name availability in custom registry #429

merged 2 commits into from
Nov 30, 2019

Conversation

itaisteinherz
Copy link
Collaborator

@sindresorhus
Copy link
Owner

@seognil Can you test this?

@seognil
Copy link

seognil commented Jun 13, 2019

Thanks for the patch, BUT it still won't work as what issue ticket described.

maybe the process should be like

// Pseudocode here
exports.isPackageNameAvailable = async pkg => {
	const latest = await latestVersion()(pkg.name);
	return latest == undefined // so it is not published
};

(inspired by update-notifier)
(Not dive too deep into it yet, I'm not sure if it works with the private registry, e.g. verdaccio's http://localhost:4873/)
(I'd check that myself later)


Test Info

// package.json

{
  "name": "@seognil-playground/npm-feature-test",
  // ...
  "publishConfig": {
    "registry": "https://registry.npmjs.org/",
    "access": "public"
  },
}
# shell

$ np --version 
5.0.3


$ np

Publish a new version of @seognil-playground/npm-feature-test (current: 0.0.12)
# ...
? Select semver increment or specify new version patch  0.0.13
? This scoped repo @seognil-playground/npm-feature-test hasn't been published. Do you want to publish it publicly? (y/N) 

@aladdin-add
Copy link
Contributor

is it going to support custom registry? I've switched to https://npm.taobao.org/ , but 3 tests failed:

 index › version is invalid

  /Users/weiran/repo/work/np/test/index.js:6

   5:   const message = 'Version should be either patch, minor, major, prepatch, preminor, premajor, prerelease, or a valid semver version.';
   6:   await t.throwsAsync(np('foo'), message);                                                                                             
   7:   await t.throwsAsync(np('4.x.3'), message);                                                                                           

  Promise rejected with unexpected exception:

  Error {
    context: {},
    message: 'Connection to npm registry failed',
  }

  Expected message to equal:

  'Version should be either patch, minor, major, prepatch, preminor, premajor, prerelease, or a valid semver version.'



  index › errors on too low version

  /Users/weiran/repo/work/np/test/index.js:21

   20: test('errors on too low version', async t => {                                                                              
   21:   await t.throwsAsync(np('1.0.0'), /New version `1\.0\.0` should be higher than current version `\d+\.\d+\.\d+`/);          
   22:   await t.throwsAsync(np('1.0.0-beta'), /New version `1\.0\.0-beta` should be higher than current version `\d+\.\d+\.\d+`/);

  Promise rejected with unexpected exception:

  Error {
    context: {},
    message: 'Connection to npm registry failed',
  }

  Expected message to match:

  /New version `1\.0\.0` should be higher than current version `\d+\.\d+\.\d+`/



  index › version is pre-release

  /Users/weiran/repo/work/np/test/index.js:12

   11:   const message = 'You must specify a dist-tag using --tag when publishing a pre-release version. This prevents accidentally tagging unstable ver…
   12:   await t.throwsAsync(np('premajor'), message);                                                                                                   
   13:   await t.throwsAsync(np('preminor'), message);                                                                                                   

  Promise rejected with unexpected exception:

  Error {
    context: {},
    message: 'Connection to npm registry failed',
  }

  Expected message to equal:

  'You must specify a dist-tag using --tag when publishing a pre-release version. This prevents accidentally tagging unstable versions as "latest". https://docs.npmjs.com/cli/dist-tag'

npm ERR! Test failed.  See above for more details.

@itaisteinherz
Copy link
Collaborator Author

I think that this, together with #410, will solve #424, so let's put this on hold until #410 gets merged.

Copy link
Collaborator

@chinesedfan chinesedfan left a comment

Choose a reason for hiding this comment

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

As #410 has been "merged"(in fact, 1c9d05f did the work), shall we merge this one?

@sindresorhus sindresorhus merged commit 8360cb6 into sindresorhus:master Nov 30, 2019
@itaisteinherz itaisteinherz deleted the check-package-name-registry branch March 3, 2020 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed within np,scoped package,publishConfig.registry
5 participants