"use strict";

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

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

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

function _bluebird() {
  const data = require("bluebird");

  _bluebird = function () {
    return data;
  };

  return data;
}

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

  _defineProperty2 = function () {
    return data;
  };

  return data;
}

function _chalk() {
  const data = _interopRequireDefault(require("chalk"));

  _chalk = function () {
    return data;
  };

  return data;
}

function nodePath() {
  const data = _interopRequireWildcard(require("path"));

  nodePath = 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;
}

class EjectConf extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'eject-conf [id]');
    (0, _defineProperty2().default)(this, "description", 'ejecting components configuration');
    (0, _defineProperty2().default)(this, "alias", '');
    (0, _defineProperty2().default)(this, "opts", [['p', 'path <path>', 'ejecting configuration into a specific directory']]);
    (0, _defineProperty2().default)(this, "loader", true);
    (0, _defineProperty2().default)(this, "migration", true);
  }

  action([id], {
    path
  }) {
    return (0, _bluebird().coroutine)(function* () {
      const cwd = process.cwd();
      const res = yield (0, _consumer().ejectConf)(id, {
        ejectPath: path
      });
      res.ejectPathRelativeToCwd = nodePath().relative(cwd, res.ejectedFullPath);
      return res;
    })();
  }

  report(ejectResults) {
    return `successfully ejected ${_chalk().default.bold(ejectResults.id)} configuration to:\n${_chalk().default.green(ejectResults.ejectPathRelativeToCwd)}`;
  }

}

exports.default = EjectConf;