@teambit/snapping 1.0.511 → 1.0.512
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/artifacts/__bit_junit.xml +6 -6
- package/dist/flattened-edges.d.ts +1 -1
- package/dist/flattened-edges.js.map +1 -1
- package/dist/get-flattened-dependencies.d.ts +1 -1
- package/dist/get-flattened-dependencies.js.map +1 -1
- package/dist/reset-component.d.ts +1 -1
- package/dist/reset-component.js.map +1 -1
- package/dist/snapping.main.runtime.d.ts +1 -1
- package/dist/snapping.main.runtime.js +7 -7
- package/dist/snapping.main.runtime.js.map +1 -1
- package/dist/snapping.spec.js +5 -5
- package/dist/snapping.spec.js.map +1 -1
- package/dist/tag-model-component.d.ts +1 -1
- package/dist/tag-model-component.js +4 -4
- package/dist/tag-model-component.js.map +1 -1
- package/package.json +36 -36
- /package/dist/{preview-1736711473672.js → preview-1736824735631.js} +0 -0
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
2
|
<testsuites tests="13" failures="0" errors="0" skipped="1">
|
|
3
|
-
<testsuite name="teambit.component/snapping@1.0.
|
|
3
|
+
<testsuite name="teambit.component/snapping@1.0.512" tests="13" failures="0" errors="0" skipped="1">
|
|
4
4
|
<testcase classname="dist/message-per-component.spec.js" name="should throw an error when the file has no changes" time="0.002"/>
|
|
5
5
|
<testcase classname="dist/message-per-component.spec.js" name="should assign the default message to the component if empty"/>
|
|
6
6
|
<testcase classname="dist/message-per-component.spec.js" name="should support multiple lines per id"/>
|
|
7
7
|
<testcase classname="dist/message-per-component.spec.js" name="should support multiple lines for the default message"/>
|
|
8
|
-
<testcase classname="dist/snapping.spec.js" name="tag should throw an ComponentsHaveIssues error" time="0.
|
|
8
|
+
<testcase classname="dist/snapping.spec.js" name="tag should throw an ComponentsHaveIssues error" time="0.581"/>
|
|
9
9
|
<testcase classname="dist/snapping.spec.js" name="should not throw an error if the config was set to ignore MissingPackagesDependenciesOnFs error">
|
|
10
10
|
<skipped/>
|
|
11
11
|
</testcase>
|
|
12
12
|
<testcase classname="dist/snapping.spec.js" name="should add the new dev dep" time="0.001"/>
|
|
13
13
|
<testcase classname="dist/snapping.spec.js" name="should remove the specified dependency" time="0.001"/>
|
|
14
14
|
<testcase classname="dist/snapping.spec.js" name="should be able to list it"/>
|
|
15
|
-
<testcase classname="dist/snapping.spec.js" name="should be ignored by tag command" time="1.
|
|
16
|
-
<testcase classname="dist/snapping.spec.js" name="should be ignored by snap command" time="
|
|
17
|
-
<testcase classname="dist/snapping.spec.js" name="should be ignored when it is an auto-tag candidate" time="6.
|
|
18
|
-
<testcase classname="dist/snapping.spec.js" name="should block setting local-only when a component is staged" time="
|
|
15
|
+
<testcase classname="dist/snapping.spec.js" name="should be ignored by tag command" time="1.341"/>
|
|
16
|
+
<testcase classname="dist/snapping.spec.js" name="should be ignored by snap command" time="3.895"/>
|
|
17
|
+
<testcase classname="dist/snapping.spec.js" name="should be ignored when it is an auto-tag candidate" time="6.472"/>
|
|
18
|
+
<testcase classname="dist/snapping.spec.js" name="should block setting local-only when a component is staged" time="3.665"/>
|
|
19
19
|
</testsuite>
|
|
20
20
|
</testsuites>
|
|
@@ -2,7 +2,7 @@ import { Graph } from '@teambit/graph.cleargraph';
|
|
|
2
2
|
import { DepEdgeType } from '@teambit/graph';
|
|
3
3
|
import { ScopeMain } from '@teambit/scope';
|
|
4
4
|
import { ConsumerComponent } from '@teambit/legacy.consumer-component';
|
|
5
|
-
import { Lane } from '@teambit/
|
|
5
|
+
import { Lane } from '@teambit/objects';
|
|
6
6
|
import { ComponentID } from '@teambit/component-id';
|
|
7
7
|
import { Logger } from '@teambit/logger';
|
|
8
8
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graph","data","require","_componentId","_toolboxPromise","_bitError","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FlattenedEdgesGetter","constructor","scope","consumerComponents","logger","lane","Graph","buildGraph","debug","buildTheFirstLevel","populateMissingFromGraph","missingFromGraph","length","graph","addPreviousGraphs","importMissingAndAddToGraph","addComponentsWithMissingFlattenedEdges","populateFlattenedAndEdgesForComp","component","graphFromIds","successorsSubgraph","id","toString","edgesFromGraph","edges","map","edge","source","ComponentID","fromString","sourceId","target","targetId","type","attr","flattenedFromGraphIncludeItself","nodes","node","flattenedFromGraph","filter","isEqual","forEach","dep","throwWhenDepNotIncluded","flattenedDependencies","ComponentIdList","fromArray","flattenedEdges","idsWithoutGraphList","legacyScope","scopeImporter","importWithoutDeps","cache","componentsAndVersions","getComponentsAndVersions","missingEdges","Promise","all","version","versionStr","getFlattenedEdges","objects","push","toComponentId","changeVersion","addFlattenedEdgesToGraph","flattenedDeps","pMapPool","comp","previousVersion","previouslyUsedVersion","modelComponent","getModelComponent","undefined","loadVersion","concurrency","flattenedDepsUniq","uniqFromArray","flat","has","warn","join","missingEdgesList","results","importMany","ids","preferDependencyGraph","allFlattened","result","allFlattenedUniq","compId","setNode","Node","addEdges","dependencies","devDependencies","extensionDependencies","setEdge","Edge","allIds","currentlySnappedIds","filteredIds","label","get","exports","componentId","dependencyId","hasScope","hasVersion","BitError"],"sources":["flattened-edges.ts"],"sourcesContent":["import { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { DepEdgeType } from '@teambit/graph';\nimport { ScopeMain } from '@teambit/scope';\nimport { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { DepEdge, Lane } from '@teambit/scope.objects';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport { Logger } from '@teambit/logger';\nimport { pMapPool } from '@teambit/toolbox.promise.map-pool';\nimport { BitError } from '@teambit/bit-error';\n\n/**\n * the goal of this class is to determine the graph dependencies of a given set of components with minimal effort.\n * it takes advantage of the fact that we save the dependency graph in the `Version` object and tries to reuse it.\n *\n * to optimize it as much as possible, we do it in 4 steps. each step we check whether the graph has missing ids,\n * and if so, continue to the next step.\n *\n * * * First step * * *\n * we have two groups in this graph.\n * 1. components that are now versioned (this.consumerComponents). they have the new version (which is not in the scope yet).\n * 2. component that are not part of the current snap/tag.\n * it's not possible that this group has new components that never been into the scope, otherwise the tag/snap is failing.\n * so we know we can always find the version-object of these components in the scope or import them.\n *\n * given the above. we can simply get the first level of dependencies of the first group.\n * start the graph by adding them all as nodes and edges.\n *\n * this dependencies array may contain components from the first group. we can filter them out. (we don't care about\n * them, they're part of the graph already)\n * we're left with the dependencies that are part of the second group. there are the `missingFromGraph`.\n *\n * * * Second step * * *\n * instead of import these components, we can more efficiently get their previous version from the scope.\n * it must be already in the scope because these are the components we load in the first place.\n * chances are that 99% of the dependencies of the current components objects are identical to the previous version.\n * by adding the flattenedEdges of the previous versions we can probably finish the graph without importing a single\n * component. It's ok that this graph of previous versions has ids that are not relevant to this graph. for example, if\n * we now tag bar@0.0.2, this graph will have bar@0.0.1 although it's not relevant. it's ok, because finally we don't\n * use this graph as a whole. we only pick a component and get its sub-graph, so all irrelevant ids are ignored.\n *\n * * * Third step * * *\n * in case the graph above wasn't enough. we can import the missing components and get their flattenedEdges.\n * all components that were snapped/tagged since around 0.0.8000 have the flattenedEdges saved in the version.\n * older components don't have them and that's why the last step is needed.\n *\n * * * Fourth step * * *\n * this is the worst scenario. we have some old dependencies without flattenedEdges, we have to import them with\n * all their flattened dependencies.\n * once we have all these objects we can iterate them and add them to the graph.\n */\nexport class FlattenedEdgesGetter {\n private graph = new Graph<ComponentID, DepEdgeType>();\n private missingFromGraph: ComponentID[] = [];\n constructor(\n private scope: ScopeMain,\n private consumerComponents: ConsumerComponent[],\n private logger: Logger,\n private lane?: Lane\n ) {}\n\n async buildGraph() {\n this.logger.debug('FlattenedEdgesGetter, start');\n this.buildTheFirstLevel();\n this.populateMissingFromGraph();\n if (!this.missingFromGraph.length) {\n return this.graph;\n }\n this.logger.debug(\n `FlattenedEdgesGetter, total ${this.missingFromGraph.length} components missing from graph, trying to find them in previous versions`\n );\n await this.addPreviousGraphs();\n if (!this.missingFromGraph.length) {\n this.logger.debug(`FlattenedEdgesGetter, all missing ids were found in previous versions`);\n return this.graph;\n }\n this.logger.debug(\n `FlattenedEdgesGetter, total ${this.missingFromGraph.length} components missing from graph, trying to import them and load their flattenedEdges`\n );\n await this.importMissingAndAddToGraph();\n if (!this.missingFromGraph.length) {\n this.logger.debug(`FlattenedEdgesGetter, successfully found flattened edges for all components without graph`);\n return this.graph;\n }\n this.logger.debug(\n `FlattenedEdgesGetter, total ${this.missingFromGraph.length} components without graph and their version-objects has no flattened edges, no choice but to import all their flattened deps`\n );\n await this.addComponentsWithMissingFlattenedEdges();\n return this.graph;\n }\n\n populateFlattenedAndEdgesForComp(component: ConsumerComponent) {\n const graphFromIds = this.graph.successorsSubgraph(component.id.toString());\n const edgesFromGraph = graphFromIds.edges.map((edge) => {\n return {\n source: ComponentID.fromString(edge.sourceId),\n target: ComponentID.fromString(edge.targetId),\n type: edge.attr as DepEdgeType,\n };\n });\n\n const flattenedFromGraphIncludeItself = graphFromIds.nodes.map((node) => node.attr);\n const flattenedFromGraph = flattenedFromGraphIncludeItself.filter((id) => !id.isEqual(component.id));\n flattenedFromGraph.forEach((dep) => throwWhenDepNotIncluded(component.id, dep));\n\n component.flattenedDependencies = ComponentIdList.fromArray(flattenedFromGraph);\n component.flattenedEdges = edgesFromGraph;\n }\n\n private async importMissingAndAddToGraph() {\n const idsWithoutGraphList = ComponentIdList.fromArray(this.missingFromGraph);\n await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsWithoutGraphList, {\n cache: true,\n lane: this.lane,\n });\n const componentsAndVersions = await this.scope.legacyScope.getComponentsAndVersions(idsWithoutGraphList);\n const missingEdges: ComponentID[] = [];\n await Promise.all(\n componentsAndVersions.map(async ({ component, version, versionStr }) => {\n const flattenedEdges = await version.getFlattenedEdges(this.scope.legacyScope.objects);\n if (!flattenedEdges.length && version.flattenedDependencies.length) {\n missingEdges.push(component.toComponentId().changeVersion(versionStr));\n }\n this.addFlattenedEdgesToGraph(flattenedEdges);\n })\n );\n this.missingFromGraph = missingEdges;\n }\n\n private async addPreviousGraphs() {\n const flattenedDeps: ComponentID[][] = [];\n await pMapPool(\n this.consumerComponents,\n async (comp) => {\n const previousVersion = comp.previouslyUsedVersion;\n if (!previousVersion) return;\n const modelComponent =\n comp.modelComponent || (await this.scope.legacyScope.getModelComponent(comp.id.changeVersion(undefined)));\n const version = await modelComponent.loadVersion(previousVersion, this.scope.legacyScope.objects, true);\n const flattenedEdges = await version.getFlattenedEdges(this.scope.legacyScope.objects);\n if (flattenedEdges.length) flattenedDeps.push(version.flattenedDependencies);\n this.addFlattenedEdgesToGraph(flattenedEdges);\n },\n { concurrency: 50 }\n );\n\n const flattenedDepsUniq = ComponentIdList.uniqFromArray(flattenedDeps.flat());\n this.missingFromGraph = this.missingFromGraph.filter((id) => !flattenedDepsUniq.has(id));\n }\n\n private async addComponentsWithMissingFlattenedEdges() {\n const missingEdges = this.missingFromGraph;\n this.logger.warn(`FlattenedEdgesGetter, found ${missingEdges.length} components with missing flattened edges:\n${missingEdges.map((e) => e.toString()).join('\\n')}`);\n const missingEdgesList = ComponentIdList.fromArray(missingEdges);\n const results = await this.scope.legacyScope.scopeImporter.importMany({\n ids: missingEdgesList,\n cache: true,\n lane: this.lane,\n preferDependencyGraph: false, // we know it does not have a dependency graph\n });\n const allFlattened = results.map((result) => result.version.flattenedDependencies);\n allFlattened.push(missingEdgesList);\n const allFlattenedUniq = ComponentIdList.uniqFromArray(allFlattened.flat());\n const componentsAndVersions = await this.scope.legacyScope.getComponentsAndVersions(\n ComponentIdList.fromArray(allFlattenedUniq)\n );\n componentsAndVersions.forEach(({ component, version, versionStr }) => {\n const compId = component.toComponentId().changeVersion(versionStr);\n this.graph.setNode(new Node(compId.toString(), compId));\n this.addEdges(compId, version.dependencies, 'prod');\n this.addEdges(compId, version.devDependencies, 'dev');\n this.addEdges(compId, version.extensionDependencies, 'ext');\n });\n }\n\n private addFlattenedEdgesToGraph(flattenedEdges: DepEdge[]) {\n flattenedEdges.forEach(({ source, target, type }) => {\n this.graph.setNode(new Node(source.toString(), source));\n this.graph.setNode(new Node(target.toString(), target));\n this.graph.setEdge(new Edge(source.toString(), target.toString(), type));\n });\n }\n\n private populateMissingFromGraph() {\n const allIds = this.graph.nodes.map((node) => node.attr);\n const currentlySnappedIds = ComponentIdList.fromArray(this.consumerComponents.map((comp) => comp.id));\n const filteredIds = allIds.filter((id) => !currentlySnappedIds.has(id));\n this.missingFromGraph = filteredIds;\n }\n\n private buildTheFirstLevel() {\n this.consumerComponents.forEach((comp) => {\n const id = comp.id;\n this.graph.setNode(new Node(id.toString(), id));\n this.addEdges(comp.id, comp.dependencies, 'prod');\n this.addEdges(comp.id, comp.devDependencies, 'dev');\n this.addEdges(comp.id, comp.extensionDependencies, 'ext');\n });\n }\n\n private addEdges(compId: ComponentID, dependencies: ConsumerComponent['dependencies'], label: DepEdgeType) {\n dependencies.get().forEach((dep) => {\n this.graph.setNode(new Node(dep.id.toString(), dep.id));\n this.graph.setEdge(new Edge(compId.toString(), dep.id.toString(), label));\n });\n }\n}\n\nfunction throwWhenDepNotIncluded(componentId: ComponentID, dependencyId: ComponentID) {\n if (!dependencyId.hasScope() && !dependencyId.hasVersion()) {\n throw new BitError(`fatal: \"${componentId.toString()}\" has a dependency \"${dependencyId.toString()}\".\nthis dependency was not included in the tag command.`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,gBAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,eAAA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QA,CAACH,MAAmB,EAAEI,YAA+C,EAAEQ,KAAkB,EAAE;IACzGR,YAAY,CAACS,GAAG,CAAC,CAAC,CAAC9D,OAAO,CAAEC,GAAG,IAAK;MAClC,IAAI,CAAC7B,KAAK,CAAC8E,OAAO,CAAC,KAAIC,aAAI,EAAClD,GAAG,CAACrB,EAAE,CAACC,QAAQ,CAAC,CAAC,EAAEoB,GAAG,CAACrB,EAAE,CAAC,CAAC;MACvD,IAAI,CAACR,KAAK,CAACoF,OAAO,CAAC,KAAIC,aAAI,EAACR,MAAM,CAACpE,QAAQ,CAAC,CAAC,EAAEoB,GAAG,CAACrB,EAAE,CAACC,QAAQ,CAAC,CAAC,EAAEgF,KAAK,CAAC,CAAC;IAC3E,CAAC,CAAC;EACJ;AACF;AAACE,OAAA,CAAAxG,oBAAA,GAAAA,oBAAA;AAED,SAAS2C,uBAAuBA,CAAC8D,WAAwB,EAAEC,YAAyB,EAAE;EACpF,IAAI,CAACA,YAAY,CAACC,QAAQ,CAAC,CAAC,IAAI,CAACD,YAAY,CAACE,UAAU,CAAC,CAAC,EAAE;IAC1D,MAAM,KAAIC,oBAAQ,EAAC,WAAWJ,WAAW,CAACnF,QAAQ,CAAC,CAAC,uBAAuBoF,YAAY,CAACpF,QAAQ,CAAC,CAAC;AACtG,qDAAqD,CAAC;EACpD;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_graph","data","require","_componentId","_toolboxPromise","_bitError","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","FlattenedEdgesGetter","constructor","scope","consumerComponents","logger","lane","Graph","buildGraph","debug","buildTheFirstLevel","populateMissingFromGraph","missingFromGraph","length","graph","addPreviousGraphs","importMissingAndAddToGraph","addComponentsWithMissingFlattenedEdges","populateFlattenedAndEdgesForComp","component","graphFromIds","successorsSubgraph","id","toString","edgesFromGraph","edges","map","edge","source","ComponentID","fromString","sourceId","target","targetId","type","attr","flattenedFromGraphIncludeItself","nodes","node","flattenedFromGraph","filter","isEqual","forEach","dep","throwWhenDepNotIncluded","flattenedDependencies","ComponentIdList","fromArray","flattenedEdges","idsWithoutGraphList","legacyScope","scopeImporter","importWithoutDeps","cache","componentsAndVersions","getComponentsAndVersions","missingEdges","Promise","all","version","versionStr","getFlattenedEdges","objects","push","toComponentId","changeVersion","addFlattenedEdgesToGraph","flattenedDeps","pMapPool","comp","previousVersion","previouslyUsedVersion","modelComponent","getModelComponent","undefined","loadVersion","concurrency","flattenedDepsUniq","uniqFromArray","flat","has","warn","join","missingEdgesList","results","importMany","ids","preferDependencyGraph","allFlattened","result","allFlattenedUniq","compId","setNode","Node","addEdges","dependencies","devDependencies","extensionDependencies","setEdge","Edge","allIds","currentlySnappedIds","filteredIds","label","get","exports","componentId","dependencyId","hasScope","hasVersion","BitError"],"sources":["flattened-edges.ts"],"sourcesContent":["import { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { DepEdgeType } from '@teambit/graph';\nimport { ScopeMain } from '@teambit/scope';\nimport { ConsumerComponent } from '@teambit/legacy.consumer-component';\nimport { DepEdge, Lane } from '@teambit/objects';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport { Logger } from '@teambit/logger';\nimport { pMapPool } from '@teambit/toolbox.promise.map-pool';\nimport { BitError } from '@teambit/bit-error';\n\n/**\n * the goal of this class is to determine the graph dependencies of a given set of components with minimal effort.\n * it takes advantage of the fact that we save the dependency graph in the `Version` object and tries to reuse it.\n *\n * to optimize it as much as possible, we do it in 4 steps. each step we check whether the graph has missing ids,\n * and if so, continue to the next step.\n *\n * * * First step * * *\n * we have two groups in this graph.\n * 1. components that are now versioned (this.consumerComponents). they have the new version (which is not in the scope yet).\n * 2. component that are not part of the current snap/tag.\n * it's not possible that this group has new components that never been into the scope, otherwise the tag/snap is failing.\n * so we know we can always find the version-object of these components in the scope or import them.\n *\n * given the above. we can simply get the first level of dependencies of the first group.\n * start the graph by adding them all as nodes and edges.\n *\n * this dependencies array may contain components from the first group. we can filter them out. (we don't care about\n * them, they're part of the graph already)\n * we're left with the dependencies that are part of the second group. there are the `missingFromGraph`.\n *\n * * * Second step * * *\n * instead of import these components, we can more efficiently get their previous version from the scope.\n * it must be already in the scope because these are the components we load in the first place.\n * chances are that 99% of the dependencies of the current components objects are identical to the previous version.\n * by adding the flattenedEdges of the previous versions we can probably finish the graph without importing a single\n * component. It's ok that this graph of previous versions has ids that are not relevant to this graph. for example, if\n * we now tag bar@0.0.2, this graph will have bar@0.0.1 although it's not relevant. it's ok, because finally we don't\n * use this graph as a whole. we only pick a component and get its sub-graph, so all irrelevant ids are ignored.\n *\n * * * Third step * * *\n * in case the graph above wasn't enough. we can import the missing components and get their flattenedEdges.\n * all components that were snapped/tagged since around 0.0.8000 have the flattenedEdges saved in the version.\n * older components don't have them and that's why the last step is needed.\n *\n * * * Fourth step * * *\n * this is the worst scenario. we have some old dependencies without flattenedEdges, we have to import them with\n * all their flattened dependencies.\n * once we have all these objects we can iterate them and add them to the graph.\n */\nexport class FlattenedEdgesGetter {\n private graph = new Graph<ComponentID, DepEdgeType>();\n private missingFromGraph: ComponentID[] = [];\n constructor(\n private scope: ScopeMain,\n private consumerComponents: ConsumerComponent[],\n private logger: Logger,\n private lane?: Lane\n ) {}\n\n async buildGraph() {\n this.logger.debug('FlattenedEdgesGetter, start');\n this.buildTheFirstLevel();\n this.populateMissingFromGraph();\n if (!this.missingFromGraph.length) {\n return this.graph;\n }\n this.logger.debug(\n `FlattenedEdgesGetter, total ${this.missingFromGraph.length} components missing from graph, trying to find them in previous versions`\n );\n await this.addPreviousGraphs();\n if (!this.missingFromGraph.length) {\n this.logger.debug(`FlattenedEdgesGetter, all missing ids were found in previous versions`);\n return this.graph;\n }\n this.logger.debug(\n `FlattenedEdgesGetter, total ${this.missingFromGraph.length} components missing from graph, trying to import them and load their flattenedEdges`\n );\n await this.importMissingAndAddToGraph();\n if (!this.missingFromGraph.length) {\n this.logger.debug(`FlattenedEdgesGetter, successfully found flattened edges for all components without graph`);\n return this.graph;\n }\n this.logger.debug(\n `FlattenedEdgesGetter, total ${this.missingFromGraph.length} components without graph and their version-objects has no flattened edges, no choice but to import all their flattened deps`\n );\n await this.addComponentsWithMissingFlattenedEdges();\n return this.graph;\n }\n\n populateFlattenedAndEdgesForComp(component: ConsumerComponent) {\n const graphFromIds = this.graph.successorsSubgraph(component.id.toString());\n const edgesFromGraph = graphFromIds.edges.map((edge) => {\n return {\n source: ComponentID.fromString(edge.sourceId),\n target: ComponentID.fromString(edge.targetId),\n type: edge.attr as DepEdgeType,\n };\n });\n\n const flattenedFromGraphIncludeItself = graphFromIds.nodes.map((node) => node.attr);\n const flattenedFromGraph = flattenedFromGraphIncludeItself.filter((id) => !id.isEqual(component.id));\n flattenedFromGraph.forEach((dep) => throwWhenDepNotIncluded(component.id, dep));\n\n component.flattenedDependencies = ComponentIdList.fromArray(flattenedFromGraph);\n component.flattenedEdges = edgesFromGraph;\n }\n\n private async importMissingAndAddToGraph() {\n const idsWithoutGraphList = ComponentIdList.fromArray(this.missingFromGraph);\n await this.scope.legacyScope.scopeImporter.importWithoutDeps(idsWithoutGraphList, {\n cache: true,\n lane: this.lane,\n });\n const componentsAndVersions = await this.scope.legacyScope.getComponentsAndVersions(idsWithoutGraphList);\n const missingEdges: ComponentID[] = [];\n await Promise.all(\n componentsAndVersions.map(async ({ component, version, versionStr }) => {\n const flattenedEdges = await version.getFlattenedEdges(this.scope.legacyScope.objects);\n if (!flattenedEdges.length && version.flattenedDependencies.length) {\n missingEdges.push(component.toComponentId().changeVersion(versionStr));\n }\n this.addFlattenedEdgesToGraph(flattenedEdges);\n })\n );\n this.missingFromGraph = missingEdges;\n }\n\n private async addPreviousGraphs() {\n const flattenedDeps: ComponentID[][] = [];\n await pMapPool(\n this.consumerComponents,\n async (comp) => {\n const previousVersion = comp.previouslyUsedVersion;\n if (!previousVersion) return;\n const modelComponent =\n comp.modelComponent || (await this.scope.legacyScope.getModelComponent(comp.id.changeVersion(undefined)));\n const version = await modelComponent.loadVersion(previousVersion, this.scope.legacyScope.objects, true);\n const flattenedEdges = await version.getFlattenedEdges(this.scope.legacyScope.objects);\n if (flattenedEdges.length) flattenedDeps.push(version.flattenedDependencies);\n this.addFlattenedEdgesToGraph(flattenedEdges);\n },\n { concurrency: 50 }\n );\n\n const flattenedDepsUniq = ComponentIdList.uniqFromArray(flattenedDeps.flat());\n this.missingFromGraph = this.missingFromGraph.filter((id) => !flattenedDepsUniq.has(id));\n }\n\n private async addComponentsWithMissingFlattenedEdges() {\n const missingEdges = this.missingFromGraph;\n this.logger.warn(`FlattenedEdgesGetter, found ${missingEdges.length} components with missing flattened edges:\n${missingEdges.map((e) => e.toString()).join('\\n')}`);\n const missingEdgesList = ComponentIdList.fromArray(missingEdges);\n const results = await this.scope.legacyScope.scopeImporter.importMany({\n ids: missingEdgesList,\n cache: true,\n lane: this.lane,\n preferDependencyGraph: false, // we know it does not have a dependency graph\n });\n const allFlattened = results.map((result) => result.version.flattenedDependencies);\n allFlattened.push(missingEdgesList);\n const allFlattenedUniq = ComponentIdList.uniqFromArray(allFlattened.flat());\n const componentsAndVersions = await this.scope.legacyScope.getComponentsAndVersions(\n ComponentIdList.fromArray(allFlattenedUniq)\n );\n componentsAndVersions.forEach(({ component, version, versionStr }) => {\n const compId = component.toComponentId().changeVersion(versionStr);\n this.graph.setNode(new Node(compId.toString(), compId));\n this.addEdges(compId, version.dependencies, 'prod');\n this.addEdges(compId, version.devDependencies, 'dev');\n this.addEdges(compId, version.extensionDependencies, 'ext');\n });\n }\n\n private addFlattenedEdgesToGraph(flattenedEdges: DepEdge[]) {\n flattenedEdges.forEach(({ source, target, type }) => {\n this.graph.setNode(new Node(source.toString(), source));\n this.graph.setNode(new Node(target.toString(), target));\n this.graph.setEdge(new Edge(source.toString(), target.toString(), type));\n });\n }\n\n private populateMissingFromGraph() {\n const allIds = this.graph.nodes.map((node) => node.attr);\n const currentlySnappedIds = ComponentIdList.fromArray(this.consumerComponents.map((comp) => comp.id));\n const filteredIds = allIds.filter((id) => !currentlySnappedIds.has(id));\n this.missingFromGraph = filteredIds;\n }\n\n private buildTheFirstLevel() {\n this.consumerComponents.forEach((comp) => {\n const id = comp.id;\n this.graph.setNode(new Node(id.toString(), id));\n this.addEdges(comp.id, comp.dependencies, 'prod');\n this.addEdges(comp.id, comp.devDependencies, 'dev');\n this.addEdges(comp.id, comp.extensionDependencies, 'ext');\n });\n }\n\n private addEdges(compId: ComponentID, dependencies: ConsumerComponent['dependencies'], label: DepEdgeType) {\n dependencies.get().forEach((dep) => {\n this.graph.setNode(new Node(dep.id.toString(), dep.id));\n this.graph.setEdge(new Edge(compId.toString(), dep.id.toString(), label));\n });\n }\n}\n\nfunction throwWhenDepNotIncluded(componentId: ComponentID, dependencyId: ComponentID) {\n if (!dependencyId.hasScope() && !dependencyId.hasVersion()) {\n throw new BitError(`fatal: \"${componentId.toString()}\" has a dependency \"${dependencyId.toString()}\".\nthis dependency was not included in the tag command.`);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,gBAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,eAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAK,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAA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B,EAAE,CAAC,CAAC;MACvD,IAAI,CAACR,KAAK,CAACoF,OAAO,CAAC,KAAIC,aAAI,EAACR,MAAM,CAACpE,QAAQ,CAAC,CAAC,EAAEoB,GAAG,CAACrB,EAAE,CAACC,QAAQ,CAAC,CAAC,EAAEgF,KAAK,CAAC,CAAC;IAC3E,CAAC,CAAC;EACJ;AACF;AAACE,OAAA,CAAAxG,oBAAA,GAAAA,oBAAA;AAED,SAAS2C,uBAAuBA,CAAC8D,WAAwB,EAAEC,YAAyB,EAAE;EACpF,IAAI,CAACA,YAAY,CAACC,QAAQ,CAAC,CAAC,IAAI,CAACD,YAAY,CAACE,UAAU,CAAC,CAAC,EAAE;IAC1D,MAAM,KAAIC,oBAAQ,EAAC,WAAWJ,WAAW,CAACnF,QAAQ,CAAC,CAAC,uBAAuBoF,YAAY,CAACpF,QAAQ,CAAC,CAAC;AACtG,qDAAqD,CAAC;EACpD;AACF","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Scope } from '@teambit/legacy.scope';
|
|
2
2
|
import { ConsumerComponent as Component } from '@teambit/legacy.consumer-component';
|
|
3
|
-
import { Lane } from '@teambit/
|
|
3
|
+
import { Lane } from '@teambit/objects';
|
|
4
4
|
export declare class FlattenedDependenciesGetter {
|
|
5
5
|
private scope;
|
|
6
6
|
private components;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphlib","data","_interopRequireWildcard","require","_pMapSeries","_interopRequireDefault","_bitError","_componentId","_legacy","_lodash","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","FlattenedDependenciesGetter","constructor","scope","components","lane","populateFlattenedDependencies","logger","debug","length","dependenciesGraph","buildComponentsGraphCombined","importExternalDependenciesInBulk","mapSeries","component","flattenedDependencies","getFlattened","componentId","allDependencies","map","getEdges","id","toString","idsStr","compact","uniq","flat","bitIds","idStr","node","filter","bitId","find","c","isEqual","scopeComponentsImporter","scopeImporter","versionDependencies","importMany","ids","ComponentIdList","fromArray","preferDependencyGraph","cache","throwForDependencyNotFound","reason","dependencies","getFlattenedFromCurrentComponents","forEach","dep","throwWhenDepNotIncluded","dependenciesDeps","getFlattenedFromVersion","dependenciesDepsFlattened","dependenciesDepsUniq","uniqFromArray","push","allDeps","dependentId","versionDeps","toComponentId","objects","existing","hasVersion","Error","fromModel","getVersionInstance","exports","dependencyId","hasScope","BitError","graph","hasNode","edges","graphlib","alg","preorder","tail","GraphLib","_setGraphEdges","devDependencies","extensionDependencies","label","dependency","depId","setNode","setEdge"],"sources":["get-flattened-dependencies.ts"],"sourcesContent":["import graphlib, { Graph as GraphLib } from 'graphlib';\nimport mapSeries from 'p-map-series';\nimport { BitError } from '@teambit/bit-error';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport { BitIdStr } from '@teambit/legacy-bit-id';\nimport { VersionDependencies, Scope } from '@teambit/legacy.scope';\nimport { ConsumerComponent as Component, Dependencies } from '@teambit/legacy.consumer-component';\nimport { logger } from '@teambit/legacy.logger';\nimport { Lane } from '@teambit/scope.objects';\nimport { compact, tail, uniq } from 'lodash';\n\nexport class FlattenedDependenciesGetter {\n private dependenciesGraph: GraphLib;\n private versionDependencies: VersionDependencies[];\n private cache: { [idStr: string]: ComponentIdList } = {};\n constructor(\n private scope: Scope,\n private components: Component[],\n private lane?: Lane\n ) {}\n\n /**\n * to get the flattened dependencies of a component, we iterate over the direct dependencies and\n * figure out what should be the flattened of each one of the dependencies.\n * a dependency can be one of the two scenarios and should be handled accordingly.\n * 1. a dependency can be tagged/snapped along with the current component.\n * 2. a dependency can be a component that was already tagged before.\n * there is no option #3 of a component that exists on the workspace but wasn't tagged and is not\n * part of the current tag. In such case, we throw an error, see throwWhenDepNotIncluded below.\n *\n * the flattened dependencies process handles the two cases above differently.\n * 1. first, it builds a graph with all current components, this way it's easier to get the\n * flattened dependencies by graph algorithm. (without graph, it becomes difficult when there are\n * circular dependencies).\n * 2. for other components, it loads them from the model and gets the flattened from the objects.\n */\n async populateFlattenedDependencies() {\n logger.debug(`populateFlattenedDependencies starts with ${this.components.length} components`);\n this.dependenciesGraph = buildComponentsGraphCombined(this.components);\n // console.log(\"this.dependenciesGraph\", this.dependenciesGraph.toString())\n await this.importExternalDependenciesInBulk();\n await mapSeries(this.components, async (component) => {\n component.flattenedDependencies = await this.getFlattened(component.componentId);\n });\n }\n\n private async importExternalDependenciesInBulk() {\n const allDependencies = this.components.map((component) => {\n return getEdges(this.dependenciesGraph, component.id.toString());\n });\n const idsStr: string[] = compact(uniq(allDependencies.flat()));\n const bitIds = idsStr\n .map((idStr) => this.dependenciesGraph.node(idStr))\n .filter((bitId) => !this.components.find((c) => c.id.isEqual(bitId)));\n const scopeComponentsImporter = this.scope.scopeImporter;\n this.versionDependencies = await scopeComponentsImporter.importMany({\n ids: ComponentIdList.fromArray(bitIds),\n preferDependencyGraph: false,\n cache: true,\n throwForDependencyNotFound: true,\n lane: this.lane,\n reason: 'for fetching all dependencies',\n });\n }\n\n private async getFlattened(bitId: ComponentID): Promise<ComponentIdList> {\n const dependencies = this.getFlattenedFromCurrentComponents(bitId);\n dependencies.forEach((dep) => throwWhenDepNotIncluded(bitId, dep));\n const dependenciesDeps = await mapSeries(dependencies, (dep) => this.getFlattenedFromVersion(dep, bitId));\n const dependenciesDepsFlattened = dependenciesDeps.flat();\n // this dependenciesDepsFlattened can be huge, don't use spread operator (...) here. otherwise, it throws\n // `Maximum call stack size exceeded`. it's important to first make them uniq\n // (from a real example, before uniq: 133,068. after uniq: 2,126)\n const dependenciesDepsUniq = ComponentIdList.uniqFromArray(dependenciesDepsFlattened);\n dependencies.push(...dependenciesDepsUniq);\n return ComponentIdList.uniqFromArray(dependencies);\n }\n\n private getFlattenedFromCurrentComponents(bitId: ComponentID): ComponentID[] {\n const allDeps = getEdges(this.dependenciesGraph, bitId.toString()) || [];\n const dependencies = allDeps.map((idStr) => this.dependenciesGraph.node(idStr));\n return dependencies;\n }\n\n private async getFlattenedFromVersion(id: ComponentID, dependentId: ComponentID): Promise<ComponentIdList> {\n if (!this.cache[id.toString()]) {\n const versionDeps = this.versionDependencies.find(({ component }) => component.toComponentId().isEqual(id));\n if (versionDeps) {\n const dependencies = await versionDeps.component.flattenedDependencies(this.scope.objects);\n this.cache[id.toString()] = dependencies;\n } else {\n const existing = this.components.find((c) => c.id.isEqual(id));\n if (existing) {\n this.cache[id.toString()] = new ComponentIdList();\n } else {\n if (!id.hasVersion()) {\n throw new Error(`error found while getting the dependencies of \"${dependentId.toString()}\". A dependency \"${id.toString()}\" doesn't have a version\nif this is an external env/extension/aspect configured in workspace.jsonc, make sure it is set with a version`);\n }\n const fromModel = await this.scope.getVersionInstance(id);\n this.cache[id.toString()] = fromModel.flattenedDependencies;\n }\n }\n }\n return this.cache[id.toString()];\n }\n}\n\nfunction throwWhenDepNotIncluded(componentId: ComponentID, dependencyId: ComponentID) {\n if (!dependencyId.hasScope() && !dependencyId.hasVersion()) {\n throw new BitError(`fatal: \"${componentId.toString()}\" has a dependency \"${dependencyId.toString()}\".\nthis dependency was not included in the tag command.`);\n }\n}\n\n/**\n * get all successors edges recursively (flatten)\n */\nfunction getEdges(graph: GraphLib, id: BitIdStr): BitIdStr[] | null {\n if (!graph.hasNode(id)) return null;\n // @ts-ignore\n const edges = graphlib.alg.preorder(graph, id);\n return tail(edges); // the first item is the component itself\n}\n\n/**\n * one graph of the given components. it doesn't fetch/load anything. it builds the graph with the\n * given data. the node is a ComponentID and the edge has the label of the dependency type. it can be\n * either \"dependencies\" or \"devDependencies\".\n */\nfunction buildComponentsGraphCombined(components: Component[]): GraphLib {\n const graph = new GraphLib();\n components.forEach((component) => {\n _setGraphEdges(component.id, component.dependencies, graph);\n _setGraphEdges(component.id, component.devDependencies, graph, 'devDependencies');\n _setGraphEdges(component.id, component.extensionDependencies, graph, 'devDependencies');\n });\n return graph;\n}\n\nfunction _setGraphEdges(bitId: ComponentID, dependencies: Dependencies, graph: GraphLib, label = 'dependencies') {\n const id = bitId.toString();\n dependencies.get().forEach((dependency) => {\n const depId = dependency.id.toString();\n // save the full ComponentID of a string id to be able to retrieve it later with no confusion\n if (!graph.hasNode(id)) graph.setNode(id, bitId);\n if (!graph.hasNode(depId)) graph.setNode(depId, dependency.id);\n graph.setEdge(id, depId, label);\n });\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAO,QAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,OAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAQ,QAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,OAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA6C,SAAAI,uBAAAK,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,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AAC,EAAEb,KAAK,CAACc,OAAO,CAACD,KAAK,EAAED,UAAU,CAAC9D,EAAE,CAAC;IAC9DkD,KAAK,CAACe,OAAO,CAACjE,EAAE,EAAE+D,KAAK,EAAEF,KAAK,CAAC;EACjC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_graphlib","data","_interopRequireWildcard","require","_pMapSeries","_interopRequireDefault","_bitError","_componentId","_legacy","_lodash","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_defineProperty","_toPropertyKey","value","enumerable","configurable","writable","_toPrimitive","Symbol","toPrimitive","TypeError","String","Number","FlattenedDependenciesGetter","constructor","scope","components","lane","populateFlattenedDependencies","logger","debug","length","dependenciesGraph","buildComponentsGraphCombined","importExternalDependenciesInBulk","mapSeries","component","flattenedDependencies","getFlattened","componentId","allDependencies","map","getEdges","id","toString","idsStr","compact","uniq","flat","bitIds","idStr","node","filter","bitId","find","c","isEqual","scopeComponentsImporter","scopeImporter","versionDependencies","importMany","ids","ComponentIdList","fromArray","preferDependencyGraph","cache","throwForDependencyNotFound","reason","dependencies","getFlattenedFromCurrentComponents","forEach","dep","throwWhenDepNotIncluded","dependenciesDeps","getFlattenedFromVersion","dependenciesDepsFlattened","dependenciesDepsUniq","uniqFromArray","push","allDeps","dependentId","versionDeps","toComponentId","objects","existing","hasVersion","Error","fromModel","getVersionInstance","exports","dependencyId","hasScope","BitError","graph","hasNode","edges","graphlib","alg","preorder","tail","GraphLib","_setGraphEdges","devDependencies","extensionDependencies","label","dependency","depId","setNode","setEdge"],"sources":["get-flattened-dependencies.ts"],"sourcesContent":["import graphlib, { Graph as GraphLib } from 'graphlib';\nimport mapSeries from 'p-map-series';\nimport { BitError } from '@teambit/bit-error';\nimport { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport { BitIdStr } from '@teambit/legacy-bit-id';\nimport { VersionDependencies, Scope } from '@teambit/legacy.scope';\nimport { ConsumerComponent as Component, Dependencies } from '@teambit/legacy.consumer-component';\nimport { logger } from '@teambit/legacy.logger';\nimport { Lane } from '@teambit/objects';\nimport { compact, tail, uniq } from 'lodash';\n\nexport class FlattenedDependenciesGetter {\n private dependenciesGraph: GraphLib;\n private versionDependencies: VersionDependencies[];\n private cache: { [idStr: string]: ComponentIdList } = {};\n constructor(\n private scope: Scope,\n private components: Component[],\n private lane?: Lane\n ) {}\n\n /**\n * to get the flattened dependencies of a component, we iterate over the direct dependencies and\n * figure out what should be the flattened of each one of the dependencies.\n * a dependency can be one of the two scenarios and should be handled accordingly.\n * 1. a dependency can be tagged/snapped along with the current component.\n * 2. a dependency can be a component that was already tagged before.\n * there is no option #3 of a component that exists on the workspace but wasn't tagged and is not\n * part of the current tag. In such case, we throw an error, see throwWhenDepNotIncluded below.\n *\n * the flattened dependencies process handles the two cases above differently.\n * 1. first, it builds a graph with all current components, this way it's easier to get the\n * flattened dependencies by graph algorithm. (without graph, it becomes difficult when there are\n * circular dependencies).\n * 2. for other components, it loads them from the model and gets the flattened from the objects.\n */\n async populateFlattenedDependencies() {\n logger.debug(`populateFlattenedDependencies starts with ${this.components.length} components`);\n this.dependenciesGraph = buildComponentsGraphCombined(this.components);\n // console.log(\"this.dependenciesGraph\", this.dependenciesGraph.toString())\n await this.importExternalDependenciesInBulk();\n await mapSeries(this.components, async (component) => {\n component.flattenedDependencies = await this.getFlattened(component.componentId);\n });\n }\n\n private async importExternalDependenciesInBulk() {\n const allDependencies = this.components.map((component) => {\n return getEdges(this.dependenciesGraph, component.id.toString());\n });\n const idsStr: string[] = compact(uniq(allDependencies.flat()));\n const bitIds = idsStr\n .map((idStr) => this.dependenciesGraph.node(idStr))\n .filter((bitId) => !this.components.find((c) => c.id.isEqual(bitId)));\n const scopeComponentsImporter = this.scope.scopeImporter;\n this.versionDependencies = await scopeComponentsImporter.importMany({\n ids: ComponentIdList.fromArray(bitIds),\n preferDependencyGraph: false,\n cache: true,\n throwForDependencyNotFound: true,\n lane: this.lane,\n reason: 'for fetching all dependencies',\n });\n }\n\n private async getFlattened(bitId: ComponentID): Promise<ComponentIdList> {\n const dependencies = this.getFlattenedFromCurrentComponents(bitId);\n dependencies.forEach((dep) => throwWhenDepNotIncluded(bitId, dep));\n const dependenciesDeps = await mapSeries(dependencies, (dep) => this.getFlattenedFromVersion(dep, bitId));\n const dependenciesDepsFlattened = dependenciesDeps.flat();\n // this dependenciesDepsFlattened can be huge, don't use spread operator (...) here. otherwise, it throws\n // `Maximum call stack size exceeded`. it's important to first make them uniq\n // (from a real example, before uniq: 133,068. after uniq: 2,126)\n const dependenciesDepsUniq = ComponentIdList.uniqFromArray(dependenciesDepsFlattened);\n dependencies.push(...dependenciesDepsUniq);\n return ComponentIdList.uniqFromArray(dependencies);\n }\n\n private getFlattenedFromCurrentComponents(bitId: ComponentID): ComponentID[] {\n const allDeps = getEdges(this.dependenciesGraph, bitId.toString()) || [];\n const dependencies = allDeps.map((idStr) => this.dependenciesGraph.node(idStr));\n return dependencies;\n }\n\n private async getFlattenedFromVersion(id: ComponentID, dependentId: ComponentID): Promise<ComponentIdList> {\n if (!this.cache[id.toString()]) {\n const versionDeps = this.versionDependencies.find(({ component }) => component.toComponentId().isEqual(id));\n if (versionDeps) {\n const dependencies = await versionDeps.component.flattenedDependencies(this.scope.objects);\n this.cache[id.toString()] = dependencies;\n } else {\n const existing = this.components.find((c) => c.id.isEqual(id));\n if (existing) {\n this.cache[id.toString()] = new ComponentIdList();\n } else {\n if (!id.hasVersion()) {\n throw new Error(`error found while getting the dependencies of \"${dependentId.toString()}\". A dependency \"${id.toString()}\" doesn't have a version\nif this is an external env/extension/aspect configured in workspace.jsonc, make sure it is set with a version`);\n }\n const fromModel = await this.scope.getVersionInstance(id);\n this.cache[id.toString()] = fromModel.flattenedDependencies;\n }\n }\n }\n return this.cache[id.toString()];\n }\n}\n\nfunction throwWhenDepNotIncluded(componentId: ComponentID, dependencyId: ComponentID) {\n if (!dependencyId.hasScope() && !dependencyId.hasVersion()) {\n throw new BitError(`fatal: \"${componentId.toString()}\" has a dependency \"${dependencyId.toString()}\".\nthis dependency was not included in the tag command.`);\n }\n}\n\n/**\n * get all successors edges recursively (flatten)\n */\nfunction getEdges(graph: GraphLib, id: BitIdStr): BitIdStr[] | null {\n if (!graph.hasNode(id)) return null;\n // @ts-ignore\n const edges = graphlib.alg.preorder(graph, id);\n return tail(edges); // the first item is the component itself\n}\n\n/**\n * one graph of the given components. it doesn't fetch/load anything. it builds the graph with the\n * given data. the node is a ComponentID and the edge has the label of the dependency type. it can be\n * either \"dependencies\" or \"devDependencies\".\n */\nfunction buildComponentsGraphCombined(components: Component[]): GraphLib {\n const graph = new GraphLib();\n components.forEach((component) => {\n _setGraphEdges(component.id, component.dependencies, graph);\n _setGraphEdges(component.id, component.devDependencies, graph, 'devDependencies');\n _setGraphEdges(component.id, component.extensionDependencies, graph, 'devDependencies');\n });\n return graph;\n}\n\nfunction _setGraphEdges(bitId: ComponentID, dependencies: Dependencies, graph: GraphLib, label = 'dependencies') {\n const id = bitId.toString();\n dependencies.get().forEach((dependency) => {\n const depId = dependency.id.toString();\n // save the full ComponentID of a string id to be able to retrieve it later with no confusion\n if (!graph.hasNode(id)) graph.setNode(id, bitId);\n if (!graph.hasNode(depId)) graph.setNode(depId, dependency.id);\n graph.setEdge(id, depId, label);\n });\n}\n"],"mappings":";;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,uBAAA,CAAAC,OAAA;EAAAH,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,YAAA;EAAA,MAAAH,IAAA,GAAAI,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,SAAA,YAA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ACmE,qBAAqB,EAAEV,KAAK,EAAE,iBAAiB,CAAC;EACzF,CAAC,CAAC;EACF,OAAOA,KAAK;AACd;AAEA,SAASQ,cAAcA,CAAChD,KAAkB,EAAEe,YAA0B,EAAEyB,KAAe,EAAEW,KAAK,GAAG,cAAc,EAAE;EAC/G,MAAM7D,EAAE,GAAGU,KAAK,CAACT,QAAQ,CAAC,CAAC;EAC3BwB,YAAY,CAACrE,GAAG,CAAC,CAAC,CAACuE,OAAO,CAAEmC,UAAU,IAAK;IACzC,MAAMC,KAAK,GAAGD,UAAU,CAAC9D,EAAE,CAACC,QAAQ,CAAC,CAAC;IACtC;IACA,IAAI,CAACiD,KAAK,CAACC,OAAO,CAACnD,EAAE,CAAC,EAAEkD,KAAK,CAACc,OAAO,CAAChE,EAAE,EAAEU,KAAK,CAAC;IAChD,IAAI,CAACwC,KAAK,CAACC,OAAO,CAACY,KAAK,CAAC,EAAEb,KAAK,CAACc,OAAO,CAACD,KAAK,EAAED,UAAU,CAAC9D,EAAE,CAAC;IAC9DkD,KAAK,CAACe,OAAO,CAACjE,EAAE,EAAE+D,KAAK,EAAEF,KAAK,CAAC;EACjC,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentID } from '@teambit/component-id';
|
|
2
2
|
import { Consumer } from '@teambit/legacy.consumer';
|
|
3
|
-
import { Lane, ModelComponent } from '@teambit/
|
|
3
|
+
import { Lane, ModelComponent } from '@teambit/objects';
|
|
4
4
|
import { RemoveMain } from '@teambit/remove';
|
|
5
5
|
import { Workspace } from '@teambit/workspace';
|
|
6
6
|
export type ResetResult = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_bitError","data","require","_legacy","_legacy2","_legacy3","removeLocalVersion","consumer","id","lane","head","force","component","scope","getModelComponent","idStr","toString","fromBitmap","bitMap","getComponentIdIfExist","localVersions","getLocalHashes","objects","length","BitError","headRef","getHeadRegardlessOfLane","Error","find","v","isEqual","versionsToRemove","versionsToRemoveStr","switchHashesWithTagsIfExist","dependencyGraph","DependencyGraph","loadAllVersions","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","headBefore","getHead","sources","removeComponentVersions","headAfter","versionToSetInBitmap","divergeData","getDivergeData","snapBeforeDetached","commonSnapBeforeDiverge","getTagOfRefIfExists","versions","removeLocalVersionsForAllComponents","workspace","remove","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","map","bitId","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","Promise","all","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents","removedStagedIds","getRemovedStaged","removedStagedBitIds","nonExistsInStaged","c","isEqualWithoutVersion","modelComps","push"],"sources":["reset-component.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport { Lane, ModelComponent } from '@teambit/scope.objects';\nimport { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\nimport { Workspace } from '@teambit/workspace';\n\nexport type ResetResult = {\n id: ComponentID;\n versions: string[];\n component?: ModelComponent;\n /**\n * relevant when the component was detached head so the head didn't change.\n * we want .bitmap to have the version before the detachment. not as the head.\n */\n versionToSetInBitmap?: string;\n};\n\n/**\n * If head is false, remove all local versions.\n */\nexport async function removeLocalVersion(\n consumer: Consumer,\n id: ComponentID,\n lane?: Lane,\n head?: boolean,\n force = false\n): Promise<ResetResult> {\n const component: ModelComponent = await consumer.scope.getModelComponent(id);\n const idStr = id.toString();\n const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);\n const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap);\n if (!localVersions.length) throw new BitError(`unable to untag ${idStr}, the component is not staged`);\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef) {\n throw new Error(`unable to reset ${idStr}, it has not head`);\n }\n if (head && !localVersions.find((v) => v.isEqual(headRef))) {\n throw new Error(`unable to reset ${idStr}, the head ${headRef.toString()} is exported`);\n }\n const versionsToRemove = head ? [headRef] : localVersions;\n const versionsToRemoveStr = component.switchHashesWithTagsIfExist(versionsToRemove);\n\n if (!force) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n\n versionsToRemoveStr.forEach((versionToRemove) => {\n const idWithVersion = component.toComponentId().changeVersion(versionToRemove);\n const dependents = dependencyGraph.getImmediateDependentsPerId(idWithVersion);\n if (dependents.length) {\n throw new BitError(\n `unable to reset ${idStr}, the version ${versionToRemove} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n\n const headBefore = component.getHead();\n await consumer.scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);\n const headAfter = component.getHead();\n let versionToSetInBitmap;\n if (headBefore && headAfter && headBefore.isEqual(headAfter) && !lane) {\n // if it's on main and the head didn't change, it means that it was in a detached-head state.\n const divergeData = component.getDivergeData();\n const snapBeforeDetached = divergeData.commonSnapBeforeDiverge;\n if (snapBeforeDetached) versionToSetInBitmap = component.getTagOfRefIfExists(snapBeforeDetached);\n }\n\n return { id, versions: versionsToRemoveStr, component, versionToSetInBitmap };\n}\n\nexport async function removeLocalVersionsForAllComponents(\n workspace: Workspace,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(workspace, remove);\n const force = true; // when removing local versions from all components, no need to check if the component is used as a dependency\n return removeLocalVersionsForMultipleComponents(workspace.consumer, componentsToUntag, lane, head, force);\n}\n\nexport async function removeLocalVersionsForMultipleComponents(\n consumer: Consumer,\n componentsToUntag: ModelComponent[],\n lane?: Lane,\n head?: boolean,\n force?: boolean\n) {\n if (!componentsToUntag.length) {\n throw new BitError(`no components found to reset on your workspace`);\n }\n // if only head is removed, there is risk of deleting dependencies version without their dependents.\n if (!force && head) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n const candidateComponentsIds = componentsToUntag.map((component) => {\n const bitId = component.toComponentId();\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef)\n throw new Error(`component ${bitId.toString()} does not have head. it should not be a candidate for reset`);\n\n return bitId.changeVersion(component.getTagOfRefIfExists(headRef) || headRef.toString());\n });\n const candidateComponentsIdsStr = candidateComponentsIds.map((id) => id.toString());\n candidateComponentsIds.forEach((bitId: ComponentID) => {\n const dependents = dependencyGraph.getImmediateDependentsPerId(bitId);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const dependentsNotCandidates = dependents.filter((dependent) => !candidateComponentsIdsStr.includes(dependent));\n if (dependentsNotCandidates.length) {\n throw new BitError( // $FlowFixMe\n `unable to untag ${bitId}, the version ${bitId.version} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n logger.debug(`found ${componentsToUntag.length} components to untag`);\n return Promise.all(\n componentsToUntag.map((component) => removeLocalVersion(consumer, component.toComponentId(), lane, head, force))\n );\n}\n\nexport async function getComponentsWithOptionToUntag(\n workspace: Workspace,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(workspace);\n const laneObj = await workspace.getCurrentLaneObject();\n const components: ModelComponent[] = await componentList.listExportPendingComponents(laneObj);\n const removedStagedIds = await remove.getRemovedStaged();\n if (!removedStagedIds.length) return components;\n const removedStagedBitIds = removedStagedIds.map((id) => id);\n const nonExistsInStaged = removedStagedBitIds.filter(\n (id) => !components.find((c) => c.toComponentId().isEqualWithoutVersion(id))\n );\n if (!nonExistsInStaged.length) return components;\n const modelComps = await Promise.all(nonExistsInStaged.map((id) => workspace.consumer.scope.getModelComponent(id)));\n components.push(...modelComps);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,UAAA;E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MAAMC,UAA4B,GAAG,MAAMJ,aAAa,CAACK,2BAA2B,CAACH,OAAO,CAAC;EAC7F,MAAMI,gBAAgB,GAAG,MAAMvB,MAAM,CAACwB,gBAAgB,CAAC,CAAC;EACxD,IAAI,CAACD,gBAAgB,CAAC3D,MAAM,EAAE,OAAOyD,UAAU;EAC/C,MAAMI,mBAAmB,GAAGF,gBAAgB,CAAClB,GAAG,CAAExD,EAAE,IAAKA,EAAE,CAAC;EAC5D,MAAM6E,iBAAiB,GAAGD,mBAAmB,CAAChB,MAAM,CACjD5D,EAAE,IAAK,CAACwE,UAAU,CAACpD,IAAI,CAAE0D,CAAC,IAAKA,CAAC,CAAC9C,aAAa,CAAC,CAAC,CAAC+C,qBAAqB,CAAC/E,EAAE,CAAC,CAC7E,CAAC;EACD,IAAI,CAAC6E,iBAAiB,CAAC9D,MAAM,EAAE,OAAOyD,UAAU;EAChD,MAAMQ,UAAU,GAAG,MAAMd,OAAO,CAACC,GAAG,CAACU,iBAAiB,CAACrB,GAAG,CAAExD,EAAE,IAAKkD,SAAS,CAACnD,QAAQ,CAACM,KAAK,CAACC,iBAAiB,CAACN,EAAE,CAAC,CAAC,CAAC;EACnHwE,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_bitError","data","require","_legacy","_legacy2","_legacy3","removeLocalVersion","consumer","id","lane","head","force","component","scope","getModelComponent","idStr","toString","fromBitmap","bitMap","getComponentIdIfExist","localVersions","getLocalHashes","objects","length","BitError","headRef","getHeadRegardlessOfLane","Error","find","v","isEqual","versionsToRemove","versionsToRemoveStr","switchHashesWithTagsIfExist","dependencyGraph","DependencyGraph","loadAllVersions","forEach","versionToRemove","idWithVersion","toComponentId","changeVersion","dependents","getImmediateDependentsPerId","join","headBefore","getHead","sources","removeComponentVersions","headAfter","versionToSetInBitmap","divergeData","getDivergeData","snapBeforeDetached","commonSnapBeforeDiverge","getTagOfRefIfExists","versions","removeLocalVersionsForAllComponents","workspace","remove","componentsToUntag","getComponentsWithOptionToUntag","removeLocalVersionsForMultipleComponents","candidateComponentsIds","map","bitId","candidateComponentsIdsStr","dependentsNotCandidates","filter","dependent","includes","version","logger","debug","Promise","all","componentList","ComponentsList","laneObj","getCurrentLaneObject","components","listExportPendingComponents","removedStagedIds","getRemovedStaged","removedStagedBitIds","nonExistsInStaged","c","isEqualWithoutVersion","modelComps","push"],"sources":["reset-component.ts"],"sourcesContent":["import { BitError } from '@teambit/bit-error';\nimport { ComponentID } from '@teambit/component-id';\nimport { Consumer } from '@teambit/legacy.consumer';\nimport { ComponentsList } from '@teambit/legacy.component-list';\nimport { logger } from '@teambit/legacy.logger';\nimport { Lane, ModelComponent } from '@teambit/objects';\nimport { RemoveMain } from '@teambit/remove';\nimport { DependencyGraph } from '@teambit/legacy.dependency-graph';\nimport { Workspace } from '@teambit/workspace';\n\nexport type ResetResult = {\n id: ComponentID;\n versions: string[];\n component?: ModelComponent;\n /**\n * relevant when the component was detached head so the head didn't change.\n * we want .bitmap to have the version before the detachment. not as the head.\n */\n versionToSetInBitmap?: string;\n};\n\n/**\n * If head is false, remove all local versions.\n */\nexport async function removeLocalVersion(\n consumer: Consumer,\n id: ComponentID,\n lane?: Lane,\n head?: boolean,\n force = false\n): Promise<ResetResult> {\n const component: ModelComponent = await consumer.scope.getModelComponent(id);\n const idStr = id.toString();\n const fromBitmap = consumer.bitMap.getComponentIdIfExist(id);\n const localVersions = await component.getLocalHashes(consumer.scope.objects, fromBitmap);\n if (!localVersions.length) throw new BitError(`unable to untag ${idStr}, the component is not staged`);\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef) {\n throw new Error(`unable to reset ${idStr}, it has not head`);\n }\n if (head && !localVersions.find((v) => v.isEqual(headRef))) {\n throw new Error(`unable to reset ${idStr}, the head ${headRef.toString()} is exported`);\n }\n const versionsToRemove = head ? [headRef] : localVersions;\n const versionsToRemoveStr = component.switchHashesWithTagsIfExist(versionsToRemove);\n\n if (!force) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n\n versionsToRemoveStr.forEach((versionToRemove) => {\n const idWithVersion = component.toComponentId().changeVersion(versionToRemove);\n const dependents = dependencyGraph.getImmediateDependentsPerId(idWithVersion);\n if (dependents.length) {\n throw new BitError(\n `unable to reset ${idStr}, the version ${versionToRemove} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n\n const headBefore = component.getHead();\n await consumer.scope.sources.removeComponentVersions(component, versionsToRemove, versionsToRemoveStr, lane, head);\n const headAfter = component.getHead();\n let versionToSetInBitmap;\n if (headBefore && headAfter && headBefore.isEqual(headAfter) && !lane) {\n // if it's on main and the head didn't change, it means that it was in a detached-head state.\n const divergeData = component.getDivergeData();\n const snapBeforeDetached = divergeData.commonSnapBeforeDiverge;\n if (snapBeforeDetached) versionToSetInBitmap = component.getTagOfRefIfExists(snapBeforeDetached);\n }\n\n return { id, versions: versionsToRemoveStr, component, versionToSetInBitmap };\n}\n\nexport async function removeLocalVersionsForAllComponents(\n workspace: Workspace,\n remove: RemoveMain,\n lane?: Lane,\n head?: boolean\n): Promise<ResetResult[]> {\n const componentsToUntag = await getComponentsWithOptionToUntag(workspace, remove);\n const force = true; // when removing local versions from all components, no need to check if the component is used as a dependency\n return removeLocalVersionsForMultipleComponents(workspace.consumer, componentsToUntag, lane, head, force);\n}\n\nexport async function removeLocalVersionsForMultipleComponents(\n consumer: Consumer,\n componentsToUntag: ModelComponent[],\n lane?: Lane,\n head?: boolean,\n force?: boolean\n) {\n if (!componentsToUntag.length) {\n throw new BitError(`no components found to reset on your workspace`);\n }\n // if only head is removed, there is risk of deleting dependencies version without their dependents.\n if (!force && head) {\n const dependencyGraph = await DependencyGraph.loadAllVersions(consumer.scope);\n const candidateComponentsIds = componentsToUntag.map((component) => {\n const bitId = component.toComponentId();\n const headRef = component.getHeadRegardlessOfLane();\n if (!headRef)\n throw new Error(`component ${bitId.toString()} does not have head. it should not be a candidate for reset`);\n\n return bitId.changeVersion(component.getTagOfRefIfExists(headRef) || headRef.toString());\n });\n const candidateComponentsIdsStr = candidateComponentsIds.map((id) => id.toString());\n candidateComponentsIds.forEach((bitId: ComponentID) => {\n const dependents = dependencyGraph.getImmediateDependentsPerId(bitId);\n // @ts-ignore AUTO-ADDED-AFTER-MIGRATION-PLEASE-FIX!\n const dependentsNotCandidates = dependents.filter((dependent) => !candidateComponentsIdsStr.includes(dependent));\n if (dependentsNotCandidates.length) {\n throw new BitError( // $FlowFixMe\n `unable to untag ${bitId}, the version ${bitId.version} has the following dependent(s) ${dependents.join(\n ', '\n )}`\n );\n }\n });\n }\n logger.debug(`found ${componentsToUntag.length} components to untag`);\n return Promise.all(\n componentsToUntag.map((component) => removeLocalVersion(consumer, component.toComponentId(), lane, head, force))\n );\n}\n\nexport async function getComponentsWithOptionToUntag(\n workspace: Workspace,\n remove: RemoveMain\n): Promise<ModelComponent[]> {\n const componentList = new ComponentsList(workspace);\n const laneObj = await workspace.getCurrentLaneObject();\n const components: ModelComponent[] = await componentList.listExportPendingComponents(laneObj);\n const removedStagedIds = await remove.getRemovedStaged();\n if (!removedStagedIds.length) return components;\n const removedStagedBitIds = removedStagedIds.map((id) => id);\n const nonExistsInStaged = removedStagedBitIds.filter(\n (id) => !components.find((c) => c.toComponentId().isEqualWithoutVersion(id))\n );\n if (!nonExistsInStaged.length) return components;\n const modelComps = await Promise.all(nonExistsInStaged.map((id) => workspace.consumer.scope.getModelComponent(id)));\n components.push(...modelComps);\n\n return components;\n}\n"],"mappings":";;;;;;;;;AAAA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IA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F,gBAAgB,CAAClB,GAAG,CAAExD,EAAE,IAAKA,EAAE,CAAC;EAC5D,MAAM6E,iBAAiB,GAAGD,mBAAmB,CAAChB,MAAM,CACjD5D,EAAE,IAAK,CAACwE,UAAU,CAACpD,IAAI,CAAE0D,CAAC,IAAKA,CAAC,CAAC9C,aAAa,CAAC,CAAC,CAAC+C,qBAAqB,CAAC/E,EAAE,CAAC,CAC7E,CAAC;EACD,IAAI,CAAC6E,iBAAiB,CAAC9D,MAAM,EAAE,OAAOyD,UAAU;EAChD,MAAMQ,UAAU,GAAG,MAAMd,OAAO,CAACC,GAAG,CAACU,iBAAiB,CAACrB,GAAG,CAAExD,EAAE,IAAKkD,SAAS,CAACnD,QAAQ,CAACM,KAAK,CAACC,iBAAiB,CAACN,EAAE,CAAC,CAAC,CAAC;EACnHwE,UAAU,CAACS,IAAI,CAAC,GAAGD,UAAU,CAAC;EAE9B,OAAOR,UAAU;AACnB","ignoreList":[]}
|
|
@@ -8,7 +8,7 @@ import { Logger, LoggerMain } from '@teambit/logger';
|
|
|
8
8
|
import { ConsumerComponent } from '@teambit/legacy.consumer-component';
|
|
9
9
|
import { InsightsMain } from '@teambit/insights';
|
|
10
10
|
import { ScopeMain } from '@teambit/scope';
|
|
11
|
-
import { BitObject, Lane, ModelComponent, Version, Log, AddVersionOpts } from '@teambit/
|
|
11
|
+
import { BitObject, Lane, ModelComponent, Version, Log, AddVersionOpts } from '@teambit/objects';
|
|
12
12
|
import { IssuesMain } from '@teambit/issues';
|
|
13
13
|
import { Component } from '@teambit/component';
|
|
14
14
|
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
@@ -144,9 +144,9 @@ function _scope() {
|
|
|
144
144
|
};
|
|
145
145
|
return data;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
148
|
-
const data = require("@teambit/
|
|
149
|
-
|
|
147
|
+
function _objects() {
|
|
148
|
+
const data = require("@teambit/objects");
|
|
149
|
+
_objects = function () {
|
|
150
150
|
return data;
|
|
151
151
|
};
|
|
152
152
|
return data;
|
|
@@ -891,8 +891,8 @@ in case you're unsure about the pattern syntax, use "bit pattern [--help]"`);
|
|
|
891
891
|
}
|
|
892
892
|
async resetNeverExported() {
|
|
893
893
|
const notExported = this.workspace.consumer.getNotExportedIds();
|
|
894
|
-
const hashes = notExported.map(id =>
|
|
895
|
-
await this.scope.legacyScope.objects.deleteObjectsFromFS(hashes.map(h =>
|
|
894
|
+
const hashes = notExported.map(id => _objects().BitObject.makeHash(id.fullName));
|
|
895
|
+
await this.scope.legacyScope.objects.deleteObjectsFromFS(hashes.map(h => _objects().Ref.from(h)));
|
|
896
896
|
notExported.map(id => this.workspace.consumer.bitMap.updateComponentId(id.changeVersion(undefined)));
|
|
897
897
|
await this.workspace.bitMap.write(`reset (never-exported)`);
|
|
898
898
|
return notExported;
|
|
@@ -1108,7 +1108,7 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1108
1108
|
}
|
|
1109
1109
|
if (unmergedComponent.unrelated === true) {
|
|
1110
1110
|
// backward compatibility
|
|
1111
|
-
const unrelatedHead =
|
|
1111
|
+
const unrelatedHead = _objects().Ref.from(source.previouslyUsedVersion);
|
|
1112
1112
|
version.setUnrelated({
|
|
1113
1113
|
head: unrelatedHead,
|
|
1114
1114
|
laneId: unmergedComponent.laneId
|
|
@@ -1209,7 +1209,7 @@ another option, in case this dependency is not in main yet is to remove all refe
|
|
|
1209
1209
|
version.extensions = consumerComponent.extensions;
|
|
1210
1210
|
version.buildStatus = consumerComponent.buildStatus;
|
|
1211
1211
|
const artifactObjects = artifacts.map(file => file.source);
|
|
1212
|
-
const dependenciesGraph =
|
|
1212
|
+
const dependenciesGraph = _objects().Version.dependenciesGraphToSource(consumerComponent.dependenciesGraph);
|
|
1213
1213
|
version.dependenciesGraphRef = dependenciesGraph ? dependenciesGraph.hash() : undefined;
|
|
1214
1214
|
const result = [version, ...artifactObjects];
|
|
1215
1215
|
if (dependenciesGraph) result.push(dependenciesGraph);
|