mirror of
https://github.com/flutter/packages.git
synced 2025-06-19 13:38:53 +08:00
[tool] Include dev_dependencies
in make-deps-path-based
(#6146)
This commit is contained in:
@ -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
|
- Bypasses version and CHANGELOG checks for Dependabot PRs for packages
|
||||||
that are known not to be client-affecting.
|
that are known not to be client-affecting.
|
||||||
|
|
||||||
|
@ -154,8 +154,14 @@ class MakeDepsPathBasedCommand extends PluginCommand {
|
|||||||
throw ToolExit(_exitCannotUpdatePubspec);
|
throw ToolExit(_exitCannotUpdatePubspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Iterable<String> packagesToOverride = pubspec.dependencies.keys.where(
|
final Iterable<String> combinedDependencies = <String>[
|
||||||
(String packageName) => localDependencies.containsKey(packageName));
|
...pubspec.dependencies.keys,
|
||||||
|
...pubspec.devDependencies.keys,
|
||||||
|
];
|
||||||
|
final Iterable<String> packagesToOverride = combinedDependencies
|
||||||
|
.where(
|
||||||
|
(String packageName) => localDependencies.containsKey(packageName))
|
||||||
|
.toList();
|
||||||
if (packagesToOverride.isNotEmpty) {
|
if (packagesToOverride.isNotEmpty) {
|
||||||
final String commonBasePath = packagesDir.path;
|
final String commonBasePath = packagesDir.path;
|
||||||
// Find the relative path to the common base.
|
// Find the relative path to the common base.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: flutter_plugin_tools
|
name: flutter_plugin_tools
|
||||||
description: Productivity utils for flutter/plugins and flutter/packages
|
description: Productivity utils for flutter/plugins and flutter/packages
|
||||||
repository: https://github.com/flutter/plugins/tree/main/script/tool
|
repository: https://github.com/flutter/plugins/tree/main/script/tool
|
||||||
version: 0.8.8
|
version: 0.8.9
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
args: ^2.1.0
|
args: ^2.1.0
|
||||||
|
@ -60,6 +60,19 @@ void main() {
|
|||||||
package.pubspecFile.writeAsStringSync(lines.join('\n'));
|
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 {
|
test('no-ops for no plugins', () async {
|
||||||
createFakePackage('foo', packagesDir, isFlutter: true);
|
createFakePackage('foo', packagesDir, isFlutter: true);
|
||||||
final RepositoryPackage packageBar =
|
final RepositoryPackage packageBar =
|
||||||
@ -81,7 +94,7 @@ void main() {
|
|||||||
expect(packageBar.pubspecFile.readAsStringSync(), originalPubspecContents);
|
expect(packageBar.pubspecFile.readAsStringSync(), originalPubspecContents);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('rewrites references', () async {
|
test('rewrites "dependencies" references', () async {
|
||||||
final RepositoryPackage simplePackage =
|
final RepositoryPackage simplePackage =
|
||||||
createFakePackage('foo', packagesDir, isFlutter: true);
|
createFakePackage('foo', packagesDir, isFlutter: true);
|
||||||
final Directory pluginGroup = packagesDir.childDirectory('bar');
|
final Directory pluginGroup = packagesDir.childDirectory('bar');
|
||||||
@ -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
|
// 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.
|
// PR that itself used this command won't fail on the rewrite step.
|
||||||
test('running a second time no-ops without failing', () async {
|
test('running a second time no-ops without failing', () async {
|
||||||
|
Reference in New Issue
Block a user