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

Cannot add URLs as dependencies in custom cli plugin #1177

Closed
joelearn opened this issue Apr 26, 2018 · 3 comments
Closed

Cannot add URLs as dependencies in custom cli plugin #1177

joelearn opened this issue Apr 26, 2018 · 3 comments

Comments

@joelearn
Copy link

Version

3.0.0-beta.6

Steps to reproduce

In a new vue-cli-plugin, add to generator.js:

module.exports = (api, options) => {
  api.extendPackage({
    dependencies: { 'my-lib': 'https://bitbucket.org/user/my-lib.git#semver:^1.0.0' }
  })
}

Then invoke the plugin on a vue-cli 3 project.

What is expected?

Dependencies should be added to package.json, whether they are defined as semver, URL, or anything valid (see: https://docs.npmjs.com/files/package.json#dependencies)

What is actually happening?

A warning "invalid version range for dependency" is displayed in the console but the dependency merge is skipped.

@dhensche
Copy link
Contributor

@joelearn, based on the npm documentation it looks like the example you provided isn't actually valid? Your URL looks like a git repo (my-lib.git#semver:^1.0.0) but the documentation specifically lists only the git, git+ssh, git+http, git+https, or git+file protocols for git URLs while your example is https. Right now the plugin API does not support URL, Git URL, local file, or GitHub URLs because of a strict semver check for some "smart" dependency merging. I was going to look into coming up with a solution, but I wanted clarification on your example

@joelearn
Copy link
Author

@dhensche Yep, it was just an example (and perhaps a bad one at that!). I thought it might've been valid since if you npm install bitbucket:user/my-lib it saves it in that format to package.json.

My actual use-case was with the git+file protocol - that's when I first encountered the problem.

@dhensche
Copy link
Contributor

it may just be missing from the npm documentation. I'll take note of that. In coming up with a solution, I was assuming that the core Vue guys (I'm just doing this in some free time) would like to try and maintain the smart dependency merging that tries to use the latest version of a dependency. According to the npm documentation you can specify a semver version when using Git URLs so I was going to take that into account

dhensche pushed a commit to dhensche/vue-cli that referenced this issue Apr 27, 2018
npm supports multiple "version" strings when declaring deps in your
`package.json`. This PR is an attempt to support some of these other
formats in a plugin specification, while retaining the smart version
merging. If a semver range can be extracted, it will be used for
version conflict resolution. If not, a warning will be displayed to
the developer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants