"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.proxyPrompts = exports.FALLBACK_PROXYNAME = void 0;
const helpers_1 = require("../utils/helpers");
const path_1 = __importDefault(require("path"));
exports.FALLBACK_PROXYNAME = 'sitecore-jss-proxy-app';
/**
 * Set of CLI prompts for an SXP app
 */
exports.proxyPrompts = [
    {
        type: 'input',
        name: 'proxyAppDestination',
        message: 'Where would you like your proxy app created?',
        default: (answers) => {
            // default proxy destination should be under same root as main app
            return (0, helpers_1.getDefaultProxyDestination)(answers.destination, answers.proxyName || exports.FALLBACK_PROXYNAME);
        },
        when: (answers) => {
            if (answers.yes && !answers.proxyAppDestination) {
                answers.proxyAppDestination = (0, helpers_1.getDefaultProxyDestination)(answers.destination, answers.proxyName || exports.FALLBACK_PROXYNAME);
            }
            return !answers.proxyAppDestination;
        },
        validate: (input, answers) => {
            if (path_1.default.resolve(input) === path_1.default.resolve(answers.destination)) {
                return 'Paths for main app and proxy cannot match. Please choose another destination';
            }
            return true;
        },
    },
];
