Browse Source

Merge branch 'dev' into Cmskit-deleting-blogpost-v12514

pull/15039/head
malik masis 4 years ago
parent
commit
bc366fb5af
  1. 198
      docs/en/Application-Startup.md
  2. 1
      docs/en/CLI.md
  3. 12
      docs/en/Deployment/Distributed-Microservice.md
  4. 2
      docs/en/Getting-Started-AspNetCore-Application.md
  5. 2
      docs/en/Getting-Started.md
  6. 1
      docs/en/Module-Development-Basics.md
  7. BIN
      docs/en/images/app-startup-console-initial.png
  8. 1
      docs/zh-Hans/CLI.md
  9. 1
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs
  10. 1
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs
  11. 49
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/AngularSourceCodeAdder.cs
  12. 5
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs
  13. 55
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs
  14. 6
      npm/ng-packs/.prettierignore
  15. 10
      npm/ng-packs/README.md
  16. 10
      npm/ng-packs/package.json
  17. 8
      npm/ng-packs/packages/components/tree/src/lib/components/tree.component.scss
  18. 13
      npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts
  19. 2
      npm/ng-packs/pre-commit

198
docs/en/Application-Startup.md

@ -1,3 +1,199 @@
## ABP Application Startup
TODO
You typically use the [ABP CLI](CLI.md)'s `abp new` command to [get started](Getting-Started.md) with one of the pre-built [startup solution templates](Startup-Templates/Index.md). When you do that, you generally don't need to know the details of how the ABP Framework is integrated with your application, how it is configured and initialized. The startup template comes with many fundamental ABP packages and [application modules](Modules/Index) are pre-installed and configured for you.
> It is always suggested to [get started with a startup template](Getting-Started.md) and modify it for your requirements. Read that document only if you want to understand the details or you need to modify how the application starts.
While the ABP Framework has a lot of features and integrations, it is built as a lightweight and modular framework. It consists of hundreds of NuGet and NMP packages, so you can use only the features you need to. If you follow the [Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application](Getting-Started-AspNetCore-Application.md) document, you see how easy to install the ABP Framework into an empty ASP.NET Core project from scratch. You only install a single NuGet package and make a few small changes.
This document is for who want to better understand how the ABP Framework is initialized and configured on startup.
## Installing to a Console Application
A .NET Console application is the minimalist .NET application. So, it is best to show installing the ABP Framework to a console application as a minimalist example.
If you [create a new console application with Visual Studio](https://learn.microsoft.com/en-us/dotnet/core/tutorials/with-visual-studio) (for .NET 7.0 or later), you will see the following solution structure (I named the solution as `MyConsoleDemo`):
![app-startup-console-initial](images/app-startup-console-initial.png)
This example uses the [top level statements](https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/top-level-statements), so it consists of only a single line of code. The first step is to install the [Volo.Abp.Core](https://www.nuget.org/packages/Volo.Abp.Core) NuGet package, which is the most core NuGet package of the ABP framework. You can install it using [Package Manager Console](https://learn.microsoft.com/en-us/nuget/consume-packages/install-use-packages-powershell) in Visual Studio:
````bash
Install-Package Volo.Abp.Core
````
Alternatively, you can use a command-line terminal in the root folder of the project (the folder containing the `MyConsoleDemo.csproj` file, for this example):
````bash
dotnet add package Volo.Abp.Core
````
After adding the NuGet package, we should create a root [module class](Module-Development-Basics.md) for our application. We can create the following class in the project:
````csharp
using Volo.Abp.Modularity;
namespace MyConsoleDemo
{
public class MyConsoleDemoModule : AbpModule
{
}
}
````
This is an empty class deriving from the `AbpModule` class. It is the main class that you will control your application's dependencies and implement your configuration, startup and shutdown logic. For more information, please check the [Modularity](Module-Development-Basics.md) document.
As the second and the last step, change the `Program.cs` as shown in the following code block:
````csharp
using MyConsoleDemo;
using Volo.Abp;
// 1: Create the application container
using var application = await AbpApplicationFactory.CreateAsync<MyConsoleDemoModule>();
// 2: Initialize/start the ABP Framework and all the modules
await application.InitializeAsync();
Console.WriteLine("ABP Framework has been started...");
// 3: Stop the ABP Framework and all the modules
await application.ShutdownAsync();
````
That's all. Now, ABP Framework is installed, integrated, started and stopped in your application. From now, you can install [ABP packages](https://abp.io/packages) to your application whenever you need them.
## Installing a Framework Package
For example, if you want to send emails from your application, you can use .NET's standard [SmtpClient class](https://learn.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient). ABP also provides an `IEmailSender` service that simplifies [sending emails](Emailing.md) and configuring the email settings in a central place. If you want to use it, you should install the [Volo.Abp.Emailing](https://www.nuget.org/packages/Volo.Abp.Emailing) NuGet package to your project:
````bash
dotnet add package Volo.Abp.Emailing
````
Once you add a new ABP package/module, you also need to specify the module dependency from your module class. So, change the `MyConsoleDemoModule` class as shown below:
````csharp
using Volo.Abp.Emailing;
using Volo.Abp.Modularity;
namespace MyConsoleDemo
{
[DependsOn(typeof(AbpEmailingModule))]
public class MyConsoleDemoModule : AbpModule
{
}
}
````
I've just added a `DependsOn` attribute to declare that I want to use the ABP Emailing Module (`AbpEmailingModule`). Now, I can use the `IEmailSender` service in my `Program.cs`:
````csharp
using Microsoft.Extensions.DependencyInjection;
using MyConsoleDemo;
using Volo.Abp;
using Volo.Abp.Emailing;
using var application = await AbpApplicationFactory.CreateAsync<MyConsoleDemoModule>();
await application.InitializeAsync();
// Sending emails using the IEmailSender service
var emailsender = application.ServiceProvider.GetRequiredService<IEmailSender>();
await emailsender.SendAsync(
to: "info@acme.com",
subject: "Hello World",
body: "My message body..."
);
await application.ShutdownAsync();
````
> If you run this application, you get a runtime error indicating that the email sending settings hasn't been done yet. You can check the [Email Sending](Emailing.md) document to learn how to configure it.
That's all. Install an ABP NuGet package, add the module dependency (using the `DependsOn` attribute) and use any service inside the NuGet package.
The [ABP CLI](CLI.md) already has a special command to perform adding an ABP NuGet and also adding the `DependsOn` attribute to your module class for you with a single command:
````bash
abp add-package Volo.Abp.Emailing
````
We suggest you to use the `add-package` command instead of manually doing it.
## AbpApplicationFactory
`AbpApplicationFactory` is the main class that creates an ABP application container. It provides a single `CreateAsync` (and `Create` if you can't use asynchronous programming) method with multiple overloads. Let's investigate these overloads to understand where you can use them.
The first overload gets a generic module class parameter as we've used before in this document:
````csharp
AbpApplicationFactory.CreateAsync<MyConsoleDemoModule>();
````
The second overload gets the module class as a `Type` parameter, instead of a generic parameter. So, the previous code block can be re-written as shown below:
````csharp
AbpApplicationFactory.CreateAsync(typeof(MyConsoleDemoModule));
````
Both overloads works exactly same. So, you can use the second one if you don't know the module class type on development time and you (somehow) calculate it on runtime.
If you create one of the methods above, ABP creates an internal service collection (`IServiceCollection`) and an internal service provider (`IServiceProvider`) to automate the [dependency injection](Dependency-Injection.md) setup from your application code. Notice that we've used the `application.ServiceProvider` property in the *Installing a Framework Package* section to resolve the `IEmailSender` service from the dependency injection system.
The next overload gets an `IServiceCollection` parameter from you to allow you to set up the dependency injection system yourself, or integrate to another framework (like ASP.NET Core) that also setups the dependency injection system internally.
We can change the `Program.cs` as shown below to externally manage the dependency injection setup:
````csharp
using Microsoft.Extensions.DependencyInjection;
using MyConsoleDemo;
using Volo.Abp;
// 1: Manually created the IServiceCollection
IServiceCollection services = new ServiceCollection();
// 2: Pass the IServiceCollection externally to the ABP Framework
using var application = await AbpApplicationFactory
.CreateAsync<MyConsoleDemoModule>(services);
// 3: Manually built the IServiceProvider object
IServiceProvider serviceProvider = services.BuildServiceProvider();
// 4: Pass the IServiceProvider externally to the ABP Framework
await application.InitializeAsync(serviceProvider);
Console.WriteLine("ABP Framework has been started...");
await application.ShutdownAsync();
````
In this example, we've used .NET's standard dependency injection container. The `services.BuildServiceProvider()` call creates the standard container. However, ABP provides an alternative extension method, `BuildServiceProviderFromFactory()`, that gracefully work even if you are using another DI container:
````csharp
IServiceProvider serviceProvider = services.BuildServiceProviderFromFactory();
````
You can check the [Autofac Integration](Autofac-Integration.md) document if you want to learn how you can integrate the [Autofac](https://autofac.org/) dependency injection container with the ABP Framework.
Finally, the `CreateAsync` method has a last overload that takes the module class name as a `Type` parameter and a `IServiceCollection` object. So, we could re-write the last `CreateAsync` method usage as like in the following code block:
````csharp
using var application = await AbpApplicationFactory
.CreateAsync(typeof(MyConsoleDemoModule), services);
````
> All of the `CreateAsync` method overloads have `Create` counterparts. If your application type can not utilize asynchronous programming (that means you can't use the `await` keyword), then you can use the `Create` method instead of the `CreateAsync` method.
### AbpApplicationCreationOptions
All of the `CreateAsync` overloads can get an optional `Action<AbpApplicationCreationOptions>` parameter to configure the options that is used on the application creation. See the following example:
````csharp
using var application = await AbpApplicationFactory
.CreateAsync<MyConsoleDemoModule>(options =>
{
options.ApplicationName = "MyApp";
});
````
We've passed a lambda method to configure the `ApplicationName` option.

1
docs/en/CLI.md

@ -353,6 +353,7 @@ abp generate-proxy -t csharp -url https://localhost:44302/
* `--type` or `-t`: The name of client type. Available clients:
* `csharp`: C#, work in the `*.HttpApi.Client` project directory. There are some additional options for this client:
* `--without-contracts`: Avoid generating the application service interface, class, enum and dto types.
* `--folder`: Folder name to place generated CSharp code in. Default value: `ClientProxies`.
* `ng`: Angular. There are some additional options for this client:
* `--api-name` or `-a`: The name of the API endpoint defined in the `/src/environments/environment.ts`. Default value: `default`.

12
docs/en/Deployment/Distributed-Microservice.md

@ -30,6 +30,16 @@ await builder.AddApplicationAsync<OrderingServiceHttpApiHostModule>(options =>
});
````
## Using a Distributed Event Bus
ABP's [Distributed Event Bus](../Distributed-Event-Bus.md) system provides a standard interface to communicate to other applications and services. While the name is "distributed", the default implementation is in-process. That means, your applications / services can not communicate to each other unless you explicitly configure a distributed event bus provider.
s
If you are building a distributed system, then the applications should communicate through an external distributed messaging server. Please follow the [Distributed Event Bus](../Distributed-Event-Bus.md) document to learn how to install and configure your distributed event bus provider.
> **Warning**: Even if you don't use the distributed event bus directly in your application code, the ABP Framework and some of the modules you are using may use it. So, if you are building a distributed system, always configure a distributed event bus provider.
> **Info**: [Clustered deployment](Clustered-Environment.md) of a single application is not considered as a distributed system. So, if you only have a single application with multiple instances serving behind a load balancer, a real distributed messaging server may not be needed.
## See Also
* [Deploying to a Clustered Environment](Clustered-Environment.md)

2
docs/en/Getting-Started-AspNetCore-Application.md

@ -1,4 +1,4 @@
# Getting Started With an ABP and AspNet Core MVC Web Application
# Getting Started with an Empty ASP.NET Core MVC / Razor Pages Application
This tutorial explains how to start ABP from scratch with minimal dependencies. You generally want to start with the **[startup template](Getting-Started-AspNetCore-MVC-Template.md)**.

2
docs/en/Getting-Started.md

@ -11,8 +11,6 @@
> This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. For other options, please change the preference on top of this document.
## Contents
This tutorial explains how to **create and run** a new web application using the ABP Framework. Follow the steps below;
1. [Setup your development environment](Getting-Started-Setup-Environment.md)

1
docs/en/Module-Development-Basics.md

@ -20,7 +20,6 @@ public class BlogModule : AbpModule
{
}
````
### Configuring Dependency Injection & Other Modules

BIN
docs/en/images/app-startup-console-initial.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

1
docs/zh-Hans/CLI.md

@ -259,6 +259,7 @@ abp generate-proxy -t csharp -url https://localhost:44302/
* `--type``-t`: 客户端类型的名称. 可用的客户端有:
* `csharp`: C#, 工作在 `*.HttpApi.Client` 项目目录. 此客户端有一些可选选项:
* `--without-contracts`: 取消生成应用程序服务接口,类,枚举和DTO.
* `--folder`: 放置生成的 CSharp 代码的文件夹名称. 默认值: `ClientProxies`.
* `ng`: Angular. 此客户端有一些可选选项:
* `--api-name``-a`: 在 `/src/environments/environment.ts` 中定义的API端点名称。. 默认值: `default`.

1
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/GenerateProxyCommand.cs

@ -29,6 +29,7 @@ public class GenerateProxyCommand : ProxyCommandBase<GenerateProxyCommand>
sb.AppendLine(" abp generate-proxy -t ng");
sb.AppendLine(" abp generate-proxy -t js -m identity -o Pages/Identity/client-proxies.js -url https://localhost:44302/");
sb.AppendLine(" abp generate-proxy -t csharp --folder MyProxies/InnerFolder -url https://localhost:44302/");
sb.AppendLine(" abp generate-proxy -t csharp -url https://localhost:44302/ --without-contracts");
return sb.ToString();
}

1
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/ProxyCommandBase.cs

@ -102,6 +102,7 @@ public abstract class ProxyCommandBase<T> : IConsoleCommand, ITransientDependenc
sb.AppendLine("-u|--url <url> API definition URL from.");
sb.AppendLine("-t|--type <generate-type> The name of generate type (csharp, js, ng).");
sb.AppendLine(" csharp");
sb.AppendLine(" --without-contracts Avoid generating the application service interface, class, enum and dto types.");
sb.AppendLine(" --folder <folder-name> (default: 'ClientProxies') Folder name to place generated CSharp code in.");
sb.AppendLine(" js");
sb.AppendLine(" -o|--output <output-name> JavaScript file path or folder to place generated code in.");

49
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/AngularSourceCodeAdder.cs

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
@ -66,6 +67,12 @@ public class AngularSourceCodeAdder : ITransientDependency
}
}
public async Task AddModuleConfigurationAsync(string angularPath, string moduleName)
{
await AddProjectToEnvironmentTsAsync(angularPath, moduleName);
await AddProjectToAppModuleTsAsync(angularPath, moduleName);
}
private async Task AddProjectsToAngularJsonAsync(string angularPath, List<string> projects)
{
var angularJsonFilePath = Path.Combine(angularPath, "angular.json");
@ -229,6 +236,46 @@ public class AngularSourceCodeAdder : ITransientDependency
File.WriteAllText(tsConfigPath, tsConfigAsJson.ToString(Formatting.Indented));
}
private async Task AddProjectToEnvironmentTsAsync(string angularPath, string moduleName)
{
var filePath = Path.Combine(angularPath, "src", "environments", "environment.ts");
if (!File.Exists(filePath))
{
return;
}
var fileContent = File.ReadAllText(filePath);
fileContent = Regex.Replace(fileContent, @"apis\s*:\s*{",
"apis: {"+ Environment.NewLine +
" " + moduleName.Split(".").Last() + ":"+ Environment.NewLine +
" rootNamespace: '" + moduleName + "',"+ Environment.NewLine +
" },");
File.WriteAllText(filePath, fileContent);
}
private async Task AddProjectToAppModuleTsAsync(string angularPath, string moduleName)
{
var filePath = Path.Combine(angularPath, "src", "app", "app.module.ts");
if (!File.Exists(filePath))
{
return;
}
var fileContent = File.ReadAllText(filePath);
fileContent = "import { "+moduleName.Split(".").Last()+"Module } from '@"+moduleName.Split(".").Last().ToKebabCase()+"/config';" + Environment.NewLine + fileContent;
fileContent = Regex.Replace(fileContent, "imports\\s*:\\s*\\[",
"imports: ["+ Environment.NewLine +
" " + moduleName.Split(".").Last() + "Module.forRoot(),");
File.WriteAllText(filePath, fileContent);
}
private async Task<List<string>> CopyAndGetNamesOfAngularProjectsAsync(string solutionFilePath,
string angularProjectsPath)
{
@ -305,7 +352,7 @@ public class AngularSourceCodeAdder : ITransientDependency
return projects;
}
private async Task<string> GetProjectPackageNameAsync(string angularProjectsPath, string project)
{
var packageJsonPath = Path.Combine(angularProjectsPath, project, "package.json");

5
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs

@ -428,6 +428,11 @@ public class SolutionModuleAdder : ITransientDependency
await PublishEventAsync(9, $"Adding angular source code");
await AngularSourceCodeAdder.AddFromModuleAsync(solutionFilePath, angularPath);
if (newTemplate)
{
await AngularSourceCodeAdder.AddModuleConfigurationAsync(angularPath, moduleName);
}
}
private static void DeleteAngularDirectoriesInModulesFolder(string modulesFolderInSolution)

55
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs

@ -19,7 +19,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
private const string ProxyDirectory = "ClientProxies";
private static readonly string[] ServicePostfixes = { "AppService", "ApplicationService", "IntService", "IntegrationService" , "Service"};
private readonly static string[] ServicePostfixes = { "AppService", "ApplicationService", "IntService", "IntegrationService" , "Service"};
private const string AppServicePrefix = "Volo.Abp.Application.Services";
private const string NamespacePlaceholder = "<namespace>";
@ -29,7 +29,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
private const string ClassNamePlaceholder = "<className>";
private const string ServiceInterfacePlaceholder = "<serviceInterface>";
private const string DtoClassNamePlaceholder = "<dtoName>";
private static readonly string ClassTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" +
private readonly static string ClassTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" +
$"{Environment.NewLine}<using>" +
$"{Environment.NewLine}" +
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" +
@ -44,7 +44,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private static readonly string ClassTemplateEmptyPart = "// This file is part of <className>, you can customize it here" +
private readonly static string ClassTemplateEmptyPart = "// This file is part of <className>, you can customize it here" +
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" +
$"{Environment.NewLine}namespace <namespace>;" +
$"{Environment.NewLine}" +
@ -53,7 +53,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private static readonly string InterfaceTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" +
private readonly static string InterfaceTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" +
$"{Environment.NewLine}<using>" +
$"{Environment.NewLine}" +
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" +
@ -65,24 +65,22 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private static readonly string DtoTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" +
$"{Environment.NewLine}using System;" +
$"{Environment.NewLine}using System.Collections.Generic;" +
$"{Environment.NewLine}using Volo.Abp.Application.Dtos;" +
$"{Environment.NewLine}using Volo.Abp.ObjectExtending;" +
$"{Environment.NewLine}<using>" +
$"{Environment.NewLine}" +
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" +
$"{Environment.NewLine}namespace <namespace>;" +
$"{Environment.NewLine}" +
$"{Environment.NewLine}public <dtoName>" +
$"{Environment.NewLine}{{" +
$"{Environment.NewLine} <property>" +
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private static readonly List<string> ClassUsingNamespaceList = new()
private readonly static string DtoTemplate = "// This file is automatically generated by ABP framework to use MVC Controllers from CSharp" +
$"{Environment.NewLine}<using>" +
$"{Environment.NewLine}" +
$"{Environment.NewLine}// ReSharper disable once CheckNamespace" +
$"{Environment.NewLine}namespace <namespace>;" +
$"{Environment.NewLine}" +
$"{Environment.NewLine}public <dtoName>" +
$"{Environment.NewLine}{{" +
$"{Environment.NewLine} <property>" +
$"{Environment.NewLine}}}" +
$"{Environment.NewLine}";
private readonly static List<string> ClassUsingNamespaceList = new()
{
"using System;",
"using System.Collections.Generic;",
"using System.Threading.Tasks;",
"using Volo.Abp.Application.Dtos;",
"using Volo.Abp.Http.Client;",
@ -91,14 +89,23 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
"using Volo.Abp.Http.Client.ClientProxying;"
};
private static readonly List<string> InterfaceUsingNamespaceList = new()
private readonly static List<string> InterfaceUsingNamespaceList = new()
{
"using System;",
"using System.Collections.Generic;",
"using System.Threading.Tasks;",
"using Volo.Abp.Application.Dtos;",
"using Volo.Abp.Application.Services;"
};
private readonly static List<string> DtoUsingNamespaceList = new()
{
"using System;",
"using System.Collections.Generic;",
"using Volo.Abp.Application.Dtos;",
"using Volo.Abp.ObjectExtending;",
};
public CSharpServiceProxyGenerator(
CliHttpClientFactory cliHttpClientFactory,
IJsonSerializer jsonSerializer) :
@ -106,7 +113,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
{
}
public override async Task GenerateProxyAsync(GenerateProxyArgs args)
public async override Task GenerateProxyAsync(GenerateProxyArgs args)
{
CheckWorkDirectory(args.WorkDirectory);
CheckFolder(args.Folder);
@ -418,7 +425,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
foreach (var type in applicationApiDescriptionModel.Types.Where(x => types.Contains(x.Key)))
{
var dto = new StringBuilder(DtoTemplate);
var dtoUsingNamespaceList = new List<string>()
var dtoUsingNamespaceList = new List<string>(DtoUsingNamespaceList)
{
$"using {GetTypeNamespace(type.Key)};"
};
@ -478,7 +485,7 @@ public class CSharpServiceProxyGenerator : ServiceProxyGeneratorBase<CSharpServi
}
}
dto.Replace($"{UsingPlaceholder}", string.Join(Environment.NewLine, dtoUsingNamespaceList.OrderBy(x => x).Select(x => x)));
dto.Replace($"{UsingPlaceholder}", string.Join(Environment.NewLine, dtoUsingNamespaceList.Distinct().OrderBy(x => x).Select(x => x)));
dto.Replace(PropertyPlaceholder, properties.ToString());
var folder = args.Folder.IsNullOrWhiteSpace()

6
npm/ng-packs/.prettierignore

@ -2,3 +2,9 @@
/dist
/coverage
/.angular
/.vscode
/node_modules
/scripts
/tools
/source-code-requirements

10
npm/ng-packs/README.md

@ -22,4 +22,12 @@ The `dev-app` project is the same as the Angular UI template project. `dev-app`
For more information, see the [docs.abp.io](https://docs.abp.io)
If would you like contribute, see the [contribution guideline](./CONTRIBUTING.md).
### Git Hooks
There is a pre-defined git hook for Angular project. This hook is `pre-commit`. The hook run prettier for staged files. If you want to use this hook. (This steps tested for linux and Mac os)
- Go to `npm/ng-packs`
- Run `chmod +x ./pre-commit` in terminal
- Run `git config core.hooksPath npm/ng-packs` in terminal
and now, when you create a git commit, git hook execute prettier for staged files.

10
npm/ng-packs/package.json

@ -10,6 +10,7 @@
"build:all": "nx run-many --target=build --all --exclude=dev-app,schematics --prod && yarn build:schematics",
"test": "ng test --detect-open-handles=true --run-in-band=true --watch-all=true",
"test:all": "nx run-many --target=test --all",
"lint-staged": "lint-staged",
"lint": "nx workspace-lint && ng lint",
"lint:all": "nx run-many --target=lint --all",
"e2e": "ng e2e",
@ -40,7 +41,6 @@
},
"private": true,
"devDependencies": {
"@abp/utils": "~7.0.0-rc.2",
"@angular-devkit/build-angular": "14.2.1",
"@angular-devkit/build-ng-packagr": "^0.1002.0",
"@angular-devkit/schematics-cli": "~14.2.1",
@ -105,6 +105,7 @@
"just-clone": "^3.2.1",
"just-compare": "^1.4.0",
"lerna": "^4.0.0",
"lint-staged": "^13.0.3",
"ng-packagr": "14.2.1",
"ng-zorro-antd": "^14.0.0",
"nx": "14.7.5",
@ -125,5 +126,10 @@
"typescript": "4.7.4",
"zone.js": "0.11.4"
},
"dependencies": {}
"dependencies": {},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}":[
"npx prettier --write --config .prettierrc "
]
}
}

