From cea929f38efe8d825dab5146072af7cae22ffd14 Mon Sep 17 00:00:00 2001 From: "leedongmyung[desktop]" Date: Thu, 16 Nov 2023 21:23:53 +0900 Subject: [PATCH] test --- lib/cli/cli.dart | 6 +++++- lib/oto/application.dart | 46 +++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/lib/cli/cli.dart b/lib/cli/cli.dart index 19aa7f9..9242793 100644 --- a/lib/cli/cli.dart +++ b/lib/cli/cli.dart @@ -121,13 +121,17 @@ class CLI { } static Future printBuffer(StringBuffer buffer) async { - return await print(buffer.toString().split('\n')); + return await printString(buffer.toString()); } static Future printString(String str) async { return await print(str.split('\n')); } + static Future println(String str, Color color) async { + return await printString(CLI.style(str, color: color)); + } + late CLIConfig config; late CommandManager _commandManager; diff --git a/lib/oto/application.dart b/lib/oto/application.dart index 4683936..cee669a 100644 --- a/lib/oto/application.dart +++ b/lib/oto/application.dart @@ -31,6 +31,7 @@ class Application { Map? buildMap; Map? jenkinsMap; + String buildContent = ''; // var envArgs = envArguments(arguments); // bool isTest = envArgs.containsKey('isTest'); //for Unit Test switch (buildType) { @@ -66,36 +67,24 @@ class Application { 'is not Mac/Windows/Linux. build must be execute in Mac/Windows os system'); } if (enable) { - printBuildStep('Jenkins Variables'); + await printBuildStep('Jenkins Variables'); print(jsonStr); } _jenkinsData = DataJenkins.fromJson(jenkinsMap!); - - var content = await getBuildData(); - await composeANSIPrint(content, Color.green); - buildMap = getMapFromYaml(content); + buildContent = await getBuildData(); + buildMap = getMapFromYaml(buildContent); break; case BuildType.file: _jenkinsData = DataJenkins.fromJson(FileData.jenkinsMap!); - - var content = yamlContent!; - await CLI.printString(CLI.style(content, color: Color.green)); - // await composeANSIPrint(content, Color.green); - buildMap = getMapFromYaml(content); + buildContent = yamlContent!; + buildMap = getMapFromYaml(buildContent); break; } - return; - await execute(buildMap!); - } + print(buildContent); - Future composeANSIPrint(String value, Color color) async { - var list = value.split('\n'); - for (var item in list) { - await CLI.print([CLI.style(item, color: color)]); - } - return simpleFuture; + await execute(buildMap!); } Future setKorean() async { @@ -117,23 +106,26 @@ class Application { for (var command in build.commands) { String commandStr = command.command.toString().replaceAll('CommandType.', ''); - printBuildStep('Phase Start: $commandStr'); + await printBuildStep('Phase Start: $commandStr'); if (!await Command(command.command).execute(command)) { exit(10); } } c.complete(); - printBuildStep('Build Successfully Complete'); + await printBuildStep('Build Successfully Complete'); exit(0); } - void printBuildStep(String name) { - print( - '************************************************************************************'); - print('* $name'); - print( - '************************************************************************************'); + Future printBuildStep(String name) async { + await CLI.println( + '************************************************************************************', + Color.green); + await CLI.println('* $name', Color.green); + await CLI.println( + '************************************************************************************', + Color.green); + return simpleFuture; } Future getBuildData() async {