Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[go_router] change fix_data.yaml uris to be absolute to fix lints #3877

Merged
merged 53 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
416612f
change fix_data uris to be absolute to fix lints
ahmednfwela May 1, 2023
d6bcf4f
Merge branch 'main' into fix-lints
ahmednfwela May 1, 2023
17ff4d1
changed version
ahmednfwela May 1, 2023
280bb99
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 1, 2023
c4a70c7
add both relative and absoulte paths to uri
ahmednfwela May 2, 2023
082bd09
added tests
ahmednfwela May 2, 2023
6dd50ca
create a temp folder instead
ahmednfwela May 2, 2023
95a3b1e
Merge branch 'main' into fix-lints
ahmednfwela May 2, 2023
d8b05ba
Merge branch 'main' into fix-lints
ahmednfwela May 2, 2023
22979c1
demonstrate testPubVersion
ahmednfwela May 2, 2023
7fd3b72
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 2, 2023
84abe08
Merge branch 'main' into fix-lints
ahmednfwela May 2, 2023
3c15fd1
remove testPubVersion entirely
ahmednfwela May 2, 2023
97fb307
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 2, 2023
89b929e
enable test for windows too
ahmednfwela May 2, 2023
c0eddc0
dart format to please the CI
ahmednfwela May 2, 2023
6131a59
Merge branch 'main' of https://github.com/flutter/packages into fix-l…
ahmednfwela May 2, 2023
06a65d5
address comments
ahmednfwela May 2, 2023
6b730ca
change comments
ahmednfwela May 2, 2023
c893a19
Merge branch 'main' into fix-lints
ahmednfwela May 2, 2023
769468a
Merge branch 'main' of https://github.com/flutter/packages into fix-l…
ahmednfwela May 2, 2023
1cdb2c0
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 2, 2023
dc99f47
allow io, yaml_edit since they are both dart owned
ahmednfwela May 2, 2023
9c08c45
Merge branch 'main' into fix-lints
ahmednfwela May 2, 2023
a1914d4
Merge branch 'main' into fix-lints
ahmednfwela May 2, 2023
2dd6f84
Merge branch 'main' of https://github.com/flutter/packages into fix-l…
ahmednfwela May 2, 2023
9cbbaa1
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 2, 2023
b0445fa
cleanUp
ahmednfwela May 2, 2023
78a6b4d
Apply suggestions from code review
ahmednfwela May 3, 2023
9c78f19
Merge branch 'main' into fix-lints
ahmednfwela May 3, 2023
78cb45c
Trigger
ahmednfwela May 3, 2023
8a0701c
Merge branch 'main' of https://github.com/flutter/packages into fix-l…
ahmednfwela May 3, 2023
4877b08
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 3, 2023
cda4ad7
Merge branch 'main' of https://github.com/flutter/packages into fix-l…
ahmednfwela May 4, 2023
258871f
reworked tests + added comments
ahmednfwela May 4, 2023
91e8973
small refactor
ahmednfwela May 4, 2023
a836a06
dart format
ahmednfwela May 4, 2023
025ffbc
Merge branch 'main' into fix-lints
ahmednfwela May 5, 2023
2c43ec5
address comments
ahmednfwela May 5, 2023
b64bc83
Merge branch 'main' of https://github.com/flutter/packages into fix-l…
ahmednfwela May 5, 2023
48c3ead
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 5, 2023
70ad1c9
Trigger CI
ahmednfwela May 5, 2023
751f84c
Merge branch 'main' into fix-lints
ahmednfwela May 6, 2023
e06e62f
Merge branch 'main' into fix-lints
ahmednfwela May 8, 2023
636b77b
Merge branch 'main' into fix-lints
ahmednfwela May 9, 2023
3ef6158
Merge branch 'main' of https://github.com/flutter/packages into fix-l…
ahmednfwela May 9, 2023
f023598
Merge branch 'fix-lints' of github.com:Bdaya-Dev/packages into fix-lints
ahmednfwela May 9, 2023
11e168d
address review
ahmednfwela May 9, 2023
1bed8f8
address review
ahmednfwela May 9, 2023
932e272
Merge branch 'main' into fix-lints
ahmednfwela May 9, 2023
219b9b0
format
ahmednfwela May 10, 2023
0ee09bb
Merge branch 'main' into fix-lints
ahmednfwela May 10, 2023
2d62b84
Merge branch 'main' into fix-lints
ahmednfwela May 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/go_router/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 7.0.1

- Adds a workaround for the `dart fix --apply` issue, https://github.com/dart-lang/sdk/issues/52233.

## 7.0.0

