UNPKG

@teambit/checkout

Version:
709 lines (700 loc) • 30.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = exports.CheckoutMain = void 0; function _cli() { const data = require("@teambit/cli"); _cli = function () { return data; }; return data; } function _logger() { const data = require("@teambit/logger"); _logger = function () { return data; }; return data; } function _workspace() { const data = require("@teambit/workspace"); _workspace = function () { return data; }; return data; } function _bitError() { const data = require("@teambit/bit-error"); _bitError = function () { return data; }; return data; } function _lodash() { const data = require("lodash"); _lodash = function () { return data; }; return data; } function _remove() { const data = require("@teambit/remove"); _remove = function () { return data; }; return data; } function _componentModules() { const data = require("@teambit/component.modules.merge-helper"); _componentModules = function () { return data; }; return data; } function _importer() { const data = require("@teambit/importer"); _importer = function () { return data; }; return data; } function _lister() { const data = require("@teambit/lister"); _lister = function () { return data; }; return data; } function _legacy() { const data = require("@teambit/legacy.constants"); _legacy = function () { return data; }; return data; } function _componentWriter() { const data = require("@teambit/component-writer"); _componentWriter = function () { return data; }; return data; } function _pMapSeries() { const data = _interopRequireDefault(require("p-map-series")); _pMapSeries = function () { return data; }; return data; } function _componentId() { const data = require("@teambit/component-id"); _componentId = function () { return data; }; return data; } function _objects() { const data = require("@teambit/objects"); _objects = function () { return data; }; return data; } function _legacy2() { const data = require("@teambit/legacy.scope"); _legacy2 = function () { return data; }; return data; } function _legacy3() { const data = require("@teambit/legacy.consumer-component"); _legacy3 = function () { return data; }; return data; } function _checkoutCmd() { const data = require("./checkout-cmd"); _checkoutCmd = function () { return data; }; return data; } function _checkout() { const data = require("./checkout.aspect"); _checkout = function () { return data; }; return data; } function _checkoutVersion() { const data = require("./checkout-version"); _checkoutVersion = function () { return data; }; return data; } function _revertCmd() { const data = require("./revert-cmd"); _revertCmd = function () { return data; }; return data; } function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return 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 CheckoutMain { constructor(workspace, logger, componentWriter, importer, remove, lister) { this.workspace = workspace; this.logger = logger; this.componentWriter = componentWriter; this.importer = importer; this.remove = remove; this.lister = lister; } async checkout(checkoutProps) { await this.ensureCheckoutConfiguration(checkoutProps); this.workspace.inInstallContext = true; const { version, ids, promptMergeOptions } = checkoutProps; await this.syncNewComponents(checkoutProps); const addedComponents = await this.restoreMissingComponents(checkoutProps); const newComponents = await this.addNewComponents(checkoutProps); const bitIds = _componentId().ComponentIdList.fromArray(ids || []); // don't use Promise.all, it loads the components and this operation must be in sequence. const allComponentStatusBeforeMerge = await (0, _pMapSeries().default)(bitIds, id => this.getComponentStatusBeforeMergeAttempt(id, checkoutProps)); const compsNeedMerge = allComponentStatusBeforeMerge.filter(c => c.propsForMerge); const compsNotNeedMerge = allComponentStatusBeforeMerge.filter(c => !c.propsForMerge); // in case the requested versions to checkout don't exist locally, import them. const toImport = allComponentStatusBeforeMerge.map(compStatus => { const idsToImport = [compStatus.id]; if (compStatus.propsForMerge) { idsToImport.push(compStatus.id.changeVersion(compStatus.propsForMerge.currentlyUsedVersion)); } return idsToImport; }).flat(); await this.workspace.scope.legacyScope.scopeImporter.importWithoutDeps(_componentId().ComponentIdList.fromArray(toImport), { cache: true, lane: checkoutProps.lane }); const consumer = this.workspace.consumer; const getComponentsStatusOfMergeNeeded = async () => { const tmp = new (_legacy2().Tmp)(consumer.scope); try { const afterMergeAttempt = await Promise.all(compsNeedMerge.map(c => this.getMergeStatus(c, checkoutProps))); await tmp.clear(); return afterMergeAttempt; } catch (err) { await tmp.clear(); throw err; } }; const compStatusMergeNeeded = await getComponentsStatusOfMergeNeeded(); const allComponentsStatus = [...compStatusMergeNeeded, ...compsNotNeedMerge]; const componentWithConflict = allComponentsStatus.find(component => component.mergeResults && component.mergeResults.hasConflicts); if (componentWithConflict) { if (!promptMergeOptions && !checkoutProps.mergeStrategy) { throw new (_bitError().BitError)(`automatic merge has failed for component ${componentWithConflict.id.toStringWithoutVersion()}.\nplease use "--auto-merge-resolve" with 'manual', 'ours' or 'theirs' to resolve the conflict/s`); } if (!checkoutProps.mergeStrategy) checkoutProps.mergeStrategy = await (0, _componentModules().getMergeStrategyInteractive)(); } (0, _checkoutVersion().throwForFailures)(allComponentsStatus); const failedComponents = allComponentsStatus.filter(componentStatus => componentStatus.unchangedMessage).filter(componentStatus => !componentStatus.shouldBeRemoved).map(componentStatus => ({ id: componentStatus.id, unchangedMessage: componentStatus.unchangedMessage, unchangedLegitimately: componentStatus.unchangedLegitimately })); const succeededComponents = allComponentsStatus.filter(componentStatus => !componentStatus.unchangedMessage); // do not use Promise.all for applyVersion. otherwise, it'll write all components in parallel, // which can be an issue when some components are also dependencies of others const checkoutPropsLegacy = _objectSpread(_objectSpread({}, checkoutProps), {}, { ids: checkoutProps.ids?.map(id => id) }); const componentsResults = await (0, _pMapSeries().default)(succeededComponents, ({ id, currentComponent, mergeResults }) => { return (0, _checkoutVersion().applyVersion)(consumer, id, currentComponent, mergeResults, checkoutPropsLegacy); }); const componentsLegacy = (0, _lodash().compact)(componentsResults.map(c => c.component)); let newFromLane; let newFromLaneAdded = false; if (checkoutProps.head) { newFromLane = await this.getNewComponentsFromLane(checkoutProps.ids || []); if (!checkoutProps.workspaceOnly) { const compsNewFromLane = await Promise.all(newFromLane.map(id => consumer.loadComponentFromModelImportIfNeeded(id))); componentsLegacy.push(...compsNewFromLane); newFromLaneAdded = true; } } let newFromScope; if (checkoutProps.head && checkoutProps.includeNewFromScope) { newFromScope = await this.getNewComponentsFromScope(); if (newFromScope.length) { const scopeImporter = this.workspace.scope.legacyScope.scopeImporter; await scopeImporter.importMany({ ids: _componentId().ComponentIdList.fromArray(newFromScope), reason: 'to import new components from the defaultScope' }); const compsNewFromScope = await Promise.all(newFromScope.map(id => consumer.loadComponentFromModelImportIfNeeded(id))); componentsLegacy.push(...compsNewFromScope); } } const leftUnresolvedConflicts = componentWithConflict && checkoutProps.mergeStrategy === 'manual'; let componentWriterResults; if (componentsLegacy.length) { const manyComponentsWriterOpts = { components: componentsLegacy, skipDependencyInstallation: checkoutProps.skipNpmInstall || leftUnresolvedConflicts, verbose: checkoutProps.verbose, resetConfig: checkoutProps.reset, skipUpdatingBitMap: checkoutProps.skipUpdatingBitmap || checkoutProps.revert, shouldUpdateWorkspaceConfig: true, reasonForBitmapChange: 'checkout', mergeStrategy: checkoutProps.mergeStrategy }; componentWriterResults = await this.componentWriter.writeMany(manyComponentsWriterOpts); } const appliedVersionComponents = componentsResults.map(c => c.applyVersionResult); const componentIdsToRemove = allComponentsStatus.filter(componentStatus => componentStatus.shouldBeRemoved).map(c => c.id.changeVersion(undefined)); if (componentIdsToRemove.length) { await this.remove.removeLocallyByIds(componentIdsToRemove, { force: true, reasonForRemoval: 'checkout' }); } return { components: appliedVersionComponents, removedComponents: componentIdsToRemove, addedComponents, newComponents, version, failedComponents, leftUnresolvedConflicts, newFromLane: newFromLane?.map(n => n.toString()), newFromLaneAdded, newFromScope: newFromScope?.map(n => n.toString()), workspaceConfigUpdateResult: componentWriterResults?.workspaceConfigUpdateResult, installationError: componentWriterResults?.installationError, compilationError: componentWriterResults?.compilationError }; } /** * if .bitmap entry exists but the rootDir is missing from the filesystem, find the component in the scope and restore it. * returns the restored component ids. */ async restoreMissingComponents(checkoutProps) { if (checkoutProps.reset) { checkoutProps.restoreMissingComponents = true; } if (!checkoutProps.restoreMissingComponents) return undefined; const ids = checkoutProps.ids || []; const missing = []; await Promise.all(ids.map(async id => { const bitMapEntry = this.workspace.bitMap.getBitmapEntry(id, { ignoreVersion: true }); if (bitMapEntry.noFilesError && bitMapEntry.noFilesError instanceof _legacy3().ComponentNotFoundInPath) { delete bitMapEntry.noFilesError; missing.push(id); } })); if (!missing.length) return undefined; const comps = await this.workspace.scope.getMany(missing); await this.componentWriter.writeMany({ components: comps.map(c => c.state._consumer), skipDependencyInstallation: true, skipUpdatingBitMap: true }); return missing; } async addNewComponents(checkoutProps) { const stashedBitmapEntries = checkoutProps.stashedBitmapEntries; if (!stashedBitmapEntries) return; const newBitmapEntries = stashedBitmapEntries.filter(entry => entry.defaultScope); if (!newBitmapEntries.length) return; const newComps = await (0, _pMapSeries().default)(newBitmapEntries, async bitmapEntry => { const id = bitmapEntry.id; const existingId = this.workspace.bitMap.getBitmapEntryIfExist(id, { ignoreVersion: true }); if (existingId) return; const modelComponent = _objects().ModelComponent.fromBitId(id); const repo = this.workspace.scope.legacyScope.objects; const consumerComp = await modelComponent.toConsumerComponent(id.version, id.scope, repo); const newCompId = _componentId().ComponentID.fromObject({ name: id.fullName }, bitmapEntry.defaultScope); await this.componentWriter.writeMany({ components: [consumerComp], skipDependencyInstallation: true, writeToPath: bitmapEntry.rootDir, skipUpdatingBitMap: true }); this.workspace.consumer.bitMap.addComponent({ componentId: newCompId, files: consumerComp.files.map(f => ({ name: f.basename, relativePath: f.relative, test: f.test })), mainFile: bitmapEntry.mainFile, config: bitmapEntry.config, defaultScope: bitmapEntry.defaultScope }); await this.workspace.triggerOnComponentAdd(newCompId, { compile: true }); return newCompId; }); await this.workspace.bitMap.write(); return (0, _lodash().compact)(newComps); } async checkoutByCLIValues(componentPattern, checkoutProps) { const { revert, head } = checkoutProps; this.logger.setStatusLine(revert ? 'reverting components...' : 'switching component version...'); if (!this.workspace) throw new (_workspace().OutsideWorkspaceError)(); const consumer = this.workspace.consumer; await this.importer.importCurrentObjects(); // important. among others, it fetches the remote lane object and its new components. if (head) await this.makeLaneComponentsAvailableOnMain(); await this.parseValues(componentPattern, checkoutProps); const checkoutResults = await this.checkout(checkoutProps); await consumer.onDestroy(`checkout (${componentPattern})`); return checkoutResults; } async syncNewComponents({ ids, head }) { if (!head) return; const notExported = ids?.filter(id => !this.workspace.isExported(id)).map(id => id.changeScope(id.scope)); const scopeComponentsImporter = this.workspace.consumer.scope.scopeImporter; try { await scopeComponentsImporter.importWithoutDeps(_componentId().ComponentIdList.fromArray(notExported || []).toVersionLatest(), { cache: false, reason: 'for making sure the new components are really new and are not out-of-sync', includeUnexported: true }); } catch (err) { // don't stop the process. it's possible that the scope doesn't exist yet because these are new components this.logger.error(`unable to sync new components, if these components are really new, ignore the error`, err); } } async makeLaneComponentsAvailableOnMain() { const unavailableOnMain = await this.workspace.getUnavailableOnMainComponents(); if (!unavailableOnMain.length) return; this.workspace.bitMap.makeComponentsAvailableOnMain(unavailableOnMain); } async ensureCheckoutConfiguration(checkoutProps) { if (checkoutProps.reset || checkoutProps.head) { checkoutProps.includeLocallyDeleted = true; } if (checkoutProps.ids?.length) { return; } if (checkoutProps.head || checkoutProps.latest) { checkoutProps.all = true; } if (!checkoutProps.all) { return; // no ids and no all. } const idsOnWorkspace = checkoutProps.includeLocallyDeleted ? this.workspace.listIdsIncludeRemoved() : this.workspace.listIds(); const currentLane = await this.workspace.consumer.getCurrentLaneObject(); const currentLaneIds = currentLane?.toComponentIds(); // When on a lane and doing head checkout, only checkout lane components const ids = currentLaneIds && checkoutProps.head ? idsOnWorkspace.filter(id => currentLaneIds.hasWithoutVersion(id)) : idsOnWorkspace; checkoutProps.ids = ids.map(id => checkoutProps.head || checkoutProps.latest ? id.changeVersion(_legacy().LATEST) : id); } async parseValues(componentPattern, checkoutProps) { // CLI-specific validations and deprecation warnings if (checkoutProps.head && !componentPattern) { if (checkoutProps.all) { this.logger.console(`"--all" is deprecated for "bit checkout ${_legacy().HEAD}", please omit it.`); } checkoutProps.all = true; } if (checkoutProps.latest && !componentPattern) { if (checkoutProps.all) { this.logger.console(`"--all" is deprecated for "bit checkout ${_legacy().LATEST}", please omit it.`); } checkoutProps.all = true; } if (componentPattern && checkoutProps.all) { throw new (_bitError().BitError)('please specify either [component-pattern] or --all, not both'); } if (!componentPattern && !checkoutProps.all) { throw new (_bitError().BitError)('please specify [component-pattern] or use --all flag'); } if (checkoutProps.workspaceOnly && !checkoutProps.head) { throw new (_bitError().BitError)(`--workspace-only flag can only be used with "head" (bit checkout head --workspace-only)`); } if (checkoutProps.reset || checkoutProps.head) { checkoutProps.includeLocallyDeleted = true; } const getIds = async () => { if (componentPattern) { return this.workspace.idsByPattern(componentPattern, true, { includeDeleted: checkoutProps.includeLocallyDeleted }); } return checkoutProps.includeLocallyDeleted ? this.workspace.listIdsIncludeRemoved() : this.workspace.listIds(); }; const idsOnWorkspace = await getIds(); const currentLane = await this.workspace.consumer.getCurrentLaneObject(); const currentLaneIds = currentLane?.toComponentIds(); // when no ids were given and the user is on a lane, return lane-ids only. // it's relevant for cases like "bit checkout head" when on a lane to not checkout main components. (see https://github.com/teambit/bit/pull/6853) const ids = currentLaneIds && !componentPattern && checkoutProps.head ? idsOnWorkspace.filter(id => currentLaneIds.hasWithoutVersion(id)) : idsOnWorkspace; checkoutProps.ids = ids.map(id => checkoutProps.head || checkoutProps.latest ? id.changeVersion(_legacy().LATEST) : id); } async getNewComponentsFromLane(ids) { // current lane object is up to date due to the previous `importCurrentObjects()` call const lane = await this.workspace.consumer.getCurrentLaneObject(); if (!lane) { return []; } const laneBitIds = lane.toComponentIds(); const newComponentIds = laneBitIds.filter(bitId => !ids.find(id => id.isEqualWithoutVersion(bitId))); const nonRemovedNewIds = []; await Promise.all(newComponentIds.map(async id => { const isRemoved = await this.workspace.scope.isComponentRemoved(id); if (!isRemoved) nonRemovedNewIds.push(id); })); return nonRemovedNewIds; } async getNewComponentsFromScope() { const defaultScope = this.workspace.defaultScope; if (!defaultScope) return []; try { const remoteComponents = await this.lister.remoteList(defaultScope, { namespacesUsingWildcards: '**' }); const workspaceIds = this.workspace.listIdsIncludeRemoved(); const newComponents = remoteComponents.filter(remote => !remote.removed && !workspaceIds.hasWithoutVersion(remote.id)); return newComponents.map(c => c.id); } catch (err) { this.logger.warn(`unable to list components from defaultScope "${defaultScope}"`, err); return []; } } // eslint-disable-next-line complexity async getComponentStatusBeforeMergeAttempt(id, checkoutProps) { const consumer = this.workspace.consumer; const { version, head: headVersion, ancestor, reset, revert, main, latest: latestVersion, versionPerId, forceOurs, forceTheirs, loadStash } = checkoutProps; const repo = consumer.scope.objects; let existingBitMapId = consumer.bitMap.getComponentIdIfExist(id, { ignoreVersion: true }); const getComponent = async () => { try { const results = await consumer.loadComponents(_componentId().ComponentIdList.fromArray([id])); if (results.components[0]) return results.components[0]; if (checkoutProps.includeLocallyDeleted && results.removedComponents[0]) { return results.removedComponents[0]; } } catch (err) { if (checkoutProps.allowAddingComponentsFromScope && !existingBitMapId) return undefined; throw err; } return undefined; }; const component = await getComponent(); if (component) { // the component might fix an out-of-sync issue and as a result, the id has changed id = component.id; existingBitMapId = consumer.bitMap.getComponentIdIfExist(id, { ignoreVersion: true }); } const componentModel = await consumer.scope.getModelComponentIfExist(id); const componentStatus = { id }; const returnFailure = (msg, unchangedLegitimately = false) => { componentStatus.unchangedMessage = msg; componentStatus.unchangedLegitimately = unchangedLegitimately; return componentStatus; }; if (!componentModel) { return returnFailure(`component ${id.toString()} is new, no version to checkout`, true); } if (main && !componentModel.head) { return returnFailure(`component ${id.toString()} is not available on main`); } const unmerged = repo.unmergedComponents.getEntry(id); if (!reset && unmerged) { return returnFailure(`component ${id.toStringWithoutVersion()} is in during-merge state, please snap/tag it first (or use bit merge --resolve/--abort)`); } const getNewVersion = async () => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion if (reset) return component.id.version; if (headVersion) return componentModel.headIncludeRemote(repo); if (ancestor) { const previousParent = await componentModel.getRefOfAncestor(repo, ancestor); return componentModel.getTagOfRefIfExists(previousParent)?.toString() || previousParent.toString(); } // we verified previously that head exists in case of "main" if (main) return componentModel.head?.toString(); if (latestVersion) { const latest = componentModel.latestVersionIfExist(); return latest || componentModel.headIncludeRemote(repo); } if (versionPerId) { return versionPerId.find(bitId => bitId.isEqualWithoutVersion(id))?.version; } // if all above are false, the version is defined return version; }; const newVersion = await getNewVersion(); if (version && !headVersion) { const hasVersion = await componentModel.hasVersion(version, repo); if (!hasVersion) return returnFailure(`component ${id.toStringWithoutVersion()} doesn't have version ${version}`); } const currentlyUsedVersion = existingBitMapId?.version; if (existingBitMapId && !currentlyUsedVersion) { return returnFailure(`component ${id.toStringWithoutVersion()} is new`); } if (version && currentlyUsedVersion === version || versionPerId && currentlyUsedVersion === newVersion) { // it won't be relevant for 'reset' as it doesn't have a version/versionPerId return returnFailure(`component ${id.toStringWithoutVersion()} is already at version ${version || newVersion}`, true); } if ((headVersion || latestVersion) && currentlyUsedVersion === newVersion) { return returnFailure(`component ${id.toStringWithoutVersion()} is already at the latest version, which is ${newVersion}`, true); } if (!reset) { const divergeDataForMergePending = await componentModel.getDivergeDataForMergePending(repo); const isMergePending = divergeDataForMergePending.isDiverged(); if (isMergePending) { return returnFailure(`component is merge-pending and cannot be checked out, run "bit status" for more info`); } } let isModified = false; if (currentlyUsedVersion) { const currentVersionObject = await componentModel.loadVersion(currentlyUsedVersion, repo); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion isModified = await consumer.isComponentModified(currentVersionObject, component); const isRemoved = component && component.isRemoved(); if (!isModified && !isRemoved && reset) { return returnFailure(`component ${id.toStringWithoutVersion()} is not modified`, true); } } const versionRef = componentModel.getRef(newVersion); if (!versionRef) throw new Error(`unable to get ref ${newVersion} from ${componentModel.id()}`); const componentVersion = await consumer.scope.getObject(versionRef.hash); if (componentVersion?.isRemoved()) { if (existingBitMapId) componentStatus.shouldBeRemoved = true; return returnFailure(`component has been removed`, true); } const newId = id.changeVersion(newVersion); if (reset || !isModified && !loadStash || revert || !currentlyUsedVersion || forceTheirs || forceOurs) { // if the component is not modified, no need to try merge the files, they will be written later on according to the // checked out version. same thing when no version is specified, it'll be reset to the model-version later. // in case of "loadStash", we want to merge the stashed modifications regardless whether it's modified currently. // if !currentlyUsedVersion it only exists in the model, so just write it. (happening during bit-switch/bit-lane-import) return { currentComponent: component, componentFromModel: componentVersion, id: newId }; } const propsForMerge = { currentlyUsedVersion, componentModel }; return { currentComponent: component, componentFromModel: componentVersion, id: newId, propsForMerge }; } async getMergeStatus({ currentComponent: componentFromFS, componentFromModel, id, propsForMerge }, checkoutProps) { if (!propsForMerge) throw new Error(`propsForMerge is missing for ${id.toString()}`); if (!componentFromFS) throw new Error(`componentFromFS is missing for ${id.toString()}`); const consumer = this.workspace.consumer; const repo = consumer.scope.objects; const { currentlyUsedVersion, componentModel } = propsForMerge; // this is tricky. imagine the user is 0.0.2+modification and wants to checkout to 0.0.1. // the base is 0.0.1, as it's the common version for 0.0.1 and 0.0.2. however, if we let git merge-file use the 0.0.1 // as the base, then, it'll get the changes done since 0.0.1 to 0.0.1, which is nothing, and put them on top of // 0.0.2+modification. in other words, it won't make any change. // this scenario of checking out while there are modified files, is forbidden in Git. here, we want to simulate a similar // experience of "git stash", then "git checkout", then "git stash pop". practically, we want the changes done on 0.0.2 // to be added to 0.0.1 // if there is no modification, it doesn't go the threeWayMerge anyway, so it doesn't matter what the base is. let baseVersion = currentlyUsedVersion; const newVersion = id.version; let baseComponent = await componentModel.loadVersion(baseVersion, repo); const otherComponent = await componentModel.loadVersion(newVersion, repo); const { loadStash } = checkoutProps; if (loadStash && otherComponent.parents.length) { // for stash, we want the stashed modifications to be added on top of the current version. // for this to happen, the "base" must be the parent of the stashed version. const parent = otherComponent.parents[0]; baseVersion = parent.toString(); baseComponent = await componentModel.loadVersion(baseVersion, repo); } const mergeResults = await (0, _componentModules().threeWayMerge)({ scope: consumer.scope, otherComponent, otherLabel: loadStash ? 'stash' : newVersion, currentComponent: componentFromFS, currentLabel: `${currentlyUsedVersion} modified`, baseComponent }); return { currentComponent: componentFromFS, componentFromModel, id, mergeResults }; } static async provider([cli, workspace, loggerMain, compWriter, importer, remove, lister]) { const logger = loggerMain.createLogger(_checkout().CheckoutAspect.id); const checkoutMain = new CheckoutMain(workspace, logger, compWriter, importer, remove, lister); cli.register(new (_checkoutCmd().CheckoutCmd)(checkoutMain), new (_revertCmd().RevertCmd)(checkoutMain)); return checkoutMain; } } exports.CheckoutMain = CheckoutMain; _defineProperty(CheckoutMain, "slots", []); _defineProperty(CheckoutMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _logger().LoggerAspect, _componentWriter().ComponentWriterAspect, _importer().ImporterAspect, _remove().RemoveAspect, _lister().ListerAspect]); _defineProperty(CheckoutMain, "runtime", _cli().MainRuntime); _checkout().CheckoutAspect.addRuntime(CheckoutMain); var _default = exports.default = CheckoutMain; //# sourceMappingURL=checkout.main.runtime.js.map