I’ve seen people online (Chris Courses namely) create tutorials on HTML5 canvas projects. He has a command that creates him a sort of boilerplate canvas setup for changing to fit the projects needs.
I feel like I am pretty well versed in creating canvas games and animations and interactive things now, but I want a more streamlined way to create new folders without having to copy and paste folders and rename and all that stuff. Here is my file tree outlined:
projects
- !template (the folder I copy to rename and edit to create a project)
- index.html
- main.js
- 001_project_name
- index.html
- main.js
index.html
and it goes on like that, each one having potentially additional class files, and there are some other CSS and JS files in there, but that’s not important. There is an index.html there in the main directory because I use live server in Visual Studio Code and I have links to the project files’ index.html files, so I can easily just go back and switch between them to review and improve my projects as time goes on.
What I’m wanting to do is potentially create a command in the command line to do this automatically. So it would ideally get the files with code in already and put them in a new folder in the directory. Is this possible? And would it also be possible to not have to create the main index.html and just be able to go between the different projects seamlessly another way?
2
Answers
I see what you are trying to ask, but it would kind of be something that isn’t doable that comes straight with windows. You’d probably have to build some python script that can make directories, add boilerplate code, etc.
Yes, it’s possible. I would create a "skeleton project" if I were you, a project which contains the usual stuff you will need and version this project via git. So you could implement a batch file containing:
and that will make sure that you have your skeleton. You can enhance this further with plugin support, installation steps etc., but the bare minimum is to get the usual stuff at a certain location.
If you version your stuff, then you will be able to make sure that you have a single source of truth which you can rely upon anytime and you will not have to worry about updating all individual copies properly.