UNPKG

@teambit/renaming

Version:
45 lines (43 loc) 2.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RenameCmd = void 0; function _chalk() { const data = _interopRequireDefault(require("chalk")); _chalk = 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", 'rename component. if exported, create a new component and delete the original component. otherwise just renames current component'); _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, deprecating 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 _chalk().default.green(`successfully renamed ${_chalk().default.bold(results.sourceId.toString())} to ${_chalk().default.bold(results.targetId.toString())}`); } } exports.RenameCmd = RenameCmd; //# sourceMappingURL=rename.cmd.js.map