Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 1 deletion script/tool/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## NEXT
## 0.8.9

- Includes `dev_dependencies` when overridding dependencies using
`make-deps-path-based`.
- Bypasses version and CHANGELOG checks for Dependabot PRs for packages
that are known not to be client-affecting.

Expand Down
10 changes: 8 additions & 2 deletions script/tool/lib/src/make_deps_path_based_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,14 @@ class MakeDepsPathBasedCommand extends PluginCommand {
throw ToolExit(_exitCannotUpdatePubspec);
}

final Iterable<String> packagesToOverride = pubspec.dependencies.keys.where(
(String packageName) => localDependencies.containsKey(packageName));
final Iterable<String> combinedDependencies = <String>[
...pubspec.dependencies.keys,
...pubspec.devDependencies.keys,
];
final Iterable<String> packagesToOverride = combinedDependencies
.where(
(String packageName) => localDependencies.containsKey(packageName))
.toList();
if (packagesToOverride.isNotEmpty) {
final String commonBasePath = packagesDir.path;
// Find the relative path to the common base.
Expand Down
2 changes: 1 addition & 1 deletion script/tool/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_plugin_tools
description: Productivity utils for flutter/plugins and flutter/packages
repository: https://github.com/flutter/plugins/tree/main/script/tool
version: 0.8.8
version: 0.8.9

dependencies:
args: ^2.1.0
Expand Down
44 changes: 43 additions & 1 deletion script/tool/test/make_deps_path_based_command_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ void main() {
package.pubspecFile.writeAsStringSync(lines.join('\n'));
}

/// Adds a 'dev_dependencies:' section with entries for each package in
/// [dependencies] to [package].
void _addDevDependenciesSection(
RepositoryPackage package, Iterable<String> devDependencies) {
final String originalContent = package.pubspecFile.readAsStringSync();
package.pubspecFile.writeAsStringSync('''
$originalContent

dev_dependencies:
${devDependencies.map((String dep) => ' $dep: ^1.0.0').join('\n')}
''');
}

test('no-ops for no plugins', () async {
createFakePackage('foo', packagesDir, isFlutter: true);
final RepositoryPackage packageBar =
Expand All @@ -81,7 +94,7 @@ void main() {
expect(packageBar.pubspecFile.readAsStringSync(), originalPubspecContents);
});

test('rewrites references', () async {
test('rewrites "dependencies" references', () async {
final RepositoryPackage simplePackage =
createFakePackage('foo', packagesDir, isFlutter: true);
final Directory pluginGroup = packagesDir.childDirectory('bar');
Expand Down Expand Up @@ -142,6 +155,35 @@ void main() {
]));
});

test('rewrites "dev_dependencies" references', () async {
createFakePackage('foo', packagesDir);
final RepositoryPackage builderPackage =
createFakePackage('foo_builder', packagesDir);

_addDevDependenciesSection(builderPackage, <String>[
'foo',
]);

final List<String> output = await runCapturingPrint(
runner, <String>['make-deps-path-based', '--target-dependencies=foo']);

expect(
output,
containsAll(<String>[
'Rewriting references to: foo...',
' Modified packages/foo_builder/pubspec.yaml',
]));

expect(
builderPackage.pubspecFile.readAsLinesSync(),
containsAllInOrder(<String>[
'# FOR TESTING ONLY. DO NOT MERGE.',
'dependency_overrides:',
' foo:',
' path: ../foo',
]));
});

// This test case ensures that running CI using this command on an interim
// PR that itself used this command won't fail on the rewrite step.
test('running a second time no-ops without failing', () async {
Expand Down