Generate, sync, and maintain your project's file/folder structure from a single
structure.txtfile β with safety features, templates, and real-time watching.
A powerful CLI tool that lets you define your entire project structure in plain text and keep it perfectly synchronized with your filesystem. Perfect for scaffolding projects, maintaining consistency, and automating project setup.
- π§ Define structure in plain text - Simple, readable
structure.txtformat - ποΈ Auto-create project trees - Generate entire folder structures instantly
- π Two-way sync - Keep filesystem and structure.txt in perfect sync
- π‘οΈ Safety first - Interactive confirmations, dry-run mode, and force flags
- π¨ Colored output - Beautiful terminal UI with clear visual feedback
- π Template system - Auto-populate new files with custom templates
- π Watch mode - Real-time synchronization as you edit structure.txt
- π« .projgenignore - Exclude files and folders from scanning
- π¬ Comment support - Add comments to your structure files
- β Strict validation - Catch errors with helpful line-number messages
- π§ͺ Fully tested - Comprehensive test suite with Vitest
- π Well documented - Complete JSDoc coverage and examples
npx projgen-cli init
npx projgen-cli syncnpm install -g projgen-cliThen use anywhere:
projgen init
projgen sync
projgen watchnpm install --save-dev projgen-cliAdd to package.json scripts:
{
"scripts": {
"struct:init": "projgen init",
"struct:sync": "projgen sync",
"struct:watch": "projgen watch"
}
}# 1. Generate structure.txt from your current project
projgen init
# 2. Edit structure.txt to add/remove files and folders
# 3. Preview changes (dry run)
projgen sync --dry-run
# 4. Apply changes
projgen sync
# 5. Or use watch mode for real-time syncing
projgen watchGenerate structure.txt from your current directory structure.
projgen init [options]Options:
--indent <size>- Indentation style:2(default),4, ortab
Examples:
projgen init # Use 2-space indentation
projgen init --indent=4 # Use 4-space indentation
projgen init --indent=tab # Use tab indentationSynchronize your filesystem with structure.txt.
projgen sync [options]Options:
--dry-run- Preview changes without applying them--force- Skip confirmation prompts for deletions--update-structure- Updatestructure.txtafter sync to reflect actual state--indent <size>- Indentation style:2,4, ortab--log- Write detailed log to.projgen.log
Examples:
projgen sync # Interactive sync with confirmations
projgen sync --dry-run # Preview what will change
projgen sync --force # Skip confirmations (use with caution!)
projgen sync --update-structure # Sync and update structure.txt
projgen sync --indent=4 --log # Use 4-space indent and log to fileWhat it does:
- β Creates missing files and folders
- β Deletes files/folders not in structure.txt (with confirmation)
- π Detects and handles renames
- π Applies templates to new files (if configured)
Watch structure.txt for changes and auto-sync in real-time.
projgen watch [options]Options:
--indent <size>- Indentation style:2,4, ortab
Examples:
projgen watch # Start watching with default settings
projgen watch --indent=4 # Watch with 4-space indentationFeatures:
- π Monitors
structure.txtfor changes - β‘ Automatically applies additions and deletions
- π Debounced (waits 500ms after changes)
- π Graceful shutdown with Ctrl+C
folder src
folder components
file Button.js
file Input.js
folder utils
file helpers.js
file index.js
folder public
file index.html
file package.json
file README.md- Use
folderorfilefollowed by the name - Use 2-space indentation for nesting (or configure with
--indent) - Indentation must be consistent (multiples of indent size)
- No trailing slashes needed
# This is a comment line
folder src # This is an inline comment
file index.js # Main entry point- Lines starting with
#are ignored - Inline comments after
#are stripped
2 spaces (default):
folder src
file index.js4 spaces:
folder src
file index.jsTabs:
folder src
file index.jsBy default, projgen sync will ask for confirmation before deleting files:
About to delete 3 items (2 files, 1 folder). Continue? (y/N)
Preview changes without applying them:
projgen sync --dry-runOutput shows:
- π’ What will be created
- π΄ What will be deleted
- βͺ What is unchanged
Skip confirmations (use with caution):
projgen sync --forceThese are always ignored:
.git/node_modules/.vscode/.idea/structure.txt.projgen.log
Automatically populate new files with custom templates based on file extension.
- Create a
.projgen/templates/directory in your project - Add template files named
default.<ext>.template
.projgen/templates/default.js.template:
/**
* {{filename}}
*
* @file {{name}}
* @author Your Name
* @date {{date}}
*/
// Your code here.projgen/templates/default.md.template:
# {{name}}
Created: {{date}}
## Description
Add your description here.{{filename}}- Full filename (e.g.,index.js){{name}}- Filename without extension (e.g.,index){{date}}- Current date (YYYY-MM-DD){{year}}- Current year{{timestamp}}- Full ISO timestamp
When you run projgen sync, new files will automatically use templates if available:
projgen sync
# Creates src/utils.js with template contentExclude files and folders from scanning when running projgen init.
Create a .projgenignore file in your project root:
# Ignore build artifacts
dist/
build/
*.log
# Ignore IDE files
.vscode/
.idea/
# Ignore test files
*.test.js
__tests__/- Exact match:
node_modules - Wildcard:
*.log,*.tmp - Path match:
dist/,build/output/ - Comments: Lines starting with
#
These are always ignored (even without .projgenignore):
.gitnode_modules.vscode.ideastructure.txt.projgen.log
projgen-cli/
βββ src/
β βββ cli/
β β βββ commands/
β β β βββ init.js # Init command
β β β βββ sync.js # Sync command
β β β βββ watch.js # Watch command
β β βββ index.js # CLI entry point
β βββ core/
β β βββ parser/
β β β βββ index.js # Structure parser
β β βββ scanner/
β β β βββ index.js # Filesystem scanner
β β β βββ ignore.js # .projgenignore handler
β β βββ sync/
β β β βββ diff.js # Diff generator
β β β βββ apply.js # Diff applicator
β β βββ templates/
β β β βββ index.js # Template system
β β βββ watcher/
β β βββ index.js # Watch mode
β βββ utils/
β βββ logger.js # Colored logging
β βββ confirm.js # Interactive prompts
β βββ validator.js # Validation utilities
βββ tests/
β βββ unit/
β βββ parser.test.js # Parser tests
β βββ scanner.test.js # Scanner tests
β βββ diff.test.js # Diff tests
βββ templates/
β βββ default.js.template # Default JS template
β βββ default.md.template # Default MD template
βββ package.json
βββ vitest.config.js
βββ README.md
Run the test suite:
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
npm run test:ui # Interactive UIIMPORTANT:
projgen syncwill delete files and folders that are not listed instructure.txt.
- β Always use version control (Git) before syncing
- β
Run
--dry-runfirst to preview changes - β Review deletions carefully before confirming
- β
Use
.projgenignoreto protect important files - β Backup your project before major structural changes
- Any file or folder not in
structure.txt - Except items in
.projgenignore - Except default protected items (
.git,node_modules, etc.)
Contributions are welcome! Here's how to contribute:
# Clone the repository
git clone https://github.com/vaibhavisno-one/ProjGen
cd projgen-cli
# Install dependencies
npm install
# Run tests
npm test
# Link for local development
npm link- β Write tests for new features
- β Follow existing code style
- β Add JSDoc comments to functions
- β Update README for new features
- β Keep commits atomic and descriptive
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
npm test) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Run projgen init first to generate the file.
Ensure your indentation is consistent:
- Use only spaces OR tabs (not mixed)
- Use multiples of your indent size (2 or 4 spaces)
Check your .projgenignore syntax:
- One pattern per line
- No quotes needed
- Use
*for wildcards
Ensure templates are in .projgen/templates/ and named default.<ext>.template.
Check that structure.txt exists and is not being ignored by your editor's auto-save settings.
MIT Β© Vaibhav kumar
Built with:
- Commander.js - CLI framework
- Chalk - Terminal colors
- Inquirer.js - Interactive prompts
- Chokidar - File watching
- Vitest - Testing framework
Made with β€οΈ by the ProjGen team