-
Notifications
You must be signed in to change notification settings - Fork 273
feat(aft): Adds link, clean, bootstrap, pub commands
#1883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 11 commits
360f4e2
98922e5
f79fb59
96a35b2
fa00f71
e57eabb
79b5d80
860fab8
79d5dfc
c82a31e
0b9e838
fc96807
aed747b
6d59830
fcdac25
4002029
0d995bc
a2415ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ Podfile.lock | |
| .last_build_id | ||
| .fvm/ | ||
| .packages | ||
| pubspec_overrides.yaml | ||
|
|
||
| # IDEs | ||
| .idea/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| // Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| import 'dart:io'; | ||
|
|
||
| import 'package:aft/aft.dart'; | ||
| import 'package:path/path.dart' as path; | ||
|
|
||
| /// Command to bootstrap/link Dart/Flutter packages in the repo. | ||
| class BootstrapCommand extends AmplifyCommand { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bootstrap is failing for the authenticator for me. See stack trace below. Are you not seeing that? Detailsamplify_authenticator type '_InternalLinkedHashMap' is not a subtype of type 'Map' in type cast #0 GenerateLocalizationsTarget.build (package:flutter_tools/src/build_system/targets/localizations.dart:66:7) #1 _BuildInstance._invokeInternal (package:flutter_tools/src/build_system/build_system.dart:847:27) #2 FlutterBuildSystem.build (package:flutter_tools/src/build_system/build_system.dart:614:16) #3 generateLocalizationsSyntheticPackage (package:flutter_tools/src/dart/generate_synthetic_packages.dart:58:30) #4 PackagesGetCommand._runPubGet (package:flutter_tools/src/commands/packages.dart:132:7) #5 PackagesGetCommand.runCommand (package:flutter_tools/src/commands/packages.dart:181:7) #6 FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:1209:27) #7 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #8 CommandRunner.runCommand (package:args/command_runner.dart:209:13) #9 FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9) #10 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #11 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5) #12 runFlutterPub. (package:aft/src/pub/pub_runner.dart:90:7) #13 AppContext.run. (package:flutter_tools/src/base/context.dart:150:19) #14 runFlutterPub (package:aft/src/pub/pub_runner.dart:84:3) #15 Result.capture. (package:async/src/result/result.dart:87:24)amplify_authenticator_example
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I have an open PR for it, it's just not merged yet. There's a TODO in there somewhere to make failures in pub get fatal, but right now it just prints them. |
||
| BootstrapCommand() { | ||
| argParser.addFlag( | ||
| 'upgrade', | ||
| abbr: 'u', | ||
| help: 'Runs `pub upgrade` instead of `pub get`', | ||
| negatable: false, | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| String get description => 'Links all packages in the Amplify Flutter repo ' | ||
| 'to prepare for local development'; | ||
|
|
||
| @override | ||
| String get name => 'bootstrap'; | ||
|
|
||
| @override | ||
| List<String> get aliases => ['bs']; | ||
|
|
||
| late final bool upgrade = argResults!['upgrade'] as bool; | ||
|
|
||
| /// Creates an empty `amplifyconfiguration.dart` file. | ||
| Future<void> _createEmptyConfig(PackageInfo package) async { | ||
| // Only create for example apps. | ||
| if (package.pubspecInfo.pubspec.publishTo == null) { | ||
| return; | ||
| } | ||
| // Exceptions | ||
| if (const ['aft'].contains(package.name)) { | ||
| return; | ||
| } | ||
| final file = File( | ||
| path.join(package.path, 'lib', 'amplifyconfiguration.dart'), | ||
| ); | ||
| if (await file.exists() || | ||
| !await Directory(path.join(package.path, 'lib')).exists()) { | ||
| return; | ||
| } | ||
| await file.create(); | ||
| await file.writeAsString( | ||
| ''' | ||
| const amplifyconfig = \'\'\'{ | ||
| "UserAgent": "aws-amplify-cli/2.0", | ||
| "Version": "1.0" | ||
| }\'\'\'; | ||
| ''', | ||
| ); | ||
| } | ||
|
|
||
| @override | ||
| Future<void> run() async { | ||
| final allPackages = await this.allPackages; | ||
| await linkPackages(allPackages); | ||
| await pubAction( | ||
| action: upgrade ? PubAction.upgrade : PubAction.get, | ||
| allPackages: allPackages, | ||
| verbose: verbose, | ||
| logger: logger, | ||
| createPubRunner: createPubRunner, | ||
| httpClient: httpClient, | ||
| ); | ||
| await Future.wait([ | ||
| for (final package in allPackages.values) _createEmptyConfig(package) | ||
| ]); | ||
|
|
||
| stdout.writeln('Repo successfully bootstrapped!'); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any value in pinning this anymore?