Skip to content
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

Add ignored directories option and bug fix. #93

Merged
merged 8 commits into from
Aug 11, 2020

Conversation

RayMMond
Copy link
Member

@RayMMond RayMMond commented Jul 18, 2020

  1. Add --ignored-directories option: ignore directories when searching files.
  2. Fix db migration workflow when project UiFramework is none.

@wakuflair
Copy link
Member

Thanks, I will check it out.

});
AddOption(new Option(new[] { "--ignore-directories" }, "Ignore directories when searching files. Example: -ignore-directories Folder1,Folder2")
{
Argument = new Argument<string>()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use string[] type instead of a single string, so that we need not to worry about the format of the option.(CLI library will check it automatically)

See:

AddArgument(new Argument<string[]>("method-names") {Description = "The method names"});


var ignored = ignoredDirectories?
.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => Path.Combine(baseDirectory, x)).ToArray() ?? Array.Empty<string>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the ignored directories have to be directly under the BaseDirectory?
Can they be arbitrary depth?

For example, If I use --ignore-directories IgnoreDir, can the directory C:\BaseDirectory\aspnet-core\src\MyAbp.Domain\*IgnoreDir* be ignored?


TemplateType templateType;
if (Directory.EnumerateFiles(baseDirectory, "*.DbMigrator.csproj", SearchOption.AllDirectories).Any())
if (Directory.EnumerateFiles(baseDirectory, "*.DbMigrator.csproj", SearchOption.AllDirectories).Any(x => !ignored.Any(x.StartsWith)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this usage repeats for many times, I think it's better to extract an extension method, e.g:

EnumerateFiles(this Directory directory, ... , string[] ignoreDirectories)

step =>
.Then<IfElse>(
ie => ie.ConditionExpression = new JavaScriptExpression<bool>
("ProjectInfo.UiFramework == 1"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use explicit enum instead of magic number, like:

($"ProjectInfo.UiFramework == {UiFramework.RazorPages.ToString("D")}")

})
.Then<IfElse>(
ie => ie.ConditionExpression = new JavaScriptExpression<bool>
("ProjectInfo.UiFramework == 0"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with previous comment.

@wakuflair
Copy link
Member

Wow, it becomes a huge PR.
I need more time to review it 🥰

@wakuflair wakuflair merged commit 838c51a into EasyAbp:develop Aug 11, 2020
@RayMMond RayMMond deleted the IgnoreDirectories branch August 11, 2020 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants