npm package: @mairistem/migrator
Description: Migration tool to convert React projects to Next.js turbo monorepo with e2e testing
Author: Mairistem
Latest version: 0.0.1

# @mairistem/migrator

Migration tool to convert React projects to Next.js turbo monorepo with e2e testing using Playwright.

## Installation

```bash
# Using npx (recommended)
npx @mairistem/migrator ./my-react-project

# Or install globally
npm install -g @mairistem/migrator
mairistem-migrator ./my-react-project
```

## Usage

```bash
npx @mairistem/migrator <source-project-path>
```

### Arguments

- `source-project-path`: Path to the React project you want to migrate

### Examples

```bash
# Migrate a project in the current directory
npx @mairistem/migrator ./mon-projet

# Migrate a project with absolute path
npx @mairistem/migrator /path/to/my-react-app

# Migrate a project in parent directory
npx @mairistem/migrator ../existing-project
```

## What it does

The migrator will:

1. **Analyze** your React project structure
2. **Create** a new turbo monorepo with the name `{project-name}-turbo`
3. **Generate** a Next.js web application in `apps/web/`
4. **Create** e2e tests with Playwright in `apps/e2e/`
5. **Extract** React Features into Next.js pages
6. **Set up** the complete workspace structure with packages

## Project Structure Created

```
my-project-turbo/
├── apps/
│   ├── web/           # Next.js application
│   └── e2e/           # Playwright e2e tests
├── packages/
│   ├── components/    # Shared components
│   ├── ui/           # UI components
│   ├── shared/       # Shared utilities
│   └── ...          # Other packages
├── package.json      # Root package.json
├── turbo.json       # Turbo configuration
└── ...
```

## Requirements

- **Node.js** >= 18.0.0
- **Source project** must contain an index file with React `render()` call
- **Supported index files**:
  - `src/index.{tsx,ts,jsx,js}`
  - `index.{tsx,ts,jsx,js}`
  - `src/main.{tsx,ts,jsx,js}`

## Features

### Component Detection

The migrator automatically detects:

- `Menu` components with `path` attributes
- `Feature` components with `Feature.Content`
- Nested component structures
- Component references and definitions

### Page Generation

Each detected Feature becomes a Next.js page:

- Route structure based on Menu/Feature path hierarchy
- Dynamic routes with parameters (`[param]`)
- Proper Next.js app directory structure

### E2E Testing

Automatically sets up:

- Playwright configuration
- Sample test files (smoke, regression)
- Test utilities and fixtures
- CI/CD ready setup

## Troubleshooting

### Common Issues

1. **No index file found**
   - Ensure your project has one of the supported index files
   - Check that the file contains a React `render()` call

2. **No features detected**
   - Verify your components follow the expected structure:
     ```jsx
     <Menu path="/example">
       <Feature path="feature1">
         <Feature.Content>{/* Your content */}</Feature.Content>
       </Feature>
     </Menu>
     ```

3. **Migration fails**
   - Check Node.js version (>= 18.0.0)
   - Ensure sufficient disk space
   - Verify source project is a valid React project

### Getting Help

If you encounter issues:

1. Check the console output for detailed error messages
2. Verify your project structure matches requirements
3. Ensure all dependencies are properly installed

## Development

To work on this package:

```bash
# Clone and setup
git clone <repository>
cd migrator
npm install

# Test locally
npm link
mairistem-migrator ./test-project
```

## License

MIT