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

Introduce "ignore" file for files that shouldn't be copied from ext/ #192

Closed
matijaSos opened this issue Feb 22, 2021 · 4 comments · Fixed by #196
Closed

Introduce "ignore" file for files that shouldn't be copied from ext/ #192

matijaSos opened this issue Feb 22, 2021 · 4 comments · Fixed by #196
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@matijaSos
Copy link
Contributor

matijaSos commented Feb 22, 2021

There is no need to try to copy e.g. tmp editor files (at the end they don't get copied because they usually disappear), so we could introduce something like our "gitignore" for the usual set of files to be ignored (vim, emacs, intellij, ...). User could also expand it with their own file extension.

@matijaSos matijaSos added enhancement New feature or request good first issue Good for newcomers labels Feb 22, 2021
@Martinsos
Copy link
Member

Or we could read it from .gitignore. But then we assume git it used for versioning.

@craigmc08
Copy link
Contributor

@Martinsos I'd like to work on this. Here's my idea for what this feature would look like:

A .waspignore file in the root directory of the project specifies patterns to match. The file can also contain comment lines starting with '#'. The syntax will be very similar to .gitignore. These patterns are checked against the relative path of files in ext/ directory, and if the path matches a pattern, then it is not included in the build.

A default .waspignore would be created by wasp new command. I'm not sure what this needs to contain, if you have ideas that would be great.

And an overview of the implementation:

  • Introduce a depedency on Glob for testing patterns
  • IgnoreFile module has code for parsing the ignore file and testing paths
  • Add a waspIgnoreFilePath field to CompileOptions, which specifies where the ignore file is located
  • Lib.enrichWaspASTBasedOnCompileOptions function filters external code files using the .waspignore

Feedback on my ideas would be appreciated! Specifically, I'm unsure about those last two bullet points in the implementation. Are those the best places to put this logic?

@Martinsos
Copy link
Member

@craigmc08 thanks for reaching out, ok let's figure this out! You did a really good preparation, let me try to answer the questions below.
Btw love your image, I love Kerbal space program :D.

I am wondering if .waspignore should be present in the root of the project or in the ext/ dir -> but for the sake of simplicity, it might make sense to put it in the root, as you said.

Default .waspignore created by wasp new command -> sounds good. I think for start it would be enough to avoid tracking files ending with ~, and we could also add files of format #*# (emacs can create those).

Glob package -> what is not great is that nobody is maintaining it properly hm Deewiant/glob#36 . But I don't see a better alternative. We could just use regexes instead? But people expect glob for stuff like this.
Ok, let's go with it and see what happens in the future.

It does make sense to have special Module for waspignore file -> I would call it WaspignoreFile though, just to be very specific.
I don' think it would contain much code, just function to read the file. I would actually also put the logic for figuring out the path to the file there, since that is the only place where it will be used for now, and we can expose it through compile options if that will be needed in the future - for now it is not.

Lib.enrichWaspASTBasedOnCompileOptions calls ExternalCode.readFiles, and what I would do is probably add the "ignore logic" into the readFiles function, so that files returned from readFiles are already filtered based on the WaspignoreFile.

Last thought: you could put logic for checking if a specific file name is ignored by WaspignoreFile into the WaspignoreFile module. This way, all the logic about how exactly is that check done is encapsulated in WaspignoreFile module. For example if we decide to replace Glob with Regex, we only have to modify WaspignoreFile module.

I think this should be enough to get you started, and what I described above is mostly what you already said but with small changes! If you get stuck on anything, not sure how to test or how to do something, ask and we will help :).

@craigmc08
Copy link
Contributor

@Martinsos Always good to find other KSP players :)

RE glob: I did notice that the package was not actively maintained, but it was the most recent and most downloaded glob package I found.

Your other suggestions are helpful. I'll work them into my implementation. I'll have a PR submitted pretty soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants