#!/usr/bin/env node
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const inquirer_1 = __importDefault(require("inquirer"));
const appGenerator_1 = require("../src/generators/appGenerator");
async function main() {
    console.log("🚀 Welcome to RNStarterKit!");
    const answers = await inquirer_1.default.prompt([
        {
            type: "input",
            name: "projectName",
            message: "Project name:",
            validate: (input) => /^[A-Za-z0-9]+$/.test(input)
                ? true
                : "Project name must be alphanumeric",
        },
        {
            type: "rawlist",
            name: "platform",
            message: "Choose platform",
            choices: ["Expo", "React Native CLI"],
        },
        {
            type: "confirm",
            name: "typescript",
            message: "Use TypeScript?",
            default: true,
        },
        {
            type: "confirm",
            name: "absoluteImports",
            message: "Use absolute import alias (@/*)?",
            default: true,
        },
        {
            type: "rawlist",
            name: "state",
            message: "State management?",
            choices: ["None", "Context API", "Redux Toolkit", "Zustand"],
            default: "Context API",
        },
        {
            type: "rawlist",
            name: "dataFetching",
            message: "Data fetching library?",
            choices: ["None", "React Query", "SWR"],
            default: "None",
        },
        {
            type: "checkbox",
            name: "validation",
            message: "Validation libraries?",
            choices: ["Formik", "React Hook Form", "Yup"],
            default: [],
            validate: (selected) => {
                if (selected.includes("Formik") && !selected.includes("Yup")) {
                    return "Formik requires Yup in this starter. Select Yup as well.";
                }
                return true;
            },
        },
        {
            type: "rawlist",
            name: "storage",
            message: "Storage method?",
            choices: ["AsyncStorage", "MMKV", "None"],
            default: "AsyncStorage",
        },
        {
            type: "confirm",
            name: "auth",
            message: "Include auth scaffold?",
            default: false,
        },
        {
            type: "confirm",
            name: "apiClient",
            message: "Include API client scaffold?",
            default: true,
        },
        {
            type: "rawlist",
            name: "apiClientType",
            message: "API client transport?",
            choices: ["Fetch", "Axios"],
            default: "Fetch",
            when: (answers) => answers.apiClient,
        },
        {
            type: "confirm",
            name: "ci",
            message: "Include CI setup?",
            default: false,
        },
        {
            type: "confirm",
            name: "husky",
            message: "Set up Husky pre-commit hooks (lint-staged)?",
            default: true,
        },
    ]);
    await (0, appGenerator_1.generateApp)(answers);
}
main().catch((error) => {
    console.error("❌ Failed to create project.");
    console.error(error);
    process.exit(1);
});
