Skip to content

Conversation

@mit-mit
Copy link
Member

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

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
Copy link
Member Author

mit-mit commented Mar 28, 2019

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

@mit-mit
Copy link
Member Author

mit-mit commented Mar 28, 2019

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
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.

@devoncarew
Copy link
Contributor

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

@mit-mit
Copy link
Member Author

mit-mit commented Mar 29, 2019

@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
Copy link
Member Author

mit-mit commented Mar 29, 2019

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
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
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
Copy link
Member Author

mit-mit commented Mar 29, 2019

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
Copy link
Member Author

mit-mit commented Apr 4, 2019

cc @jonahwilliams any tips on the test question above?

@jonahwilliams
Copy link
Contributor

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

@mit-mit
Copy link
Member Author

mit-mit commented Apr 5, 2019

I think so:

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

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@jonahwilliams
Copy link
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