- **BREAKING CHANGE**:
Expand Down
30 changes: 20 additions & 10 deletions packages/go_router/lib/fix_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
method: 'replaceNamed'
inClass: 'GoRouter'
changes:
Expand All @@ -35,7 +36,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'pushReplacementNamed'
inClass: 'GoRouter'
changes:
Expand All @@ -50,7 +52,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'pushNamed'
inClass: 'GoRouter'
changes:
Expand All @@ -65,7 +68,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'goNamed'
inClass: 'GoRouter'
changes:
Expand All @@ -80,7 +84,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'namedLocation'
inClass: 'GoRouter'
changes:
Expand All @@ -95,7 +100,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'namedLocation'
inClass: 'GoRouterState'
changes:
Expand All @@ -110,7 +116,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'queryParams'
inClass: 'GoRouterState'
changes:
Expand All @@ -121,7 +128,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'fullpath'
inClass: 'GoRouterState'
changes:
Expand All @@ -132,7 +140,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'params'
inClass: 'GoRouterState'
changes:
Expand All @@ -143,7 +152,8 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
# TODO(ahmednfwela): Workaround for https://github.com/dart-lang/sdk/issues/52233
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'subloc'
inClass: 'GoRouterState'
changes:
Expand Down
3 changes: 2 additions & 1 deletion packages/go_router/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: go_router
description: A declarative router for Flutter based on Navigation 2 supporting
deep linking, data-driven routes and more
version: 7.0.0
version: 7.0.1
repository: https://github.com/flutter/packages/tree/main/packages/go_router
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+go_router%22

Expand All @@ -21,4 +21,5 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
io: ^1.0.4
path: ^1.8.2
chunhtai marked this conversation as resolved.
Show resolved Hide resolved
83 changes: 75 additions & 8 deletions packages/go_router/tool/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,92 @@
// ignore_for_file: avoid_print

import 'dart:io';
import 'package:io/io.dart' as io;
import 'package:path/path.dart' as p;

// This test runner simulates a consumption of go_router that checks if
// the dart fixes are applied correctly.
// This is done by copying the `test_fixes/` directory to a temp directory
// that references `go_router`, and running `dart fix --compare-to-golden`
// on the temp directory.
Future<void> main(List<String> args) async {
if (!Platform.isMacOS) {
print('This test can only be run on macOS.');
exit(0);
final Directory goRouterPackageRoot =
File.fromUri(Platform.script).parent.parent;

final Directory testTempDir = await Directory.systemTemp.createTemp();

// Cleans up the temp directory and exits with a given statusCode.
Future<Never> cleanUpAndExit(int statusCode) async {
await testTempDir.delete(recursive: true);
exit(statusCode);
}
final Directory packageRoot =
Directory(p.dirname(Platform.script.path)).parent;
final int status = await _runProcess(

// Copy the test_fixes folder to the temporary testFixesTargetDir.
//
// This also creates the proper pubspec.yaml in the temp directory.
await _prepareTemplate(
packageRoot: goRouterPackageRoot,
testTempDir: testTempDir,
);

// Run dart pub get in the temp directory to set it up.
final int pubGetStatusCode = await _runProcess(
'dart',
<String>[
'pub',
'get',
],
workingDirectory: testTempDir.path,
);

if (pubGetStatusCode != 0) {
await cleanUpAndExit(pubGetStatusCode);
}

// Run dart fix --compare-to-golden in the temp directory.
final int dartFixStatusCode = await _runProcess(
'dart',
<String>[
'fix',
'--compare-to-golden',
],
workingDirectory: p.join(packageRoot.path, 'test_fixes'),
workingDirectory: testTempDir.path,
);
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved

exit(status);
await cleanUpAndExit(dartFixStatusCode);
}

Future<void> _prepareTemplate({
required Directory packageRoot,
required Directory testTempDir,
}) async {
// The src test_fixes directory.
final Directory testFixesSrcDir =
Directory(p.join(packageRoot.path, 'test_fixes'));

// Copy from src `test_fixes/` to the temp directory.
await io.copyPath(testFixesSrcDir.path, testTempDir.path);

// The pubspec.yaml file to create.
final File targetPubspecFile = File(p.join(testTempDir.path, 'pubspec.yaml'));

final String targetYaml = '''
name: test_fixes
publish_to: "none"
version: 1.0.0

environment:
sdk: ">=2.18.0 <4.0.0"
flutter: ">=3.3.0"

dependencies:
flutter:
sdk: flutter
go_router:
path: ${packageRoot.path}
''';

await targetPubspecFile.writeAsString(targetYaml);
}

Future<Process> _streamOutput(Future<Process> processFuture) async {
Expand Down
1 change: 1 addition & 0 deletions script/configs/allowed_unpinned_deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- html
- http
- intl
- io
- js
- json_serializable
- lints
Expand Down