"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

function _defineProperty2() {
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

  _defineProperty2 = function () {
    return data;
  };

  return data;
}

function _command() {
  const data = _interopRequireDefault(require("../../command"));

  _command = function () {
    return data;
  };

  return data;
}

function _consumer() {
  const data = require("../../../api/consumer");

  _consumer = function () {
    return data;
  };

  return data;
}

function _ejectTemplate() {
  const data = _interopRequireDefault(require("../../templates/eject-template"));

  _ejectTemplate = function () {
    return data;
  };

  return data;
}

class Eject extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'eject <id...>');
    (0, _defineProperty2().default)(this, "description", 'replaces the components from the local scope with the corresponding packages');
    (0, _defineProperty2().default)(this, "alias", 'E');
    (0, _defineProperty2().default)(this, "opts", [['f', 'force', 'ignore local version. remove the components even when they are staged or modified'], ['j', 'json', 'print the results in JSON format']]);
    (0, _defineProperty2().default)(this, "loader", true);
    (0, _defineProperty2().default)(this, "migration", true);
  }

  action([ids], {
    force,
    json
  }) {
    return (0, _consumer().ejectAction)(ids, force).then(ejectResults => ({
      ejectResults,
      json
    }));
  }

  report({
    ejectResults,
    json
  }) {
    if (json) return JSON.stringify(ejectResults, null, 2);
    return (0, _ejectTemplate().default)(ejectResults);
  }

}

exports.default = Eject;