@teambit/workspace
Version:
78 lines (76 loc) • 3.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EnvsUpdateCmd = void 0;
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 _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 EnvsUpdateCmd {
constructor(workspace) {
this.workspace = workspace;
_defineProperty(this, "name", 'update [env-id] [pattern]');
_defineProperty(this, "description", 'update a version of an env for all components using that env');
_defineProperty(this, "arguments", [{
name: 'env-id',
description: 'the environment id (defaults to all envs). optionally, add a version (id@version), if no version is supplied will use the latest version on the remote.'
}, {
name: 'pattern',
description: `the components to update (defaults to all components). ${_legacy().COMPONENT_PATTERN_HELP}`
}]);
_defineProperty(this, "examples", [{
cmd: 'envs update',
description: 'update all envs for all components in the workspace, to their latest version'
}, {
cmd: "envs update scope.org/env '**/ui/**'",
description: 'update components in the "ui" namespace that use scope.org/env to use its latest version'
}, {
cmd: 'envs update scope.org/env@2.0.0',
description: 'update all components that use scope.org/env to version 2.0.0 (of this env).'
}]);
_defineProperty(this, "options", []);
_defineProperty(this, "group", 'component-config');
}
async report([aspectId, pattern]) {
const {
updated,
alreadyUpToDate
} = await this.workspace.updateEnvForComponents(aspectId, pattern);
if (Object.keys(updated).length) {
const body = Object.keys(updated).map(envId => {
return `${_chalk().default.bold(envId)}:\n${updated[envId].map(compId => compId.toString()).join('\n')}`;
}).join('\n\n');
const title = _chalk().default.green(`the following component(s) env has been successfully updated:\n`);
const suffix = `\n${_envsSet().installAfterEnvChangesMsg}`;
return title + body + suffix;
}
if (alreadyUpToDate.length) {
return _chalk().default.green(`all ${alreadyUpToDate.length} component(s) that use this env are already up to date. nothing to update`);
}
return _chalk().default.yellow(`unable to find any components using env ${_chalk().default.bold(aspectId)}`);
}
}
exports.EnvsUpdateCmd = EnvsUpdateCmd;
//# sourceMappingURL=envs-update.cmd.js.map