Renamed MicroForge to MycroForge

This commit is contained in:
Donné Napo 2024-04-22 09:56:39 +02:00
parent 8fed922cfe
commit 7e249e12c4
46 changed files with 265 additions and 266 deletions

View File

@ -1,6 +1,6 @@
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
COPY . /source
WORKDIR /source/MicroForge.CLI
WORKDIR /source/MycroForge.CLI
ARG TARGETARCH
# Leverage a cache mount to /root/.nuget/packages so that subsequent builds don't have to re-download packages.
# If TARGETARCH is "amd64", replace it with "x64" - "x64" is .NET's canonical name for this and "amd64" doesn't
@ -26,7 +26,7 @@ WORKDIR /app
COPY --from=build /app .
WORKDIR /project
COPY MicroForge.CLI/scripts /scripts
COPY MycroForge.CLI/scripts /scripts
USER root
ENTRYPOINT ["dotnet", "/app/MicroForge.CLI.dll"] CMD ["-?"]
ENTRYPOINT ["dotnet", "/app/MycroForge.CLI.dll"] CMD ["-?"]

View File

@ -1,17 +0,0 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
public partial class MicroForge : RootCommand
{
public override string Name => "m4g";
public MicroForge(IEnumerable<ISubCommandOf<MicroForge>> commands) : base("The MicroForge CLI tool.")
{
commands
.Cast<Command>()
.ToList()
.ForEach(AddCommand);
}
}

View File

@ -1,46 +0,0 @@
using MicroForge.CLI.Commands.Interfaces;
using MicroForge.CLI.Features;
using Microsoft.Extensions.DependencyInjection;
namespace MicroForge.CLI.Extensions;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddServices(this IServiceCollection services, string[] args)
{
services.AddScoped<ArgsContext>(_ => new ArgsContext { Args = args });
services.AddScoped<ProjectContext>();
services.AddScoped<IFeature, Api>();
services.AddScoped<IFeature, Orm>();
return services;
}
public static IServiceCollection AddCommands(this IServiceCollection services)
{
// Register "m4g"
services.AddScoped<Commands.MicroForge>();
services.AddScoped<ISubCommandOf<Commands.MicroForge>, Commands.MicroForge.Init>();
services.AddScoped<ISubCommandOf<Commands.MicroForge>, Commands.MicroForge.Run>();
services.AddScoped<ISubCommandOf<Commands.MicroForge>, Commands.MicroForge.Install>();
services.AddScoped<ISubCommandOf<Commands.MicroForge>, Commands.MicroForge.Uninstall>();
// Register "m4g add"
services.AddScoped<ISubCommandOf<Commands.MicroForge>, Commands.MicroForge.Add>();
services.AddScoped<ISubCommandOf<Commands.MicroForge.Add>, Commands.MicroForge.Add.Api>();
services.AddScoped<ISubCommandOf<Commands.MicroForge.Add>, Commands.MicroForge.Add.Orm>();
// Register "m4g generate"
services.AddScoped<ISubCommandOf<Commands.MicroForge>, Commands.MicroForge.Generate>();
services.AddScoped<ISubCommandOf<Commands.MicroForge.Generate>, Commands.MicroForge.Generate.Entity>();
services.AddScoped<ISubCommandOf<Commands.MicroForge.Generate>, Commands.MicroForge.Generate.Router>();
services.AddScoped<ISubCommandOf<Commands.MicroForge.Generate>, Commands.MicroForge.Generate.Migration>();
// Register "m4g migrations"
services.AddScoped<ISubCommandOf<Commands.MicroForge>, Commands.MicroForge.Migrations>();
services.AddScoped<ISubCommandOf<Commands.MicroForge.Migrations>, Commands.MicroForge.Migrations.Apply>();
services.AddScoped<ISubCommandOf<Commands.MicroForge.Migrations>, Commands.MicroForge.Migrations.Rollback>();
return services;
}
}

View File

@ -1,5 +0,0 @@
#!/usr/bin/bash
dotnet pack -v d
dotnet tool update --global --add-source ./nupkg MicroForge.CLI -v d

View File

