"use strict";
const helpers_1 = require("../../common/helpers");
class ListPluginsCommand {
    constructor($pluginsService, $logger) {
        this.$pluginsService = $pluginsService;
        this.$logger = $logger;
        this.allowedParameters = [];
    }
    execute(args) {
        return (() => {
            let installedPlugins = this.$pluginsService.getDependenciesFromPackageJson().wait();
            let headers = ["Plugin", "Version"];
            let dependenciesData = this.createTableCells(installedPlugins.dependencies);
            let dependenciesTable = helpers_1.createTable(headers, dependenciesData);
            this.$logger.out("Dependencies:");
            this.$logger.out(dependenciesTable.toString());
            if (installedPlugins.devDependencies && installedPlugins.devDependencies.length) {
                let devDependenciesData = this.createTableCells(installedPlugins.devDependencies);
                let devDependenciesTable = helpers_1.createTable(headers, devDependenciesData);
                this.$logger.out("Dev Dependencies:");
                this.$logger.out(devDependenciesTable.toString());
            }
            else {
                this.$logger.out("There are no dev dependencies.");
            }
            let viewDependenciesCommand = "npm view <pluginName> grep dependencies".cyan.toString();
            let viewDevDependenciesCommand = "npm view <pluginName> grep devDependencies".cyan.toString();
            this.$logger.warn("NOTE:");
            this.$logger.warn(`If you want to check the dependencies of installed plugin use ${viewDependenciesCommand}`);
            this.$logger.warn(`If you want to check the dev dependencies of installed plugin use ${viewDevDependenciesCommand}`);
        }).future()();
    }
    createTableCells(items) {
        return items.map(item => [item.name, item.version]);
    }
}
exports.ListPluginsCommand = ListPluginsCommand;
$injector.registerCommand("plugin|*list", ListPluginsCommand);
