A modern CLI tool to scaffold TypeScript and Node.js projects with best practices configurations. Creates production-ready project structures in seconds with ESLint, Prettier, Jest, and Husky pre-configured.
- 🚀 Interactive Setup: Uses
@clack/prompts
for a user-friendly setup experience. - 📂 Template-Based: Generates projects from templates stored within the CLI project.
- ⚙️ Configurable Options: Allows users to choose:
- Project Name
- Base Template (e.g., Node.js Base, Node.js + Fastify)
- Inclusion of Jest for testing.
- Inclusion of Husky + Lint-Staged for pre-commit hooks.
- 🛠️ Standard Tooling: Generated projects come pre-configured with:
- TypeScript
- ESLint (with TypeScript support and Prettier integration)
- Prettier
- TSX for development (
npm run dev
)
The simplest way to use this CLI is with npx:
# Run the latest version
npx @shahafc13/create-node-ts-app
# Or specify a version
npx @shahafc13/create-node-ts-app@latest
This will start the interactive prompt and guide you through project creation without installing the package globally.
- Clone the repository:
git clone https://github.com/shahafc13/create-node-ts-app.git cd create-node-ts-app
- Install dependencies:
npm install
- Run the generator:
npm run dev
The CLI will guide you through these options:
- Project Name: Enter the desired name for your new project (e.g.,
my-api
). - Template Selection: Choose the base template (e.g.,
Node.js Base
). - Add Jest?: Confirm if you want to include Jest configuration and dependencies.
- Add Husky?: Confirm if you want to include Husky and Lint-Staged for pre-commit hooks.
The CLI will then create a new directory with the chosen project name in the location where you ran the command, populate it with the selected template files, and configure it according to your choices.
Project templates are located in the src/templates/
directory within this repository.
src/templates/node
: A basic Node.js setup with TypeScript.src/templates/node-fastify
: A Node.js setup including the Fastify framework.
- Create a new directory under
src/templates/
(e.g.,src/templates/node-express
). - Populate this directory with all the necessary configuration files (
package.json
,tsconfig.json
,.gitignore
, etc.) and a basicsrc/index.ts
for that template. - Update the
select
options insrc/index.ts
within themain
function to include your new template.
- Clone the repository.
- Install dependencies:
npm install
. - Run in development mode:
npm run dev
. This will execute the CLI script directly usingtsx
. - Build the project (optional):
npm run build
.
Make changes to the generator logic in src/index.ts
or modify/add templates in src/templates/
.
MIT © Shahaf Cohen