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

- Fixes the `dart fix --apply` command not working
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved

## 7.0.0

- **BREAKING CHANGE**:
Expand Down
20 changes: 10 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,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
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 +35,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'pushReplacementNamed'
inClass: 'GoRouter'
changes:
Expand All @@ -50,7 +50,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'pushNamed'
inClass: 'GoRouter'
changes:
Expand All @@ -65,7 +65,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'goNamed'
inClass: 'GoRouter'
changes:
Expand All @@ -80,7 +80,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'namedLocation'
inClass: 'GoRouter'
changes:
Expand All @@ -95,7 +95,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
method: 'namedLocation'
inClass: 'GoRouterState'
changes:
Expand All @@ -110,7 +110,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'queryParams'
inClass: 'GoRouterState'
changes:
Expand All @@ -121,7 +121,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'fullpath'
inClass: 'GoRouterState'
changes:
Expand All @@ -132,7 +132,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'params'
inClass: 'GoRouterState'
changes:
Expand All @@ -143,7 +143,7 @@ transforms:
date: 2023-04-24
bulkApply: true
element:
uris: [ 'go_router.dart' ]
uris: [ 'go_router.dart', 'package:go_router/go_router.dart' ]
field: 'subloc'
inClass: 'GoRouterState'
changes:
Expand Down
4 changes: 3 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,6 @@ 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
yaml_edit: ^2.1.0
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 13 additions & 0 deletions packages/go_router/test_fixes/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: test_fixes
publish_to: "none"
version: 1.0.0+1

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

dependencies:
flutter:
sdk: flutter
go_router:
path: ../
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
60 changes: 56 additions & 4 deletions packages/go_router/tool/run_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,79 @@
// ignore_for_file: avoid_print

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

Future<void> main(List<String> args) async {
if (!Platform.isMacOS) {
print('This test can only be run on macOS.');
if (!Platform.isMacOS && !Platform.isWindows) {
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
print('This test can only be run on macOS or windows.');
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
exit(0);
}
final p.Context ctx = p.context;
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
final Directory packageRoot =
Directory(p.dirname(Platform.script.path)).parent;
Directory(ctx.dirname(_ensureTrimLeadingSeparator(Platform.script.path)))
.parent;

//copy from go_router/test_fixes to temp directory
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
final Directory testFixesTargetDir = await Directory.systemTemp.createTemp();

await _prepareTemplate(
ctx: ctx,
testFixesDir: ctx.join(packageRoot.path, 'test_fixes'),
testFixesTargetDir: testFixesTargetDir.path,
);
final int pubGet = await _runProcess(
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
'dart',
<String>[
'pub',
'upgrade',
],
workingDirectory: testFixesTargetDir.path,
);
if (pubGet != 0) {
exit(pubGet);
}
final int status = await _runProcess(
'dart',
<String>[
'fix',
'--compare-to-golden',
],
workingDirectory: p.join(packageRoot.path, 'test_fixes'),
workingDirectory: testFixesTargetDir.path,
);
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved

exit(status);
}

Future<void> _prepareTemplate({
required String testFixesDir,
required String testFixesTargetDir,
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
required p.Context ctx,
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
}) async {
await io.copyPath(testFixesDir, testFixesTargetDir);

final String pubspecYamlPath = ctx.join(testFixesTargetDir, 'pubspec.yaml');
final File targetPubspecPath = File(pubspecYamlPath);

final YamlEditor editor = YamlEditor(await targetPubspecPath.readAsString());
editor.update(
<String>['dependencies', 'go_router', 'path'],
ctx.dirname(testFixesDir),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is go_router being pointed at the test fixes directory, rather than the go_router directory? I'm confused as to how this is working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's not pointing at the test_fixes directory, it's pointing at its parent, which is the go_router directory

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, I missed the dirname. This would be much less confusing if instead of appending test_fixes outside the method (for the sole purpose of passing it in) and then having the method have to have the special knowledge that it's the parent directory that is the go_router directory (which is not obvious in local context) to remove the component that was added outside, to just pass in the go_router directory and construct the subdirectory inside.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stuartmorgan pushed a new commit to address this, please check again

);
final String newYaml = editor.toString();
await targetPubspecPath.writeAsString(newYaml);
}

String _ensureTrimLeadingSeparator(String path) {
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
if (Platform.isWindows) {
if (path.startsWith('/')) {
ahmednfwela marked this conversation as resolved.
Show resolved Hide resolved
return path.substring(1);
}
}
return path;
}

Future<Process> _streamOutput(Future<Process> processFuture) async {
final Process process = await processFuture;
stdout.addStream(process.stdout);
Expand Down