Skip to content

Support URLs and paths in Add Dependency command #3635

Closed

Description

@EhsanAramide

I am using v3.27.2 of the extension and I searched for a similar issue but I didn't find anything related.

Currently, the auto-completion about dependencies just works in pubspec.yaml but I think it can be better to add the dependencies in import (for tired guys can be the best solution).

At this time the process for using a package is: (expect its kind - local, hosted on pub server or as a dev dep)

  1. Adding dependencies in pubspec.yaml
  2. Runnin pub get to fetch the package and other related configs
  3. import it and use it

But I suggest a new way (I am not sure this feature can be implemented in extension or not let me know).
For example, we want to add a dependency in the dependency section in pubspec.yaml what we should do is:

  1. import the package with this syntax import 'dep:<package_name | git_remote_repo | local/path/to/package>'; auto completion works as same logic as used in pubspec.yaml (with some modification)
  2. crtl + . click on fetch package
  3. then pub add <package_name> --<associated_switch> will run and do all configurations

Note: as dev dependency we can use import 'dev:<package_name | git_remote_repo | local/path/to/package>';

Activity

  1. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Oct 26, 2021
  2. DanTup commented on Oct 26, 2021

    @DanTup
    Member

    It wouldn't be technically difficult to include the packages in package:foo/ in the import completion - however, I think it would be odd to complete on the first part and then not be able to complete on the filename part (eg. /foo.dart).

    We do have a quick fix for adding the dependency automatically if you paste in the import though, eg.:

    image

    It's not exactly what was requested, but perhaps it works as an alternative?

  3. added
    awaiting infoRequires more information from the customer to progress
    on Oct 26, 2021
  4. EhsanAramide commented on Oct 26, 2021

    @EhsanAramide
    ContributorAuthor

    Yeah as you said it works as an alternative and it isn't what exactly I want.
    I think auto-completion and special syntax can be better because users can see what they want as same as in pubspec.yaml

  5. EhsanAramide commented on Oct 26, 2021

    @EhsanAramide
    ContributorAuthor

    This is what I want and what is added to the extension.

    Screenshot from 2021-10-27 00-26-31

    and after that, we do the process as same as past (ctrl + . then click add to dependencies)
    auto-completion can work for both path and regular one (fetching from pub server). I think can be implemented for GitHub I am not sure about GitHub REST API limitations.

    and this is for dev dependencies.
    Screenshot from 2021-10-27 00-34-22

  6. DanTup commented on Oct 27, 2021

    @DanTup
    Member

    I'm not sure if I entirely understand the suggestion. Are you expecting to type the dev: string, or for it to be in code completion? I'm not sure it makes sense to put invalid code into the code completion, and I'm also unsure of the benefit of typing it yourself as there are existing commands for adding dependencies, see https://dartcode.org/releases/v3-25/#improved-dependency-management

    Perhaps extending the Add Dependency commands to accept URLs and paths (in addition to the existing list of pub package names) would address the request?

  7. EhsanAramide commented on Oct 29, 2021

    @EhsanAramide
    ContributorAuthor

    I think I should have reviewed the feature before suggesting it. Actually, I agree with you about extending Add Dependency to accept URLs and paths, it would be a better solution 👍🏾

  8. DanTup commented on Nov 1, 2021

    @DanTup
    Member

    sgtm, I'll do that. Thanks!

  9. changed the title [-]importing dependencies and auto-completion [/-] [+]Support URLs and paths in Add Dependency command[/+] on Nov 1, 2021
  10. added
    in commandsRelates to commands (usually invoked from the command Palette)
    and removed
    awaiting infoRequires more information from the customer to progress
    on Nov 1, 2021
  11. added this to the v3.29.0 milestone on Nov 1, 2021
  12. EhsanAramide commented on Nov 1, 2021

    @EhsanAramide
    ContributorAuthor

    Me too. You can count on me in feature implementation (I am not a TS expert but I can do some stuff with it😅🌹)

  13. DanTup commented on Nov 1, 2021

    @DanTup
    Member

    You're welcome to have a go if you want :-)

    The way I was thinking it would work is that we insert two new items in the picklist, one for URLs and one for paths. Select the path option would open the folder picker and let you browser to the folder, and picking URL would just give an input box that is validated as a URL. Then the results just get passed to pub add the same way the package name would.

  14. EhsanAramide commented on Nov 1, 2021

    @EhsanAramide
    ContributorAuthor

    Thank you a lot for your response I will try to implement it on my forked repository based on contribution guidlines. I just wanted to aware you to avoid conflict.

  15. added
    good first issue :octocat:A relatively straight forward issue that could be done by a new contributor
    on Nov 2, 2021
  16. DanTup commented on Nov 22, 2021

    @DanTup
    Member

    @EhsanAramide are you still working on this? There's no rush, but if you don't have time I'm happy to try to finish it off for the upcoming release.

  17. EhsanAramide commented on Nov 22, 2021

    @EhsanAramide
    ContributorAuthor

    Thank you to make me notify, Yes as you said unfortunately I don't have time these days, I am sorry about it.💙🌹🌹

  18. DanTup commented on Nov 22, 2021

    @DanTup
    Member

    @EhsanAramide it's not problem at all, I understand how things are. I'll work on this for the next release - thank you for your effort in starting this though! :-)

  19. added a commit that references this issue on Nov 22, 2021
    a434c3a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue :octocat:A relatively straight forward issue that could be done by a new contributorin commandsRelates to commands (usually invoked from the command Palette)is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions