@teambit/importer 0.0.307 → 0.0.309

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"names":["ImportComponents","constructor","consumer","options","scope","laneObjects","lanes","importComponents","loader","start","BEFORE_IMPORT_ACTION","saveDependenciesAsComponents","config","_saveDependenciesAsComponents","ids","length","importObjectsOnLane","importSpecificComponents","importAccordingToBitMap","objectsOnly","Error","lane","undefined","bitIds","getBitIds","logger","debug","id","toString","beforeImportVersions","_getCurrentVersions","componentsWithDependencies","importComponentsObjects","allHistory","mainIdsLatest","BitIds","fromArray","toBitIds","map","m","changeVersion","ignoreMissingHead","mergeAllLanesResults","pMapSeries","laneObject","sources","mergeLane","mergedLanes","result","Promise","all","mergedLane","saveLane","componentsWithDependenciesFiltered","_filterComponentsWithLowerVersions","_fetchDivergeData","_throwForDivergedHistory","_writeToFileSystem","_saveLaneDataIfNeeded","importDetails","_getImportDetails","dependencies","join","_throwForPotentialIssues","importComponentsHarmony","component","modelComponent","getModelComponent","setDivergeData","objects","divergeData","push","merge","divergedComponents","filter","getDivergeData","isDiverged","snapsLocal","snapsOnLocalOnly","snapsRemote","snapsOnRemoteOnly","ComponentsPendingMerge","comp","sameIdHigherVersion","find","c","isEqual","isEqualWithoutVersion","isTag","version","semver","gt","getBitIdsForLanes","bitIdsFromLane","flatMap","mainIds","bitMap","getAuthoredAndImportedBitIdsOfDefaultLane","mainIdsToImport","hasScope","hasWithoutVersion","idsWithWildcard","hasWildcard","idsWithoutWildcard","idsWithoutWildcardPreferFromLane","idStr","BitId","parse","fromLane","searchWithoutVersion","idsFromRemote","getRemoteBitIdsByWildcards","existingOnLanes","BitError","l","name","toStringWithoutVersion","getBitIdsForNonLanes","importDependenciesDirectly","importDependents","graphs","_getComponentsGraphs","dependenciesIds","_getDependenciesFromGraph","dependentsIds","_getDependentsFromGraph","uniqFromArray","bitId","componentGraph","graph","scopeName","dependenciesInfo","getDependenciesInfo","d","R","flatten","dependents","dependentsInfo","getDependentsInfo","remotes","getScopeRemotes","scopeGraphs","override","componentsIdsToImport","getIdsToImportFromBitmap","isEmpty","NothingToImport","_throwForModifiedOrNewComponents","componentsAndDependencies","fromOriginalScope","authoredExportedComponents","getExportedComponents","versionsP","getModelComponentIfExist","listVersions","versions","fromPairs","currentVersions","components","detailsP","Object","keys","ShowDoctorError","afterImportVersions","versionDifference","difference","getStatus","filesStatus","mergeStatus","deprecated","isDeprecated","removed","latestVersion","latest","includes","status","missingDeps","missingDependencies","_throwForDifferentComponentWithSameName","componentsStatuses","getManyComponentsStatuses","modifiedComponents","modified","newlyCreated","GeneralError","chalk","yellow","forEach","existingId","getParsedIdIfExist","_getMergeStatus","componentWithDependencies","componentStatus","getComponentStatusById","mergeResults","componentModel","existingBitMapBitId","getBitId","ignoreVersion","fsComponent","loadComponent","currentlyUsedVersion","baseComponent","loadVersion","otherComponent","threeWayMerge","otherLabel","currentComponent","currentLabel","_updateComponentFilesPerMergeStrategy","componentMergeStatus","files","hasConflicts","mergeStrategy","MergeOptions","ours","file","pathNormalizeToLinux","relative","FileStatus","unchanged","updateComponentId","hasChanged","theirs","updated","modifiedFiles","applyModifiedVersion","updateAllComponentsAccordingToMergeStrategy","componentsStatusP","componentsStatus","componentWithConflict","getMergeStrategyInteractive","componentsToWrite","unchangedFiles","removeNulls","reject","isNil","_shouldSaveLaneData","isOnLane","currentLane","getCurrentLaneObject","idsFromRemoteLanes","existOnRemoteLane","has","saveInLane","setComponentProp","ref","getRef","addComponent","head","manyComponentsWriter","ManyComponentsWriter","writeToPath","writeConfig","installNpmPackages","verbose","writeAll"],"sources":["import-components.ts"],"sourcesContent":["import chalk from 'chalk';\nimport R from 'ramda';\nimport semver from 'semver';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\nimport pMapSeries from 'p-map-series';\nimport { isTag } from '@teambit/component-version';\nimport { getRemoteBitIdsByWildcards } from '@teambit/legacy/dist/api/consumer/lib/list-scope';\nimport { BitId, BitIds } from '@teambit/legacy/dist/bit-id';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BEFORE_IMPORT_ACTION } from '@teambit/legacy/dist/cli/loader/loader-messages';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport ShowDoctorError from '@teambit/legacy/dist/error/show-doctor-error';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport Remotes from '@teambit/legacy/dist/remotes/remotes';\nimport { ComponentWithDependencies, Scope } from '@teambit/legacy/dist/scope';\nimport DependencyGraph from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport { Lane, ModelComponent, Version } from '@teambit/legacy/dist/scope/models';\nimport { getScopeRemotes } from '@teambit/legacy/dist/scope/scope-remotes';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport hasWildcard from '@teambit/legacy/dist/utils/string/has-wildcard';\nimport Component from '@teambit/legacy/dist/consumer/component';\nimport { NothingToImport } from '@teambit/legacy/dist/consumer/exceptions';\nimport { applyModifiedVersion } from '@teambit/legacy/dist/consumer/versions-ops/checkout-version';\nimport {\n FileStatus,\n getMergeStrategyInteractive,\n MergeOptions,\n threeWayMerge,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport { FilesStatus, MergeStrategy } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';\nimport { MergeResultsThreeWay } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';\nimport ComponentsPendingMerge from '@teambit/legacy/dist/consumer/component-ops/exceptions/components-pending-merge';\nimport ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';\n\nexport type ImportOptions = {\n ids: string[]; // array might be empty\n verbose?: boolean;\n merge?: boolean;\n mergeStrategy?: MergeStrategy;\n writeToPath?: string;\n writeConfig?: boolean;\n override?: boolean;\n installNpmPackages: boolean; // default: true\n objectsOnly?: boolean;\n saveDependenciesAsComponents?: boolean;\n importDependenciesDirectly?: boolean; // default: false, normally it imports them as packages or nested, not as imported\n importDependents?: boolean;\n fromOriginalScope?: boolean; // default: false, otherwise, it fetches flattened dependencies from their dependents\n saveInLane?: boolean; // save the imported component on the current lane (won't be available on main)\n lanes?: {\n laneIds: LaneId[];\n lanes: Lane[]; // it can be an empty array when a lane is a local lane and doesn't exist on the remote\n };\n allHistory?: boolean;\n};\ntype ComponentMergeStatus = {\n componentWithDependencies: ComponentWithDependencies;\n mergeResults: MergeResultsThreeWay | null | undefined;\n};\ntype ImportedVersions = { [id: string]: string[] };\nexport type ImportStatus = 'added' | 'updated' | 'up to date';\nexport type ImportDetails = {\n id: string;\n versions: string[];\n latestVersion: string | null;\n status: ImportStatus;\n filesStatus: FilesStatus | null | undefined;\n missingDeps: BitId[];\n deprecated: boolean;\n removed?: boolean;\n};\nexport type ImportResult = {\n dependencies: ComponentWithDependencies[];\n envComponents?: Component[];\n importDetails: ImportDetails[];\n cancellationMessage?: string;\n};\n\nexport default class ImportComponents {\n consumer: Consumer;\n scope: Scope;\n options: ImportOptions;\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n mergeStatus: { [id: string]: FilesStatus };\n private laneObjects: Lane[];\n private divergeData: Array<ModelComponent> = [];\n // @ts-ignore\n constructor(consumer: Consumer, options: ImportOptions) {\n this.consumer = consumer;\n this.scope = consumer.scope;\n this.options = options;\n this.laneObjects = this.options.lanes ? (this.options.lanes.lanes as Lane[]) : [];\n }\n\n importComponents(): Promise<ImportResult> {\n loader.start(BEFORE_IMPORT_ACTION);\n this.options.saveDependenciesAsComponents = this.consumer.config._saveDependenciesAsComponents;\n if (this.options.lanes && !this.options.ids.length) {\n return this.importObjectsOnLane();\n }\n if (this.options.ids.length) {\n return this.importSpecificComponents();\n }\n return this.importAccordingToBitMap();\n }\n\n async importObjectsOnLane(): Promise<ImportResult> {\n if (!this.options.objectsOnly) {\n throw new Error(`importObjectsOnLane should have objectsOnly=true`);\n }\n if (this.laneObjects.length > 1) {\n throw new Error(`importObjectsOnLane does not support more than one lane`);\n }\n const lane = this.laneObjects.length ? this.laneObjects[0] : undefined;\n const bitIds: BitIds = await this.getBitIds();\n lane\n ? logger.debug(`importObjectsOnLane, Lane: ${lane.id()}, Ids: ${bitIds.toString()}`)\n : logger.debug(`importObjectsOnLane, the lane does not exist on the remote. importing only the main components`);\n const beforeImportVersions = await this._getCurrentVersions(bitIds);\n const componentsWithDependencies = await this.consumer.importComponentsObjects(bitIds, {\n allHistory: this.options.allHistory,\n lane,\n });\n\n // import lane components from their original scope, this way, it's possible to run diff/merge on them.\n // don't use `scope.getDefaultLaneIdsFromLane()`. we need all components, because it's possible that a component\n // does't have \"head\" locally although it exits in the origin-scope. it happens when the component was created on\n // the origin-scope after a component with the same-name was created on the lane\n if (lane) {\n // @todo: optimize this maybe. currently, it imports twice.\n // try to make the previous `importComponentsObjectsHarmony` import the same component once from the original\n // scope and once from the lane-scope.\n const mainIdsLatest = BitIds.fromArray(lane.toBitIds().map((m) => m.changeVersion(undefined)));\n await this.consumer.importComponentsObjects(mainIdsLatest, {\n allHistory: this.options.allHistory,\n ignoreMissingHead: true,\n });\n }\n\n // merge the lane objects\n const mergeAllLanesResults = await pMapSeries(this.laneObjects, (laneObject) =>\n this.scope.sources.mergeLane(laneObject, true)\n );\n const mergedLanes = mergeAllLanesResults.map((result) => result.mergeLane);\n await Promise.all(mergedLanes.map((mergedLane) => this.scope.lanes.saveLane(mergedLane)));\n\n const componentsWithDependenciesFiltered = this._filterComponentsWithLowerVersions(componentsWithDependencies);\n await this._fetchDivergeData(componentsWithDependenciesFiltered);\n this._throwForDivergedHistory();\n await this._writeToFileSystem(componentsWithDependenciesFiltered);\n await this._saveLaneDataIfNeeded(componentsWithDependenciesFiltered);\n const importDetails = await this._getImportDetails(beforeImportVersions, componentsWithDependencies);\n return { dependencies: componentsWithDependenciesFiltered, importDetails };\n }\n\n async importSpecificComponents(): Promise<ImportResult> {\n logger.debug(`importSpecificComponents, Ids: ${this.options.ids.join(', ')}`);\n const bitIds: BitIds = await this.getBitIds();\n const beforeImportVersions = await this._getCurrentVersions(bitIds);\n await this._throwForPotentialIssues(bitIds);\n const componentsWithDependencies = await this.consumer.importComponentsHarmony(bitIds, true, this.laneObjects);\n if (this.laneObjects && this.options.objectsOnly) {\n // merge the lane objects\n const mergeAllLanesResults = await pMapSeries(this.laneObjects, (laneObject) =>\n this.scope.sources.mergeLane(laneObject, true)\n );\n const mergedLanes = mergeAllLanesResults.map((result) => result.mergeLane);\n await Promise.all(mergedLanes.map((mergedLane) => this.scope.lanes.saveLane(mergedLane)));\n }\n const componentsWithDependenciesFiltered = this._filterComponentsWithLowerVersions(componentsWithDependencies);\n await this._fetchDivergeData(componentsWithDependenciesFiltered);\n this._throwForDivergedHistory();\n await this._writeToFileSystem(componentsWithDependenciesFiltered);\n await this._saveLaneDataIfNeeded(componentsWithDependenciesFiltered);\n const importDetails = await this._getImportDetails(beforeImportVersions, componentsWithDependencies);\n return { dependencies: componentsWithDependenciesFiltered, importDetails };\n }\n\n async _fetchDivergeData(componentsWithDependencies: ComponentWithDependencies[]) {\n if (this.options.objectsOnly) {\n // no need for it when importing objects only. if it's enabled, in case when on a lane and a non-lane\n // component is in bitmap using an older version, it throws \"getDivergeData: unable to find Version X of Y\"\n return;\n }\n await Promise.all(\n componentsWithDependencies.map(async ({ component }) => {\n const modelComponent = await this.scope.getModelComponent(component.id);\n await modelComponent.setDivergeData(this.scope.objects, undefined, false);\n this.divergeData.push(modelComponent);\n })\n );\n }\n\n _throwForDivergedHistory() {\n if (this.options.merge || this.options.objectsOnly) return;\n const divergedComponents = this.divergeData.filter((modelComponent) =>\n modelComponent.getDivergeData().isDiverged()\n );\n if (divergedComponents.length) {\n const divergeData = divergedComponents.map((modelComponent) => ({\n id: modelComponent.id(),\n snapsLocal: modelComponent.getDivergeData().snapsOnLocalOnly.length,\n snapsRemote: modelComponent.getDivergeData().snapsOnRemoteOnly.length,\n }));\n throw new ComponentsPendingMerge(divergeData);\n }\n }\n\n /**\n * it can happen for example when importing a component with `--dependent` flag and the component has\n * the same dependent with different versions. we only want the one with the higher version\n */\n _filterComponentsWithLowerVersions(\n componentsWithDependencies: ComponentWithDependencies[]\n ): ComponentWithDependencies[] {\n return componentsWithDependencies.filter((comp) => {\n const sameIdHigherVersion = componentsWithDependencies.find(\n (c) =>\n !c.component.id.isEqual(comp.component.id) &&\n c.component.id.isEqualWithoutVersion(comp.component.id) &&\n isTag(c.component.id.version) &&\n isTag(comp.component.id.version) &&\n semver.gt(c.component.id.version as string, comp.component.id.version as string)\n );\n return !sameIdHigherVersion;\n });\n }\n\n /**\n * consider the following use cases:\n * 1) no ids were provided. it should import all the lanes components objects AND main components objects\n * (otherwise, if main components are not imported and are missing, then bit-status complains about it)\n * 2) ids are provided with wildcards. we assume the user wants only the ids that are available on the lane.\n * because a user may entered \"bit import scope/*\" and this scope has many component on the lane and many not on the lane.\n * we want to bring only the components on the lane.\n * 3) ids are provided without wildcards. here, the user knows exactly what's needed and it's ok to get the ids from\n * main if not found on the lane.\n */\n private async getBitIdsForLanes(): Promise<BitId[]> {\n if (!this.options.lanes) {\n throw new Error(`getBitIdsForLanes: this.options.lanes must be set`);\n }\n const bitIdsFromLane = BitIds.fromArray(this.laneObjects.flatMap((lane) => lane.toBitIds()));\n\n if (!this.options.ids.length) {\n const mainIds = this.consumer.bitMap.getAuthoredAndImportedBitIdsOfDefaultLane();\n const mainIdsToImport = mainIds.filter((id) => id.hasScope() && !bitIdsFromLane.hasWithoutVersion(id));\n bitIdsFromLane.push(...mainIdsToImport);\n return bitIdsFromLane;\n }\n\n const idsWithWildcard = this.options.ids.filter((id) => hasWildcard(id));\n const idsWithoutWildcard = this.options.ids.filter((id) => !hasWildcard(id));\n const idsWithoutWildcardPreferFromLane = idsWithoutWildcard.map((idStr) => {\n const id = BitId.parse(idStr, true);\n const fromLane = bitIdsFromLane.searchWithoutVersion(id);\n return fromLane || id;\n });\n\n const bitIds: BitId[] = [...idsWithoutWildcardPreferFromLane];\n\n if (!idsWithWildcard) {\n return bitIds;\n }\n\n await pMapSeries(idsWithWildcard, async (idStr: string) => {\n const idsFromRemote = await getRemoteBitIdsByWildcards(idStr);\n const existingOnLanes = idsFromRemote.filter((id) => bitIdsFromLane.hasWithoutVersion(id));\n if (!existingOnLanes.length) {\n throw new BitError(`the id with the the wildcard \"${idStr}\" has been parsed to multiple component ids.\nhowever, none of them existing on the lane \"${this.laneObjects.map((l) => l.name).join(', ')}\"\nin case you intend to import these components from main, please run the following:\nbit import ${idsFromRemote.map((id) => id.toStringWithoutVersion()).join(' ')}`);\n }\n bitIds.push(...existingOnLanes);\n });\n\n return bitIds;\n }\n\n private async getBitIdsForNonLanes() {\n const bitIds: BitId[] = [];\n await Promise.all(\n this.options.ids.map(async (idStr: string) => {\n if (hasWildcard(idStr)) {\n const ids = await getRemoteBitIdsByWildcards(idStr);\n loader.start(BEFORE_IMPORT_ACTION); // it stops the previous loader of BEFORE_REMOTE_LIST\n bitIds.push(...ids);\n } else {\n bitIds.push(BitId.parse(idStr, true)); // we don't support importing without a scope name\n }\n })\n );\n\n return bitIds;\n }\n\n private async getBitIds(): Promise<BitIds> {\n const bitIds: BitId[] = this.options.lanes ? await this.getBitIdsForLanes() : await this.getBitIdsForNonLanes();\n if (this.options.importDependenciesDirectly || this.options.importDependents) {\n const graphs = await this._getComponentsGraphs(bitIds);\n if (this.options.importDependenciesDirectly) {\n const dependenciesIds = this._getDependenciesFromGraph(bitIds, graphs);\n bitIds.push(...dependenciesIds);\n }\n if (this.options.importDependents) {\n const dependentsIds = this._getDependentsFromGraph(bitIds, graphs);\n bitIds.push(...dependentsIds);\n }\n }\n return BitIds.uniqFromArray(bitIds);\n }\n\n _getDependenciesFromGraph(bitIds: BitId[], graphs: DependencyGraph[]): BitId[] {\n const dependencies = bitIds.map((bitId) => {\n const componentGraph = graphs.find((graph) => graph.scopeName === bitId.scope);\n if (!componentGraph) {\n throw new Error(`unable to find a graph for ${bitId.toString()}`);\n }\n const dependenciesInfo = componentGraph.getDependenciesInfo(bitId);\n return dependenciesInfo.map((d) => d.id);\n });\n return R.flatten(dependencies);\n }\n\n _getDependentsFromGraph(bitIds: BitId[], graphs: DependencyGraph[]): BitId[] {\n const dependents = bitIds.map((bitId) => {\n const componentGraph = graphs.find((graph) => graph.scopeName === bitId.scope);\n if (!componentGraph) {\n throw new Error(`unable to find a graph for ${bitId.toString()}`);\n }\n const dependentsInfo = componentGraph.getDependentsInfo(bitId);\n return dependentsInfo.map((d) => d.id);\n });\n return R.flatten(dependents);\n }\n\n async _getComponentsGraphs(bitIds: BitId[]): Promise<DependencyGraph[]> {\n const remotes: Remotes = await getScopeRemotes(this.consumer.scope);\n return remotes.scopeGraphs(bitIds, this.consumer.scope);\n }\n\n async importAccordingToBitMap(): Promise<ImportResult> {\n this.options.objectsOnly = !this.options.merge && !this.options.override;\n const componentsIdsToImport = this.getIdsToImportFromBitmap();\n\n if (R.isEmpty(componentsIdsToImport)) {\n throw new NothingToImport();\n }\n await this._throwForModifiedOrNewComponents(componentsIdsToImport);\n const beforeImportVersions = await this._getCurrentVersions(componentsIdsToImport);\n\n let componentsAndDependencies: ComponentWithDependencies[] = [];\n if (componentsIdsToImport.length) {\n // change all ids version to 'latest'. otherwise, it tries to import local tags/snaps from a remote\n // const idsWithLatestVersion = componentsIdsToImport.toVersionLatest();\n if (!this.options.objectsOnly) {\n throw new Error(`bit import with no ids and --merge flag was not implemented yet`);\n }\n componentsAndDependencies = await this.consumer.importComponentsObjects(componentsIdsToImport, {\n fromOriginalScope: this.options.fromOriginalScope,\n allHistory: this.options.allHistory,\n });\n await this._writeToFileSystem(componentsAndDependencies);\n }\n const importDetails = await this._getImportDetails(beforeImportVersions, componentsAndDependencies);\n\n return { dependencies: componentsAndDependencies, importDetails };\n }\n\n private getIdsToImportFromBitmap() {\n const authoredExportedComponents = this.consumer.bitMap.getExportedComponents();\n return BitIds.fromArray(authoredExportedComponents);\n }\n\n async _getCurrentVersions(ids: BitIds): Promise<ImportedVersions> {\n const versionsP = ids.map(async (id) => {\n const modelComponent = await this.consumer.scope.getModelComponentIfExist(id.changeVersion(undefined));\n const idStr = id.toStringWithoutVersion();\n if (!modelComponent) return [idStr, []];\n return [idStr, modelComponent.listVersions()];\n });\n const versions = await Promise.all(versionsP);\n return R.fromPairs(versions);\n }\n\n /**\n * get import details, includes the diff between the versions array before import and after import\n */\n async _getImportDetails(\n currentVersions: ImportedVersions,\n components: ComponentWithDependencies[]\n ): Promise<ImportDetails[]> {\n const detailsP = components.map(async (component) => {\n const id = component.component.id;\n const idStr = id.toStringWithoutVersion();\n const beforeImportVersions = currentVersions[idStr];\n if (!beforeImportVersions) {\n throw new Error(\n `_getImportDetails failed finding ${idStr} in currentVersions, which has ${Object.keys(currentVersions).join(\n ', '\n )}`\n );\n }\n const modelComponent = await this.consumer.scope.getModelComponentIfExist(id);\n if (!modelComponent) throw new ShowDoctorError(`imported component ${idStr} was not found in the model`);\n const afterImportVersions = modelComponent.listVersions();\n const versionDifference: string[] = R.difference(afterImportVersions, beforeImportVersions);\n const getStatus = (): ImportStatus => {\n if (!versionDifference.length) return 'up to date';\n if (!beforeImportVersions.length) return 'added';\n return 'updated';\n };\n const filesStatus = this.mergeStatus && this.mergeStatus[idStr] ? this.mergeStatus[idStr] : null;\n const deprecated = await modelComponent.isDeprecated(this.scope.objects);\n const removed = component.component.removed;\n const latestVersion = modelComponent.latest();\n return {\n id: idStr,\n versions: versionDifference,\n latestVersion: versionDifference.includes(latestVersion) ? latestVersion : null,\n status: getStatus(),\n filesStatus,\n missingDeps: component.missingDependencies,\n deprecated,\n removed,\n };\n });\n return Promise.all(detailsP);\n }\n\n async _throwForPotentialIssues(ids: BitIds): Promise<void> {\n await this._throwForModifiedOrNewComponents(ids);\n this._throwForDifferentComponentWithSameName(ids);\n }\n\n async _throwForModifiedOrNewComponents(ids: BitIds): Promise<void> {\n // the typical objectsOnly option is when a user cloned a project with components tagged to the source code, but\n // doesn't have the model objects. in that case, calling getComponentStatusById() may return an error as it relies\n // on the model objects when there are dependencies\n if (this.options.override || this.options.objectsOnly || this.options.merge) return;\n const componentsStatuses = await this.consumer.getManyComponentsStatuses(ids);\n const modifiedComponents = componentsStatuses\n .filter(({ status }) => status.modified || status.newlyCreated)\n .map((c) => c.id);\n if (modifiedComponents.length) {\n throw new GeneralError(\n chalk.yellow(\n `unable to import the following components due to local changes, use --merge flag to merge your local changes or --override to override them\\n${modifiedComponents.join(\n '\\n'\n )} `\n )\n );\n }\n }\n\n /**\n * Model Component id() calculation uses id.toString() for the hash.\n * If an imported component has scopereadonly name equals to a local name, both will have the exact same\n * hash and they'll override each other.\n */\n _throwForDifferentComponentWithSameName(ids: BitIds): void {\n ids.forEach((id: BitId) => {\n const existingId = this.consumer.getParsedIdIfExist(id.toStringWithoutVersion());\n if (existingId && !existingId.hasScope()) {\n throw new GeneralError(`unable to import ${id.toString()}. the component name conflicted with your local component with the same name.\n it's fine to have components with the same name as long as their scope names are different.\n Make sure to export your component first to get a scope and then try importing again`);\n }\n });\n }\n\n async _getMergeStatus(componentWithDependencies: ComponentWithDependencies): Promise<ComponentMergeStatus> {\n const component = componentWithDependencies.component;\n const componentStatus = await this.consumer.getComponentStatusById(component.id);\n const mergeStatus: ComponentMergeStatus = { componentWithDependencies, mergeResults: null };\n if (!componentStatus.modified) return mergeStatus;\n const componentModel = await this.consumer.scope.getModelComponent(component.id);\n const existingBitMapBitId = this.consumer.bitMap.getBitId(component.id, { ignoreVersion: true });\n const fsComponent = await this.consumer.loadComponent(existingBitMapBitId);\n const currentlyUsedVersion = existingBitMapBitId.version;\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const baseComponent: Version = await componentModel.loadVersion(currentlyUsedVersion, this.consumer.scope.objects);\n const otherComponent: Version = await componentModel.loadVersion(\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n component.id.version,\n this.consumer.scope.objects\n );\n const mergeResults = await threeWayMerge({\n consumer: this.consumer,\n otherComponent,\n otherLabel: component.id.version as string,\n currentComponent: fsComponent,\n currentLabel: `${currentlyUsedVersion} modified`,\n baseComponent,\n });\n mergeStatus.mergeResults = mergeResults;\n return mergeStatus;\n }\n\n /**\n * 1) when there are conflicts and the strategy is \"ours\", don't write the imported component to\n * the filesystem, only update bitmap.\n *\n * 2) when there are conflicts and the strategy is \"theirs\", override the local changes by the\n * imported component. (similar to --override)\n *\n * 3) when there is no conflict or there are conflicts and the strategy is manual, write the files\n * according to the merge result. (done by applyModifiedVersion())\n */\n _updateComponentFilesPerMergeStrategy(componentMergeStatus: ComponentMergeStatus): FilesStatus | null | undefined {\n const mergeResults = componentMergeStatus.mergeResults;\n if (!mergeResults) return null;\n const component = componentMergeStatus.componentWithDependencies.component;\n const files = component.files;\n\n if (mergeResults.hasConflicts && this.options.mergeStrategy === MergeOptions.ours) {\n const filesStatus = {};\n // don't write the files to the filesystem, only bump the bitmap version.\n files.forEach((file) => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n filesStatus[pathNormalizeToLinux(file.relative)] = FileStatus.unchanged;\n });\n this.consumer.bitMap.updateComponentId(component.id);\n this.consumer.bitMap.hasChanged = true;\n return filesStatus;\n }\n if (mergeResults.hasConflicts && this.options.mergeStrategy === MergeOptions.theirs) {\n const filesStatus = {};\n // the local changes will be overridden (as if the user entered --override flag for this component)\n files.forEach((file) => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n filesStatus[pathNormalizeToLinux(file.relative)] = FileStatus.updated;\n });\n return filesStatus;\n }\n const { filesStatus, modifiedFiles } = applyModifiedVersion(\n component.files,\n mergeResults,\n this.options.mergeStrategy\n );\n component.files = modifiedFiles;\n\n return filesStatus;\n }\n\n /**\n * update the component files if they are modified and there is a merge strategy.\n * returns only the components that need to be written to the filesystem\n */\n async updateAllComponentsAccordingToMergeStrategy(\n componentsWithDependencies: ComponentWithDependencies[]\n ): Promise<ComponentWithDependencies[]> {\n if (!this.options.merge) return componentsWithDependencies;\n const componentsStatusP = componentsWithDependencies.map((componentWithDependencies: ComponentWithDependencies) => {\n return this._getMergeStatus(componentWithDependencies);\n });\n const componentsStatus = await Promise.all(componentsStatusP);\n const componentWithConflict = componentsStatus.find(\n (component) => component.mergeResults && component.mergeResults.hasConflicts\n );\n if (componentWithConflict && !this.options.mergeStrategy) {\n this.options.mergeStrategy = await getMergeStrategyInteractive();\n }\n this.mergeStatus = {};\n\n const componentsToWrite = componentsStatus.map((componentStatus) => {\n const filesStatus: FilesStatus | null | undefined = this._updateComponentFilesPerMergeStrategy(componentStatus);\n const componentWithDependencies = componentStatus.componentWithDependencies;\n if (!filesStatus) return componentWithDependencies;\n this.mergeStatus[componentWithDependencies.component.id.toStringWithoutVersion()] = filesStatus;\n const unchangedFiles = Object.keys(filesStatus).filter((file) => filesStatus[file] === FileStatus.unchanged);\n if (unchangedFiles.length === Object.keys(filesStatus).length) {\n // all files are unchanged\n return null;\n }\n return componentWithDependencies;\n });\n const removeNulls = R.reject(R.isNil);\n return removeNulls(componentsToWrite);\n }\n\n _shouldSaveLaneData(): boolean {\n if (this.options.objectsOnly) {\n return false;\n }\n return this.consumer.isOnLane();\n }\n\n async _saveLaneDataIfNeeded(componentsWithDependencies: ComponentWithDependencies[]): Promise<void> {\n if (!this._shouldSaveLaneData()) {\n return;\n }\n const currentLane = await this.consumer.getCurrentLaneObject();\n if (!currentLane) {\n return; // user on main\n }\n const idsFromRemoteLanes = BitIds.fromArray(this.laneObjects.flatMap((lane) => lane.toBitIds()));\n const components = componentsWithDependencies.map((c) => c.component);\n await Promise.all(\n components.map(async (comp) => {\n const existOnRemoteLane = idsFromRemoteLanes.has(comp.id);\n if (!existOnRemoteLane && !this.options.saveInLane) {\n this.consumer.bitMap.setComponentProp(comp.id, 'onLanesOnly', false);\n return;\n }\n const modelComponent = await this.scope.getModelComponent(comp.id);\n const ref = modelComponent.getRef(comp.id.version as string);\n if (!ref) throw new Error(`_saveLaneDataIfNeeded unable to get ref for ${comp.id.toString()}`);\n currentLane.addComponent({ id: comp.id, head: ref });\n })\n );\n await this.scope.lanes.saveLane(currentLane);\n }\n\n async _writeToFileSystem(componentsWithDependencies: ComponentWithDependencies[]) {\n if (this.options.objectsOnly) {\n return;\n }\n const componentsToWrite = await this.updateAllComponentsAccordingToMergeStrategy(componentsWithDependencies);\n const manyComponentsWriter = new ManyComponentsWriter({\n consumer: this.consumer,\n componentsWithDependencies: componentsToWrite,\n writeToPath: this.options.writeToPath,\n writeConfig: this.options.writeConfig,\n installNpmPackages: this.options.installNpmPackages,\n verbose: this.options.verbose,\n override: this.options.override,\n });\n await manyComponentsWriter.writeAll();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAA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E,KAAK5P,OAAL,CAAa4P,OAN8B;MAOpDjH,QAAQ,EAAE,KAAK3I,OAAL,CAAa2I;IAP6B,CAAzB,CAA7B;IASA,MAAM4G,oBAAoB,CAACM,QAArB,EAAN;EACD;;AAxiBmC"}
1
+ {"version":3,"names":["ImportComponents","constructor","workspace","graph","options","consumer","scope","laneObjects","lanes","importComponents","loader","start","BEFORE_IMPORT_ACTION","saveDependenciesAsComponents","config","_saveDependenciesAsComponents","ids","length","importObjectsOnLane","importSpecificComponents","importAccordingToBitMap","objectsOnly","Error","lane","undefined","bitIds","getBitIds","logger","debug","id","toString","beforeImportVersions","_getCurrentVersions","versionDependenciesArr","_importComponentsObjects","allHistory","mainIdsLatest","BitIds","fromArray","toBitIds","map","m","changeVersion","ignoreMissingHead","mergeAllLanesResults","pMapSeries","laneObject","sources","mergeLane","mergedLanes","result","Promise","all","mergedLane","saveLane","importDetails","_getImportDetails","importedIds","v","component","flat","importedDeps","allDependenciesIds","join","_throwForPotentialIssues","writtenComponents","componentsWithDependencies","multipleVersionDependenciesToConsumer","objects","_fetchDivergeData","_throwForDivergedHistory","_writeToFileSystem","_saveLaneDataIfNeeded","c","modelComponent","getModelComponent","setDivergeData","divergeData","push","merge","divergedComponents","filter","getDivergeData","isDiverged","snapsLocal","snapsOnLocalOnly","snapsRemote","snapsOnRemoteOnly","ComponentsPendingMerge","fromOriginalScope","scopeComponentsImporter","ScopeComponentsImporter","getInstance","importManyDeltaWithoutDeps","results","importManyFromOriginalScopes","importMany","getBitIdsForLanes","bitIdsFromLane","flatMap","mainIds","bitMap","getAuthoredAndImportedBitIdsOfDefaultLane","mainIdsToImport","hasScope","hasWithoutVersion","idsWithWildcard","hasWildcard","idsWithoutWildcard","idsWithoutWildcardPreferFromLane","idStr","BitId","parse","fromLane","searchWithoutVersion","idsFromRemote","getRemoteBitIdsByWildcards","existingOnLanes","BitError","l","name","toStringWithoutVersion","getBitIdsForNonLanes","importDependenciesDirectly","importDependents","graphs","_getComponentsGraphs","dependenciesIds","_getDependenciesFromGraph","getGraph","targetCompIds","resolveMultipleComponentIds","sourceIds","listIds","findIdsFromSourcesToTargets","_legacy","uniqFromArray","dependencies","bitId","componentGraph","find","scopeName","dependenciesInfo","getDependenciesInfo","d","R","flatten","_getDependentsFromGraph","dependents","dependentsInfo","getDependentsInfo","remotes","getScopeRemotes","scopeGraphs","override","componentsIdsToImport","getIdsToImportFromBitmap","isEmpty","NothingToImport","_throwForModifiedOrNewComponents","componentWithDependencies","authoredExportedComponents","getExportedComponents","versionsP","getModelComponentIfExist","listVersions","versions","fromPairs","currentVersions","components","detailsP","Object","keys","ShowDoctorError","afterImportVersions","versionDifference","difference","getStatus","filesStatus","mergeStatus","deprecated","isDeprecated","removed","isRemoved","latestVersion","latest","includes","status","missingDeps","getMissingDependencies","_throwForDifferentComponentWithSameName","componentsStatuses","getManyComponentsStatuses","modifiedComponents","modified","newlyCreated","GeneralError","chalk","yellow","forEach","existingId","getParsedIdIfExist","_getMergeStatus","componentStatus","getComponentStatusById","mergeResults","componentModel","existingBitMapBitId","getBitId","ignoreVersion","fsComponent","loadComponent","currentlyUsedVersion","version","baseComponent","loadVersion","otherComponent","threeWayMerge","otherLabel","currentComponent","currentLabel","_updateComponentFilesPerMergeStrategy","componentMergeStatus","files","hasConflicts","mergeStrategy","MergeOptions","ours","file","pathNormalizeToLinux","relative","FileStatus","unchanged","updateComponentId","hasChanged","theirs","updated","modifiedFiles","applyModifiedVersion","updateAllComponentsAccordingToMergeStrategy","componentsStatusP","componentsStatus","componentWithConflict","getMergeStrategyInteractive","componentsToWrite","unchangedFiles","removeNulls","reject","isNil","_shouldSaveLaneData","isOnLane","currentLane","getCurrentLaneObject","idsFromRemoteLanes","comp","existOnRemoteLane","has","saveInLane","setComponentProp","ref","getRef","addComponent","head","manyComponentsWriter","ManyComponentsWriter","writeToPath","writeConfig","installNpmPackages","verbose","writeAll"],"sources":["import-components.ts"],"sourcesContent":["import chalk from 'chalk';\nimport R from 'ramda';\nimport { BitError } from '@teambit/bit-error';\nimport { LaneId } from '@teambit/lane-id';\nimport pMapSeries from 'p-map-series';\nimport { getRemoteBitIdsByWildcards } from '@teambit/legacy/dist/api/consumer/lib/list-scope';\nimport { BitId, BitIds } from '@teambit/legacy/dist/bit-id';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BEFORE_IMPORT_ACTION } from '@teambit/legacy/dist/cli/loader/loader-messages';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport ShowDoctorError from '@teambit/legacy/dist/error/show-doctor-error';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport Remotes from '@teambit/legacy/dist/remotes/remotes';\nimport { ComponentWithDependencies, Scope } from '@teambit/legacy/dist/scope';\nimport DependencyGraph from '@teambit/legacy/dist/scope/graph/scope-graph';\nimport { Lane, ModelComponent, Version } from '@teambit/legacy/dist/scope/models';\nimport { getScopeRemotes } from '@teambit/legacy/dist/scope/scope-remotes';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport hasWildcard from '@teambit/legacy/dist/utils/string/has-wildcard';\nimport Component from '@teambit/legacy/dist/consumer/component';\nimport { NothingToImport } from '@teambit/legacy/dist/consumer/exceptions';\nimport { applyModifiedVersion } from '@teambit/legacy/dist/consumer/versions-ops/checkout-version';\nimport {\n FileStatus,\n getMergeStrategyInteractive,\n MergeOptions,\n threeWayMerge,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version';\nimport { FilesStatus, MergeStrategy } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';\nimport { MergeResultsThreeWay } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';\nimport ComponentsPendingMerge from '@teambit/legacy/dist/consumer/component-ops/exceptions/components-pending-merge';\nimport ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport VersionDependencies, {\n multipleVersionDependenciesToConsumer,\n} from '@teambit/legacy/dist/scope/version-dependencies';\nimport { GraphMain } from '@teambit/graph';\nimport { Workspace } from '@teambit/workspace';\n\nexport type ImportOptions = {\n ids: string[]; // array might be empty\n verbose?: boolean;\n merge?: boolean;\n mergeStrategy?: MergeStrategy;\n writeToPath?: string;\n writeConfig?: boolean;\n override?: boolean;\n installNpmPackages: boolean; // default: true\n objectsOnly?: boolean;\n saveDependenciesAsComponents?: boolean;\n importDependenciesDirectly?: boolean; // default: false, normally it imports them as packages or nested, not as imported\n importDependents?: boolean;\n fromOriginalScope?: boolean; // default: false, otherwise, it fetches flattened dependencies from their dependents\n saveInLane?: boolean; // save the imported component on the current lane (won't be available on main)\n lanes?: {\n laneIds: LaneId[];\n lanes: Lane[]; // it can be an empty array when a lane is a local lane and doesn't exist on the remote\n };\n allHistory?: boolean;\n};\ntype ComponentMergeStatus = {\n componentWithDependencies: ComponentWithDependencies;\n mergeResults: MergeResultsThreeWay | null | undefined;\n};\ntype ImportedVersions = { [id: string]: string[] };\nexport type ImportStatus = 'added' | 'updated' | 'up to date';\nexport type ImportDetails = {\n id: string;\n versions: string[];\n latestVersion: string | null;\n status: ImportStatus;\n filesStatus: FilesStatus | null | undefined;\n missingDeps: BitId[];\n deprecated: boolean;\n removed?: boolean;\n};\nexport type ImportResult = {\n importedIds: BitId[];\n importedDeps: BitId[];\n writtenComponents?: Component[];\n importDetails: ImportDetails[];\n cancellationMessage?: string;\n};\n\nexport default class ImportComponents {\n consumer: Consumer;\n scope: Scope;\n mergeStatus: { [id: string]: FilesStatus };\n private laneObjects: Lane[];\n private divergeData: Array<ModelComponent> = [];\n constructor(private workspace: Workspace, private graph: GraphMain, public options: ImportOptions) {\n this.consumer = this.workspace.consumer;\n this.scope = this.consumer.scope;\n this.laneObjects = this.options.lanes ? (this.options.lanes.lanes as Lane[]) : [];\n }\n\n importComponents(): Promise<ImportResult> {\n loader.start(BEFORE_IMPORT_ACTION);\n this.options.saveDependenciesAsComponents = this.consumer.config._saveDependenciesAsComponents;\n if (this.options.lanes && !this.options.ids.length) {\n return this.importObjectsOnLane();\n }\n if (this.options.ids.length) {\n return this.importSpecificComponents();\n }\n return this.importAccordingToBitMap();\n }\n\n async importObjectsOnLane(): Promise<ImportResult> {\n if (!this.options.objectsOnly) {\n throw new Error(`importObjectsOnLane should have objectsOnly=true`);\n }\n if (this.laneObjects.length > 1) {\n throw new Error(`importObjectsOnLane does not support more than one lane`);\n }\n const lane = this.laneObjects.length ? this.laneObjects[0] : undefined;\n const bitIds: BitIds = await this.getBitIds();\n lane\n ? logger.debug(`importObjectsOnLane, Lane: ${lane.id()}, Ids: ${bitIds.toString()}`)\n : logger.debug(`importObjectsOnLane, the lane does not exist on the remote. importing only the main components`);\n const beforeImportVersions = await this._getCurrentVersions(bitIds);\n const versionDependenciesArr = await this._importComponentsObjects(bitIds, {\n allHistory: this.options.allHistory,\n lane,\n });\n\n // import lane components from their original scope, this way, it's possible to run diff/merge on them.\n // don't use `scope.getDefaultLaneIdsFromLane()`. we need all components, because it's possible that a component\n // does't have \"head\" locally although it exits in the origin-scope. it happens when the component was created on\n // the origin-scope after a component with the same-name was created on the lane\n if (lane) {\n // @todo: optimize this maybe. currently, it imports twice.\n // try to make the previous `importComponentsObjectsHarmony` import the same component once from the original\n // scope and once from the lane-scope.\n const mainIdsLatest = BitIds.fromArray(lane.toBitIds().map((m) => m.changeVersion(undefined)));\n await this._importComponentsObjects(mainIdsLatest, {\n allHistory: this.options.allHistory,\n ignoreMissingHead: true,\n });\n }\n\n // merge the lane objects\n const mergeAllLanesResults = await pMapSeries(this.laneObjects, (laneObject) =>\n this.scope.sources.mergeLane(laneObject, true)\n );\n const mergedLanes = mergeAllLanesResults.map((result) => result.mergeLane);\n await Promise.all(mergedLanes.map((mergedLane) => this.scope.lanes.saveLane(mergedLane)));\n\n const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);\n return {\n importedIds: versionDependenciesArr.map((v) => v.component.id).flat(),\n importedDeps: versionDependenciesArr.map((v) => v.allDependenciesIds).flat(),\n importDetails,\n };\n }\n\n async importSpecificComponents(): Promise<ImportResult> {\n logger.debug(`importSpecificComponents, Ids: ${this.options.ids.join(', ')}`);\n const bitIds: BitIds = await this.getBitIds();\n const beforeImportVersions = await this._getCurrentVersions(bitIds);\n await this._throwForPotentialIssues(bitIds);\n const versionDependenciesArr = await this._importComponentsObjects(bitIds, {\n lane: this.laneObjects?.[0],\n });\n if (this.laneObjects && this.options.objectsOnly) {\n // merge the lane objects\n const mergeAllLanesResults = await pMapSeries(this.laneObjects, (laneObject) =>\n this.scope.sources.mergeLane(laneObject, true)\n );\n const mergedLanes = mergeAllLanesResults.map((result) => result.mergeLane);\n await Promise.all(mergedLanes.map((mergedLane) => this.scope.lanes.saveLane(mergedLane)));\n }\n let writtenComponents: Component[] = [];\n if (!this.options.objectsOnly) {\n const componentsWithDependencies = await multipleVersionDependenciesToConsumer(\n versionDependenciesArr,\n this.scope.objects\n );\n await this._fetchDivergeData(componentsWithDependencies);\n this._throwForDivergedHistory();\n await this._writeToFileSystem(componentsWithDependencies);\n await this._saveLaneDataIfNeeded(componentsWithDependencies);\n writtenComponents = componentsWithDependencies.map((c) => c.component);\n }\n\n const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);\n return {\n importedIds: versionDependenciesArr.map((v) => v.component.id).flat(),\n importedDeps: versionDependenciesArr.map((v) => v.allDependenciesIds).flat(),\n writtenComponents,\n importDetails,\n };\n }\n\n async _fetchDivergeData(componentsWithDependencies: ComponentWithDependencies[]) {\n if (this.options.objectsOnly) {\n // no need for it when importing objects only. if it's enabled, in case when on a lane and a non-lane\n // component is in bitmap using an older version, it throws \"getDivergeData: unable to find Version X of Y\"\n return;\n }\n await Promise.all(\n componentsWithDependencies.map(async ({ component }) => {\n const modelComponent = await this.scope.getModelComponent(component.id);\n await modelComponent.setDivergeData(this.scope.objects, undefined, false);\n this.divergeData.push(modelComponent);\n })\n );\n }\n\n _throwForDivergedHistory() {\n if (this.options.merge || this.options.objectsOnly) return;\n const divergedComponents = this.divergeData.filter((modelComponent) =>\n modelComponent.getDivergeData().isDiverged()\n );\n if (divergedComponents.length) {\n const divergeData = divergedComponents.map((modelComponent) => ({\n id: modelComponent.id(),\n snapsLocal: modelComponent.getDivergeData().snapsOnLocalOnly.length,\n snapsRemote: modelComponent.getDivergeData().snapsOnRemoteOnly.length,\n }));\n throw new ComponentsPendingMerge(divergeData);\n }\n }\n\n private async _importComponentsObjects(\n ids: BitIds,\n {\n fromOriginalScope = false,\n allHistory = false,\n lane,\n ignoreMissingHead = false,\n }: {\n fromOriginalScope?: boolean;\n allHistory?: boolean;\n lane?: Lane;\n ignoreMissingHead?: boolean;\n }\n ): Promise<VersionDependencies[]> {\n const scopeComponentsImporter = ScopeComponentsImporter.getInstance(this.scope);\n await scopeComponentsImporter.importManyDeltaWithoutDeps(ids, allHistory, lane, ignoreMissingHead);\n loader.start(`import ${ids.length} components with their dependencies (if missing)`);\n const results = fromOriginalScope\n ? await scopeComponentsImporter.importManyFromOriginalScopes(ids)\n : await scopeComponentsImporter.importMany({ ids, ignoreMissingHead, lanes: lane ? [lane] : undefined });\n\n return results;\n }\n\n /**\n * consider the following use cases:\n * 1) no ids were provided. it should import all the lanes components objects AND main components objects\n * (otherwise, if main components are not imported and are missing, then bit-status complains about it)\n * 2) ids are provided with wildcards. we assume the user wants only the ids that are available on the lane.\n * because a user may entered \"bit import scope/*\" and this scope has many component on the lane and many not on the lane.\n * we want to bring only the components on the lane.\n * 3) ids are provided without wildcards. here, the user knows exactly what's needed and it's ok to get the ids from\n * main if not found on the lane.\n */\n private async getBitIdsForLanes(): Promise<BitId[]> {\n if (!this.options.lanes) {\n throw new Error(`getBitIdsForLanes: this.options.lanes must be set`);\n }\n const bitIdsFromLane = BitIds.fromArray(this.laneObjects.flatMap((lane) => lane.toBitIds()));\n\n if (!this.options.ids.length) {\n const mainIds = this.consumer.bitMap.getAuthoredAndImportedBitIdsOfDefaultLane();\n const mainIdsToImport = mainIds.filter((id) => id.hasScope() && !bitIdsFromLane.hasWithoutVersion(id));\n bitIdsFromLane.push(...mainIdsToImport);\n return bitIdsFromLane;\n }\n\n const idsWithWildcard = this.options.ids.filter((id) => hasWildcard(id));\n const idsWithoutWildcard = this.options.ids.filter((id) => !hasWildcard(id));\n const idsWithoutWildcardPreferFromLane = idsWithoutWildcard.map((idStr) => {\n const id = BitId.parse(idStr, true);\n const fromLane = bitIdsFromLane.searchWithoutVersion(id);\n return fromLane || id;\n });\n\n const bitIds: BitId[] = [...idsWithoutWildcardPreferFromLane];\n\n if (!idsWithWildcard) {\n return bitIds;\n }\n\n await pMapSeries(idsWithWildcard, async (idStr: string) => {\n const idsFromRemote = await getRemoteBitIdsByWildcards(idStr);\n const existingOnLanes = idsFromRemote.filter((id) => bitIdsFromLane.hasWithoutVersion(id));\n if (!existingOnLanes.length) {\n throw new BitError(`the id with the the wildcard \"${idStr}\" has been parsed to multiple component ids.\nhowever, none of them existing on the lane \"${this.laneObjects.map((l) => l.name).join(', ')}\"\nin case you intend to import these components from main, please run the following:\nbit import ${idsFromRemote.map((id) => id.toStringWithoutVersion()).join(' ')}`);\n }\n bitIds.push(...existingOnLanes);\n });\n\n return bitIds;\n }\n\n private async getBitIdsForNonLanes() {\n const bitIds: BitId[] = [];\n await Promise.all(\n this.options.ids.map(async (idStr: string) => {\n if (hasWildcard(idStr)) {\n const ids = await getRemoteBitIdsByWildcards(idStr);\n loader.start(BEFORE_IMPORT_ACTION); // it stops the previous loader of BEFORE_REMOTE_LIST\n bitIds.push(...ids);\n } else {\n bitIds.push(BitId.parse(idStr, true)); // we don't support importing without a scope name\n }\n })\n );\n\n return bitIds;\n }\n\n private async getBitIds(): Promise<BitIds> {\n const bitIds: BitId[] = this.options.lanes ? await this.getBitIdsForLanes() : await this.getBitIdsForNonLanes();\n if (this.options.importDependenciesDirectly || this.options.importDependents) {\n const graphs = await this._getComponentsGraphs(bitIds);\n if (this.options.importDependenciesDirectly) {\n const dependenciesIds = this._getDependenciesFromGraph(bitIds, graphs);\n bitIds.push(...dependenciesIds);\n }\n if (this.options.importDependents) {\n const graph = await this.graph.getGraph();\n const targetCompIds = await this.workspace.resolveMultipleComponentIds(bitIds);\n const sourceIds = await this.workspace.listIds();\n const ids = graph.findIdsFromSourcesToTargets(sourceIds, targetCompIds);\n logger.debug(\n `found ${ids.length} component for --dependents flag`,\n ids.map((id) => id.toString())\n );\n bitIds.push(...ids.map((id) => id._legacy));\n }\n }\n return BitIds.uniqFromArray(bitIds);\n }\n\n _getDependenciesFromGraph(bitIds: BitId[], graphs: DependencyGraph[]): BitId[] {\n const dependencies = bitIds.map((bitId) => {\n const componentGraph = graphs.find((graph) => graph.scopeName === bitId.scope);\n if (!componentGraph) {\n throw new Error(`unable to find a graph for ${bitId.toString()}`);\n }\n const dependenciesInfo = componentGraph.getDependenciesInfo(bitId);\n return dependenciesInfo.map((d) => d.id);\n });\n return R.flatten(dependencies);\n }\n\n _getDependentsFromGraph(bitIds: BitId[], graphs: DependencyGraph[]): BitId[] {\n const dependents = bitIds.map((bitId) => {\n const componentGraph = graphs.find((graph) => graph.scopeName === bitId.scope);\n if (!componentGraph) {\n throw new Error(`unable to find a graph for ${bitId.toString()}`);\n }\n const dependentsInfo = componentGraph.getDependentsInfo(bitId);\n return dependentsInfo.map((d) => d.id);\n });\n return R.flatten(dependents);\n }\n\n async _getComponentsGraphs(bitIds: BitId[]): Promise<DependencyGraph[]> {\n const remotes: Remotes = await getScopeRemotes(this.consumer.scope);\n return remotes.scopeGraphs(bitIds, this.consumer.scope);\n }\n\n async importAccordingToBitMap(): Promise<ImportResult> {\n this.options.objectsOnly = !this.options.merge && !this.options.override;\n const componentsIdsToImport = this.getIdsToImportFromBitmap();\n\n if (R.isEmpty(componentsIdsToImport)) {\n throw new NothingToImport();\n }\n await this._throwForModifiedOrNewComponents(componentsIdsToImport);\n const beforeImportVersions = await this._getCurrentVersions(componentsIdsToImport);\n if (!componentsIdsToImport.length) {\n return {\n importedIds: [],\n importedDeps: [],\n importDetails: [],\n };\n }\n if (!this.options.objectsOnly) {\n throw new Error(`bit import with no ids and --merge flag was not implemented yet`);\n }\n const versionDependenciesArr = await this._importComponentsObjects(componentsIdsToImport, {\n fromOriginalScope: this.options.fromOriginalScope,\n allHistory: this.options.allHistory,\n });\n let writtenComponents: Component[] = [];\n if (!this.options.objectsOnly) {\n const componentWithDependencies = await multipleVersionDependenciesToConsumer(\n versionDependenciesArr,\n this.scope.objects\n );\n await this._writeToFileSystem(componentWithDependencies);\n writtenComponents = componentWithDependencies.map((c) => c.component);\n }\n\n const importDetails = await this._getImportDetails(beforeImportVersions, versionDependenciesArr);\n\n return {\n importedIds: versionDependenciesArr.map((v) => v.component.id).flat(),\n importedDeps: versionDependenciesArr.map((v) => v.allDependenciesIds).flat(),\n writtenComponents,\n importDetails,\n };\n }\n\n private getIdsToImportFromBitmap() {\n const authoredExportedComponents = this.consumer.bitMap.getExportedComponents();\n return BitIds.fromArray(authoredExportedComponents);\n }\n\n async _getCurrentVersions(ids: BitIds): Promise<ImportedVersions> {\n const versionsP = ids.map(async (id) => {\n const modelComponent = await this.consumer.scope.getModelComponentIfExist(id.changeVersion(undefined));\n const idStr = id.toStringWithoutVersion();\n if (!modelComponent) return [idStr, []];\n return [idStr, modelComponent.listVersions()];\n });\n const versions = await Promise.all(versionsP);\n return R.fromPairs(versions);\n }\n\n /**\n * get import details, includes the diff between the versions array before import and after import\n */\n async _getImportDetails(\n currentVersions: ImportedVersions,\n components: VersionDependencies[]\n ): Promise<ImportDetails[]> {\n const detailsP = components.map(async (component) => {\n const id = component.component.id;\n const idStr = id.toStringWithoutVersion();\n const beforeImportVersions = currentVersions[idStr];\n if (!beforeImportVersions) {\n throw new Error(\n `_getImportDetails failed finding ${idStr} in currentVersions, which has ${Object.keys(currentVersions).join(\n ', '\n )}`\n );\n }\n const modelComponent = await this.consumer.scope.getModelComponentIfExist(id);\n if (!modelComponent) throw new ShowDoctorError(`imported component ${idStr} was not found in the model`);\n const afterImportVersions = modelComponent.listVersions();\n const versionDifference: string[] = R.difference(afterImportVersions, beforeImportVersions);\n const getStatus = (): ImportStatus => {\n if (!versionDifference.length) return 'up to date';\n if (!beforeImportVersions.length) return 'added';\n return 'updated';\n };\n const filesStatus = this.mergeStatus && this.mergeStatus[idStr] ? this.mergeStatus[idStr] : null;\n const deprecated = await modelComponent.isDeprecated(this.scope.objects);\n const removed = await component.component.component.isRemoved(this.scope.objects);\n const latestVersion = modelComponent.latest();\n return {\n id: idStr,\n versions: versionDifference,\n latestVersion: versionDifference.includes(latestVersion) ? latestVersion : null,\n status: getStatus(),\n filesStatus,\n missingDeps: component.getMissingDependencies(),\n deprecated,\n removed,\n };\n });\n return Promise.all(detailsP);\n }\n\n async _throwForPotentialIssues(ids: BitIds): Promise<void> {\n await this._throwForModifiedOrNewComponents(ids);\n this._throwForDifferentComponentWithSameName(ids);\n }\n\n async _throwForModifiedOrNewComponents(ids: BitIds): Promise<void> {\n // the typical objectsOnly option is when a user cloned a project with components tagged to the source code, but\n // doesn't have the model objects. in that case, calling getComponentStatusById() may return an error as it relies\n // on the model objects when there are dependencies\n if (this.options.override || this.options.objectsOnly || this.options.merge) return;\n const componentsStatuses = await this.consumer.getManyComponentsStatuses(ids);\n const modifiedComponents = componentsStatuses\n .filter(({ status }) => status.modified || status.newlyCreated)\n .map((c) => c.id);\n if (modifiedComponents.length) {\n throw new GeneralError(\n chalk.yellow(\n `unable to import the following components due to local changes, use --merge flag to merge your local changes or --override to override them\\n${modifiedComponents.join(\n '\\n'\n )} `\n )\n );\n }\n }\n\n /**\n * Model Component id() calculation uses id.toString() for the hash.\n * If an imported component has scopereadonly name equals to a local name, both will have the exact same\n * hash and they'll override each other.\n */\n _throwForDifferentComponentWithSameName(ids: BitIds): void {\n ids.forEach((id: BitId) => {\n const existingId = this.consumer.getParsedIdIfExist(id.toStringWithoutVersion());\n if (existingId && !existingId.hasScope()) {\n throw new GeneralError(`unable to import ${id.toString()}. the component name conflicted with your local component with the same name.\n it's fine to have components with the same name as long as their scope names are different.\n Make sure to export your component first to get a scope and then try importing again`);\n }\n });\n }\n\n async _getMergeStatus(componentWithDependencies: ComponentWithDependencies): Promise<ComponentMergeStatus> {\n const component = componentWithDependencies.component;\n const componentStatus = await this.consumer.getComponentStatusById(component.id);\n const mergeStatus: ComponentMergeStatus = { componentWithDependencies, mergeResults: null };\n if (!componentStatus.modified) return mergeStatus;\n const componentModel = await this.consumer.scope.getModelComponent(component.id);\n const existingBitMapBitId = this.consumer.bitMap.getBitId(component.id, { ignoreVersion: true });\n const fsComponent = await this.consumer.loadComponent(existingBitMapBitId);\n const currentlyUsedVersion = existingBitMapBitId.version;\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const baseComponent: Version = await componentModel.loadVersion(currentlyUsedVersion, this.consumer.scope.objects);\n const otherComponent: Version = await componentModel.loadVersion(\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n component.id.version,\n this.consumer.scope.objects\n );\n const mergeResults = await threeWayMerge({\n consumer: this.consumer,\n otherComponent,\n otherLabel: component.id.version as string,\n currentComponent: fsComponent,\n currentLabel: `${currentlyUsedVersion} modified`,\n baseComponent,\n });\n mergeStatus.mergeResults = mergeResults;\n return mergeStatus;\n }\n\n /**\n * 1) when there are conflicts and the strategy is \"ours\", don't write the imported component to\n * the filesystem, only update bitmap.\n *\n * 2) when there are conflicts and the strategy is \"theirs\", override the local changes by the\n * imported component. (similar to --override)\n *\n * 3) when there is no conflict or there are conflicts and the strategy is manual, write the files\n * according to the merge result. (done by applyModifiedVersion())\n */\n _updateComponentFilesPerMergeStrategy(componentMergeStatus: ComponentMergeStatus): FilesStatus | null | undefined {\n const mergeResults = componentMergeStatus.mergeResults;\n if (!mergeResults) return null;\n const component = componentMergeStatus.componentWithDependencies.component;\n const files = component.files;\n\n if (mergeResults.hasConflicts && this.options.mergeStrategy === MergeOptions.ours) {\n const filesStatus = {};\n // don't write the files to the filesystem, only bump the bitmap version.\n files.forEach((file) => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n filesStatus[pathNormalizeToLinux(file.relative)] = FileStatus.unchanged;\n });\n this.consumer.bitMap.updateComponentId(component.id);\n this.consumer.bitMap.hasChanged = true;\n return filesStatus;\n }\n if (mergeResults.hasConflicts && this.options.mergeStrategy === MergeOptions.theirs) {\n const filesStatus = {};\n // the local changes will be overridden (as if the user entered --override flag for this component)\n files.forEach((file) => {\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n filesStatus[pathNormalizeToLinux(file.relative)] = FileStatus.updated;\n });\n return filesStatus;\n }\n const { filesStatus, modifiedFiles } = applyModifiedVersion(\n component.files,\n mergeResults,\n this.options.mergeStrategy\n );\n component.files = modifiedFiles;\n\n return filesStatus;\n }\n\n /**\n * update the component files if they are modified and there is a merge strategy.\n * returns only the components that need to be written to the filesystem\n */\n async updateAllComponentsAccordingToMergeStrategy(\n componentsWithDependencies: ComponentWithDependencies[]\n ): Promise<ComponentWithDependencies[]> {\n if (!this.options.merge) return componentsWithDependencies;\n const componentsStatusP = componentsWithDependencies.map((componentWithDependencies: ComponentWithDependencies) => {\n return this._getMergeStatus(componentWithDependencies);\n });\n const componentsStatus = await Promise.all(componentsStatusP);\n const componentWithConflict = componentsStatus.find(\n (component) => component.mergeResults && component.mergeResults.hasConflicts\n );\n if (componentWithConflict && !this.options.mergeStrategy) {\n this.options.mergeStrategy = await getMergeStrategyInteractive();\n }\n this.mergeStatus = {};\n\n const componentsToWrite = componentsStatus.map((componentStatus) => {\n const filesStatus: FilesStatus | null | undefined = this._updateComponentFilesPerMergeStrategy(componentStatus);\n const componentWithDependencies = componentStatus.componentWithDependencies;\n if (!filesStatus) return componentWithDependencies;\n this.mergeStatus[componentWithDependencies.component.id.toStringWithoutVersion()] = filesStatus;\n const unchangedFiles = Object.keys(filesStatus).filter((file) => filesStatus[file] === FileStatus.unchanged);\n if (unchangedFiles.length === Object.keys(filesStatus).length) {\n // all files are unchanged\n return null;\n }\n return componentWithDependencies;\n });\n const removeNulls = R.reject(R.isNil);\n return removeNulls(componentsToWrite);\n }\n\n _shouldSaveLaneData(): boolean {\n if (this.options.objectsOnly) {\n return false;\n }\n return this.consumer.isOnLane();\n }\n\n async _saveLaneDataIfNeeded(componentsWithDependencies: ComponentWithDependencies[]): Promise<void> {\n if (!this._shouldSaveLaneData()) {\n return;\n }\n const currentLane = await this.consumer.getCurrentLaneObject();\n if (!currentLane) {\n return; // user on main\n }\n const idsFromRemoteLanes = BitIds.fromArray(this.laneObjects.flatMap((lane) => lane.toBitIds()));\n const components = componentsWithDependencies.map((c) => c.component);\n await Promise.all(\n components.map(async (comp) => {\n const existOnRemoteLane = idsFromRemoteLanes.has(comp.id);\n if (!existOnRemoteLane && !this.options.saveInLane) {\n this.consumer.bitMap.setComponentProp(comp.id, 'onLanesOnly', false);\n return;\n }\n const modelComponent = await this.scope.getModelComponent(comp.id);\n const ref = modelComponent.getRef(comp.id.version as string);\n if (!ref) throw new Error(`_saveLaneDataIfNeeded unable to get ref for ${comp.id.toString()}`);\n currentLane.addComponent({ id: comp.id, head: ref });\n })\n );\n await this.scope.lanes.saveLane(currentLane);\n }\n\n async _writeToFileSystem(componentsWithDependencies: ComponentWithDependencies[]) {\n if (this.options.objectsOnly) {\n return;\n }\n const componentsToWrite = await this.updateAllComponentsAccordingToMergeStrategy(componentsWithDependencies);\n const manyComponentsWriter = new ManyComponentsWriter({\n consumer: this.consumer,\n componentsWithDependencies: componentsToWrite,\n writeToPath: this.options.writeToPath,\n writeConfig: this.options.writeConfig,\n installNpmPackages: this.options.installNpmPackages,\n verbose: this.options.verbose,\n override: this.options.override,\n });\n await manyComponentsWriter.writeAll();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAA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,IAAI,CAACjO,EAAlC,CAA7B;MACA,MAAMsO,GAAG,GAAGzL,cAAc,CAAC0L,MAAf,CAAsBN,IAAI,CAACjO,EAAL,CAAQwL,OAA9B,CAAZ;MACA,IAAI,CAAC8C,GAAL,EAAU,MAAM,IAAI7O,KAAJ,CAAW,+CAA8CwO,IAAI,CAACjO,EAAL,CAAQC,QAAR,EAAmB,EAA5E,CAAN;MACV6N,WAAW,CAACU,YAAZ,CAAyB;QAAExO,EAAE,EAAEiO,IAAI,CAACjO,EAAX;QAAeyO,IAAI,EAAEH;MAArB,CAAzB;IACD,CAVD,CADI,CAAN;IAaA,MAAM,KAAK7P,KAAL,CAAWE,KAAX,CAAiB8C,QAAjB,CAA0BqM,WAA1B,CAAN;EACD;;EAEuB,MAAlBpL,kBAAkB,CAACL,0BAAD,EAA0D;IAChF,IAAI,KAAK9D,OAAL,CAAaiB,WAAjB,EAA8B;MAC5B;IACD;;IACD,MAAM+N,iBAAiB,GAAG,MAAM,KAAKL,2CAAL,CAAiD7K,0BAAjD,CAAhC;IACA,MAAMqM,oBAAoB,GAAG,KAAIC,+BAAJ,EAAyB;MACpDnQ,QAAQ,EAAE,KAAKA,QADqC;MAEpD6D,0BAA0B,EAAEkL,iBAFwB;MAGpDqB,WAAW,EAAE,KAAKrQ,OAAL,CAAaqQ,WAH0B;MAIpDC,WAAW,EAAE,KAAKtQ,OAAL,CAAasQ,WAJ0B;MAKpDC,kBAAkB,EAAE,KAAKvQ,OAAL,CAAauQ,kBALmB;MAMpDC,OAAO,EAAE,KAAKxQ,OAAL,CAAawQ,OAN8B;MAOpDlH,QAAQ,EAAE,KAAKtJ,OAAL,CAAasJ;IAP6B,CAAzB,CAA7B;IASA,MAAM6G,oBAAoB,CAACM,QAArB,EAAN;EACD;;AA5kBmC"}
@@ -116,7 +116,7 @@ class ImportCmd {
116
116
  (0, _defineProperty2().default)(this, "group", 'collaborate');
117
117
  (0, _defineProperty2().default)(this, "alias", '');
118
118
  (0, _defineProperty2().default)(this, "options", [['p', 'path <path>', 'import components into a specific directory (a relative path in the workspace)'], ['o', 'objects', 'import components objects to the local scope without checkout (without writing them to the file system). This is a default behavior for import with no id argument'], ['d', 'display-dependencies', 'display the imported dependencies'], ['O', 'override', 'override local changes'], ['v', 'verbose', 'show verbose output for inspection'], ['j', 'json', 'return the output as JSON'], // ['', 'conf', 'write the configuration file (component.json) of the component'], // not working. need to fix once ComponentWriter is moved to Harmony
119
- ['', 'skip-npm-install', 'DEPRECATED. use "--skip-dependency-installation" instead'], ['', 'skip-dependency-installation', 'do not install packages of the imported components'], ['m', 'merge [strategy]', 'merge local changes with the imported version. strategy should be "theirs", "ours" or "manual"'], ['', 'dependencies', 'EXPERIMENTAL. import all dependencies and write them to the workspace'], ['', 'dependents', "EXPERIMENTAL. import the components' dependents. this enables changes to propagate from (modified) components to their dependents"], ['', 'save-in-lane', 'EXPERIMENTAL. when checked out to a lane and the component is not on the remote-lane, save it in the lane (default to save on main)'], ['', 'all-history', 'relevant for fetching all components objects. avoid optimizations, fetch all history versions, always']]);
119
+ ['', 'skip-npm-install', 'DEPRECATED. use "--skip-dependency-installation" instead'], ['', 'skip-dependency-installation', 'do not install packages of the imported components'], ['m', 'merge [strategy]', 'merge local changes with the imported version. strategy should be "theirs", "ours" or "manual"'], ['', 'dependencies', 'EXPERIMENTAL. import all dependencies and write them to the workspace'], ['', 'dependents', 'EXPERIMENTAL. import components found while traversing from the given ids upwards to the workspace components'], ['', 'save-in-lane', 'EXPERIMENTAL. when checked out to a lane and the component is not on the remote-lane, save it in the lane (default to save on main)'], ['', 'all-history', 'relevant for fetching all components objects. avoid optimizations, fetch all history versions, always']]);
120
120
  (0, _defineProperty2().default)(this, "loader", true);
