export class ProjectTemplates {
    static TYPESCRIPT_LIBRARY = {
        name: 'TypeScript Library',
        description: 'A modern TypeScript library with testing and build setup',
        type: 'library',
        files: [
            {
                path: 'src/index.ts',
                content: `/**
 * {{projectName}} - {{description}}
 */

export class {{capitalizedName}} {
  private version = '1.0.0';
  
  constructor() {
    // TODO: Initialize your library
  }
  
  /**
   * Get the library version
   */
  getVersion(): string {
    return this.version;
  }
  
  /**
   * Example method - replace with your functionality
   */
  hello(name: string): string {
    return \`Hello, \${name}! Welcome to {{projectName}}.\`;
  }
}

// Default export
export default {{capitalizedName}};
`,
                isTemplate: true,
            },
            {
                path: 'src/types.ts',
                content: `/**
 * Type definitions for {{projectName}}
 */

export interface Config {
  apiUrl?: string;
  timeout?: number;
  retries?: number;
}

export interface ApiResponse<T = any> {
  data: T;
  status: number;
  message?: string;
}

export type LogLevel = 'debug' | 'info' | 'warn' | 'error';
`,
                isTemplate: true,
            },
            {
                path: 'tests/index.test.ts',
                content: `import { {{capitalizedName}} } from '../src/index';

describe('{{capitalizedName}}', () => {
  let instance: {{capitalizedName}};
  
  beforeEach(() => {
    instance = new {{capitalizedName}}();
  });
  
  describe('getVersion', () => {
    it('should return the correct version', () => {
      expect(instance.getVersion()).toBe('1.0.0');
    });
  });
  
  describe('hello', () => {
    it('should greet the user', () => {
      const result = instance.hello('World');
      expect(result).toBe('Hello, World! Welcome to {{projectName}}.');
    });
    
    it('should handle empty name', () => {
      const result = instance.hello('');
      expect(result).toBe('Hello, ! Welcome to {{projectName}}.');
    });
  });
});
`,
                isTemplate: true,
            },
            {
                path: 'tsconfig.json',
                content: `{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "node",
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "resolveJsonModule": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist", "tests"]
}
`,
                isTemplate: false,
            },
        ],
        scripts: {
            "build": "tsc",
            "test": "jest",
            "test:watch": "jest --watch",
            "test:coverage": "jest --coverage",
            "dev": "tsc --watch",
            "prepublishOnly": "npm run build && npm test"
        },
        dependencies: [],
        devDependencies: [
            "typescript",
            "@types/node",
            "@types/jest",
            "jest",
            "ts-jest"
        ],
        gitignoreEntries: [
            "dist/",
            "*.tgz",
            "coverage/"
        ],
        postInitSteps: [
            "Run 'npm install' to install dependencies",
            "Run 'npm test' to run the test suite",
            "Run 'npm run build' to build the library",
            "Update the README.md with your library's documentation"
        ]
    };
    static NODE_API = {
        name: 'Node.js API',
        description: 'RESTful API with Express, TypeScript, and testing',
        type: 'api',
        files: [
            {
                path: 'src/app.ts',
                content: `import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
import { errorHandler } from './middleware/errorHandler';
import { logger } from './utils/logger';
import apiRoutes from './routes';

const app = express();
const PORT = process.env.PORT || 3000;

// Middleware
app.use(helmet());
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));

// Routes
app.use('/api', apiRoutes);

// Health check
app.get('/health', (req, res) => {
  res.json({ status: 'OK', service: '{{projectName}}' });
});

// Error handling
app.use(errorHandler);

app.listen(PORT, () => {
  logger.info(\`{{projectName}} server running on port \${PORT}\`);
});

export default app;
`,
                isTemplate: true,
            },
            {
                path: 'src/routes/index.ts',
                content: `import { Router } from 'express';
import { healthController } from '../controllers/healthController';

const router = Router();

// Health endpoint
router.get('/health', healthController);

// TODO: Add your API routes here
// router.use('/users', userRoutes);
// router.use('/auth', authRoutes);

export default router;
`,
                isTemplate: false,
            },
            {
                path: 'src/controllers/healthController.ts',
                content: `import { Request, Response } from 'express';

export const healthController = (req: Request, res: Response) => {
  res.json({
    status: 'healthy',
    timestamp: new Date().toISOString(),
    uptime: process.uptime(),
    service: '{{projectName}}'
  });
};
`,
                isTemplate: true,
            },
            {
                path: 'src/middleware/errorHandler.ts',
                content: `import { Request, Response, NextFunction } from 'express';
import { logger } from '../utils/logger';

export interface AppError extends Error {
  statusCode?: number;
}

export const errorHandler = (
  err: AppError,
  req: Request,
  res: Response,
  next: NextFunction
) => {
  logger.error(err.message, { stack: err.stack, url: req.url, method: req.method });
  
  const statusCode = err.statusCode || 500;
  const message = statusCode === 500 ? 'Internal Server Error' : err.message;
  
  res.status(statusCode).json({
    error: {
      message,
      status: statusCode,
      timestamp: new Date().toISOString()
    }
  });
};
`,
                isTemplate: false,
            },
            {
                path: 'src/utils/logger.ts',
                content: `export const logger = {
  info: (message: string, meta?: any) => {
    console.log(\`[\${new Date().toISOString()}] INFO: \${message}\`, meta || '');
  },
  
  error: (message: string, meta?: any) => {
    console.error(\`[\${new Date().toISOString()}] ERROR: \${message}\`, meta || '');
  },
  
  warn: (message: string, meta?: any) => {
    console.warn(\`[\${new Date().toISOString()}] WARN: \${message}\`, meta || '');
  },
  
  debug: (message: string, meta?: any) => {
    if (process.env.NODE_ENV === 'development') {
      console.debug(\`[\${new Date().toISOString()}] DEBUG: \${message}\`, meta || '');
    }
  }
};
`,
                isTemplate: false,
            },
            {
                path: 'tests/app.test.ts',
                content: `import request from 'supertest';
import app from '../src/app';

describe('{{projectName}} API', () => {
  describe('GET /health', () => {
    it('should return health status', async () => {
      const response = await request(app)
        .get('/health')
        .expect(200);
        
      expect(response.body).toHaveProperty('status', 'OK');
      expect(response.body).toHaveProperty('service', '{{projectName}}');
    });
  });
  
  describe('GET /api/health', () => {
    it('should return detailed health info', async () => {
      const response = await request(app)
        .get('/api/health')
        .expect(200);
        
      expect(response.body).toHaveProperty('status', 'healthy');
      expect(response.body).toHaveProperty('timestamp');
      expect(response.body).toHaveProperty('uptime');
    });
  });
});
`,
                isTemplate: true,
            }
        ],
        scripts: {
            "start": "node dist/app.js",
            "dev": "tsx watch src/app.ts",
            "build": "tsc",
            "test": "jest",
            "test:watch": "jest --watch",
            "test:coverage": "jest --coverage"
        },
        dependencies: [
            "express",
            "cors",
            "helmet"
        ],
        devDependencies: [
            "typescript",
            "@types/node",
            "@types/express",
            "@types/cors",
            "@types/jest",
            "@types/supertest",
            "jest",
            "supertest",
            "tsx",
            "ts-jest"
        ],
        gitignoreEntries: [
            "dist/",
            ".env",
            "*.log"
        ],
        postInitSteps: [
            "Run 'npm install' to install dependencies",
            "Run 'npm run dev' to start development server",
            "Visit http://localhost:3000/health to test the API",
            "Add your API routes in src/routes/"
        ]
    };
    static REACT_APP = {
        name: 'React TypeScript App',
        description: 'Modern React app with TypeScript, testing, and development tools',
        type: 'web-app',
        files: [
            {
                path: 'src/App.tsx',
                content: `import React from 'react';
import { Header } from './components/Header';
import { Welcome } from './components/Welcome';
import './App.css';

function App() {
  return (
    <div className="App">
      <Header title="{{projectName}}" />
      <main>
        <Welcome name="{{projectName}}" />
      </main>
    </div>
  );
}

export default App;
`,
                isTemplate: true,
            },
            {
                path: 'src/components/Header.tsx',
                content: `import React from 'react';

interface HeaderProps {
  title: string;
}

export const Header: React.FC<HeaderProps> = ({ title }) => {
  return (
    <header className="header">
      <h1>{title}</h1>
      <nav>
        <a href="#home">Home</a>
        <a href="#about">About</a>
        <a href="#contact">Contact</a>
      </nav>
    </header>
  );
};
`,
                isTemplate: false,
            },
            {
                path: 'src/components/Welcome.tsx',
                content: `import React, { useState } from 'react';

interface WelcomeProps {
  name: string;
}

export const Welcome: React.FC<WelcomeProps> = ({ name }) => {
  const [count, setCount] = useState(0);

  return (
    <div className="welcome">
      <h2>Welcome to {name}!</h2>
      <p>This is your new React TypeScript application.</p>
      
      <div className="counter">
        <button onClick={() => setCount(count - 1)}>-</button>
        <span>Count: {count}</span>
        <button onClick={() => setCount(count + 1)}>+</button>
      </div>
      
      <p>
        Edit <code>src/App.tsx</code> and save to reload.
      </p>
    </div>
  );
};
`,
                isTemplate: false,
            },
            {
                path: 'src/App.css',
                content: `.App {
  text-align: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid #e1e5e9;
  margin-bottom: 2rem;
}

.header h1 {
  margin: 0;
  color: #333;
}

.header nav a {
  margin: 0 1rem;
  text-decoration: none;
  color: #666;
  transition: color 0.2s;
}

.header nav a:hover {
  color: #007bff;
}

.welcome {
  max-width: 600px;
  margin: 0 auto;
}

.counter {
  margin: 2rem 0;
}

.counter button {
  background: #007bff;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  margin: 0 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.counter button:hover {
  background: #0056b3;
}

.counter span {
  font-size: 1.2rem;
  font-weight: bold;
}

code {
  background: #f8f9fa;
  padding: 0.2rem 0.4rem;
  border-radius: 3px;
  font-family: 'Monaco', 'Menlo', monospace;
}
`,
                isTemplate: false,
            },
            {
                path: 'src/tests/App.test.tsx',
                content: `import React from 'react';
import { render, screen, fireEvent } from '@testing-library/react';
import App from '../App';

describe('App', () => {
  it('renders project title', () => {
    render(<App />);
    const titleElement = screen.getByText(/{{projectName}}/i);
    expect(titleElement).toBeInTheDocument();
  });
  
  it('renders welcome message', () => {
    render(<App />);
    const welcomeElement = screen.getByText(/Welcome to {{projectName}}!/i);
    expect(welcomeElement).toBeInTheDocument();
  });
  
  it('increments counter when plus button is clicked', () => {
    render(<App />);
    const plusButton = screen.getByText('+');
    const countDisplay = screen.getByText(/Count: 0/);
    
    fireEvent.click(plusButton);
    
    expect(screen.getByText(/Count: 1/)).toBeInTheDocument();
  });
});
`,
                isTemplate: true,
            },
            {
                path: 'public/index.html',
                content: `<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{{projectName}}</title>
</head>
<body>
  <div id="root"></div>
</body>
</html>
`,
                isTemplate: true,
            }
        ],
        scripts: {
            "start": "react-scripts start",
            "build": "react-scripts build",
            "test": "react-scripts test",
            "eject": "react-scripts eject"
        },
        dependencies: [
            "react",
            "@types/react",
            "react-dom",
            "@types/react-dom"
        ],
        devDependencies: [
            "react-scripts",
            "@testing-library/react",
            "@testing-library/jest-dom",
            "@testing-library/user-event",
            "typescript"
        ],
        gitignoreEntries: [
            "build/",
            ".env.local",
            ".env.development.local",
            ".env.test.local",
            ".env.production.local"
        ],
        postInitSteps: [
            "Run 'npm install' to install dependencies",
            "Run 'npm start' to start development server",
            "Visit http://localhost:3000 to see your app",
            "Run 'npm test' to run the test suite"
        ]
    };
    static CLI_TOOL = {
        name: 'CLI Tool',
        description: 'Command-line interface tool with TypeScript and Commander.js',
        type: 'cli-tool',
        files: [
            {
                path: 'src/index.ts',
                content: `#!/usr/bin/env node
import { Command } from 'commander';
import { logger } from './utils/logger';
import { version } from '../package.json';

const program = new Command();

program
  .name('{{kebabName}}')
  .description('{{description}}')
  .version(version);

program
  .command('hello')
  .description('Say hello')
  .option('-n, --name <name>', 'name to greet', 'World')
  .action((options) => {
    logger.info(\`Hello, \${options.name}!\`);
  });

program
  .command('config')
  .description('Manage configuration')
  .option('-s, --set <key=value>', 'set configuration value')
  .option('-g, --get <key>', 'get configuration value')
  .action((options) => {
    if (options.set) {
      const [key, value] = options.set.split('=');
      logger.info(\`Setting \${key} = \${value}\`);
      // TODO: Implement config storage
    }
    
    if (options.get) {
      logger.info(\`Getting \${options.get}\`);
      // TODO: Implement config retrieval
    }
  });

program.parse();
`,
                isTemplate: true,
            },
            {
                path: 'src/utils/logger.ts',
                content: `import chalk from 'chalk';

export const logger = {
  info: (message: string) => {
    console.log(chalk.blue('ℹ'), message);
  },
  
  success: (message: string) => {
    console.log(chalk.green('✓'), message);
  },
  
  error: (message: string) => {
    console.error(chalk.red('✗'), message);
  },
  
  warn: (message: string) => {
    console.warn(chalk.yellow('⚠'), message);
  },
  
  debug: (message: string) => {
    if (process.env.DEBUG) {
      console.debug(chalk.gray('🐛'), message);
    }
  }
};
`,
                isTemplate: false,
            },
            {
                path: 'src/utils/config.ts',
                content: `import { promises as fs } from 'fs';
import path from 'path';
import os from 'os';

const CONFIG_DIR = path.join(os.homedir(), '.{{kebabName}}');
const CONFIG_FILE = path.join(CONFIG_DIR, 'config.json');

export interface Config {
  [key: string]: any;
}

export class ConfigManager {
  private config: Config = {};
  
  async load(): Promise<void> {
    try {
      const data = await fs.readFile(CONFIG_FILE, 'utf-8');
      this.config = JSON.parse(data);
    } catch (error) {
      // Config file doesn't exist, use defaults
      this.config = {};
    }
  }
  
  async save(): Promise<void> {
    await fs.mkdir(CONFIG_DIR, { recursive: true });
    await fs.writeFile(CONFIG_FILE, JSON.stringify(this.config, null, 2));
  }
  
  get(key: string): any {
    return this.config[key];
  }
  
  set(key: string, value: any): void {
    this.config[key] = value;
  }
  
  has(key: string): boolean {
    return key in this.config;
  }
  
  delete(key: string): void {
    delete this.config[key];
  }
  
  all(): Config {
    return { ...this.config };
  }
}
`,
                isTemplate: true,
            },
            {
                path: 'tests/cli.test.ts',
                content: `import { exec } from 'child_process';
import { promisify } from 'util';

const execAsync = promisify(exec);

describe('{{projectName}} CLI', () => {
  it('should show help message', async () => {
    const { stdout } = await execAsync('npm run cli -- --help');
    expect(stdout).toContain('{{description}}');
  });
  
  it('should show version', async () => {
    const { stdout } = await execAsync('npm run cli -- --version');
    expect(stdout.trim()).toMatch(/\\d+\\.\\d+\\.\\d+/);
  });
  
  it('should greet with default name', async () => {
    const { stdout } = await execAsync('npm run cli hello');
    expect(stdout).toContain('Hello, World!');
  });
  
  it('should greet with custom name', async () => {
    const { stdout } = await execAsync('npm run cli hello --name Test');
    expect(stdout).toContain('Hello, Test!');
  });
});
`,
                isTemplate: true,
            }
        ],
        scripts: {
            "build": "tsc",
            "cli": "tsx src/index.ts",
            "dev": "tsx watch src/index.ts",
            "test": "jest",
            "prepublishOnly": "npm run build"
        },
        dependencies: [
            "commander",
            "chalk"
        ],
        devDependencies: [
            "typescript",
            "@types/node",
            "@types/jest",
            "jest",
            "tsx",
            "ts-jest"
        ],
        gitignoreEntries: [
            "dist/",
            "*.log"
        ],
        postInitSteps: [
            "Run 'npm install' to install dependencies",
            "Run 'npm run cli -- --help' to see available commands",
            "Run 'npm run cli hello' to test the CLI",
            "Add your commands to src/index.ts"
        ]
    };
    /**
     * Get all available templates
     */
    static getAllTemplates() {
        return [
            this.TYPESCRIPT_LIBRARY,
            this.NODE_API,
            this.REACT_APP,
            this.CLI_TOOL,
        ];
    }
    /**
     * Get template by type
     */
    static getTemplate(type) {
        return this.getAllTemplates().find(t => t.type === type);
    }
    /**
     * Process template variables in content
     */
    static processTemplate(content, variables) {
        let processed = content;
        for (const [key, value] of Object.entries(variables)) {
            const regex = new RegExp(`{{${key}}}`, 'g');
            processed = processed.replace(regex, value);
        }
        return processed;
    }
    /**
     * Generate template variables from project config
     */
    static generateVariables(config) {
        const capitalizedName = config.name
            .split(/[-_\s]+/)
            .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
            .join('');
        const kebabName = config.name
            .toLowerCase()
            .replace(/[^a-z0-9]+/g, '-')
            .replace(/^-+|-+$/g, '');
        return {
            projectName: config.name,
            description: config.description || `A ${config.type} project`,
            capitalizedName,
            kebabName,
            type: config.type,
            language: config.language || 'typescript',
            author: config.author || '',
            license: config.license || 'MIT',
        };
    }
}
//# sourceMappingURL=templates.js.map