77import 'dart:convert' ;
88import 'dart:io' ;
99
10- import 'package:amplify_core/amplify_core.dart' ;
10+ import 'package:amplify_core/amplify_core.dart' show UUID ;
1111import 'package:args/args.dart' ;
1212import 'package:path/path.dart' as p;
1313
@@ -20,7 +20,7 @@ import 'package:path/path.dart' as p;
2020/// 4. Run `dart tool/deploy_gen2.dart` to deploy the backend
2121const List <AmplifyBackendGroup > infraConfig = [
2222 AmplifyBackendGroup (
23- category: Category .api ,
23+ category: 'API' ,
2424 defaultOutput: 'packages/api/amplify_api/example/lib' ,
2525 backends: [
2626 AmplifyBackend (
@@ -31,7 +31,7 @@ const List<AmplifyBackendGroup> infraConfig = [
3131 ],
3232 ),
3333 AmplifyBackendGroup (
34- category: Category .auth ,
34+ category: 'Auth' ,
3535 defaultOutput: 'packages/auth/amplify_auth_cognito/example/lib' ,
3636 sharedOutputs: [
3737 'packages/auth/amplify_auth_cognito_dart/example/lib' ,
@@ -96,7 +96,7 @@ const List<AmplifyBackendGroup> infraConfig = [
9696 ],
9797 ),
9898 AmplifyBackendGroup (
99- category: Category .storage ,
99+ category: 'Storage' ,
100100 defaultOutput: 'packages/storage/amplify_storage_s3/example/lib' ,
101101 backends: [
102102 AmplifyBackend (
@@ -112,7 +112,7 @@ const List<AmplifyBackendGroup> infraConfig = [
112112 ],
113113 ),
114114 AmplifyBackendGroup (
115- category: Category .analytics ,
115+ category: 'Analytics' ,
116116 defaultOutput: 'packages/analytics/amplify_analytics_pinpoint/example/lib' ,
117117 backends: [
118118 AmplifyBackend (
@@ -133,7 +133,7 @@ const List<AmplifyBackendGroup> infraConfig = [
133133 ],
134134 ),
135135 AmplifyBackendGroup (
136- category: Category .kinesis ,
136+ category: 'Kinesis' ,
137137 defaultOutput: 'packages/kinesis/amplify_kinesis_dart/lib' ,
138138 backends: [
139139 AmplifyBackend (
@@ -159,8 +159,7 @@ void main(List<String> arguments) async {
159159
160160 print ('🚀 Deploying Gen 2 backends!' );
161161 for (final backendGroup in infraConfig) {
162- if (categoryToDeploy != null &&
163- backendGroup.category.name != categoryToDeploy) {
162+ if (categoryToDeploy != null && backendGroup.category != categoryToDeploy) {
164163 continue ;
165164 }
166165 // TODO(equartey): Could be removed when all backends are defined.
@@ -169,7 +168,7 @@ void main(List<String> arguments) async {
169168 }
170169 var gen2Environments = < String , String > {};
171170 var gen1Environments = < String , String > {};
172- final categoryName = backendGroup.category.name ;
171+ final categoryName = backendGroup.category;
173172 final outputPath = p.join (repoRoot.path, backendGroup.defaultOutput);
174173 final amplifyOutputs = File (p.join (outputPath, 'amplify_outputs.dart' ));
175174 final amplifyConfiguration = File (
@@ -267,7 +266,7 @@ ArgResults _parseArgs(List<String> args) {
267266 'category' ,
268267 abbr: 'c' ,
269268 help: 'Specify the category to deploy.' ,
270- allowed: Category .values. map ((e) => e.name ).toList (),
269+ allowed: infraConfig. map ((e) => e.category ).toList (),
271270 defaultsTo: null ,
272271 );
273272
@@ -276,14 +275,12 @@ ArgResults _parseArgs(List<String> args) {
276275
277276/// Deploy Sandbox for a given backend backend
278277Future <String > _deployBackend (
279- Category category,
278+ String category,
280279 AmplifyBackend backend,
281280 String outputPath,
282281 bool verbose,
283282) async {
284- print (
285- '🏖️ Deploying ${category .name } ${backend .name }, this may take a while...' ,
286- );
283+ print ('🏖️ Deploying $category ${backend .name }, this may take a while...' );
287284
288285 final outputFile = File (p.join (outputPath, 'amplify_outputs.dart' ));
289286 if (outputFile.existsSync ()) {
@@ -329,7 +326,6 @@ Future<String> _deployBackend(
329326 in process.stdout
330327 .transform (utf8.decoder)
331328 .transform (const LineSplitter ())) {
332-
333329 if (! line.startsWith (' at ' ) && line.trim ().isNotEmpty) {
334330 // This line does not belong to a cdk build error
335331 postingBackendBuildError = false ;
@@ -369,22 +365,24 @@ Future<String> _deployBackend(
369365
370366 if (exitCode != 0 ) {
371367 throw Exception (
372- '❌ Error deploying ${ category . name } ${backend .identifier } sandbox' ,
368+ '❌ Error deploying $category ${backend .identifier } sandbox' ,
373369 );
374- } else if (postedDeploymentError && postedDeploymentErrorReason && postedDeploymentUpdateFailed) {
370+ } else if (postedDeploymentError &&
371+ postedDeploymentErrorReason &&
372+ postedDeploymentUpdateFailed) {
375373 throw Exception (
376- '❌ Error deploying ${ category . name } ${backend .identifier } sandbox: Update failed' ,
374+ '❌ Error deploying $category ${backend .identifier } sandbox: Update failed' ,
377375 );
378376 } else if (postedBackendBuildError) {
379377 throw Exception (
380- '❌ Error deploying ${ category . name } ${backend .identifier } sandbox - CDK build failed' ,
378+ '❌ Error deploying $category ${backend .identifier } sandbox - CDK build failed' ,
381379 );
382380 } else if (! outputFile.existsSync ()) {
383381 throw Exception (
384- '❌ Error deploying ${ category . name } ${backend .identifier } sandbox - Output file not generated' ,
382+ '❌ Error deploying $category ${backend .identifier } sandbox - Output file not generated' ,
385383 );
386384 } else {
387- print ('👍 ${ category . name } ${backend .identifier } sandbox deployed' );
385+ print ('👍 $category ${backend .identifier } sandbox deployed' );
388386 return stackID;
389387 }
390388}
@@ -461,7 +459,7 @@ void _copyConfigFile(List<String> outputPaths, List<File> configFiles) {
461459
462460/// Create a unique bucket name
463461String _createBucketName (String base ) {
464- final uniqueShort = uuid ().substring (0 , 8 );
462+ final uniqueShort = UUID . getUUID ().substring (0 , 8 );
465463 return '${base .toLowerCase ()}-gen2-integ-$uniqueShort ' ;
466464}
467465
@@ -560,14 +558,12 @@ void _uploadConfigFileToS3(String bucketName, List<File> configFiles) {
560558
561559/// Generates gen 1 amplifyconfiguration.dart file
562560void _generateGen1Config (
563- Category category,
561+ String category,
564562 AmplifyBackend backend,
565563 String outputPath,
566564 String stack,
567565) {
568- print (
569- '📁 Generating gen 1 config file for ${category .name } ${backend .name }...' ,
570- );
566+ print ('📁 Generating gen 1 config file for $category ${backend .name }...' );
571567
572568 final outputFile = File (p.join (outputPath, 'amplifyconfiguration.dart' ));
573569 if (outputFile.existsSync ()) {
@@ -594,16 +590,14 @@ void _generateGen1Config(
594590
595591 if (process.exitCode != 0 ) {
596592 throw Exception (
597- '❌ Error generating gen 1 config file for ${ category . name } ${backend .name }:: ${process .stdout }' ,
593+ '❌ Error generating gen 1 config file for $category ${backend .name }:: ${process .stdout }' ,
598594 );
599- } else if (! outputFile.existsSync ()) {
595+ } else if (! outputFile.existsSync ()) {
600596 throw Exception (
601- '❌ Error generating gen 1 config file for ${ category . name } ${backend .identifier } - Output file not generated' ,
597+ '❌ Error generating gen 1 config file for $category ${backend .identifier } - Output file not generated' ,
602598 );
603599 } else {
604- print (
605- '👍 Gen 1 config file for ${category .name } ${backend .name } generated' ,
606- );
600+ print ('👍 Gen 1 config file for $category ${backend .name } generated' );
607601 }
608602}
609603
@@ -616,7 +610,7 @@ class AmplifyBackendGroup {
616610 });
617611
618612 /// This is the category of the integration group
619- final Category category;
613+ final String category;
620614
621615 /// This is the list of backends for the group
622616 final List <AmplifyBackend > backends;
0 commit comments