Skip to content

Add logic for VS code to promote other VS code extensions  #4705

Closed

Description

@kenzieschmoll

As part of the broader effort to support dart ecosystem extensions, we've designed a mechanism for a pub package to provide extension information as part of its package. For DevTools, this is the precompiled flutter web app that DevTools will embed. For VS Code extensions, the pub package can include a config.yaml file that tells the Dart-Code promotion which extension should be promoted:

my_package/
   lib/
      ...
   extension/
      vs_code/
          # contains meta data that VS code needs to point to another
          # extension on the VS code marketplace
         config.yaml

package:extension_discovery has logic to detect available extensions for a given .dart_tool/package_config.json file. Since this package is written in Dart, it cannot be used by the Dart-Code extension directly, so it will need to be called into from the Dart-Code extension by proxy of some other Dart service. Eventually, this would be a great fit for the Dart Tooling Daemon, but since this does not exist yet, we can use the DevTools server in the interim.

We can add an API to DevTools server that the Dart-Code extension can call, and the devtools_server will call findExtensions('vs_code', <path/to/package_config.json>) from package:extension_discovery on the Dart-Code extension's behalf.

Open Question
The element we still need to figure out is how to handle a monorepo workspace, where there are multiple package_config.json files available.

Related: Flutter DevTools Extensions

