Skip to content

Commit bedfff6

Browse files
committed
feat(bot): support package as a 'bot' type
Signed-off-by: JobaDiniz <[email protected]>
1 parent aa02abf commit bedfff6

File tree

4 files changed

+42
-1
lines changed

4 files changed

+42
-1
lines changed

src/Joba.IBM.RPA.Cli/Joba.IBM.RPA.Cli.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<ItemGroup>
2828
<None Remove="Templates\attended.wal" />
2929
<None Remove="Templates\excel.wal" />
30+
<None Remove="Templates\package.wal" />
3031
<None Remove="Templates\unattended.wal" />
3132
</ItemGroup>
3233

@@ -36,6 +37,7 @@
3637
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
3738
</EmbeddedResource>
3839
<EmbeddedResource Include="Templates\excel.wal" />
40+
<EmbeddedResource Include="Templates\package.wal" />
3941
<EmbeddedResource Include="Templates\unattended.wal" />
4042
</ItemGroup>
4143

src/Joba.IBM.RPA.Cli/Robot/RobotCommand.New.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public NewBotCommand() : base(CommandName, "Scaffolds wal files based on the tem
1313
{
1414
var name = new Argument<string>("name", description: "The bot name.");
1515
var template = new Option<string>("--template", () => "unattended", "The template to use. Depending on the template, different configurations are allowed.")
16-
.FromAmong("attended", "chatbot", "unattended", "excel");
16+
.FromAmong("attended", "chatbot", "unattended", "package", "excel");
1717

1818
AddArgument(name);
1919
AddOption(template);
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
�defVar --name methodName --type String --parameter
2+
defVar --name methodNames --type List --innertype String --parameter
3+
defVar --name workingDirectory --type String
4+
//************************************
5+
//Template for packages
6+
//- Create routines and this template exposes them as methods.
7+
//- To understand how to create packages using this template, read https://ibm.github.io/ibm-rpa-cli/#/guide/creating-packages
8+
//************************************
9+
//Set the working directory where all local .wal files are located. Always use 'workingDirectory' variable in the 'executeScript' to reference the scripts.
10+
//- The build process will ignore 'executeScripts' that do not reference local .wal files using 'workingDirectory'.
11+
//- DO NOT publish or use published scripts in the 'executeScript'. The build process will buil ONE script with all the local referenced dependencies.
12+
//- Also, this will ensure your dev team only has to change one variable (workingDirectory) to run the project.
13+
//- If you call an 'executeScript', always pass the 'workingDirectory' variable as a parameter, so you do not need to set in every script.
14+
//- To store the source code .wal files, use GIT. Do not use the Control Center to store the .wal files.
15+
setVarIf --variablename "${workingDirectory}" --value "@{workingDirectory}" --left "${workingDirectory}" --operator "Is_Null_Or_Empty" --comment "The build process will inject the correct value for \'workingDirectory\' at runtime."
16+
#region validating
17+
case --switches "CaseSwitchesAll"
18+
when --left "${methodName}" --operator "Is_Null_Or_Empty"
19+
when --left "${methodNames}" --operator "Is_Empty"
20+
then
21+
failTest --message "The parameter \'methodName\' or \'methodNames\' is required and was not specified"
22+
endCase
23+
#endregion
24+
25+
if --left "${methodName}" --operator "Is_Null_Or_Empty" --negate
26+
add --collection "${methodNames}" --value "${methodName}"
27+
endIf
28+
foreach --collection "${methodNames}" --variable "${methodName}" --distinct
29+
assert --message "The method \'${methodName}\' is not defined in ${rpa:scriptName} version ${rpa:scriptVersion}" --left "${rpa:scriptMetadata.Routines}" --operator "Contains" --right "${methodName}"
30+
goSub --label "${methodName}"
31+
endFor*23.0.7.0

src/Joba.IBM.RPA/Project/Robots.cs

+8
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public static RobotSettings Create(string type, string description)
3939
{
4040
return type switch
4141
{
42+
PackageSettings.TypeName => new PackageSettings { Description = description },
4243
ChatbotSettings.TypeName => new ChatbotSettings { Description = description },
4344
AttendedSettings.TypeName => new AttendedSettings { Description = description },
4445
UnattendedSettings.TypeName => new UnattendedSettings { Description = description },
@@ -73,6 +74,7 @@ public override bool Equals([NotNullWhen(true)] object? obj)
7374
}
7475

7576
[JsonPolymorphic(TypeDiscriminatorPropertyName = "type")]
77+
[JsonDerivedType(typeof(PackageSettings), typeDiscriminator: PackageSettings.TypeName)]
7678
[JsonDerivedType(typeof(ChatbotSettings), typeDiscriminator: ChatbotSettings.TypeName)]
7779
[JsonDerivedType(typeof(UnattendedSettings), typeDiscriminator: UnattendedSettings.TypeName)]
7880
[JsonDerivedType(typeof(AttendedSettings), typeDiscriminator: AttendedSettings.TypeName)]
@@ -108,4 +110,10 @@ internal class AttendedSettings : RobotSettings
108110
internal const string TypeName = "attended";
109111
internal AttendedSettings() : base() { }
110112
}
113+
114+
internal class PackageSettings : RobotSettings
115+
{
116+
internal const string TypeName = "package";
117+
internal PackageSettings() : base() { }
118+
}
111119
}

0 commit comments

Comments
 (0)