Compare commits
7 Commits
8f82360cc7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| c0b2ce44ad | |||
| 21f4e7765b | |||
| 33ba944f8a | |||
| 05051878f2 | |||
| 3fff9c7dd0 | |||
| eda7992c23 | |||
| 457429f7ec |
@@ -1,9 +1,9 @@
|
||||
name: Build and publish MycroForge.CLI
|
||||
run-name: ${{ gitea.actor }} triggered a build for the MycroForge.CLI
|
||||
run-name: ${{ gitea.actor }} triggered a build for the MycroForge.CLI package
|
||||
on: [ push ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
steps:
|
||||
@@ -14,7 +14,8 @@ jobs:
|
||||
- name: "Build and publish NuGet package"
|
||||
run: |
|
||||
# Build the NuGet package
|
||||
cd MycroForge.CLI && dotnet pack -v m
|
||||
cd MycroForge.CLI
|
||||
dotnet pack -v m
|
||||
|
||||
# Add the NuGet source
|
||||
dotnet nuget add source --name devdisciples \
|
||||
33
.gitea/workflows/build_core.yml
Normal file
33
.gitea/workflows/build_core.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Build and publish MycroForge.Core
|
||||
run-name: ${{ gitea.actor }} triggered a build for the MycroForge.Core package
|
||||
on: [ workflow_dispatch ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: https://github.com/actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.x'
|
||||
- name: "Build and publish NuGet package"
|
||||
run: |
|
||||
# Build the NuGet package
|
||||
cd MycroForge.Core
|
||||
dotnet publish
|
||||
dotnet pack -v m
|
||||
|
||||
# Add the NuGet source
|
||||
dotnet nuget add source --name devdisciples \
|
||||
--username ${{ secrets.NUGET_USER }} \
|
||||
--password ${{ secrets.NUGET_PASS }} \
|
||||
--store-password-in-clear-text \
|
||||
https://git.devdisciples.com/api/packages/devdisciples/nuget/index.json
|
||||
|
||||
# Set the path to the package
|
||||
VERSION=$(grep '<Version>' < MycroForge.Core.csproj | sed 's/.*<Version>\(.*\)<\/Version>/\1/' | xargs)
|
||||
PACKAGE="bin/Release/MycroForge.Core.$VERSION.nupkg"
|
||||
|
||||
# Push the package
|
||||
dotnet nuget push "$PACKAGE" --source devdisciples
|
||||
33
.gitea/workflows/build_plugin_template.yml
Normal file
33
.gitea/workflows/build_plugin_template.yml
Normal file
@@ -0,0 +1,33 @@
|
||||
name: Build and publish MycroForge.PluginTemplate package
|
||||
run-name: ${{ gitea.actor }} triggered a build for the MycroForge.PluginTemplate package
|
||||
on: [ workflow_dispatch ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v4
|
||||
- uses: https://github.com/actions/setup-dotnet@v4
|
||||
with:
|
||||
dotnet-version: '8.x'
|
||||
- name: "Build and publish NuGet package"
|
||||
run: |
|
||||
# Build the NuGet package
|
||||
cd MycroForge.PluginTemplate.Package
|
||||
dotnet publish
|
||||
dotnet pack -v m
|
||||
|
||||
# Add the NuGet source
|
||||
dotnet nuget add source --name devdisciples \
|
||||
--username ${{ secrets.NUGET_USER }} \
|
||||
--password ${{ secrets.NUGET_PASS }} \
|
||||
--store-password-in-clear-text \
|
||||
https://git.devdisciples.com/api/packages/devdisciples/nuget/index.json
|
||||
|
||||
# Set the path to the package
|
||||
VERSION=$(grep '<PackageVersion>' < MycroForge.PluginTemplate.Package.csproj | sed 's/.*<PackageVersion>\(.*\)<\/PackageVersion>/\1/' | xargs)
|
||||
PACKAGE="bin/Release/MycroForge.PluginTemplate.Package.$VERSION.nupkg"
|
||||
|
||||
# Push the package
|
||||
dotnet nuget push "$PACKAGE" --source devdisciples
|
||||
@@ -10,21 +10,29 @@ public partial class MycroForge
|
||||
{
|
||||
public class Init : Command, ISubCommandOf<Plugin>
|
||||
{
|
||||
private static readonly Argument<string> NameArgument =
|
||||
new(name: "name", description: "The name of your project");
|
||||
private static readonly Argument<string> NamespaceArgument =
|
||||
new(name: "namespace", description: "The namespace of your project");
|
||||
|
||||
private static readonly Argument<string> ClassArgument =
|
||||
new(name: "class", description: "The class name of the generated command");
|
||||
|
||||
private static readonly Argument<string> CommandArgument =
|
||||
new(name: "command", description: "The command name that will be added to 'm4g'");
|
||||
|
||||
private readonly ProjectContext _context;
|
||||
|
||||
public Init(ProjectContext context) : base("init", "Initialize a basic plugin project")
|
||||
{
|
||||
_context = context;
|
||||
AddArgument(NameArgument);
|
||||
this.SetHandler(ExecuteAsync, NameArgument);
|
||||
AddArgument(NamespaceArgument);
|
||||
AddArgument(ClassArgument);
|
||||
AddArgument(CommandArgument);
|
||||
this.SetHandler(ExecuteAsync, NamespaceArgument, ClassArgument, CommandArgument);
|
||||
}
|
||||
|
||||
private async Task ExecuteAsync(string name)
|
||||
private async Task ExecuteAsync(string @namespace, string @class, string command)
|
||||
{
|
||||
await _context.Bash($"dotnet new m4gp -n {name}");
|
||||
await _context.Bash($"dotnet new m4gp -n {@namespace} --class {@class} --command {command}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +44,13 @@ public partial class MycroForge
|
||||
var assemblyName = GetAssemblyName();
|
||||
var pluginInstallPath = Path.Join(Plugins.RootDirectory, assemblyName);
|
||||
var platform = target.ToString().Dasherize();
|
||||
await _context.Bash($"dotnet publish -c Release -r {platform} --output {pluginInstallPath}");
|
||||
Console.WriteLine($"Successfully installed plugin {assemblyName}");
|
||||
var exitCode = await _context.Bash(
|
||||
$"dotnet publish -c Release -r {platform} --output {pluginInstallPath}"
|
||||
);
|
||||
|
||||
Console.WriteLine(exitCode == 0
|
||||
? $"Successfully installed plugin {assemblyName}"
|
||||
: $"Could not install {assemblyName}, process exited with code {exitCode}.");
|
||||
}
|
||||
|
||||
private string GetAssemblyName()
|
||||
|
||||
@@ -52,7 +52,7 @@ public sealed partial class Api : IFeature
|
||||
|
||||
await context.Bash(
|
||||
"source .venv/bin/activate",
|
||||
"python3 -m pip install fastapi",
|
||||
"python3 -m pip install fastapi uvicorn",
|
||||
"python3 -m pip freeze > requirements.txt"
|
||||
);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>1.0.1</Version>
|
||||
<Version>0.0.1</Version>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
|
||||
0
MycroForge.CLI/scripts/publish-tool.sh
Normal file → Executable file
0
MycroForge.CLI/scripts/publish-tool.sh
Normal file → Executable file
@@ -6,7 +6,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<PackageId>MycroForge.Core</PackageId>
|
||||
<Description>The MycroForge core package</Description>
|
||||
<Version>1.0.0</Version>
|
||||
<Version>0.0.1</Version>
|
||||
<Authors>Donné Napo</Authors>
|
||||
<Company>Dev Disciples</Company>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ProjectContext
|
||||
Console.WriteLine($"Modified file {path}");
|
||||
}
|
||||
|
||||
public async Task Bash(params string[] script)
|
||||
public async Task<int> Bash(params string[] script)
|
||||
{
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
@@ -112,6 +112,8 @@ public class ProjectContext
|
||||
|
||||
await process.WaitForExitAsync();
|
||||
Environment.ExitCode = process.ExitCode;
|
||||
|
||||
return process.ExitCode;
|
||||
}
|
||||
|
||||
public async Task SaveConfig(ProjectConfig config)
|
||||
|
||||
7
MycroForge.Core/scripts/publish-nuget.sh
Normal file → Executable file
7
MycroForge.Core/scripts/publish-nuget.sh
Normal file → Executable file
@@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
#!/bin/bash
|
||||
|
||||
dotnet build -r Release
|
||||
dotnet nuget push --source devdisciples bin/Release/MycroForge.Core.1.0.0.nupkg
|
||||
VERSION=$(grep '<Version>' < MycroForge.Core.csproj | sed 's/.*<Version>\(.*\)<\/Version>/\1/' | tr -d '[:space:]')
|
||||
dotnet build -r Releasedo
|
||||
dotnet nuget push --source devdisciples "bin/Release/MycroForge.Core.$VERSION.nupkg"
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<!-- The package metadata. Fill in the properties marked as TODO below -->
|
||||
<!-- Follow the instructions on https://learn.microsoft.com/nuget/create-packages/package-authoring-best-practices -->
|
||||
<PackageId>MycroForge.PluginTemplate.Package</PackageId>
|
||||
<PackageVersion>1.0</PackageVersion>
|
||||
<PackageVersion>0.0.1</PackageVersion>
|
||||
<Title>A template for generating MycroForge plugins</Title>
|
||||
<Authors>Donné Napo</Authors>
|
||||
<Description>Template to use when creating a plugin for the MycroForge CLI.</Description>
|
||||
|
||||
2
MycroForge.PluginTemplate.Package/scripts/build_package.sh → MycroForge.PluginTemplate.Package/scripts/build-package.sh
Normal file → Executable file
2
MycroForge.PluginTemplate.Package/scripts/build_package.sh → MycroForge.PluginTemplate.Package/scripts/build-package.sh
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/env bash
|
||||
|
||||
rm -rf templates/MycroForge.PluginTemplate
|
||||
cp -R ../MycroForge.PluginTemplate templates/MycroForge.PluginTemplate
|
||||
12
MycroForge.PluginTemplate.Package/scripts/publish-nuget.sh
Executable file
12
MycroForge.PluginTemplate.Package/scripts/publish-nuget.sh
Executable file
@@ -0,0 +1,12 @@
|
||||
#!/bin/env bash
|
||||
|
||||
rm -rf templates/MycroForge.PluginTemplate
|
||||
cp -R ../MycroForge.PluginTemplate templates/MycroForge.PluginTemplate
|
||||
dotnet pack
|
||||
|
||||
# Set the path to the package
|
||||
VERSION=$(grep '<PackageVersion>' < MycroForge.PluginTemplate.Package.csproj | sed 's/.*<PackageVersion>\(.*\)<\/PackageVersion>/\1/' | tr -d '[:space:]')
|
||||
PACKAGE="bin/Release/MycroForge.PluginTemplate.Package.$VERSION.nupkg"
|
||||
|
||||
# Push the package
|
||||
dotnet nuget push "$PACKAGE" --source devdisciples
|
||||
@@ -17,5 +17,16 @@
|
||||
"language": "C#",
|
||||
"type": "project"
|
||||
},
|
||||
"preferNameDirectory": true
|
||||
"preferNameDirectory": true,
|
||||
"symbols": {
|
||||
"class": {
|
||||
"type": "parameter",
|
||||
"replaces": "ExampleCommand",
|
||||
"fileRename": "ExampleCommand"
|
||||
},
|
||||
"command": {
|
||||
"type": "parameter",
|
||||
"replaces": "example"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using RootCommand = MycroForge.Core.RootCommand;
|
||||
|
||||
namespace MycroForge.PluginTemplate;
|
||||
|
||||
public class HelloWorldCommand : Command, ISubCommandOf<RootCommand>
|
||||
public class ExampleCommand : Command, ISubCommandOf<RootCommand>
|
||||
{
|
||||
private readonly Argument<string> NameArgument =
|
||||
new(name: "name", description: "The name of the person to greet");
|
||||
@@ -15,8 +15,8 @@ public class HelloWorldCommand : Command, ISubCommandOf<RootCommand>
|
||||
|
||||
private readonly ProjectContext _context;
|
||||
|
||||
public HelloWorldCommand(ProjectContext context) :
|
||||
base("hello", "An example command generated by dotnet new using the m4gp template")
|
||||
public ExampleCommand(ProjectContext context) :
|
||||
base("example", "A basic command plugin generated by the 'm4g plugin init' command")
|
||||
{
|
||||
_context = context;
|
||||
AddArgument(NameArgument);
|
||||
@@ -28,9 +28,9 @@ public class HelloWorldCommand : Command, ISubCommandOf<RootCommand>
|
||||
{
|
||||
name = allCaps ? name.ToUpper() : name;
|
||||
|
||||
await _context.CreateFile("hello_world.txt",
|
||||
await _context.CreateFile("example.txt",
|
||||
$"Hello {name}!",
|
||||
"This file was generated by your custom command!"
|
||||
"This file was generated by the 'm4g example' command!"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,12 @@ using RootCommand = MycroForge.Core.RootCommand;
|
||||
|
||||
namespace MycroForge.PluginTemplate;
|
||||
|
||||
public class HelloWorldCommandPlugin : ICommandPlugin
|
||||
public class ExampleCommandPlugin : ICommandPlugin
|
||||
{
|
||||
public string Name => "MycroForge.PluginTemplate";
|
||||
|
||||
public void RegisterServices(IServiceCollection services)
|
||||
{
|
||||
services.AddScoped<ISubCommandOf<RootCommand>, HelloWorldCommand>();
|
||||
services.AddScoped<ISubCommandOf<RootCommand>, ExampleCommand>();
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MycroForge.Core" Version="1.0.0" />
|
||||
<PackageReference Include="MycroForge.Core" Version="0.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user