-
Couldn't load subscription status.
- Fork 97
Add template path configuration #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new optional template-path parameter to enable users to specify custom template loading paths. The implementation allows for fallback to embedded templates when custom templates are not found at the specified path.
Key changes:
- Added
TemplatePathproperty toCommandOptionsBasewith corresponding mapping logic - Updated template loading logic across all command classes to use the new path mapping
- Enhanced file provider extensions to support physical and virtual template directory mirroring
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| AbpHelperCoreConsts.cs | Defines template resource path prefix constant |
| CommandOptionsBase.cs | Adds template-path option and path mapping functionality |
| FileProviderExtensions.cs | Implements template directory mirroring and file loading logic |
| TextGenerator.cs | Updates template loading to check physical files first |
| TemplateLoader.cs | Modifies template loading to support physical/virtual file fallback |
| GroupGenerationStep.cs | Uses new template directory mirroring for file generation |
| Multiple Command files | Updates all commands to use the new template path mapping |
Comments suppressed due to low confidence (2)
src/AbpHelper.Core/Extensions/FileProviderExtensions.cs:42
- The variable name 'p' is ambiguous. Consider renaming it to 'file' or 'physicalFile' for better clarity.
var physicalPaths = new HashSet<string>(physicalFiles.Select(p => p.Item1));
src/AbpHelper.Core/Extensions/FileProviderExtensions.cs:43
- The variable name 'v' is ambiguous. Consider renaming it to 'file' or 'virtualFile' for better clarity.
return physicalFiles.Concat(virtualFiles.Where(v => !physicalPaths.Contains(v.Item1)));
| return Path.Combine(new[] { resourcePathPrefix, subPath }).NormalizePath(); | ||
| } | ||
|
|
||
| if (AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '/' || AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '\\') |
Copilot
AI
Jul 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Direct character indexing can throw IndexOutOfRangeException if the string is empty. Consider using string.StartsWith() method instead for safer string comparison.
| if (AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '/' || AbpHelperCoreConsts.TemplateResourcePathPrefix[0] == '\\') | |
| if (AbpHelperCoreConsts.TemplateResourcePathPrefix.StartsWith("/") || AbpHelperCoreConsts.TemplateResourcePathPrefix.StartsWith("\\")) |
|
|
||
| public static IEnumerable<(string, IFileInfo)> GetFilesRecursively(this IVirtualFileProvider fileProvider, string dir) | ||
| { | ||
| var (virtualDirectory, physicalDirectory) = TemplateRootDirectoryMirror(dir); |
Copilot
AI
Jul 18, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The method calls the static TemplateRootDirectoryMirror instead of using the extension method GetTemplateRootDirectoryMirror. This creates inconsistency in the API usage pattern.
| var (virtualDirectory, physicalDirectory) = TemplateRootDirectoryMirror(dir); | |
| var (virtualDirectory, physicalDirectory) = fileProvider.GetTemplateRootDirectoryMirror(dir); |
新增可选参数
template-path,用于设置模板加载路径。注意:指定路径文件需要与项目Templates目录一致。
Add a new optional parameter
template-pathto set the template loading path.Note: The specified path file needs to be consistent with the project Templates directory.