fix(cd): make cd use new usecases
Some checks failed
continuous-integration/drone/pr Build is failing
Some checks failed
continuous-integration/drone/pr Build is failing
This commit is contained in:
parent
cca7b29a6d
commit
d69106adeb
@ -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 {
|
||||
const useCase = CheckToolsUsecase();
|
||||
|
||||
final result = await useCase(null);
|
||||
final result = await useCase();
|
||||
|
||||
result.fold((value) => print('Success'), (error) => print('Error: $error'));
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ class InitProjectTask extends TaskCubit {
|
||||
// 2. Check tools
|
||||
emit(TaskStateCheckTools());
|
||||
|
||||
final checkToolsResult = await checkToolsUsecase(null);
|
||||
final checkToolsResult = await checkToolsUsecase();
|
||||
if (checkToolsResult.isErr) {
|
||||
return emit(TaskStateError.fromRes(checkToolsResult));
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ abstract class TaskCubit extends Cubit<TaskState> {
|
||||
if (checks) {
|
||||
emit(TaskStateCheckTools());
|
||||
|
||||
final checkToolsResult = await _checkToolsUsecase(null);
|
||||
final checkToolsResult = await _checkToolsUsecase();
|
||||
if (checkToolsResult.isErr) {
|
||||
return emit(TaskStateError.fromRes(checkToolsResult));
|
||||
}
|
||||
|
@ -49,9 +49,9 @@ class Flutter {
|
||||
final FlutterBuildIpaUsecase _flutterBuildIpaUsecase;
|
||||
final FlutterBuildAppBundleUsecase _flutterBuildAppBundleUsecase;
|
||||
|
||||
FutureOrResult<void> clean() => _flutterCleanUsecase(null);
|
||||
FutureOrResult<void> getDependencies() => _flutterPubGetUsecase(null);
|
||||
FutureOrResult<void> createXcArchive() => _flutterBuildXcarchiveUsecase(null);
|
||||
FutureOrResult<void> clean() => _flutterCleanUsecase();
|
||||
FutureOrResult<void> getDependencies() => _flutterPubGetUsecase();
|
||||
FutureOrResult<void> createXcArchive() => _flutterBuildXcarchiveUsecase();
|
||||
FutureOrResult<void> buildIpa(List<String> args) =>
|
||||
_flutterBuildIpaUsecase(args);
|
||||
FutureOrResult<void> buildAppBundle(List<String> args) =>
|
||||
|
@ -19,7 +19,6 @@ import 'dart:io';
|
||||
|
||||
import 'package:wyatt_architecture/wyatt_architecture.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';
|
||||
|
||||
abstract class ProcessUsecase<T> extends AsyncUseCase<T, void> {
|
||||
@ -58,7 +57,7 @@ abstract class ProcessUsecase<T> extends AsyncUseCase<T, void> {
|
||||
}
|
||||
progress.complete(onCompletedMessage);
|
||||
logger.detail(processResult?.stdout.toString().trim());
|
||||
return const Ok(null);
|
||||
return Ok(null);
|
||||
}
|
||||
|
||||
/// Run the process with the given parameters.
|
||||
@ -81,7 +80,7 @@ abstract class ProcessNoParamsUsecase extends NoParamsAsyncUseCase<void> {
|
||||
String get onErrorMessage;
|
||||
|
||||
@override
|
||||
FutureOrResult<void> execute(void params) async {
|
||||
FutureOrResult<void> execute() async {
|
||||
final progress = logger.progress(onStartedMessage);
|
||||
final processResult = await run();
|
||||
if (processResult != null) {
|
||||
@ -94,7 +93,7 @@ abstract class ProcessNoParamsUsecase extends NoParamsAsyncUseCase<void> {
|
||||
}
|
||||
progress.complete(onCompletedMessage);
|
||||
logger.detail(processResult?.stdout.toString().trim());
|
||||
return const Ok(null);
|
||||
return Ok(null);
|
||||
}
|
||||
|
||||
/// Run the process with no parameters.
|
||||
|
@ -27,7 +27,7 @@ class CheckToolsUsecase extends NoParamsAsyncUseCase<void> {
|
||||
const CheckToolsUsecase() : super();
|
||||
|
||||
@override
|
||||
FutureOrResult<void> execute(void params) async => unsafeAsync(() async {
|
||||
FutureOrResult<void> execute() async => unsafeAsync(() async {
|
||||
final missingTools = <String>[];
|
||||
for (final tool in AppConstants.requiredTools) {
|
||||
final isInstalled = await checkToolInstalled(tool);
|
||||
|
@ -17,7 +17,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
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';
|
||||
|
||||
typedef Res<T> = Result<T, AppException>;
|
||||
@ -28,7 +27,3 @@ FutureOrResult<T> unsafeAsync<T>(FutureOr<T> Function() fn) =>
|
||||
() async => fn.call(),
|
||||
(error) => error.toException(),
|
||||
);
|
||||
|
||||
abstract class NoParamsAsyncUseCase<T> extends AsyncUseCase<void, T> {
|
||||
const NoParamsAsyncUseCase();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user