|
| 1 | +# @s54a/init |
| 2 | + |
| 3 | +I built this project cause I was didn't wanted to create templates times while starting a new project. |
| 4 | + |
| 5 | +## Folder Structure |
| 6 | + |
| 7 | +there is only 1 for testing which has three files |
| 8 | +I didn't add any more template cause I didn"t wanted to bloat the package |
| 9 | + |
| 10 | + 📁 init |
| 11 | + ├── 🌅 images |
| 12 | + │ ├── 🖼️ article.png |
| 13 | + │ ├── 🖼️ init -a.png |
| 14 | + │ ├── 🖼️ init -c.png |
| 15 | + │ ├── 🖼️ init -h.png |
| 16 | + │ ├── 🖼️ init -r.png |
| 17 | + │ └── 🖼️ init.png |
| 18 | + ├── 📁 templates |
| 19 | + │ └── 📁 templateTest |
| 20 | + │ ├── 📄 index.html |
| 21 | + │ ├── 📄 main.js |
| 22 | + │ └── 📄 style.css |
| 23 | + ├── 📄 .gitignore |
| 24 | + ├── 📄 .npmignore |
| 25 | + ├── 📄 index.js |
| 26 | + ├── 📜 LICENSE |
| 27 | + ├── 📝 Readme.md |
| 28 | + ├── 📋 package.json |
| 29 | + └── 📋 package-lock.json |
| 30 | + |
| 31 | +###### (Note ChatGPT built this folder structure) |
| 32 | + |
| 33 | +## How it Works |
| 34 | + |
| 35 | +To begin, open a terminal at the desired project location and run this command |
| 36 | + |
| 37 | +```bash |
| 38 | +init |
| 39 | +``` |
| 40 | + |
| 41 | +This displays all available templates from the template folder, listed by folder name. Choose a template and enter the desired folder name when prompted to create a new project with the selected template's contents. |
| 42 | + |
| 43 | +**Users can also create templates themselves by running:** |
| 44 | + |
| 45 | +```bash |
| 46 | +init -a "C:\Users\{User}\Desktop\Projects\Ongoing Projects" |
| 47 | +``` |
| 48 | + |
| 49 | +Upon execution, the tool generates a new folder path containing the contents of the user-created template. Subsequently, when the init command is invoked, it showcases the recently created template under the specified name. |
| 50 | + |
| 51 | +_Tip_: For Windows users, you can quickly access the folder by selecting it and then pressing `ctrl + shift + c.` |
| 52 | + |
| 53 | +**Templates can be removed using the following command:** |
| 54 | + |
| 55 | +```bash |
| 56 | +init -r "template name" |
| 57 | +``` |
| 58 | + |
| 59 | +_(Note: The name must match exactly.)_ |
| 60 | + |
| 61 | +**Templates can also be added from GitHub with:** |
| 62 | + |
| 63 | +```bash |
| 64 | +init -c "https://github.com/user/repoitoryName" |
| 65 | +``` |
| 66 | + |
| 67 | +This process involves cloning the repository into the current terminal directory, removing the .git folder from the cloned repository, executing the init -a "repoName" command to create a copy in the templates folder, and then deleting the cloned repository folder from the current terminal location. |
| 68 | + |
| 69 | +The reason it performs all these steps is because I attempted to accomplish it in a simpler manner but couldn't find one. |
| 70 | + |
| 71 | +## Resources |
| 72 | + |
| 73 | +#### These are the YouTube Videos & Article which helped me build this |
| 74 | + |
| 75 | +[](https://medium.com/northcoders/creating-a-project-generator-with-node-29e13b3cd309) |
| 76 | + |
| 77 | +[](https://www.youtube.com/watch?v=xYko2bHNgVA) |
| 78 | + |
| 79 | +[](https://www.youtube.com/watch?v=UxdSoefSxrA) |
| 80 | + |
| 81 | +& ChatGPT |
| 82 | + |
| 83 | +This a similer project built with Typescript |
| 84 | +https://github.com/pongsatt/mycli/blob/master/src/index.ts |
| 85 | + |
| 86 | +Extra Resources |
| 87 | +https://github.com/lirantal/nodejs-cli-apps-best-practices |
| 88 | + |
| 89 | +Take a look at https://yeoman.io/generators/ |
0 commit comments