Skip to content

Commit

Permalink
Merge pull request #11 from Rexios80/feature/dart-run
Browse files Browse the repository at this point in the history
Improvements for `dart run`
  • Loading branch information
Rexios80 authored Dec 1, 2024
2 parents 621be5a + d2f683b commit 8fae493
Show file tree
Hide file tree
Showing 14 changed files with 328 additions and 106 deletions.
55 changes: 55 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.37.0

- `puby gen` and `puby run` now map to `dart run` instead of `[engine] pub run`
- `dart run` is automatically skipped in projects without the required package
- Projects configured with FVM will now use `fvm dart`

## 1.36.0

- Improves exit codes
Expand All @@ -6,11 +12,13 @@
- Bumps Dart SDK constraint to `^3.0.0`

## 1.35.0

- `puby link` no longer runs `pub get --offline` in flutter example projects
- Fixes `--no-fvm` flag for `puby link`
- Fixes nested fvm project resolution

## 1.34.0

- Adds `puby relink` as an alias for `puby clean && puby link`
- `puby link` now respects the fvm flutter version during linking
- `puby link` now respects excludes during linking
Expand All @@ -19,158 +27,205 @@
- Cleanup tests and fix testing in GitHub Actions

## 1.33.0

- The `puby link` command no longer requires existing `pubspec.lock` files to function
- Fixes `--no-fvm` flag for `puby link`
- Updates for fvm 3.0.0

## 1.32.1

- Adds more log lines to show that work is being done

## 1.32.0

- Fixes `puby link` on Windows

## 1.31.0

- Display the packages as they are cached by `puby link`

## 1.30.0

- Fixes `--no-fvm` flag for convenience commands
- Uses `TaskQueue` from `flutter_tools_task_queue`

## 1.29.0

- Use `fvm` if `.fvm` configuration folder exists in any parent directory

## 1.28.0

- Run `puby clean` in parallel

## 1.27.1

- Adds `puby link` to help output

## 1.27.0

- Adds `puby link` to link all locked dependencies
- Only search for projects once
- Fixes platform path separator issues
- More informational timers

## 1.26.0

- Adds `puby exec` to run any command in all projects
- Fixes a race condition with command output

## 1.25.0

- Project-level error if FVM required flutter version is not installed

## 1.24.0

- Exit immediately if pub returns an unknown subcommand error

## 1.23.0

- Adds `puby reset` as an alias for `puby clean && puby get`

## 1.22.0

- Adds the ability to disable FVM support with the `--no-fvm` option

## 1.21.0

- `puby mup` now only runs `pub upgrade --major-versions`
- > Fix a bug in dart pub upgrade --major-versions where packages not requiring major updates would be held back unless needed.
- https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md#pub
- Updates minimum Dart SDK to 2.19.0

## 1.20.0

- Retry with `flutter` engine if `dart` command fails with 'Flutter users should run `flutter pub get` instead of `dart pub get`.'

## 1.19.0

- Adds `puby mup` convenience command for `puby upgrade --major-versions && puby upgrade`

## 1.18.0

- Run `flutter clean` in dart projects

## 1.17.0

- Prints failed projects to the console

## 1.16.1

- Fixed typo

## 1.16.0

- Commands no longer run in build folders
- Uses pubspec_parse package for pubspec parsing

## 1.15.0

- Show elapsed time after command completion

## 1.14.1

- Handle empty pubspec files

## 1.14.0

- Exit if there are no projects found in the current directory

## 1.13.1

- Fixed readme layout

## 1.13.0

- FVM support
- Config file to allow per-project command exclusions
- Added tests

## 1.12.2

- Updated pub_update_checker

## 1.12.1

- Print the update text in yellow

## 1.12.0

- Added update checking

## 1.11.0

- Fixed flutter example project skipping if example folder is in current directory

## 1.10.0

- Skip projects in hidden folders
- Colored outputs

## 1.9.1

- Fixed skipping flutter example projects on Windows

## 1.9.0

- Fixed running on Windows

## 1.8.0

- Don't skip a Flutter example project if it is the only project found

## 1.7.0

- Added more useful help text

## 1.6.0

- Fixed issue with unicode characters in output

## 1.5.0

- Combined exit code for use in CI

## 1.4.0

- Added `puby test` and `puby clean`
- Use relative paths

## 1.3.0

- Added `puby gen` shortcut for `[dart|flutter] pub run build_runner build --delete-conflicting-outputs`

## 1.2.3

