Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dillon Nys committed Jun 28, 2023
1 parent 88d7720 commit 2640ad0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 19 deletions.
45 changes: 26 additions & 19 deletions packages/aft/lib/src/commands/bootstrap_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,39 +71,46 @@ const amplifyEnvironments = <String, String>{};
await super.run();
await linkPackages();

final bootstrapPackages = commandPackages.values.where(
// Skip bootstrap for `aft` since it has already had `dart pub upgrade`
// run with the native command, and running it again with the embedded
// command could cause issues later on, esp. when the native `pub`
// command is significantly newer/older than the embedded one.
(pkg) => pkg.name != 'aft',
);
final bootstrapPackages = commandPackages.values
.where(
// Skip bootstrap for `aft` since it has already had `dart pub upgrade`
// run with the native command, and running it again with the embedded
// command could cause issues later on, esp. when the native `pub`
// command is significantly newer/older than the embedded one.
(pkg) => pkg.name != 'aft',
)
.expand(
(pkg) => [
pkg,
if (pkg.example case final example?) example,
],
);
for (final package in bootstrapPackages) {
await pubAction(
arguments: [if (upgrade) 'upgrade' else 'get'],
package: package,
);
}
await Future.wait([
for (final package in bootstrapPackages.expand(
(pkg) => [
pkg,
if (pkg.example case final example?) example,
],
))
_createEmptyConfig(package),
for (final package in bootstrapPackages) _createEmptyConfig(package),
]);
if (build) {
// Packages which must be built because they vendor assets required for
// running all downstream packages.
const mustBuild = [
final mustBuild = [
'amplify_auth_cognito_dart',
'amplify_secure_storage_dart'
].map((pkgName) => repo.allPackages[pkgName]!);
final buildPackages = [
...commandPackages.values,

// Include "must build" packages if any of the command packages depend
// on them.
for (final mustBuildPkg in mustBuild)
if (commandPackages.values
.any((pkg) => pkg.dependsOn(mustBuildPkg, repo)))
mustBuildPkg,
];
final buildPackages = repo.allPackages.values.where(
(pkg) =>
bootstrapPackages.contains(pkg) || mustBuild.contains(pkg.name),
);
for (final package in buildPackages) {
// Only run build_runner for packages which need it for development,
// i.e. those packages which specify worker JS files in their assets.
Expand Down
14 changes: 14 additions & 0 deletions packages/aft/lib/src/models/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dart:io';

import 'package:aft/src/changelog/changelog.dart';
import 'package:aft/src/models.dart';
import 'package:aft/src/repo.dart';
import 'package:aft/src/util.dart';
import 'package:aws_common/aws_common.dart';
import 'package:collection/collection.dart';
Expand Down Expand Up @@ -223,6 +224,19 @@ class PackageInfo
p.basename(path).contains('e2e');
}

/// Whether [package] is a direct or transitive dependency of `this`.
bool dependsOn(PackageInfo package, Repo repo) {
var found = false;
dfs(
repo.getPackageGraph(includeDevDependencies: true),
root: this,
(pkg) {
if (pkg == package) found = true;
},
);
return found;
}

/// The parsed `CHANGELOG.md`.
Changelog get changelog {
final changelogMd = File(p.join(path, 'CHANGELOG.md')).readAsStringSync();
Expand Down

0 comments on commit 2640ad0

Please sign in to comment.