'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.failureEjectMessage = exports.successEjectMessage = undefined;
exports.default = ejectTemplate;

var _chalk;

function _load_chalk() {
  return _chalk = _interopRequireDefault(require('chalk'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var successEjectMessage = exports.successEjectMessage = 'successfully ejected the following components';
var failureEjectMessage = exports.failureEjectMessage = 'failed to eject the following components';

function ejectTemplate(ejectResults) {
  var getEjectedOutput = function getEjectedOutput() {
    if (!ejectResults.ejectedComponents.length) return '';
    return (_chalk || _load_chalk()).default.green(`${successEjectMessage} ${(_chalk || _load_chalk()).default.bold(ejectResults.ejectedComponents.toString())}\n`);
  };
  var getFailureOutput = function getFailureOutput() {
    var failures = ejectResults.failedComponents;
    var title = (_chalk || _load_chalk()).default.red(`${failureEjectMessage}\n`);
    var modified = failures.modifiedComponents.length ? `components with local modification (use --force to ignore): ${failures.modifiedComponents.toString()}\n` : '';
    var staged = failures.stagedComponents.length ? `components with local versions (use --force to ignore): ${failures.stagedComponents.toString()}\n` : '';
    var notExported = failures.notExportedComponents.length ? `local components that were not exported yet: ${failures.notExportedComponents.toString()}\n` : '';
    var selfHosted = failures.selfHostedExportedComponents.length ? `components that were exported to a self hosted scope (not bitsrc): ${failures.selfHostedExportedComponents.toString()}\n` : '';
    var body = modified + staged + notExported + selfHosted;
    if (body) return (_chalk || _load_chalk()).default.underline(title) + (_chalk || _load_chalk()).default.red(body);
    return '';
  };
  return getEjectedOutput() + getFailureOutput();
}