buidl isolate 적용
This commit is contained in:
parent
d5d132a127
commit
219d79e2de
6 changed files with 76 additions and 26 deletions
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
|
|
@ -18,6 +18,13 @@
|
|||
"program": "./bin/main.dart",
|
||||
"args": ["install", "-h"]
|
||||
},
|
||||
{
|
||||
"name": "exe test",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"program": "./bin/main.dart",
|
||||
"args": ["exe", "-t"]
|
||||
},
|
||||
{
|
||||
"name": "exe win",
|
||||
"request": "launch",
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@ pipeline:
|
|||
workflow:
|
||||
- async: git
|
||||
|
||||
- exe: json-reader
|
||||
# - exe: json-reader
|
||||
|
||||
#동기식 실행, 해당 수행이 끝나야만 다음 스텝실행, command일경우 해당 id 기입
|
||||
- exe: appData
|
||||
# - exe: appData
|
||||
|
||||
#비동기식 실행, 해당 수행이 완료됨과 관계없이 실행하고 다음 스텝을 실행한다
|
||||
# - exe: buildDart
|
||||
|
|
@ -84,14 +84,14 @@ commands:
|
|||
to: <!property.old-git-count>
|
||||
|
||||
### Version 쓰기
|
||||
- command: CreateAppData
|
||||
id: appData
|
||||
param:
|
||||
scm: Git
|
||||
name: OTO
|
||||
relativeAssetPath: assets/data
|
||||
return-version: "<!property.version>"
|
||||
return-hash: "<!property.hash>"
|
||||
# - command: CreateAppData
|
||||
# id: appData
|
||||
# param:
|
||||
# scm: Git
|
||||
# name: OTO
|
||||
# relativeAssetPath: assets/data
|
||||
# return-version: "<!property.version>"
|
||||
# return-hash: "<!property.hash>"
|
||||
|
||||
### 실행가능한 파일로 빌드
|
||||
- command: BuildDart
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/cli/cli.dart';
|
||||
import 'package:oto_cli/cli/commands/command_template.dart';
|
||||
import 'package:oto_cli/cli/commands/command_install.dart';
|
||||
|
|
@ -5,6 +6,7 @@ import 'package:oto_cli/cli/commands/command_exe.dart';
|
|||
import 'package:oto_cli/cli/commands/command_start.dart';
|
||||
|
||||
void main(List<String> arguments) async {
|
||||
initialize();
|
||||
CLI.initialize('OTO', arguments, [
|
||||
CommandTemplate(),
|
||||
CommandInstall(),
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/cli/commands/command_base.dart';
|
||||
|
|
@ -201,8 +202,8 @@ abstract class Printer {
|
|||
var now = DateTime.now();
|
||||
var time =
|
||||
'${now.hour}${now.minute}${now.second}${now.millisecond}${now.microsecond}';
|
||||
var tempFile =
|
||||
File(path.join(Directory.systemTemp.path, 'temp_$time.$extension'));
|
||||
var tempFile = File(path.join(Directory.systemTemp.path,
|
||||
'temp_${time}_${Random().nextInt(1000)}.$extension'));
|
||||
await tempFile.writeAsString(content);
|
||||
c.complete(tempFile);
|
||||
return c.future;
|
||||
|
|
|
|||
|
|
@ -1,13 +1,20 @@
|
|||
// ignore_for_file: avoid_init_to_null
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dart_framework/charset/euc_kr.dart';
|
||||
import 'package:dart_framework/data/isolate_data.dart';
|
||||
import 'package:dart_framework/platform/isolate_manager.dart';
|
||||
import 'package:oto_cli/cli/cli.dart';
|
||||
import 'package:oto_cli/cli/commands/command_base.dart';
|
||||
import 'package:dart_framework/utils/system_util.dart';
|
||||
import 'package:oto_cli/oto/application.dart';
|
||||
|
||||
class CommandExe extends CommandBase {
|
||||
late IsolateHandler _handler;
|
||||
bool _complete = false;
|
||||
|
||||
@override
|
||||
Map<String, List<String>> get arguments => {
|
||||
'-j': ["Used when it's a Jenkins build."],
|
||||
|
|
@ -18,15 +25,17 @@ class CommandExe extends CommandBase {
|
|||
String get name => 'exe';
|
||||
|
||||
@override
|
||||
Future execute(List<String> parameters) {
|
||||
Future execute(List<String> parameters) async {
|
||||
for (var i = 0; i < parameters.length; ++i) {
|
||||
var item = parameters[i];
|
||||
if (item.startsWith('-j')) {
|
||||
Application.instance.build(BuildType.jenkins);
|
||||
_handler = IsolateManager.create(IsolateExe(BuildType.jenkins));
|
||||
await isComplete();
|
||||
break;
|
||||
}
|
||||
if (item.startsWith('-t')) {
|
||||
Application.instance.build(BuildType.test);
|
||||
_handler = IsolateManager.create(IsolateExe(BuildType.test));
|
||||
await isComplete();
|
||||
}
|
||||
if (item.startsWith('-f')) {
|
||||
var file = '';
|
||||
|
|
@ -35,24 +44,34 @@ class CommandExe extends CommandBase {
|
|||
} else {
|
||||
file = item.replaceFirst('-f', '').trimLeft();
|
||||
}
|
||||
startYaml(file);
|
||||
await startYaml(file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return simpleFuture;
|
||||
}
|
||||
|
||||
void startYaml(String target) {
|
||||
Future isComplete() async {
|
||||
_handler.addListener('complete', (data) => _complete = true);
|
||||
while (!_complete) {
|
||||
await Future.delayed(const Duration(milliseconds: 200));
|
||||
}
|
||||
}
|
||||
|
||||
Future startYaml(String target) async {
|
||||
var file = File(target);
|
||||
if (file.existsSync()) {
|
||||
Application.instance.build(BuildType.file,
|
||||
_handler = IsolateManager.create(IsolateExe(BuildType.file,
|
||||
yamlContent: file.readAsStringSync(
|
||||
encoding: Platform.isWindows ? eucKr : systemEncoding));
|
||||
encoding: Platform.isWindows ? eucKr : systemEncoding)));
|
||||
IsolateManager.create(IsolateExe(BuildType.test));
|
||||
await isComplete();
|
||||
} else {
|
||||
CLI.print([
|
||||
await CLI.print([
|
||||
CLI.style('There are no files in path "$target"', color: Color.red)
|
||||
]);
|
||||
}
|
||||
return simpleFuture;
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -60,3 +79,17 @@ class CommandExe extends CommandBase {
|
|||
return ':::: Read documents written in yaml to do process task.';
|
||||
}
|
||||
}
|
||||
|
||||
class IsolateExe extends IsolateBase {
|
||||
final BuildType _buildType;
|
||||
String? _yamleContent = null;
|
||||
IsolateExe(this._buildType, {String? yamlContent}) {
|
||||
_yamleContent = yamlContent;
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady(Object? initData) async {
|
||||
await Application.instance.build(_buildType, yamlContent: _yamleContent);
|
||||
send(IsoMessege('complete'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,17 +28,23 @@ class TestData {
|
|||
if (Platform.isMacOS) {
|
||||
yaml = '''
|
||||
---
|
||||
common:
|
||||
property:
|
||||
workspace: ${Directory.current.path}
|
||||
|
||||
pipeline:
|
||||
id: main
|
||||
workflow:
|
||||
- exe: createApp
|
||||
|
||||
commands:
|
||||
- command: CreateAppData
|
||||
id: createApp
|
||||
param:
|
||||
scm: Git
|
||||
name: OTO
|
||||
relativeAssetPath: assets/data
|
||||
returnVersion: "<!common.version>"
|
||||
returnHash: "<!common.hash>"
|
||||
return-version: "<!property.version>"
|
||||
return-hash: "<!property.hash>"
|
||||
|
||||
#- command: BuildDart
|
||||
# param:
|
||||
|
|
@ -147,17 +153,18 @@ commands:
|
|||
} else if (Platform.isWindows) {
|
||||
yaml = '''
|
||||
---
|
||||
common:
|
||||
property:
|
||||
workspace: ${Directory.current.path}
|
||||
|
||||
commands:
|
||||
- command: CreateAppData
|
||||
id: createApp
|
||||
param:
|
||||
scm: Git
|
||||
name: Build Manager
|
||||
relativeAssetPath: assets/data
|
||||
returnVersion: "<!common.version>"
|
||||
returnHash: "<!common.hash>"
|
||||
return-version: "<!property.version>"
|
||||
return-hash: "<!property.hash>"
|
||||
|
||||
#- command: BuildDart
|
||||
# param:
|
||||
|
|
|
|||
Loading…
Reference in a new issue