Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stepwise console template for easy start #135

Merged
merged 2 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,32 @@ StepWise is a .NET framework which assists you to code, visualize and execute ev
- **Event-Driven**: Execute steps in parallel and resolve dependencies automatically.
- **AI-Powered**: Work with `Geeno`, a built-in AI assistant in StepWise WebUI to help you run and analyze workflows with ease.

## Table of Contents
- [Quick Start with Template](#quick-start-with-template)
- [Quick Start](#quick-start)
- [Visualize stepwise workflow](#visualize-stepwise-workflow)
- [Examples](#examples)
- [Dependency Management between Steps](#dependency-management-between-steps)


## Quick Start with Template
StepWise provides a list of templates to help you get started quickly. To install the template, run the following command:

```bash
dotnet new -i LittleLittleCloud.StepWise.Template
```

This will install the following templates:
- stepwise-console: A console application template with StepWise.

To create a new project using the template, run the following command. This will create a new console application project with StepWise WebUI configured.

```bash
dotnet new stepwise-console
```

After creating the project, you can run the project and visit `http://localhost:5123` to see the StepWise WebUI.

## Quick Start

Here's a simple example of how to define a workflow to prepare dinner. The workflow consists of several steps, such as chopping vegetables, boiling water, cooking pasta, and cooking sauce. The final step is to serve dinner, which depends on all the previous steps. When executed, the workflow will automatically resolve the dependencies between steps and execute them in the parallel if possible.
Expand Down
9 changes: 9 additions & 0 deletions StepWise.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StepWise", "src\StepWise\St
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StepWise.Gallery.Web", "example\StepWIse.Gallery.Web\StepWise.Gallery.Web.csproj", "{218B897C-F0F6-4B8F-A3F4-2289B6B5415F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "template", "template", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StepWise.Template", "template\StepWise.Template.csproj", "{E2D7CB90-C283-9851-BC17-380194A3AEA5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -83,6 +87,10 @@ Global
{218B897C-F0F6-4B8F-A3F4-2289B6B5415F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{218B897C-F0F6-4B8F-A3F4-2289B6B5415F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{218B897C-F0F6-4B8F-A3F4-2289B6B5415F}.Release|Any CPU.Build.0 = Release|Any CPU
{E2D7CB90-C283-9851-BC17-380194A3AEA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E2D7CB90-C283-9851-BC17-380194A3AEA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E2D7CB90-C283-9851-BC17-380194A3AEA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E2D7CB90-C283-9851-BC17-380194A3AEA5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -98,6 +106,7 @@ Global
{7DD9A65A-C68D-464A-AFDB-21E9A3C6AA0E} = {19750AFD-3091-4569-9D89-8D5735C3EBFC}
{3D5EDF70-D0B3-4552-8185-BE5EB11C7ADA} = {19750AFD-3091-4569-9D89-8D5735C3EBFC}
{218B897C-F0F6-4B8F-A3F4-2289B6B5415F} = {0D861355-C022-4E1A-8C7B-7D1C3A066EE3}
{E2D7CB90-C283-9851-BC17-380194A3AEA5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {55953F2E-2283-4F22-9B79-17E81B54BDCE}
Expand Down
10 changes: 5 additions & 5 deletions nuget/NUGET.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
A powerful C# library for building and executing workflows. Define steps, manage dependencies, and orchestrate complex processes with ease. Perfect for task automation, data processing pipelines, and business logic implementation.

Key features:
• Automatic dependency resolution
• Built-in WebUI for visualizing and executing workflows
StepWise is a .NET framework which assists you to code, visualize and execute event-base workflow. It is designed to help you build complex workflows in a simple and efficient way. StepWise comes with the following key features:
- **Code-First**: Define workflows using C# code in your project.
- **WebUI** Visualize and execute workflows from your favorite browser using StepWise WebUI.
- **Event-Driven**: Execute steps in parallel and resolve dependencies automatically.
- **AI-Powered**: Work with `Geeno`, a built-in AI assistant in StepWise WebUI to help you run and analyze workflows with ease.
35 changes: 35 additions & 0 deletions template/StepWise.Template.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<Import Project="$(RepoRoot)/nuget/nuget-package.props" />

<PropertyGroup>
<!-- Keep package type as 'Template' to show the package as a template package on nuget.org and make your template available in dotnet new search.-->
<TargetFramework>net8.0</TargetFramework>
<IncludeContentInPack>true</IncludeContentInPack>
<ContentTargetFolders>content</ContentTargetFolders>
<NoPackageAnalysis>true</NoPackageAnalysis>
<PackageType>Template</PackageType>
<NoWarn>$(NoWarn);NU5128;NU5017</NoWarn>
<NoDefaultExcludes>true</NoDefaultExcludes>
<IncludeBuildOutput>False</IncludeBuildOutput>
<IncludeSource>False</IncludeSource>
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
<SuppressDependenciesWhenPacking>True</SuppressDependenciesWhenPacking>
<EnableNETAnalyzers>False</EnableNETAnalyzers>
</PropertyGroup>

<PropertyGroup>
<LocalizeTemplates>false</LocalizeTemplates>
</PropertyGroup>

<ItemGroup>
<PackageReference Remove="Microsoft.NETCore.App" />
<PackageReference Include="Microsoft.TemplateEngine.Tasks" Version="*" PrivateAssets="all" IsImplicitlyDefined="true"/>
</ItemGroup>

<ItemGroup>
<Content Include="content\**\*" Exclude="content\**\bin\**;content\**\obj\**" />
<Compile Remove="**\*" />
</ItemGroup>

</Project>
27 changes: 27 additions & 0 deletions template/content/Console/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "StepWise",
"classifications": [
"Common",
"Console",
"StepWise"
],
"identity": "StepWise.Template.Console",
"name": "StepWise Console Application",
"shortName": "stepwise-console",
"sourceName": "stepwise.console",
"tags": {
"language": "C#",
"type": "project"
},
"symbols": {
"TargetFrameworkOverride": {
"type": "parameter",
"description": "Overrides the target framework",
"replaces": "TargetFrameworkOverride",
"datatype": "string",
"defaultValue": "",
"displayName": "Target framework override"
}
}
}
40 changes: 40 additions & 0 deletions template/content/Console/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using StepWise.Core;
using StepWise.WebAPI;

var host = Host.CreateDefaultBuilder()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("http://localhost:5123");
})
.UseStepWiseServer()
.Build();

await host.StartAsync();

var stepWiseClient = host.Services.GetRequiredService<StepWiseClient>();

var helloWorld = new HelloWorld();
var workflow = Workflow.CreateFromInstance(helloWorld);
stepWiseClient.AddWorkflow(workflow);

await host.WaitForShutdownAsync();

public class HelloWorld
{
[StepWiseUITextInput(description: "Enter your name")]
public Task<string?> Name()
{
return Task.FromResult<string?>(null);
}

[Step]
[DependOn(nameof(Name))]
public async Task<string> Greeting(
[FromStep(nameof(Name))] string name)
{
return $"Hello world, {name}!";
}
}
15 changes: 15 additions & 0 deletions template/content/Console/stepwise.console.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework Condition="'$(TargetFrameworkOverride)' == ''">net8.0</TargetFramework>
<TargetFramework Condition="'$(TargetFrameworkOverride)' != ''">TargetFrameworkOverride</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="LittleLittleCloud.StepWise" Version="0.0.14" />
</ItemGroup>

</Project>
Loading