diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml index f878f1a..98f0ebe 100644 --- a/.github/workflows/renovate.yml +++ b/.github/workflows/renovate.yml @@ -28,3 +28,4 @@ jobs: env: LOG_LEVEL: debug RENOVATE_REPOSITORIES: ${{ github.repository }} + MEND_RNV_MC_TOKEN: ${{ secrets.MEND_RNV_MC_TOKEN }} diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index fba9373..109d634 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -278,7 +278,7 @@ interface TemplateManifest { { // Runtime 'vite': '^6.0.7', - '@vitejs/plugin-react': '^4.3.4', + '@vitejs/plugin-react': '^5.0.0', 'next': '^16.1.6', 'react': '^19.0.0', 'react-dom': '^19.0.0', @@ -679,12 +679,14 @@ npm run test:coverage # Coverage report Options are conditional based on runtime: **Vite (4 options)**: + - `tailwind` — Tailwind CSS v4 (recommended) - `styled-components` — CSS-in-JS - `css-modules` — Scoped CSS - `css` — Plain CSS **Next.js**: + - `tailwind` — Auto-selected (recommended for App Router) ### State Management diff --git a/CODE_QUALITY.md b/CODE_QUALITY.md deleted file mode 100644 index cffa4dd..0000000 --- a/CODE_QUALITY.md +++ /dev/null @@ -1,308 +0,0 @@ -# Code Quality Tools Setup 🛡️ - -This project uses **free GitHub-provided tools** to ensure code quality, security, and maintainability. - -## 🎯 Integrated Tools - -### 1. **CodeQL** - Security & Code Quality Analysis -**What it does**: Automated security vulnerability detection and code quality scanning -**Free for**: Public repositories -**Runs**: On every push/PR + weekly scheduled scan - -**Configuration**: `.github/workflows/codeql.yml` - -#### Features -- ✅ Security vulnerability detection -- ✅ Code quality issues -- ✅ Common bug patterns -- ✅ Best practice violations -- ✅ SQL injection, XSS, and other security flaws - -#### How to View Results -1. Go to your GitHub repository -2. Click **Security** tab -3. Click **Code scanning alerts** -4. Review any findings and fix them - ---- - -### 2. **Dependabot** - Automated Dependency Updates -**What it does**: Automatically creates PRs to update dependencies and security patches -**Free for**: All repositories -**Runs**: Weekly on Mondays - -**Configuration**: `.github/dependabot.yml` - -#### Features -- ✅ Automatic dependency updates -- ✅ Security vulnerability patches -- ✅ GitHub Actions updates -- ✅ Grouped updates (dev vs production) -- ✅ Configurable review schedule - -#### What You'll See -- Weekly PRs for dependency updates -- Grouped by dev dependencies and production dependencies -- Automatic labels: `dependencies`, `automated` -- Security alerts for vulnerable packages - ---- - -### 3. **Dependency Review** - PR Vulnerability Check -**What it does**: Checks every PR for vulnerable or prohibited dependencies -**Free for**: Public repositories -**Runs**: On every pull request - -**Configuration**: `.github/workflows/dependency-review.yml` - -#### Features -- ✅ Blocks PRs with vulnerable dependencies -- ✅ License compliance checking -- ✅ Fails on moderate+ severity vulnerabilities -- ✅ Comments on PRs with findings - -#### Allowed Licenses -- MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, 0BSD - -#### Blocked Licenses -- GPL-3.0, AGPL-3.0 (copyleft licenses) - ---- - -### 4. **Codecov** - Test Coverage Reporting -**What it does**: Tracks test coverage and reports on PRs -**Free for**: Public repositories -**Runs**: On every push/PR - -**Configuration**: CI workflow includes coverage upload - -#### Setup Required -1. Go to [codecov.io](https://codecov.io/) -2. Sign in with GitHub -3. Enable your repository -4. Copy the Codecov token -5. Add to GitHub: Settings → Secrets → `CODECOV_TOKEN` - -#### Features -- ✅ Coverage reports on PRs -- ✅ Coverage trends over time -- ✅ Line-by-line coverage view -- ✅ Fails if coverage drops significantly - ---- - -### 5. **Enhanced CI Pipeline** - Quality Gates -**What it does**: Runs linting, tests, and builds on every PR -**Free for**: All repositories -**Runs**: On every push/PR - -**Configuration**: `.github/workflows/ci.yml` - -#### Checks Performed -1. ✅ **Linting** - Code style and quality (ESLint) -2. ✅ **Tests** - All unit tests must pass -3. ✅ **Build** - Code must compile successfully -4. ✅ **Coverage** - Test coverage reporting - ---- - -## 📊 Quality Dashboard - -Once set up, you'll have: - -### Security Tab -- CodeQL security scanning results -- Dependabot security alerts -- Dependency graph -- Security advisories - -### Actions Tab -- CI pipeline status -- CodeQL analysis runs -- Dependency review results -- Test coverage trends - -### Pull Requests -- Automatic checks must pass -- Coverage reports -- Dependency vulnerability warnings -- Code quality feedback - ---- - -## 🚀 Setup Steps - -### 1. Enable CodeQL (One-time) -CodeQL should work automatically once you push the workflow file. - -**Verify**: -1. Push the `.github/workflows/codeql.yml` file -2. Go to **Security** → **Code scanning** -3. Wait for first scan to complete - ---- - -### 2. Enable Dependabot (Automatic) -Dependabot activates automatically with the config file. - -**Verify**: -1. Push `.github/dependabot.yml` -2. Go to **Insights** → **Dependency graph** → **Dependabot** -3. Should show "Active" status - -**Update Reviewer**: -Edit `.github/dependabot.yml` and replace `chiragmak10` with your GitHub username. - ---- - -### 3. Enable Codecov (Optional but Recommended) - -#### Step-by-step: -1. **Sign up on Codecov** - - Go to [codecov.io](https://codecov.io/) - - Click "Sign up with GitHub" - - Authorize Codecov - -2. **Enable Repository** - - Find `react-setup` in the list - - Click to enable - -3. **Get Token** - - Click on repository in Codecov - - Go to Settings - - Copy the repository upload token - -4. **Add to GitHub** - - Go to repository on GitHub - - Settings → Secrets and variables → Actions - - New repository secret - - Name: `CODECOV_TOKEN` - - Value: (paste token) - -5. **Verify** - - Create a PR - - Codecov bot should comment with coverage report - -**If you skip Codecov**: The CI will still work, coverage just won't be uploaded. - ---- - -## 📋 Workflow Summary - -```mermaid -graph TD - A[Create PR] --> B{CI Checks} - B --> C[Lint Code] - B --> D[Run Tests] - B --> E[Build Project] - B --> F[Test Coverage] - B --> G[CodeQL Scan] - B --> H[Dependency Review] - - C --> I{All Pass?} - D --> I - E --> I - F --> I - G --> I - H --> I - - I -->|Yes| J[✅ Ready to Merge] - I -->|No| K[❌ Fix Issues] -``` - ---- - -## 🎨 Status Badges - -Add these to your `README.md` to show build status: - -```markdown -[![CI](https://github.com/chiragmak10/react-setup/actions/workflows/ci.yml/badge.svg)](https://github.com/chiragmak10/react-setup/actions/workflows/ci.yml) -[![CodeQL](https://github.com/chiragmak10/react-setup/actions/workflows/codeql.yml/badge.svg)](https://github.com/chiragmak10/react-setup/actions/workflows/codeql.yml) -[![codecov](https://codecov.io/gh/chiragmak10/react-setup/branch/master/graph/badge.svg)](https://codecov.io/gh/chiragmak10/react-setup) -``` - -Replace `chiragmak10/react-setup` with your actual GitHub username/repo. - ---- - -## 🔧 Configuration Files - -| File | Purpose | -|------|---------| -| `.github/workflows/ci.yml` | Main CI pipeline (lint, test, build) | -| `.github/workflows/codeql.yml` | Security scanning | -| `.github/workflows/dependency-review.yml` | PR dependency checks | -| `.github/dependabot.yml` | Automated dependency updates | - ---- - -## 📈 What You Get - -### On Every Pull Request -- ✅ Linting check -- ✅ All tests must pass -- ✅ Build must succeed -- ✅ Coverage report -- ✅ Security scan -- ✅ Dependency vulnerability check - -### Weekly -- 📦 Dependency update PRs (Mondays) -- 🔍 Scheduled CodeQL security scan - -### Always On -- 🚨 Security alerts in Security tab -- 📊 Dependency graph -- 🎯 Code quality insights - ---- - -## 💡 Benefits - -1. **Catch bugs early** - Before they reach production -2. **Security** - Automatic vulnerability detection -3. **Maintainability** - Consistent code quality -4. **Up-to-date deps** - Automatic updates -5. **Confidence** - Know your code works -6. **Professional** - Industry-standard practices - ---- - -## 🆘 Troubleshooting - -### CodeQL not running? -- Check Security tab → Code scanning -- Verify workflow file is in `.github/workflows/codeql.yml` -- Ensure repository is public (or has GitHub Advanced Security) - -### Dependabot not creating PRs? -- Check Settings → Security → Dependabot -- Verify `.github/dependabot.yml` is committed -- Wait for Monday (scheduled day) - -### Coverage not uploading? -- Add `CODECOV_TOKEN` secret -- Check if coverage files are generated locally -- Review CI logs for upload errors - ---- - -## 🎓 Industry Standard - -These tools are used by: -- ✅ React, Vue, Next.js -- ✅ TypeScript, VS Code -- ✅ Major open source projects -- ✅ Enterprise codebases - -**All completely free for public repositories!** 🎉 - ---- - -## 📚 Learn More - -- [CodeQL Documentation](https://codeql.github.com/) -- [Dependabot Documentation](https://docs.github.com/en/code-security/dependabot) -- [Dependency Review](https://docs.github.com/en/code-security/supply-chain-security/understanding-your-software-supply-chain/about-dependency-review) -- [Codecov Documentation](https://docs.codecov.com/) diff --git a/COMPREHENSIVE_TESTS.md b/COMPREHENSIVE_TESTS.md deleted file mode 100644 index 5acb38c..0000000 --- a/COMPREHENSIVE_TESTS.md +++ /dev/null @@ -1,475 +0,0 @@ -# Comprehensive Test Suite - Implementation Summary - -## Overview - -Comprehensive testcases have been added to ensure **production-ready quality** across all major features and configurations. Tests run automatically on **Windows, macOS, and Linux** with Node 20.x and 22.x. - -## New Test Files Added - -### 1. **config-builder.test.ts** - -**Location**: `src/__tests__/config-builder.test.ts` - -Tests the configuration builder and validation system. - -**Test Coverage**: - -- ✅ Fluent API chaining -- ✅ All runtime options (Vite, Next.js) -- ✅ All language options (TypeScript, JavaScript) -- ✅ All styling solutions (Tailwind, Styled Components, CSS Modules, CSS) -- ✅ All state management (Zustand, Redux, Jotai, none) -- ✅ Testing configurations (unit, component, e2e with Vitest/Jest/Playwright/Cypress) -- ✅ Package managers (npm, yarn, pnpm) -- ✅ Git initialization -- ✅ Data fetching options -- ✅ Configuration validation -- ✅ Configuration merging -- ✅ Edge cases and error handling - -**Test Cases**: 50+ - -```bash -npm test -- src/__tests__/config-builder.test.ts -``` - ---- - -### 2. **integration/template-loading.test.ts** - -**Location**: `src/__tests__/integration/template-loading.test.ts` - -Tests the template registry and template composition system. - -**Test Coverage**: - -- ✅ Template loading for all runtimes -- ✅ All runtime + language combinations (2x2) -- ✅ All styling solutions -- ✅ All state management options -- ✅ All testing configurations -- ✅ Data fetching setup -- ✅ Complex template combinations -- ✅ Template consistency -- ✅ Template overlays - -**Test Cases**: 40+ - -```bash -npm test -- src/__tests__/integration/template-loading.test.ts -``` - ---- - -### 3. **integration/generator.test.ts** - -**Location**: `src/__tests__/integration/generator.test.ts` - -Tests the project generator for actual project creation. - -**Test Coverage**: - -- ✅ Basic project generation -- ✅ Directory structure creation -- ✅ package.json generation -- ✅ Documentation generation (README, ARCHITECTURE) -- ✅ Runtime-specific generation (Vite, Next.js) -- ✅ Language-specific generation (TypeScript, JavaScript) -- ✅ Styling-specific setup -- ✅ Testing framework setup -- ✅ State management setup -- ✅ Package manager configuration -- ✅ Data fetching setup -- ✅ Complex real-world scenarios -- ✅ Generation results validation - -**Test Cases**: 50+ - -```bash -npm test -- src/__tests__/integration/generator.test.ts -``` - ---- - -### 4. **e2e-scenarios.test.ts** - -**Location**: `src/__tests__/integration/e2e-scenarios.test.ts` - -Real-world end-to-end scenarios testing complete configurations. - -**Tested Scenarios**: - -1. **Startup SPA** (Vite + TypeScript + Tailwind + Zustand + Full Testing + TanStack Query) - - ✅ Complete SPA setup for startups - - ✅ Full testing infrastructure - - ✅ Modern state management - - ✅ Data fetching - -2. **Enterprise Next.js** (Next.js + TypeScript + Redux + Full Testing) - - ✅ Enterprise-grade setup - - ✅ Redux for state - - ✅ Jest + Cypress for testing - - ✅ pnpm support - -3. **Lightweight Project** (Vite + JavaScript + CSS Modules + No Testing) - - ✅ Minimal configuration - - ✅ JavaScript only - - ✅ No test overhead - -4. **Component Library** (Vite + TypeScript + Styled Components + Jest Unit Only) - - ✅ Component-focused setup - - ✅ Unit testing only - - ✅ Component styling - -5. **Data-Heavy App** (Next.js + TypeScript + TanStack Query + Redux) - - ✅ Data fetching priority - - ✅ State management - - ✅ Next.js with full testing - -6. **Jotai-Based Project** (Vite + TypeScript + Styled Components + Jotai) - - ✅ Alternative state management - - ✅ Modern tooling - -7. **Multi-PM Support** (Same config, different package managers) - - ✅ npm support - - ✅ yarn support - - ✅ pnpm support - -8. **All Options Combinations** - - ✅ All runtime + language combos (4 combinations) - - ✅ All styling solutions (4) - - ✅ All state management options (4) - -**Test Cases**: 30+ - -```bash -npm test -- src/__tests__/integration/e2e-scenarios.test.ts -``` - ---- - -## Test Execution in CI/CD - -### Workflow File - -**Location**: `.github/workflows/cross-platform-tests.yml` - -### Test Execution Order (in CI) - -1. **Unit Tests** (all) - - ``` - npm test - ``` - -2. **Integration Tests** (all) - - ``` - npm test -- src/__tests__/integration/ - ``` - -3. **Cross-Platform Tests** - - ``` - npm test -- src/__tests__/integration/cross-platform-cli.test.ts - ``` - -4. **E2E CLI Tests** - - ``` - npm test -- src/__tests__/integration/e2e-cli.test.ts - ``` - -5. **E2E Scenario Tests** - - ``` - npm test -- src/__tests__/integration/e2e-scenarios.test.ts - ``` - -6. **Config Builder Comprehensive** - - ``` - npm test -- src/__tests__/config-builder.test.ts - ``` - -7. **Template System Comprehensive** - - ``` - npm test -- src/__tests__/integration/template-loading.test.ts - ``` - -8. **Generator Comprehensive** - ``` - npm test -- src/__tests__/integration/generator.test.ts - ``` - -### CI Matrix - -- **OS**: Ubuntu, Windows, macOS -- **Node**: 20.x, 22.x -- **Total Test Runs**: 6 OS/Node combinations -- **Total Test Cases**: 200+ - ---- - -## Running Tests Locally - -### All Tests - -```bash -npm test -``` - -### Specific Test Suite - -```bash -npm test -- src/__tests__/config-builder.test.ts -npm test -- src/__tests__/integration/template-loading.test.ts -npm test -- src/__tests__/integration/generator.test.ts -npm test -- src/__tests__/integration/e2e-scenarios.test.ts -``` - -### Watch Mode - -```bash -npm run test:watch -``` - -### Coverage Report - -```bash -npm run test:coverage -``` - -### Cross-Platform Tests - -```bash -npm run test:cross-platform -``` - -### E2E CLI Tests - -```bash -npm run test:e2e -``` - ---- - -## Test Coverage Summary - -| Component | Test Category | Cases | Coverage | -| ------------------- | ----------------------------------- | ----- | -------- | -| **Config Builder** | Fluent API, Validation, Merging | 50+ | 95%+ | -| **Template System** | Loading, Composition, Combinations | 40+ | 90%+ | -| **Generator** | Creation, Structure, Dependencies | 50+ | 95%+ | -| **E2E Scenarios** | Real-world configs, Quality checks | 30+ | 100% | -| **Cross-Platform** | Windows, macOS, Linux compatibility | 30+ | 100% | -| **CLI Commands** | Version, help, error handling | 15+ | 95%+ | - -**Total Test Cases**: 200+ -**Total Coverage**: 95%+ - ---- - -## Key Testing Scenarios - -### Configuration Combinations Tested - -- ✅ 2 runtimes × 2 languages = 4 base combinations -- ✅ 4 styling solutions -- ✅ 4 state management options -- ✅ 3 unit test runners (none, vitest, jest) -- ✅ 3 E2E runners (none, playwright, cypress) -- ✅ 3 package managers -- ✅ Data fetching on/off -- ✅ Git init on/off - -**Total Possible Combinations**: 1000+ -**Critical Paths Tested**: 100+ - ---- - -## Automated Quality Checks - -The CI workflow automatically: - -1. ✅ Installs dependencies -2. ✅ Builds the project -3. ✅ Runs all unit tests -4. ✅ Runs all integration tests -5. ✅ Tests cross-platform compatibility -6. ✅ Tests CLI command execution -7. ✅ Tests configuration validation -8. ✅ Tests template loading -9. ✅ Tests project generation -10. ✅ Verifies package.json dependencies -11. ✅ Verifies project structure -12. ✅ Uploads code coverage - ---- - -## What Each Test File Tests - -### config-builder.test.ts - -**Purpose**: Ensure configuration system works correctly - -Tests: - -- Configuration builder fluent API -- All option combinations -- Validation logic -- Configuration merging -- Edge cases - -**Importance**: HIGH - Foundation for all project generation - ---- - -### integration/template-loading.test.ts - -**Purpose**: Ensure templates load correctly for all configs - -Tests: - -- Template registry loading -- Template selection for configurations -- Template consistency -- Complex template combinations - -**Importance**: HIGH - Affects generated project structure - ---- - -### integration/generator.test.ts - -**Purpose**: Ensure projects are generated correctly - -Tests: - -- Project creation -- File generation -- package.json structure -- Dependency injection -- Documentation generation - -**Importance**: CRITICAL - Core functionality - ---- - -### e2e-scenarios.test.ts - -**Purpose**: Test real-world project configurations - -Tests: - -- 8 real-world scenarios -- All combinations of options -- Package manager support -- Quality checks - -**Importance**: CRITICAL - Real-world validation - ---- - -## CI/CD Integration - -### Test Runs Automatically On: - -- ✅ Push to `main` branch -- ✅ Push to `develop` branch -- ✅ Pull requests to `main` -- ✅ Pull requests to `develop` - -### Blocking Tests: - -Tests must pass before: - -- Merging PRs -- Releasing new versions -- Deploying to production - -### Coverage Requirements: - -- Minimum 95% code coverage required -- All platforms must pass -- All Node versions must pass - ---- - -## Test Results Dashboard - -Check GitHub Actions for: - -- **Test Results**: Passes/Failures per OS/Node -- **Coverage Report**: Code coverage percentage -- **Build Logs**: Detailed execution logs -- **Performance**: Test execution time - -URL: https://github.com/chiragmak10/create-react-forge/actions - ---- - -## Maintenance - -### Adding New Tests - -When adding new features: - -1. Add corresponding unit test -2. Add integration test if multi-component -3. Add scenario test if affecting project generation -4. Ensure cross-platform compatibility -5. Run `npm run test:coverage` locally - -### Updating Tests - -When modifying code: - -1. Update related tests -2. Run full test suite: `npm test` -3. Check coverage: `npm run test:coverage` -4. Verify on all platforms via CI - -### Continuous Improvement - -Monitor test metrics: - -- Coverage trends -- Test execution time -- Failure patterns -- Platform-specific issues - ---- - -## Success Metrics - -✅ All 200+ tests pass on all platforms -✅ 95%+ code coverage maintained -✅ Zero critical failures in CI -✅ All scenarios execute successfully -✅ Performance: < 10 minutes total test time -✅ Cross-platform compatibility verified - ---- - -## Next Steps - -1. **Review test coverage**: `npm run test:coverage` -2. **Run all tests**: `npm test` -3. **Verify on all platforms**: GitHub Actions -4. **Monitor test health**: Check CI/CD dashboard -5. **Add more tests as features grow**: Keep coverage >95% - ---- - -## Resources - -- [Test Files](../src/__tests__/) -- [CI Workflow](.github/workflows/cross-platform-tests.yml) -- [Vitest Documentation](https://vitest.dev/) -- [GitHub Actions](https://github.com/features/actions) - ---- - -**Status**: ✅ All tests implemented and integrated into CI/CD pipeline diff --git a/CROSS_PLATFORM_TESTING.md b/CROSS_PLATFORM_TESTING.md deleted file mode 100644 index d8ed352..0000000 --- a/CROSS_PLATFORM_TESTING.md +++ /dev/null @@ -1,203 +0,0 @@ -# Cross-Platform Testing Guide - -This document explains the cross-platform testing strategy for `create-react-forge` to ensure consistent user experience across Windows, macOS, and Linux. - -## Overview - -The project includes comprehensive cross-platform testing to catch OS-specific issues early and ensure reliability across different environments. - -## Test Coverage - -### 1. **Cross-Platform CLI Tests** (`src/__tests__/integration/cross-platform-cli.test.ts`) - -Tests platform-specific behaviors: - -- **Path Handling**: Tests path separators (`/` vs `\`) on Windows vs Unix -- **Case Sensitivity**: Verifies file system case sensitivity (case-insensitive on Windows/macOS, case-sensitive on Linux) -- **Line Endings**: Tests consistent handling of `LF` vs `CRLF` -- **Special Characters**: Tests directory names with hyphens, underscores, camelCase -- **Permissions**: Tests executable file permissions on Unix systems -- **Package Manager Detection**: Verifies correct detection of `npm`, `yarn`, `pnpm` on each platform - -### 2. **E2E CLI Tests** (`src/__tests__/integration/e2e-cli.test.ts`) - -Tests actual CLI command execution: - -- **Version & Help**: Ensures `--version` and `--help` flags work -- **Exit Codes**: Verifies proper exit codes (0 for success, non-zero for errors) -- **Output Consistency**: Ensures output is consistent across multiple runs -- **Concurrent Execution**: Tests CLI behavior under concurrent invocations -- **Environment Variables**: Tests behavior with different env vars -- **Error Handling**: Tests graceful error handling for invalid inputs - -## Running Tests Locally - -### Run All Tests - -```bash -npm test -``` - -### Run Only Cross-Platform Tests - -```bash -npm test -- cross-platform-cli.test.ts -``` - -### Run Only E2E Tests - -```bash -npm test -- e2e-cli.test.ts -``` - -### Run Tests in Watch Mode - -```bash -npm run test:watch -``` - -### Run With Coverage - -```bash -npm run test:coverage -``` - -## CI/CD Pipeline - -The project uses GitHub Actions for automated cross-platform testing: - -**Workflow: `.github/workflows/cross-platform-tests.yml`** - -### Test Matrix - -- **Operating Systems**: Ubuntu Latest, Windows Latest, macOS Latest -- **Node Versions**: Node 20.x, Node 22.x -- **Total Combinations**: 6 OS/Node combinations - -### Jobs - -1. **test**: Runs unit, integration, and platform-specific tests -2. **e2e-scaffold-test**: Tests the actual scaffolding command -3. **lint**: Runs linter and format checks -4. **build-artifacts**: Verifies build output - -### Each Job Tests - -- ✅ Installation of dependencies -- ✅ Project builds successfully -- ✅ All tests pass -- ✅ Linter rules pass -- ✅ CLI can be invoked -- ✅ TypeScript definitions are generated - -## Key Platform Differences - -### Windows (`win32`) - -```typescript -// Path separator -sep === '\\'; - -// Case-insensitive file system -file.txt === FILE.TXT; // true - -// CRLF line endings -lineEnding === '\r\n'; -``` - -### macOS (`darwin`) - -```typescript -// Path separator -sep === '/'; - -// Case-insensitive file system (by default) -file.txt === FILE.TXT; // true - -// LF line endings -lineEnding === '\n'; -``` - -### Linux - -```typescript -// Path separator -sep === '/'; - -// Case-sensitive file system -file.txt === FILE.TXT; // false - -// LF line endings -lineEnding === '\n'; -``` - -## Dependency Note - -**Important**: The `@inquirer/core` peer dependency is now explicitly listed in `package.json` to ensure proper resolution across all platforms. This fixes the module resolution error that occurred on some systems. - -## Troubleshooting - -### Issue: Tests fail on Windows only - -- Check for path separator issues (`/` vs `\`) -- Verify case sensitivity handling -- Check for line ending differences - -### Issue: Tests fail on macOS only - -- Check for code signing issues -- Verify file permission handling -- Check for environment variable differences - -### Issue: Tests fail on Linux only - -- Check for case sensitivity in file names -- Verify file permissions -- Check for path length issues - -### Module Resolution Errors - -If you see errors like `Cannot find package '@inquirer/core'`: - -1. Run `npm install` to reinstall dependencies -2. Clear npm cache: `npm cache clean --force` -3. Delete node_modules and package-lock.json, then reinstall - -## Adding New Tests - -When adding new features, ensure cross-platform compatibility: - -```typescript -import os from 'node:os'; -import { sep } from 'node:path'; - -describe('Feature', () => { - it('should work on all platforms', () => { - if (os.platform() === 'win32') { - // Windows-specific test - } else { - // Unix-specific test - } - }); - - it('should handle path separators correctly', () => { - const path = `src${sep}components`; - // Use sep instead of hardcoding / or \ - }); -}); -``` - -## Continuous Improvement - -The testing infrastructure allows: - -- ✅ Early detection of platform-specific bugs -- ✅ Validation of fixes across all platforms -- ✅ Prevention of regressions -- ✅ Confidence in releases - -## Related Documentation - -- [ARCHITECTURE.md](../ARCHITECTURE.md) - Project architecture -- [CODE_QUALITY.md](../CODE_QUALITY.md) - Code quality standards -- [RELEASE_GUIDE.md](../RELEASE_GUIDE.md) - Release process diff --git a/QUICK_START_TESTING.md b/QUICK_START_TESTING.md deleted file mode 100644 index f63489e..0000000 --- a/QUICK_START_TESTING.md +++ /dev/null @@ -1,289 +0,0 @@ -# Quick Start Guide: Cross-Platform Testing - -## Problem Solved ✅ - -**Original Issue**: `npx create-react-forge@latest` failed with: - -``` -Error: Cannot find package '@inquirer/core' imported from... -``` - -**Root Cause**: Missing peer dependency that wasn't explicitly listed - -**Solution**: Added `@inquirer/core` to dependencies + comprehensive cross-platform testing infrastructure - ---- - -## What You Get Now - -### 1. **Fixed npx Command** - -```bash -npx create-react-forge@latest -# Now works reliably on Windows, macOS, and Linux! -``` - -### 2. **Comprehensive Test Coverage** - -- Cross-platform specific tests (paths, case sensitivity, line endings, permissions) -- E2E CLI command tests -- Runs on Windows, macOS, and Linux -- Tests on Node 20.x and 22.x - -### 3. **Automated CI/CD Pipeline** - -- GitHub Actions runs all tests automatically on every push/PR -- Tests across 6 OS/Node combinations -- Prevents platform-specific regressions - -### 4. **Easy Local Testing** - -```bash -# Quick test -npm test - -# Cross-platform specific tests -npm run test:cross-platform - -# E2E CLI tests -npm run test:e2e - -# Full test suite with platform checks -npm run test:local -``` - ---- - -## Usage Instructions - -### For Users - -Your `npx create-react-forge@latest` command will now: - -1. ✅ Install correctly on Windows, macOS, and Linux -2. ✅ Handle file paths properly on all platforms -3. ✅ Work with different file systems (NTFS, APFS, ext4) -4. ✅ Support Node 20.9.0+ - -### For Developers - -#### **Running Tests Locally** - -**On macOS/Linux:** - -```bash -npm run test:local -``` - -**On Windows:** - -```bash -scripts/test-local.bat -``` - -Or manually: - -```bash -npm test # All tests -npm run test:cross-platform # Platform-specific tests -npm run test:e2e # CLI command tests -npm run test:watch # Watch mode -npm run test:coverage # Coverage report -``` - -#### **Testing Different Scenarios** - -The test suite checks for: - -- ✅ Path separator handling (`/` vs `\`) -- ✅ File system case sensitivity -- ✅ Line ending consistency -- ✅ Special characters in paths -- ✅ File permissions -- ✅ Package manager detection -- ✅ CLI output consistency -- ✅ Error handling - -#### **Adding New Features** - -When adding features, test on all platforms: - -```typescript -import os from 'node:os'; -import { sep } from 'node:path'; - -describe('My Feature', () => { - it('should work on all platforms', () => { - const platform = os.platform(); // 'win32', 'darwin', 'linux' - - if (platform === 'win32') { - // Windows-specific logic - } else { - // Unix-specific logic - } - }); - - it('should handle paths correctly', () => { - const path = `src${sep}components`; // Uses proper separator - expect(path).toContain(sep); - }); -}); -``` - ---- - -## CI/CD Pipeline Details - -### Workflow: `.github/workflows/cross-platform-tests.yml` - -Runs on every push and PR: - -``` -Trigger: Push/PR to main/develop - │ - ├─ Test Job (runs 6 times) - │ ├─ Ubuntu + Node 20.x - │ ├─ Ubuntu + Node 22.x - │ ├─ Windows + Node 20.x - │ ├─ Windows + Node 22.x - │ ├─ macOS + Node 20.x - │ └─ macOS + Node 22.x - │ - ├─ E2E Scaffold Test (runs 3 times) - │ ├─ Ubuntu - │ ├─ Windows - │ └─ macOS - │ - ├─ Lint Check (Ubuntu only) - │ - └─ Build Verification (Ubuntu only) -``` - -Each job runs: - -- Dependency installation -- Project build -- All test suites -- CLI execution -- Artifact verification - ---- - -## Platform-Specific Information - -### Windows - -- **Separators**: `C:\Users\...` (backslash) -- **File System**: NTFS (case-insensitive) -- **Line Endings**: CRLF (`\r\n`) -- **PowerShell/CMD support**: Included in workflow - -### macOS - -- **Separators**: `/Users/...` (forward slash) -- **File System**: APFS (case-insensitive by default) -- **Line Endings**: LF (`\n`) -- **Code Signing**: Handled automatically - -### Linux - -- **Separators**: `/home/...` (forward slash) -- **File System**: ext4/btrfs (case-sensitive) -- **Line Endings**: LF (`\n`) -- **Permissions**: Full permission handling - ---- - -## Files Changed/Created - -### Modified - -- `package.json` - Added `@inquirer/core` + new npm scripts -- `README.md` - Added cross-platform support section - -### Created - -- `src/__tests__/integration/cross-platform-cli.test.ts` - Platform behavior tests -- `src/__tests__/integration/e2e-cli.test.ts` - CLI command tests -- `.github/workflows/cross-platform-tests.yml` - CI/CD pipeline -- `CROSS_PLATFORM_TESTING.md` - Testing documentation -- `IMPLEMENTATION_SUMMARY.md` - What was implemented -- `scripts/test-local.sh` - Unix test automation -- `scripts/test-local.bat` - Windows test automation - ---- - -## Troubleshooting - -### Module Resolution Error Still Occurs - -```bash -# Clear cache and reinstall -npm cache clean --force -rm -rf node_modules package-lock.json -npm install -``` - -### Tests Failing on One Platform - -1. Check the test output in GitHub Actions -2. Review `CROSS_PLATFORM_TESTING.md` troubleshooting section -3. Ensure path separators are using `path.sep` -4. Check for case sensitivity issues - -### CLI Not Executable - -```bash -# Rebuild the project -npm run build - -# Verify dist files exist -ls -la dist/ - -# Test execution -node dist/index.js --help -``` - ---- - -## Performance Impact - -- ✅ CI/CD runs ~5-10 minutes total -- ✅ Local tests complete in ~30 seconds -- ✅ No performance regression in generated projects -- ✅ Build still produces same output - ---- - -## Documentation - -For more detailed information, see: - -- `CROSS_PLATFORM_TESTING.md` - Comprehensive testing guide -- `IMPLEMENTATION_SUMMARY.md` - What was implemented and why -- `.github/workflows/cross-platform-tests.yml` - CI/CD workflow details -- `README.md` - Updated with testing info - ---- - -## Questions? - -Check these files: - -1. **How do I run tests?** → This file (Quick Start) -2. **What platforms are tested?** → `CROSS_PLATFORM_TESTING.md` -3. **What was changed?** → `IMPLEMENTATION_SUMMARY.md` -4. **How does the workflow work?** → `.github/workflows/cross-platform-tests.yml` -5. **General help** → `README.md` → Troubleshooting section - ---- - -## Success Indicators ✅ - -You'll know everything is working when: - -1. ✅ `npx create-react-forge@latest` works without errors -2. ✅ `npm test` passes all tests -3. ✅ `npm run test:local` completes successfully -4. ✅ GitHub Actions shows all checks passing -5. ✅ Tests pass on all 6 OS/Node combinations diff --git a/README.md b/README.md index 2fa8f26..f1c661c 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ The CLI uses pinned, tested versions for all dependencies: ## Automated dependency updates -This repo now uses Renovate to auto-update dependencies (including template manifests under `src/templates/overlays/**/manifest.json`, `src/dependencies/resolver.ts`, and the dependency versions table in this README). The workflow runs weekly and can also be run manually. +This repo now uses Renovate to auto-update dependencies (including template manifests under `src/templates/overlays/**/manifest.json`, `src/dependencies/resolver.ts`, selected dependency fixtures in `src/__tests__/*.test.ts`, the dependency versions table in this README, and the dependency registry snippet in `ARCHITECTURE.md`). The workflow runs weekly and can also be run manually. ### One-time setup @@ -124,8 +124,11 @@ This repo now uses Renovate to auto-update dependencies (including template mani 2. Use a fine-grained GitHub token scoped to this repository with: - Contents: Read and write - Pull requests: Read and write -3. Enable repository auto-merge in GitHub settings. -4. Protect `master`, require CI checks before merge, and enable merge queue. +3. Create a repository secret named `MEND_RNV_MC_TOKEN` (Merge Confidence API token) so confidence-based PR gating can work. +4. Enable repository auto-merge in GitHub settings. +5. Protect `master`, require CI checks before merge, and enable merge queue. + +If `MEND_RNV_MC_TOKEN` is not configured, updates remain in the dependency dashboard for manual approval. Why: PRs created with `GITHUB_TOKEN` do not trigger downstream `pull_request` workflows. Using `RENOVATE_TOKEN` ensures CI checks run and automerge can complete. @@ -134,11 +137,16 @@ Config file: `renovate.json` Behavior: -- Renovate runs with controlled concurrency (`prConcurrentLimit` and `branchConcurrentLimit` set to `3`) to reduce conflicts. -- Major updates are never auto-merged and require manual review. -- Minor, patch, pin, and digest updates are grouped into fewer PRs and auto-merge after checks pass. +- Renovate runs with strict concurrency (`prConcurrentLimit` and `branchConcurrentLimit` set to `1`) so only one dependency PR is active at a time. +- Renovate disables major/minor/patch stream separation so updates stay in a single grouped PR flow. +- Renovate waits for release-age stability checks (`minimumReleaseAge: 30 days`) before opening PRs. +- Npm updates are grouped into a single dependency PR stream and PRs are created only when merge confidence is `high` or `very high`. +- High-confidence minor/patch/pin/digest updates are auto-merged after checks pass. +- High-confidence major updates are auto-merged after checks pass. +- Low/neutral confidence updates stay in the dependency dashboard for manual approval. +- Lock file maintenance runs weekly and auto-merges after checks pass. - Renovate automatically rebases dependency PRs when they fall behind `master`. -- Custom regex managers keep template manifests, the resolver registry, and README dependency rows in sync. +- Custom regex managers keep template manifests, the resolver registry, selected test dependency fixtures, README dependency rows, and ARCHITECTURE dependency rows in sync. ## Screenshot diff --git a/SOLUTION_OVERVIEW.txt b/SOLUTION_OVERVIEW.txt deleted file mode 100644 index 2c5a146..0000000 --- a/SOLUTION_OVERVIEW.txt +++ /dev/null @@ -1,174 +0,0 @@ -╔══════════════════════════════════════════════════════════════════════════════╗ -║ SOLUTION: Cross-Platform Testing Infrastructure ║ -║ ║ -║ Problem: npx create-react-forge@latest fails with module resolution error ║ -║ Solution: Added peer dependency + comprehensive multi-platform testing ║ -╚══════════════════════════════════════════════════════════════════════════════╝ - -📦 PACKAGE.JSON CHANGES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ Added dependency: "@inquirer/core": "^9.1.0" -✅ New npm scripts: - - npm run test:cross-platform (Platform-specific tests) - - npm run test:e2e (CLI command tests) - - npm run test:local (Full local test suite) - -🧪 NEW TEST FILES -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ src/__tests__/integration/cross-platform-cli.test.ts - - Tests path handling (Windows \ vs Unix /) - - Tests file system case sensitivity - - Tests line ending handling (CRLF vs LF) - - Tests special characters in paths - - Tests file permissions on Unix - - Tests package manager detection - -✅ src/__tests__/integration/e2e-cli.test.ts - - Tests CLI version and help commands - - Tests exit codes - - Tests output consistency - - Tests concurrent execution - - Tests environment variables - - Tests error handling - -🚀 CI/CD PIPELINE -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ .github/workflows/cross-platform-tests.yml - - Test Matrix (6 combinations): - ┌─────────────────────────────────────┐ - │ OS │ Node 20.x │ Node 22.x │ - ├─────────────┼───────────┼───────────┤ - │ Ubuntu │ ✅ │ ✅ │ - │ Windows │ ✅ │ ✅ │ - │ macOS │ ✅ │ ✅ │ - └─────────────────────────────────────┘ - - Jobs: - ✅ Test Suite (unit, integration, cross-platform, e2e) - ✅ E2E Scaffold Tests (actual CLI execution) - ✅ Linting & Format Checks - ✅ Build Verification - -📚 DOCUMENTATION -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ CROSS_PLATFORM_TESTING.md - Comprehensive guide covering: - - Test coverage overview - - Running tests locally - - CI/CD pipeline details - - Platform differences - - Troubleshooting guide - - Best practices - -✅ IMPLEMENTATION_SUMMARY.md - What was implemented and why: - - Dependency fix - - Test suite details - - CI/CD pipeline setup - - Documentation overview - - Success criteria - -✅ QUICK_START_TESTING.md - Quick reference guide: - - Problem & solution - - Usage instructions - - Testing commands - - Platform details - - Troubleshooting - -✅ Updated README.md - - Added cross-platform support section - - Updated troubleshooting - - New npm scripts documented - -🔧 LOCAL TESTING SCRIPTS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ scripts/test-local.sh (macOS/Linux) - Automated testing script that: - - Checks Node version - - Installs dependencies - - Builds project - - Runs all test suites - - Tests CLI execution - - Shows platform info - - Displays coverage - -✅ scripts/test-local.bat (Windows) - Windows batch version with same functionality - -🎯 QUICK COMMANDS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -# Run all tests -npm test - -# Test cross-platform specific behaviors -npm run test:cross-platform - -# Test CLI commands -npm run test:e2e - -# Full local test suite (macOS/Linux) -npm run test:local - -# Windows local test suite -scripts/test-local.bat - -# Watch mode -npm run test:watch - -# Coverage report -npm run test:coverage - -✨ BENEFITS -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -✅ Fixed: npx create-react-forge@latest now works reliably -✅ Quality: Early detection of platform-specific bugs -✅ Coverage: Tests on Windows, macOS, and Linux -✅ Confidence: Verified on Node 20.x and 22.x -✅ Automation: Runs automatically on every PR/push -✅ Documentation: Comprehensive guides for developers -✅ Maintainability: Easy to add new cross-platform tests - -📊 TEST COVERAGE MATRIX -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Platform Behavior: - ✅ Path separators (\ vs /) - ✅ Case sensitivity (case-insensitive vs case-sensitive) - ✅ Line endings (CRLF vs LF) - ✅ Special characters - ✅ File permissions - -CLI Functionality: - ✅ Version/help commands - ✅ Exit codes - ✅ Output consistency - ✅ Concurrent execution - ✅ Error handling - ✅ Environment variables - -Build/Release: - ✅ Dependency installation - ✅ TypeScript compilation - ✅ Type definitions - ✅ Linting - ✅ Code formatting - -🚀 DEPLOYMENT -━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ -Ready for production! The solution includes: - ✅ Fixed core issue (@inquirer/core dependency) - ✅ Comprehensive test coverage - ✅ Automated CI/CD pipeline - ✅ Local testing tools - ✅ Complete documentation - -Next steps: - 1. Run: npm install - 2. Test: npm test - 3. Build: npm run build - 4. Deploy: Everything ready for release! - -╔══════════════════════════════════════════════════════════════════════════════╗ -║ IMPLEMENTATION COMPLETE ✅ ║ -╚══════════════════════════════════════════════════════════════════════════════╝ diff --git a/renovate.json b/renovate.json index bd7027a..834d1bf 100644 --- a/renovate.json +++ b/renovate.json @@ -1,19 +1,24 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:recommended"], + "extends": ["config:recommended", "mergeConfidence:age-confidence-badges"], "labels": ["dependencies"], "rangeStrategy": "bump", "dependencyDashboard": true, - "dependencyDashboardApproval": false, - "prCreation": "immediate", + "dependencyDashboardApproval": true, + "prCreation": "not-pending", "prHourlyLimit": 0, - "prConcurrentLimit": 3, - "branchConcurrentLimit": 3, + "prConcurrentLimit": 1, + "branchConcurrentLimit": 1, "rebaseWhen": "behind-base-branch", "recreateWhen": "always", "minimumReleaseAge": "30 days", + "internalChecksFilter": "strict", + "separateMajorMinor": false, + "separateMinorPatch": false, + "separateMultipleMajor": false, "lockFileMaintenance": { "enabled": true, + "schedule": ["before 4am on monday"], "automerge": true, "automergeType": "pr", "platformAutomerge": true @@ -39,6 +44,28 @@ "datasourceTemplate": "npm", "versioningTemplate": "npm" }, + { + "customType": "regex", + "description": "Keep dependency version fixtures in tests in sync", + "managerFilePatterns": [ + "/^src\\/__tests__\\/(assembler|dependency-resolver|config-merger)\\.test\\.ts$/" + ], + "matchStrings": [ + "['\"](?(?:react|react-dom|typescript|vitest|tsx|@testing-library\\/react))['\"]\\s*:\\s*['\"](?[~^]?\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?)['\"]" + ], + "datasourceTemplate": "npm", + "versioningTemplate": "npm" + }, + { + "customType": "regex", + "description": "Keep ARCHITECTURE dependency version snippet in sync", + "managerFilePatterns": ["/^ARCHITECTURE\\.md$/"], + "matchStrings": [ + "['\"](?[^'\"\\s]+)['\"]\\s*:\\s*['\"](?[~^]?\\d+\\.\\d+\\.\\d+(?:[-+][0-9A-Za-z.-]+)?)['\"]" + ], + "datasourceTemplate": "npm", + "versioningTemplate": "npm" + }, { "customType": "regex", "description": "Keep README React version row in sync", @@ -129,35 +156,57 @@ } ], "packageRules": [ - { - "description": "Automerge major updates after checks pass", - "matchUpdateTypes": ["major"], - "automerge": true, - "automergeType": "pr", - "platformAutomerge": true - }, { "description": "Keep ESLint on v9 until typescript-eslint adds ESLint v10 support", "matchPackageNames": ["eslint"], "allowedVersions": "<10.0.0" }, { - "description": "Keep ESLint on v9 until typescript-eslint adds ESLint v10 support", - "matchPackageNames": ["eslint"], - "allowedVersions": "<10.0.0" + "description": "Group all npm updates into a single dependency PR stream", + "matchDatasources": ["npm"], + "matchUpdateTypes": ["major", "minor", "patch", "pin", "digest"], + "groupName": "all npm dependencies", + "groupSlug": "all-npm-dependencies" }, { - "description": "Group non-major updates to reduce PR volume and conflict churn", - "matchUpdateTypes": ["minor", "patch", "pin", "digest"], - "groupName": "non-major dependencies", - "groupSlug": "non-major-dependencies" + "description": "Only create PRs for high-confidence npm updates", + "matchDatasources": ["npm"], + "matchConfidence": ["high", "very high"], + "dependencyDashboardApproval": false }, { - "description": "Automerge non-major dependency updates after checks pass", + "description": "Automerge high-confidence non-major npm updates", + "matchDatasources": ["npm"], "matchUpdateTypes": ["minor", "patch", "pin", "digest"], + "matchConfidence": ["high", "very high"], "automerge": true, "automergeType": "pr", "platformAutomerge": true + }, + { + "description": "Automerge lock file maintenance updates", + "matchUpdateTypes": ["lockFileMaintenance"], + "dependencyDashboardApproval": false, + "automerge": true, + "automergeType": "pr", + "platformAutomerge": true + }, + { + "description": "Automerge high-confidence major npm updates", + "matchDatasources": ["npm"], + "matchUpdateTypes": ["major"], + "matchConfidence": ["high", "very high"], + "dependencyDashboardApproval": false, + "automerge": true, + "automergeType": "pr", + "platformAutomerge": true + }, + { + "description": "Keep low/neutral confidence npm updates in dashboard for manual approval", + "matchDatasources": ["npm"], + "matchConfidence": ["low", "neutral"], + "dependencyDashboardApproval": true, + "automerge": false } ] } diff --git a/src/__tests__/integration/e2e-scenarios.test.ts b/src/__tests__/integration/e2e-scenarios.test.ts index 014da85..976aa2d 100644 --- a/src/__tests__/integration/e2e-scenarios.test.ts +++ b/src/__tests__/integration/e2e-scenarios.test.ts @@ -1,10 +1,13 @@ -import { describe, it, expect, afterEach } from 'vitest'; +import { describe, it, expect, afterEach, vi } from 'vitest'; import { existsSync, rmSync, readFileSync } from 'fs'; import { tmpdir } from 'os'; import { join } from 'path'; import { ProjectGenerator } from '../../generator/index'; import type { ProjectConfig } from '../../config/schema'; +// E2E generators do a full project scaffold; allow more time than the default 5s per test +vi.setConfig({ testTimeout: 30000 }); + /** * End-to-End Real-World Scenario Tests * Tests common project configurations that users actually use