"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

function Promise() {
  const data = _interopRequireWildcard(require("bluebird"));

  Promise = function () {
    return data;
  };

  return data;
}

function _loudRejection() {
  const data = _interopRequireDefault(require("loud-rejection"));

  _loudRejection = function () {
    return data;
  };

  return data;
}

function _commandRegistrarBuilder() {
  const data = _interopRequireDefault(require("./cli/command-registrar-builder"));

  _commandRegistrarBuilder = function () {
    return data;
  };

  return data;
}

function _extensionsLoader() {
  const data = _interopRequireDefault(require("./extensions/extensions-loader"));

  _extensionsLoader = function () {
    return data;
  };

  return data;
}

function _hooks() {
  const data = _interopRequireDefault(require("./hooks"));

  _hooks = function () {
    return data;
  };

  return data;
}

Promise().config({
  longStackTraces: false // change it to true for easy debugging. by default, leave it as false for better performance

});
(0, _loudRejection().default)();

_hooks().default.init(); // Load extensions


(0, _extensionsLoader().default)().then(extensions => {
  // Make sure to register all the hooks actions in the global hooks manager
  extensions.forEach(extension => {
    extension.registerHookActionsOnHooksManager();
  });
  const extensionsCommands = extensions.reduce((acc, curr) => {
    if (curr.commands && curr.commands.length) {
      acc = acc.concat(curr.commands);
    }

    return acc;
  }, []);
  const registrar = (0, _commandRegistrarBuilder().default)(extensionsCommands);

  try {
    registrar.run();
  } catch (err) {
    console.error('loud rejected:', err); // eslint-disable-line no-console
  }
});