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

Refactor .ncurc loading #1457

Merged
merged 2 commits into from
Sep 22, 2024
Merged

Refactor .ncurc loading #1457

merged 2 commits into from
Sep 22, 2024

Conversation

jftanner
Copy link
Contributor

My primary intent here was to fix #1452. Internally, format is expected to be an array. However, when it's loaded outside the cli (in runUpgrades) it's not parsed as such. The correct answer probably would have been to validate it and throw an error. However, since even this repo's own .ncurc file uses a string, that would definitely be a breaking change.

While this fixes the problem, I recommend refactoring the app to validate the loaded .ncurc file every time one is loaded, and avoid passing into commander as arguments. There remain a number of type-safety issues with invalid configs that are outside the scope of this PR.

The code to set args didn't need to change, but I'd already cleaned it up while chasing a red herring, so I figured I'd leave it.

I didn't see commit guidelines anywhere, but let me know if you'd prefer a semantic-commit format and I can change it.

Oh, and thanks for this incredibly helpful tool!

@jftanner
Copy link
Contributor Author

jftanner commented Sep 21, 2024

Ah... the tests run against build. :(
I'm used to using tsx to run typescript directly, so I didn't even think to build it before testing.
I'll need to debug this over the weekend.

@jftanner jftanner marked this pull request as draft September 21, 2024 02:56
@jftanner
Copy link
Contributor Author

It's because I was setting { format: undefined }. :)

@jftanner jftanner marked this pull request as ready for review September 21, 2024 03:34
Copy link
Owner

@raineorshine raineorshine left a comment

Choose a reason for hiding this comment

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

Thanks, looks good!

While this fixes the problem, I recommend refactoring the app to validate the loaded .ncurc file every time one is loaded, and avoid passing into commander as arguments. There remain a number of type-safety issues with invalid configs that are outside the scope of this PR.

Yes, good point.

Ah... the tests run against build. :(
I'm used to using tsx to run typescript directly, so I didn't even think to build it before testing.

That's not a great test setup on my part. npm test should not depend on anything other than dependencies being installed to work!

src/lib/getNcuRc.ts Outdated Show resolved Hide resolved
@raineorshine raineorshine merged commit 2258ef7 into raineorshine:main Sep 22, 2024
7 checks passed
@jftanner jftanner deleted the fix-1452 branch September 22, 2024 13:03
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.

format remains a string when set via ncurc.js
2 participants