Enable prefer_relative_imports (#6501)

This commit is contained in:
stuartmorgan
2022-09-28 10:25:24 -04:00
committed by GitHub
parent 9974a8ef44
commit 2e2c4c5837
10 changed files with 47 additions and 9 deletions

View File

@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_plugin_tools/src/common/core.dart';
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
import 'core.dart';
import 'process_runner.dart'; import 'process_runner.dart';
const String _cacheCommandKey = 'CMAKE_COMMAND:INTERNAL'; const String _cacheCommandKey = 'CMAKE_COMMAND:INTERNAL';

View File

@ -3,10 +3,10 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_plugin_tools/src/common/git_version_finder.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'git_version_finder.dart';
import 'repository_package.dart'; import 'repository_package.dart';
/// The state of a package on disk relative to git state. /// The state of a package on disk relative to git state.

View File

@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'package:flutter_plugin_tools/src/common/repository_package.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import 'core.dart'; import 'core.dart';
import 'repository_package.dart';
/// Possible plugin support options for a platform. /// Possible plugin support options for a platform.
enum PlatformSupport { enum PlatformSupport {

View File

@ -3,7 +3,6 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
import 'package:git/git.dart'; import 'package:git/git.dart';
import 'package:path/path.dart' as p; import 'package:path/path.dart' as p;
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
@ -13,6 +12,7 @@ import 'common/core.dart';
import 'common/file_utils.dart'; import 'common/file_utils.dart';
import 'common/git_version_finder.dart'; import 'common/git_version_finder.dart';
import 'common/package_looping_command.dart'; import 'common/package_looping_command.dart';
import 'common/plugin_utils.dart';
import 'common/process_runner.dart'; import 'common/process_runner.dart';
import 'common/repository_package.dart'; import 'common/repository_package.dart';

View File

@ -3,12 +3,12 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_plugin_tools/src/common/plugin_utils.dart';
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
import 'common/core.dart'; import 'common/core.dart';
import 'common/gradle.dart'; import 'common/gradle.dart';
import 'common/package_looping_command.dart'; import 'common/package_looping_command.dart';
import 'common/plugin_utils.dart';
import 'common/process_runner.dart'; import 'common/process_runner.dart';
import 'common/repository_package.dart'; import 'common/repository_package.dart';

View File

@ -7,13 +7,13 @@ import 'dart:io' as io;
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:file/local.dart'; import 'package:file/local.dart';
import 'package:flutter_plugin_tools/src/dependabot_check_command.dart';
import 'analyze_command.dart'; import 'analyze_command.dart';
import 'build_examples_command.dart'; import 'build_examples_command.dart';
import 'common/core.dart'; import 'common/core.dart';
import 'create_all_plugins_app_command.dart'; import 'create_all_plugins_app_command.dart';
import 'custom_test_command.dart'; import 'custom_test_command.dart';
import 'dependabot_check_command.dart';
import 'drive_examples_command.dart'; import 'drive_examples_command.dart';
import 'federation_safety_check_command.dart'; import 'federation_safety_check_command.dart';
import 'firebase_test_lab_command.dart'; import 'firebase_test_lab_command.dart';

View File

@ -158,10 +158,12 @@ class MakeDepsPathBasedCommand extends PackageCommand {
...pubspec.dependencies.keys, ...pubspec.dependencies.keys,
...pubspec.devDependencies.keys, ...pubspec.devDependencies.keys,
]; ];
final Iterable<String> packagesToOverride = combinedDependencies final List<String> packagesToOverride = combinedDependencies
.where( .where(
(String packageName) => localDependencies.containsKey(packageName)) (String packageName) => localDependencies.containsKey(packageName))
.toList(); .toList();
// Sort the combined list to avoid sort_pub_dependencies lint violations.
packagesToOverride.sort();
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.

View File

@ -5,12 +5,12 @@
import 'dart:io' as io; import 'dart:io' as io;
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_plugin_tools/src/common/core.dart';
import 'package:git/git.dart'; import 'package:git/git.dart';
import 'package:platform/platform.dart'; import 'package:platform/platform.dart';
import 'package:yaml/yaml.dart'; import 'package:yaml/yaml.dart';
import 'package:yaml_edit/yaml_edit.dart'; import 'package:yaml_edit/yaml_edit.dart';
import 'common/core.dart';
import 'common/package_looping_command.dart'; import 'common/package_looping_command.dart';
import 'common/process_runner.dart'; import 'common/process_runner.dart';
import 'common/repository_package.dart'; import 'common/repository_package.dart';

View File

@ -4,11 +4,11 @@
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:file/file.dart'; import 'package:file/file.dart';
import 'package:flutter_plugin_tools/src/common/core.dart';
import 'package:git/git.dart'; import 'package:git/git.dart';
import 'package:pub_semver/pub_semver.dart'; import 'package:pub_semver/pub_semver.dart';
import 'package:yaml_edit/yaml_edit.dart'; import 'package:yaml_edit/yaml_edit.dart';
import 'common/core.dart';
import 'common/git_version_finder.dart'; import 'common/git_version_finder.dart';
import 'common/package_looping_command.dart'; import 'common/package_looping_command.dart';
import 'common/package_state_utils.dart'; import 'common/package_state_utils.dart';

View File

@ -184,6 +184,42 @@ ${devDependencies.map((String dep) => ' $dep: ^1.0.0').join('\n')}
])); ]));
}); });
test(
'alphabetizes overrides from different sectinos to avoid lint warnings in analysis',
() async {
createFakePackage('a', packagesDir);
createFakePackage('b', packagesDir);
createFakePackage('c', packagesDir);
final RepositoryPackage targetPackage =
createFakePackage('target', packagesDir);
_addDependencies(targetPackage, <String>['a', 'c']);
_addDevDependenciesSection(targetPackage, <String>['b']);
final List<String> output = await runCapturingPrint(runner,
<String>['make-deps-path-based', '--target-dependencies=c,a,b']);
expect(
output,
containsAllInOrder(<String>[
'Rewriting references to: c, a, b...',
' Modified packages/target/pubspec.yaml',
]));
expect(
targetPackage.pubspecFile.readAsLinesSync(),
containsAllInOrder(<String>[
'# FOR TESTING ONLY. DO NOT MERGE.',
'dependency_overrides:',
' a:',
' path: ../a',
' b:',
' path: ../b',
' c:',
' path: ../c',
]));
});
// 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 {