diff --git a/assets/pipeline-test2.yaml b/assets/pipeline-test2.yaml index 16bd843..50aa5c6 100644 --- a/assets/pipeline-test2.yaml +++ b/assets/pipeline-test2.yaml @@ -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: + setValue: <@property.osValue> + on-do: + - if: + condition-string: == aos + on-true: + - exe: set-aos + on-false: + - exe: set-ios + - exe: print + - foreach: + iterator: + 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: + +### Set ios +- command: SetValue + id: set-ios + param: + values-string: + repository: C:/works/dart_framework + values-object: + configs: + +### Test print +- command: Print + id: print + param: + message: Repository - + +### Test print +- command: Print + id: print-config + param: + message: Config - + ### Strings Read - command: FileRead id: read param: showPrint: false - path: /assets/config.xml + path: setContent: <@property.content> ### Replace @@ -40,7 +93,7 @@ commands: - command: GitBranch id: branch param: - path: /Users/toki/works/lgup-mcs-aos + path: startDay: 60 setBranches: <@property.value> @@ -57,5 +110,5 @@ commands: - command: FileWrite id: write param: - path: /assets/config.xml + path: content: \ No newline at end of file diff --git a/lib/oto/commands/command.dart b/lib/oto/commands/command.dart index 0d113b4..ca3288d 100644 --- a/lib/oto/commands/command.dart +++ b/lib/oto/commands/command.dart @@ -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.', ''); diff --git a/lib/oto/commands/util/set_value.dart b/lib/oto/commands/util/set_value.dart index 13481ac..633b685 100644 --- a/lib/oto/commands/util/set_value.dart +++ b/lib/oto/commands/util/set_value.dart @@ -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>'; } } diff --git a/lib/oto/data/command_data.dart b/lib/oto/data/command_data.dart index 297f3a6..26ad931 100644 --- a/lib/oto/data/command_data.dart +++ b/lib/oto/data/command_data.dart @@ -110,6 +110,8 @@ class DataSetValue extends DataParam { late Map? values_string; @JsonKey(name: 'values-bool') late Map? values_bool; + @JsonKey(name: 'values-object') + late Map? values_object; factory DataSetValue.fromJson(Map json) => _$DataSetValueFromJson(json); diff --git a/lib/oto/data/command_data.g.dart b/lib/oto/data/command_data.g.dart index 9b9fd9a..d7411e9 100644 --- a/lib/oto/data/command_data.g.dart +++ b/lib/oto/data/command_data.g.dart @@ -196,7 +196,8 @@ DataSetValue _$DataSetValueFromJson(Map json) => DataSetValue() ..values_int = json['values-int'] as Map? ..values_float = json['values-float'] as Map? ..values_string = json['values-string'] as Map? - ..values_bool = json['values-bool'] as Map?; + ..values_bool = json['values-bool'] as Map? + ..values_object = json['values-object'] as Map?; Map _$DataSetValueToJson(DataSetValue instance) => { @@ -209,6 +210,7 @@ Map _$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 json) =>