- Fixed crash with no dependencies listed in pubspec

## 1.2.2

- Print process output in real time

## 1.2.1

- Updated flutter detection

## 1.2.0

- Don't search symlinks for pubspec files

## 1.1.2

- Exit with message if no arguments are passed

## 1.1.1

- Updated readme

## 1.1.0

- Determine if a project uses dart or flutter automatically
- Skip flutter pub get for flutter example projects

## 1.0.0

- Initial version
31 changes: 18 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,20 @@ Run commands in all projects in the current directory. Handle monorepos with eas
- Combined exit code for use in CI
- Per-project command exclusions

| Command | Equivalent |
| --------------------- | ------------------------------------------------------------------- |
| `puby [args]` | `[engine] pub [args]` |
| `puby link` | Warm the pub cache and run `[engine] pub get --offline` (see below) |
| `puby gen` | `[engine] pub run build_runner build --delete-conflicting-outputs` |
| `puby test` | `[engine] test` |
| `puby clean` | `flutter clean` |
| `puby mup` | `[engine] pub upgrade --major-versions` |
| `puby reset` | `puby clean && puby get` |
| `puby relink` | `puby clean && puby link` |
| `puby exec [command]` | `command` |

For projects configured with FVM, `fvm flutter` is used. FVM support can be disabled with the `--no-fvm` option.
| Command | Equivalent |
| --------------------- | ---------------------------------------------------------- |
| `puby [args]` | `[engine] pub [args]` |
| `puby link` | Warm the pub cache and run `[engine] pub get --offline` |
| `puby gen` | `dart run build_runner build --delete-conflicting-outputs` |
| `puby run` | `dart run` |
| `puby test` | `[engine] test` |
| `puby clean` | `flutter clean` |
| `puby mup` | `[engine] pub upgrade --major-versions` |
| `puby reset` | `puby clean && puby get` |
| `puby relink` | `puby clean && puby link` |
| `puby exec [command]` | `command` |

For projects configured with FVM, `fvm flutter` and `fvm dart` are used. FVM support can be disabled with the `--no-fvm` option.

## Use as an executable

Expand Down Expand Up @@ -65,6 +66,10 @@ Benchmark setup:
- Run `puby clean && dart pub cache clean` before each run
- `melos bootstrap` is run with a [custom branch of flutter/packages](https://github.com/Rexios80/packages_flutter/tree/puby_benchmarking) with the required setup

## Notes on `puby gen` and `puby run`

Commands that map to `dart run [package]` will not run in projects that do not depend on the required package. For example, `puby gen` will skip projects that do not depend on `build_runner`. Transitive dependencies are included in this check, however a `pub get` must be run in the project at least once for the check to work.

## Notes on `puby exec`

Paths relative to the directory you are running `puby` in will not work. For example:
Expand Down
26 changes: 16 additions & 10 deletions bin/commands.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import 'link.dart';
import 'projects.dart';

abstract class Commands {
static final clean = ProjectCommand(['clean'], parallel: true);
static final clean =
ProjectCommand(['clean'], parallel: true, engine: Engine.flutter);
static final link = GlobalCommand(
['link'],
(command, projects) =>
Expand All @@ -23,13 +24,18 @@ abstract class Commands {

static final convenience = <String, List<Command>>{
'gen': [
ProjectCommand([
'pub',
'run',
'build_runner',
'build',
'--delete-conflicting-outputs',
]),
ProjectCommand(
[
'run',
'build_runner',
'build',
'--delete-conflicting-outputs',
],
engine: Engine.dart,
),
],
'run': [
ProjectCommand(['run'], engine: Engine.dart),
],
'test': [
ProjectCommand(['test']),
Expand Down Expand Up @@ -57,7 +63,7 @@ abstract class Commands {

/// Check if we should continue after this line is received
static bool shouldKill(Project project, Command command, String line) {
if (project.engine == Engine.fvm) {
if (project.fvm) {
final flutterVersionNotInstalledMatch =
RegExp(r'Flutter SDK: SDK Version : (.+?) is not installed\.')
.firstMatch(line);
Expand Down Expand Up @@ -88,7 +94,7 @@ extension ProjectCommandExtension on ProjectCommand {
if (resolved.exclude) return 0;

final finalArgs = [
if (!raw) ...resolved.engine.prefixArgs,
if (!raw) ...resolved.prefixArgs,
...args,
];

Expand Down
Loading

0 comments on commit 8fae493

Please sign in to comment.