yaml 파일로 읽어 실행
This commit is contained in:
parent
daa70e44f2
commit
769ccbad16
6 changed files with 110 additions and 51 deletions
9
.vscode/launch.json
vendored
9
.vscode/launch.json
vendored
|
|
@ -23,7 +23,14 @@
|
|||
"request": "launch",
|
||||
"type": "dart",
|
||||
"program": "./bin/main.dart",
|
||||
"args": ["exe", "-j", "-t"]
|
||||
"args": ["exe", "-f ./build_win.yaml"]
|
||||
},
|
||||
{
|
||||
"name": "test",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"program": "./test/test.dart",
|
||||
"args": []
|
||||
}
|
||||
]
|
||||
}
|
||||
30
build_win.yaml
Normal file
30
build_win.yaml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
---
|
||||
common:
|
||||
workspace: "."
|
||||
|
||||
commands:
|
||||
### Version 쓰기
|
||||
- command: CreateAppData
|
||||
param:
|
||||
scm: Git
|
||||
name: OTO
|
||||
relativeAssetPath: assets/data
|
||||
returnVersion: "<!common.version>"
|
||||
returnHash: "<!common.hash>"
|
||||
|
||||
### 프로젝트 패키지 업데이트
|
||||
- command: BuildDart
|
||||
param: {}
|
||||
|
||||
### 실행가능한 파일로 빌드
|
||||
- command: BuildDartCompile
|
||||
param:
|
||||
targetDartFile: "./bin/main.dart"
|
||||
buildFileName: oto_cli
|
||||
|
||||
### 최종 zip 파일 형태로 저장
|
||||
- command: Zip
|
||||
param:
|
||||
zipFile: "<!common.workspace>/release/oto_win_v<!common.version>.zip"
|
||||
zipList:
|
||||
- "<!common.workspace>/release/oto_cli.exe"
|
||||
|
|
@ -23,8 +23,8 @@ class CommandExe extends CommandBase {
|
|||
startJenkinsBuild(parameters.contains('-t'));
|
||||
break;
|
||||
}
|
||||
if (item.startsWith('-f ')) {
|
||||
startYaml(item.replaceFirst('-f ', ''));
|
||||
if (item.startsWith('-f')) {
|
||||
startYaml(item.replaceFirst('-f', '').trimLeft());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -32,15 +32,18 @@ class CommandExe extends CommandBase {
|
|||
}
|
||||
|
||||
void startJenkinsBuild(bool isTest) {
|
||||
Application.instance.build(isTest);
|
||||
Application.instance.build(isTest ? BuildType.test : BuildType.jenkins);
|
||||
}
|
||||
|
||||
void startYaml(String target) {
|
||||
var file = File(target);
|
||||
if (file.existsSync()) {
|
||||
Application.instance
|
||||
.build(BuildType.file, yamlContent: file.readAsStringSync());
|
||||
} else {
|
||||
print(
|
||||
CLI.style('There are no files in path "$target"', color: Color.red));
|
||||
CLI.print([
|
||||
CLI.style('There are no files in path "$target"', color: Color.red)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import 'package:oto_cli/oto/data/data.dart';
|
|||
import 'package:oto_cli/oto/data/jenkins_data.dart';
|
||||
import 'package:oto_cli/oto/test_data.dart';
|
||||
|
||||
enum BuildType { jenkins, test, file }
|
||||
|
||||
class Application {
|
||||
Application._privateConstructor();
|
||||
static final Application _instance = Application._privateConstructor();
|
||||
|
|
@ -21,7 +23,7 @@ class Application {
|
|||
return _jenkinsData;
|
||||
}
|
||||
|
||||
Future<void> build(bool isTest) async {
|
||||
Future<void> build(BuildType buildType, {String? yamlContent}) async {
|
||||
// await test();
|
||||
// return;
|
||||
|
||||
|
|
@ -29,49 +31,51 @@ class Application {
|
|||
Map<String, dynamic>? jenkinsMap;
|
||||
// var envArgs = envArguments(arguments);
|
||||
// bool isTest = envArgs.containsKey('isTest'); //for Unit Test
|
||||
if (isTest) {
|
||||
//Test map
|
||||
buildMap = TestData.buildMap;
|
||||
jenkinsMap = TestData.jenkinsMap!;
|
||||
print('Start test build...');
|
||||
} else {
|
||||
String os = Platform.operatingSystem;
|
||||
var enable = true;
|
||||
print('Current OS: $os');
|
||||
print('Start build...');
|
||||
String jsonStr = '';
|
||||
if (Platform.isMacOS || Platform.isLinux) {
|
||||
await Process.run('zsh', [
|
||||
'${Directory.current.path}/assets/script/shell/jenkins_env_params.sh'
|
||||
]).then((ProcessResult result) => jsonStr = result.stdout);
|
||||
jenkinsMap = getMapFromJson(jsonStr)!;
|
||||
} else if (Platform.isWindows) {
|
||||
print('Win Test!!');
|
||||
await Process.run('cmd', [
|
||||
'/C',
|
||||
'${Directory.current.path}/assets/script/batch/jenkins_env_params.bat'
|
||||
]).then((ProcessResult result) => jsonStr = result.stdout);
|
||||
jenkinsMap = getMapFromJson(jsonStr);
|
||||
} else {
|
||||
enable = false;
|
||||
print(
|
||||
'is not Mac/Windows/Linux. build must be execute in Mac/Windows os system');
|
||||
}
|
||||
if (enable) {
|
||||
printBuildStep('Jenkins Variables');
|
||||
print(jsonStr);
|
||||
}
|
||||
switch (buildType) {
|
||||
case BuildType.test:
|
||||
//Test map
|
||||
buildMap = TestData.buildMap;
|
||||
_jenkinsData = DataJenkins.fromJson(TestData.jenkinsMap!);
|
||||
print('Start test build...');
|
||||
break;
|
||||
|
||||
case BuildType.jenkins:
|
||||
String os = Platform.operatingSystem;
|
||||
var enable = true;
|
||||
print('Current OS: $os');
|
||||
print('Start build...');
|
||||
String jsonStr = '';
|
||||
if (Platform.isMacOS || Platform.isLinux) {
|
||||
await Process.run('zsh', [
|
||||
'${Directory.current.path}/assets/script/shell/jenkins_env_params.sh'
|
||||
]).then((ProcessResult result) => jsonStr = result.stdout);
|
||||
jenkinsMap = getMapFromJson(jsonStr)!;
|
||||
} else if (Platform.isWindows) {
|
||||
await Process.run('cmd', [
|
||||
'/C',
|
||||
'${Directory.current.path}/assets/script/batch/jenkins_env_params.bat'
|
||||
]).then((ProcessResult result) => jsonStr = result.stdout);
|
||||
jenkinsMap = getMapFromJson(jsonStr);
|
||||
} else {
|
||||
enable = false;
|
||||
print(
|
||||
'is not Mac/Windows/Linux. build must be execute in Mac/Windows os system');
|
||||
}
|
||||
if (enable) {
|
||||
printBuildStep('Jenkins Variables');
|
||||
print(jsonStr);
|
||||
}
|
||||
buildMap = getMapFromYaml(await getBuildData());
|
||||
_jenkinsData = DataJenkins.fromJson(jenkinsMap!);
|
||||
break;
|
||||
|
||||
case BuildType.file:
|
||||
buildMap = getMapFromYaml(yamlContent!);
|
||||
_jenkinsData = DataJenkins.fromJson(TestData.jenkinsMap!);
|
||||
break;
|
||||
}
|
||||
|
||||
if (jenkinsMap != null) {
|
||||
_jenkinsData = DataJenkins.fromJson(jenkinsMap);
|
||||
if (!isTest) {
|
||||
var buildStr = await getBuildData();
|
||||
buildMap = getMapFromYaml(buildStr);
|
||||
}
|
||||
|
||||
await execute(buildMap!);
|
||||
}
|
||||
await execute(buildMap!);
|
||||
}
|
||||
|
||||
Future<void> execute(Map<String, dynamic> buildMap) async {
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ dependencies:
|
|||
ref: master
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^2.0.0
|
||||
test: ^1.21.0
|
||||
lints: ^3.0.0
|
||||
test: ^1.24.9
|
||||
build_runner: ^2.1.4
|
||||
json_serializable: ^6.0.1
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,20 @@
|
|||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('calculate', () {});
|
||||
setUp(() async {
|
||||
print('[SetUp] Set up initalize enviroments');
|
||||
});
|
||||
group('CLI', () {
|
||||
test('calculate', () {
|
||||
expect(2 + 3, equals(5));
|
||||
});
|
||||
|
||||
test('calculate2', () {
|
||||
expect(2 + 3, equals(6));
|
||||
});
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
print('[TearDown] Post process. this doing event failed');
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue