Commit Graph

139 Commits

Author SHA1 Message Date
Matan Lurey
5458f42782
Remove isExplicitPackageDependenciesEnabled: true, it is the default. (#169156)
This flag has been enabled by default for quite some time in `master`,
and in the current `stable`.

This is the first of many PRs to get rid of the flag and the deprecated
code it is guarding.
2025-05-21 04:26:10 +00:00
Sigurd Meldgaard
b23840d044
Only bundle assets and plugins from transitive closure of dependencies (#160443)
Fixes https://github.com/dart-lang/pub/issues/4486
Fixes https://github.com/dart-lang/pub/issues/4473
Fixes https://github.com/flutter/flutter/issues/79261
Fixes https://github.com/flutter/flutter/issues/160142
Fixes https://github.com/flutter/flutter/issues/155242

Use the new `.dart_tool/package_graph.json` file to compute the
dependency graph. Determining

* which are transitive dependencies of the main app's direct and
dev-dependencies, (not other packages from the workspace)
* which of these are only in the transitive set of the direct
dependencies

Bundles assets from dev_dependencies when running `flutter test`, but
not otherwise.
2025-05-19 15:30:58 +00:00
Matan Lurey
54b3a97f53
Allow dart pub deps --json to fail without causing an explicit crash. (#166778)
Closes https://github.com/flutter/flutter/issues/166648.

I think a better fix is to stop using `dart pub deps --json` and use
@sigurdm's new `.dart_tool/` vendored solution, but that can be a
follow-up change.
2025-04-09 01:53:02 +00:00
Matan Lurey
46969e531b
Allow generate: true as long as synthetic packages are not being used. (#165838)
Closes https://github.com/flutter/flutter/issues/164864.
2025-03-25 14:54:22 +00:00
Sigurd Meldgaard
95843ca334
Normalize path before searching for package config (#165392)
If we don't normalize the `.absolute.path` will look like `/child/.`
And `Directory('/child/.').parent` is `Directory('/child)`.
2025-03-20 10:07:32 +00:00
Sigurd Meldgaard
45b21ec3bb
Refactor writing of package config in tests (#163734)
Seems like each test had its own way of doing this.

Extracted from https://github.com/flutter/flutter/pull/160443
2025-02-28 08:51:59 +00:00
Matan Lurey
5a8f23c3dc
Fix and test an edge case in findPackageConfigFile. (#163902)
Closes https://github.com/flutter/flutter/issues/163901.

I'm not aware of a case where this causes user crashes, but it could,
and seems easy to fix/test.
2025-02-25 15:01:51 +00:00
Andrew Kolos
a9c50335c7
remove dependency on Usage from Pub class (#162279)
Towards https://github.com/flutter/flutter/issues/150575

Removes more usage of `Usage`. This PR is scoped to removing all
references to it in `pub`-related code.

<details>

<summary> Pre-launch checklist </summary> 


- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

</details>


If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
2025-01-28 17:32:27 +00:00
Michael Goderbauer
5491c8c146
Auto-format Framework (#160545)
This auto-formats all *.dart files in the repository outside of the
`engine` subdirectory and enforces that these files stay formatted with
a presubmit check.

**Reviewers:** Please carefully review all the commits except for the
one titled "formatted". The "formatted" commit was auto-generated by
running `dev/tools/format.sh -a -f`. The other commits were hand-crafted
to prepare the repo for the formatting change. I recommend reviewing the
commits one-by-one via the "Commits" tab and avoiding Github's "Files
changed" tab as it will likely slow down your browser because of the
size of this PR.

---------

Co-authored-by: Kate Lovett <katelovett@google.com>
Co-authored-by: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com>
2024-12-19 20:06:21 +00:00
Matan Lurey
daaceacb30
Fix a bug to skip flutter_gen when synthetic packages are disabled (#160367)
Without this bug fix, when flipping the flag a lot of things blow up :)

(https://github.com/flutter/flutter/pull/160289 as an example of needing
this)
2024-12-16 19:33:34 +00:00
Matan Lurey
5332e696a4
Migrate generate_synthetic_packages_test.dart to explicit-package-dependencies. (#160267)
Work towards https://github.com/flutter/flutter/issues/160257.

Unlike some of the other PRs, this test explicitly _opts-out_ of the
flag, as the test itself is testing whether the now deprecated feature
works.
2024-12-13 22:22:12 +00:00
Anis Alibegić
e2ada1c939
Fixed typos (#159331)
Here's another one of my PRs where I hunt for typos across `flutter`
repo.

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] All existing and new tests are passing.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
2024-12-05 16:54:09 +00:00
Matan Lurey
752ac20f87
No longer pass --verbose to implicit pub calls when flutter --verbose is set. (#158898)
Closes https://github.com/flutter/flutter/issues/158896.
2024-11-14 08:59:49 -08:00
Matan Lurey
125b4e945e
Move explicit package dependencies to a feature flag (#158016)
Closes https://github.com/flutter/flutter/issues/158012.

This is (effectively) a user-facing NOP, which is exchanging an
on-by-default command-line argument (`--implicit-pubspec-resolution`)
for an off-by-default global feature flag
(`explicit-package-dependencies`). It matches the mental model better,
is less painstaking to maintain and feed throughout, and will be easier
to globally flip on/off in a future PR.

---------

Co-authored-by: Andrew Kolos <andrewrkolos@gmail.com>
2024-11-13 18:33:34 -08:00
Matan Lurey
2d1a3efc38
Move dart pub deps call to <Pub>.deps and use it accordingly (#158524)
Closes https://github.com/flutter/flutter/issues/158396, closes https://github.com/flutter/flutter/pull/158370.
2024-11-13 18:03:53 +00:00
Polina Cherkasova
b8519bc21e
Reland2: Revert "Revert "Add a warning/additional handlers for parsingsynthetic-package."" (#158184)
Reverts flutter/flutter#158078
2024-11-05 09:42:57 -08:00
Polina Cherkasova
f7b24fa525
Revert "Add a warning/additional handlers for parsingsynthetic-package." (#158078)
Reverts flutter/flutter#157934 to unblock https://github.com/flutter/flutter/pull/158076 and then flutter roll.

Reason: b/377107864
2024-11-03 17:12:20 +00:00
Matan Lurey
d77d7c3f36
Add a warning/additional handlers for parsingsynthetic-package. (#157934)
Closes https://github.com/flutter/flutter/issues/157928.
Closes https://github.com/flutter/flutter/issues/157929.

| Condition | Expectation |
| --------- | ------------ |
| `synthetic-packages: true` && `--implicit-pubpsec-resolution` | Generates `flutter_gen` with warning.
| `<no synthetic-packages key>` && `--implicit-pubspec-resolution` | Generates `flutter_gen` with warning.
| `synthetic-packages: false` && `--implicit-pubpsec-resolution` | Does not generate `flutter_gen`.
| `synthetic-packages: true` && `--no-implicit-pubpsec-resolution` | Error.
| `<no synthetic-packages key>` && `--no-implicit-pubspec-resolution` | Does not generate `flutter_gen`.
| `synthetic-packages: false` && `--no-implicit-pubpsec-resolution` | Generates `flutter_gen` with warning.
2024-11-01 00:45:07 +00:00
Matan Lurey
a9e94d9045
Do not silently fail pub get even if output-mode is "none" (#153596)
I am making an assumption `OutputMode.none` should _really_ mean
`OutputMode.failuresOnly`, that is, if we ever get a non-zero exit code,
we still want to know why. If I've somehow misunderstood that, LMK and
I'm happy to revert this PR or make adjustments.

This fixes the bug where if you were to do:

```sh
git clone https://github.com/myuser/fork-of-flutter
cd fork-of-flutter
./bin/flutter update-packages
```

You now get:

1. An actual error message, versus no output at all.
2. A warning that a common reason is not tracking a remote, with
instructions to fix it.

Closes https://github.com/flutter/flutter/issues/148569.
2024-08-22 09:12:54 -07:00
Matan Lurey
66367dd888
Remove message about pub cache that is not actionable (#143357)
... and neither the pub nor tools team think it's important.

Fixes https://github.com/flutter/flutter/issues/140628.
2024-02-13 11:15:15 -08:00
Alexander Dahlberg
f3ee371285
Fixed test in language_version_test.dart that failed when shuffling, … (#142904)
…and removed the no-shuffle tag.

This PR fixes #142376 by fixing the flaky test in language_version_test.dart and removes the no-shuffle tag.
 
## The Problem
The test expected the language version that is set at the top of the test file ('2.13' set in language_version_test.dart – line 14) but defaulted to the language version set in the file it is testing ('2.12' is set in language_version.dart).

This problem was hidden when some other test ran before this test and set up the language version correctly.
 
## The Fix
Make the test itself load the default language version we are testing against.
2024-02-05 20:25:39 +00:00
Lau Ching Jun
ac7879e2aa
Avoid depending on files from build_system/targets other than from top level entrypoints in flutter_tools. (#142760)
Add a new `BuildTargets` class that provides commonly used build targets. And avoid importing files from `build_system/targets` except from the top level entrypoints or from top level commands.

Also move `scene_importer.dart` and `shader_compiler.dart` into `build_system/tools` because they are not `Target` classes, but wrapper for certain tools.

With this change, we can ignore all files in `build_system/targets` internally and make PR #142709 easier to land internally. See cl/603434066 for the corresponding internal change.

Related to:
https://github.com/flutter/flutter/pull/142709
https://github.com/flutter/flutter/issues/142041

Also note that I have opted to add a new variable in `globals.dart` for `BuildTargets` in this PR, but I know that we are trying to get rid of globals. Several alternatives that I was considering:

1. Add a new field in `BuildSystem` that returns a `BuildTargets` instance. Since `BuildSystem` is already in `globals`, we can access build targets using `globals.buildSystem.buildTargets` without adding a new global variable.
2. Properly inject the `BuildTargetsImpl` instance from the top level `executable.dart` and top level commands.

Let me know if you want me to do one of the above instead. Thanks!
2024-02-02 18:23:08 +00:00
Zachary Anderson
4601341b50
Add no-shuffle to language_version_test.dart (#142378) 2024-01-27 10:57:39 -08:00
Andrew Kolos
295a9a2031
provide command to FakeCommand::onRun (#142206)
Part of work on [#101077](https://github.com/flutter/flutter/pull/141194). This is done as a separate PR to avoid a massive diff.

## Context
1. The `FakeCommand` class accepts a list of patterns that's used to match a command given to its `FakeProcessManager`. Since `FakeCommand` can match a list of patterns, not just specifically strings, it can be used to match commands where the exact value of some arguments can't (easily) known ahead of time. For example, a part of the tool may invoke a command with an argument that is the path of a temporarily file that has a randomly-generated basename.
2. The `FakeCommand` class provides on `onRun` parameter, which is a callback that is run when the `FakeProcessManager` runs a command that matches the `FakeCommand` in question.

## Issue
In the event that a `FakeCommand` is constructed using patterns, the test code can't know the exact values used for arguments in the command. This PR proposes changing the type of `onRun` from `VoidCallback?` to `void Function(List<String>)?`. When run, the value `List<String>` parameter will be the full command that the `FakeCommand` matched.

Example:
```dart
FakeCommand(
  command: <Pattern>[
    artifacts.getArtifactPath(Artifact.engineDartBinary),
    'run',
    'vector_graphics_compiler',
    RegExp(r'--input=/.*\.temp'),
    RegExp(r'--output=/.*\.temp'),
  ],
  onRun: (List<String> command) {
    final outputPath = (() { 
      // code to parse `--output` from `command`
    })();
    testFileSystem.file(outputPath).createSync(recursive: true);
  },
)
```
2024-01-25 07:51:25 +00:00
Christopher Fujino
1cee81c40a
[flutter_tools] fix language_version_test and enable shuffle (#142009)
Part of https://github.com/flutter/flutter/issues/85160
2024-01-23 20:31:53 +00:00
Dery Rahman Ahaddienata
6b5766d41e
Fix dart pub cache clean command on pub.dart (#128171)
Command instruction for clearing dart pub cache is somewhat wrong. Instead of `clear`, `clean` is the correct one. Ref: https://dart.dev/tools/pub/cmd/pub-cache

Fixes https://github.com/flutter/flutter/issues/128663

(Edited by @andrewkolos. Changed "related to" issue to "fixes" to link this PR to the issue).
2023-06-15 20:38:04 +00:00
Sigurd Meldgaard
7b54a30e31
Notify about existing caches when preloading (#122592) 2023-03-30 16:20:33 +02:00
Christopher Fujino
7d767270b2
[flutter_tools] replace --no-analytics with --suppress-analytics (#123133)
[flutter_tools] replace --no-analytics with --suppress-analytics
2023-03-21 19:18:57 +00:00
Sigurd Meldgaard
1fd84f88e9
Always use user-level pub cache (#121802)
Use the pub cache resolved by pub itself.
To add packages to the flutter.zip download they are packaged as tar.gz and added to the pub-cache on first run by using  `pub cache preload`.
2023-03-13 08:38:17 +01:00
Sigurd Meldgaard
7a28078509
Use dart pub instead of dart __deprecated pub (#121605) 2023-03-06 11:23:12 +01:00
Andrew Kolos
ee1c59d462
reduce pub output from flutter create (#118285)
* reduce pub output from flutter create

* fix fake Pub implementations

* fix tests

* Update pub.dart

* replace enum with simpler boolean

* fix tests

* Revert "fix tests"

This reverts commit 8a3182d3b9.

* Revert "replace enum with simpler boolean"

This reverts commit 445dbc443d.

* go back to using an enum
2023-01-12 21:42:02 +00:00
Sigurd Meldgaard
40bc6b55e4
Move debug error message from failed pub to logger.printTrace (#118379)
* Move debug error message from failed pub to logger.printTrace

* Update test
2023-01-12 19:24:20 +00:00
Sigurd Meldgaard
b7881e5b64
Align flutter pub get/upgrade/add/remove/downgrade (#117896)
* Align `flutter pub get/upgrade/add/remove/downgrade`

* Add final . to command description

* Remove trailing whitespace

* Don't print message that command is being run

* Update expectations

* Use relative path

* Remove duplicated line

* Improve function dartdoc
2023-01-10 23:29:09 +00:00
Nehal Patel
de2a42497f
Fix flutter update-packages regression by fixing parameters in "pub get" runner (#116687)
* Make pub get runner respect printProgress and retry parameters

* Fix typo

* Add regression test

* Improve test

* Fix implementation and test

* Test to fix flutter_drone tests

* Revert test

* Attempt #2 to fix flutter_drone tests

* Revert attempt

* Hack: Force printProgress to debug Windows tests

* Use ProcessUtils.run to avoid dangling stdout and stderr

* Update documentation

* Clean up retry argument
2023-01-06 00:08:05 +00:00
Michael Goderbauer
b308555ed1
Enable dangling_library_doc_comments and library_annotations lints (#117365) 2022-12-20 16:03:21 -08:00
Nehal Patel
3b15d6a501
Removes retries from "dart pub get" and un-buffers its stdout/stderr output (#115801)
* Removes retries from "pub get" and proxies its stdout output

* Fix issue where ErrorHandlingProcessManager does not forward "mode" parameter to backing ProcessManager's "start" method

* Make "pub get" use ProcessStartMode.inheritStdio instead of forwarding bytes to stdout and stderr

* Fix tests

* Remove unused env var

* Add back 'Running "flutter pub get"...' status log

* Fix indent

* Add Pub.test() constructor which lets tests mock stdio
2022-12-01 19:30:17 +00:00
Christopher Fujino
559d524ec1
improve debugging when dart pub get call fails (#112968) 2022-10-05 21:53:06 +00:00
Sigurd Meldgaard
d80e994a62
Reland: Show output from pub get in flutter pub get (#110851) 2022-09-08 15:13:23 +02:00
Zachary Anderson
0e195e9d46
Revert "Show output from pub get in flutter pub get (#106300)" (#110478)
This reverts commit 3802eb627e.
2022-08-29 08:02:50 -07:00
Sigurd Meldgaard
3802eb627e
Show output from pub get in flutter pub get (#106300) 2022-08-29 07:37:19 +00:00
Jesús S Guerrero
6048e07f47
[flutter_tools] join flutter specific with home cache (#105343) 2022-07-29 19:58:06 +00:00
Christopher Fujino
6abd3691c3
[flutter_tools] add more debugging when pub get fails (#108062) 2022-07-21 19:22:07 +00:00
Alexandre Ardhuin
07f1c20474
add missing trailing commas in list/set/map literals (#102585) 2022-04-27 09:15:35 +02:00
Ian Hickson
61a0add286
Enable avoid_redundant_argument_values lint (#91409) (#91462) 2021-10-08 09:25:14 -07:00
Zachary Anderson
b9d2177da0
Revert "Enable avoid_redundant_argument_values lint (#91409)" (#91461)
This reverts commit 5fd259be24.
2021-10-07 21:11:07 -07:00
Ian Hickson
5fd259be24
Enable avoid_redundant_argument_values lint (#91409) 2021-10-07 20:13:02 -07:00
Christopher Fujino
f753168cb6
[flutter_tools] add working directory to ProcessException when pub get fails (#91436) 2021-10-07 18:08:04 -07:00
Jason Simmons
cd19bc6007
Do not retry if pub get is run in offline mode (#90394) 2021-09-27 08:18:06 -07:00
Sigurd Meldgaard
bce366203a
Stop calling top level pub (#89032)
* Use `dart __deprecated_pub` instead of `pub` to invoke pub from tools

The top level `pub` commmand has been deprecated and will print
a message. It is however implemented via the __deprecated_pub command
that prints no message.
2021-08-30 10:40:10 -07:00
Jenn Magder
d550d497f1
Migrate some flutter_tools tests to null safety (#88850) 2021-08-25 16:21:04 -07:00