nicoalbanese / kirimase

Build full-stack Next.js apps, incredibly fast
https://kirimase.dev
MIT License
2.39k stars 107 forks source link

Run init with CLI options #59

Closed elie222 closed 8 months ago

elie222 commented 8 months ago

Closes https://github.com/nicoalbanese/kirimase/issues/7

Allows for non-interactive mode.

Output:

➜  kirimase git:(master) ✗ pnpm run dev2 init -sf -pm pnpm -o prisma -db postgres -a next-auth -ie      

> kirimase@0.0.17 dev2 /xyz/kirimase
> node dist/index.js "init" "-sf" "-pm" "pnpm" "-o" "prisma" "-db" "postgres" "-a" "next-auth" "-ie"

✔ File created at ./kirimase.config.json                            2:12:19 AM
✔ Kirimase initialized!                                             2:12:19 AM
ℹ You can now add packages.                                         2:12:19 AM
✔ File created at prisma/schema.prisma                              2:12:19 AM
✔ File created at src/lib/db/index.ts                               2:12:19 AM
✔ File replaced at prisma/schema.prisma                             2:12:19 AM
✔ Added Computer to Prisma schema                                   2:12:19 AM
✔ File created at src/lib/db/schema/computers.ts                    2:12:19 AM
✔ File created at src/lib/api/computers/queries.ts                  2:12:19 AM
✔ File created at src/lib/api/computers/mutations.ts                2:12:19 AM
[2:12:19 AM] ◐ Installing packages: zod@3.21.4 @t3-oss/env-nextjs prisma zod-prisma...
elie222 commented 8 months ago

@nicoalbanese I'll make more updates to this and make sure it works 100%, but let me know if you're happy with the PR so far. It's mostly done. Just need to do more of the same for the other commands and test it a bit more.

elie222 commented 8 months ago

@nicoalbanese would love some sort of status update on this. Even if that's just saying you haven't time to look at it yet.

nicoalbanese commented 8 months ago

Hey @elie222 - sorry for the delay! Just gotten back from 2 weeks away and haven't had the chance to review this yet. I've got one big feature that I was in the middle of building before I left that I'm hoping to have sorted by end of the weekend and then will get on to this. BTW - this is my first open-source project and I've never reviewed a longer PR like this so may take me a little longer to review. Thanks again for pulling this together and aiming to revert back early next week!

elie222 commented 8 months ago

No problem. Happy to answer questions if needed.

The main thing I did if it wasn't clear is that you can now pass options in via the cli. Most of the changes are just passing down the arguments into the relevant functions.

nicoalbanese commented 8 months ago

Awesome - thanks. Yes I had put this off for a while as I was invoking the Shadcn-UI CLI rather than generating the files through kirimase. I've just made the change yesterday (88fbc08) to now perform the installation manually (avoiding the need to invoke the CLI) so should be all good to cover all options.

nicoalbanese commented 8 months ago

Hey @elie222 - sorry adding stripe has taken a lot longer than expected. Should be done today and then onto this!

nicoalbanese commented 8 months ago

Thanks so much for this @elie222 and for bearing with me here. I had made some changes to the init and add flow so updated your code to reflect that. I removed the implementation associated with the generate command because the field types differ dependent on db and I think that will be too complicated for end users to use properly and consistently. I'm also considering whether we break out the command (like rails) with one more subcommand to distinguish the resources ie. kirimase generate all or kirimase generate model akin to rails generate controller etc.

What do you think?

Thanks again!

nicoalbanese commented 7 months ago

Hey @elie222 - mentioned here why I removed the CLI options for the generate command. Still thinking about how best to implement this

elie222 commented 7 months ago

Hey @elie222 - mentioned here why I removed the CLI options for the generate command. Still thinking about how best to implement this

Hmm. So I'm adding it back in my own repo as I want to make use of the options. The nice thing about the CLI options is now users can call the CLI from other apps. For my own use case it allows an AI to call it. So for my use case it doesn't matter if the fields are complicated. I just want a way to be able to call it programatically.

I'll make a PR with the update soon. Up to you if you want to merge it in or have suggestions to adjust it.

nicoalbanese commented 7 months ago

ah interesting, that's a very cool way to use it!

I'm definitely not opposed to it but wanted a bit more concise syntax like kirimase generate teams name:string year_founded?:number kind of thing. Have a few things on the roadmap that I want to get done in the next few weeks but will add this to the list

elie222 commented 7 months ago

ah interesting, that's a very cool way to use it!

I'm definitely not opposed to it but wanted a bit more concise syntax like kirimase generate teams name:string year_founded?:number kind of thing. Have a few things on the roadmap that I want to get done in the next few weeks but will add this to the list

Np. I can adjust to that format. I realised probably easiest way for me to consume it is by exporting the relevant functions from the package. So people can also call as a regular package from another cli if they want.

Anyway I'll have a demo up of what I built with kirimase by tomorrow. Already published to npm but ironing out some bugs I noticed.