"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 _chalk() {
  const data = _interopRequireDefault(require("chalk"));

  _chalk = 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 _constants() {
  const data = require("../../../constants");

  _constants = function () {
    return data;
  };

  return data;
}

class Move extends _command().default {
  constructor(...args) {
    super(...args);
    (0, _defineProperty2().default)(this, "name", 'move <from> <to>');
    (0, _defineProperty2().default)(this, "description", `move files or directories of component(s)\n  https://${_constants().BASE_DOCS_DOMAIN}/docs/cli-move.html`);
    (0, _defineProperty2().default)(this, "alias", 'mv');
    (0, _defineProperty2().default)(this, "opts", []);
    (0, _defineProperty2().default)(this, "loader", true);
  }

  action([from, to]) {
    return (0, _consumer().move)({
      from,
      to
    });
  }

  report(componentsChanged) {
    const output = componentsChanged.map(component => {
      const title = _chalk().default.green(`moved component ${component.id.toString()}:\n`);

      const files = component.changes.map(file => `from ${_chalk().default.bold(file.from)} to ${_chalk().default.bold(file.to)}`).join('\n');
      return title + files;
    });
    return output.join('\n');
  }

}

exports.default = Move;