#!/usr/bin/env node
"use strict";
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 });
const minimist_1 = __importDefault(require("minimist"));
const chalk_1 = __importDefault(require("chalk"));
const new_project_1 = __importDefault(require("./commands/new-project"));
const dev_1 = __importDefault(require("./commands/dev"));
const create_env_1 = __importDefault(require("./commands/create-env"));
const add_dao_1 = __importDefault(require("./commands/add-dao"));
const add_plugin_1 = __importDefault(require("./commands/add-plugin"));
const add_auth_1 = __importDefault(require("./commands/add-auth"));
const deploy_1 = __importDefault(require("./commands/deploy"));
const remove_1 = __importDefault(require("./commands/remove"));
const cli = () => __awaiter(void 0, void 0, void 0, function* () {
    const majorVersion = parseInt((/^(\d+)(\.\d+){0,2}$/.exec(process.versions.node))[1], 10);
    if (majorVersion < 12) {
        throw new Error('Restlessness cli requires node version >= 12.x');
    }
    process.env['RLN_PROJECT_PATH'] = process.env['RLN_PROJECT_PATH'] || process.cwd();
    const argv = minimist_1.default(process.argv.slice(2));
    switch (argv._[0]) {
        case 'new':
            yield new_project_1.default(argv);
            break;
        case 'dev':
            yield dev_1.default(argv);
            break;
        case 'create-env':
            yield create_env_1.default(argv);
            break;
        case 'add-dao':
            yield add_dao_1.default(argv);
            break;
        case 'add-plugin':
            yield add_plugin_1.default(argv);
            break;
        case 'add-auth':
            yield add_auth_1.default(argv);
            break;
        case 'deploy':
            yield deploy_1.default(argv);
            break;
        case 'remove':
            yield remove_1.default(argv);
            break;
        default:
            console.log(chalk_1.default.red('Wrong invocation of RLN'));
            break;
    }
});
cli().then().catch(e => {
    console.error(chalk_1.default.red(e));
    process.exit(1);
});
//# sourceMappingURL=index.js.map