[flutter_tools] remove late from update-packages command (#121891)

[flutter_tools] remove late from update-packages command
This commit is contained in:
Christopher Fujino
2023-03-03 14:38:19 -08:00
committed by GitHub
parent b81b1e28a3
commit 26b7456f88
2 changed files with 23 additions and 11 deletions

View File

@@ -771,10 +771,8 @@ class PubspecYaml {
}
} else {
// We're in a section we care about. Try to parse out the dependency:
final PubspecDependency? dependency = PubspecDependency.parse(line, filename: filename);
final PubspecDependency? dependency = PubspecDependency.parse(line, filename: filename, isDevDependency: seenDev);
if (dependency != null) { // We got one!
// Track whether or not this a dev dependency.
dependency.isDevDependency = seenDev;
result.add(dependency);
if (dependency.kind == DependencyKind.unknown) {
// If we didn't get a version number, then we need to be ready to
@@ -1198,9 +1196,14 @@ class PubspecDependency extends PubspecLine {
required DependencyKind kind,
required this.version,
required this.sourcePath,
required this.isDevDependency,
}) : _kind = kind;
static PubspecDependency? parse(String line, { required String filename }) {
static PubspecDependency? parse(
String line, {
required String filename,
required bool isDevDependency,
}) {
// We recognize any line that:
// * starts with exactly two spaces, no more or less
// * has some content, then a colon
@@ -1249,7 +1252,15 @@ class PubspecDependency extends PubspecLine {
if (colonIndex != -1) {
version = line.substring(colonIndex + 1, hashIndex != -1 ? hashIndex : line.length).trim();
}
return PubspecDependency(line, package, suffix, isTransitive: isTransitive, version: version, kind: stripped.isEmpty ? DependencyKind.unknown : DependencyKind.normal, sourcePath: filename);
return PubspecDependency(
line,
package,
suffix,
isTransitive: isTransitive,
version: version,
kind: stripped.isEmpty ? DependencyKind.unknown : DependencyKind.normal, sourcePath: filename,
isDevDependency: isDevDependency,
);
}
final String name; // the package name
@@ -1257,7 +1268,7 @@ class PubspecDependency extends PubspecLine {
final String version; // the version string if found, or blank.
final bool isTransitive; // whether the suffix matched kTransitiveMagicString
final String sourcePath; // the filename of the pubspec.yaml file, for error messages
late bool isDevDependency; // Whether this dependency is under the `dev dependencies` section.
final bool isDevDependency; // Whether this dependency is under the `dev dependencies` section.
DependencyKind get kind => _kind;
DependencyKind _kind = DependencyKind.normal;
@@ -1274,8 +1285,7 @@ class PubspecDependency extends PubspecLine {
/// dependencies/dev_dependencies section, or a dependency_overrides section.
/// We track this so that we can put ourselves in the right section when
/// generating the fake pubspec.yaml.
bool get lockIsOverride => _lockIsOverride;
late bool _lockIsOverride;
bool _lockIsOverride = false;
static const String _pathPrefix = ' path: ';
static const String _sdkPrefix = ' sdk: ';
@@ -1372,7 +1382,7 @@ class PubspecDependency extends PubspecLine {
}
break;
case DependencyKind.path:
if (lockIsOverride) {
if (_lockIsOverride) {
dependencies.writeln(' $name: $versionToUse');
overrides.writeln(' $name:');
overrides.writeln(' path: $_lockTarget');
@@ -1382,7 +1392,7 @@ class PubspecDependency extends PubspecLine {
}
break;
case DependencyKind.sdk:
if (lockIsOverride) {
if (_lockIsOverride) {
dependencies.writeln(' $name: $versionToUse');
overrides.writeln(' $name:');
overrides.writeln(' sdk: $_lockTarget');
@@ -1392,7 +1402,7 @@ class PubspecDependency extends PubspecLine {
}
break;
case DependencyKind.git:
if (lockIsOverride) {
if (_lockIsOverride) {
dependencies.writeln(' $name: $versionToUse');
overrides.writeln(' $name:');
overrides.writeln(lockLine);

View File

@@ -236,6 +236,7 @@ void main() {
sourcePath: '/path/to/pubspec.yaml',
kind: DependencyKind.normal,
isTransitive: false,
isDevDependency: false,
),
],
doUpgrade: true,
@@ -255,6 +256,7 @@ void main() {
sourcePath: '/path/to/pubspec.yaml',
kind: DependencyKind.normal,
isTransitive: false,
isDevDependency: false,
),
],
);