A comprehensive CLI tool to automate Angular project initialization with intelligent version management and prerequisite handling
npm install @jatinmourya/ng-initbash
npm install -g @jatinmourya/ng-init
`
$3
`bash
npx @jatinmourya/ng-init
`
š Usage
$3
`bash
ng-init
`
or
`bash
ng-init create
`
This starts the interactive CLI that guides you through:
1. System environment check
2. Angular version selection
3. Node.js compatibility check and resolution
4. Project configuration
5. Template selection
6. Library search and installation
7. Additional features setup
8. Profile saving option
$3
`bash
ng-init check
`
Displays current versions of Node.js, npm, nvm, and Angular CLI.
$3
#### List all saved profiles
`bash
ng-init profile list
`
#### Show profile details
`bash
ng-init profile show
`
#### Delete a profile
`bash
ng-init profile delete
`
#### Export a profile
`bash
ng-init profile export
`
Example:
`bash
ng-init profile export my-enterprise-setup ./enterprise-profile.json
`
#### Import a profile
`bash
ng-init profile import
`
Example:
`bash
ng-init profile import ./enterprise-profile.json
`
$3
`bash
ng-init examples
`
šÆ Usage Examples
$3
1. Run ng-init
2. Select Angular version 17
3. Choose "Enterprise" template
4. Select "Interactive search" for libraries
5. Search and add additional packages
6. Enable Git initialization
7. Enable README generation
8. Save as profile for future use
$3
1. Run ng-init
2. Select "Yes" to use saved profile
3. Choose your saved profile
4. Confirm configuration
5. Project is created automatically
$3
1. Run ng-init
2. Select latest Angular version
3. Choose "PWA Ready" template
4. Select "Testing Bundle" from bundles
5. Enable ESLint + Prettier
6. Enable Husky hooks
7. Project created with complete testing setup
š CLI Application Flow Diagram
The following diagram illustrates the complete user journey when using the ng-init CLI application:
`mermaid
flowchart TB
subgraph START["š CLI Start"]
A["User runs ng-init"] --> B["Display Welcome Banner"]
B --> C["Display System Versions
(Node.js, npm, nvm, Angular CLI)"]
end
subgraph PROFILE["š¾ Profile Check"]
C --> D{"Use saved profile?"}
D -->|"Yes"| E["List available profiles"]
E --> F["Select profile"]
F --> G["Display profile info"]
G --> H{"Confirm profile?"}
H -->|"Yes"| SKIP["Skip to Project Name
(if not in profile)"]
H -->|"No"| I["Continue with manual setup"]
D -->|"No"| I
end
subgraph ANGULAR["š¦ Angular Version Selection"]
I --> J["Fetch Angular versions from npm"]
J --> K["Select Major Version
(e.g., Angular 17, 18, 19)"]
K --> L["Select Minor Version
(e.g., 17.0.x, 17.1.x)"]
L --> M["Select Patch Version
(e.g., 17.1.0, 17.1.1)"]
M --> N["Angular version confirmed"]
end
subgraph NODE["š§ Node.js Compatibility"]
N --> O["Check Node.js requirements"]
SKIP --> O
O --> P{"Node.js compatible?"}
P -->|"Yes"| PROJECT
P -->|"No"| Q{"nvm installed?"}
Q -->|"Yes"| R["Check installed Node versions"]
R --> S{"Compatible version
available?"}
S -->|"Yes"| T["Select & switch Node version"]
T --> PROJECT
S -->|"No"| U["Install recommended Node version"]
U --> T
Q -->|"No"| V{"How to proceed?"}
V -->|"Install nvm"| W["Display nvm install guide"]
W --> X["Exit - Install manually"]
V -->|"Direct install
(Windows)"| Y["Install Node via winget"]
Y --> Z["Exit - Restart terminal"]
V -->|"Exit"| X
end
subgraph PROJECT["š Project Configuration"]
AA["Enter project name"] --> BB{"Select location?"}
BB -->|"Current directory"| CC["Use current directory"]
BB -->|"Custom"| DD["Enter custom path"]
CC --> EE["Project path confirmed"]
DD --> EE
end
subgraph TEMPLATE["šØ Template Selection"]
EE --> FF{"Select template"}
FF -->|"Basic SPA"| GG["Minimal setup"]
FF -->|"Enterprise"| HH["NgRx + Material + ESLint"]
FF -->|"PWA Ready"| II["Service workers + offline"]
FF -->|"Material Design"| JJ["Angular Material components"]
FF -->|"Testing Ready"| KK["Jest + Testing Library"]
FF -->|"Standalone"| LL["Modern standalone components"]
FF -->|"Custom"| MM["Configure manually"]
MM --> NN["Enable routing?"]
NN --> OO["Select stylesheet format"]
OO --> PP["Enable strict mode?"]
PP --> QQ["Use standalone components?"]
GG & HH & II & JJ & KK & LL & QQ --> RR["Template configured"]
end
subgraph LIBRARY["š Library Selection"]
RR --> SS{"Library selection method?"}
SS -->|"Interactive Search"| TT["Search npm packages"]
TT --> UU["Select package"]
UU --> VV["Choose version method"]
VV -->|"Latest"| WW["Use latest version"]
VV -->|"Specific"| XX["Select Major ā Minor ā Patch"]
VV -->|"Manual"| YY["Enter version manually"]
WW & XX & YY --> ZZ["Check Angular compatibility"]
ZZ --> AAA{"Add more libraries?"}
AAA -->|"Yes"| TT
AAA -->|"No"| BBB["Libraries selected"]
SS -->|"Manual Input"| CCC["Enter package names"]
CCC --> BBB
SS -->|"Library Bundles"| DDD["Select predefined bundles"]
DDD --> EEE["UI Framework / State Mgmt /
Forms / Testing / etc."]
EEE --> BBB
SS -->|"Skip"| BBB
end
subgraph FEATURES["āļø Additional Features"]
BBB --> FFF["Select features"]
FFF --> GGG["āļø Git initialization"]
FFF --> HHH["āļø Project structure"]
FFF --> III["āļø README.md"]
FFF --> JJJ["ā CHANGELOG.md"]
FFF --> KKK["ā ESLint + Prettier"]
FFF --> LLL["ā Husky hooks"]
GGG & HHH & III & JJJ & KKK & LLL --> MMM["Features configured"]
end
subgraph SAVE["š¾ Save Profile"]
MMM --> NNN{"Save as profile?"}
NNN -->|"Yes"| OOO["Enter profile name"]
OOO --> PPP["Profile saved"]
PPP --> QQQ["Display configuration summary"]
NNN -->|"No"| QQQ
end
subgraph CONFIRM["ā
Confirmation"]
QQQ --> RRR{"Confirm creation?"}
RRR -->|"No"| SSS["Project creation cancelled"]
RRR -->|"Yes"| TTT["Start project creation"]
end
subgraph CREATE["šØ Project Creation"]
TTT --> UUU["Create Angular project"]
UUU --> VVV["Resolve library versions"]
VVV --> WWW["Install additional libraries"]
WWW --> XXX["Run npm install"]
XXX --> YYY{"Structure enabled?"}
YYY -->|"Yes"| ZZZ["Create project folders & files"]
YYY -->|"No"| AAAA
ZZZ --> AAAA{"Git enabled?"}
AAAA -->|"Yes"| BBBB["Initialize Git repo"]
BBBB --> CCCC["Create .gitignore"]
AAAA -->|"No"| DDDD
CCCC --> DDDD{"README enabled?"}
DDDD -->|"Yes"| EEEE["Generate README.md"]
DDDD -->|"No"| FFFF
EEEE --> FFFF{"Changelog enabled?"}
FFFF -->|"Yes"| GGGG["Generate CHANGELOG.md"]
FFFF -->|"No"| HHHH
GGGG --> HHHH{"ESLint enabled?"}
HHHH -->|"Yes"| IIII["Setup ESLint + Prettier"]
HHHH -->|"No"| JJJJ
IIII --> JJJJ{"Husky enabled?"}
JJJJ -->|"Yes"| KKKK["Setup Husky hooks"]
JJJJ -->|"No"| LLLL
KKKK --> LLLL{"Git enabled?"}
LLLL -->|"Yes"| MMMM["Create initial commit"]
LLLL -->|"No"| NNNN
MMMM --> NNNN["š Success!"]
end
subgraph END["š Complete"]
NNNN --> OOOO["Display next steps"]
OOOO --> PPPP["cd project-name"]
PPPP --> QQQQ["ng serve"]
QQQQ --> RRRR["Open localhost:4200"]
end
style START fill:#e1f5fe
style PROFILE fill:#f3e5f5
style ANGULAR fill:#fff3e0
style NODE fill:#ffebee
style PROJECT fill:#e8f5e9
style TEMPLATE fill:#fce4ec
style LIBRARY fill:#e0f2f1
style FEATURES fill:#fff8e1
style SAVE fill:#f3e5f5
style CONFIRM fill:#e8eaf6
style CREATE fill:#e3f2fd
style END fill:#c8e6c9
`
$3
| Step | Phase | Description |
|------|-------|-------------|
| 1 | Start | User initiates CLI with ng-init command |
| 2 | System Check | Displays current Node.js, npm, nvm, and Angular CLI versions |
| 3 | Profile | Option to use a previously saved configuration profile |
| 4 | Angular Version | Three-tier selection: Major ā Minor ā Patch version |
| 5 | Node.js Check | Validates and resolves Node.js compatibility |
| 6 | Project Setup | Configure project name and location |
| 7 | Template | Choose from 6 pre-configured templates or custom setup |
| 8 | Libraries | Interactive search, manual input, or bundled packages |
| 9 | Features | Select Git, structure, docs, linting, hooks |
| 10 | Save Profile | Optionally save configuration for reuse |
| 11 | Confirm | Review summary and confirm creation |
| 12 | Create | Execute all selected operations |
| 13 | Complete | Display success message and next steps |
šļø Project Structure
`
ng-init/
āāā src/
ā āāā index.js # CLI entry point
ā āāā runner.js # Main CLI flow
ā āāā utils/ # Helper functions
ā ā āāā version-checker.js # Version detection and management
ā ā āāā compatibility.js # Compatibility checking & version resolution
ā ā āāā npm-search.js # npm registry search
ā ā āāā installer.js # Package installation
ā ā āāā prompt-handler.js # Interactive prompts
ā ā āāā file-utils.js # File operations
ā ā āāā profile-manager.js # Profile management
ā āāā templates/ # Project templates
ā āāā templates.js # Template definitions
āāā build.js # Build script for production
āāā package.json
āāā README.md
`
š§ Configuration
$3
The CLI includes several pre-configured templates:
- basic: Minimal Angular setup with routing
- enterprise: Complete setup with NgRx, Material, ESLint
- pwa: Progressive Web App ready
- material: Angular Material UI components
- testing: Jest and Testing Library setup
- standalone: Modern standalone components
$3
Pre-configured library combinations for common use cases:
- uiFramework: Angular Material suite
- stateManagement: NgRx complete setup
- forms: Form utilities and validators
- testing: Complete testing stack
- performance: Optimization tools
- authentication: Auth integration
- utilities: Common utility libraries
- http: HTTP and API tools
š¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (git checkout -b feature/amazing-feature)
3. Commit your changes (git commit -m 'Add some amazing feature')
4. Push to the branch (git push origin feature/amazing-feature`)