Add Wyatt Continuous Deployment as Sub package #236
| @ -0,0 +1,23 @@ | |||||||
|  | // Copyright (C) 2024 WYATT GROUP | ||||||
|  | // Please see the AUTHORS file for details. | ||||||
|  | // | ||||||
|  | // This program is free software: you can redistribute it and/or modify | ||||||
|  | // it under the terms of the GNU General Public License as published by | ||||||
|  | // the Free Software Foundation, either version 3 of the License, or | ||||||
|  | // any later version. | ||||||
|  | // | ||||||
|  | // This program is distributed in the hope that it will be useful, | ||||||
|  | // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
|  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
|  | // GNU General Public License for more details. | ||||||
|  | // | ||||||
|  | // You should have received a copy of the GNU General Public License | ||||||
|  | // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||
|  | 
 | ||||||
|  | import 'dart:io'; | ||||||
|  | 
 | ||||||
|  | import 'package:wyatt_continuous_deployment_example/main.dart'; | ||||||
|  | 
 | ||||||
|  | void main(List<String> args) { | ||||||
|  |   WyattContinuousDeploymentExample.run(args).then((_) => exit(0)); | ||||||
|  | } | ||||||
| @ -20,7 +20,7 @@ class WyattContinuousDeploymentExample { | |||||||
|   static Future<void> run(List<String> args) async { |   static Future<void> run(List<String> args) async { | ||||||
|     const useCase = CheckToolsUsecase(); |     const useCase = CheckToolsUsecase(); | ||||||
| 
 | 
 | ||||||
|     final result = await useCase(null); |     final result = await useCase(); | ||||||
| 
 | 
 | ||||||
|     result.fold((value) => print('Success'), (error) => print('Error: $error')); |     result.fold((value) => print('Success'), (error) => print('Error: $error')); | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -66,7 +66,7 @@ class InitProjectTask extends TaskCubit { | |||||||
|     // 2. Check tools |     // 2. Check tools | ||||||
|     emit(TaskStateCheckTools()); |     emit(TaskStateCheckTools()); | ||||||
| 
 | 
 | ||||||
|     final checkToolsResult = await checkToolsUsecase(null); |     final checkToolsResult = await checkToolsUsecase(); | ||||||
|     if (checkToolsResult.isErr) { |     if (checkToolsResult.isErr) { | ||||||
|       return emit(TaskStateError.fromRes(checkToolsResult)); |       return emit(TaskStateError.fromRes(checkToolsResult)); | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ abstract class TaskCubit extends Cubit<TaskState> { | |||||||
|     if (checks) { |     if (checks) { | ||||||
|       emit(TaskStateCheckTools()); |       emit(TaskStateCheckTools()); | ||||||
| 
 | 
 | ||||||
|       final checkToolsResult = await _checkToolsUsecase(null); |       final checkToolsResult = await _checkToolsUsecase(); | ||||||
|       if (checkToolsResult.isErr) { |       if (checkToolsResult.isErr) { | ||||||
|         return emit(TaskStateError.fromRes(checkToolsResult)); |         return emit(TaskStateError.fromRes(checkToolsResult)); | ||||||
|       } |       } | ||||||
|  | |||||||
| @ -49,9 +49,9 @@ class Flutter { | |||||||
|   final FlutterBuildIpaUsecase _flutterBuildIpaUsecase; |   final FlutterBuildIpaUsecase _flutterBuildIpaUsecase; | ||||||
|   final FlutterBuildAppBundleUsecase _flutterBuildAppBundleUsecase; |   final FlutterBuildAppBundleUsecase _flutterBuildAppBundleUsecase; | ||||||
| 
 | 
 | ||||||
|   FutureOrResult<void> clean() => _flutterCleanUsecase(null); |   FutureOrResult<void> clean() => _flutterCleanUsecase(); | ||||||
|   FutureOrResult<void> getDependencies() => _flutterPubGetUsecase(null); |   FutureOrResult<void> getDependencies() => _flutterPubGetUsecase(); | ||||||
|   FutureOrResult<void> createXcArchive() => _flutterBuildXcarchiveUsecase(null); |   FutureOrResult<void> createXcArchive() => _flutterBuildXcarchiveUsecase(); | ||||||
|   FutureOrResult<void> buildIpa(List<String> args) => |   FutureOrResult<void> buildIpa(List<String> args) => | ||||||
|       _flutterBuildIpaUsecase(args); |       _flutterBuildIpaUsecase(args); | ||||||
|   FutureOrResult<void> buildAppBundle(List<String> args) => |   FutureOrResult<void> buildAppBundle(List<String> args) => | ||||||
|  | |||||||
| @ -19,7 +19,6 @@ import 'dart:io'; | |||||||
| 
 | 
 | ||||||
| import 'package:wyatt_architecture/wyatt_architecture.dart'; | import 'package:wyatt_architecture/wyatt_architecture.dart'; | ||||||
| import 'package:wyatt_continuous_deployment/src/core/utils/logging.dart'; | import 'package:wyatt_continuous_deployment/src/core/utils/logging.dart'; | ||||||
| import 'package:wyatt_continuous_deployment/src/domain/usecases/usecase.dart'; |  | ||||||
| import 'package:wyatt_type_utils/wyatt_type_utils.dart'; | import 'package:wyatt_type_utils/wyatt_type_utils.dart'; | ||||||
| 
 | 
 | ||||||
| abstract class ProcessUsecase<T> extends AsyncUseCase<T, void> { | abstract class ProcessUsecase<T> extends AsyncUseCase<T, void> { | ||||||
| @ -58,7 +57,7 @@ abstract class ProcessUsecase<T> extends AsyncUseCase<T, void> { | |||||||
|     } |     } | ||||||
|     progress.complete(onCompletedMessage); |     progress.complete(onCompletedMessage); | ||||||
|     logger.detail(processResult?.stdout.toString().trim()); |     logger.detail(processResult?.stdout.toString().trim()); | ||||||
|     return const Ok(null); |     return Ok(null); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /// Run the process with the given parameters. |   /// Run the process with the given parameters. | ||||||
| @ -81,7 +80,7 @@ abstract class ProcessNoParamsUsecase extends NoParamsAsyncUseCase<void> { | |||||||
|   String get onErrorMessage; |   String get onErrorMessage; | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   FutureOrResult<void> execute(void params) async { |   FutureOrResult<void> execute() async { | ||||||
|     final progress = logger.progress(onStartedMessage); |     final progress = logger.progress(onStartedMessage); | ||||||
|     final processResult = await run(); |     final processResult = await run(); | ||||||
|     if (processResult != null) { |     if (processResult != null) { | ||||||
| @ -94,7 +93,7 @@ abstract class ProcessNoParamsUsecase extends NoParamsAsyncUseCase<void> { | |||||||
|     } |     } | ||||||
|     progress.complete(onCompletedMessage); |     progress.complete(onCompletedMessage); | ||||||
|     logger.detail(processResult?.stdout.toString().trim()); |     logger.detail(processResult?.stdout.toString().trim()); | ||||||
|     return const Ok(null); |     return Ok(null); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   /// Run the process with no parameters. |   /// Run the process with no parameters. | ||||||
|  | |||||||
| @ -27,7 +27,7 @@ class CheckToolsUsecase extends NoParamsAsyncUseCase<void> { | |||||||
|   const CheckToolsUsecase() : super(); |   const CheckToolsUsecase() : super(); | ||||||
| 
 | 
 | ||||||
|   @override |   @override | ||||||
|   FutureOrResult<void> execute(void params) async => unsafeAsync(() async { |   FutureOrResult<void> execute() async => unsafeAsync(() async { | ||||||
|         final missingTools = <String>[]; |         final missingTools = <String>[]; | ||||||
|         for (final tool in AppConstants.requiredTools) { |         for (final tool in AppConstants.requiredTools) { | ||||||
|           final isInstalled = await checkToolInstalled(tool); |           final isInstalled = await checkToolInstalled(tool); | ||||||
|  | |||||||
| @ -17,7 +17,6 @@ | |||||||
| import 'dart:async'; | import 'dart:async'; | ||||||
| 
 | 
 | ||||||
| import 'package:wyatt_architecture/wyatt_architecture.dart'; | import 'package:wyatt_architecture/wyatt_architecture.dart'; | ||||||
| import 'package:wyatt_continuous_deployment/src/core/extensions/object_extension.dart'; |  | ||||||
| import 'package:wyatt_type_utils/wyatt_type_utils.dart'; | import 'package:wyatt_type_utils/wyatt_type_utils.dart'; | ||||||
| 
 | 
 | ||||||
| typedef Res<T> = Result<T, AppException>; | typedef Res<T> = Result<T, AppException>; | ||||||
| @ -28,7 +27,3 @@ FutureOrResult<T> unsafeAsync<T>(FutureOr<T> Function() fn) => | |||||||
|       () async => fn.call(), |       () async => fn.call(), | ||||||
|       (error) => error.toException(), |       (error) => error.toException(), | ||||||
|     ); |     ); | ||||||
| 
 |  | ||||||
| abstract class NoParamsAsyncUseCase<T> extends AsyncUseCase<void, T> { |  | ||||||
|   const NoParamsAsyncUseCase(); |  | ||||||
| } |  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user