Coder Social home page Coder Social logo

easyabp / abphelper.cli Goto Github PK

View Code? Open in Web Editor NEW
285.0 17.0 95.0 13.43 MB

Providing code generation and more features to help you develop applications and modules with the ABP framework.

License: MIT License

C# 96.75% PowerShell 0.26% TypeScript 0.14% HTML 1.40% JavaScript 1.45%

abphelper.cli's Introduction

AbpHelper.CLI

ABP version NuGet NuGet Download Discord online GitHub stars

AbpHelper is a tool that help you with developing Abp vNext applications.

Make sure to backup your source files before using it!

Getting Started

  1. Install AbpHelper CLI tool

    dotnet tool install EasyAbp.AbpHelper -g

    If you prefer GUI, there is also a tool with a fancy UI: AbpHelper.GUI

  2. If you have previously installed it, update it with the following command:

    dotnet tool update EasyAbp.AbpHelper -g

  3. Use ABP CLI to create an ABP application

    abp new MyToDo

  4. Create an entity

    public class Todo : FullAuditedEntity<Guid>
    {
        public string Content { get; set; }
        public bool Done { get; set; }
    }
  5. Run AbpHelper

    abphelper generate crud Todo -d C:\MyTodo

    • generate crud is a sub command to generate CRUD files
    • Todo specified the entity name we created earlier
    • -d specified the root directory of the ABP project, which is created by the ABP CLI

    AbpHelper will generate all the CRUD stuffs , even include adding migration and database updating!

  6. Run the DbMigrator to seed the database

  7. Startup your application

  8. Login with the default admin account, and see the magic happens!

    running_demo

    If you don't see the TODO menu, check your permissions and make sure the TODO related permissions are granted

Usage

  • Run abphelper -h to see the general help
  • Similarly, you can use -h or --help option to see detailed usage of each of the following commands

Commands

  • generate

    Generate files for ABP projects. See 'abphelper generate --help' for details

    • crud

      Generate a set of CRUD related files according to the specified entity

      Demo GIF

    • service

      Generate service interface and class files according to the specified name

      Demo GIF

    • methods

      Generate service method(s) according to the specified name(s)

      Demo GIF

    • localization

      Generate localization item(s) according to the specified name(s)

      Demo GIF

    • controller

      Generate controller class and methods according to the specified service

      Demo GIF

  • ef

    A shortcut to run 'dotnet ef' commands. See 'abphelper ef --help' for details

    Demo GIF

  • module

    Help quickly add/update/remove ABP modules. See 'abphelper module --help' for details

    Demo GIF

abphelper.cli's People

Contributors

adeewu avatar blackwins avatar dependabot[bot] avatar gdlcf88 avatar hanazawa avatar indexlang avatar itryan avatar jadynwong avatar raymmond avatar rwing avatar wakuflair avatar woshidajiao avatar yellow-dragon-cloud avatar zhjmao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

abphelper.cli's Issues

Need create/update info models generation.

image

It is not a good way to add Bootstrap attributes to creation DTO.

Developers may need a CreateUpdateTodoInfoModel (or two separated info models), so they can custom their form.

Generator doesn't work when an entity class implements more than one interface.

Error here:

var genericNameSyntax = baseList.Descendants<SimpleBaseTypeSyntax>().Single().Descendants<GenericNameSyntax>().FirstOrDefault();

Entity class for example:

    public class ReviewNotice : CreationAuditedAggregateRoot<Guid>, IMultiTenant
    {
        public virtual Guid? TenantId { get; set; }
        
        public virtual Guid ReviewId { get; protected set; }
        
        public virtual Guid UserId { get; protected set; }
    }

build cli ERROR,copy sbntxt file

error MSB3027: 无法将“F:\github\abptools\AbpHelper.CLI\src\AbpHelper\Templates\Crud\Groups\Test\test{{ ProjectInfo.FullName }}.EntityFrameworkCore.Tests\EntityFrameworkCore{{ EntityInfo.NamespaceLastPart }}{{ EntityInfo.Name }}RepositoryTests.cs.sbntxt”复制到“bin\Debug\netcoreapp3.1\publish\Templates\Crud\Groups\Test\test{{ ProjectInfo.FullName }}.EntityFrameworkCore.Tests\EntityFrameworkCore{{ EntityInfo.NamespaceLastPart }}{{ EntityInfo.Name }}RepositoryTests.cs.sbntxt”。超出了重试计数 10。失败。

