Important Notes: This generator is far from perfect and can most definitely be improved. This is intended for convenient personal use and was mainly designed for an keen interest in trying to develop my own implementation.
Although this demonstrates how you may create a generator yourself 😄
Below is an example of the generator in action
Technology | Description | Link |
---|---|---|
JavaScript | High Level, Dynamic, Interpreted Language | https://webpack.js.org/ |
NodeJS | Open Source, Javascript Run Time Environment, Execute Javascript code for server side | https://nodejs.org/en/ |
Typescript | Open-source programming language developed and maintained by Microsoft | https://www.typescriptlang.org/ |
Jest | Javascript Testing Framework | https://jestjs.io/ |
- Ability to generate either a project or code file with various options
- Able to use CLI mode or User Input Mode
- Easily able to add new templates and options/questions to the generator
- List all projects
- List all code files
- Add new prompts for user input mode
- Generate project with NPM Package Installation and Git Init
Ensure Node.js and NPM are installed
-
Clone or Download the repository (Depending on whether you are using SSH or HTTPS)
Example below shows using SSH:
$ git clone [email protected]:luvuong-le/node-project-generator.git $ cd node-project-generator
-
Install dependencies using npm install
-
Build the project using npm run build
-
Symlink the project using npm link
For more information on npm link view here npm link
-
Once the link is successful, open up a terminal and you should be able to run:
gen -h
generate -h
Option | Description |
---|---|
--help, -h | Show help menu |
--version, -v | Display version number |
--name, -n | Specify name of generated file or project [Optional] |
--path, -p | Specify path of file or project [Optional] |
--templatePath, --tp | Specify path of custom template folder [Optional] |
--npmInit, --ni | Specify to run project generation with npm install [Optional] |
--gitInit, --ginit | Specify to run project generation with git init [Optional] |
Notes:
- Custom template path must have the correct specific structure based on the Enums. An example of this is below:
- templateFolderName
- code
- Router.js (One level only)
- project
- express
- code
- templateFolderName
gen -h
generate new project express --name ExpressProject -p express/test --ni --ginit
generate new code controller --name TestController -p ./test/
generate new code route --name TestController -p ./test/ --tp 'custom path'
gen list code
gen list all
Tests should be run before every commit to ensure the build is not broken by any code changes.
Running the tests:
In the root directory
$ npm run test
Built as a personal project for learning experience and fun. Please feel free to contribute by creating issues, submitting new pull requests!