diff --git a/assets/check_rev.bat b/assets/check_rev.bat new file mode 100644 index 0000000..2abb33b --- /dev/null +++ b/assets/check_rev.bat @@ -0,0 +1,8 @@ +set /p REV_OLD= git_rev.txt +set /p REV_NEW= result.txt \ No newline at end of file diff --git a/assets/check_rev.sh b/assets/check_rev.sh new file mode 100644 index 0000000..72698d1 --- /dev/null +++ b/assets/check_rev.sh @@ -0,0 +1,14 @@ +#!/bin/zsh +REV_OLD=`cat git_rev.txt` +git rev-list --all HEAD --all --count > git_rev.txt +REV_NEW=`cat git_rev.txt` + +echo "$REV_OLD" +echo "$REV_NEW" + +RESULT=FALSE +if [ ${REV_OLD} -ne ${REV_NEW} ] ; then + RESULT=TRUE +fi + +echo $RESULT > result.txt \ No newline at end of file diff --git a/assets/example.yaml b/assets/example.yaml new file mode 100644 index 0000000..0d3c218 --- /dev/null +++ b/assets/example.yaml @@ -0,0 +1,94 @@ +--- +import: + - #외부 정의 파이프라인 로드 + +#전역 변수(), runtime에서 할당, 수정 가능 +properties: + #로 접근 + workspace: ${WORKSPACE} + +#pipeline 사용시에는 커맨드는 무조건 command id로만 사용 +pipeline: + id: main + workflow: + #동기식 실행, 해당 수행이 끝나야만 다음 스텝실행, command일경우 해당 id 기입 + - exe: + + #비동기식 실행, 해당 수행이 완료됨과 관계없이 실행하고 다음 스텝을 실행한다 + - async: + + #외부에서 import한 문서에 선언한 pipeline의 id + - exec: + + #일반적인 if문과 동일 + - if: + #property의 내용은 기본 dynamic(Object)형으로써, 비교시 정확한 캐스팅 필요, 적지 않을시 기본 string + condition: == [int] + #false도 가능, true/false로 선언시 일반적인 else와 동일 + true: + - exe: + + #일반적인 while문과 동일 + - while: + condition: [bool] + do: + - async: + - exec: + #조건식이 끝날때까지 단순 대기, 비동기 실행의 완료를 잡기위함 + - wait-until: != null + - if: + #version에 대한 비교시, 자릿수는 같아야 한다 0.0.0 or 0.0.0.0 + condition: == 1.0.1 [version] + true: + #조건문 내에도 선언 가능, 반대도 가능 + - while: + condition: < 10 [int] + do: + - exec: + #일반적인 switch구문과 동일 + - switch: + state: [string] + case: + #case 아이템 하나에 여러 작업을 array형태로 할당 + - : + - exec: + - exec: + - test: + - exec: + - default: + - exec: + +#pipeline에 기록된 command id가 command define list에 없다면 오류를 뱉으며 종료 +commands: +- command: CreateAppData + id: createAppData#1 + param: + scm: Git + relativeAssetPath: assets/data + #결과가 저장되는 command의 경우 선언 + result: + #결과의 경우 무조건 설정하도록 + version: + #property[hash]에 저장 + hash: + +- command: BuildDart + id: buildDart#1 + param: {} + +- command: BuildDartCompile + id: buildDartCompile#1 + param: + targetDartFile: ./bin/oto_cli.dart + buildFileName: oto_cli + +- command: Zip + id: zip#1 + param: + zipFile: /release/oto_linux_v.zip + zipList: + - /release/oto_cli + - /release/test + rersult: + success: + zipPath: diff --git a/assets/jenkins_env_params.bat b/assets/jenkins_env_params.bat new file mode 100644 index 0000000..1d340eb --- /dev/null +++ b/assets/jenkins_env_params.bat @@ -0,0 +1,14 @@ +@echo { +@echo "workspace":"%WORKSPACE%", +@echo "jenkinsHome":"%JENKINS_HOME%", +@echo "jenkinsUrl":"%JENKINS_URL%", +@echo "buildUrl":"%BUILD_URL%", +@echo "jobUrl":"%JOB_URL%", +@echo "jobName":"%JOB_NAME%", +@echo "gitCommit":"%GIT_COMMIT%", +@echo "buildNumber":%BUILD_NUMBER%, +@echo "buildID":%BUILD_ID%, +@echo "buildDisplayName":"%BUILD_DISPLAY_NAME%", +@echo "gitBranch":"%GIT_BRANCH%", +@echo "buildTag":"%BUILD_TAG%" +@echo } \ No newline at end of file diff --git a/assets/jenkins_env_params.sh b/assets/jenkins_env_params.sh new file mode 100644 index 0000000..9f636f9 --- /dev/null +++ b/assets/jenkins_env_params.sh @@ -0,0 +1,17 @@ +# shellcheck disable=SC2016 +echo -e ' +{ + "workspace":"'${WORKSPACE}'", + "jenkinsHome":"'${JENKINS_HOME}'", + "jenkinsUrl":"'${JENKINS_URL}'", + "buildUrl":"'${BUILD_URL}'", + "jobUrl":"'${JOB_URL}'", + "jobName":"'${JOB_NAME}'", + "gitCommit":"'${GIT_COMMIT}'", + "buildNumber":'${BUILD_NUMBER}', + "buildID":'${BUILD_ID}', + "buildDisplayName":"'${BUILD_DISPLAY_NAME}'", + "gitBranch":"'${GIT_BRANCH}'", + "buildTag":"'${BUILD_TAG}'" +}' +echo ${BuildData} > "${WORKSPACE}/build_data.conf" \ No newline at end of file diff --git a/assets/silentbatch.exe b/assets/silentbatch.exe new file mode 100644 index 0000000..93428ef Binary files /dev/null and b/assets/silentbatch.exe differ diff --git a/bin/oto_cli.dart b/bin/oto_cli.dart index 944f804..a9b7350 100644 --- a/bin/oto_cli.dart +++ b/bin/oto_cli.dart @@ -5,7 +5,7 @@ import 'package:oto_cli/cli/cli.dart'; import 'package:oto_cli/cli/commands/command_template.dart'; void main(List arguments) async { - CLI.initialize('desktop_service', arguments, [ + CLI.initialize('OTO', arguments, [ CommandTemplate(), CommandInstall(), CommandUninstall(), diff --git a/lib/cli/commands/command_const.dart b/lib/cli/commands/command_const.dart new file mode 100644 index 0000000..ddf2738 --- /dev/null +++ b/lib/cli/commands/command_const.dart @@ -0,0 +1,50 @@ +import 'dart:io'; + +import 'package:oto_cli/cli/cli.dart'; + +class CommandConstant { + static _CommandConstantBase? _instance; + // ignore: library_private_types_in_public_api + static _CommandConstantBase? get OS { + if (_instance == null) { + if (Platform.isMacOS) { + _instance = _CommandConstantOSX(); + } else if (Platform.isLinux) { + _instance = _CommandConstantLinux(); + } else { + _instance = _CommandConstantWindows(); + } + } + return _instance; + } +} + +class _CommandConstantBase { + String get installPath { + return ''; + } +} + +class _CommandConstantOSX extends _CommandConstantBase { + @override + String get installPath { + return ''; + } +} + +class _CommandConstantLinux extends _CommandConstantBase { + @override + String get installPath { + return ''; + } +} + +class _CommandConstantWindows extends _CommandConstantBase { + final windowRoamingPath = '\\AppData\\Roaming\\'; + + @override + String get installPath { + var userPath = Platform.environment['UserProfile']; + return '$userPath$windowRoamingPath${CLI.serviceName}'; + } +} diff --git a/lib/cli/commands/command_install.dart b/lib/cli/commands/command_install.dart index 6367e16..6831bbb 100644 --- a/lib/cli/commands/command_install.dart +++ b/lib/cli/commands/command_install.dart @@ -4,6 +4,7 @@ import 'dart:io'; import 'package:dart_framework/utils/os_startup.dart'; import 'package:oto_cli/cli/cli.dart'; import 'package:oto_cli/cli/commands/command_base.dart'; +import 'package:oto_cli/cli/commands/command_const.dart'; class CommandInstall extends CommandBase { @override @@ -14,7 +15,20 @@ class CommandInstall extends CommandBase { var c = Completer(); var label = CLI.serviceName; if (!await OSStartup.isRegistedStartup(label)) { - await OSStartup.registStartup(Platform.resolvedExecutable, label, + var installPath = CommandConstant.OS!.installPath; + //Create install folder + var installDir = Directory(installPath); + if (!installDir.existsSync()) { + await installDir.create(recursive: true); + } + + //Copy executable file + var target = File(Platform.resolvedExecutable); + var installFilePath = '$installPath\\$label.exe'; + await target.copy(installFilePath); + + //Create startup + await OSStartup.registStartup(installFilePath, label, arguments: ['start']); printOut('Installed successfully.', PrintType.information); } else { @@ -40,6 +54,15 @@ class CommandUninstall extends CommandBase { var c = Completer(); var label = CLI.serviceName; if (await OSStartup.isRegistedStartup(label)) { + //To-do: Proccess kill + + //Remove Installed file + var installDir = Directory(CommandConstant.OS!.installPath); + if (installDir.existsSync()) { + await installDir.delete(recursive: true); + } + + //Remove startup await OSStartup.unregistStartup(label); printOut('Uninstalled successfully.', PrintType.information); } else { diff --git a/open_url_cmd.bat b/open_url_cmd.bat new file mode 100644 index 0000000..85f0718 --- /dev/null +++ b/open_url_cmd.bat @@ -0,0 +1 @@ +rundll32 url.dll,FileProtocolHandler https://www.google.com \ No newline at end of file