Skip to content

Forward missing pub commands#30115

Merged
mit-mit merged 5 commits into
flutter:masterfrom
mit-mit:pubcmd
Apr 9, 2019
Merged

Forward missing pub commands#30115
mit-mit merged 5 commits into
flutter:masterfrom
mit-mit:pubcmd

Conversation

@mit-mit

@mit-mit mit-mit commented Mar 28, 2019

Copy link
Copy Markdown
Member

Description

Currently flutter supports just two pub subcommands:

  1. flutter packages get -> pub get
  2. flutter packages upgrade -> pub upgrade

This adds forwards for the following missing pub commands:

  1. flutter packages downgrade -> pub downgrade, the opposite of upgrade
  2. flutter packages publish -> pub publish to support publishing a plugin
  3. flutter packages deps -> pub deps to show package dependencies
  4. flutter packages run -> pub run to support running executables, e.g. for package:intl
  5. flutter packages cache -> pub cache to manage the pub cache contents
  6. flutter packages version -> pub version to see the pub version
  7. flutter packages uploader -> pub uploader to manage package uploaders
  8. flutter packages global -> pub global: pub global commands

Related Issues

Fixes #27911
Fixes #9301
Fixes #13360
Fixes #21898
Fixes #28292

@mit-mit

mit-mit commented Mar 28, 2019

Copy link
Copy Markdown
Member Author

cc @devoncarew, I'm missing tests, I think. How do those usually work the flutter packages?

@mit-mit

mit-mit commented Mar 28, 2019

Copy link
Copy Markdown
Member Author

Sample output:

  • -h:
$ flutter pub -h
Commands for managing Flutter packages.

Usage: flutter packages <subcommand> [arguments]
-h, --help    Print this usage information.

Available subcommands:
  cache       Work with the Pub system cache.
  deps        Print package dependencies.
  downgrade   Downgrade packages in a Flutter project.
  get         Get packages in a Flutter project.
  global      Work with Pub global packages.
  pub         Pass the remaining arguments to Dart's "pub" tool.
  publish     Publish the current package to pub.dartlang.org.
  run         Run an executable from a package.
  test        Run the "test" package.
  upgrade     Upgrade packages in a Flutter project.
  uploader    Manage uploaders for a package on pub.dartlang.org.
  version     Print Pub version.
  • global:
$ flutter pub global activate stagehand
Package stagehand is currently active at version 3.2.0.

@Piinks Piinks added the tool Affects the "flutter" command-line tool. See also t: labels. label Mar 28, 2019
@devoncarew

Copy link
Copy Markdown
Contributor

@mit-mit, since we're adding so many new pub forwarding commands, do we generally want these exposed as flutter packages ... or flutter pub ...?

Also adding @jonahwilliams as a reviewer.

Comment thread packages/flutter_tools/lib/src/commands/packages.dart Outdated
@devoncarew

Copy link
Copy Markdown
Contributor

re: testing, the existing flutter packages tests are at /flutter/packages/flutter_tools/test/commands/packages_test.dart.

@mit-mit

mit-mit commented Mar 29, 2019

Copy link
Copy Markdown
Member Author

@mit-mit, since we're adding so many new pub forwarding commands, do we generally want these exposed as flutter packages ... or flutter pub ...?

cc @devoncarew, we already have an alias in place, so you can already run either flutter packages xxx or flutter pub xxx. Per recent PM discussion, once we launch the new pub.dev site, we would like to move all Dart development to use the pub nomenclature, so I'll be creating a new PR here and over in flutter/website to change the docs to use flutter pub.

@mit-mit

mit-mit commented Mar 29, 2019

Copy link
Copy Markdown
Member Author

cc @kevmoo, I don't fully understand the voodoo magic for analytics over in pub.dart -- can you see if the one-liner I added is sufficient?

static final PubContext pubForward = PubContext._(<String>['forward']);

static final PubContext interactive = PubContext._(<String>['interactive']);
static final PubContext pubGet = PubContext._(<String>['get']);
static final PubContext pubUpgrade = PubContext._(<String>['upgrade']);
static final PubContext pubForward = PubContext._(<String>['forward']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be fine. This is how we track what a user ran if the command ends up hitting the server.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Great, thanks!

@mit-mit

mit-mit commented Mar 29, 2019

Copy link
Copy Markdown
Member Author

I've added tests. They are passing locally, but fail on CI. Any tips?

est/commands/packages_test.dart: packages test/pub uploader [E]                                                                                                                     
  Expected: an object with length of <2>
    Actual: ['/tmp/flutter sdk/bin/cache/dart-sdk/bin/pub', '--trace', 'uploader']
     Which: has length of <3>

@mit-mit

mit-mit commented Apr 4, 2019

Copy link
Copy Markdown
Member Author

cc @jonahwilliams any tips on the test question above?

@jonahwilliams

Copy link
Copy Markdown
Contributor

Are you running the test with pub or build_runner? CI uses pub run build_runner test

@mit-mit

mit-mit commented Apr 5, 2019

Copy link
Copy Markdown
Member Author

I think so:

$ flutter pub run build_runner test --  test/commands/packages_test.dart
...
00:19 +15: All tests passed!

@jonahwilliams jonahwilliams left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jonahwilliams

Copy link
Copy Markdown
Contributor

Restarted tool_tests-macos, they timed out

@mit-mit
mit-mit merged commit 811f1ad into flutter:master Apr 9, 2019
@mit-mit
mit-mit deleted the pubcmd branch April 9, 2019 15:03
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

6 participants