"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const ora_1 = __importDefault(require("ora"));
const core_1 = require("../../core");
const enum_1 = require("../utils/enum");
const adapters_1 = require("../adapters");
class Base {
    constructor(name = [core_1.ModuleName.eventTracker]) {
        this.eventTracker = (eventName, opt) => {
            return this.manager.execute(core_1.ModuleName.eventTracker, core_1.EventTrackerCmdEnum.Counter, eventName, opt);
        };
        const modules = new adapters_1.Modules(name);
        this.manager = modules.manager;
    }
    loading(step, done = false, isSuccess = true) {
        if (!this.spinner) {
            this.spinner = (0, ora_1.default)({
                text: step,
                discardStdin: false,
            }).start();
        }
        if (done) {
            if (isSuccess) {
                this.spinner.succeed(step);
            }
            else {
                this.spinner.fail(step);
            }
            this.spinner = undefined;
        }
        else {
            this.spinner.text = step;
        }
        return this.spinner;
    }
    async detectAppType(path) {
        const type = await this.manager.execute(core_1.ModuleName.sniffer, core_1.SnifferCmdEnum.GetAppType, path);
        switch (type) {
            case 'gadget':
                return enum_1.TypeEnum.Gadget;
            case 'block':
                return enum_1.TypeEnum.Block;
            default:
                return '';
        }
    }
}
exports.default = Base;
