initra
v1.0.38
Published
A comprehensive NPX tool that revolutionizes project setup and management for modern developers
Maintainers
Readme
Initra CLI
A comprehensive NPX tool for project setup and management.
Key Features
- Project Initialization: Create new projects with various frameworks and configurations
- Automatic Dependency Installation: Installs all dependencies using npm or yarn automatically
- Feature Management: Add, remove, or update features in your project
- Code Generation: Generate components, models, tests, utilities, and configs
- Project Analysis: Analyze your project for security, performance, and code quality
- Deployment: Deploy your project to various platforms
- Updates: Keep your project dependencies and features up to date
Quick Start
npx initra initOr install globally:
npm install -g initra-cli
initra initHow It Works
For New Projects
- Run
initra init - Follow the interactive setup wizard
- Choose your project structure, framework, and features
- The CLI will create your project with all selected features
- Dependencies are automatically installed using npm or yarn
- Get a detailed installation summary with dependency counts
For Existing Projects
- Run
initra featuresto add or remove features - Use
initra generateto create new code - Run
initra analyzeto check your project quality
Main Commands
initra init: Initialize a new projectinitra features: Manage project featuresinitra status: Check project statusinitra generate: Generate codeinitra deploy: Deploy your projectinitra analyze: Analyze your projectinitra update: Update your project
Code Generation
Generate various code elements:
# Generate a component
initra generate component MyComponent
# Generate a model
initra generate model User
# Generate a test
initra generate test MyComponent
# Generate a utility
initra generate util StringHelper
# Generate a config
initra generate config DatabaseAvailable Generation Types
- component/c: Components with TypeScript support
- model/m: Data models with validation and serialization
- test/t: Jest test files with proper structure
- util/u: Utility functions with common patterns
- config: Configuration files with environment support
Environment Configuration
The CLI automatically creates a .env file with all necessary environment variables:
- Common Variables:
NODE_ENV,PORT - Database Variables: Based on your selected database (MongoDB, PostgreSQL, MySQL)
- Authentication Variables: Based on your selected authentication method
- Setup Instructions: Clear instructions for OAuth provider configuration
Generated Environment Variables
JWT Authentication
JWT_SECRET=your-secret-keyOAuth Authentication
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
FACEBOOK_APP_ID=your_facebook_app_id
FACEBOOK_APP_SECRET=your_facebook_app_secret
SESSION_SECRET=your-session-secretSession Authentication
SESSION_SECRET=your-session-secretDatabase Variables
- MongoDB:
MONGODB_URI - PostgreSQL:
PGUSER,PGPASSWORD,PGDATABASE,PGHOST,PGPORT - MySQL:
DB_NAME,DB_USER,DB_PASSWORD,DB_HOST,DB_PORT
Dependency Installation
The CLI automatically handles dependency installation:
- Package Manager Detection: Automatically detects and uses npm or yarn
- Real Installation: Actually installs dependencies, not just simulation
- Progress Tracking: Shows real-time installation progress
- Error Handling: Provides helpful error messages and fallback instructions
- Installation Summary: Shows dependency counts and installation time
- Smart Detection: Skips installation if node_modules already exists
OAuth Authentication Setup
When you select OAuth authentication, the CLI automatically:
- Installs Dependencies: Passport.js and OAuth provider strategies
- Generates OAuth Configuration: Complete OAuth setup with multiple providers
- Creates Routes: Authentication routes for Google, GitHub, and Facebook
- Provides Middleware: Authentication and logout middleware
- TypeScript Support: Full TypeScript support with proper type definitions
Supported OAuth Providers
- Google OAuth: Uses Google+ API for authentication
- GitHub OAuth: Uses GitHub API for authentication
- Facebook OAuth: Uses Facebook Graph API for authentication
Environment Variables Required
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
# GitHub OAuth
GITHUB_CLIENT_ID=your_github_client_id
GITHUB_CLIENT_SECRET=your_github_client_secret
# Facebook OAuth
FACEBOOK_APP_ID=your_facebook_app_id
FACEBOOK_APP_SECRET=your_facebook_app_secretGenerated Routes
GET /auth/google- Initiate Google OAuthGET /auth/google/callback- Google OAuth callbackGET /auth/github- Initiate GitHub OAuthGET /auth/github/callback- GitHub OAuth callbackGET /auth/facebook- Initiate Facebook OAuthGET /auth/facebook/callback- Facebook OAuth callbackGET /auth/logout- Logout user
TypeScript Support
When you select TypeScript, the CLI automatically:
- Generates
tsconfig.jsonwith optimal settings - Installs core TypeScript dependencies (
typescript,ts-node,@types/node) - Adds framework-specific type definitions:
- Express:
@types/express,@types/cors,@types/morgan - Koa:
@types/koa,@types/koa__cors - Hapi:
@types/hapi__hapi
- Express:
- Includes feature-specific types:
- Testing:
@types/jest,ts-jest - ESLint:
@typescript-eslint/eslint-plugin,@typescript-eslint/parser - Database:
@types/mongoose,@types/pg,@types/sequelize - Authentication:
@types/jsonwebtoken,@types/bcryptjs - Logging:
@types/winston - Security:
@types/helmet,@types/dotenv
- Testing:
- Configures build scripts (
build,build:watch) - Sets up proper Jest configuration for TypeScript
- Configures ESLint for TypeScript linting
Project Analysis
Analyze your project for various aspects:
# Run all analyses
initra analyze
# Run specific analyses
initra analyze --security --performance
# Run code quality analysis only
initra analyze --qualityAnalysis Types
- Security: npm audit, dependency vulnerabilities, security best practices
- Performance: Bundle analysis, optimization recommendations
- Code Quality: ESLint integration, test coverage, code standards
- Dependencies: Outdated packages, unused dependencies
- Accessibility: WCAG compliance, accessibility best practices
- Best Practices: Documentation, project structure, configuration
Project Setup Wizard
The setup wizard guides you through:
- Project name and description
- Language (JavaScript/TypeScript)
- Framework selection
- Project structure
- Database integration
- Authentication
- Testing framework
- Code quality tools
- DevOps and deployment options
Project Structures
- Basic: Simple structure for small projects
- MVC: Model-View-Controller architecture
- Microservices: Distributed architecture
- Library: Structure for creating libraries
- Full-Stack: Combined frontend and backend
Available Features
Authentication
- JWT Authentication: JSON Web Token-based authentication with secure token generation and verification
- OAuth Integration: Complete OAuth 2.0 implementation with support for:
- Google OAuth (Google+ API)
- GitHub OAuth (GitHub API)
- Facebook OAuth (Facebook Graph API)
- Passport.js strategies for easy provider addition
- Session-based Authentication: Traditional session-based authentication with secure session management
- Role-based Access Control: Built-in middleware for role-based authorization
Database Integration
- MongoDB
- PostgreSQL
- MySQL
Testing
- Jest
- Mocha
- Cypress
Code Quality
- ESLint
- Prettier
- TypeScript
DevOps
- Docker
- CI/CD (GitHub Actions, GitLab CI)
- Automated documentation
Deployment
- Vercel
- Netlify
- Heroku
- AWS
- Docker
Monitoring
- Error tracking
- Performance monitoring
- Usage analytics
Configuration
Initra CLI uses an initra.json file to store your project configuration:
{
"name": "my-project",
"version": "1.0.0",
"description": "My awesome project",
"language": "typescript",
"framework": "react",
"structure": "basic",
"features": {
"authentication": "jwt",
"database": "mongodb",
"testing": "jest",
"codeQuality": ["eslint", "prettier"],
"devops": ["docker", "github-actions"],
"deployment": "vercel"
},
"analysis": {
"lastRun": "2024-01-01T00:00:00.000Z",
"results": {
"security": { "score": 85 },
"performance": { "score": 80 },
"codeQuality": { "score": 75 }
}
}
}Framework-Specific Features
Express.js
- REST API generation
- Middleware setup (CORS, Helmet, Morgan)
- Database integration
- Authentication middleware
Nest.js
- Decorator-based architecture
- Dependency injection
- Built-in validation
- Swagger documentation
Fastify
- High-performance framework
- Plugin system
- Built-in validation
- TypeScript support
Koa
- Lightweight middleware framework
- Async/await support
- Context-based middleware
- Modular architecture
Hapi
- Enterprise-grade framework
- Built-in security features
- Plugin ecosystem
- Configuration-driven
Vanilla Node.js
- Minimal setup
- Custom server implementation
- Full control over architecture
Examples
Generate an E-commerce Application
initra init --template e-commerceGenerate a Blog
initra init --template blogGenerate a REST API
initra init --template apiGenerate a Real-time Chat Application
initra init --template chatEnvironment Configuration
The CLI supports environment-specific configurations:
# Development
NODE_ENV=development initra analyze
# Production
NODE_ENV=production initra deployError Handling
The CLI includes comprehensive error handling:
- Graceful failure with helpful error messages
- Validation of user inputs
- Fallback options when tools are not available
- Detailed logging in verbose mode
Testing
Test the CLI tool:
# Run the test suite
npm test
# Test CLI functionality
node test-cli.jsContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
- Documentation: GitHub Wiki
- Issues: GitHub Issues
- Discussions: GitHub Discussions