121
121
  (0, _defineProperty2().default)(this, "migration", true);
122
122
  (0, _defineProperty2().default)(this, "remoteOp", true);
@@ -192,7 +192,9 @@ ${(0, _constants().WILDCARD_HELP)('import')}`;
192
192
  };
193
193
  const importResults = await this.importer.import(importOptions, this._packageManagerArgs);
194
194
  const {
195
- importDetails
195
+ importDetails,
196
+ importedIds,
197
+ importedDeps
196
198
  } = importResults;
197
199
 
198
200
  if (json) {
@@ -201,47 +203,37 @@ ${(0, _constants().WILDCARD_HELP)('import')}`;
201
203
  }, null, 4);
202
204
  }
203
205
 
204
- let dependenciesOutput;
205
-
206
- if (importResults.dependencies && !_ramda().default.isEmpty(importResults.dependencies)) {
207
- const components = importResults.dependencies.map(d => d.component);
208
-
209
- const peerDependencies = _ramda().default.flatten(importResults.dependencies.map(_ramda().default.prop('dependencies')), importResults.dependencies.map(_ramda().default.prop('devDependencies')));
210
-
211
- const titlePrefix = components.length === 1 ? 'successfully imported one component' : `successfully imported ${components.length} components`;
212
- let upToDateCount = 0;
213
- const componentDependencies = components.map(component => {
214
- const details = importDetails.find(c => c.id === component.id.toStringWithoutVersion());
215
- if (!details) throw new Error(`missing details of component ${component.id.toString()}`);
216
-
217
- if (details.status === 'up to date') {
218
- upToDateCount += 1;
219
- }
220
-
221
- return formatPlainComponentItemWithVersions(component, details);
222
- });
223
- const upToDateStr = upToDateCount === 0 ? '' : `, ${upToDateCount} components are up to date`;
224
- const title = `${titlePrefix}${upToDateStr}`;
225
- const componentDependenciesOutput = [_chalk().default.green(title), ...(0, _lodash().compact)(componentDependencies)].join('\n');
226
- const peerDependenciesOutput = peerDependencies && !_ramda().default.isEmpty(peerDependencies) && displayDependencies ? (0, _utils().immutableUnshift)(_ramda().default.uniq(peerDependencies.map(_chalkBox().formatPlainComponentItem)), _chalk().default.green(`\n\nsuccessfully imported ${components.length} component dependencies`)).join('\n') : '';
227
- dependenciesOutput = componentDependenciesOutput + peerDependenciesOutput;
206
+ if (!importedIds.length) {
207
+ return _chalk().default.yellow(importResults.cancellationMessage || 'nothing to import');
228
208
  }
229
209
 
230
- const getImportOutput = () => {
231
- if (dependenciesOutput) return dependenciesOutput;
232
- return _chalk().default.yellow(importResults.cancellationMessage || 'nothing to import');
233
- };
210
+ const titlePrefix = importedIds.length === 1 ? 'successfully imported one component' : `successfully imported ${importedIds.length} components`;
211
+ let upToDateCount = 0;
212
+ const importedComponents = importedIds.map(bitId => {
213
+ const details = importDetails.find(c => c.id === bitId.toStringWithoutVersion());
214
+ if (!details) throw new Error(`missing details of component ${bitId.toString()}`);
215
+
216
+ if (details.status === 'up to date') {
217
+ upToDateCount += 1;
218
+ }
234
219
 
235
- return getImportOutput();
220
+ return formatPlainComponentItemWithVersions(bitId, details);
221
+ });
222
+ const upToDateStr = upToDateCount === 0 ? '' : `, ${upToDateCount} components are up to date`;
223
+ const title = `${titlePrefix}${upToDateStr}`;
224
+ const componentDependenciesOutput = [_chalk().default.green(title), ...(0, _lodash().compact)(importedComponents)].join('\n');
225
+ const importedDepsOutput = displayDependencies && importedDeps.length ? (0, _utils().immutableUnshift)(_ramda().default.uniq(importedDeps.map(_chalkBox().formatPlainComponentItem)), _chalk().default.green(`\n\nsuccessfully imported ${importedDeps.length} component dependencies`)).join('\n') : '';
226
+ const dependenciesOutput = componentDependenciesOutput + importedDepsOutput;
227
+ return dependenciesOutput;
236
228
  }
