How to write a new project template script
Hey, I've written a small game engine to create text adventures in Deno. The resulting project is a static web site—just a few little files—which can then be uploaded to itch.io or some other static web-based game server.
What would make this easier is a script of some kind that would generate new projects from a template. Currently, Vite uses a script that asks the user a few questions on the command line and generates a new project from GitHub. Is there an idomatic way to do this with Deno? If I write a new project script like this, is there a way to upload it so other users can create games the same way?
5 Replies
Have a look at Fresh init.ts It has all the features that you would need to create this.
https://github.com/denoland/fresh/blob/main/init.ts
might be just me but this sounds like a simple enough problem you could just raw dog write it in, well, Deno. There is prompt(), alert() and confirm() functions for simple ui interactions. Seems like there shouldn't be a need to bring in huge amount of dependencies for this?
There's also https://cliffy.io/ which is pretty nice for making fancier CLI apps with all kinds of prompts, command line arguments, automatic --help generation etc. It's around 230Kb / 40 files
Fresh init brings a whopping 11.9Mb of dependencies in 190 files 😲
I pointed to Fresh init.ts for inspiration, not to use it. I agree that this should be easy to build.
I wouldn't even use cli-input, just supply a cfg file and use that for options to scaffold the app.
I wouldn't even use cli-input, just supply a cfg file and use that for options to scaffold the app.
Hey, I wanted to thank the community and report back. This was really easy! I was hampered a little by the fact that there appears to be a bug in Deno for Windows right now with the prompt command. I switched to just using Deno.args and saved myself some pain. Here it is: https://github.com/spaceflounder/yarthouse
GitHub
GitHub - spaceflounder/yarthouse: Command line tool for creating Ya...
Command line tool for creating Yart games. Contribute to spaceflounder/yarthouse development by creating an account on GitHub.
Short and sweet! Very nice!