#!/usr/bin/env node import * as path from "node:path"; import { fileURLToPath } from "node:url"; import chalk from "chalk"; import { createApp, discoverTemplates } from "./index.js"; type ParsedArgs = { projectName?: string; template?: string; config?: Record; help?: boolean; }; function parseArgs(args: string[]): ParsedArgs { const result: ParsedArgs = { config: {}, }; for (let i = 0; i < args.length; i++) { const arg = args[i]; if (arg === "--help" || arg === "-h") { result.help = true; } else if (arg === "--template" || arg === "-t") { result.template = args[++i]; } else if (arg.startsWith("--")) { // Handle --key=value or --key value const [key, value] = arg.includes("=") ? arg.split("=", 2) : [arg, args[++i]]; const configKey = key.replace(/^--/, ""); // Try to parse as number, otherwise keep as string const parsedValue = !Number.isNaN(Number(value)) && value !== "" ? Number(value) : value; if (result.config) { result.config[configKey] = parsedValue; } } else if (!result.projectName) { result.projectName = arg; } } return result; } function showHelp() { const __dirname = path.dirname(fileURLToPath(import.meta.url)); const templatesDir = path.join(__dirname, "..", "templates"); const templates = discoverTemplates(templatesDir); console.log(chalk.blue("Create App - Project scaffolding for applications and libraries")); console.log(); console.log(chalk.bold("Usage:")); console.log(" npx @mariozechner/create-app [options]"); console.log(); console.log(chalk.dim("Running with just a project name starts interactive mode")); console.log(); console.log(chalk.bold("Options:")); console.log(" -t, --template Template to use"); console.log(" -h, --help Show this help message"); console.log(" --