mirror of
https://github.com/flutter/packages.git
synced 2025-06-17 02:48:43 +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
|
||||
that are known not to be client-affecting.
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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 =
|
||||
@ -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');
|
||||
@ -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 {
|
||||
|
Reference in New Issue
Block a user