-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Ensure users don't create a .wasp file #2418
Ensure users don't create a .wasp file #2418
Conversation
acd4f7c
to
11862bc
Compare
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.
Hey @komyg, thanks for the effort!
You have the right idea, and I see you know how to use both Haskell and our codebase (props for using relfile
and IOUtil.doesFileExist
), so I have no doubt we'll be merging this soon.
There are some improvements we can do, I left three requests (the biggest of which is moving the logic into findWaspFile
).
Let me know if you have any questions :)
9e3bada
to
9830797
Compare
Hey @sodic, thank you for your review, it was very through! I believe I addressed most of your comments. Could you review again, please? The only thing left is making sure we don't have more than one .wasp file. I am currently working on that, but it is not done yet. If I can get it done before your next review, then I can be a part of this PR, otherwise, I can make it into another PR. What do you think? |
Hey @sodic, I managed to check if we have more than one |
e37f38f
to
c6947d4
Compare
84f06e1
to
d3b219e
Compare
c831691
to
10e1682
Compare
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.
Nice work, Felipe!
I appreciate the patience. I tried to make it up to you with a thorough review.
Let me know what you think!
10e1682
to
7b0ee3a
Compare
Hey @sodic, I've refactored the code based on your suggestions. It does look better (and more declarative) using the pattern matching you suggested, however I had to add a Anyway, could you review again, please? |
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.
Hey @komyg, great work! This is almost ready.
Just a couple of small fixes and we're good to go.
About your question:
however I had to add a if to check if the file is called just .wasp or .wasp.ts, which is invalid. Maybe there is a better way to account for these cases?
if
expressions are a fine way to do this, but I personally prefer guards:
(waspLangFiles, []) -> case waspLangFiles of
[singleWaspLangFile]
| fromRelPath (basename singleWaspLangFile) == ".wasp" -> Left "Name too short"
| otherwise -> Right . WaspLang $ castFile (projectDir </> singleWaspLangFile)
You're free to keep the if if you like it. This is just my preference.
Hey @sodic, I've made the changes you requested. Can you review again, please? |
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.
There's just one slight regression we should fix and I'm merging.
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.
All's good to go!
@komyg Great work and thanks for the fix!
Description
Fixes: #2406
Select what type of change this PR introduces:
Update Waspc ChangeLog and version if needed
If you did a bug fix, new feature, or breaking change, that affects waspc, make sure you satisfy the following:
Update example apps if needed
If you did code changes and added a new feature or modified an existing feature, make sure you satisfy the following:
waspc/examples/todoApp
as needed (updated modified feature or added new feature) and manually checked it works correctly.waspc/headless-test/examples/todoApp
and its e2e tests as needed (updated modified feature and its tests or added new feature and new tests for it).