파일 ignore 패턴 추가
This commit is contained in:
parent
88af0e5a85
commit
73000ea619
6 changed files with 93 additions and 13 deletions
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
|
|
@ -53,6 +53,13 @@
|
|||
"program": "./bin/main.dart",
|
||||
"args": ["exe", "-f", "./assets/pipeline-test2.yaml"]
|
||||
},
|
||||
{
|
||||
"name": "exe aos build",
|
||||
"request": "launch",
|
||||
"type": "dart",
|
||||
"program": "./bin/main.dart",
|
||||
"args": ["exe", "-f", "/Users/toki/works/lgup-mcs-aos/app/buildScript/build-lt.yaml"]
|
||||
},
|
||||
{
|
||||
"name": "exe slack",
|
||||
"request": "launch",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ enum CommandType {
|
|||
FileDiffCheck,
|
||||
FileRead,
|
||||
FileWrite,
|
||||
Files,
|
||||
DirectoryCreate,
|
||||
Slack,
|
||||
SlackBuild,
|
||||
|
|
@ -124,6 +125,7 @@ abstract class Command {
|
|||
CommandType.FileDiffCheck: () => FileDiffCheck(),
|
||||
CommandType.FileRead: () => FileRead(),
|
||||
CommandType.FileWrite: () => FileWrite(),
|
||||
CommandType.Files: () => Files(),
|
||||
CommandType.DirectoryCreate: () => DirectoryCreate(),
|
||||
CommandType.Slack: () => Slack(),
|
||||
CommandType.SlackBuild: () => SlackBuild(),
|
||||
|
|
@ -363,7 +365,7 @@ abstract class Command {
|
|||
|
||||
Map<String, dynamic> getParam(DataCommand command) {
|
||||
Map<String, dynamic> map;
|
||||
if(command.param == null) {
|
||||
if (command.param == null) {
|
||||
map = <String, dynamic>{};
|
||||
} else {
|
||||
map = Command.replaceAllTagsMap(command.param);
|
||||
|
|
@ -378,11 +380,9 @@ abstract class Command {
|
|||
|
||||
Future executeHandle(DataCommand command, ExeHandleData handleData) async {
|
||||
exeHandle = handleData;
|
||||
try
|
||||
{
|
||||
try {
|
||||
return await execute(command);
|
||||
}
|
||||
on Exception {
|
||||
} on Exception {
|
||||
return await exeHandle!.pipelineFail!.execute();
|
||||
}
|
||||
}
|
||||
|
|
@ -434,8 +434,7 @@ abstract class Command {
|
|||
await setProperty(data.setResult!, resultMessage);
|
||||
}
|
||||
}
|
||||
if(exeHandle == null)
|
||||
{
|
||||
if (exeHandle == null) {
|
||||
if (passExitCodesMerge.contains(exitCode)) {
|
||||
return simpleFuture;
|
||||
} else {
|
||||
|
|
@ -445,9 +444,7 @@ abstract class Command {
|
|||
data.message = errorMessage;
|
||||
throw Exception(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if (passExitCodesMerge.contains(exitCode)) {
|
||||
return await exeHandle!.pipelineSuccess!.execute();
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class FileRead extends Command {
|
|||
var data = DataFileRead.fromJson(getParam(command));
|
||||
var file = File(data.path);
|
||||
var content = '';
|
||||
if(file.existsSync()) {
|
||||
if (file.existsSync()) {
|
||||
content = file.readAsStringSync();
|
||||
} else {
|
||||
throw Exception('File not exist - ${data.path}');
|
||||
|
|
@ -26,9 +26,44 @@ class FileWrite extends Command {
|
|||
Future execute(DataCommand command) async {
|
||||
var data = DataFileWrite.fromJson(getParam(command));
|
||||
var file = File(data.path);
|
||||
if(file.existsSync()) file.deleteSync();
|
||||
if (file.existsSync()) file.deleteSync();
|
||||
|
||||
await file.writeAsString(data.content);
|
||||
return complete(0, command);
|
||||
}
|
||||
}
|
||||
|
||||
class Files extends Command {
|
||||
@override
|
||||
Future execute(DataCommand command) async {
|
||||
var data = DataFiles.fromJson(getParam(command));
|
||||
var target = Directory(data.path);
|
||||
var list = <String>[];
|
||||
var recursive = data.recursive ?? false;
|
||||
var regExs = data.ignoreRegExs ?? [];
|
||||
|
||||
if (target.existsSync()) {
|
||||
var files = target.listSync(recursive: recursive);
|
||||
for (var file in files) {
|
||||
var path = file.path;
|
||||
var matched = false;
|
||||
for (var regEx in regExs) {
|
||||
var pattern = RegExp(regEx);
|
||||
if (pattern.hasMatch(path)) {
|
||||
matched = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!matched) {
|
||||
if (FileSystemEntity.typeSync(path) == FileSystemEntityType.file) {
|
||||
list.add(path);
|
||||
print('====================$path');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await setProperty(data.setFiles, list);
|
||||
return complete(0, command);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,6 +434,22 @@ class DataFileWrite extends DataParam {
|
|||
Map<String, dynamic> toJson() => _$DataFileWriteToJson(this);
|
||||
}
|
||||
|
||||
//Files
|
||||
@JsonSerializable()
|
||||
class DataFiles extends DataParam {
|
||||
DataFiles();
|
||||
|
||||
late String path;
|
||||
late bool? recursive = false;
|
||||
late List<String>? ignoreRegExs = [];
|
||||
late String setFiles;
|
||||
|
||||
factory DataFiles.fromJson(Map<String, dynamic> json) =>
|
||||
_$DataFilesFromJson(json);
|
||||
@override
|
||||
Map<String, dynamic> toJson() => _$DataFilesToJson(this);
|
||||
}
|
||||
|
||||
//Directory Create
|
||||
@JsonSerializable()
|
||||
class DataDirectoryCreate extends DataParam {
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ const _$CommandTypeEnumMap = {
|
|||
CommandType.FileDiffCheck: 'FileDiffCheck',
|
||||
CommandType.FileRead: 'FileRead',
|
||||
CommandType.FileWrite: 'FileWrite',
|
||||
CommandType.Files: 'Files',
|
||||
CommandType.DirectoryCreate: 'DirectoryCreate',
|
||||
CommandType.Slack: 'Slack',
|
||||
CommandType.SlackBuild: 'SlackBuild',
|
||||
|
|
@ -708,6 +709,30 @@ Map<String, dynamic> _$DataFileWriteToJson(DataFileWrite instance) =>
|
|||
'content': instance.content,
|
||||
};
|
||||
|
||||
DataFiles _$DataFilesFromJson(Map<String, dynamic> json) => DataFiles()
|
||||
..workspace = json['workspace'] as String?
|
||||
..passExitCodes = (json['passExitCodes'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList()
|
||||
..setResult = json['setResult'] as String?
|
||||
..setExitCode = json['setExitCode'] as String?
|
||||
..path = json['path'] as String
|
||||
..recursive = json['recursive'] as bool?
|
||||
..ignoreRegExs =
|
||||
(json['ignoreRegExs'] as List<dynamic>?)?.map((e) => e as String).toList()
|
||||
..setFiles = json['setFiles'] as String;
|
||||
|
||||
Map<String, dynamic> _$DataFilesToJson(DataFiles instance) => <String, dynamic>{
|
||||
'workspace': instance.workspace,
|
||||
'passExitCodes': instance.passExitCodes,
|
||||
'setResult': instance.setResult,
|
||||
'setExitCode': instance.setExitCode,
|
||||
'path': instance.path,
|
||||
'recursive': instance.recursive,
|
||||
'ignoreRegExs': instance.ignoreRegExs,
|
||||
'setFiles': instance.setFiles,
|
||||
};
|
||||
|
||||
DataDirectoryCreate _$DataDirectoryCreateFromJson(Map<String, dynamic> json) =>
|
||||
DataDirectoryCreate()
|
||||
..workspace = json['workspace'] as String?
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ dependencies:
|
|||
file_hasher: ^0.1.0+0
|
||||
|
||||
dev_dependencies:
|
||||
lints: ^4.0.0
|
||||
lints: ^5.0.0
|
||||
test: ^1.24.9
|
||||
build_runner: ^2.1.4
|
||||
json_serializable: ^6.0.1
|
||||
|
|
|
|||
Loading…
Reference in a new issue