@teambit/renaming
Version:
55 lines (53 loc) • 3.27 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RenameCmd = void 0;
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _cli() {
const data = require("@teambit/cli");
_cli = 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 RenameCmd {
constructor(renaming) {
this.renaming = renaming;
_defineProperty(this, "name", 'rename <current-name> <new-name>');
_defineProperty(this, "description", 'change a component name');
_defineProperty(this, "extendedDescription", `renames a component and optionally refactors dependent code to use the new name.
for exported components: creates a new component with the new name and marks the original as deleted.
for local components: simply renames the existing component in place.`);
_defineProperty(this, "helpUrl", 'reference/components/renaming-components');
_defineProperty(this, "arguments", [{
name: 'current-name',
description: 'the current component name (without its scope name)'
}, {
name: 'new-name',
description: "the new component name (without its scope name. use --scope to define the new component's scope)"
}]);
_defineProperty(this, "group", 'component-development');
_defineProperty(this, "skipWorkspace", true);
_defineProperty(this, "alias", '');
_defineProperty(this, "options", [['s', 'scope <scope-name>', 'define the scope for the new component'], ['r', 'refactor', 'update the import/require statements in all dependent components (in the same workspace)'], ['', 'preserve', 'avoid renaming files and variables/classes according to the new component name'], ['', 'ast', 'use ast to transform files instead of regex'], ['', 'delete', 'DEPRECATED. this is now the default'], ['', 'deprecate', 'instead of deleting the original component, deprecate it'], ['p', 'path <relative-path>', 'relative path in the workspace to place new component in. by default, the directory of the new component is from your workspace\'s "defaultScope" value']]);
_defineProperty(this, "loader", true);
_defineProperty(this, "remoteOp", true);
}
async report([sourceId, targetId], options) {
const results = await this.renaming.rename(sourceId, targetId, options);
return (0, _cli().formatSuccessSummary)(`renamed ${_chalk().default.bold(results.sourceId.toString())} to ${_chalk().default.bold(results.targetId.toString())}`);
}
}
exports.RenameCmd = RenameCmd;
//# sourceMappingURL=rename.cmd.js.map