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

feat(core): make module scans more configurable and ignores more robust #1019

Merged
merged 3 commits into from
Jul 25, 2019

Conversation

edvald
Copy link
Collaborator

@edvald edvald commented Jul 24, 2019

This adds dotIgnoreFiles, modules.include and modules.exclude 
fields to the project config.

The first allows you to specify which "dot ignore" files to use across
you project. To match current behavior, dotIgnoreFiles defaults to
.gitignore and .gardenignore. The feature is also more robust
now because we properly use git to evaluate the files in all cases now,
including handling nested ignore files.
This meant getting rid of the Ignorer package, which was always quite
flimsy anyway, and instead using the VcsHandler when scanning the
project, much like module sources.

Secondly, we allow explicit filtering of which directories to scan for
modules, using the modules.include/exclude keys. This allows us to
control project scanning, without blanket ignoring files that we may
actually want to be part of module builds.

Copy link
Member

@10ko 10ko left a comment

Choose a reason for hiding this comment

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

Great, good job Jón!
Aside few questions it's good to go for me. One last question: did you think about what happens if somebody adds the same path in both include and exclude?

E.


const VALID_CONFIG_FILENAMES = ["garden.yml", "garden.yaml"]
const metadataFilename = "metadata.json"
export const defaultDotIgnoreFiles = [".gitignore", ".gardenignore"]
export const fixedExcludes = [".git", ".garden", "debug-log-*"]
Copy link
Member

Choose a reason for hiding this comment

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

The original ignore was debug-info-* not debug-log-* or you perhaps meant *.log?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oops, yeah I'll fix that.

}

return paths
export async function findConfigPathsInPath(
Copy link
Member

Choose a reason for hiding this comment

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

May I suggest a more explicit name like findModulePaths or findGardenModulePaths?

Copy link
Member

Choose a reason for hiding this comment

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

Also there are missing @params in the docs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These find all config paths, not just modules, so I went for the more generic term.

Also, we generally don't use @param annotations, feels unnecessary in most cases with TypeScript imo.

@@ -622,6 +629,12 @@ export class Garden {
return version
}

async scanForConfigs(path: string) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add a comment to explain reasons and context and to not mistake this function with the one down?

@edvald
Copy link
Collaborator Author

edvald commented Jul 25, 2019

I didn't consider the case where include and exclude are the same, but it feels like that should be fairly obvious to the user?

edvald added 2 commits July 25, 2019 16:49
This adds `dotIgnoreFiles`, `modules.include` and `modules.exclude` 
fields to the project config.

The first allows you to specify which "dot ignore" files to use across
you project. To match current behavior, `dotIgnoreFiles` defaults to
`.gitignore` and `.gardenignore`. The feature is also more robust
now because we properly use git to evaluate the files in all cases now,
including handling nested ignore files.
This meant getting rid of the `Ignorer` package, which was always quite
flimsy anyway, and instead using the VcsHandler when scanning the
project, much like module sources.

Secondly, we allow explicit filtering of which directories to scan for
modules, using the `modules.include/exclude` keys. This allows us to
control project scanning, without blanket ignoring files that we may
actually want to be part of module builds.
@edvald edvald force-pushed the project-include-exclude branch from 1e1c893 to cd9a3ab Compare July 25, 2019 14:52
@10ko
Copy link
Member

10ko commented Jul 25, 2019

Thanks Jón.
👍LGTM!

@edvald edvald merged commit 4afeebf into master Jul 25, 2019
@edvald edvald deleted the project-include-exclude branch July 25, 2019 15:23
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