"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@oclif/core");
const _cliter_1 = require("../@cliter");
const back_1 = require("../@cliter/functions/back");
class New extends core_1.Command {
    async run() {
        const { args, flags } = await this.parse(New);
        switch (args.firstArg) {
            case _cliter_1.Scope.BACK:
                await _cliter_1.BackHandler.new({
                    appName: args.secondArg,
                    command: this,
                    flags,
                });
                await (0, back_1.generateEnvFile)(this, args.secondArg);
                if (flags.install)
                    await (0, back_1.installDependencies)(args.secondArg);
                break;
            case _cliter_1.Scope.FRONT:
                await _cliter_1.FrontHandler.new({
                    appName: args.secondArg,
                    command: this,
                    flags,
                });
                if (flags.install)
                    await (0, back_1.installDependencies)(args.secondArg);
                break;
        }
    }
}
exports.default = New;
New.description = 'Create new aurora item';
New.flags = {
    help: core_1.Flags.help({ char: 'h' }),
    force: core_1.Flags.boolean({
        char: 'f',
        description: 'Overwrite existing files.',
    }),
    install: core_1.Flags.boolean({
        char: 'i',
        description: 'Install dependencies after create item.',
    }),
    verbose: core_1.Flags.boolean({
        char: 'v',
        description: 'Reports on screen all the steps followed by the command.',
    }),
};
New.args = {
    firstArg: core_1.Args.string({
        name: 'scope',
        required: true,
        description: 'Scope where our command will act.',
        options: [
            'back',
            'front',
        ],
    }),
    secondArg: core_1.Args.string({
        name: 'name',
        required: true,
        description: 'Name of item to create',
    }),
};
New.examples = [
    '$ aurora new back my-app',
    '$ aurora --help',
];
