diff --git a/infra-gen2/tool/deploy_gen2.dart b/infra-gen2/tool/deploy_gen2.dart index 92f590d0028..8982aea1492 100644 --- a/infra-gen2/tool/deploy_gen2.dart +++ b/infra-gen2/tool/deploy_gen2.dart @@ -7,7 +7,7 @@ import 'dart:convert'; import 'dart:io'; -import 'package:amplify_core/amplify_core.dart'; +import 'package:amplify_core/amplify_core.dart' show UUID; import 'package:args/args.dart'; import 'package:path/path.dart' as p; @@ -20,7 +20,7 @@ import 'package:path/path.dart' as p; /// 4. Run `dart tool/deploy_gen2.dart` to deploy the backend const List infraConfig = [ AmplifyBackendGroup( - category: Category.api, + category: 'API', defaultOutput: 'packages/api/amplify_api/example/lib', backends: [ AmplifyBackend( @@ -31,7 +31,7 @@ const List infraConfig = [ ], ), AmplifyBackendGroup( - category: Category.auth, + category: 'Auth', defaultOutput: 'packages/auth/amplify_auth_cognito/example/lib', sharedOutputs: [ 'packages/auth/amplify_auth_cognito_dart/example/lib', @@ -96,7 +96,7 @@ const List infraConfig = [ ], ), AmplifyBackendGroup( - category: Category.storage, + category: 'Storage', defaultOutput: 'packages/storage/amplify_storage_s3/example/lib', backends: [ AmplifyBackend( @@ -112,7 +112,7 @@ const List infraConfig = [ ], ), AmplifyBackendGroup( - category: Category.analytics, + category: 'Analytics', defaultOutput: 'packages/analytics/amplify_analytics_pinpoint/example/lib', backends: [ AmplifyBackend( @@ -133,7 +133,7 @@ const List infraConfig = [ ], ), AmplifyBackendGroup( - category: Category.kinesis, + category: 'Kinesis', defaultOutput: 'packages/kinesis/amplify_kinesis_dart/lib', backends: [ AmplifyBackend( @@ -159,8 +159,7 @@ void main(List arguments) async { print('🚀 Deploying Gen 2 backends!'); for (final backendGroup in infraConfig) { - if (categoryToDeploy != null && - backendGroup.category.name != categoryToDeploy) { + if (categoryToDeploy != null && backendGroup.category != categoryToDeploy) { continue; } // TODO(equartey): Could be removed when all backends are defined. @@ -169,7 +168,7 @@ void main(List arguments) async { } var gen2Environments = {}; var gen1Environments = {}; - final categoryName = backendGroup.category.name; + final categoryName = backendGroup.category; final outputPath = p.join(repoRoot.path, backendGroup.defaultOutput); final amplifyOutputs = File(p.join(outputPath, 'amplify_outputs.dart')); final amplifyConfiguration = File( @@ -267,7 +266,7 @@ ArgResults _parseArgs(List args) { 'category', abbr: 'c', help: 'Specify the category to deploy.', - allowed: Category.values.map((e) => e.name).toList(), + allowed: infraConfig.map((e) => e.category).toList(), defaultsTo: null, ); @@ -276,14 +275,12 @@ ArgResults _parseArgs(List args) { /// Deploy Sandbox for a given backend backend Future _deployBackend( - Category category, + String category, AmplifyBackend backend, String outputPath, bool verbose, ) async { - print( - '🏖️ Deploying ${category.name} ${backend.name}, this may take a while...', - ); + print('🏖️ Deploying $category ${backend.name}, this may take a while...'); final outputFile = File(p.join(outputPath, 'amplify_outputs.dart')); if (outputFile.existsSync()) { @@ -329,7 +326,6 @@ Future _deployBackend( in process.stdout .transform(utf8.decoder) .transform(const LineSplitter())) { - if (!line.startsWith(' at ') && line.trim().isNotEmpty) { // This line does not belong to a cdk build error postingBackendBuildError = false; @@ -369,22 +365,24 @@ Future _deployBackend( if (exitCode != 0) { throw Exception( - '❌ Error deploying ${category.name} ${backend.identifier} sandbox', + '❌ Error deploying $category ${backend.identifier} sandbox', ); - } else if (postedDeploymentError && postedDeploymentErrorReason && postedDeploymentUpdateFailed) { + } else if (postedDeploymentError && + postedDeploymentErrorReason && + postedDeploymentUpdateFailed) { throw Exception( - '❌ Error deploying ${category.name} ${backend.identifier} sandbox: Update failed', + '❌ Error deploying $category ${backend.identifier} sandbox: Update failed', ); } else if (postedBackendBuildError) { throw Exception( - '❌ Error deploying ${category.name} ${backend.identifier} sandbox - CDK build failed', + '❌ Error deploying $category ${backend.identifier} sandbox - CDK build failed', ); } else if (!outputFile.existsSync()) { throw Exception( - '❌ Error deploying ${category.name} ${backend.identifier} sandbox - Output file not generated', + '❌ Error deploying $category ${backend.identifier} sandbox - Output file not generated', ); } else { - print('👍 ${category.name} ${backend.identifier} sandbox deployed'); + print('👍 $category ${backend.identifier} sandbox deployed'); return stackID; } } @@ -461,7 +459,7 @@ void _copyConfigFile(List outputPaths, List configFiles) { /// Create a unique bucket name String _createBucketName(String base) { - final uniqueShort = uuid().substring(0, 8); + final uniqueShort = UUID.getUUID().substring(0, 8); return '${base.toLowerCase()}-gen2-integ-$uniqueShort'; } @@ -560,14 +558,12 @@ void _uploadConfigFileToS3(String bucketName, List configFiles) { /// Generates gen 1 amplifyconfiguration.dart file void _generateGen1Config( - Category category, + String category, AmplifyBackend backend, String outputPath, String stack, ) { - print( - '📁 Generating gen 1 config file for ${category.name} ${backend.name}...', - ); + print('📁 Generating gen 1 config file for $category ${backend.name}...'); final outputFile = File(p.join(outputPath, 'amplifyconfiguration.dart')); if (outputFile.existsSync()) { @@ -594,16 +590,14 @@ void _generateGen1Config( if (process.exitCode != 0) { throw Exception( - '❌ Error generating gen 1 config file for ${category.name} ${backend.name}:: ${process.stdout}', + '❌ Error generating gen 1 config file for $category ${backend.name}:: ${process.stdout}', ); - } else if(!outputFile.existsSync()) { + } else if (!outputFile.existsSync()) { throw Exception( - '❌ Error generating gen 1 config file for ${category.name} ${backend.identifier} - Output file not generated', + '❌ Error generating gen 1 config file for $category ${backend.identifier} - Output file not generated', ); } else { - print( - '👍 Gen 1 config file for ${category.name} ${backend.name} generated', - ); + print('👍 Gen 1 config file for $category ${backend.name} generated'); } } @@ -616,7 +610,7 @@ class AmplifyBackendGroup { }); /// This is the category of the integration group - final Category category; + final String category; /// This is the list of backends for the group final List backends; diff --git a/packages/amplify_core/lib/src/amplify_class_impl.dart b/packages/amplify_core/lib/src/amplify_class_impl.dart index 59629ee377a..c7760f842e6 100644 --- a/packages/amplify_core/lib/src/amplify_class_impl.dart +++ b/packages/amplify_core/lib/src/amplify_class_impl.dart @@ -46,8 +46,6 @@ class AmplifyClassImpl extends AmplifyClass { plugin.cast(), authProviderRepo: authProviderRepo, ); - case Category.kinesis: - throw UnimplementedError(); } } } diff --git a/packages/amplify_core/lib/src/category/amplify_categories.dart b/packages/amplify_core/lib/src/category/amplify_categories.dart index b344969448d..4c6170b846e 100644 --- a/packages/amplify_core/lib/src/category/amplify_categories.dart +++ b/packages/amplify_core/lib/src/category/amplify_categories.dart @@ -50,10 +50,7 @@ enum Category { storage, /// Push Notifications - pushNotifications, - - /// Kinesis streaming (Data Streams + Firehose) - kinesis; + pushNotifications; String get name => switch (this) { Category.analytics => 'Analytics', @@ -63,7 +60,6 @@ enum Category { Category.hub => 'Hub', Category.storage => 'Storage', Category.pushNotifications => 'PushNotifications', - Category.kinesis => 'Kinesis', }; }