8
npm/ng-packs/packages/components/tree/src/lib/components/tree.component.scss

@ -1,4 +1,4 @@
.ant-tree {
abp-tree .ant-tree {
color: inherit;
.ant-tree-node-content-wrapper.ant-tree-node-selected {
@ -7,6 +7,9 @@
.ant-tree-switcher {
line-height: 17px;
align-items: center;
justify-content: center;
display: inline-flex;
}
.ant-tree-node-content-wrapper {
@ -19,13 +22,12 @@
position: relative;
display: inline-block;
margin: 0;
padding: 0 5px;
line-height: 30px;
text-decoration: none;
vertical-align: top;
border-radius: 2px;
cursor: pointer;
padding-left: 8px;
padding: 0 5px 0 8px;
border: 1px solid transparent;
}

13
npm/ng-packs/packages/components/tree/src/lib/components/tree.component.ts

@ -12,22 +12,27 @@ import { of } from 'rxjs';
import { TreeNodeTemplateDirective } from '../templates/tree-node-template.directive';
import { ExpandedIconTemplateDirective } from '../templates/expanded-icon-template.directive';
import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap';
import { LazyLoadService, LOADING_STRATEGY, SubscriptionService } from '@abp/ng.core';
export type DropEvent = NzFormatEmitEvent & { pos: number };
@Component({
selector: 'abp-tree',
templateUrl: 'tree.component.html',
styleUrls: [
'../../../../../../node_modules/ng-zorro-antd/tree/style/index.min.css',
'tree.component.scss',
],
styleUrls: ['tree.component.scss'],
encapsulation: ViewEncapsulation.None,
providers: [SubscriptionService],
})
export class TreeComponent {
dropPosition: number;
dropdowns = {} as { [key: string]: NgbDropdown };
constructor(private lazyLoadService: LazyLoadService, subscriptionService: SubscriptionService) {
const loaded$ = this.lazyLoadService.load(
LOADING_STRATEGY.AppendAnonymousStyleToHead('ng-zorro-antd-tree.css'),
);
subscriptionService.addOne(loaded$);
}
@ContentChild('menu') menu: TemplateRef<any>;
@ContentChild(TreeNodeTemplateDirective) customNodeTemplate: TreeNodeTemplateDirective;

2
npm/ng-packs/pre-commit

@ -0,0 +1,2 @@
#!/usr/bin/env sh
cd npm/ng-packs && npm run lint-staged
Loading…
Cancel
Save