{"id":15039233,"url":"https://github.com/dotnetcore/smartcode","last_synced_at":"2025-04-13T05:08:41.640Z","repository":{"id":37824414,"uuid":"151589356","full_name":"dotnetcore/SmartCode","owner":"dotnetcore","description":"SmartCode = IDataSource -\u003e IBuildTask -\u003e IOutput =\u003e Build Everything!!!","archived":false,"fork":false,"pushed_at":"2023-12-15T11:57:13.000Z","size":4668,"stargazers_count":575,"open_issues_count":18,"forks_count":165,"subscribers_count":56,"default_branch":"master","last_synced_at":"2025-04-13T05:08:22.523Z","etag":null,"topics":["code-generator","dotnet","dotnet-core","dotnetcore","etl","smartcode"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotnetcore.png","metadata":{"files":{"readme":"README-EN.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"code-of-conduct.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-10-04T14:55:10.000Z","updated_at":"2025-03-30T09:56:57.000Z","dependencies_parsed_at":"2024-01-05T20:52:07.837Z","dependency_job_id":"9ab2bf18-ca19-4d8d-b99c-d01682542c78","html_url":"https://github.com/dotnetcore/SmartCode","commit_stats":null,"previous_names":["smart-kit/smartcode","ahoo-wang/smartcode"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FSmartCode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FSmartCode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FSmartCode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotnetcore%2FSmartCode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotnetcore","download_url":"https://codeload.github.com/dotnetcore/SmartCode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248665747,"owners_count":21142123,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generator","dotnet","dotnet-core","dotnetcore","etl","smartcode"],"created_at":"2024-09-24T20:42:03.081Z","updated_at":"2025-04-13T05:08:41.620Z","avatar_url":"https://github.com/dotnetcore.png","language":"C#","readme":"\u003cp align=\"center\"\u003e\n  \u003cimg width=\"100\"src=\"./doc/Logo.png\"/\u003e\n\u003c/p\u003e\n\n# SmartCode([Chinese Document](./README.md))\n\n\u003e SmartCode = IDataSource -\u003e IBuildTask -\u003e IOutput =\u003e Build Everything\n\n## Introduction\n\n![SmartCode](./doc/SmartCode-EN.png)\n\n## Nuget Packages\n\n| Package | NuGet Stable |  Downloads |\n| ------- | -------- | ------- |\n| [SmartCode.CLI](https://www.nuget.org/packages/SmartCode.CLI/) | [![SmartCode.CLI](https://img.shields.io/nuget/v/SmartCode.CLI.svg)](https://www.nuget.org/packages/SmartCode.CLI/)  | [![SmartCode.CLI](https://img.shields.io/nuget/dt/SmartCode.CLI.svg)](https://www.nuget.org/packages/SmartCode.CLI/) |\n\n## SmartCode.Generator (Code generator)\n\n### Demo\n\n![SmartCode](./doc/SmartCode-Db-1.gif)\n\n### Getting Started\n\n1. Install from .NET Core Global Tool  \n\n  ``` shell\n    dotnet tool install --global SmartCode.CLI\n  ```\n\n2. edit build configuration file (default: SmartCode.yml)\n3. the command line executes the SmartCode command.\n    - SmartCode\n    - wait for prompt to enter the configuration file path (optional: SmartCode.yml file in the default program root directory)\n    - carriage return execution command\n4. wait for the end of the task execution.\n5. View output directory results\n6. run the API project and debug with Swagger.\n\n### Building configuration files\n\n``` yml\nModule: SmartSql.Starter\nAuthor: Ahoo Wang\nDataSource:\n  Name: DbTable\n  Parameters:\n    DbName: SmartSqlTestDB\n    DbProvider: SqlServer\n    ConnectionString: Data Source=.;Initial Catalog=SmartSqlTestDB;Integrated Security=True\nLanguage: CSharp\nTemplateEngine: \n   Name: Razor\n   Root: CSharp\nOutput: \n  Type: File\n  Path: 'E:\\SmartSql-Starter'\nParameters:\n  SmartSqlVersion: '4.0.46'\n  SmartSqlSchemaVersion: '4.0.42'\n  BuildDir: 'E:\\SmartSql-Starter\\build'\n  DockerImage: 'smartsql.starter'\n  \nNamingConverter:\n  Table:\n    Tokenizer:\n      Type: Default\n      Parameters:\n        IgnorePrefix: 'T_'\n        Delimiter: '_'\n    Converter:\n      Type: Pascal\n      Parameters: { }\n  View:\n    Tokenizer:\n      Type: Default\n      Parameters:\n        IgnorePrefix: 'V_'\n        Delimiter: '_'\n    Converter:\n      Type: Pascal\n  Column:\n    Tokenizer:\n      Type: Default\n      Parameters:\n        Delimiter: '_'\n    Converter:\n      Type: Pascal\n\n# 构建任务\nBuild:\n\n#  ClearDir:\n#    Type: Clear\n#    Parameters:\n#      Dirs: '.'\n\n  MakeBuildDir:\n    Type: Process\n    Parameters:\n      FileName: powershell\n      Args: mkdir '{{Project.Parameters.BuildDir}}'\n  Copy:\n    Type: Process\n    Parameters:\n      FileName: powershell\n      Args:  cp '{{Project.ConfigPath}}' '{{Project.Parameters.BuildDir}}'\n\n  Scaffolding:\n    Type: MultiTemplate\n    Output: \n      Path: '.'\n    Parameters:\n      Templates: [{Key: 'Sln.cshtml',Output: {Name: '{{Project.Module}}',Extension: '.sln'}},\n        {Key: 'Sln-Directory.Build.cshtml',Output: {Name: 'Directory.Build',Extension: '.props'}},\n        {Key: 'Sln-Version.cshtml',Output: {Path: 'build',Name: 'version',Extension: '.props'}},\n        {Key: 'Sln-Dockerfile.cshtml',Output: {Name: 'Dockerfile',Extension: ''}},\n        {Key: 'Sln-DockerIgnore.cshtml',Output: {Name: '.dockerignore',Extension: ''}},\n        {Key: 'Sln-GitIgnore.cshtml',Output: {Name: '.gitignore',Extension: ''}},\n        {Key: \"Proj-Entity.cshtml\",Output: {Path: 'src/{{Project.Module}}.Entity',Name: '{{Project.Module}}.Entity',Extension: '.csproj'}},\n        {Key: \"Proj-Repository.cshtml\",Output: {Path: 'src/{{Project.Module}}.Repository',Name: '{{Project.Module}}.Repository',Extension: '.csproj'}},\n        {Key: \"Proj-Service.cshtml\",Output: {Path: 'src/{{Project.Module}}.Service',Name: '{{Project.Module}}.Service',Extension: '.csproj'}},\n        {Key: \"Proj-API.cshtml\",Output: {Path: 'src/{{Project.Module}}.API',Name: '{{Project.Module}}.API',Extension: '.csproj'}},\n        {Key: \"API/LaunchSettings.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Properties',Name: 'launchSettings',Extension: '.json'}},\n        {Key: \"API/AppSettings.cshtml\",Output: {Path: 'src/{{Project.Module}}.API',Name: 'appsettings',Extension: '.json'}},\n        {Key: \"API/AppSettings-Development.cshtml\",Output: {Path: 'src/{{Project.Module}}.API',Name: 'appsettings.Development',Extension: '.json'}},\n        {Key: \"API/Program.cshtml\",Output: {Path: 'src/{{Project.Module}}.API',Name: 'Program',Extension: '.cs'}},\n        {Key: \"API/Startup.cshtml\",Output: {Path: 'src/{{Project.Module}}.API',Name: 'Startup',Extension: '.cs'}},\n        {Key: \"API/APIException.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Exceptions',Name: 'APIException',Extension: '.cs'}},\n        {Key: \"API/GlobalExceptionFilter.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Filters',Name: 'GlobalExceptionFilter',Extension: '.cs'}},\n        {Key: \"API/GlobalValidateModelFilter.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Filters',Name: 'GlobalValidateModelFilter',Extension: '.cs'}},\n        {Key: \"API/QueryRequest.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Messages',Name: 'QueryRequest',Extension: '.cs'}},\n        {Key: \"API/QueryByPageRequest.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Messages',Name: 'QueryByPageRequest',Extension: '.cs'}},\n        {Key: \"API/ResponseMessage.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Messages',Name: 'ResponseMessage',Extension: '.cs'}},\n        {Key: \"API/QueryResponse.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Messages',Name: 'QueryResponse',Extension: '.cs'}},\n        {Key: \"API/QueryByPageResponse.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Messages',Name: 'QueryByPageResponse',Extension: '.cs'}},\n        {Key: \"API/ResponseMessage.cshtml\",Output: {Path: 'src/{{Project.Module}}.API/Messages',Name: 'ResponseMessage',Extension: '.cs'}},\n        {Key: \"SqlMapConfig.cshtml\",Output: {Path: 'src/{{Project.Module}}.Repository',Name: 'SmartSqlMapConfig',Extension: '.xml'}},\n        {Key: \"SqlMapConfig.cshtml\",Output: {Path: 'src/{{Project.Module}}.Repository',Name: 'SmartSqlMapConfig.Development',Extension: '.xml'}}]\n\n  Entity:\n    Type: Table\n    Module: Entity\n    TemplateEngine: \n      Path: Entity.cshtml\n    Output: \n      Path: 'src/{{Project.Module}}.{{Build.Module}}'\n      Name: '{{Items.CurrentTable.ConvertedName}}'\n      Extension: '.cs'\n\n  Repository:\n    Type: Table\n    Module: Repository\n    TemplateEngine: \n      Path: Repository.cshtml\n    IgnoreNoPKTable: true\n    IgnoreView: true\n    Output: \n      Path: 'src/{{Project.Module}}.{{Build.Module}}'\n      Name: 'I{{Items.CurrentTable.ConvertedName}}Repository'\n      Extension: .cs\n\n  Service:\n    Type: Table\n    Module: Service\n    TemplateEngine: \n      Path: Service.cshtml\n    IgnoreNoPKTable: true\n    IgnoreView: true\n    Output: \n      Path: 'src/{{Project.Module}}.{{Build.Module}}'\n      Name: '{{Items.CurrentTable.ConvertedName}}Service'\n      Extension: .cs\n\n  APIController:\n    Type: Table\n    Module: API\n    TemplateEngine: \n      Path: API/APIController.cshtml\n    IgnoreNoPKTable: true\n    IgnoreView: true\n    Output: \n      Path: 'src/{{Project.Module}}.{{Build.Module}}/Controllers'\n      Name: '{{Items.CurrentTable.ConvertedName}}Controller'\n      Extension: .cs\n\n  SqlMap:\n    Type: Table\n    TemplateEngine: \n      Path: SqlMap.cshtml\n    Output: \n      Path: 'src/{{Project.Module}}.Repository/Maps'\n      Name: '{{Items.CurrentTable.ConvertedName}}'\n      Extension: .xml\n    IgnoreNoPKTable: true\n    IgnoreView: true\n\n# Please install dotnet-format first!\n# dotnet tool install -g dotnet-format\n  CodeFormat:\n    Type: Process\n    Parameters:\n      FileName: powershell\n      WorkingDirectory: '{{Project.Output.Path}}'\n      Args: dotnet-format\n\n  ReStore:\n    Type: Process\n    Parameters: \n      FileName: powershell\n      WorkingDirectory: '{{Project.Output.Path}}'\n      Args: dotnet restore\n\n#  BuildDocker:\n#    Type: Process\n#    Parameters: \n#      FileName: powershell\n#      WorkingDirectory: '{{Project.Output.Path}}'\n#      Args: docker build -t {{Project.Parameters.DockerImage}}:v1.0.0 .\n\n#  RunDocker:\n#    Type: Process\n#    Parameters: \n#      FileName: powershell\n#      WorkingDirectory: '{{Project.Output.Path}}'\n#      Args: docker run --name {{Project.Parameters.DockerImage}} --rm -d -p 8008:80 {{Project.Parameters.DockerImage}}:v1.0.0 .\n\n#  Publish:\n#    Type: Process\n#    Parameters: \n#      FileName: powershell\n#      WorkingDirectory: '{{Project.Output.Path}}'\n#      Args: dotnet publish -c Release -o '{{Project.Output.Path}}\\publish'\n\n#  Run:\n#    Type: Process\n#    Parameters: \n#      FileName: powershell\n#      WorkingDirectory: '{{Project.Output.Path}}\\publish'\n#      CreateNoWindow: false\n#      RedirectStandardOutput: false\n#      RedirectStandardError: false\n#      WaitForExit: false\n#      WriteLines: ['dotnet {{Project.Module}}.API.dll']\n\n#  RunChrome:\n#    Type: Process\n#    Parameters: \n#      FileName: C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe\n#      CreateNoWindow: false\n#      Args: http://localhost:8008/swagger\n```\n\n### Build file parameter overview\n\n| Parameter Name | Description |\n| :--------- | --------:|\n| Module | Root Module Name |\n| Author | Author |\n| DataSource | Data Source |\n| Language | Language: CSharp/Java/.... |\n| TemplateEngine | Template Engine: Currently Built: Razor/Handlebars |\n| Output | Output |\n| Build | Task Build |\n\n#### DataSource Data Source, Name: DbTable\n\n\u003e Property Name: DbTable, using the DbTableSource plugin as a data source\n\nDbTableSource.Parameters accepts the following three parameters:\n\n| Parameter Name | Description |\n| :--------- | --------:|\n| DbName | Database Name |\n| DbProvider | Data Drivers: MySql, MariaDB, PostgreSql, SqlServer, Oracle, SQLite |\n| ConnectionString | Connection String |\n\n#### Build Task Build\n\n| Parameter Name | Description |\n| :--------- | --------:|\n| Type | Build type, Clear: used to clean up the directory s / file s, Project: used to build a single file, such as: solution file / project file, Table: used to build a data table-based file, such as: Entity , Repository file|\n| Module | Building Module Name |\n| TemplateEngine | Template Engine, optional, default to root module engine |\n| Template | Template File |\n| Output | Output |\n| IgnoreNoPKTable | Ignore no PK Table |\n| IgnoreView | Ignore view |\n| IncludeTables | Include table name s |\n| IgnoreTables | Ignore table name s |\n| NamingConverter | Named Converter |\n| Parameters | Custom Build Parameters |\n\n#### NamingConverter Name Conversion\n\n| Attribute | Description |\n| :--------- | --------:|\n| Type | Table/View/Column |\n| Tokenizer | Word Segmenter |\n| Converter | Converter: Camel/Pascal/None |\n\n##### NamingConverter.Tokenizer Word Segmenter\n\n| Attribute | Description |\n| :--------- | --------:|\n| Type | Default |\n| Parameters.IgnorePrefix | Ignore prefix characters |\n| Parameters.Delimiter | Separator |\n| Parameters.UppercaseSplit | Using uppercase separation, default: true |\n\n### How to contribute a template\n\n\u003eIn order to allow more people to participate in the construction of SmartCode templates, there are the following template specifications:\n\n1. The template author creates a new directory in src/SmartCode.Generator/RazorTemplates and names it in the author's English name.\n2. Place the template in the author directory\n3. The README.md file must be included in the author directory to illustrate the purpose of the template and how it is used.\n4. Submit PR\n\n## SmartCode.ETL(Extract-Transform-Load)\n\n### ETL Building configuration files\n\n``` yml\nAuthor: Ahoo Wang\nDataSource:\n  Name: Extract\n  Parameters:\n    DbProvider: SqlServer\n    ConnectionString: Data Source=.;Initial Catalog=SmartSqlDB;Integrated Security=True\n    Query: SELECT [Id],[UserName],[Pwd],[Status],[LastLoginTime],[CreationTime],[Deleted] FROM [T_User] Where Id\u003e@LastMaxId And CreationTime\u003e@LastQueryTime\n    PKColumn: Id\n\nParameters:\n  ETLCode: SmartCode.ETL.Test\n  ETLRepository: PG\n  \nBuild:\n\n  Transform:\n    Type: Transform\n    Parameters:\n      Script: Load2PostgreSql.cshtml\n\n  Load2PostgreSql: \n    Type: Load\n    Parameters:\n      DbProvider: PostgreSql\n      ConnectionString: Server=localhost;Port=5432;User Id=postgres;Password=SmartSql; Database=smartsql_db;\n      Table: t_user\n      ColumnMapping: [{Column: UserName,Mapping: user_name}\n      ,{Column: Pwd,Mapping: pwd}\n      ,{Column: Status,Mapping: status}\n      ,{Column: LastLoginTime,Mapping: lastlogintime}\n      ,{Column: CreationTime,Mapping: creationtime}\n      ,{Column: Deleted,Mapping: deleted}]\n      PreCommand: \n      PostCommand: \n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnetcore%2Fsmartcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotnetcore%2Fsmartcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotnetcore%2Fsmartcode/lists"}