├── .gitattributes
├── common.props
├── src
├── AbpVnextPro.GUI.Domain
│ ├── AbpVnextProGUIDomainModule.cs
│ ├── AbpVnextPro.GUI.Domain.csproj
│ ├── Replaces
│ │ ├── ReplaceConsts.cs
│ │ ├── Extensions
│ │ │ └── ReplaceExtension.cs
│ │ └── ReplaceManager.cs
│ ├── Exceptions
│ │ ├── DownSourceCodeException.cs
│ │ ├── ZipException.cs
│ │ └── GenerateTemplateException.cs
│ ├── Zips
│ │ └── ZipManager.cs
│ └── Githubs
│ │ └── GithubManager.cs
├── AbpVnextPro.GUI
│ ├── appsettings.json
│ ├── HelloWorldService.cs
│ ├── App.xaml
│ ├── AssemblyInfo.cs
│ ├── GUIModule.cs
│ ├── AbpVnextPro.GUI.csproj
│ ├── MainWindow.xaml
│ ├── App.xaml.cs
│ └── MainWindow.xaml.cs
└── AbpVnextPro.GUI.ApplicationService
│ ├── AbpVnextPro.GUI.ApplicationService.csproj
│ ├── AbpVnextProGUIApplicationService.cs
│ └── Generates
│ └── GenerateAppService.cs
├── AbpVnextPro.GUI.sln
└── .gitignore
/.gitattributes:
--------------------------------------------------------------------------------
1 | **/wwwroot/libs/** linguist-vendored
2 |
--------------------------------------------------------------------------------
/common.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | latest
4 | 0.1.0
5 | $(NoWarn);CS1591;CS0436
6 |
7 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/AbpVnextProGUIDomainModule.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Volo.Abp.Modularity;
3 |
4 | namespace AbpVnextPro.GUI.Domain
5 | {
6 | public class AbpVnextProGUIDomainModule : AbpModule
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Github": {
3 | "AbpVnextPro": {
4 | "Author": "WangJunZzz",
5 | "RepsotiryName": "abp-vnext-pro"
6 | }
7 | },
8 | "CompanyName": "CompanyName",
9 | "ProjectName": "ProjectName"
10 | }
11 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/HelloWorldService.cs:
--------------------------------------------------------------------------------
1 | using Volo.Abp.DependencyInjection;
2 |
3 | namespace AbpVnextPro.GUI
4 | {
5 | public class HelloWorldService : ITransientDependency
6 | {
7 | public string SayHello()
8 | {
9 | return "Hello world!";
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/App.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.ApplicationService/AbpVnextPro.GUI.ApplicationService.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/AbpVnextPro.GUI.Domain.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net5.0
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Replaces/ReplaceConsts.cs:
--------------------------------------------------------------------------------
1 | namespace AbpVnextPro.GUI.Domain.Replaces
2 | {
3 | public class ReplaceConsts
4 | {
5 | public const string OldCompanyName = "Lion";
6 | public const string OldProjectName = "AbpPro";
7 | ///
8 | /// 后台服务需替换的文件后缀
9 | ///
10 | public const string FileFilter = ".sln,.csproj,.cs,.cshtml,.json,.ci,.yml,.yaml,.nswag,.DotSettings,.env";
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.ApplicationService/AbpVnextProGUIApplicationService.cs:
--------------------------------------------------------------------------------
1 | using AbpVnextPro.GUI.Domain;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Volo.Abp.Modularity;
8 |
9 | namespace AbpVnextPro.GUI.ApplicationService
10 | {
11 | [DependsOn(typeof(AbpVnextProGUIDomainModule))]
12 | public class AbpVnextProGUIApplicationService:AbpModule
13 | {
14 |
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
5 | //(used if a resource is not found in the page,
6 | // or application resource dictionaries)
7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
8 | //(used if a resource is not found in the page,
9 | // app, or any theme specific resource dictionaries)
10 | )]
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/GUIModule.cs:
--------------------------------------------------------------------------------
1 | using AbpVnextPro.GUI.ApplicationService;
2 | using Microsoft.Extensions.DependencyInjection;
3 | using Volo.Abp.Autofac;
4 | using Volo.Abp.Modularity;
5 |
6 | namespace AbpVnextPro.GUI
7 | {
8 | [DependsOn(
9 | typeof(AbpAutofacModule),
10 | typeof(AbpVnextProGUIApplicationService))]
11 | public class GUIModule : AbpModule
12 | {
13 | public override void ConfigureServices(ServiceConfigurationContext context)
14 | {
15 | context.Services.AddSingleton();
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Replaces/Extensions/ReplaceExtension.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AbpVnextPro.GUI.Domain.Replaces.Extensions
8 | {
9 | public static class ReplaceExtension
10 | {
11 | public static string CustomReplace(this string content,string companyName,string projectName)
12 | {
13 | var result = content
14 | .Replace(ReplaceConsts.OldCompanyName, companyName)
15 | .Replace(ReplaceConsts.OldProjectName, projectName)
16 | ;
17 |
18 | return result;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Exceptions/DownSourceCodeException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.Serialization;
3 |
4 | namespace AbpVnextPro.GUI.Domain.Exceptions
5 | {
6 | public class DownSourceCodeException : Exception
7 | {
8 | public DownSourceCodeException()
9 | {
10 | }
11 |
12 | public DownSourceCodeException(string message) : base(message)
13 | {
14 | }
15 |
16 | public DownSourceCodeException(string message, Exception innerException) : base(message, innerException)
17 | {
18 | }
19 |
20 | protected DownSourceCodeException(SerializationInfo info, StreamingContext context) : base(info, context)
21 | {
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Exceptions/ZipException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AbpVnextPro.GUI.Domain.Exceptions
9 | {
10 | public class ZipException : Exception
11 | {
12 | public ZipException()
13 | {
14 | }
15 |
16 | public ZipException(string message) : base(message)
17 | {
18 | }
19 |
20 | public ZipException(string message, Exception innerException) : base(message, innerException)
21 | {
22 | }
23 |
24 | protected ZipException(SerializationInfo info, StreamingContext context) : base(info, context)
25 | {
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Exceptions/GenerateTemplateException.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.Serialization;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace AbpVnextPro.GUI.Domain.Exceptions
9 | {
10 | public class GenerateTemplateException : Exception
11 | {
12 | public GenerateTemplateException()
13 | {
14 | }
15 |
16 | public GenerateTemplateException(string message) : base(message)
17 | {
18 | }
19 |
20 | public GenerateTemplateException(string message, Exception innerException) : base(message, innerException)
21 | {
22 | }
23 |
24 | protected GenerateTemplateException(SerializationInfo info, StreamingContext context) : base(info, context)
25 | {
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/AbpVnextPro.GUI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | WinExe
7 | net5.0-windows
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | Always
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Zips/ZipManager.cs:
--------------------------------------------------------------------------------
1 | using AbpVnextPro.GUI.Domain.Exceptions;
2 | using System;
3 | using System.IO;
4 | using System.IO.Compression;
5 | using Volo.Abp.DependencyInjection;
6 |
7 | namespace AbpVnextPro.GUI.Domain.Zips
8 | {
9 | public class ZipManager : ISingletonDependency
10 | {
11 | public string ExtractZips(string sourceZipFullPath, string commpanyName, string projectName)
12 | {
13 | try
14 | {
15 | var path = Path.Combine(Directory.GetCurrentDirectory(), "code",commpanyName+projectName);
16 | if (!Directory.Exists(path))
17 | {
18 | Directory.CreateDirectory(path);
19 | }
20 | var decompressionPath = Path.Combine(path, Path.GetFileNameWithoutExtension(sourceZipFullPath));
21 | if (Directory.Exists(decompressionPath)) return decompressionPath;
22 | ZipFile.ExtractToDirectory(sourceZipFullPath, path);
23 | return decompressionPath;
24 | }
25 | catch (Exception ex)
26 | {
27 | throw new ZipException($"{DateTime.Now.ToString() }解压源码失败:{ex.Message}");
28 | }
29 |
30 | }
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.ApplicationService/Generates/GenerateAppService.cs:
--------------------------------------------------------------------------------
1 | using AbpVnextPro.GUI.Domain.Githubs;
2 | using AbpVnextPro.GUI.Domain.Replaces;
3 | using AbpVnextPro.GUI.Domain.Zips;
4 | using System;
5 | using System.Collections.Generic;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using Volo.Abp.DependencyInjection;
11 |
12 | namespace AbpVnextPro.GUI.ApplicationService.Generates
13 | {
14 | public class GenerateAppService : ITransientDependency
15 | {
16 | public readonly GithubManager _githubManager;
17 | private readonly ZipManager _zipManager;
18 | private readonly ReplaceManager _replaceManager;
19 | public GenerateAppService(GithubManager githubManager, ZipManager zipManager, ReplaceManager replaceManager)
20 | {
21 | _githubManager = githubManager;
22 | _zipManager = zipManager;
23 | _replaceManager = replaceManager;
24 | }
25 |
26 |
27 | public async Task DownloadSourceAsync(string type)
28 | {
29 | return await _githubManager.GetSourceCodeAsync(type);
30 | }
31 |
32 | public string ExtractZips(string path,string commpanyName,string projectName)
33 | {
34 | return _zipManager.ExtractZips(path, commpanyName, projectName);
35 | }
36 |
37 | public void GenerateTemplate(string path, string companyName, string projectName)
38 | {
39 | _replaceManager.ReplaceTemplates(path, companyName, projectName);
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Configuration;
4 | using System.Data;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using Microsoft.Extensions.DependencyInjection;
9 | using Microsoft.Extensions.Hosting;
10 | using Serilog;
11 | using Serilog.Events;
12 | using Volo.Abp;
13 |
14 | namespace AbpVnextPro.GUI
15 | {
16 | ///
17 | /// Interaction logic for App.xaml
18 | ///
19 | public partial class App : Application
20 | {
21 | private readonly IHost _host;
22 | private readonly IAbpApplicationWithExternalServiceProvider _application;
23 |
24 | public App()
25 | {
26 | _host = Host
27 | .CreateDefaultBuilder(null)
28 | .UseAutofac()
29 | .UseSerilog()
30 | .ConfigureServices((hostContext, services) =>
31 | {
32 | services.AddApplication();
33 | }).Build();
34 | _application = _host.Services.GetService();
35 | }
36 |
37 | protected async override void OnStartup(StartupEventArgs e)
38 | {
39 | Log.Logger = new LoggerConfiguration()
40 | #if DEBUG
41 | .MinimumLevel.Debug()
42 | #else
43 | .MinimumLevel.Information()
44 | #endif
45 | .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
46 | .Enrich.FromLogContext()
47 | .WriteTo.Async(c => c.File("Logs/logs.txt"))
48 | .CreateLogger();
49 |
50 | try
51 | {
52 | Log.Information("Starting WPF host.");
53 | await _host.StartAsync();
54 | Initialize(_host.Services);
55 |
56 | _host.Services.GetService()?.Show();
57 |
58 | }
59 | catch (Exception ex)
60 | {
61 | Log.Fatal(ex, "Host terminated unexpectedly!");
62 | }
63 | finally
64 | {
65 | Log.CloseAndFlush();
66 | }
67 | }
68 |
69 | protected async override void OnExit(ExitEventArgs e)
70 | {
71 | _application.Shutdown();
72 | await _host.StopAsync();
73 | _host.Dispose();
74 | }
75 |
76 | private void Initialize(IServiceProvider serviceProvider)
77 | {
78 | _application.Initialize(serviceProvider);
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/AbpVnextPro.GUI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31105.61
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AbpVnextPro.GUI", "src\AbpVnextPro.GUI\AbpVnextPro.GUI.csproj", "{7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}"
7 | EndProject
8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{25D4C66E-2173-478D-ABBE-0E9FC0E93B57}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbpVnextPro.GUI.Domain", "src\AbpVnextPro.GUI.Domain\AbpVnextPro.GUI.Domain.csproj", "{8F304FEF-26BA-4268-A446-E3730D3F6C25}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbpVnextPro.GUI.ApplicationService", "src\AbpVnextPro.GUI.ApplicationService\AbpVnextPro.GUI.ApplicationService.csproj", "{B9113FD9-0307-4CC9-B74B-878C97547582}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Release|Any CPU = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF}.Release|Any CPU.Build.0 = Release|Any CPU
24 | {8F304FEF-26BA-4268-A446-E3730D3F6C25}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
25 | {8F304FEF-26BA-4268-A446-E3730D3F6C25}.Debug|Any CPU.Build.0 = Debug|Any CPU
26 | {8F304FEF-26BA-4268-A446-E3730D3F6C25}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {8F304FEF-26BA-4268-A446-E3730D3F6C25}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {B9113FD9-0307-4CC9-B74B-878C97547582}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29 | {B9113FD9-0307-4CC9-B74B-878C97547582}.Debug|Any CPU.Build.0 = Debug|Any CPU
30 | {B9113FD9-0307-4CC9-B74B-878C97547582}.Release|Any CPU.ActiveCfg = Release|Any CPU
31 | {B9113FD9-0307-4CC9-B74B-878C97547582}.Release|Any CPU.Build.0 = Release|Any CPU
32 | EndGlobalSection
33 | GlobalSection(SolutionProperties) = preSolution
34 | HideSolutionNode = FALSE
35 | EndGlobalSection
36 | GlobalSection(NestedProjects) = preSolution
37 | {7CC4F9BA-520E-4D2E-92A5-8B91BFA08CBF} = {25D4C66E-2173-478D-ABBE-0E9FC0E93B57}
38 | {8F304FEF-26BA-4268-A446-E3730D3F6C25} = {25D4C66E-2173-478D-ABBE-0E9FC0E93B57}
39 | {B9113FD9-0307-4CC9-B74B-878C97547582} = {25D4C66E-2173-478D-ABBE-0E9FC0E93B57}
40 | EndGlobalSection
41 | GlobalSection(ExtensibilityGlobals) = postSolution
42 | SolutionGuid = {1F6059C0-9B13-47D6-A3FA-7A8A485FB299}
43 | EndGlobalSection
44 | EndGlobal
45 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Githubs/GithubManager.cs:
--------------------------------------------------------------------------------
1 | using AbpVnextPro.GUI.Domain.Exceptions;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.Logging;
4 | using Octokit;
5 | using System;
6 | using System.IO;
7 | using System.Net.Http;
8 | using System.Threading.Tasks;
9 | using Volo.Abp.DependencyInjection;
10 | using System.Linq;
11 |
12 | namespace AbpVnextPro.GUI.Domain.Githubs
13 | {
14 | public class GithubManager : ITransientDependency
15 | {
16 | //private string Owner = "WangJunZzz";
17 | //private string RepsotiryName = "abp-vnext-module-template";
18 | private readonly IConfiguration _configuration;
19 |
20 | public GithubManager(IConfiguration configuration)
21 | {
22 | _configuration = configuration;
23 | }
24 |
25 | public async Task GetSourceCodeAsync(string type)
26 | {
27 | try
28 | {
29 | var repsotiryName = _configuration.GetValue("Github:AbpVnextPro:RepsotiryName");
30 | var author = _configuration.GetValue("Github:AbpVnextPro:Author");
31 | var resease = await GetLastReleaseInfoAsync(repsotiryName,author);
32 | var path = Path.Combine(Directory.GetCurrentDirectory(), "source");
33 | if (!Directory.Exists(path))
34 | {
35 | Directory.CreateDirectory(path);
36 | }
37 | var outputFullPath = Path.Combine(path, $"{repsotiryName}-{resease.TagName}.zip");
38 | if (File.Exists(outputFullPath)) return outputFullPath;
39 | var uri = new Uri($"https://github.com/{author}/{repsotiryName}/archive/refs/tags/{resease.TagName}.zip");
40 | await DownloadReleaseAsync(uri, Path.Combine(path, outputFullPath));
41 | return outputFullPath;
42 | }
43 | catch (Exception ex)
44 | {
45 | throw new DownSourceCodeException($"{DateTime.Now.ToString() }下载源码失败:{ex.Message}");
46 | }
47 | }
48 |
49 | ///
50 | /// 获取最后一个Release信息
51 | ///
52 | ///
53 | private Task GetLastReleaseInfoAsync(string repsotiryName,string author)
54 | {
55 | var github = new GitHubClient(new ProductHeaderValue(repsotiryName));
56 | return github.Repository.Release.GetLatest(author, repsotiryName);
57 |
58 | }
59 |
60 | ///
61 | /// 下载源码
62 | ///
63 | ///
64 | ///
65 | ///
66 | private async Task DownloadReleaseAsync(Uri uri, string SourceZipFullPath)
67 | {
68 | using (var httpClient = new HttpClient())
69 | {
70 | var response = await httpClient.GetAsync(uri);
71 | response.EnsureSuccessStatusCode();
72 |
73 | using (FileStream fileStream = new FileStream(SourceZipFullPath, System.IO.FileMode.Create, FileAccess.Write, FileShare.None))
74 | {
75 | await response.Content.CopyToAsync(fileStream);
76 | }
77 | }
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using AbpVnextPro.GUI.ApplicationService.Generates;
2 | using AbpVnextPro.GUI.Domain;
3 | using AbpVnextPro.GUI.Domain.Exceptions;
4 | using Microsoft.Extensions.Configuration;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Diagnostics;
8 | using System.IO;
9 | using System.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 | using System.Windows;
13 | using System.Windows.Controls;
14 | using System.Windows.Data;
15 | using System.Windows.Documents;
16 | using System.Windows.Input;
17 | using System.Windows.Media;
18 | using System.Windows.Media.Imaging;
19 | using System.Windows.Navigation;
20 | using System.Windows.Shapes;
21 |
22 | namespace AbpVnextPro.GUI
23 | {
24 | ///
25 | /// Interaction logic for MainWindow.xaml
26 | ///
27 | public partial class MainWindow : Window
28 | {
29 | private readonly GenerateAppService _generateAppService;
30 |
31 |
32 | public MainWindow(GenerateAppService generateAppService)
33 | {
34 | InitializeComponent();
35 | _generateAppService = generateAppService;
36 |
37 | }
38 |
39 | protected override void OnContentRendered(EventArgs e)
40 | {
41 | var defaultSelected = "AbpVnextPro";
42 | this.Source.Items.Add(defaultSelected);
43 | this.Source.SelectedItem = defaultSelected;
44 | this.Logs.Text += $"{DateTime.Now.ToString() } 解决方案名称:CompanyName.ProjectName \r\n";
45 | }
46 |
47 | private async void Button_Click(object sender, RoutedEventArgs e)
48 | {
49 | try
50 | {
51 | this.Logs.Text += $"{DateTime.Now.ToString() } 代码已经生成在 {Directory.GetCurrentDirectory()} \r\n";
52 | if (string.IsNullOrWhiteSpace(this.CompanyName.Text))
53 | {
54 | this.Logs.Text += $"{DateTime.Now.ToString() } 请输入CompanyName....... \r\n";
55 |
56 | return;
57 | }
58 | if (string.IsNullOrWhiteSpace(this.ProjectName.Text))
59 | {
60 | this.Logs.Text += $"{DateTime.Now.ToString() } 请输入ProjectName....... \r\n";
61 | return;
62 | }
63 |
64 |
65 | this.Logs.Text += $"{DateTime.Now.ToString() } 开始下载 {this.Source.Text}....... \r\n";
66 | var sourcePath = await _generateAppService.DownloadSourceAsync(this.Source.Text);
67 | this.Logs.Text += $"{DateTime.Now.ToString() } Abp-Vnext-Pro下载完成. \r\n";
68 |
69 | this.Logs.Text += $"{DateTime.Now.ToString() } 开始解压 {this.Source.Text}....... \r\n";
70 | var zipPath = _generateAppService.ExtractZips(sourcePath, this.CompanyName.Text.Trim(), this.ProjectName.Text.Trim());
71 | this.Logs.Text += $"{DateTime.Now.ToString() } 解压 {this.Source.Text} 完成. \r\n";
72 |
73 | this.Logs.Text += $"{DateTime.Now.ToString() } 开始生成 {this.Source.Text} 模板....... \r\n";
74 | _generateAppService.GenerateTemplate(zipPath, this.CompanyName.Text.Trim(), this.ProjectName.Text.Trim());
75 | this.Logs.Text += $"{DateTime.Now.ToString() } {this.Source.Text} 模板生成成功. \r\n";
76 | this.Logs.Text+= $"{DateTime.Now.ToString() } 代码已经生成在 {Directory.GetCurrentDirectory()}\\code下 \r\n";
77 |
78 | Process.Start("explorer.exe", $"{Directory.GetCurrentDirectory()}\\code");
79 |
80 | }
81 | catch (Exception ex)
82 | {
83 | this.Logs.Text += ex.Message;
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/AbpVnextPro.GUI.Domain/Replaces/ReplaceManager.cs:
--------------------------------------------------------------------------------
1 | using AbpVnextPro.GUI.Domain.Exceptions;
2 | using AbpVnextPro.GUI.Domain.Replaces.Extensions;
3 | using System;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using Volo.Abp.DependencyInjection;
8 |
9 | namespace AbpVnextPro.GUI.Domain.Replaces
10 | {
11 | public class ReplaceManager : ISingletonDependency
12 | {
13 |
14 | public void ReplaceTemplates(string sourcePath, string companyName, string projectName)
15 | {
16 | try
17 | {
18 | RenameTemplate(sourcePath, companyName, projectName);
19 | }
20 | catch (Exception ex)
21 | {
22 | throw new GenerateTemplateException($"{DateTime.Now.ToString() }生成模板失败:{ex.Message}");
23 | }
24 | }
25 |
26 | ///
27 | /// 重命名所有文件夹
28 | ///
29 | private void RenameTemplate(string sourcePath, string companyName, string projectName)
30 | {
31 | RenameAllDirectories(sourcePath, companyName, projectName);
32 | RenameAllFileNameAndContent(sourcePath, companyName, projectName);
33 | }
34 |
35 | private void RenameAllDirectories(string sourcePath, string companyName, string projectName)
36 | {
37 | var directories = Directory.GetDirectories(sourcePath);
38 | foreach (var subDirectory in directories)
39 | {
40 | RenameAllDirectories(subDirectory, companyName, projectName);
41 |
42 | var directoryInfo = new DirectoryInfo(subDirectory);
43 | if (directoryInfo.Name.Contains(ReplaceConsts.OldCompanyName) ||
44 | directoryInfo.Name.Contains(ReplaceConsts.OldProjectName))
45 | {
46 | var oldDirectoryName = directoryInfo.Name;
47 | var newDirectoryName = oldDirectoryName.CustomReplace(companyName, projectName);
48 |
49 | var newDirectoryPath = Path.Combine(directoryInfo.Parent?.FullName, newDirectoryName);
50 |
51 | if (directoryInfo.FullName != newDirectoryPath)
52 | {
53 | directoryInfo.MoveTo(newDirectoryPath);
54 | }
55 | }
56 | }
57 | }
58 | private void RenameAllFileNameAndContent(string sourcePath, string companyName, string projectName)
59 | {
60 | var list = new DirectoryInfo(sourcePath)
61 | .GetFiles()
62 | .Where(f => ReplaceConsts.FileFilter.Contains(f.Extension))
63 | .ToList();
64 |
65 | var encoding = new UTF8Encoding(false);
66 | foreach (var fileInfo in list)
67 | {
68 | // 改文件内容
69 | var oldContents = File.ReadAllText(fileInfo.FullName, encoding);
70 | var newContents = oldContents.CustomReplace(companyName, projectName);
71 |
72 | // 文件名包含模板关键字
73 | if (fileInfo.Name.Contains(ReplaceConsts.OldCompanyName)
74 | || fileInfo.Name.Contains(ReplaceConsts.OldProjectName))
75 | {
76 | var oldFileName = fileInfo.Name;
77 | var newFileName = oldFileName.CustomReplace(companyName, projectName);
78 |
79 | var newFilePath = Path.Combine(fileInfo.DirectoryName, newFileName);
80 | // 无变化才重命名
81 | if (newFilePath != fileInfo.FullName)
82 | {
83 |
84 | File.Delete(fileInfo.FullName);
85 | }
86 | File.WriteAllText(newFilePath, newContents, encoding);
87 | }
88 | else
89 | File.WriteAllText(fileInfo.FullName, newContents, encoding);
90 |
91 |
92 | }
93 |
94 | foreach (var subDirectory in Directory.GetDirectories(sourcePath))
95 | {
96 | RenameAllFileNameAndContent(subDirectory, companyName, projectName);
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
254 | # GUI
255 | src/AbpVnextPro.GUI.ConsoleApp/Logs/logs.txt
256 |
--------------------------------------------------------------------------------