"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EnvsUnsetCmd = void 0;
function _constants() {
  const data = require("@teambit/legacy/dist/constants");
  _constants = function () {
    return data;
  };
  return data;
}
function _chalk() {
  const data = _interopRequireDefault(require("chalk"));
  _chalk = function () {
    return data;
  };
  return data;
}
function _envsSet() {
  const data = require("./envs-set.cmd");
  _envsSet = function () {
    return data;
  };
  return data;
}
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
class EnvsUnsetCmd {
  constructor(workspace) {
    this.workspace = workspace;
    _defineProperty(this, "name", 'unset <component-pattern>');
    _defineProperty(this, "description", 'un-sets an env from components that were previously set by "bit env set" or by a component template');
    _defineProperty(this, "arguments", [{
      name: 'component-pattern',
      description: _constants().COMPONENT_PATTERN_HELP
    }]);
    _defineProperty(this, "options", []);
    _defineProperty(this, "group", 'development');
    _defineProperty(this, "extendedDescription", `keep in mind that this doesn't remove envs that are set via variants.
in only removes envs that appear in the .bitmap file, which were previously configured via "bit env set".
the purpose of this command is to reset previously assigned envs to either allow variants configure the env or use the base node env.
${(0, _constants().PATTERN_HELP)('env unset')}`);
  }
  async report([pattern]) {
    const componentIds = await this.workspace.idsByPattern(pattern);
    const {
      changed
    } = await this.workspace.unsetEnvFromComponents(componentIds);
    if (!changed.length) {
      return _chalk().default.yellow(`unable to find components matching the pattern with env configured in the .bitmap file`);
    }
    return `successfully removed .bitmap env configuration from the following component(s):
${changed.map(id => id.toString()).join('\n')}\n${_envsSet().installAfterEnvChangesMsg}`;
  }
}
exports.EnvsUnsetCmd = EnvsUnsetCmd;

//# sourceMappingURL=envs-unset.cmd.js.map