237
229
 
238
230
  }
239
231
 
240
232
  exports.ImportCmd = ImportCmd;
241
233
 
242
- function formatPlainComponentItemWithVersions(component, importDetails) {
234
+ function formatPlainComponentItemWithVersions(bitId, importDetails) {
243
235
  const status = importDetails.status;
244
- const id = component.id.toStringWithoutVersion();
236
+ const id = bitId.toStringWithoutVersion();
245
237
 
246
238
  const getVersionsOutput = () => {
247
239
  if (!importDetails.versions.length) return '';
@@ -254,7 +246,7 @@ function formatPlainComponentItemWithVersions(component, importDetails) {
254
246
  };
255
247
 
256
248
  const versions = getVersionsOutput();
257
- const usedVersion = status === 'added' ? `, currently used version ${component.version}` : '';
249
+ const usedVersion = status === 'added' ? `, currently used version ${bitId.version}` : '';
258
250
 
259
251
  const getConflictMessage = () => {
260
252
  if (!importDetails.filesStatus) return '';
@@ -1 +1 @@
1
- {"version":3,"names":["ImportCmd","constructor","importer","docsDomain","name","description","extendedDescription","WILDCARD_HELP","report","ids","path","objects","displayDependencies","override","verbose","json","conf","skipNpmInstall","skipDependencyInstallation","merge","saveInLane","dependencies","dependents","allHistory","GeneralError","length","console","log","chalk","yellow","mergeStrategy","R","is","String","options","Object","keys","MergeOptions","includes","join","importOptions","Boolean","writeToPath","objectsOnly","writeConfig","installNpmPackages","importDependenciesDirectly","importDependents","importResults","import","_packageManagerArgs","importDetails","JSON","stringify","dependenciesOutput","isEmpty","components","map","d","component","peerDependencies","flatten","prop","titlePrefix","upToDateCount","componentDependencies","details","find","c","id","toStringWithoutVersion","Error","toString","status","formatPlainComponentItemWithVersions","upToDateStr","title","componentDependenciesOutput","green","compact","peerDependenciesOutput","immutableUnshift","uniq","formatPlainComponentItem","getImportOutput","cancellationMessage","getVersionsOutput","versions","latestVersion","usedVersion","version","getConflictMessage","filesStatus","conflictedFiles","filter","file","FileStatus","manual","bold","conflictMessage","deprecated","removed","red","missingDeps","undefined","cyan"],"sources":["import.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { compact } from 'lodash';\nimport R from 'ramda';\nimport { WILDCARD_HELP } from '@teambit/legacy/dist/constants';\nimport {\n FileStatus,\n MergeOptions,\n MergeStrategy,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component/consumer-component';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { immutableUnshift } from '@teambit/legacy/dist/utils';\nimport { formatPlainComponentItem } from '@teambit/legacy/dist/cli/chalk-box';\nimport { ImporterMain } from './importer.main.runtime';\nimport { ImportOptions, ImportDetails, ImportStatus } from './import-components';\n\nexport class ImportCmd implements Command {\n name = 'import [component-patterns...]';\n description = 'import components from their remote scopes to the local workspace';\n arguments = [\n {\n name: 'component-patterns...',\n description:\n 'component IDs or component patterns (separated by space). Use patterns to import groups of components using a common scope or namespace. E.g., \"utils/*\" (wrap with double quotes)',\n },\n ];\n extendedDescription: string;\n group = 'collaborate';\n alias = '';\n options = [\n ['p', 'path <path>', 'import components into a specific directory (a relative path in the workspace)'],\n [\n 'o',\n 'objects',\n 'import components objects to the local scope without checkout (without writing them to the file system). This is a default behavior for import with no id argument',\n ],\n ['d', 'display-dependencies', 'display the imported dependencies'],\n ['O', 'override', 'override local changes'],\n ['v', 'verbose', 'show verbose output for inspection'],\n ['j', 'json', 'return the output as JSON'],\n // ['', 'conf', 'write the configuration file (component.json) of the component'], // not working. need to fix once ComponentWriter is moved to Harmony\n ['', 'skip-npm-install', 'DEPRECATED. use \"--skip-dependency-installation\" instead'],\n ['', 'skip-dependency-installation', 'do not install packages of the imported components'],\n [\n 'm',\n 'merge [strategy]',\n 'merge local changes with the imported version. strategy should be \"theirs\", \"ours\" or \"manual\"',\n ],\n ['', 'dependencies', 'EXPERIMENTAL. import all dependencies and write them to the workspace'],\n [\n '',\n 'dependents',\n \"EXPERIMENTAL. import the components' dependents. this enables changes to propagate from (modified) components to their dependents\",\n ],\n [\n '',\n 'save-in-lane',\n 'EXPERIMENTAL. when checked out to a lane and the component is not on the remote-lane, save it in the lane (default to save on main)',\n ],\n [\n '',\n 'all-history',\n 'relevant for fetching all components objects. avoid optimizations, fetch all history versions, always',\n ],\n ] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n _packageManagerArgs: string[]; // gets populated by yargs-adapter.handler().\n\n constructor(private importer: ImporterMain, private docsDomain: string) {\n this.extendedDescription = `https://${docsDomain}/components/importing-components\n${WILDCARD_HELP('import')}`;\n }\n\n async report(\n [ids = []]: [string[]],\n {\n path,\n objects = false,\n displayDependencies = false,\n override = false,\n verbose = false,\n json = false,\n conf,\n skipNpmInstall = false,\n skipDependencyInstallation = false,\n merge,\n saveInLane = false,\n dependencies = false,\n dependents = false,\n allHistory = false,\n }: {\n path?: string;\n objects?: boolean;\n displayDependencies?: boolean;\n override?: boolean;\n verbose?: boolean;\n json?: boolean;\n conf?: string;\n skipNpmInstall?: boolean;\n skipDependencyInstallation?: boolean;\n merge?: MergeStrategy;\n saveInLane?: boolean;\n dependencies?: boolean;\n dependents?: boolean;\n allHistory?: boolean;\n }\n ): Promise<any> {\n if (objects && merge) {\n throw new GeneralError('you cant use --objects and --merge flags combined');\n }\n if (override && merge) {\n throw new GeneralError('you cant use --override and --merge flags combined');\n }\n if (!ids.length && dependencies) {\n throw new GeneralError('you have to specify ids to use \"--dependencies\" flag');\n }\n if (!ids.length && dependents) {\n throw new GeneralError('you have to specify ids to use \"--dependents\" flag');\n }\n if (skipNpmInstall) {\n // eslint-disable-next-line no-console\n console.log(\n chalk.yellow(`\"--skip-npm-install\" has been deprecated, please use \"--skip-dependency-installation\" instead`)\n );\n skipDependencyInstallation = true;\n }\n let mergeStrategy;\n if (merge && R.is(String, merge)) {\n const options = Object.keys(MergeOptions);\n if (!options.includes(merge)) {\n throw new GeneralError(`merge must be one of the following: ${options.join(', ')}`);\n }\n mergeStrategy = merge;\n }\n\n const importOptions: ImportOptions = {\n ids,\n verbose,\n merge: Boolean(merge),\n mergeStrategy,\n writeToPath: path,\n objectsOnly: objects,\n override,\n writeConfig: Boolean(conf),\n installNpmPackages: !skipDependencyInstallation,\n saveInLane,\n importDependenciesDirectly: dependencies,\n importDependents: dependents,\n allHistory,\n };\n const importResults = await this.importer.import(importOptions, this._packageManagerArgs);\n const { importDetails } = importResults;\n\n if (json) {\n return JSON.stringify({ importDetails }, null, 4);\n }\n let dependenciesOutput;\n\n if (importResults.dependencies && !R.isEmpty(importResults.dependencies)) {\n const components = importResults.dependencies.map((d) => d.component);\n const peerDependencies = R.flatten(\n importResults.dependencies.map(R.prop('dependencies')),\n importResults.dependencies.map(R.prop('devDependencies'))\n );\n\n const titlePrefix =\n components.length === 1\n ? 'successfully imported one component'\n : `successfully imported ${components.length} components`;\n\n let upToDateCount = 0;\n const componentDependencies = components.map((component) => {\n const details = importDetails.find((c) => c.id === component.id.toStringWithoutVersion());\n if (!details) throw new Error(`missing details of component ${component.id.toString()}`);\n if (details.status === 'up to date') {\n upToDateCount += 1;\n }\n return formatPlainComponentItemWithVersions(component, details);\n });\n const upToDateStr = upToDateCount === 0 ? '' : `, ${upToDateCount} components are up to date`;\n const title = `${titlePrefix}${upToDateStr}`;\n const componentDependenciesOutput = [chalk.green(title), ...compact(componentDependencies)].join('\\n');\n const peerDependenciesOutput =\n peerDependencies && !R.isEmpty(peerDependencies) && displayDependencies\n ? immutableUnshift(\n R.uniq(peerDependencies.map(formatPlainComponentItem)),\n chalk.green(`\\n\\nsuccessfully imported ${components.length} component dependencies`)\n ).join('\\n')\n : '';\n\n dependenciesOutput = componentDependenciesOutput + peerDependenciesOutput;\n }\n\n const getImportOutput = () => {\n if (dependenciesOutput) return dependenciesOutput;\n return chalk.yellow(importResults.cancellationMessage || 'nothing to import');\n };\n\n return getImportOutput();\n }\n}\n\nfunction formatPlainComponentItemWithVersions(component: ConsumerComponent, importDetails: ImportDetails) {\n const status: ImportStatus = importDetails.status;\n const id = component.id.toStringWithoutVersion();\n const getVersionsOutput = () => {\n if (!importDetails.versions.length) return '';\n if (importDetails.latestVersion) {\n return `${importDetails.versions.length} new version(s) available, latest ${importDetails.latestVersion}`;\n }\n return `new versions: ${importDetails.versions.join(', ')}`;\n };\n const versions = getVersionsOutput();\n const usedVersion = status === 'added' ? `, currently used version ${component.version}` : '';\n const getConflictMessage = () => {\n if (!importDetails.filesStatus) return '';\n const conflictedFiles = Object.keys(importDetails.filesStatus)\n // @ts-ignore file is set\n .filter((file) => importDetails.filesStatus[file] === FileStatus.manual);\n if (!conflictedFiles.length) return '';\n return `(the following files were saved with conflicts ${conflictedFiles\n .map((file) => chalk.bold(file))\n .join(', ')}) `;\n };\n const conflictMessage = getConflictMessage();\n const deprecated = importDetails.deprecated ? chalk.yellow('deprecated') : '';\n const removed = importDetails.removed ? chalk.red('removed') : '';\n const missingDeps = importDetails.missingDeps.length\n ? chalk.red(`missing dependencies: ${importDetails.missingDeps.map((d) => d.toString()).join(', ')}`)\n : '';\n if (status === 'up to date' && !missingDeps && !deprecated && !conflictMessage) {\n return undefined;\n }\n return `- ${chalk.green(status)} ${chalk.cyan(\n id\n )} ${versions}${usedVersion} ${conflictMessage}${deprecated}${removed} ${missingDeps}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,SAAN,CAAmC;EAoDT;EAE/BC,WAAW,CAASC,QAAT,EAAyCC,UAAzC,EAA6D;IAAA,KAApDD,QAAoD,GAApDA,QAAoD;IAAA,KAApBC,UAAoB,GAApBA,UAAoB;IAAA,8CArDjE,gCAqDiE;IAAA,qDApD1D,mEAoD0D;IAAA,mDAnD5D,CACV;MACEC,IAAI,EAAE,uBADR;MAEEC,WAAW,EACT;IAHJ,CADU,CAmD4D;IAAA;IAAA,+CA3ChE,aA2CgE;IAAA,+CA1ChE,EA0CgE;IAAA,iDAzC9D,CACR,CAAC,GAAD,EAAM,aAAN,EAAqB,gFAArB,CADQ,EAER,CACE,GADF,EAEE,SAFF,EAGE,oKAHF,CAFQ,EAOR,CAAC,GAAD,EAAM,sBAAN,EAA8B,mCAA9B,CAPQ,EAQR,CAAC,GAAD,EAAM,UAAN,EAAkB,wBAAlB,CARQ,EASR,CAAC,GAAD,EAAM,SAAN,EAAiB,oCAAjB,CATQ,EAUR,CAAC,GAAD,EAAM,MAAN,EAAc,2BAAd,CAVQ,EAWR;IACA,CAAC,EAAD,EAAK,kBAAL,EAAyB,0D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IAAOA,CAAC,CAACc,QAAF,EAArC,EAAmDjC,IAAnD,CAAwD,IAAxD,CAA8D,EAAjG,CADgB,GAEhB,EAFJ;;EAGA,IAAIkC,MAAM,KAAK,YAAX,IAA2B,CAAC8B,WAA5B,IAA2C,CAACH,UAA5C,IAA0D,CAACD,eAA/D,EAAgF;IAC9E,OAAOK,SAAP;EACD;;EACD,OAAQ,KAAI5E,gBAAA,CAAMkD,KAAN,CAAYL,MAAZ,CAAoB,IAAG7C,gBAAA,CAAM6E,IAAN,CACjCpC,EADiC,CAEjC,IAAGkB,QAAS,GAAEE,WAAY,IAAGU,eAAgB,GAAEC,UAAW,GAAEC,OAAQ,IAAGE,WAAY,EAFrF;AAGD"}
1
+ {"version":3,"names":["ImportCmd","constructor","importer","docsDomain","name","description","extendedDescription","WILDCARD_HELP","report","ids","path","objects","displayDependencies","override","verbose","json","conf","skipNpmInstall","skipDependencyInstallation","merge","saveInLane","dependencies","dependents","allHistory","GeneralError","length","console","log","chalk","yellow","mergeStrategy","R","is","String","options","Object","keys","MergeOptions","includes","join","importOptions","Boolean","writeToPath","objectsOnly","writeConfig","installNpmPackages","importDependenciesDirectly","importDependents","importResults","import","_packageManagerArgs","importDetails","importedIds","importedDeps","JSON","stringify","cancellationMessage","titlePrefix","upToDateCount","importedComponents","map","bitId","details","find","c","id","toStringWithoutVersion","Error","toString","status","formatPlainComponentItemWithVersions","upToDateStr","title","componentDependenciesOutput","green","compact","importedDepsOutput","immutableUnshift","uniq","formatPlainComponentItem","dependenciesOutput","getVersionsOutput","versions","latestVersion","usedVersion","version","getConflictMessage","filesStatus","conflictedFiles","filter","file","FileStatus","manual","bold","conflictMessage","deprecated","removed","red","missingDeps","d","undefined","cyan"],"sources":["import.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { compact } from 'lodash';\nimport R from 'ramda';\nimport { WILDCARD_HELP } from '@teambit/legacy/dist/constants';\nimport {\n FileStatus,\n MergeOptions,\n MergeStrategy,\n} from '@teambit/legacy/dist/consumer/versions-ops/merge-version/merge-version';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport GeneralError from '@teambit/legacy/dist/error/general-error';\nimport { immutableUnshift } from '@teambit/legacy/dist/utils';\nimport { formatPlainComponentItem } from '@teambit/legacy/dist/cli/chalk-box';\nimport { ImporterMain } from './importer.main.runtime';\nimport { ImportOptions, ImportDetails, ImportStatus } from './import-components';\n\nexport class ImportCmd implements Command {\n name = 'import [component-patterns...]';\n description = 'import components from their remote scopes to the local workspace';\n arguments = [\n {\n name: 'component-patterns...',\n description:\n 'component IDs or component patterns (separated by space). Use patterns to import groups of components using a common scope or namespace. E.g., \"utils/*\" (wrap with double quotes)',\n },\n ];\n extendedDescription: string;\n group = 'collaborate';\n alias = '';\n options = [\n ['p', 'path <path>', 'import components into a specific directory (a relative path in the workspace)'],\n [\n 'o',\n 'objects',\n 'import components objects to the local scope without checkout (without writing them to the file system). This is a default behavior for import with no id argument',\n ],\n ['d', 'display-dependencies', 'display the imported dependencies'],\n ['O', 'override', 'override local changes'],\n ['v', 'verbose', 'show verbose output for inspection'],\n ['j', 'json', 'return the output as JSON'],\n // ['', 'conf', 'write the configuration file (component.json) of the component'], // not working. need to fix once ComponentWriter is moved to Harmony\n ['', 'skip-npm-install', 'DEPRECATED. use \"--skip-dependency-installation\" instead'],\n ['', 'skip-dependency-installation', 'do not install packages of the imported components'],\n [\n 'm',\n 'merge [strategy]',\n 'merge local changes with the imported version. strategy should be \"theirs\", \"ours\" or \"manual\"',\n ],\n ['', 'dependencies', 'EXPERIMENTAL. import all dependencies and write them to the workspace'],\n [\n '',\n 'dependents',\n 'EXPERIMENTAL. import components found while traversing from the given ids upwards to the workspace components',\n ],\n [\n '',\n 'save-in-lane',\n 'EXPERIMENTAL. when checked out to a lane and the component is not on the remote-lane, save it in the lane (default to save on main)',\n ],\n [\n '',\n 'all-history',\n 'relevant for fetching all components objects. avoid optimizations, fetch all history versions, always',\n ],\n ] as CommandOptions;\n loader = true;\n migration = true;\n remoteOp = true;\n _packageManagerArgs: string[]; // gets populated by yargs-adapter.handler().\n\n constructor(private importer: ImporterMain, private docsDomain: string) {\n this.extendedDescription = `https://${docsDomain}/components/importing-components\n${WILDCARD_HELP('import')}`;\n }\n\n async report(\n [ids = []]: [string[]],\n {\n path,\n objects = false,\n displayDependencies = false,\n override = false,\n verbose = false,\n json = false,\n conf,\n skipNpmInstall = false,\n skipDependencyInstallation = false,\n merge,\n saveInLane = false,\n dependencies = false,\n dependents = false,\n allHistory = false,\n }: {\n path?: string;\n objects?: boolean;\n displayDependencies?: boolean;\n override?: boolean;\n verbose?: boolean;\n json?: boolean;\n conf?: string;\n skipNpmInstall?: boolean;\n skipDependencyInstallation?: boolean;\n merge?: MergeStrategy;\n saveInLane?: boolean;\n dependencies?: boolean;\n dependents?: boolean;\n allHistory?: boolean;\n }\n ): Promise<any> {\n if (objects && merge) {\n throw new GeneralError('you cant use --objects and --merge flags combined');\n }\n if (override && merge) {\n throw new GeneralError('you cant use --override and --merge flags combined');\n }\n if (!ids.length && dependencies) {\n throw new GeneralError('you have to specify ids to use \"--dependencies\" flag');\n }\n if (!ids.length && dependents) {\n throw new GeneralError('you have to specify ids to use \"--dependents\" flag');\n }\n if (skipNpmInstall) {\n // eslint-disable-next-line no-console\n console.log(\n chalk.yellow(`\"--skip-npm-install\" has been deprecated, please use \"--skip-dependency-installation\" instead`)\n );\n skipDependencyInstallation = true;\n }\n let mergeStrategy;\n if (merge && R.is(String, merge)) {\n const options = Object.keys(MergeOptions);\n if (!options.includes(merge)) {\n throw new GeneralError(`merge must be one of the following: ${options.join(', ')}`);\n }\n mergeStrategy = merge;\n }\n\n const importOptions: ImportOptions = {\n ids,\n verbose,\n merge: Boolean(merge),\n mergeStrategy,\n writeToPath: path,\n objectsOnly: objects,\n override,\n writeConfig: Boolean(conf),\n installNpmPackages: !skipDependencyInstallation,\n saveInLane,\n importDependenciesDirectly: dependencies,\n importDependents: dependents,\n allHistory,\n };\n const importResults = await this.importer.import(importOptions, this._packageManagerArgs);\n const { importDetails, importedIds, importedDeps } = importResults;\n\n if (json) {\n return JSON.stringify({ importDetails }, null, 4);\n }\n\n if (!importedIds.length) {\n return chalk.yellow(importResults.cancellationMessage || 'nothing to import');\n }\n\n const titlePrefix =\n importedIds.length === 1\n ? 'successfully imported one component'\n : `successfully imported ${importedIds.length} components`;\n\n let upToDateCount = 0;\n const importedComponents = importedIds.map((bitId) => {\n const details = importDetails.find((c) => c.id === bitId.toStringWithoutVersion());\n if (!details) throw new Error(`missing details of component ${bitId.toString()}`);\n if (details.status === 'up to date') {\n upToDateCount += 1;\n }\n return formatPlainComponentItemWithVersions(bitId, details);\n });\n const upToDateStr = upToDateCount === 0 ? '' : `, ${upToDateCount} components are up to date`;\n const title = `${titlePrefix}${upToDateStr}`;\n const componentDependenciesOutput = [chalk.green(title), ...compact(importedComponents)].join('\\n');\n const importedDepsOutput =\n displayDependencies && importedDeps.length\n ? immutableUnshift(\n R.uniq(importedDeps.map(formatPlainComponentItem)),\n chalk.green(`\\n\\nsuccessfully imported ${importedDeps.length} component dependencies`)\n ).join('\\n')\n : '';\n\n const dependenciesOutput = componentDependenciesOutput + importedDepsOutput;\n\n return dependenciesOutput;\n }\n}\n\nfunction formatPlainComponentItemWithVersions(bitId: BitId, importDetails: ImportDetails) {\n const status: ImportStatus = importDetails.status;\n const id = bitId.toStringWithoutVersion();\n const getVersionsOutput = () => {\n if (!importDetails.versions.length) return '';\n if (importDetails.latestVersion) {\n return `${importDetails.versions.length} new version(s) available, latest ${importDetails.latestVersion}`;\n }\n return `new versions: ${importDetails.versions.join(', ')}`;\n };\n const versions = getVersionsOutput();\n const usedVersion = status === 'added' ? `, currently used version ${bitId.version}` : '';\n const getConflictMessage = () => {\n if (!importDetails.filesStatus) return '';\n const conflictedFiles = Object.keys(importDetails.filesStatus)\n // @ts-ignore file is set\n .filter((file) => importDetails.filesStatus[file] === FileStatus.manual);\n if (!conflictedFiles.length) return '';\n return `(the following files were saved with conflicts ${conflictedFiles\n .map((file) => chalk.bold(file))\n .join(', ')}) `;\n };\n const conflictMessage = getConflictMessage();\n const deprecated = importDetails.deprecated ? chalk.yellow('deprecated') : '';\n const removed = importDetails.removed ? chalk.red('removed') : '';\n const missingDeps = importDetails.missingDeps.length\n ? chalk.red(`missing dependencies: ${importDetails.missingDeps.map((d) => d.toString()).join(', ')}`)\n : '';\n if (status === 'up to date' && !missingDeps && !deprecated && !conflictMessage) {\n return undefined;\n }\n return `- ${chalk.green(status)} ${chalk.cyan(\n id\n )} ${versions}${usedVersion} ${conflictMessage}${deprecated}${removed} ${missingDeps}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAMA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,MAAMA,SAAN,CAAmC;EAoDT;EAE/BC,WAAW,CAASC,QAAT,EAAyCC,UAAzC,EAA6D;IAAA,KAApDD,QAAoD,GAApDA,QAAoD;IAAA,KAApBC,UAAoB,GAApBA,UAAoB;IAAA,8CArDjE,gCAqDiE;IAAA,qDApD1D,mEAoD0D;IAAA,mDAnD5D,CACV;MACEC,IAAI,EAAE,uBADR;MAEEC,WAAW,EACT;IAHJ,CADU,CAmD4D;IAAA;IAAA,+CA3ChE,aA2CgE;IAAA,+CA1ChE,EA0CgE;IAAA,iDAzC9D,CACR,CAAC,GAAD,EAAM,aAAN,EAAqB,gFAArB,CADQ,EAER,CACE,GADF,EAEE,SAFF,E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C,EADiC,CAEjC,IAAGiB,QAAS,GAAEE,WAAY,IAAGU,eAAgB,GAAEC,UAAW,GAAEC,OAAQ,IAAGE,WAAY,EAFrF;AAGD"}
@@ -2,20 +2,20 @@ import { CLIMain } from '@teambit/cli';
2
2
  import { DependencyResolverMain } from '@teambit/dependency-resolver';
3
3
  import { Workspace } from '@teambit/workspace';
4
4
  import type { CommunityMain } from '@teambit/community';
5
- import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
5
+ import { GraphMain } from '@teambit/graph';
6
6
  import { ImportOptions, ImportResult } from './import-components';
7
7
  export declare class ImporterMain {
8
8
  private workspace;
9
9
  private depResolver;
10
- constructor(workspace: Workspace, depResolver: DependencyResolverMain);
10
+ private graph;
11
+ constructor(workspace: Workspace, depResolver: DependencyResolverMain, graph: GraphMain);
11
12
  import(importOptions: ImportOptions, packageManagerArgs: string[]): Promise<ImportResult>;
12
13
  /**
13
14
  * @todo: combine with this.import()
14
15
  */
15
16
  importWithOptions(importOptions: ImportOptions): Promise<ImportResult>;
16
17
  fetch(ids: string[], lanes: boolean, components: boolean, fromOriginalScope: boolean): Promise<{
17
- dependencies: import("@teambit/legacy/dist/scope").ComponentWithDependencies[];
18
- envComponents: ConsumerComponent[] | undefined;
18
+ importedIds: import("@teambit/legacy/dist/bit-id").BitId[];
19
19
  importDetails: import("./import-components").ImportDetails[];
20
20
  }>;
21
21
  private removeFromWorkspaceConfig;
@@ -23,10 +23,11 @@ export declare class ImporterMain {
23
23
  static slots: never[];
24
24
  static dependencies: import("@teambit/harmony").Aspect[];
25
25
  static runtime: import("@teambit/harmony").RuntimeDefinition;
26
- static provider([cli, workspace, depResolver, community]: [
26
+ static provider([cli, workspace, depResolver, community, graph]: [
27
27
  CLIMain,
28
28
  Workspace,
29
29
  DependencyResolverMain,
30
- CommunityMain
30
+ CommunityMain,
31
+ GraphMain
31
32
  ]): Promise<ImporterMain>;
32
33
  }