UNPKG

@teambit/workspace

Version:
69 lines (65 loc) 3.19 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; function _path() { const data = _interopRequireDefault(require("path")); _path = function () { return data; }; return data; } function _chalk() { const data = _interopRequireDefault(require("chalk")); _chalk = function () { return data; }; return data; } function _legacy() { const data = require("@teambit/legacy.constants"); _legacy = 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); } // From the cli we might get those as string in case we run it like --propagate true (return string) as opposed to only --propagate class EjectConfCmd { constructor(workspace) { this.workspace = workspace; _defineProperty(this, "name", 'eject-conf <pattern>'); _defineProperty(this, "description", 'create component.json configuration files for components'); _defineProperty(this, "extendedDescription", `generates component.json files containing component-specific configuration that overrides workspace defaults. useful for customizing individual component settings. alternatively, use commands like "bit env set", "bit deps set", or "bit aspect set". can be reversed by deleting the component.json file and snapping/tagging the changes. ${(0, _legacy().PATTERN_HELP)('eject-conf')}`); _defineProperty(this, "alias", ''); _defineProperty(this, "group", 'component-config'); _defineProperty(this, "options", [['p', 'propagate', 'mark propagate true in the config file, so that component.json configs will be merge with workspace configs'], ['o', 'override', 'override file if exist']]); } async report(args, options) { const ejectResult = await this.json(args, options); const paths = ejectResult.map(result => result.configPath).map(p => _path().default.relative(this.workspace.path, p)).join('\n'); return _chalk().default.green(`successfully ejected config to the following path(s) ${_chalk().default.bold(paths)}`); } async json([pattern], options) { const ejectOptions = options; if (ejectOptions.propagate === 'true') { ejectOptions.propagate = true; } if (ejectOptions.override === 'true') { ejectOptions.override = true; } const componentIds = await this.workspace.idsByPattern(pattern); const results = await this.workspace.ejectMultipleConfigs(componentIds, ejectOptions); return results; } } exports.default = EjectConfCmd; //# sourceMappingURL=eject-conf.cmd.js.map