"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getOptions = void 0;
const path = __importStar(require("path"));
const yargs_1 = __importDefault(require("yargs"));
const get_port_1 = __importDefault(require("get-port"));
const { argv } = yargs_1.default
    .option('path', {
    alias: 'p',
    type: 'string',
    description: 'Path to functions package',
})
    .option('port', {
    alias: 'P',
    type: 'number',
    description: 'Port to run preview server on',
})
    .option('generated', {
    alias: 'g',
    type: 'string',
    description: 'Path to build generated code at',
});
let PREVIEW_CLIENT_PORT;
let PREVIEW_SERVER_PORT;
let SERVER_PORT;
exports.getOptions = () => __awaiter(void 0, void 0, void 0, function* () {
    if (!PREVIEW_CLIENT_PORT)
        PREVIEW_CLIENT_PORT = yield get_port_1.default({
            port: argv.port || Number(process.env.PREVIEW_CLIENT_PORT) || 3000,
        });
    if (!PREVIEW_SERVER_PORT)
        PREVIEW_SERVER_PORT = yield get_port_1.default({
            port: argv.port || Number(process.env.PREVIEW_SERVER_PORT) || 3001,
        });
    if (!SERVER_PORT)
        SERVER_PORT = yield get_port_1.default({ port: argv.port || Number(process.env.SERVER_PORT) || 3002 });
    const FUNCTIONS_PATH = argv.path || process.env.FUNCTIONS_PATH || process.cwd();
    // const GENERATED_CODE_PATH = argv.generated || process.env.GENERATED_PATH || '/tmp/GeneratedCode';
    const GENERATED_CODE_PATH = path.join(process.cwd(), '.ui-studio');
    return {
        PREVIEW_CLIENT_PORT,
        PREVIEW_SERVER_PORT,
        SERVER_PORT,
        GENERATED_CODE_PATH,
        FUNCTIONS_PATH,
    };
});
//# sourceMappingURL=options.js.map