Skip to content

jatinmourya/ng-init

Repository files navigation

Angular Project Initialization Automator πŸš€

A comprehensive command-line interface (CLI) tool designed to automate and streamline the initialization of Angular projects with intelligent version management, interactive library search, and comprehensive prerequisite handling.

npm version License: MIT

✨ Features

Core Features

  • πŸ” System Environment Check - Displays Node.js, npm, nvm, and Angular CLI versions before starting
  • πŸ“¦ Angular Version Selection - Fetches and displays all available Angular versions from npm registry
  • βœ… Prerequisite Compatibility Check - Validates Node.js compatibility with selected Angular version
  • πŸ”„ Smart Node Version Management - Automatically handles Node version switching with nvm
  • πŸ’Ύ Node.js Installation Assistant - Guides installation when nvm is not available
  • πŸ“ Project Location Configuration - Choose current or custom directory for project creation
  • 🎯 Project Initialization - Creates Angular project with selected configuration

Advanced Features

  • πŸ” Interactive Library Search & Installation

    • Real-time npm package search with autocomplete
    • Package validation and metadata display
    • Weekly download statistics
    • Version selection (latest or specific)
    • Multiple library queue management
  • Dynamic Library Version Resolution

    • Automatically resolves compatible versions based on Angular version
    • Checks peer dependencies from npm registry
    • Matches major versions for Angular-scoped packages
    • Displays compatibility warnings
    • Caches npm responses for performance
  • πŸ’Ύ Profile Management

    • Save configurations as reusable profiles
    • Load saved profiles for quick setup
    • Export/import profiles for sharing
      • Local profile storage (saved to ~/.ng-init)

πŸ“‹ Prerequisites

  • Node.js: v18.0.0 or higher
  • npm: Comes with Node.js
  • nvm (optional but recommended): For managing multiple Node.js versions

πŸš€ Installation

Global Installation (Recommended)

npm install -g @jatinmourya/ng-init

Or use with npx (no installation)

npx @jatinmourya/ng-init

πŸ“– Usage

Create New Project (Interactive)

ng-init

or

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. Library search and installation
  6. Profile saving option

Check System Versions

ng-init check

Displays current versions of Node.js, npm, nvm, and Angular CLI.

Profile Management

List all saved profiles

ng-init profile list

Show profile details

ng-init profile show <profile-name>

Delete a profile

ng-init profile delete <profile-name>

Export a profile

ng-init profile export <profile-name> <output-file>

Example:

ng-init profile export my-enterprise-setup ./enterprise-profile.json

Import a profile

ng-init profile import <profile-file>

Example:

ng-init profile import ./enterprise-profile.json

Show Usage Examples

ng-init examples

🎯 Usage Examples

Example 1: Create Project with Libraries

  1. Run ng-init
  2. Select Angular version 17
  3. Configure project options (routing, style, etc.)
  4. Select "Interactive search" for libraries
  5. Search and add packages like @angular/material, @ngrx/store
  6. Save as profile for future use

Example 2: Quick Setup with Saved Profile

  1. Run ng-init
  2. Select "Yes" to use saved profile
  3. Choose your saved profile
  4. Confirm configuration
  5. Project is created automatically

Example 3: Quick Project Setup

  1. Run ng-init
  2. Select latest Angular version
  3. Configure project options
  4. Skip library installation
  5. Project created with basic Angular setup

πŸ“Š CLI Application Flow Diagram

The following diagram illustrates the complete user journey when using the ng-init CLI application:

flowchart TB
    subgraph START["πŸš€ CLI Start"]
        A["User runs ng-init"] --> B["Display Welcome Banner"]
        B --> C["Display System Versions<br/>(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<br/>(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<br/>(e.g., Angular 17, 18, 19)"]
        K --> L["Select Minor Version<br/>(e.g., 17.0.x, 17.1.x)"]
        L --> M["Select Patch Version<br/>(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<br/>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<br/>(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
        EE --> FF["Enable routing?"]
        FF --> GG["Select stylesheet format"]
        GG --> HH["Enable strict mode?"]
        HH --> II["Use standalone components?"]
        II --> JJ["Project configuration complete"]
    end

    subgraph LIBRARY["πŸ“š Library Selection"]
        JJ --> 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 -->|"Skip"| BBB
    end

    subgraph SAVE["πŸ’Ύ Save Profile"]
        BBB --> 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 --> 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
Loading

Flow Description

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 Libraries Interactive search or manual input
8 Save Profile Optionally save configuration for reuse
9 Confirm Review summary and confirm creation
10 Create Execute all selected operations
11 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/             # Configuration templates (disabled/removed)
β”œβ”€β”€ build.js                   # Build script for production
β”œβ”€β”€ package.json
└── README.md

🀝 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)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ› Bug Reports & Feature Requests

If you encounter any bugs or have feature requests, please create an issue on GitHub.

πŸ“š Documentation

For detailed documentation, visit PROJECT_DOCUMENTATION.md

πŸ™ Acknowledgments

  • Angular Team for the amazing framework
  • Node.js and npm communities
  • All open-source contributors

πŸ“ž Support

πŸŽ‰ Success Metrics

  • ⏱️ 80% reduction in project initialization time
  • βœ… Zero environment setup errors with guided installation
  • πŸš€ Instant project scaffolding with best practices
  • πŸ’Ύ Reusable profiles for team standardization
  • πŸ”„ Dynamic library version resolution for Angular compatibility

About

Angular Project Initialization Automator πŸš€

Resources

License

Contributing

Stars

Watchers

Forks

Contributors