SmartCode (Github.com/Ahoo-Wang/S…

SmartCode = IDataSource -> IBuildTask -> IOutput => Build Everything

Introduction

Smartcode.db (Code generator)

Demo

Getting Started

  1. Install from .NET Core Global Tool
dotnet tool install --global SmartCode.CLI
Copy the code
  1. Edit the build configuration file (default: smartcode.yml)
  2. Run the SmartCode command
    • SmartCode
    • Wait for a prompt to enter the configuration file path (Optional: Smartcode.yml file in the default program root directory)
    • Enter to execute the command
  3. Wait until the task is complete
  4. View the output directory result

Building a configuration file

Module: SmartSql.Starter
Author: Ahoo Wang
DataSource:
  Name: Db
  Paramters:
    DbName: SmartSqlStarterDB
    DbProvider: SqlServer
    ConnectionString: Data Source=.; Initial Catalog=SmartSqlStarterDB; Integrated Security=True
Language: CSharp
TemplateEngine: Razor 
Output: 
  Type: File
  Path: 'E://SmartSql-Starter'

# Build task
Build:
  ClearDir:
    Type: Clear
    Paramters:
      Dirs: '. '
  Solution:
    Type: Project
    Template: Sln.cshtml
    Output:
      Path: '. '
      Name: '{{Project.Module}}'
      Extension: '.sln'
  SmartSqlConfig:
    Type: Project
    Template: SqlMapConfig.cshtml
    Output:
      Path: '{{Project.Module}}.API'
      Name: 'SmartSqlMapConfig'
      Extension: '.xml'
  Entity_Project:
    Type: Project
    Template: Proj.cshtml
    Output:
      Path: '{{Project.Module}}.Entity'
      Name: '{{Project.Module}}.Entity'
      Extension: '.csproj'
  Entity:
    Type: Table
    Module: Entity
    Template: Entity.cshtml
    Output:
      Path: '{{Project.Module}}.{{Build.Module}}'
      Extension: '.cs'
    NamingConverter:
      Table:
        Tokenizer:
          Type: Default
          Paramters:
            IgnorePrefix: 'T_'
            Delimiter: '_'
        Converter:
          Type: Default
          Paramters: { }
      View:
        Tokenizer:
          Type: Default
          Paramters:
            IgnorePrefix: 'V_'
            Delimiter: '_'
        Converter:
          Type: Pascal
      Column:
        Tokenizer:
          Type: Default
          Paramters: 
            Delimiter: '_'
        Converter:
          Type: Pascal
  Repository_Project:
    Type: Project
    Template: Proj-Repository.cshtml
    Output:
      Path: '{{Project.Module}}.Repository'
      Name: '{{Project.Module}}.Repository'
      Extension: '.csproj'
  Repository:
    Type: Table
    Module: Repository
    Template: Repository.cshtml
    Output:
      Path: '{{Project.Module}}.{{Build.Module}}'
      Name: 'I{{OutputName}}Repository'
      Extension: .cs
    NamingConverter:
      Table:
        Tokenizer:
          Type: Default
          Paramters:
            IgnorePrefix: 'T_'
            Delimiter: '_'
        Converter:
          Type: Default
      View:
        Tokenizer:
          Type: Default
          Paramters: 
            IgnorePrefix: 'V_'
            Delimiter: '_'
        Converter:
          Type: Default

  SqlMap:
    Type: Table
    Template: SqlMap-SqlServer.cshtml
    Output:
      Path: '{{Project.Module}}.API/Maps'
      Extension: .xml
    IgnoreTables: null
    NamingConverter:
      Table:
        Tokenizer:
          Type: Default
          Paramters: 
            IgnorePrefix: 'T_'
            Delimiter: '_'
        Converter:
          Type: Default
      View:
        Tokenizer:
          Type: Default
          Paramters: 
            IgnorePrefix: 'V_'
            Delimiter: '_'
        Converter:
          Type: Default
      Column:
        Tokenizer:
          Type: Default
          Paramters: 
            IgnorePrefix: 'T_'
            Delimiter: '_'
        Converter:
          Type: Default
Copy the code
Parameter names instructions
Module The root module name
Author The author
DataSource The data source
Language Language: CSharp/Java /…
TemplateEngine Template engine: Currently built in: Razor/Handlebars
Output The output
Build Task Building S

DataSource DataSource, Name:Db

Attribute Name:Db, using the DbSource plug-in as the data source

Dbsource. Paramters takes the following three parameters:

Parameter names instructions
DbName Database name
DbProvider Data driven provider: MySql and MariaDB, PostgreSql, essentially, Oracle and SQLite
ConnectionString Connection string

Build tasks

Parameter names instructions
Type Build types,Clear: used to Clear directory S/file S,Project: used to build single files, such as solution files/Project files,Table: used to build data table-based files, such as Entity and Repository files
Module Building module name
TemplateEngine Template engine, optional, uses the root module engine by default
Template Template file
Output The output
IncludeTables Include table name S
IgnoreTables Ignore the table name s
NamingConverter Named converter
Paramters Customize build parameters

NamingConverter name conversion

attribute instructions
type Table/View/Column
Tokenizer Word segmentation is
Converter Converter: Camel/Pascal/None
NamingConverter. Tokenizer participle
attribute instructions
Type Default
Paramters.IgnorePrefix Ignore prefix characters
Paramters.Delimiter The separator
Paramters.UppercaseSplit Use uppercase separation, default: true