Suggestions for command line improvement

This is the current command line demo:
abphelper C:\MyTodo Todo.cs

I have some suggestions:

  1. Rename "abphelper" to "abp-helper".
    Of course we should not use CamelCase, but maybe abp-helper is a better choice.
  2. Change the input from solution folder to .sln file.
    If we do it, maybe developers can use it directly by select a .sln file without having to learn which folder should be inputted.
  3. Add a required function name to command line.
    In future, AbpHelper may has more functions than the code generation, so we can add a function name likes generate after the command abphelper.
  4. Entity name don't need .cs suffix.
    If developers input Todo, we can assert the filename is "Todo.cs", and if the entity file is not in the default location "C:\MyTodo\src\MyTodo.Domain\Todos\Todo.cs", they can configure the correct path by --EntityFile C:\MyTodo\src\MyTodo.Domain\Todos\TodoEntity.cs or -e C:\MyTodo\src\MyTodo.Domain\Todos\TodoEntity.cs.
  5. Maybe solution folder input could be omitted.
    Developers can change current folder to C:\MyTodo and run the command line, for this use, solution folder (or .sln file) is not required to input, so we can omit it can provide a way to set the target .sln file likes -s C:\MyTodo\MyTodo.sln.

For example:

abp-helper generate Todo
abp-helper generate Todo -e C:\MyTodo\src\MyTodo.Domain\Todos\TodoEntity.cs
abp-helper generate Todo -s C:\MyTodo\MyTodo.sln

Maybe we can add a option to specify UI framework.

Refer to: https://github.com/abpframework/abp/blob/dev/docs/en/CLI.md

Maybe we need a CLI parameter like: --ui angular or -u angular.

