-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(aft): Better handling of pre-release Dart SDK usage (#3569)
Some packages in the repo (for example, the `actions` pkg) set a pre-release Dart SDK constraint so that preview features of Dart can be leveraged. This updates `aft` so that: 1) `bootstrap` skips packages which set this constraint if the current Dart SDK doesn't support it; and 2) Ignores preview constraints in the constraints checker, since these packages do not need to conform to the global setting.
- Loading branch information
Showing
7 changed files
with
261 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import 'package:aft/aft.dart'; | ||
import 'package:pub_semver/pub_semver.dart'; | ||
import 'package:pubspec_parse/pubspec_parse.dart'; | ||
import 'package:yaml/yaml.dart'; | ||
import 'package:yaml_edit/yaml_edit.dart'; | ||
|
||
/// Creates a dummy package for testing repo operations. | ||
MapEntry<PackageInfo, List<PackageInfo>> dummyPackage( | ||
String name, { | ||
Version? version, | ||
bool publishable = true, | ||
VersionConstraint? sdkConstraint, | ||
Map<PackageInfo, VersionConstraint> deps = const {}, | ||
Map<PackageInfo, VersionConstraint> devDeps = const {}, | ||
}) { | ||
final path = 'packages/$name'; | ||
sdkConstraint ??= VersionConstraint.compatibleWith(Version(3, 0, 0)); | ||
|
||
final pubspecEditor = YamlEditor(''' | ||
name: $name | ||
environment: | ||
sdk: $sdkConstraint | ||
dependencies: {} | ||
dev_dependencies: {} | ||
'''); | ||
|
||
if (version != null) { | ||
pubspecEditor.update(['version'], version.toString()); | ||
} | ||
|
||
void addConstraints( | ||
Map<PackageInfo, VersionConstraint> constraints, | ||
DependencyType type, | ||
) { | ||
for (final MapEntry(key: dep, value: constraint) in constraints.entries) { | ||
final path = <String>[type.key, dep.name]; | ||
pubspecEditor.update(path, constraint.toString()); | ||
} | ||
} | ||
|
||
addConstraints(deps, DependencyType.dependency); | ||
addConstraints(devDeps, DependencyType.devDependency); | ||
|
||
if (!publishable) { | ||
pubspecEditor.update(['publish_to'], 'none'); | ||
} | ||
|
||
final pubspecYaml = pubspecEditor.toString(); | ||
final pubspec = Pubspec.parse(pubspecYaml); | ||
final pubspecMap = loadYamlNode(pubspecYaml) as YamlMap; | ||
|
||
final package = PackageInfo( | ||
name: name, | ||
path: path, | ||
pubspecInfo: PubspecInfo( | ||
pubspec: pubspec, | ||
pubspecYaml: pubspecYaml, | ||
pubspecMap: pubspecMap, | ||
uri: Uri.base.resolve(path), | ||
), | ||
flavor: PackageFlavor.dart, | ||
); | ||
return MapEntry(package, [...deps.keys, ...devDeps.keys]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.