install 방식 변경
This commit is contained in:
parent
5e74ae06f3
commit
fd14b9fcc7
10 changed files with 223 additions and 2 deletions
8
assets/check_rev.bat
Normal file
8
assets/check_rev.bat
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
set /p REV_OLD=<git_rev.txt
|
||||||
|
git rev-list --all HEAD --all --count > git_rev.txt
|
||||||
|
set /p REV_NEW=<git_rev.txt
|
||||||
|
|
||||||
|
IF %REV_OLD%==%REV_NEW% set RESULT=TRUE
|
||||||
|
IF NOT %REV_OLD%==%REV_NEW% set RESULT=FALSE
|
||||||
|
|
||||||
|
echo %RESULT% > result.txt
|
||||||
14
assets/check_rev.sh
Normal file
14
assets/check_rev.sh
Normal file
|
|
@ -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
|
||||||
94
assets/example.yaml
Normal file
94
assets/example.yaml
Normal file
|
|
@ -0,0 +1,94 @@
|
||||||
|
---
|
||||||
|
import:
|
||||||
|
- <file:./User/name/work/pipeline.yaml> #외부 정의 파이프라인 로드
|
||||||
|
|
||||||
|
#전역 변수(<Map, dynamic>), runtime에서 할당, 수정 가능
|
||||||
|
properties:
|
||||||
|
#<property:workspace>로 접근
|
||||||
|
workspace: ${WORKSPACE}
|
||||||
|
|
||||||
|
#pipeline 사용시에는 커맨드는 무조건 command id로만 사용
|
||||||
|
pipeline:
|
||||||
|
id: main
|
||||||
|
workflow:
|
||||||
|
#동기식 실행, 해당 수행이 끝나야만 다음 스텝실행, command일경우 해당 id 기입
|
||||||
|
- exe: <command:createAppData#1>
|
||||||
|
|
||||||
|
#비동기식 실행, 해당 수행이 완료됨과 관계없이 실행하고 다음 스텝을 실행한다
|
||||||
|
- async: <command:dartCompile#1>
|
||||||
|
|
||||||
|
#외부에서 import한 문서에 선언한 pipeline의 id
|
||||||
|
- exec: <pipeline:compareFile>
|
||||||
|
|
||||||
|
#일반적인 if문과 동일
|
||||||
|
- if:
|
||||||
|
#property의 내용은 기본 dynamic(Object)형으로써, 비교시 정확한 캐스팅 필요, 적지 않을시 기본 string
|
||||||
|
condition: <property:test> == <property:result> [int]
|
||||||
|
#false도 가능, true/false로 선언시 일반적인 else와 동일
|
||||||
|
true:
|
||||||
|
- exe: <command:buildDartCompile#1>
|
||||||
|
|
||||||
|
#일반적인 while문과 동일
|
||||||
|
- while:
|
||||||
|
condition: <property:result> [bool]
|
||||||
|
do:
|
||||||
|
- async: <command:buildDart>
|
||||||
|
- exec: <command:zip#1>
|
||||||
|
#조건식이 끝날때까지 단순 대기, 비동기 실행의 완료를 잡기위함
|
||||||
|
- wait-until: <property:result> != null
|
||||||
|
- if:
|
||||||
|
#version에 대한 비교시, 자릿수는 같아야 한다 0.0.0 or 0.0.0.0
|
||||||
|
condition: <property:version> == 1.0.1 [version]
|
||||||
|
true:
|
||||||
|
#조건문 내에도 선언 가능, 반대도 가능
|
||||||
|
- while:
|
||||||
|
condition: <property:result> < 10 [int]
|
||||||
|
do:
|
||||||
|
- exec: <command:buildDart#1>
|
||||||
|
#일반적인 switch구문과 동일
|
||||||
|
- switch:
|
||||||
|
state: <property:test> [string]
|
||||||
|
case:
|
||||||
|
#case 아이템 하나에 여러 작업을 array형태로 할당
|
||||||
|
- <property:abb>:
|
||||||
|
- exec: <command:buildDartCompile#1>
|
||||||
|
- exec: <command:job#2>
|
||||||
|
- test:
|
||||||
|
- exec: <command:buildDart#1>
|
||||||
|
- default:
|
||||||
|
- exec: <command:build#1>
|
||||||
|
|
||||||
|
#pipeline에 기록된 command id가 command define list에 없다면 오류를 뱉으며 종료
|
||||||
|
commands:
|
||||||
|
- command: CreateAppData
|
||||||
|
id: createAppData#1
|
||||||
|
param:
|
||||||
|
scm: Git
|
||||||
|
relativeAssetPath: assets/data
|
||||||
|
#결과가 저장되는 command의 경우 선언
|
||||||
|
result:
|
||||||
|
#결과의 경우 무조건 설정하도록
|
||||||
|
version: <property:version>
|
||||||
|
#property[hash]에 저장
|
||||||
|
hash: <property: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: <property:workspace>/release/oto_linux_v<!common.version>.zip
|
||||||
|
zipList:
|
||||||
|
- <property:workspace>/release/oto_cli
|
||||||
|
- <property:workspace>/release/test
|
||||||
|
rersult:
|
||||||
|
success: <property:zipResult>
|
||||||
|
zipPath: <property:zipPath>
|
||||||
14
assets/jenkins_env_params.bat
Normal file
14
assets/jenkins_env_params.bat
Normal file
|
|
@ -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 }
|
||||||
17
assets/jenkins_env_params.sh
Normal file
17
assets/jenkins_env_params.sh
Normal file
|
|
@ -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"
|
||||||
BIN
assets/silentbatch.exe
Normal file
BIN
assets/silentbatch.exe
Normal file
Binary file not shown.
|
|
@ -5,7 +5,7 @@ import 'package:oto_cli/cli/cli.dart';
|
||||||
import 'package:oto_cli/cli/commands/command_template.dart';
|
import 'package:oto_cli/cli/commands/command_template.dart';
|
||||||
|
|
||||||
void main(List<String> arguments) async {
|
void main(List<String> arguments) async {
|
||||||
CLI.initialize('desktop_service', arguments, [
|
CLI.initialize('OTO', arguments, [
|
||||||
CommandTemplate(),
|
CommandTemplate(),
|
||||||
CommandInstall(),
|
CommandInstall(),
|
||||||
CommandUninstall(),
|
CommandUninstall(),
|
||||||
|
|
|
||||||
50
lib/cli/commands/command_const.dart
Normal file
50
lib/cli/commands/command_const.dart
Normal file
|
|
@ -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}';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ import 'dart:io';
|
||||||
import 'package:dart_framework/utils/os_startup.dart';
|
import 'package:dart_framework/utils/os_startup.dart';
|
||||||
import 'package:oto_cli/cli/cli.dart';
|
import 'package:oto_cli/cli/cli.dart';
|
||||||
import 'package:oto_cli/cli/commands/command_base.dart';
|
import 'package:oto_cli/cli/commands/command_base.dart';
|
||||||
|
import 'package:oto_cli/cli/commands/command_const.dart';
|
||||||
|
|
||||||
class CommandInstall extends CommandBase {
|
class CommandInstall extends CommandBase {
|
||||||
@override
|
@override
|
||||||
|
|
@ -14,7 +15,20 @@ class CommandInstall extends CommandBase {
|
||||||
var c = Completer();
|
var c = Completer();
|
||||||
var label = CLI.serviceName;
|
var label = CLI.serviceName;
|
||||||
if (!await OSStartup.isRegistedStartup(label)) {
|
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']);
|
arguments: ['start']);
|
||||||
printOut('Installed successfully.', PrintType.information);
|
printOut('Installed successfully.', PrintType.information);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -40,6 +54,15 @@ class CommandUninstall extends CommandBase {
|
||||||
var c = Completer<bool>();
|
var c = Completer<bool>();
|
||||||
var label = CLI.serviceName;
|
var label = CLI.serviceName;
|
||||||
if (await OSStartup.isRegistedStartup(label)) {
|
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);
|
await OSStartup.unregistStartup(label);
|
||||||
printOut('Uninstalled successfully.', PrintType.information);
|
printOut('Uninstalled successfully.', PrintType.information);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
1
open_url_cmd.bat
Normal file
1
open_url_cmd.bat
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
rundll32 url.dll,FileProtocolHandler https://www.google.com
|
||||||
Loading…
Reference in a new issue