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

Ensure users don't create a .wasp file #2418

Merged
merged 13 commits into from
Feb 12, 2025

Conversation

komyg
Copy link
Contributor

@komyg komyg commented Dec 14, 2024

Description

Fixes: #2406

Select what type of change this PR introduces:

  1. Just code/docs improvement (no functional change).
  2. Bug fix (non-breaking change which fixes an issue).
  3. New feature (non-breaking change which adds functionality).
  4. Breaking change (fix or feature that would cause existing functionality to not work as expected).

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:

  1. I updated ChangeLog.md with description of the change this PR introduces.
  2. I bumped waspc version in waspc.cabal to reflect changes I introduced, with regards to the version of the latest wasp release, if the bump was needed.

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:

  1. I updated waspc/examples/todoApp as needed (updated modified feature or added new feature) and manually checked it works correctly.
  2. I updated 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).

@komyg komyg force-pushed the fix/2406/check-for-dot-wasp-file branch from acd4f7c to 11862bc Compare December 19, 2024 18:35
@Martinsos Martinsos requested a review from sodic December 19, 2024 20:32
Copy link
Contributor

@sodic sodic left a 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 :)

waspc/src/Wasp/Project/Analyze.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/Analyze.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/Analyze.hs Outdated Show resolved Hide resolved
@komyg komyg force-pushed the fix/2406/check-for-dot-wasp-file branch from 9e3bada to 9830797 Compare December 23, 2024 13:06
@komyg komyg requested a review from sodic December 24, 2024 00:08
@komyg
Copy link
Contributor Author

komyg commented Dec 24, 2024

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?

@komyg
Copy link
Contributor Author

komyg commented Dec 27, 2024

Hey @sodic, I managed to check if we have more than one *.wasp or *.wasp.ts files in the .wasp folder. Could you review again and tell me what you think, please?

@komyg komyg force-pushed the fix/2406/check-for-dot-wasp-file branch 2 times, most recently from e37f38f to c6947d4 Compare January 13, 2025 19:37
@komyg komyg force-pushed the fix/2406/check-for-dot-wasp-file branch 2 times, most recently from 84f06e1 to d3b219e Compare January 23, 2025 13:42
@komyg komyg force-pushed the fix/2406/check-for-dot-wasp-file branch 3 times, most recently from c831691 to 10e1682 Compare February 3, 2025 12:21
Copy link
Contributor

@sodic sodic left a 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!

waspc/src/Wasp/Project/WaspFile.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/WaspFile.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/Analyze.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/Analyze.hs Outdated Show resolved Hide resolved
@komyg komyg force-pushed the fix/2406/check-for-dot-wasp-file branch from 10e1682 to 7b0ee3a Compare February 10, 2025 21:45
@komyg komyg requested a review from sodic February 11, 2025 11:28
@komyg
Copy link
Contributor Author

komyg commented Feb 11, 2025

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 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?

Anyway, could you review again, please?

Copy link
Contributor

@sodic sodic left a 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.

waspc/src/Wasp/Project/WaspFile.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/WaspFile.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/WaspFile.hs Outdated Show resolved Hide resolved
waspc/src/Wasp/Project/WaspFile.hs Outdated Show resolved Hide resolved
@komyg komyg requested a review from sodic February 12, 2025 11:46
@komyg
Copy link
Contributor Author

komyg commented Feb 12, 2025

Hey @sodic, I've made the changes you requested. Can you review again, please?

Copy link
Contributor

@sodic sodic left a 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.

waspc/src/Wasp/Util/StrongPath.hs Outdated Show resolved Hide resolved
@komyg komyg requested a review from sodic February 12, 2025 12:44
Copy link
Contributor

@sodic sodic left a 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!

@sodic sodic merged commit 12b4bd3 into wasp-lang:main Feb 12, 2025
6 checks passed
@komyg komyg deleted the fix/2406/check-for-dot-wasp-file branch February 12, 2025 13: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.

Ensure users don't create a .wasp file
2 participants