@nhankyjangchan/project-structure-generator

Minimal and flexible CLI tool to scaffold a standardized Node.js or Bun backend folder structure. It generates essential directories and copies configuration boilerplates so you can focus on writing code instead of setting up the skeleton.
β¨ Features
- Zero Config by Default β Run
psg and you're ready to go.
- Predefined Structure β Automatically creates
src/ with subfolders like config, controllers, models, middlewares, etc.
- Boilerplate Files β Copies template files from the built-in library.
- Custom Presets β Create and manage your own directory lists and templates.
- Single Template Loading β Pull individual templates from your custom preset on demand.
- Safety First β Refuses to run in a non-empty directory unless
--force is provided.
- Interactive Confirmation β Asks for explicit user consent before making any changes.
π¦ Installation
npm i -g @nhankyjangchan/project-structure-generator
π οΈ Usage
Navigate to your project folder and run the command:
psg [flags]
The CLI will check if the directory is empty, display a confirmation prompt, and then generate the structure.
βοΈ Options
Scaffold Flags
--ts | Copies tsconfig.json instead of jsconfig.json (mutually exclusive). |
--prettier | Copies .prettierignore and .prettierrc.json configuration files. |
--use-custom | Uses your custom preset (directories + templates) instead of the default one. |
--template | Loads a single template file from the custom preset by name. Requires --use-custom. |
--force | Ignores the "empty directory" check and forces the creation of folders/files (overwrites existing files). |
--h | Displays help format. |
Config Management Flags
--config | Enters config mode for managing custom presets. |
--modify-dirlist | Appends comma-separated directory names to your custom dirlist.txt. |
--clear-dirlist | Clears all entries from your custom dirlist.txt. |
--append-template | Adds a new template file to your custom preset from a given path. |
--delete-template | Removes a template file from your custom preset by name. |
π Examples
Basic JavaScript Project (Default)
mkdir my-cool-api
cd my-cool-api
psg
Result: Creates jsconfig.json and all default directories.
TypeScript Project with Prettier
mkdir my-ts-api
cd my-ts-api
psg --ts --prettier
Result: Creates tsconfig.json (skips jsconfig.json), adds Prettier configs, and creates the standard folder structure.
Override Non-Empty Directory
psg --force
Result: Copies all applicable files and creates directories, potentially overwriting existing files with the same names.
Use Custom Preset
psg --use-custom
Result: Generates the project using your custom dirlist.txt and templates/ instead of the built-in defaults.
Load a Single Custom Template
psg --use-custom --template .env.production
Result: Creates the custom directory structure, copies only .env.production.txt (without .txt extension) from your custom templates, and skips all other template files.
Manage Custom Preset
psg --config --modify-dirlist "src/routes,src/services,src/validators"
psg --config --append-template /path/to/my-config.json
psg --config --delete-template old-config.json
psg --config --clear-dirlist
π Generated Structure
After running the command, your project root will look like this:
.
βββ .env.development # Environment variables template
βββ .gitignore # Node.js specific ignore rules
βββ .prettierignore # Prettier ignore rules (with --prettier)
βββ .prettierrc.json # Basic formatting config (with --prettier)
βββ jsconfig.json # JavaScript configuration (default)
βββ package.json # Package manifest
βββ tsconfig.json # TypeScript configuration (with --ts)
βββ src/
βββ config/
βββ controllers/
βββ handlers/
βββ middlewares/
βββ models/
βββ plugins/
βββ routing/
βββ utils/
π Custom Presets
Custom presets are stored alongside the package in the config/custom/ directory:
config/
βββ base/ # Built-in default preset (shipped with package)
β βββ dirlist.txt
β βββ templates/
βββ custom/ # Your personal preset (created on demand)
βββ dirlist.txt
βββ templates/
dirlist.txt β comma-separated list of directories to create (e.g. src/routes,src/services).
templates/ β any .txt files placed here will be copied to the project root with the .txt extension stripped (e.g. Dockerfile.txt β Dockerfile).
Releases
CHANGELOG
License
MIT