Erase transient progress lines and coordinate shared grace period across embedders (#4864) * Erase progress lines using ANSI escape codes in Progress.stopAndClear * Revert ensure_pubspec_resolved.dart and remove clearWhenDone parameter * Use spinner for resolution, downloading, and executable building when summaryOnly is true * Do not print summary in SolveReport when quiet is true * Debounce progress display in Progress with delay * Adjust progress debounce delay to 150ms and timer to 50ms * Share grace period timer across spinners * Support shared ProgressGracePeriod across Zones and embedders * Fix IOOverrides recursion and update embedding test expectations * Unify progress and spinner into log.progress(..., transient: ...) * Update doc comments in progress.dart to refer to transient progress * Restore summary message output in SolveReport when quiet * Restore summary_only_environment_test expectations to match SolveReport * Address code review: propagate grace period to embedded commands, prevent timer leaks, and improve encapsulation * Refine grace period validation, export withProgressGracePeriod, and optimize client wrapping * Suppress non-terminal transient progress and clean up redundant imports * Revert nullable fileSystem in _IOOverrides to keep PR minimal * Align ANSI escape sequences with other constants in log.dart * Avoid backspace when erasing elapsed time in Progress.stopAnimating * Disable animated progress when ANSI escape codes are not supported * Require terminalOutputForStdout in addition to canUseAnsiCodes for animated progress * Remove unused top-level hasShownProgress getter and setter * Require terminalOutputForStdout in addition to canUseAnsiCodes in outdated and upgrade commands * Ensure Stopwatch is running, document constructor args, and isolate tests in progress_test.dart * Require stopwatch to be running in ProgressGracePeriod * Suppress summary message in SolveReport when quiet * Distinguish summaryOnly from quiet to preserve summary in example resolution * Use SolveReportMode enum instead of boolean flags for resolution report * Remove summaryOnly parameter from ensurePubspecResolved * Explain why withOverrides has a separate no-overrides fast path Routing the no-overrides case through runWithProgressGracePeriod adds a frame to every stack trace pub produces, which surfaces in crash logs. * Address review comments: use isNegative and extract runWithMockStdout helper
Pub is the package manager for Dart.
Thanks for being interested in contributing to pub! Contributing to a new project can be hard: there's a lot of new code and practices to learn. This document is intended to get you up and running as quickly as possible. For more information, see the pub tool documentation.
The first step towards contributing is to contact the pub dev team and let us know what you‘re working on, so we can be sure not to start working on the same thing at the same time. Open an issue letting us know that you’re interested in contributing and what you plan on working on. This will also let us give you specific advice about where to start.
Pub isn‘t a package, but it’s organized like one. It has four top-level directories:
lib/ contains the implementation of pub. Currently, it's all in lib/src/, since there are no libraries intended for public consumption.
test/ contains the tests for pub.
bin/ contains pub.dart, the entrypoint script that's run whenever a user types “pub” on the command line or runs it in the Dart editor. This is usually run through shell scripts in sdk/bin at the root of the Dart repository.
It's probably easiest to start diving into the codebase by looking at a particular pub command. Each command is encapsulated in files in lib/src/command/.
To run pub from the Git repository, run:
dart bin/pub.dart
Before any change is made to pub, all tests should pass. To run a pub test, run:
dart tool/test.dart test/path/to_test.dart
To run all tests at once, run:
dart tool/test.dart
Changes to pub should be accompanied by one or more tests that exercise the new functionality. When adding a test, the best strategy is to find a similar test in test/ and follow the same patterns.
Pub tests come in two basic forms. The first, which is usually used to unit test classes and libraries internal to pub, has many tests in a single file. This is used when each test will take a short time to run. For example, test/version_test.dart contains unit tests for pub's Version class.
The other form, used by most pub tests, is usually used for integration tests of user-visible pub commands. Each test has a file to itself, which is named after the test description. This is used when tests can take a long time to run to avoid having the tests time out when running on the build bots. For example, tests/get/hosted/get_transitive_test.dart tests the resolution of transitive hosted dependencies when using dart pub get/flutter pub get.
All patches to official Dart packages, including to pub, need to undergo code review before they're submitted. The full process for putting up your patch for review is documented elsewhere.