And it could be --ui none by default to skip the UI pages generation. (Relate to: #15)

There are several reasons:

  1. In future, there will be more ABP official UI frameworks and community UI frameworks, even a solution has more than one UI frameworks, so it is hard to do automatic recognition.

  2. Developers have experience to use -u angular because ABP CLI also has the parameter.

  3. GUI will remember the solution information so developers do not need to repeat it. (Not yet implemented)

support generate entities?

suggest

  • Whether to consider support for generating entities?
  • Consider reading the PDM file to generate the entities!

Dto class code style problem.

    public class CreateUpdateTodoDto
    {
        [DisplayName("TodoTenantId")]
        public Guid? TenantId {get; set;}  // Should be { get; set; }
// Extra line should be removed
    }
    public class ReviewNoticeDto : CreationAuditedEntityDto<Guid>
    {
        public Guid? TenantId {get; set;}  // Should be { get; set; }
    }

The module menu item may need to be a sub item of administration menu item.

        private async Task ConfigureMainMenu(MenuConfigurationContext context)
        {
            var administrationMenuItem = context.Menu.GetAdministration();
            var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<UniappManagementResource>>();            //Add main menu items.

            var authorizationService = context.ServiceProvider.GetRequiredService<IAuthorizationService>();

            if (await authorizationService.IsGrantedAsync(UniappManagementPermissions.Uniapps.Default))
            {
                administrationMenuItem.AddItem(
                    new ApplicationMenuItem("Uniapp", l["Menu:Uniapp"], "/UniappManagement/Uniapps/Uniapp")
                );
            }
        }

Otherwise, too many menu items will cause trouble to the UI, Only a few cases require customization by developers to move out the module menu item.

CreateUpdateViewModel generation.

Most of entities need attributes to customize form, and the manual operation is troublesome.

We may need to generate CreateUpdateViewModel to replace CreateUpdateDto using in MVC UI modal, because the latter has more attributes for the abp dynamic form.

Maybe we should split CreateUpdateTodoDto to CreateTodoDto and UpdateTodoDto

Now it builds the CRUD class with a CreateUpdateTodoDto:

public class TodoAppService : CrudAppService<Todo, TodoDto, Guid, PagedAndSortedResultRequestDto,
            CreateUpdateTodoDto, CreateUpdateTodoDto>,
        ITodoAppService

When developers want a CreateTodoDto and a UpdateTodoDto, so they should delete CreateUpdateTodoDto, create those two new dtos, change ITodoAppService and TodoAppService and add them to automapper profile manually.

If we build both CreateTodoDto and UpdateTodoDto to replace CreateUpdateTodoDto by default, when developers want to combine them, they can just let CreateTodoDto inherit from UpdateTodoDto.

Entity class auto complete feature.

Developer create an entity without ctor:

    public class Todo : AggregateRoot<Guid>
    {
        public virtual string Content { get; protected set; }
        
        public virtual DateTime? DueTime { get; protected set; }
        
        public virtual bool IsDone { get; protected set; }
    }

When he use code generator, should we complete the ctor methods?

    public class Todo : AggregateRoot<Guid>
    {
        public virtual string Content { get; protected set; }
        
        public virtual DateTime? DueTime { get; protected set; }
        
        public virtual bool IsDone { get; protected set; }
        
        protected Todo() {}

        public Todo(
            Guid id,
            string content,
            DateTime? dueTime,
            bool isDone) : base(id)
        {
            Content = content;
            DueTime = dueTime;
            IsDone = isDone;
        }
    }

System.NotSupportedException: Unknown ABP project structure. Directory

[10:32:12 ERR] Error while invoking activity activity-5 of workflow 713380c7ffff471cb26237e68d68cf37
System.NotSupportedException: Unknown ABP project structure. Directory: D:\Work\Hd.StandardWork.Exec
at EasyAbp.AbpHelper.Steps.Abp.ProjectInfoProviderStep.OnExecuteAsync(WorkflowExecutionContext context, CancellationToken cancellationToken) in D:\Repos\EasyAbp\AbpHelper.CLI\src\AbpHelper\Steps\Abp\ProjectInfoProviderStep.cs:line 36
at Elsa.Services.ActivityInvoker.InvokeAsync(WorkflowExecutionContext workflowContext, IActivity activity, Func`2 invokeAction)

我是用abp 创建的模块,2.2.1版本的。

Maybe .sln is better than directory for code generation command.

Relate to: #19

Today the ABP CLI generate the .sln file in root directory for MVC template, but generate it in /aspnet-core directory for Angular template.
3E@$1LLUJ XNG64YS502NN2 image

Maybe we should use -s .sln instead of -d root-directory, reasons:

  1. Developers who use Angular may input the /aspnet-core directory before he know the mistake (For now the correct input is root directory). The .sln file scheme requires less learning costs.

  2. AbpHelper GUI will remember solution configurations, and one day maybe ABP CLI will optimize the directory structure, so there are two different structure that need to be adapted. But if we use .sln file to locating the solution, we will not care about this changing.

  3. ABP CLI also use .sln and .csproj, developers have experience. https://github.com/abpframework/abp/blob/dev/docs/en/CLI.md

CRUD permissions generation.

In CrudAppService we have GetPolicyName, GetListPolicyName, CreatePolicyName, UpdatePolicyName and DeletePolicyName, maybe the basic CRUD permissions should be generated.

fix: build failed in VS

build failed in VS with following error:

CS8630 Invalid 'nullable' value: 'Enable' for C# 7.3. Please use language version '8.0' or greater.

unless forcing the AbpHelper.csproj to use C# 8.0

<PropertyGroup>
   <LangVersion>8.0</LangVersion>
</PropertyGroup

Rollback mechanism for the code generator.

We need a way to rollback the code generated by the generator.

When the program runs in error, even the migration has been executed, we should rollback all the changes, or it will pollute the projects.

MVC UI Index.cshtml page generation improvement.

https://github.com/EasyAbp/AbpHelper.CLI/blob/develop/src/AbpHelper/Templates/Crud/Groups/UiRazor/src/%7B%7B%20ProjectInfo.FullName%20%7D%7D.Web/Pages/%7B%7B%20EntityInfo.NamespaceLastPart%20%7D%7D/%7B%7B%20EntityInfo.Name%20%7D%7D/Index.cshtml.sbntxt

Refer to: https://github.com/abpframework/abp/blob/dev/modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Roles/Index.cshtml

  1. Needs "PageLayout" generation: Title, BreadCrumb and MenuItemName configurations in PageLayout.Content.

  2. "<h2></h2>" should be "<abp-card-title></abp-card-title>".

  3. "size-md" should be _6 and _6.

  4. Creation button needs permission check. Relate to: #33 .

  5. "<abp-table>" may need class="nowrap".

Add `methods` sub command

will generate:

  • Contracts project
    • Method declaration in the specified service interface
    • Dto classes(Input and Output) in the Dtos folder
  • Application project
    • Empty method implementation in the specified service class

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.