UNPKG

@teambit/lanes

Version:
690 lines (687 loc) • 30.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LaneShowCmd = exports.LaneRevertCmd = exports.LaneRenameCmd = exports.LaneRemoveReadmeCmd = exports.LaneRemoveCompCmd = exports.LaneRemoveCmd = exports.LaneListCmd = exports.LaneImportCmd = exports.LaneHistoryCmd = exports.LaneFetchCmd = exports.LaneEjectCmd = exports.LaneCreateCmd = exports.LaneCmd = exports.LaneCheckoutCmd = exports.LaneChangeScopeCmd = exports.LaneAliasCmd = exports.CatLaneHistoryCmd = void 0; function _chalk() { const data = _interopRequireDefault(require("chalk")); _chalk = function () { return data; }; return data; } function _yn() { const data = _interopRequireDefault(require("yn")); _yn = function () { return data; }; return data; } function _laneId() { const data = require("@teambit/lane-id"); _laneId = function () { return data; }; return data; } function _checkout() { const data = require("@teambit/checkout"); _checkout = function () { return data; }; return data; } function _workspace() { const data = require("@teambit/workspace"); _workspace = function () { return data; }; return data; } function _legacy() { const data = require("@teambit/legacy.scope"); _legacy = function () { return data; }; return data; } function _bitError() { const data = require("@teambit/bit-error"); _bitError = function () { return data; }; return data; } function _legacyCli() { const data = require("@teambit/legacy.cli.prompts"); _legacyCli = function () { return data; }; return data; } function _legacy2() { const data = require("@teambit/legacy.constants"); _legacy2 = 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); } // eslint-disable-next-line max-classes-per-file class LaneListCmd { constructor(lanes, workspace, scope) { this.lanes = lanes; this.workspace = workspace; this.scope = scope; _defineProperty(this, "name", 'list'); _defineProperty(this, "description", `list local or remote lanes`); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['d', 'details', 'show more details on the state of each component in each lane'], ['j', 'json', "show lanes' details in a json format"], ['r', 'remote <remote-scope-name>', 'show all remote lanes from the specified scope'], ['', 'merged', 'list only merged lanes'], ['', 'not-merged', "list only lanes that haven't been merged"]]); _defineProperty(this, "loader", true); _defineProperty(this, "remoteOp", true); _defineProperty(this, "skipWorkspace", true); } async report(args, laneOptions) { const { details, remote, merged, notMerged } = laneOptions; const laneIdStr = (laneId, alias) => { if (laneId.isDefault()) return laneId.name; if (alias) return `${laneId.toString()} (${alias})`; return laneId.toString(); }; const lanes = await this.lanes.getLanes({ remote, merged, notMerged, showDefaultLane: true }); if (merged) { const mergedLanes = lanes.filter(l => l.isMerged); if (!mergedLanes.length) return _chalk().default.green('None of the lanes is merged'); return _chalk().default.green(mergedLanes.map(m => m.name).join('\n')); } if (notMerged) { const unmergedLanes = lanes.filter(l => !l.isMerged); if (!unmergedLanes.length) return _chalk().default.green('All lanes are merged'); return _chalk().default.green(unmergedLanes.map(m => m.name).join('\n')); } const currentLane = this.lanes.getCurrentLaneId() || this.lanes.getDefaultLaneId(); const laneDataOfCurrentLane = currentLane ? lanes.find(l => currentLane.isEqual(l.id)) : undefined; const currentAlias = laneDataOfCurrentLane ? laneDataOfCurrentLane.alias : undefined; const currentLaneReadmeComponentStr = outputReadmeComponent(laneDataOfCurrentLane?.readmeComponent); let currentLaneStr = remote ? '' : `current lane - ${_chalk().default.green.green(laneIdStr(currentLane, currentAlias))}${currentLaneReadmeComponentStr}`; if (details) { const currentLaneComponents = laneDataOfCurrentLane ? outputComponents(laneDataOfCurrentLane.components) : ''; if (currentLaneStr) { currentLaneStr += `\n${currentLaneComponents}`; } } const availableLanes = lanes.filter(l => !currentLane.isEqual(l.id)).map(laneData => { const readmeComponentStr = outputReadmeComponent(laneData.readmeComponent); if (details) { const laneTitle = `> ${_chalk().default.bold(laneIdStr(laneData.id, laneData.alias))}\n`; const components = outputComponents(laneData.components); return laneTitle + readmeComponentStr.concat('\n') + components; } return ` > ${_chalk().default.green(laneIdStr(laneData.id, laneData.alias))} (${laneData.components.length} components)${readmeComponentStr}`; }).join('\n'); const outputFooter = () => { let footer = '\n'; if (details) { footer += 'You can use --merged and --not-merged to see which of the lanes is fully merged.'; } else { footer += "to get more info on all lanes in local scope use 'bit lane list --details', or 'bit lane show <lane-name>' for a specific lane."; } if (!remote && this.workspace) footer += `\nswitch lanes using 'bit switch <name>'. create lanes using 'bit lane create <name>'.`; return footer; }; return outputCurrentLane() + outputAvailableLanes() + outputFooter(); function outputCurrentLane() { return currentLaneStr ? `${currentLaneStr}\n` : ''; } function outputAvailableLanes() { if (!availableLanes) return ''; return remote ? `${availableLanes}\n` : `\nAvailable lanes:\n${availableLanes}\n`; } } async json(args, laneOptions) { const { remote, merged = false, notMerged = false } = laneOptions; const lanesData = await this.lanes.getLanes({ remote, showDefaultLane: true, merged, notMerged }); const lanes = lanesData.map(_legacy().serializeLaneData); const currentLane = this.lanes.getCurrentLaneNameOrAlias(); return { lanes, currentLane }; } } exports.LaneListCmd = LaneListCmd; class LaneShowCmd { constructor(lanes, workspace, scope) { this.lanes = lanes; this.workspace = workspace; this.scope = scope; _defineProperty(this, "name", 'show [lane-name]'); _defineProperty(this, "description", `show lane details. if no lane specified, show the current lane`); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['j', 'json', 'show the lane details in json format'], ['r', 'remote', 'show details of the remote head of the provided lane']]); _defineProperty(this, "loader", true); _defineProperty(this, "remoteOp", true); _defineProperty(this, "skipWorkspace", true); } async report([name], laneOptions) { const lanes = await this.geLanesData([name], laneOptions); const onlyLane = lanes[0]; const laneId = onlyLane.id; const laneIdStr = laneId.isDefault() ? _laneId().DEFAULT_LANE : laneId.toString(); const title = `showing information for ${_chalk().default.bold(laneIdStr)}\n`; const author = onlyLane.log ? `author: ${onlyLane.log?.username || 'N/A'} <${onlyLane.log?.email || 'N/A'}>\n` : ''; const date = onlyLane.log?.date ? `created: ${new Date(parseInt(onlyLane.log.date)).toLocaleString()}\n` : ''; const link = laneId.isDefault() ? '' : `link: https://${_legacy2().DEFAULT_CLOUD_DOMAIN}/${laneId.scope.replace('.', '/')}/~lane/${laneId.name}\n`; return title + author + date + link + outputComponents(onlyLane.components); } async geLanesData([name], laneOptions) { const { remote } = laneOptions; if (!name && remote) { throw new Error('remote flag is not supported without lane name'); } if (!name) { name = this.lanes.getCurrentLaneName() || _laneId().DEFAULT_LANE; } const laneId = await this.lanes.parseLaneId(name); const lanes = await this.lanes.getLanes({ name: laneId.name, remote: remote ? laneId.scope : undefined }); return lanes; } async json([name], laneOptions) { const lanes = await this.geLanesData([name], laneOptions); return (0, _legacy().serializeLaneData)(lanes[0]); } } exports.LaneShowCmd = LaneShowCmd; class LaneCreateCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'create <lane-name>'); _defineProperty(this, "arguments", [{ name: 'lane-name', description: 'the name for the new lane' }]); _defineProperty(this, "description", `creates a new lane and switches to it`); _defineProperty(this, "extendedDescription", `a lane created from main (default-lane) is empty until components are snapped. a lane created from another lane contains all the components of the original lane.`); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['s', 'scope <scope-name>', 'remote scope to which this lane will be exported, default to the workspace.json\'s defaultScope (can be changed up to first export of the lane with "bit lane change-scope")'], ['', 'remote-scope <scope-name>', 'DEPRECATED. use --scope'], ['', 'alias <name>', 'a local alias to refer to this lane, defaults to the `<lane-name>` (can be added later with "bit lane alias")'], ['', 'fork-lane-new-scope', 'create the new lane in a different scope than its parent lane (if created from another lane)']]); _defineProperty(this, "loader", true); } async report([name], createLaneOptions) { if (!this.lanes.workspace) throw new (_workspace().OutsideWorkspaceError)(); const currentLane = await this.lanes.getCurrentLane(); if (createLaneOptions.remoteScope) createLaneOptions.scope = createLaneOptions.remoteScope; const result = await this.lanes.createLane(name, createLaneOptions); const remoteScopeOrDefaultScope = createLaneOptions.scope ? `the remote scope ${_chalk().default.bold(createLaneOptions.scope)}` : `the default-scope ${_chalk().default.bold(result.laneId.scope)}. you can change the lane's scope, before it is exported, with the "bit lane change-scope" command`; const title = _chalk().default.green(`successfully added and checked out to the new lane ${_chalk().default.bold(result.alias || result.laneId.name)} ${currentLane ? _chalk().default.yellow(`\nnote - your new lane will be based on lane ${currentLane.name}`) : ''} `); const remoteScopeOutput = `this lane will be exported to ${remoteScopeOrDefaultScope}`; return `${title}\n${remoteScopeOutput}`; } } exports.LaneCreateCmd = LaneCreateCmd; class LaneAliasCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'alias <lane-name> <alias>'); _defineProperty(this, "description", 'adds an alias to a lane'); _defineProperty(this, "extendedDescription", `an alias is a name that can be used locally to refer to a lane. it is saved locally and never reaches the remote. it is useful e.g. when having multiple lanes with the same name, but with different remote scopes.`); _defineProperty(this, "alias", ''); _defineProperty(this, "options", []); _defineProperty(this, "loader", true); } async report([laneName, alias]) { const { laneId } = await this.lanes.aliasLane(laneName, alias); return `successfully added the alias ${_chalk().default.bold(alias)} for lane ${_chalk().default.bold(laneId.toString())}`; } } exports.LaneAliasCmd = LaneAliasCmd; class CatLaneHistoryCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'cat-lane-history <lane-name>'); _defineProperty(this, "description", 'cat lane-history object by lane-name'); _defineProperty(this, "private", true); _defineProperty(this, "alias", 'clh'); _defineProperty(this, "options", []); _defineProperty(this, "loader", true); _defineProperty(this, "group", 'advanced'); } async report([laneName]) { const laneId = await this.lanes.parseLaneId(laneName); const laneHistory = await this.lanes.getLaneHistory(laneId); return JSON.stringify(laneHistory.toObject(), null, 2); } } exports.CatLaneHistoryCmd = CatLaneHistoryCmd; class LaneCheckoutCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'checkout <history-id>'); _defineProperty(this, "description", 'EXPERIMENTAL. checkout to a previous history of the current lane. see also "bit lane revert"'); _defineProperty(this, "arguments", [{ name: 'history-id', description: 'the history-id to checkout to. run "bit lane history" to list the ids' }]); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['x', 'skip-dependency-installation', 'do not install dependencies of the checked out components']]); _defineProperty(this, "loader", true); } async report([historyId], opts) { const result = await this.lanes.checkoutHistory(historyId, opts); return (0, _checkout().checkoutOutput)(result, {}, `successfully checked out according to history-id: ${historyId}`); } } exports.LaneCheckoutCmd = LaneCheckoutCmd; class LaneRevertCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'revert <history-id>'); _defineProperty(this, "description", 'EXPERIMENTAL. revert to a previous history of the current lane. see also "bit lane checkout"'); _defineProperty(this, "extendedDescription", `revert is similar to "lane checkout", but it keeps the versions and only change the files. choose one or the other based on your needs. if you want to continue working on this lane and needs the changes from the history to be the head, then use "lane revert". if you want to fork the lane from a certain point in history, use "lane checkout" and create a new lane from it.`); _defineProperty(this, "arguments", [{ name: 'history-id', description: 'the history-id to checkout to. run "bit lane history" to list the ids' }]); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['x', 'skip-dependency-installation', 'do not install dependencies of the checked out components'], ['j', 'json', 'return the revert result in json format']]); _defineProperty(this, "loader", true); } async report([historyId], opts) { const result = await this.lanes.revertHistory(historyId, opts); return (0, _checkout().checkoutOutput)(result, {}, `successfully reverted according to history-id: ${historyId}`); } async json([historyId], opts) { const result = await this.lanes.revertHistory(historyId, opts); return { components: result.components?.map(component => ({ id: component.id.toString(), filesStatus: Object.entries(component.filesStatus || {}).reduce((acc, [filePath, status]) => { acc[filePath] = status; return acc; }, {}) })), removedComponents: result.removedComponents?.map(id => id.toString()), addedComponents: result.addedComponents?.map(id => id.toString()), newComponents: result.newComponents?.map(id => id.toString()), failedComponents: result.failedComponents?.map(component => ({ id: component.id.toString(), unchangedMessage: component.unchangedMessage, unchangedLegitimately: component.unchangedLegitimately })), leftUnresolvedConflicts: result.leftUnresolvedConflicts, newFromLane: result.newFromLane, newFromLaneAdded: result.newFromLaneAdded, version: result.version, resolvedComponents: result.resolvedComponents?.map(component => component.id.toString()), abortedComponents: result.abortedComponents?.map(component => ({ id: component.id.toString(), filesStatus: Object.entries(component.filesStatus || {}).reduce((acc, [filePath, status]) => { acc[filePath] = status; return acc; }, {}) })), installationError: result.installationError?.message, compilationError: result.compilationError?.message, mergeSnapError: result.mergeSnapError?.message, mergeSnapResults: result.mergeSnapResults ? { snappedComponents: result.mergeSnapResults.snappedComponents?.map(component => component.id.toString()), removedComponents: result.mergeSnapResults.removedComponents?.toStringArray(), exportedIds: result.mergeSnapResults.exportedIds?.map(id => id.toString()) } : null, workspaceConfigUpdateResult: result.workspaceConfigUpdateResult ? { logs: result.workspaceConfigUpdateResult.logs } : undefined, historyId }; } } exports.LaneRevertCmd = LaneRevertCmd; class LaneHistoryCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'history [lane-name]'); _defineProperty(this, "description", 'EXPERIMENTAL. show lane history, default to the current lane'); _defineProperty(this, "extendedDescription", `list from the oldest to the newest history items`); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['', 'id <string>', 'show a specific history item'], ['j', 'json', 'return the lane history in json format']]); _defineProperty(this, "loader", true); } async getHistoryData(laneName, id) { const laneId = laneName ? await this.lanes.parseLaneId(laneName) : this.lanes.getCurrentLaneId(); if (!laneId || laneId.isDefault()) throw new (_bitError().BitError)(`unable to show history of the default lane (main)`); await this.lanes.importLaneHistory(laneId); const laneHistory = await this.lanes.getLaneHistory(laneId); const history = laneHistory.getHistory(); if (id) { const historyItem = history[id]; if (!historyItem) throw new Error(`history id ${id} was not found`); return { historyItem, id, history, singleItem: true }; } return { history, singleItem: false }; } getDateString(date) { return new Date(parseInt(date)).toLocaleString(); } async report([laneName], { id }) { const { history, historyItem, singleItem } = await this.getHistoryData(laneName, id); if (singleItem && historyItem) { const date = this.getDateString(historyItem.log.date); const message = historyItem.log.message; return `${id} ${date} ${historyItem.log.username} ${message}\n\n${historyItem.components.join('\n')}`; } const items = Object.keys(history).map(uuid => { const item = history[uuid]; const date = this.getDateString(item.log.date); const message = item.log.message; return `${uuid} ${date} ${item.log.username} ${message}`; }); return items.join('\n'); } async json([laneName], { id }) { const { history, historyItem, id: historyId, singleItem } = await this.getHistoryData(laneName, id); if (singleItem && historyItem) { return { id: historyId, date: historyItem.log.date, username: historyItem.log.username, message: historyItem.log.message, components: historyItem.components }; } return Object.keys(history).map(uuid => { const item = history[uuid]; return { id: uuid, date: item.log.date, username: item.log.username, message: item.log.message, components: item.components }; }); } } exports.LaneHistoryCmd = LaneHistoryCmd; class LaneEjectCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'eject <component-pattern>'); _defineProperty(this, "description", `delete a component from the lane and install it as a package from main`); _defineProperty(this, "extendedDescription", `NOTE: unlike "bit eject" on main, this command doesn't only remove the component from the workspace, but also mark it as deleted from the lane, so it won't be merged later on.`); _defineProperty(this, "alias", ''); _defineProperty(this, "arguments", [{ name: 'component-pattern', description: _legacy2().COMPONENT_PATTERN_HELP }]); _defineProperty(this, "options", []); _defineProperty(this, "loader", true); } async report([pattern]) { const results = await this.lanes.eject(pattern); const title = _chalk().default.green('successfully ejected the following components'); const body = results.map(r => r.toString()).join('\n'); return `${title}\n${body}`; } } exports.LaneEjectCmd = LaneEjectCmd; class LaneChangeScopeCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'change-scope <remote-scope-name>'); _defineProperty(this, "description", `changes the remote scope of a lane`); _defineProperty(this, "extendedDescription", 'NOTE: available only before the lane is exported to the remote'); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['l', 'lane-name <lane-name>', 'the name of the lane to change its remote scope. if not specified, the current lane is used']]); _defineProperty(this, "loader", true); } async report([remoteScope], { laneName }) { const { remoteScopeBefore, localName } = await this.lanes.changeScope(remoteScope, laneName); return `the remote-scope of ${_chalk().default.bold(localName)} has been changed from ${_chalk().default.bold(remoteScopeBefore)} to ${_chalk().default.bold(remoteScope)}`; } } exports.LaneChangeScopeCmd = LaneChangeScopeCmd; class LaneRenameCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'rename <new-name>'); _defineProperty(this, "description", `change the lane-name locally`); _defineProperty(this, "extendedDescription", 'the remote will be updated after the next "bit export" command'); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['l', 'lane-name <lane-name>', 'the name of the lane to rename. if not specified, the current lane is used']]); _defineProperty(this, "loader", true); } async report([newName], { laneName }) { const { currentName } = await this.lanes.rename(newName, laneName); return `the lane ${_chalk().default.bold(currentName)}'s name has been changed to ${_chalk().default.bold(newName)}.`; } } exports.LaneRenameCmd = LaneRenameCmd; class LaneRemoveCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'remove <lanes...>'); _defineProperty(this, "arguments", [{ name: 'lanes...', description: 'A list of lane names, separated by spaces' }]); _defineProperty(this, "description", `remove or delete lanes`); _defineProperty(this, "group", 'collaborate'); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['r', 'remote', 'delete a remote lane. use remote/lane-id syntax e.g. bit lane remove owner.org/my-lane --remote. Delete is immediate, no export required'], ['f', 'force', 'removes/deletes the lane even when the lane is not yet merged to main'], ['s', 'silent', 'skip confirmation']]); _defineProperty(this, "loader", true); } async report([names], { remote = false, force = false, silent = false }) { if (!silent) { const removePromptResult = await (0, _legacyCli().approveOperation)(); // @ts-ignore if (!(0, _yn().default)(removePromptResult.shouldProceed)) { throw new (_bitError().BitError)('the operation has been cancelled'); } } const laneResults = await this.lanes.removeLanes(names, { remote, force }); return _chalk().default.green(`successfully removed the following lane(s): ${_chalk().default.bold(laneResults.join(', '))}`); } } exports.LaneRemoveCmd = LaneRemoveCmd; class LaneRemoveCompCmd { constructor(workspace, lanes) { this.workspace = workspace; this.lanes = lanes; _defineProperty(this, "name", 'remove-comp <component-pattern>'); _defineProperty(this, "arguments", [{ name: 'component-pattern', description: _legacy2().COMPONENT_PATTERN_HELP }]); _defineProperty(this, "description", `DEPRECATED. remove components when on a lane`); _defineProperty(this, "group", 'collaborate'); _defineProperty(this, "alias", 'rc'); _defineProperty(this, "options", [['', 'workspace-only', 'do not mark the components as removed from the lane. instead, remove them from the workspace only'], ['', 'update-main', 'EXPERIMENTAL. remove, i.e. delete, component/s on the main lane after merging this lane into main']]); _defineProperty(this, "loader", true); } async report() { throw new (_bitError().BitError)(`bit lane remove-comp has been removed. please use "bit remove" or "bit delete" instead`); } } exports.LaneRemoveCompCmd = LaneRemoveCompCmd; class LaneImportCmd { constructor(switchCmd) { this.switchCmd = switchCmd; _defineProperty(this, "name", 'import <lane>'); _defineProperty(this, "description", `import a remote lane to your workspace and switch to that lane`); _defineProperty(this, "arguments", [{ name: 'lane', description: 'the remote lane name' }]); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['x', 'skip-dependency-installation', 'do not install dependencies of the imported components'], ['p', 'pattern <component-pattern>', 'import only components from the lane that fit the specified component-pattern to the workspace. works only when the workspace is empty'], ['', 'branch', 'create and checkout a new git branch named after the lane']]); _defineProperty(this, "loader", true); } async report([lane], { skipDependencyInstallation = false, pattern, branch = false }) { return this.switchCmd.report([lane], { skipDependencyInstallation, pattern, branch }); } } exports.LaneImportCmd = LaneImportCmd; class LaneFetchCmd { constructor(fetchCmd, lanes) { this.fetchCmd = fetchCmd; this.lanes = lanes; _defineProperty(this, "name", 'fetch [lane-id]'); _defineProperty(this, "description", `fetch component objects from lanes. if no lane-id is provided, it fetches from the current lane`); _defineProperty(this, "extendedDescription", `note, it does not save the remote lanes objects locally, only the refs`); _defineProperty(this, "alias", ''); _defineProperty(this, "options", [['a', 'all', 'fetch all remote lanes']]); _defineProperty(this, "loader", true); } async report([laneId], { all }) { if (all) return this.fetchCmd.report([[]], { lanes: true }); const getLaneIdStr = () => { if (laneId) return laneId; const currentLane = this.lanes.getCurrentLaneId(); if (!currentLane || currentLane.isDefault()) throw new (_bitError().BitError)('you are not checked out to any lane. please specify a lane-id to fetch or use --all flag'); return currentLane.toString(); }; const lane = getLaneIdStr(); return this.fetchCmd.report([[lane]], { lanes: true }); } } exports.LaneFetchCmd = LaneFetchCmd; class LaneCmd { constructor(lanes, workspace, scope) { this.lanes = lanes; this.workspace = workspace; this.scope = scope; _defineProperty(this, "name", 'lane [sub-command]'); _defineProperty(this, "description", 'manage lanes - if no sub-command is used, runs "bit lane list"'); _defineProperty(this, "alias", 'l'); _defineProperty(this, "options", [['d', 'details', 'show more details on the state of each component in each lane'], ['j', 'json', 'show lanes details in json format'], ['r', 'remote <remote-scope-name>', 'show all remote lanes from the specified scope'], ['', 'merged', 'list only merged lanes'], ['', 'not-merged', "list only lanes that haven't been merged"]]); _defineProperty(this, "loader", true); _defineProperty(this, "group", 'collaborate'); _defineProperty(this, "remoteOp", true); _defineProperty(this, "skipWorkspace", true); _defineProperty(this, "helpUrl", 'reference/components/lanes'); _defineProperty(this, "commands", []); } async report([name], laneOptions) { return new LaneListCmd(this.lanes, this.workspace, this.scope).report([name], laneOptions); } } /** * @deprecated - only use it to revert the add-readme command changes */ exports.LaneCmd = LaneCmd; class LaneRemoveReadmeCmd { constructor(lanes) { this.lanes = lanes; _defineProperty(this, "name", 'remove-readme [laneName]'); _defineProperty(this, "description", 'DEPRECATED (only use it if you have used add-readme and want to undo it). remove lane readme component'); _defineProperty(this, "options", []); _defineProperty(this, "loader", true); _defineProperty(this, "skipWorkspace", false); } async report([laneName]) { const { result, message } = await this.lanes.removeLaneReadme(laneName); if (result) { return _chalk().default.green(`the readme component has been successfully removed from the lane ${laneName || this.lanes.getCurrentLaneName()}`); } return _chalk().default.red(`${message}\n`); } } exports.LaneRemoveReadmeCmd = LaneRemoveReadmeCmd; function outputComponents(components) { const componentsTitle = `\t${_chalk().default.bold(`components (${components.length})`)}\n`; const componentsStr = components.map(c => `\t ${c.id.toString()} - ${c.head}`).join('\n'); return componentsTitle + componentsStr; } function outputReadmeComponent(component) { if (!component) return ''; return `\n\t${`${_chalk().default.yellow('readme component')}\n\t ${component.id} - ${component.head || `(unsnapped)\n\t("use bit snap ${component.id.fullName}" to snap the readme component on the lane before exporting)`}`}\n`; } //# sourceMappingURL=lane.cmd.js.map