"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getMakeOptions = void 0;
const path_1 = __importDefault(require("path"));
const core_1 = require("@electron-forge/core");
const get_1 = require("@electron/get");
const commander_1 = __importDefault(require("commander"));
const fs_extra_1 = __importDefault(require("fs-extra"));
require("./util/terminate");
const working_dir_1 = __importDefault(require("./util/working-dir"));
async function getMakeOptions() {
    let dir = process.cwd();
    commander_1.default
        .version((await fs_extra_1.default.readJson(path_1.default.resolve(__dirname, '../package.json'))).version)
        .arguments('[cwd]')
        .option('--skip-package', 'Assume the app is already packaged')
        .option('-a, --arch [arch]', 'Target architecture')
        .option('-p, --platform [platform]', 'Target build platform')
        .option('--targets [targets]', 'Override your make targets for this run')
        .allowUnknownOption(true)
        .action((cwd) => {
        dir = (0, working_dir_1.default)(dir, cwd);
    })
        .parse(process.argv);
    const makeOpts = {
        dir,
        interactive: true,
        skipPackage: commander_1.default.skipPackage,
    };
    if (commander_1.default.targets)
        makeOpts.overrideTargets = commander_1.default.targets.split(',');
    if (commander_1.default.arch)
        makeOpts.arch = commander_1.default.arch;
    if (commander_1.default.platform)
        makeOpts.platform = commander_1.default.platform;
    return makeOpts;
}
exports.getMakeOptions = getMakeOptions;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (require.main === module || global.__LINKED_FORGE__) {
    (async () => {
        const makeOpts = await getMakeOptions();
        (0, get_1.initializeProxy)();
        await core_1.api.make(makeOpts);
    })();
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZWxlY3Ryb24tZm9yZ2UtbWFrZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9lbGVjdHJvbi1mb3JnZS1tYWtlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLGdEQUF3QjtBQUV4QiwrQ0FBd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