Skip to content
🔧 Node CLI Project | Code Generator
TypeScript JavaScript
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
source
spec
templates
.gitignore
README.md
jest.config.js
package-lock.json
package.json
tsconfig.json

README.md

🔧 Node Project/Code Generator

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 😄

License: MIT PRs Welcome

Content

Demo

Below is an example of the generator in action

Node Project Generator Example Demo

Tech Stack

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/

Features

  • 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

Installation

Running the generator

Ensure Node.js and NPM are installed

  1. Clone or Download the repository (Depending on whether you are using SSH or HTTPS)

    Example below shows using SSH:

    $ git clone git@github.com:luvuong-le/node-project-generator.git
    $ cd node-project-generator
  2. Install dependencies using npm install

  3. Build the project using npm run build

  4. Symlink the project using npm link

    For more information on npm link view here npm link

  5. Once the link is successful, open up a terminal and you should be able to run:

gen -h 
generate -h

Options

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

Example Commands

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

Running Tests

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

Contribute

Built as a personal project for learning experience and fun. Please feel free to contribute by creating issues, submitting new pull requests!

You can’t perform that action at this time.