Activity

  1. DanTup commented on Sep 4, 2023

    @DanTup
    Member

    @anderdobo @mosuem FYI - I wonder whether there's value in trying to use this for arb-editor (eg. have the Flutter/intl packages provide the recommendation)? It might need something extra (only show the recommendation if an arb file is opened?), but it might work out better than special handling for one extension?

  2. mosuem commented on Sep 5, 2023

    @mosuem

    To recap an offline discussion: We will go with implementing the suggestion the extension itself for now, see #4719. We will possibly migrate to using this new feature. At the moment, the lack of a file filter ("only show the recommendation on opening .arb files") would result in too much noise for Flutter users.

  3. DanTup commented on Sep 5, 2023

    @DanTup
    Member

    The element we still need to figure out is how to handle a monorepo workspace, where there are multiple package_config.json files available.

    We could have the client just call a single API for each project it discovers in the workspace. A single API that takes a set of projects might be slightly more efficient, but I suspect internally it would just do the same anyway so it may be better to keep the API simple.

    One slight tweak I'd make though (at least for the API called by the IDE) is to accept a package folder rather than the package_config.json directly. Dart-Code tries to avoid knowing about implementation details like .dart_tool/package_config.json (although it's unlikely to happen again, this file has moved in the past from .packages -> .dart_tool/package_config.json) so I'd prefer to keep that in the Dart world.

  4. added this to the v3.76.0 milestone on Sep 11, 2023
  5. added
    is enhancementAn enhancement or improvement that should be listed in release notes but is not a bug fix.
    on Sep 11, 2023
  6. modified the milestones: v3.76.0, v3.78.0 on Oct 30, 2023
  7. DanTup commented on Nov 20, 2023

    @DanTup
    Member

    I made a start on this at #4847 (and some SDK work in the DevTools server that needs tests before uploading).

    @kenzieschmoll @anderdobo Jacob asked me today whether this includes transitive dependencies or only direct dependencies. It's using package:extension_discovery which I think reads the .dart_tool/package_config.json and might therefore include transitive dependencies -although I'm not sure whether that's the behaviour we want?

  8. kenzieschmoll commented on Nov 20, 2023

    @kenzieschmoll
    Author

    Right now, package:extension_discovery includes transitive dependencies. @jonasfj if I remember correctly, there is not currently a way to distinguish between transitive and direct deps based on the package_config.json file, right?

    If we did only want to include direct dependencies, I think this would be easy to do by modifying the extension_discovery package so that it has a parameter includeTransitiveDependencies, and when false, it could only return extensions whose parent package has an entry in the pubspec.yaml file at the project root that is passed in to the findExtensions method.

  9. modified the milestones: v3.78.0, v3.80.0 on Nov 27, 2023
  10. DanTup commented on Dec 4, 2023

    @DanTup
    Member

    @anderdobo @jacob314 are you happy with how this displays in my current PR?

    image

    In particular, we need to be sure the user is aware they are installing third-party code that is not owned/reviewed by the Flutter team.

    @kenzieschmoll @jacob314

    1. we discussed using a whitelist for initial testing of this. Do we have any extensions in mind, or should we land this with an empty whitelist?
    2. did we conclude whether or not we're happy for this to look all (inc. transitive) dependencies, or do we need to update extension_discovery to handle only top-level dependencies (and if so, should it be only dependencies or also dev_dependencies?)
  11. kenzieschmoll commented on Dec 4, 2023

    @kenzieschmoll
    Author
    1. we discussed using a whitelist for initial testing of this. Do we have any extensions in mind, or should we land this with an empty whitelist?

    serverpod is a good first candidate. What do you need for the whitelist? just the package name? @vlidholt - can you confirm that serverpod is the correct serverpod package that you would like to promote your VS code extension from?

    1. Did we conclude whether or not we're happy for this to look all (inc. transitive) dependencies, or do we need to update extension_discovery to handle only top-level dependencies (and if so, should it be only dependencies or also dev_dependencies?)

    Since we are using a whitelist for now, I think that including transitive deps is okay. I do think we should update extension_discovery package to take a parameter includeTransitive in the findExtensions method though. (CC @jonasfj). We do want to include dev dependencies, IMO. For example, someone may provide a package solely for developer tooling (this package could contain a devtools extension and may promote a paired vs code extension too).

  12. DanTup commented on Dec 4, 2023

    @DanTup
    Member

    What do you need for the whitelist? just the package name

    I guess we could do it either by package name or extension identifier. There's probably not a lot of difference. If we have the right package name(s) I'll use them.

  13. kenzieschmoll commented on Dec 4, 2023

    @kenzieschmoll
    Author

    Extension identifier might be better since the package could arbitrarily change the VS code extension it is asking to promote, and then we really don't have control over the VS code extension whitelist.

  14. jonasfj commented on Dec 4, 2023

    @jonasfj

    I think we can let findExtensions return a field indicating whether it's a direct or transitive dependency.

    Please file an issue on repository, then let's discuss that separately.

    Correct: the information is not in package_config.json, so we'll need to read pubspec.yaml

  15. kenzieschmoll commented on Dec 4, 2023

    @kenzieschmoll
    Author

    Filed dart-lang/tools#214 to track adding transitive dependency distinction to extension_discovery

  16. anderdobo commented on Dec 4, 2023

    @anderdobo

    @anderdobo @jacob314 are you happy with how this displays in my current PR?

    image

    In particular, we need to be sure the user is aware they are installing third-party code that is not owned/reviewed by the Flutter team.

    @DanTup the notification and language LGTM. Is this ready to be used to promote ARB Editor? If so, we should.

  17. DanTup commented on Dec 4, 2023

    @DanTup
    Member

    Is this ready to be used to promote ARB Editor? If so, we should.

    I think we'll have a different codepath for the ARB editor because it won't be driven by a package (but rather opening arb files), but I do plan to look at that shortly too (there's an issue at #4719 tracking that).

  18. jacob314 commented on Dec 6, 2023

    @jacob314

    LGTM as long as the initial whitelisted packages aren't ones where the transitive dependency case is a concern. I'm not concerned about Serverpod as odds of it only being a transitive dependency seem very low (why are your dependencies using serverpod if you aren't running serverpod?).
    On the other hand, you really wouldn't want to show Freezed (e.g. you depend on a package that is using Freezed for its internal serialization but you have no idea what it is) unless they were direct dependencies because none or your app is using the functionality.

  19. modified the milestones: v3.80.0, v3.82.0 on Dec 27, 2023
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

    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