Merge pull request #14969 from abpframework/auto-merge/rel-6-0/1540

Merge branch rel-7.0 with rel-6.0
pull/14978/head
Yunus Emre Kalkan 3 years ago committed by GitHub
commit be0b5c9def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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");

@ -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)

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

@ -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,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 "
]
}
}

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