@teambit/importer 0.0.284 → 0.0.286
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.
- package/dist/import-components.d.ts +4 -7
- package/dist/import-components.js +1 -7
- package/dist/import-components.js.map +1 -1
- package/dist/import.cmd.js +2 -1
- package/dist/import.cmd.js.map +1 -1
- package/dist/importer.main.runtime.js +0 -3
- package/dist/importer.main.runtime.js.map +1 -1
- package/package-tar/teambit-importer-0.0.286.tgz +0 -0
- package/package.json +9 -9
- package/{preview-1663299323454.js → preview-1663472005837.js} +2 -2
- package/package-tar/teambit-importer-0.0.284.tgz +0 -0
|
@@ -9,17 +9,14 @@ import { FilesStatus, MergeStrategy } from '@teambit/legacy/dist/consumer/versio
|
|
|
9
9
|
import { MergeResultsThreeWay } from '@teambit/legacy/dist/consumer/versions-ops/merge-version/three-way-merge';
|
|
10
10
|
export declare type ImportOptions = {
|
|
11
11
|
ids: string[];
|
|
12
|
-
verbose
|
|
12
|
+
verbose?: boolean;
|
|
13
13
|
merge?: boolean;
|
|
14
14
|
mergeStrategy?: MergeStrategy;
|
|
15
|
-
withEnvironments?: boolean;
|
|
16
15
|
writeToPath?: string;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
writeDists?: boolean;
|
|
20
|
-
override: boolean;
|
|
16
|
+
writeConfig?: boolean;
|
|
17
|
+
override?: boolean;
|
|
21
18
|
installNpmPackages: boolean;
|
|
22
|
-
objectsOnly
|
|
19
|
+
objectsOnly?: boolean;
|
|
23
20
|
saveDependenciesAsComponents?: boolean;
|
|
24
21
|
importDependenciesDirectly?: boolean;
|
|
25
22
|
importDependents?: boolean;
|
|
@@ -523,9 +523,7 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
|
|
|
523
523
|
const componentsIdsToImport = this.getIdsToImportFromBitmap();
|
|
524
524
|
|
|
525
525
|
if (_ramda().default.isEmpty(componentsIdsToImport)) {
|
|
526
|
-
|
|
527
|
-
throw new (_exceptions().NothingToImport)();
|
|
528
|
-
}
|
|
526
|
+
throw new (_exceptions().NothingToImport)();
|
|
529
527
|
}
|
|
530
528
|
|
|
531
529
|
await this._throwForModifiedOrNewComponents(componentsIdsToImport);
|
|
@@ -847,11 +845,7 @@ bit import ${idsFromRemote.map(id => id.toStringWithoutVersion()).join(' ')}`);
|
|
|
847
845
|
consumer: this.consumer,
|
|
848
846
|
componentsWithDependencies: componentsToWrite,
|
|
849
847
|
writeToPath: this.options.writeToPath,
|
|
850
|
-
writePackageJson: this.options.writePackageJson,
|
|
851
|
-
addToRootPackageJson: this.options.writePackageJson,
|
|
852
|
-
// no point to add to root if it doesn't have package.json
|
|
853
848
|
writeConfig: this.options.writeConfig,
|
|
854
|
-
writeDists: this.options.writeDists,
|
|
855
849
|
installNpmPackages: this.options.installNpmPackages,
|
|
856
850
|
verbose: this.options.verbose,
|
|
857
851
|
override: this.options.override
|
|
@@ -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","mainIds","getDefaultLaneIdsFromLane","mainIdsLatest","BitIds","fromArray","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","toBitIds","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","withEnvironments","NothingToImport","_throwForModifiedOrNewComponents","componentsAndDependencies","fromOriginalScope","authoredExportedComponents","getExportedComponents","getIdsOfDepsInstalledAsPackages","authoredNonExportedComponentsIds","getAuthoredNonExportedComponents","components","authoredNonExportedComponents","loadComponents","getAllDependenciesIds","missingDeps","dep","isInScope","isComponentInScope","versionsP","getModelComponentIfExist","listVersions","versions","fromPairs","currentVersions","detailsP","Object","keys","ShowDoctorError","afterImportVersions","versionDifference","difference","getStatus","filesStatus","mergeStatus","deprecated","isDeprecated","removed","latestVersion","latest","includes","status","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","writePackageJson","addToRootPackageJson","writeConfig","writeDists","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; // default: false\n merge?: boolean; // default: false\n mergeStrategy?: MergeStrategy;\n withEnvironments?: boolean; // default: false. Ignored by Harmony - always false.\n writeToPath?: string;\n writePackageJson?: boolean; // default: true. Ignored by Harmony - always false.\n writeConfig: boolean; // default: false\n writeDists?: boolean; // default: true. Ignored by Harmony - always true, as they're inside node_modules.\n override: boolean; // default: false\n installNpmPackages: boolean; // default: true\n objectsOnly: boolean; // default: false\n saveDependenciesAsComponents?: boolean; // default: false,\n importDependenciesDirectly?: boolean; // default: false, normally it imports them as packages or nested, not as imported\n importDependents?: boolean; // default: false,\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 if (lane) {\n const mainIds = await this.scope.getDefaultLaneIdsFromLane(lane);\n const mainIdsLatest = BitIds.fromArray(mainIds.map((m) => m.changeVersion(undefined)));\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 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 if (!this.options.withEnvironments) {\n throw new NothingToImport();\n }\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 /**\n * author might require bit-components that were installed via a package-manager. in that case,\n * the objects are not imported until bit build or bit tag was running. this makes sure to get\n * the objects on 'bit import', so then in the UI, they'll be shown nicely.\n */\n async getIdsOfDepsInstalledAsPackages() {\n if (!this.options.objectsOnly) {\n // this is needed only when importing objects. we don't want these components to be written to the fs\n return [];\n }\n const authoredNonExportedComponentsIds = this.consumer.bitMap.getAuthoredNonExportedComponents();\n const { components: authoredNonExportedComponents } = await this.consumer.loadComponents(\n BitIds.fromArray(authoredNonExportedComponentsIds),\n false\n );\n const dependencies: BitId[] = R.flatten(authoredNonExportedComponents.map((c) => c.getAllDependenciesIds()));\n const missingDeps: BitId[] = [];\n await Promise.all(\n dependencies.map(async (dep) => {\n if (!dep.hasScope()) return;\n const isInScope = await this.scope.isComponentInScope(dep);\n if (!isInScope) missingDeps.push(dep);\n })\n );\n return missingDeps;\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 writePackageJson: this.options.writePackageJson,\n addToRootPackageJson: this.options.writePackageJson, // no point to add to root if it doesn't have package.json\n writeConfig: this.options.writeConfig,\n writeDists: this.options.writeDists,\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;EAA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,UAAU,EAAE,KAAKxQ,OAAL,CAAawQ,UAP2B;MAQpDC,kBAAkB,EAAE,KAAKzQ,OAAL,CAAayQ,kBARmB;MASpDC,OAAO,EAAE,KAAK1Q,OAAL,CAAa0Q,OAT8B;MAUpD9H,QAAQ,EAAE,KAAK5I,OAAL,CAAa4I;IAV6B,CAAzB,CAA7B;IAYA,MAAMsH,oBAAoB,CAACS,QAArB,EAAN;EACD;;AAtkBmC"}
|
|
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","mainIds","getDefaultLaneIdsFromLane","mainIdsLatest","BitIds","fromArray","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","toBitIds","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","getIdsOfDepsInstalledAsPackages","authoredNonExportedComponentsIds","getAuthoredNonExportedComponents","components","authoredNonExportedComponents","loadComponents","getAllDependenciesIds","missingDeps","dep","isInScope","isComponentInScope","versionsP","getModelComponentIfExist","listVersions","versions","fromPairs","currentVersions","detailsP","Object","keys","ShowDoctorError","afterImportVersions","versionDifference","difference","getStatus","filesStatus","mergeStatus","deprecated","isDeprecated","removed","latestVersion","latest","includes","status","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 if (lane) {\n const mainIds = await this.scope.getDefaultLaneIdsFromLane(lane);\n const mainIdsLatest = BitIds.fromArray(mainIds.map((m) => m.changeVersion(undefined)));\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 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 /**\n * author might require bit-components that were installed via a package-manager. in that case,\n * the objects are not imported until bit build or bit tag was running. this makes sure to get\n * the objects on 'bit import', so then in the UI, they'll be shown nicely.\n */\n async getIdsOfDepsInstalledAsPackages() {\n if (!this.options.objectsOnly) {\n // this is needed only when importing objects. we don't want these components to be written to the fs\n return [];\n }\n const authoredNonExportedComponentsIds = this.consumer.bitMap.getAuthoredNonExportedComponents();\n const { components: authoredNonExportedComponents } = await this.consumer.loadComponents(\n BitIds.fromArray(authoredNonExportedComponentsIds),\n false\n );\n const dependencies: BitId[] = R.flatten(authoredNonExportedComponents.map((c) => c.getAllDependenciesIds()));\n const missingDeps: BitId[] = [];\n await Promise.all(\n dependencies.map(async (dep) => {\n if (!dep.hasScope()) return;\n const isInScope = await this.scope.isComponentInScope(dep);\n if (!isInScope) missingDeps.push(dep);\n })\n );\n return missingDeps;\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":";;;;;;;;;;;;;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,CAAN;EACD;;EAEuB,MAAlB/L,kBAAkB,CAAC3B,0BAAD,EAA0D;IAChF,IAAI,KAAK5B,OAAL,CAAagB,WAAjB,EAA8B;MAC5B;IACD;;IACD,MAAM+N,iBAAiB,GAAG,MAAM,KAAKL,2CAAL,CAAiD9M,0BAAjD,CAAhC;IACA,MAAMqO,oBAAoB,GAAG,KAAIC,+BAAJ,EAAyB;MACpDnQ,QAAQ,EAAE,KAAKA,QADqC;MAEpD6B,0BAA0B,EAAEmN,iBAFwB;MAGpDoB,WAAW,EAAE,KAAKnQ,OAAL,CAAamQ,WAH0B;MAIpDC,WAAW,EAAE,KAAKpQ,OAAL,CAAaoQ,WAJ0B;MAKpDC,kBAAkB,EAAE,KAAKrQ,OAAL,CAAaqQ,kBALmB;MAMpDC,OAAO,EAAE,KAAKtQ,OAAL,CAAasQ,OAN8B;MAOpD1H,QAAQ,EAAE,KAAK5I,OAAL,CAAa4I;IAP6B,CAAzB,CAA7B;IASA,MAAMqH,oBAAoB,CAACM,QAArB,EAAN;EACD;;AAjkBmC"}
|
package/dist/import.cmd.js
CHANGED
|
@@ -115,7 +115,8 @@ class ImportCmd {
|
|
|
115
115
|
(0, _defineProperty2().default)(this, "extendedDescription", void 0);
|
|
116
116
|
(0, _defineProperty2().default)(this, "group", 'collaborate');
|
|
117
117
|
(0, _defineProperty2().default)(this, "alias", '');
|
|
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'],
|
|
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
120
|
(0, _defineProperty2().default)(this, "loader", true);
|
|
120
121
|
(0, _defineProperty2().default)(this, "migration", true);
|
|
121
122
|
(0, _defineProperty2().default)(this, "remoteOp", true);
|
package/dist/import.cmd.js.map
CHANGED
|
@@ -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'],\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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C,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","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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AA0B9E,MAA1B,GAChBG,gBAAA,CAAM0E,GAAN,CAAW,yBAAwBnD,aAAa,CAACoD,WAAd,CAA0B9C,GAA1B,CAA+BC,CAAD,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"}
|
|
@@ -301,10 +301,7 @@ class ImporterMain {
|
|
|
301
301
|
ids,
|
|
302
302
|
objectsOnly: true,
|
|
303
303
|
verbose: false,
|
|
304
|
-
withEnvironments: false,
|
|
305
|
-
writePackageJson: false,
|
|
306
304
|
writeConfig: false,
|
|
307
|
-
writeDists: false,
|
|
308
305
|
override: false,
|
|
309
306
|
installNpmPackages: false,
|
|
310
307
|
fromOriginalScope
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ImporterMain","constructor","workspace","depResolver","import","importOptions","packageManagerArgs","ConsumerNotFound","consumer","ids","length","objectsOnly","isOnLane","currentRemoteLane","getCurrentRemoteLane","lanes","laneIds","toLaneId","currentLaneId","getCurrentLaneId","importComponents","ImportComponents","dependencies","importDetails","bitIds","map","R","path","Analytics","setExtraData","importedComponents","d","component","removeFromWorkspaceConfig","onDestroy","importWithOptions","fetch","components","fromOriginalScope","BitError","loader","start","verbose","withEnvironments","writePackageJson","writeConfig","writeDists","override","installNpmPackages","getLanes","envComponents","result","remoteLaneIds","id","trackLane","scope","getRemoteTrackedDataByLocalLane","LaneId","from","remoteLane","remoteScope","parse","objects","remoteLanes","getAllRemoteLaneIds","scopeComponentImporter","ScopeComponentsImporter","getInstance","importLanes","push","err","InvalidScopeName","ScopeNotFoundOrDenied","LaneNotFound","InvalidScopeNameFromRemote","stop","logger","console","message","importedPackageNames","getImportedPackagesNames","removeFromRootPolicy","persistConfig","componentIdToPackageName","provider","cli","community","importerMain","register","ImportCmd","getDocsDomain","FetchCmd","CLIAspect","WorkspaceAspect","DependencyResolverAspect","CommunityAspect","MainRuntime","ImporterAspect","addRuntime"],"sources":["importer.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\nimport R from 'ramda';\nimport { Analytics } from '@teambit/legacy/dist/analytics/analytics';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\n\nimport { InvalidScopeName, InvalidScopeNameFromRemote } from '@teambit/legacy-bit-id';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { LaneId } from '@teambit/lane-id';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { Lane } from '@teambit/legacy/dist/scope/models';\nimport { ScopeNotFoundOrDenied } from '@teambit/legacy/dist/remotes/exceptions/scope-not-found-or-denied';\nimport { LaneNotFound } from '@teambit/legacy/dist/api/scope/lib/exceptions/lane-not-found';\nimport { BitError } from '@teambit/bit-error';\nimport { ImportCmd } from './import.cmd';\nimport { ImporterAspect } from './importer.aspect';\nimport { FetchCmd } from './fetch-cmd';\nimport ImportComponents, { ImportOptions, ImportResult } from './import-components';\n\nexport class ImporterMain {\n constructor(private workspace: Workspace, private depResolver: DependencyResolverMain) {}\n\n async import(importOptions: ImportOptions, packageManagerArgs: string[]): Promise<ImportResult> {\n if (!this.workspace) throw new ConsumerNotFound();\n const consumer = this.workspace.consumer;\n consumer.packageManagerArgs = packageManagerArgs;\n if (!importOptions.ids.length) {\n importOptions.objectsOnly = true;\n }\n if (this.workspace.consumer.isOnLane()) {\n const currentRemoteLane = await this.workspace.getCurrentRemoteLane();\n if (currentRemoteLane) {\n importOptions.lanes = { laneIds: [currentRemoteLane.toLaneId()], lanes: [currentRemoteLane] };\n } else if (!importOptions.ids.length) {\n // this is probably a local lane that was never exported.\n // although no need to fetch from the lane, still, the import is needed for main (which are available on this\n // local lane)\n const currentLaneId = this.workspace.getCurrentLaneId();\n importOptions.lanes = { laneIds: [currentLaneId], lanes: [] };\n }\n }\n const importComponents = new ImportComponents(consumer, importOptions);\n const { dependencies, importDetails } = await importComponents.importComponents();\n const bitIds = dependencies.map(R.path(['component', 'id']));\n Analytics.setExtraData('num_components', bitIds.length);\n if (importOptions.ids.length) {\n const importedComponents = dependencies.map((d) => d.component);\n await this.removeFromWorkspaceConfig(importedComponents);\n }\n await consumer.onDestroy();\n return { dependencies, importDetails };\n }\n\n /**\n * @todo: combine with this.import()\n */\n async importWithOptions(importOptions: ImportOptions) {\n if (!this.workspace) throw new ConsumerNotFound();\n const consumer = this.workspace.consumer;\n const importComponents = new ImportComponents(consumer, importOptions);\n return importComponents.importComponents();\n }\n\n async fetch(ids: string[], lanes: boolean, components: boolean, fromOriginalScope: boolean) {\n if (!lanes && !components) {\n throw new BitError(\n `please provide the type of objects you would like to pull, the options are --components and --lanes`\n );\n }\n loader.start('fetching objects...');\n if (!this.workspace) throw new ConsumerNotFound();\n const consumer = this.workspace.consumer;\n const importOptions: ImportOptions = {\n ids,\n objectsOnly: true,\n verbose: false,\n withEnvironments: false,\n writePackageJson: false,\n writeConfig: false,\n writeDists: false,\n override: false,\n installNpmPackages: false,\n fromOriginalScope,\n };\n if (lanes) {\n importOptions.lanes = await getLanes();\n importOptions.ids = [];\n }\n const importComponents = new ImportComponents(consumer, importOptions);\n const { dependencies, envComponents, importDetails } = await importComponents.importComponents();\n const bitIds = dependencies.map(R.path(['component', 'id']));\n Analytics.setExtraData('num_components', bitIds.length);\n await consumer.onDestroy();\n return { dependencies, envComponents, importDetails };\n\n async function getLanes(): Promise<{ laneIds: LaneId[]; lanes: Lane[] }> {\n const result: { laneIds: LaneId[]; lanes: Lane[] } = { laneIds: [], lanes: [] };\n let remoteLaneIds: LaneId[] = [];\n if (ids.length) {\n remoteLaneIds = ids.map((id) => {\n const trackLane = consumer.scope.lanes.getRemoteTrackedDataByLocalLane(id);\n if (trackLane) return LaneId.from(trackLane.remoteLane, trackLane.remoteScope);\n return LaneId.parse(id);\n });\n } else {\n remoteLaneIds = await consumer.scope.objects.remoteLanes.getAllRemoteLaneIds();\n }\n const scopeComponentImporter = ScopeComponentsImporter.getInstance(consumer.scope);\n try {\n const remoteLanes = await scopeComponentImporter.importLanes(remoteLaneIds);\n result.laneIds.push(...remoteLaneIds);\n result.lanes.push(...remoteLanes);\n } catch (err) {\n if (\n err instanceof InvalidScopeName ||\n err instanceof ScopeNotFoundOrDenied ||\n err instanceof LaneNotFound ||\n err instanceof InvalidScopeNameFromRemote\n ) {\n // the lane could be a local lane so no need to throw an error in such case\n loader.stop();\n logger.console(`unable to get lane's data from a remote due to an error:\\n${err.message}`, 'warn', 'yellow');\n } else {\n throw err;\n }\n }\n\n return result;\n }\n }\n\n private async removeFromWorkspaceConfig(component: ConsumerComponent[]) {\n const importedPackageNames = this.getImportedPackagesNames(component);\n this.depResolver.removeFromRootPolicy(importedPackageNames);\n await this.depResolver.persistConfig(this.workspace.path);\n }\n\n private getImportedPackagesNames(components: ConsumerComponent[]): string[] {\n return components.map((component) => componentIdToPackageName(component));\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect, DependencyResolverAspect, CommunityAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, depResolver, community]: [\n CLIMain,\n Workspace,\n DependencyResolverMain,\n CommunityMain\n ]) {\n const importerMain = new ImporterMain(workspace, depResolver);\n cli.register(new ImportCmd(importerMain, community.getDocsDomain()), new FetchCmd(importerMain));\n return importerMain;\n }\n}\n\nImporterAspect.addRuntime(ImporterMain);\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;;AAEA;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;;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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,YAAN,CAAmB;EACxBC,WAAW,CAASC,SAAT,EAAuCC,WAAvC,EAA4E;IAA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,CAACC,GAAD,EAAMnF,SAAN,EAAiBC,WAAjB,EAA8BmF,SAA9B,CAAD,EAKlB;IACD,MAAMC,YAAY,GAAG,IAAIvF,YAAJ,CAAiBE,SAAjB,EAA4BC,WAA5B,CAArB;IACAkF,GAAG,CAACG,QAAJ,CAAa,KAAIC,mBAAJ,EAAcF,YAAd,EAA4BD,SAAS,CAACI,aAAV,EAA5B,CAAb,EAAqE,KAAIC,oBAAJ,EAAaJ,YAAb,CAArE;IACA,OAAOA,YAAP;EACD;;AAtIuB;;;gCAAbvF,Y,WA0HI,E;gCA1HJA,Y,kBA2HW,CAAC4F,gBAAD,EAAYC,oBAAZ,EAA6BC,8CAA7B,EAAuDC,4BAAvD,C;gCA3HX/F,Y,aA4HMgG,kB;;AAanBC,0BAAA,CAAeC,UAAf,CAA0BlG,YAA1B"}
|
|
1
|
+
{"version":3,"names":["ImporterMain","constructor","workspace","depResolver","import","importOptions","packageManagerArgs","ConsumerNotFound","consumer","ids","length","objectsOnly","isOnLane","currentRemoteLane","getCurrentRemoteLane","lanes","laneIds","toLaneId","currentLaneId","getCurrentLaneId","importComponents","ImportComponents","dependencies","importDetails","bitIds","map","R","path","Analytics","setExtraData","importedComponents","d","component","removeFromWorkspaceConfig","onDestroy","importWithOptions","fetch","components","fromOriginalScope","BitError","loader","start","verbose","writeConfig","override","installNpmPackages","getLanes","envComponents","result","remoteLaneIds","id","trackLane","scope","getRemoteTrackedDataByLocalLane","LaneId","from","remoteLane","remoteScope","parse","objects","remoteLanes","getAllRemoteLaneIds","scopeComponentImporter","ScopeComponentsImporter","getInstance","importLanes","push","err","InvalidScopeName","ScopeNotFoundOrDenied","LaneNotFound","InvalidScopeNameFromRemote","stop","logger","console","message","importedPackageNames","getImportedPackagesNames","removeFromRootPolicy","persistConfig","componentIdToPackageName","provider","cli","community","importerMain","register","ImportCmd","getDocsDomain","FetchCmd","CLIAspect","WorkspaceAspect","DependencyResolverAspect","CommunityAspect","MainRuntime","ImporterAspect","addRuntime"],"sources":["importer.main.runtime.ts"],"sourcesContent":["import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { CommunityAspect } from '@teambit/community';\nimport type { CommunityMain } from '@teambit/community';\nimport R from 'ramda';\nimport { Analytics } from '@teambit/legacy/dist/analytics/analytics';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\n\nimport { InvalidScopeName, InvalidScopeNameFromRemote } from '@teambit/legacy-bit-id';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { LaneId } from '@teambit/lane-id';\nimport ScopeComponentsImporter from '@teambit/legacy/dist/scope/component-ops/scope-components-importer';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { Lane } from '@teambit/legacy/dist/scope/models';\nimport { ScopeNotFoundOrDenied } from '@teambit/legacy/dist/remotes/exceptions/scope-not-found-or-denied';\nimport { LaneNotFound } from '@teambit/legacy/dist/api/scope/lib/exceptions/lane-not-found';\nimport { BitError } from '@teambit/bit-error';\nimport { ImportCmd } from './import.cmd';\nimport { ImporterAspect } from './importer.aspect';\nimport { FetchCmd } from './fetch-cmd';\nimport ImportComponents, { ImportOptions, ImportResult } from './import-components';\n\nexport class ImporterMain {\n constructor(private workspace: Workspace, private depResolver: DependencyResolverMain) {}\n\n async import(importOptions: ImportOptions, packageManagerArgs: string[]): Promise<ImportResult> {\n if (!this.workspace) throw new ConsumerNotFound();\n const consumer = this.workspace.consumer;\n consumer.packageManagerArgs = packageManagerArgs;\n if (!importOptions.ids.length) {\n importOptions.objectsOnly = true;\n }\n if (this.workspace.consumer.isOnLane()) {\n const currentRemoteLane = await this.workspace.getCurrentRemoteLane();\n if (currentRemoteLane) {\n importOptions.lanes = { laneIds: [currentRemoteLane.toLaneId()], lanes: [currentRemoteLane] };\n } else if (!importOptions.ids.length) {\n // this is probably a local lane that was never exported.\n // although no need to fetch from the lane, still, the import is needed for main (which are available on this\n // local lane)\n const currentLaneId = this.workspace.getCurrentLaneId();\n importOptions.lanes = { laneIds: [currentLaneId], lanes: [] };\n }\n }\n const importComponents = new ImportComponents(consumer, importOptions);\n const { dependencies, importDetails } = await importComponents.importComponents();\n const bitIds = dependencies.map(R.path(['component', 'id']));\n Analytics.setExtraData('num_components', bitIds.length);\n if (importOptions.ids.length) {\n const importedComponents = dependencies.map((d) => d.component);\n await this.removeFromWorkspaceConfig(importedComponents);\n }\n await consumer.onDestroy();\n return { dependencies, importDetails };\n }\n\n /**\n * @todo: combine with this.import()\n */\n async importWithOptions(importOptions: ImportOptions) {\n if (!this.workspace) throw new ConsumerNotFound();\n const consumer = this.workspace.consumer;\n const importComponents = new ImportComponents(consumer, importOptions);\n return importComponents.importComponents();\n }\n\n async fetch(ids: string[], lanes: boolean, components: boolean, fromOriginalScope: boolean) {\n if (!lanes && !components) {\n throw new BitError(\n `please provide the type of objects you would like to pull, the options are --components and --lanes`\n );\n }\n loader.start('fetching objects...');\n if (!this.workspace) throw new ConsumerNotFound();\n const consumer = this.workspace.consumer;\n const importOptions: ImportOptions = {\n ids,\n objectsOnly: true,\n verbose: false,\n writeConfig: false,\n override: false,\n installNpmPackages: false,\n fromOriginalScope,\n };\n if (lanes) {\n importOptions.lanes = await getLanes();\n importOptions.ids = [];\n }\n const importComponents = new ImportComponents(consumer, importOptions);\n const { dependencies, envComponents, importDetails } = await importComponents.importComponents();\n const bitIds = dependencies.map(R.path(['component', 'id']));\n Analytics.setExtraData('num_components', bitIds.length);\n await consumer.onDestroy();\n return { dependencies, envComponents, importDetails };\n\n async function getLanes(): Promise<{ laneIds: LaneId[]; lanes: Lane[] }> {\n const result: { laneIds: LaneId[]; lanes: Lane[] } = { laneIds: [], lanes: [] };\n let remoteLaneIds: LaneId[] = [];\n if (ids.length) {\n remoteLaneIds = ids.map((id) => {\n const trackLane = consumer.scope.lanes.getRemoteTrackedDataByLocalLane(id);\n if (trackLane) return LaneId.from(trackLane.remoteLane, trackLane.remoteScope);\n return LaneId.parse(id);\n });\n } else {\n remoteLaneIds = await consumer.scope.objects.remoteLanes.getAllRemoteLaneIds();\n }\n const scopeComponentImporter = ScopeComponentsImporter.getInstance(consumer.scope);\n try {\n const remoteLanes = await scopeComponentImporter.importLanes(remoteLaneIds);\n result.laneIds.push(...remoteLaneIds);\n result.lanes.push(...remoteLanes);\n } catch (err) {\n if (\n err instanceof InvalidScopeName ||\n err instanceof ScopeNotFoundOrDenied ||\n err instanceof LaneNotFound ||\n err instanceof InvalidScopeNameFromRemote\n ) {\n // the lane could be a local lane so no need to throw an error in such case\n loader.stop();\n logger.console(`unable to get lane's data from a remote due to an error:\\n${err.message}`, 'warn', 'yellow');\n } else {\n throw err;\n }\n }\n\n return result;\n }\n }\n\n private async removeFromWorkspaceConfig(component: ConsumerComponent[]) {\n const importedPackageNames = this.getImportedPackagesNames(component);\n this.depResolver.removeFromRootPolicy(importedPackageNames);\n await this.depResolver.persistConfig(this.workspace.path);\n }\n\n private getImportedPackagesNames(components: ConsumerComponent[]): string[] {\n return components.map((component) => componentIdToPackageName(component));\n }\n\n static slots = [];\n static dependencies = [CLIAspect, WorkspaceAspect, DependencyResolverAspect, CommunityAspect];\n static runtime = MainRuntime;\n static async provider([cli, workspace, depResolver, community]: [\n CLIMain,\n Workspace,\n DependencyResolverMain,\n CommunityMain\n ]) {\n const importerMain = new ImporterMain(workspace, depResolver);\n cli.register(new ImportCmd(importerMain, community.getDocsDomain()), new FetchCmd(importerMain));\n return importerMain;\n }\n}\n\nImporterAspect.addRuntime(ImporterMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA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AAanBC,0BAAA,CAAeC,UAAf,CAA0B/F,YAA1B"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/importer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.286",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/scope/importer",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.scope",
|
|
8
8
|
"name": "importer",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.286"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -16,15 +16,15 @@
|
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
17
|
"@babel/runtime": "7.12.18",
|
|
18
18
|
"core-js": "^3.0.0",
|
|
19
|
-
"@teambit/cli": "0.0.568",
|
|
20
|
-
"@teambit/bit-error": "0.0.400",
|
|
21
19
|
"@teambit/component-version": "0.0.395",
|
|
22
|
-
"@teambit/lane-id": "0.0.87",
|
|
23
20
|
"@teambit/harmony": "0.3.3",
|
|
24
|
-
"@teambit/
|
|
25
|
-
"@teambit/
|
|
21
|
+
"@teambit/cli": "0.0.569",
|
|
22
|
+
"@teambit/bit-error": "0.0.400",
|
|
23
|
+
"@teambit/lane-id": "0.0.88",
|
|
24
|
+
"@teambit/community": "0.0.117",
|
|
25
|
+
"@teambit/dependency-resolver": "0.0.857",
|
|
26
26
|
"@teambit/legacy-bit-id": "0.0.414",
|
|
27
|
-
"@teambit/workspace": "0.0.
|
|
27
|
+
"@teambit/workspace": "0.0.857"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/semver": "7.3.4",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@types/node": "12.20.4"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@teambit/legacy": "1.0.
|
|
40
|
+
"@teambit/legacy": "1.0.350",
|
|
41
41
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
42
42
|
"react": "^16.8.0 || ^17.0.0"
|
|
43
43
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@0.0.286/dist/importer.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.scope_importer@0.0.286/dist/importer.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|