@ -1,4 +1,4 @@
namespace MicroForge.CLI;
namespace MycroForge.CLI;
public class ArgsContext
{

View File

@ -1,8 +1,8 @@
using System.Diagnostics;
using System.Text;
using MicroForge.CLI.Exceptions;
using MycroForge.CLI.Exceptions;
namespace MicroForge.CLI;
namespace MycroForge.CLI;
public static class Bash
{

View File

@ -1,6 +1,6 @@
using MicroForge.Parsing;
using MycroForge.Parsing;
namespace MicroForge.CLI.CodeGen;
namespace MycroForge.CLI.CodeGen;
public class OrmEnvInitializer : PythonSourceModifier
{

View File

@ -1,6 +1,6 @@
using MicroForge.Parsing;
using MycroForge.Parsing;
namespace MicroForge.CLI.CodeGen;
namespace MycroForge.CLI.CodeGen;
public class OrmEnvUpdater : PythonSourceModifier
{

View File

@ -1,7 +1,7 @@
using Antlr4.Runtime;
using MicroForge.Parsing;
using MycroForge.Parsing;
namespace MicroForge.CLI.CodeGen;
namespace MycroForge.CLI.CodeGen;
public abstract class PythonSourceModifier : PythonParserBaseVisitor<object?>
{

View File

@ -1,6 +1,6 @@
using System.CommandLine;
namespace MicroForge.CLI.Commands.Interfaces;
namespace MycroForge.CLI.Commands.Interfaces;
public interface ISubCommandOf<T> where T : Command
{

View File

@ -1,10 +1,10 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MicroForge.CLI.Features;
using MycroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Features;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Add
{

View File

@ -1,10 +1,10 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MicroForge.CLI.Features;
using MycroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Features;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Add
{

View File

@ -1,11 +1,11 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public new partial class Add : Command, ISubCommandOf<MicroForge>
public new partial class Add : Command, ISubCommandOf<MycroForge>
{
public Add(IEnumerable<ISubCommandOf<Add>> subCommands) :
base("add", "Add a predefined feature to your project")
@ -15,7 +15,7 @@ public partial class MicroForge
}
}
public class Run : Command, ISubCommandOf<MicroForge>
public class Run : Command, ISubCommandOf<MycroForge>
{
public Run() : base("run", "Run your app")
{

View File

@ -1,11 +1,11 @@
using System.CommandLine;
using Humanizer;
using MicroForge.CLI.CodeGen;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.CodeGen;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Generate
{

View File

@ -1,9 +1,9 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Generate
{

View File

@ -1,10 +1,10 @@
using System.CommandLine;
using Humanizer;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Generate
{

View File

@ -1,11 +1,11 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Generate : Command, ISubCommandOf<MicroForge>
public partial class Generate : Command, ISubCommandOf<MycroForge>
{
public Generate(IEnumerable<ISubCommandOf<Generate>> subCommands) :
base("generate", "Generate a project item")

View File

@ -1,13 +1,13 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MicroForge.CLI.Features;
using Microsoft.Extensions.DependencyInjection;
using MycroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Features;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public class Init : Command, ISubCommandOf<MicroForge>
public class Init : Command, ISubCommandOf<MycroForge>
{
#region GitIgnore

View File

@ -1,11 +1,11 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public class Install : Command, ISubCommandOf<MicroForge>
public class Install : Command, ISubCommandOf<MycroForge>
{
private static readonly Argument<IEnumerable<string>> PackagesArgument =
new(name: "packages", description: "The names of the packages to install");

View File

@ -1,9 +1,9 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Migrations
{

View File

@ -1,9 +1,9 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Migrations
{

View File

@ -1,11 +1,11 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public partial class Migrations : Command, ISubCommandOf<MicroForge>
public partial class Migrations : Command, ISubCommandOf<MycroForge>
{
public Migrations(IEnumerable<ISubCommandOf<Migrations>> subCommands) :
base("migrations", "Manage your migrations")

View File

@ -1,11 +1,11 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public class Rewrite : Command, ISubCommandOf<MicroForge>
public class Rewrite : Command, ISubCommandOf<MycroForge>
{
public Rewrite() : base("rewrite", "Test a python source rewriter.")
{

View File

@ -1,11 +1,11 @@
using System.CommandLine;
using MicroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Commands.Interfaces;
namespace MicroForge.CLI.Commands;
namespace MycroForge.CLI.Commands;
public partial class MicroForge
public partial class MycroForge
{
public class Uninstall : Command, ISubCommandOf<MicroForge>
public class Uninstall : Command, ISubCommandOf<MycroForge>
{
private static readonly Argument<IEnumerable<string>> PackagesArgument =
new(name: "packages", description: "The names of the packages to uninstall");

View File

@ -0,0 +1,17 @@
using System.CommandLine;
using MycroForge.CLI.Commands.Interfaces;
namespace MycroForge.CLI.Commands;
public partial class MycroForge : RootCommand
{
public override string Name => "m4g";
public MycroForge(IEnumerable<ISubCommandOf<MycroForge>> commands) : base("The MycroForge CLI tool.")
{
commands
.Cast<Command>()
.ToList()
.ForEach(AddCommand);
}
}

View File

@ -1,4 +1,4 @@
namespace MicroForge.CLI.Exceptions;
namespace MycroForge.CLI.Exceptions;
public class BashException : Exception
{

View File

@ -1,6 +1,6 @@
using System.Text.Json;
namespace MicroForge.CLI.Extensions;
namespace MycroForge.CLI.Extensions;
public static class ObjectStreamExtensions
{

View File

@ -0,0 +1,46 @@
using Microsoft.Extensions.DependencyInjection;
using MycroForge.CLI.Commands.Interfaces;
using MycroForge.CLI.Features;
namespace MycroForge.CLI.Extensions;
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddServices(this IServiceCollection services, string[] args)
{
services.AddScoped<ArgsContext>(_ => new ArgsContext { Args = args });
services.AddScoped<ProjectContext>();
services.AddScoped<IFeature, Api>();
services.AddScoped<IFeature, Orm>();
return services;
}
public static IServiceCollection AddCommands(this IServiceCollection services)
{
// Register "m4g"
services.AddScoped<Commands.MycroForge>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Init>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Run>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Install>();
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Uninstall>();
// Register "m4g add"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Add>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Add>, Commands.MycroForge.Add.Api>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Add>, Commands.MycroForge.Add.Orm>();
// Register "m4g generate"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Generate>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Generate>, Commands.MycroForge.Generate.Entity>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Generate>, Commands.MycroForge.Generate.Router>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Generate>, Commands.MycroForge.Generate.Migration>();
// Register "m4g migrations"
services.AddScoped<ISubCommandOf<Commands.MycroForge>, Commands.MycroForge.Migrations>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Migrations>, Commands.MycroForge.Migrations.Apply>();
services.AddScoped<ISubCommandOf<Commands.MycroForge.Migrations>, Commands.MycroForge.Migrations.Rollback>();
return services;
}
}

View File

@ -1,4 +1,4 @@
namespace MicroForge.CLI.Features;
namespace MycroForge.CLI.Features;
public sealed class Api : IFeature
{

View File

@ -1,4 +1,4 @@
namespace MicroForge.CLI.Features;
namespace MycroForge.CLI.Features;
public interface IFeature

View File

@ -1,6 +1,6 @@
using MicroForge.CLI.CodeGen;
using MycroForge.CLI.CodeGen;
namespace MicroForge.CLI.Features;
namespace MycroForge.CLI.Features;
public sealed class Orm : IFeature
{

View File

@ -11,7 +11,7 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MicroForge.Parsing\MicroForge.Parsing.csproj" />
<ProjectReference Include="..\MycroForge.Parsing\MycroForge.Parsing.csproj" />
</ItemGroup>
<ItemGroup>
@ -30,8 +30,8 @@
</ItemGroup>
<ItemGroup>
<Reference Include="MicroForge.Parsing">
<HintPath>bin\Debug\net8.0\MicroForge.Parsing.dll</HintPath>
<Reference Include="MycroForge.Parsing">
<HintPath>bin\Debug\net8.0\MycroForge.Parsing.dll</HintPath>
</Reference>
</ItemGroup>

View File

@ -1,11 +1,10 @@
using System.CommandLine;
using MicroForge.CLI;
using MicroForge.CLI.CodeGen;
using MicroForge.CLI.Exceptions;
using MicroForge.CLI.Extensions;
using MycroForge.CLI;
using MycroForge.CLI.CodeGen;
using MycroForge.CLI.Exceptions;
using MycroForge.CLI.Extensions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using RootCommand = MicroForge.CLI.Commands.MicroForge;
using var host = Host
.CreateDefaultBuilder()
@ -21,7 +20,7 @@ try
{
var ctx = host.Services.GetRequiredService<ProjectContext>();
await ctx.LoadConfig();
await host.Services.GetRequiredService<RootCommand>().InvokeAsync(args);
await host.Services.GetRequiredService<MycroForge.CLI.Commands.MycroForge>().InvokeAsync(args);
await ctx.SaveConfig();
}
catch

View File

@ -1,4 +1,4 @@
namespace MicroForge.CLI;
namespace MycroForge.CLI;
public class ProjectConfig
{

View File

@ -1,7 +1,7 @@
using System.Text.Json;
using MicroForge.CLI.Extensions;
using MycroForge.CLI.Extensions;
namespace MicroForge.CLI;
namespace MycroForge.CLI;
public class ProjectContext
{

View File

@ -1,6 +1,6 @@
using System.Text.Json;
namespace MicroForge.CLI;
namespace MycroForge.CLI;
public static class Shared
{

View File

@ -0,0 +1,5 @@
#!/usr/bin/bash
dotnet pack -v d
dotnet tool update --global --add-source ./nupkg MycroForge.CLI -v d

View File

@ -28,7 +28,7 @@ THE SOFTWARE.
using Antlr4.Runtime;
using System.Text.RegularExpressions;
namespace MicroForge.Parsing;
namespace MycroForge.Parsing;
public abstract class PythonLexerBase : Lexer
{

View File

@ -1,6 +1,6 @@
using Antlr4.Runtime;
namespace MicroForge.Parsing;
namespace MycroForge.Parsing;
public abstract class PythonParserBase : Parser
{

View File

@ -1,8 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroForge.CLI", "MicroForge.CLI\MicroForge.CLI.csproj", "{27EFB015-AFC3-4046-8D9A-DD5C5D3B35E0}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MycroForge.CLI", "MycroForge.CLI\MycroForge.CLI.csproj", "{27EFB015-AFC3-4046-8D9A-DD5C5D3B35E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MicroForge.Parsing", "MicroForge.Parsing\MicroForge.Parsing.csproj", "{D697CEFD-7CF7-4680-82FC-F84B08F81635}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MycroForge.Parsing", "MycroForge.Parsing\MycroForge.Parsing.csproj", "{D697CEFD-7CF7-4680-82FC-F84B08F81635}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution