"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.installAfterEnvChangesMsg = exports.EnvsSetCmd = void 0;
function _chalk() {
  const data = _interopRequireDefault(require("chalk"));
  _chalk = function () {
    return data;
  };
  return data;
}
function _constants() {
  const data = require("@teambit/legacy/dist/constants");
  _constants = 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); }
const installAfterEnvChangesMsg = exports.installAfterEnvChangesMsg = _chalk().default.yellow("please run 'bit install' for the changes to take effect");
class EnvsSetCmd {
  constructor(workspace) {
    this.workspace = workspace;
    _defineProperty(this, "name", 'set <component-pattern> <env>');
    _defineProperty(this, "description", 'Assigns one or more components a development environment (env)');
    _defineProperty(this, "arguments", [{
      name: 'component-pattern',
      description: _constants().COMPONENT_PATTERN_HELP
    }, {
      name: 'env',
      description: "the env's component id (include version if not latest, e.g `teambit.community/envs/community-react@1.95.13`)"
    }]);
    _defineProperty(this, "examples", [{
      cmd: 'set ui/button teambit.react/react-env',
      description: "configures 'ui/button' to use the latest version of the 'teambit.react/react-env' env"
    }, {
      cmd: 'set ui/button teambit.community/envs/community-mdx@1.95.16',
      description: "configures 'ui/button' to use the 'teambit.community/envs/community-mdx@1.95.16' env"
    }, {
      cmd: 'set "*/ui/**" teambit.react/react-env',
      description: "configures all components that have the 'ui' namespace to use the latest version of the teambit.react/react-env env"
    }]);
    _defineProperty(this, "options", []);
    _defineProperty(this, "group", 'development');
  }
  async report([pattern, env]) {
    const envId = await this.workspace.resolveComponentId(env);
    const componentIds = await this.workspace.idsByPattern(pattern);
    await this.workspace.setEnvToComponents(envId, componentIds);
    return `assigned ${_chalk().default.bold(envId.toString())} env to the following component(s):
${componentIds.map(compId => compId.toString()).join('\n')}\n
${installAfterEnvChangesMsg}`;
  }
}
exports.EnvsSetCmd = EnvsSetCmd;

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