set-value add object type

This commit is contained in:
leedongmyung 2025-08-22 11:47:11 +09:00
parent dee87b8e94
commit 9f25377514
5 changed files with 103 additions and 69 deletions

View file

@ -1,28 +1,81 @@
---
property:
workspace: .
value:
- test1
- test2
- test3
- test4
os:
- aos
- ios
configAOS:
- C:/Jenkins/jobs/mcs-aos
- C:/Jenkins/jobs/mcs-aos-lt
configiOS:
- C:/Jenkins/jobs/mcs-ios
- C:/Jenkins/jobs/mcs-ios-lt
pipeline:
id: main
workflow:
- exe: read
- exe: branch
- exe: param-modify
- exe: write
- foreach:
iterator: <!property.os>
setValue: <@property.osValue>
on-do:
- if:
condition-string: <!property.osValue> == aos
on-true:
- exe: set-aos
on-false:
- exe: set-ios
- exe: print
- foreach:
iterator: <!property.configs>
setValue: <@property.configValue>
on-do:
- exe: print-config
- exe: read
- exe: branch
- exe: param-modify
# - exe: write
commands:
### Set aos
- command: SetValue
id: set-aos
param:
values-string:
repository: C:/works/oto_cli
values-object:
configs: <!property.configAOS>
### Set ios
- command: SetValue
id: set-ios
param:
values-string:
repository: C:/works/dart_framework
values-object:
configs: <!property.configiOS>
### Test print
- command: Print
id: print
param:
message: Repository - <!property.repository>
### Test print
- command: Print
id: print-config
param:
message: Config - <!property.configValue>
### Strings Read
- command: FileRead
id: read
param:
showPrint: false
path: <!property.workspace>/assets/config.xml
path: <!property.configValue>
setContent: <@property.content>
### Replace
@ -40,7 +93,7 @@ commands:
- command: GitBranch
id: branch
param:
path: /Users/toki/works/lgup-mcs-aos
path: <!property.repository>
startDay: 60
setBranches: <@property.value>
@ -57,5 +110,5 @@ commands:
- command: FileWrite
id: write
param:
path: <!property.workspace>/assets/config.xml
path: <!property.configValue>
content: <!property.content>

View file

@ -267,6 +267,9 @@ abstract class Command {
static Future setPropertyValue(String tag, dynamic value,
{bool? showPrint}) async {
var match = regSetEx.firstMatch(tag);
if (match == null) {
throw Exception('Please put the correct value. (ex: <@property.value>)');
}
tag = match!.group(2)!;
if (tag.startsWith('property')) {
var key = tag.replaceFirst('property.', '');

View file

@ -8,28 +8,19 @@ class SetValueCommand extends Command {
Future execute(DataCommand command) async {
var data = DataSetValue.fromJson(getParam(command));
if(data.values_bool != null)
{
for(var pair in data.values_bool!.entries)
{
if (data.values_bool != null) {
for (var pair in data.values_bool!.entries) {
bool value = false;
if(pair.value is bool)
{
if (pair.value is bool) {
value = pair.value;
}
else if(pair.value is String)
{
} else if (pair.value is String) {
var resultTag = replaceSingleTag(pair.value);
if(resultTag is String)
{
if (resultTag is String) {
var toLow = resultTag.toLowerCase();
if(toLow == 'true' || toLow == 'false')
{
if (toLow == 'true' || toLow == 'false') {
value = toLow == 'true';
}
}
else if(resultTag is bool)
{
} else if (resultTag is bool) {
value = resultTag;
}
}
@ -37,28 +28,18 @@ class SetValueCommand extends Command {
}
}
if(data.values_float != null)
{
for(var pair in data.values_float!.entries)
{
if (data.values_float != null) {
for (var pair in data.values_float!.entries) {
double value = 0;
if(pair.value is double)
{
if (pair.value is double) {
value = pair.value;
}
else if(pair.value is String)
{
} else if (pair.value is String) {
var resultTag = replaceSingleTag(pair.value);
if(resultTag is String)
{
if (resultTag is String) {
value = double.parse(resultTag);
}
else if(resultTag is double)
{
} else if (resultTag is double) {
value = resultTag;
}
else if(resultTag is int)
{
} else if (resultTag is int) {
value = resultTag + 0.0;
}
}
@ -66,28 +47,18 @@ class SetValueCommand extends Command {
}
}
if(data.values_int != null)
{
for(var pair in data.values_int!.entries)
{
if (data.values_int != null) {
for (var pair in data.values_int!.entries) {
var value = 0;
if(pair.value is int)
{
if (pair.value is int) {
value = pair.value;
}
else if(pair.value is String)
{
} else if (pair.value is String) {
var resultTag = replaceSingleTag(pair.value);
if(resultTag is String)
{
if (resultTag is String) {
value = int.parse(resultTag);
}
else if(resultTag is int)
{
} else if (resultTag is int) {
value = resultTag;
}
else if(resultTag is double)
{
} else if (resultTag is double) {
value = resultTag.round();
}
}
@ -95,10 +66,14 @@ class SetValueCommand extends Command {
}
}
if(data.values_string != null)
{
for(var pair in data.values_string!.entries)
{
if (data.values_string != null) {
for (var pair in data.values_string!.entries) {
await setProperty(getTag(pair.key), pair.value);
}
}
if (data.values_object != null) {
for (var pair in data.values_object!.entries) {
await setProperty(getTag(pair.key), pair.value);
}
}
@ -106,8 +81,7 @@ class SetValueCommand extends Command {
return complete(0, command);
}
String getTag(String key)
{
String getTag(String key) {
return '<@property.$key>';
}
}

View file

@ -110,6 +110,8 @@ class DataSetValue extends DataParam {
late Map<String, dynamic>? values_string;
@JsonKey(name: 'values-bool')
late Map<String, dynamic>? values_bool;
@JsonKey(name: 'values-object')
late Map<String, dynamic>? values_object;
factory DataSetValue.fromJson(Map<String, dynamic> json) =>
_$DataSetValueFromJson(json);

View file

@ -196,7 +196,8 @@ DataSetValue _$DataSetValueFromJson(Map<String, dynamic> json) => DataSetValue()
..values_int = json['values-int'] as Map<String, dynamic>?
..values_float = json['values-float'] as Map<String, dynamic>?
..values_string = json['values-string'] as Map<String, dynamic>?
..values_bool = json['values-bool'] as Map<String, dynamic>?;
..values_bool = json['values-bool'] as Map<String, dynamic>?
..values_object = json['values-object'] as Map<String, dynamic>?;
Map<String, dynamic> _$DataSetValueToJson(DataSetValue instance) =>
<String, dynamic>{
@ -209,6 +210,7 @@ Map<String, dynamic> _$DataSetValueToJson(DataSetValue instance) =>
'values-float': instance.values_float,
'values-string': instance.values_string,
'values-bool': instance.values_bool,
'values-object': instance.values_object,
};
DataAppDataCreator _$DataAppDataCreatorFromJson(Map<String, dynamic> json) =>