Skip to content

add cli directory support (using globs) #238

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

Merged
merged 14 commits into from
Mar 14, 2020

Conversation

Ethan-Arrowood
Copy link
Contributor

@Ethan-Arrowood Ethan-Arrowood commented Jun 18, 2019

I'm working on adding cli support for glob patterns and directories of JSON files. This probably isn't complete just yet but I thought I'd share my work so I could get some initial feedback.

Ref #16

I need to familiarize myself with the library more, but it seems like there is need to add this to the programmatic side too (https://github.com/eweap/json-schema-to-typescript/blob/97f91e758317ef3ea5be3b9a1dfdd162051e3a48/src/index.ts#L68-L92). I'll try and use that as a reference

@Ethan-Arrowood
Copy link
Contributor Author

FWIW this may also be better implemented in another library. Something that wraps this one. I'll let the maintainers decide what they'd like best

Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for the contribution! What do you think is a good way to unit test this?

@Ethan-Arrowood
Copy link
Contributor Author

Okay made changes; working on testing now

@Ethan-Arrowood
Copy link
Contributor Author

Haha testing was a bit of a challenge but I got something working! Let me know what else you'd like for this new feature :)

Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

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

Almost there -- sending this back to your queue.

@Ethan-Arrowood
Copy link
Contributor Author

Thank you for the review; will work on these recommendations soon and push changes!

@Ethan-Arrowood
Copy link
Contributor Author

sorry it has been a little while, got swept up with final projects (yay for still being in college).

@Ethan-Arrowood
Copy link
Contributor Author

The test suite is passing but I'm getting unhandelled promise rejection errors in the console. Trying to track it down now.

@Ethan-Arrowood
Copy link
Contributor Author

@bcherny hey! I'd like to try and complete this PR. I tried rebasing on master and I seem to have messed up the snapshots. Can you advise how I can fix this?

@Ethan-Arrowood
Copy link
Contributor Author

For those looking for directory access I've now published another npm module that implements such https://www.npmjs.com/package/compile-schemas-to-typescript (only api no cli right now)

@bcherny
Copy link
Owner

bcherny commented Dec 23, 2019

@Ethan-Arrowood Hey! Missed your comment.

You want to re-generate the snapshots:

git rebase origin/master
yarn test -u

@Ethan-Arrowood Ethan-Arrowood force-pushed the feature/glob-support branch 2 times, most recently from 66bf06b to 7f2c9c8 Compare December 28, 2019 15:53
@Ethan-Arrowood
Copy link
Contributor Author

Okay rebased and updated but there is some dep issue? Not sure whats wrong there

Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

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

Getting closer, but this still needs a bit more cleanup and thinking about edge cases. Sending this back to your queue.

Also:

  1. It may be worth defensively running the testCLI.ts tests serially, so they don't step on each others' toes when concurrently interacting with the filesystem. Here's how to do that.
  2. Looking at the error output in CircleCI, the issue is that we're running tests on an old version of NodeJS:
yarn install v1.3.2
...
error @typescript-eslint/[email protected]: The engine "node" is incompatible with this module. Expected version "^8.10.0 || ^10.13.0 || >=11.10.1".
error Found incompatible module
...

To fix that, I just bumped the version of NodeJS we use on CircleCI. If you rebase on the latest master, build should work. :)

@Ethan-Arrowood
Copy link
Contributor Author

Working on adding support for nested directory output now

@Ethan-Arrowood
Copy link
Contributor Author

Fixing tests and adding the single output error catch now 😄

@Ethan-Arrowood
Copy link
Contributor Author

So I added the error check, but struggled to write a test for it. execSync isn't processing the error correctly for ava .throws() to catch

@Ethan-Arrowood
Copy link
Contributor Author

@bcherny can you confirm what version of node this library is supposed to support? The package.json says 4.5 but I'm having issues with the @types/node version being so out of date. My latest commit bumps it to latest let me know if I should revert that and use old-style node code instead

@Ethan-Arrowood
Copy link
Contributor Author

Bumping - what are my next steps to get this completed?

Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

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

Looking good -- we're almost there. Sending this back to your queue for one last set of revisions, then we can merge this and publish out a beta for people to try it out.

@Ethan-Arrowood
Copy link
Contributor Author

Sorry for being MIA - will get to this asap (work has picked up significantly)

@bcherny
Copy link
Owner

bcherny commented Mar 8, 2020

Want to push the commit? Happy to pull it to help debug.

@Ethan-Arrowood
Copy link
Contributor Author

Yep! Here it is: 5c1e875

@bcherny
Copy link
Owner

bcherny commented Mar 8, 2020

@Ethan-Arrowood So you want to pull your pathTransform function into utils.ts, and make a new test file for it -- testUtils.ts. Otherwise, when you import pathTransform from cli.ts, you're accidentally triggering main() in cli.ts, which is throwing your error.

Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

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

Looking good. Ready to merge? Anything else you want to change before we go for it?

@Ethan-Arrowood
Copy link
Contributor Author

I think its ready to go!

@bcherny
Copy link
Owner

bcherny commented Mar 9, 2020

@Ethan-Arrowood Mind rebasing?

@Ethan-Arrowood
Copy link
Contributor Author

rebased :D

Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

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

Final couple of comments (sorry, thought we were done). Also, want to do the honors of updating the README?

@Ethan-Arrowood
Copy link
Contributor Author

And yes I can update the README!

@Ethan-Arrowood Ethan-Arrowood requested a review from bcherny March 11, 2020 19:42
Copy link
Owner

@bcherny bcherny left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution @Ethan-Arrowood -- this is a long time coming!

@bcherny bcherny merged commit a0257d8 into bcherny:master Mar 14, 2020
@bcherny
Copy link
Owner

bcherny commented Mar 14, 2020

Published 8.2.0.

@Ethan-Arrowood
Copy link
Contributor Author

Wooo so happy this got merged! I'll be sure to contribute more in the future 😄

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.

4 participants