francescov1 / mongoose-tsgen

A plug-n-play Typescript generator for Mongoose.
103 stars 24 forks source link

feat: expose generateDefinitions method as api #103

Closed 10kc-emilyk closed 1 year ago

10kc-emilyk commented 2 years ago

I would like to use mongoose-tsgen from within another script, and so, I'd like to expose a method that performs the same actions the cli would. I called the method generateDefinitions, although we can bikeshed on the name.

Also, if this change is desired, I can update the readme to document this feature.

I've also added some complex typings to infer the parameters type from the oclif configuration, and I think I could upstream that (although, we would need to upgrade to the latest oclif, as it looks like they've deprecated the package youre using).

francescov1 commented 2 years ago

Hey @10kc-emilyk, thanks for the submission! Looks good to me, I like the method name generateDefinitions.

Also, if this change is desired, I can update the readme to document this feature.

Would be great, thanks!

I've also added some complex typings to infer the parameters type from the oclif configuration, and I think I could upstream that (although, we would need to upgrade to the latest oclif, as it looks like they've deprecated the package youre using).

Do you mean that the typings you added are exported directly from oclif in newer versions? Any breaking changes we'd need to handle to upgrade oclif?

forivall commented 2 years ago

Do you mean that the typings you added are exported directly from oclif in newer versions? Any breaking changes we'd need to handle to upgrade oclif?

No, oclif's newer versions also don't have the typings I've added, they have the same typings as the version we're currently depending on. If/when I submit those typings to oclif, they would only land in the newest version; that's what I'm trying to say.

francescov1 commented 2 years ago

Ahh got it. Okay sounds good, if they make it in then I'd be happy to upgrade oclif here.

forivall commented 1 year ago

Ok, finally got back to this: oclif's latest version does have the types i needed, so i've gone ahead and made the upgrade (see also: https://github.com/francescov1/mongoose-tsgen/pull/112 , if you want it in a separate PR )

francescov1 commented 1 year ago

Hey @forivall thanks for the submission, apologies for the delay I've been on vacation. Will take a look at this sometime this week.

francescov1 commented 1 year ago

@forivall Lets merge in #112 first and then these changes separately. I added a few questions on #112.

francescov1 commented 1 year ago

Now that #112 is merged, do you mind rebasing here now so that this PR doesnt contain the same changes?

forivall commented 1 year ago

@francescov1 done, also updated the readme.

francescov1 commented 1 year ago

Thanks for the great work @forivall !