@teambit/workspace 1.0.173 → 1.0.174

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.
@@ -79,6 +79,8 @@ function lifecycleToDepType(compDep) {
79
79
  return 'dev';
80
80
  case 'runtime':
81
81
  return 'prod';
82
+ case 'peer':
83
+ return 'peer';
82
84
  default:
83
85
  throw new Error(`lifecycle ${compDep.lifecycle} is not support`);
84
86
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_graph","_lodash","_component","_componentId","_exceptions","_scope","_lodash2","_bitError","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","lifecycleToDepType","compDep","isExtension","lifecycle","Error","GraphIdsFromFsBuilder","constructor","workspace","logger","dependencyResolver","shouldThrowOnMissingDep","Graph","consumer","shouldThrowOnInvalidDeps","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","depth","importObjects","allDependencies","mapSeries","component","processOneComponent","allDependenciesFlattened","flatten","workspaceIds","listIds","compOnWorkspaceOnly","filter","comp","find","id","isEqual","notImported","map","c","importedIds","includes","toString","exportedDeps","dep","isExported","scopeComponentsImporter","scope","scopeImporter","importMany","ComponentIdList","uniqFromArray","throwForDependencyNotFound","throwForSeederNotFound","reFetchUnBuiltVersion","lane","getCurrentLaneObject","undefined","reason","push","idStr","completed","graphFromScope","getSavedGraphOfComponentIfExist","edges","isOnWorkspace","hasId","allDependenciesComps","processCompFromWorkspaceWithGraph","merge","deps","getComponentDependencies","allDepsIds","d","componentId","forEach","addDepEdge","depsInScopeGraph","depsNotInScopeGraph","partition","hasNode","depsInScopeGraphIds","depsInScopeGraphIdsNotCompleted","subGraphs","successorsSubgraph","depId","warn","setEdge","Edge","componentsIds","dependenciesOf","fromCache","loadedComponents","get","setNode","Node","err","ComponentNotFound","ComponentNotFoundInScope","ScopeNotFound","BitError","ConsumerComponent","isComponentInvalidByErrorType","message","error","compact","exports"],"sources":["build-graph-ids-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { flatten, partition } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { Component, ComponentID } from '@teambit/component';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { ComponentIdList } from '@teambit/component-id';\nimport { ComponentDependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { CompIdGraph, DepEdgeType } from '@teambit/graph';\nimport { ComponentNotFound, ScopeNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { ComponentNotFound as ComponentNotFoundInScope } from '@teambit/scope';\nimport compact from 'lodash.compact';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport function lifecycleToDepType(compDep: ComponentDependency): DepEdgeType {\n if (compDep.isExtension) return 'ext';\n switch (compDep.lifecycle) {\n case 'dev':\n return 'dev';\n case 'runtime':\n return 'prod';\n default:\n throw new Error(`lifecycle ${compDep.lifecycle} is not support`);\n }\n}\n\nexport class GraphIdsFromFsBuilder {\n private graph = new Graph<ComponentID, DepEdgeType>();\n private completed: string[] = [];\n private depth = 1;\n private consumer: Consumer;\n private loadedComponents: { [idStr: string]: Component } = {};\n private importedIds: string[] = [];\n private shouldThrowOnInvalidDeps = true; // for now it has the same value as shouldThrowOnMissingDep. change if needed\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private shouldThrowOnMissingDep = true\n ) {\n this.consumer = this.workspace.consumer;\n this.shouldThrowOnInvalidDeps = this.shouldThrowOnMissingDep;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are component-ids and the edges has a label of the dependency type.\n * to get some info about this the graph build take a look into build-graph-from-fs.buildGraph() docs.\n */\n async buildGraph(ids: ComponentID[]): Promise<Graph<ComponentID, DepEdgeType>> {\n this.logger.debug(`GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids);\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(\n `GraphIdsFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`\n );\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n /**\n * only for components from the workspace that can be modified to add/remove dependencies, we need to make sure that\n * all their dependencies are imported.\n * once a component from scope is imported, we know that either we have its dependency graph or all flattened deps\n */\n private async importObjects(components: Component[]) {\n const workspaceIds = await this.workspace.listIds();\n const compOnWorkspaceOnly = components.filter((comp) => workspaceIds.find((id) => id.isEqual(comp.id)));\n const notImported = compOnWorkspaceOnly.map((c) => c.id).filter((id) => !this.importedIds.includes(id.toString()));\n const exportedDeps = notImported.filter((dep) => this.workspace.isExported(dep));\n const scopeComponentsImporter = this.consumer.scope.scopeImporter;\n await scopeComponentsImporter.importMany({\n ids: ComponentIdList.uniqFromArray(exportedDeps),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n throwForSeederNotFound: this.shouldThrowOnMissingDep,\n reFetchUnBuiltVersion: false,\n lane: (await this.workspace.getCurrentLaneObject()) || undefined,\n reason: 'for building graph-ids from the workspace',\n });\n notImported.map((id) => this.importedIds.push(id.toString()));\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const graphFromScope = await this.workspace.getSavedGraphOfComponentIfExist(component);\n if (graphFromScope?.edges.length) {\n const isOnWorkspace = await this.workspace.hasId(component.id);\n if (isOnWorkspace) {\n const allDependenciesComps = await this.processCompFromWorkspaceWithGraph(graphFromScope, component);\n this.completed.push(idStr);\n return allDependenciesComps;\n }\n this.graph.merge([graphFromScope]);\n this.completed.push(idStr);\n return [];\n }\n\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const allDepsIds = deps.map((d) => d.componentId);\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n this.completed.push(idStr);\n\n return allDependenciesComps;\n }\n\n /**\n * this is tricky.\n * the component is in the workspace so it can be modified. dependencies can be added/removed/updated/downgraded.\n * we have the graph-dependencies from the last snap, so we prefer to use it whenever possible for performance reasons.\n * if we can't use it, we have to recursively load dependencies components and get the data from there.\n * to maximize the performance, we iterate the direct dependencies, if we find a dep with the same id in the graph,\n * and that id is not in the workspace then ask the graph for all its successors. otherwise, if it's not there, or\n * it's there but it's also in the workspace (which therefore can be modified), we recursively load the dep components\n * and get its dependencies.\n */\n private async processCompFromWorkspaceWithGraph(\n graphFromScope: CompIdGraph,\n component: Component\n ): Promise<Component[]> {\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const workspaceIds = await this.workspace.listIds();\n const [depsInScopeGraph, depsNotInScopeGraph] = partition(\n deps,\n (dep) =>\n graphFromScope.hasNode(dep.componentId.toString()) && !workspaceIds.find((id) => id.isEqual(dep.componentId))\n );\n\n const depsInScopeGraphIds = depsInScopeGraph.map((dep) => dep.componentId.toString());\n const depsInScopeGraphIdsNotCompleted = depsInScopeGraphIds.filter((id) => !this.completed.includes(id));\n if (depsInScopeGraphIdsNotCompleted.length) {\n const subGraphs = graphFromScope.successorsSubgraph(depsInScopeGraphIdsNotCompleted);\n this.graph.merge([subGraphs]);\n this.completed.push(...depsInScopeGraphIdsNotCompleted);\n }\n\n const allDepsIds = depsNotInScopeGraph.map((d) => d.componentId);\n const idStr = component.id.toString();\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n return allDependenciesComps;\n }\n\n private addDepEdge(idStr: string, dep: ComponentDependency) {\n const depId = dep.componentId;\n if (!this.graph.hasNode(depId.toString())) {\n if (this.shouldThrowOnMissingDep) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.logger.warn(`ignoring missing ${depId.toString()}`);\n return;\n }\n this.graph.setEdge(new Edge(idStr, depId.toString(), lifecycleToDepType(dep)));\n }\n\n private async loadManyComponents(componentsIds: ComponentID[], dependenciesOf?: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp) => {\n const idStr = comp.toString();\n const fromCache = this.loadedComponents[idStr];\n if (fromCache) return fromCache;\n try {\n const component = await this.workspace.get(comp);\n this.loadedComponents[idStr] = component;\n this.graph.setNode(new Node(idStr, component.id));\n return component;\n } catch (err: any) {\n if (\n err instanceof ComponentNotFound ||\n err instanceof ComponentNotFoundInScope ||\n err instanceof ScopeNotFound\n ) {\n if (dependenciesOf && !this.shouldThrowOnMissingDep) {\n this.logger.warn(\n `component ${idStr}, dependency of ${dependenciesOf} was not found. continuing without it`\n );\n return null;\n }\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${\n dependenciesOf || '<none>'\n }\" and is needed as part of the graph generation`\n );\n }\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n if (dependenciesOf && !this.shouldThrowOnInvalidDeps) {\n this.logger.warn(`component ${idStr}, dependency of ${dependenciesOf} is invalid. continuing without it`);\n return null;\n }\n throw new BitError(\n `error: component \"${idStr}\" is invalid (${err.message}).\\nthis component is a dependency of \"${\n dependenciesOf || '<none>'\n }\" and is needed as part of the graph generation`\n );\n }\n if (dependenciesOf) this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return compact(components);\n }\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAA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F,MAAMM,GAAG;MACX;IACF,CAAC,CAAC;IACF,OAAO,IAAAS,kBAAO,EAACxF,UAAU,CAAC;EAC5B;AACF;AAACyF,OAAA,CAAAzG,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_graph","_lodash","_component","_componentId","_exceptions","_scope","_lodash2","_bitError","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","lifecycleToDepType","compDep","isExtension","lifecycle","Error","GraphIdsFromFsBuilder","constructor","workspace","logger","dependencyResolver","shouldThrowOnMissingDep","Graph","consumer","shouldThrowOnInvalidDeps","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","depth","importObjects","allDependencies","mapSeries","component","processOneComponent","allDependenciesFlattened","flatten","workspaceIds","listIds","compOnWorkspaceOnly","filter","comp","find","id","isEqual","notImported","map","c","importedIds","includes","toString","exportedDeps","dep","isExported","scopeComponentsImporter","scope","scopeImporter","importMany","ComponentIdList","uniqFromArray","throwForDependencyNotFound","throwForSeederNotFound","reFetchUnBuiltVersion","lane","getCurrentLaneObject","undefined","reason","push","idStr","completed","graphFromScope","getSavedGraphOfComponentIfExist","edges","isOnWorkspace","hasId","allDependenciesComps","processCompFromWorkspaceWithGraph","merge","deps","getComponentDependencies","allDepsIds","d","componentId","forEach","addDepEdge","depsInScopeGraph","depsNotInScopeGraph","partition","hasNode","depsInScopeGraphIds","depsInScopeGraphIdsNotCompleted","subGraphs","successorsSubgraph","depId","warn","setEdge","Edge","componentsIds","dependenciesOf","fromCache","loadedComponents","get","setNode","Node","err","ComponentNotFound","ComponentNotFoundInScope","ScopeNotFound","BitError","ConsumerComponent","isComponentInvalidByErrorType","message","error","compact","exports"],"sources":["build-graph-ids-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { flatten, partition } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { Component, ComponentID } from '@teambit/component';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { ComponentIdList } from '@teambit/component-id';\nimport { ComponentDependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { CompIdGraph, DepEdgeType } from '@teambit/graph';\nimport { ComponentNotFound, ScopeNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { ComponentNotFound as ComponentNotFoundInScope } from '@teambit/scope';\nimport compact from 'lodash.compact';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport function lifecycleToDepType(compDep: ComponentDependency): DepEdgeType {\n if (compDep.isExtension) return 'ext';\n switch (compDep.lifecycle) {\n case 'dev':\n return 'dev';\n case 'runtime':\n return 'prod';\n case 'peer':\n return 'peer';\n default:\n throw new Error(`lifecycle ${compDep.lifecycle} is not support`);\n }\n}\n\nexport class GraphIdsFromFsBuilder {\n private graph = new Graph<ComponentID, DepEdgeType>();\n private completed: string[] = [];\n private depth = 1;\n private consumer: Consumer;\n private loadedComponents: { [idStr: string]: Component } = {};\n private importedIds: string[] = [];\n private shouldThrowOnInvalidDeps = true; // for now it has the same value as shouldThrowOnMissingDep. change if needed\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private shouldThrowOnMissingDep = true\n ) {\n this.consumer = this.workspace.consumer;\n this.shouldThrowOnInvalidDeps = this.shouldThrowOnMissingDep;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are component-ids and the edges has a label of the dependency type.\n * to get some info about this the graph build take a look into build-graph-from-fs.buildGraph() docs.\n */\n async buildGraph(ids: ComponentID[]): Promise<Graph<ComponentID, DepEdgeType>> {\n this.logger.debug(`GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids);\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(\n `GraphIdsFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`\n );\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n /**\n * only for components from the workspace that can be modified to add/remove dependencies, we need to make sure that\n * all their dependencies are imported.\n * once a component from scope is imported, we know that either we have its dependency graph or all flattened deps\n */\n private async importObjects(components: Component[]) {\n const workspaceIds = await this.workspace.listIds();\n const compOnWorkspaceOnly = components.filter((comp) => workspaceIds.find((id) => id.isEqual(comp.id)));\n const notImported = compOnWorkspaceOnly.map((c) => c.id).filter((id) => !this.importedIds.includes(id.toString()));\n const exportedDeps = notImported.filter((dep) => this.workspace.isExported(dep));\n const scopeComponentsImporter = this.consumer.scope.scopeImporter;\n await scopeComponentsImporter.importMany({\n ids: ComponentIdList.uniqFromArray(exportedDeps),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n throwForSeederNotFound: this.shouldThrowOnMissingDep,\n reFetchUnBuiltVersion: false,\n lane: (await this.workspace.getCurrentLaneObject()) || undefined,\n reason: 'for building graph-ids from the workspace',\n });\n notImported.map((id) => this.importedIds.push(id.toString()));\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const graphFromScope = await this.workspace.getSavedGraphOfComponentIfExist(component);\n if (graphFromScope?.edges.length) {\n const isOnWorkspace = await this.workspace.hasId(component.id);\n if (isOnWorkspace) {\n const allDependenciesComps = await this.processCompFromWorkspaceWithGraph(graphFromScope, component);\n this.completed.push(idStr);\n return allDependenciesComps;\n }\n this.graph.merge([graphFromScope]);\n this.completed.push(idStr);\n return [];\n }\n\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const allDepsIds = deps.map((d) => d.componentId);\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n this.completed.push(idStr);\n\n return allDependenciesComps;\n }\n\n /**\n * this is tricky.\n * the component is in the workspace so it can be modified. dependencies can be added/removed/updated/downgraded.\n * we have the graph-dependencies from the last snap, so we prefer to use it whenever possible for performance reasons.\n * if we can't use it, we have to recursively load dependencies components and get the data from there.\n * to maximize the performance, we iterate the direct dependencies, if we find a dep with the same id in the graph,\n * and that id is not in the workspace then ask the graph for all its successors. otherwise, if it's not there, or\n * it's there but it's also in the workspace (which therefore can be modified), we recursively load the dep components\n * and get its dependencies.\n */\n private async processCompFromWorkspaceWithGraph(\n graphFromScope: CompIdGraph,\n component: Component\n ): Promise<Component[]> {\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const workspaceIds = await this.workspace.listIds();\n const [depsInScopeGraph, depsNotInScopeGraph] = partition(\n deps,\n (dep) =>\n graphFromScope.hasNode(dep.componentId.toString()) && !workspaceIds.find((id) => id.isEqual(dep.componentId))\n );\n\n const depsInScopeGraphIds = depsInScopeGraph.map((dep) => dep.componentId.toString());\n const depsInScopeGraphIdsNotCompleted = depsInScopeGraphIds.filter((id) => !this.completed.includes(id));\n if (depsInScopeGraphIdsNotCompleted.length) {\n const subGraphs = graphFromScope.successorsSubgraph(depsInScopeGraphIdsNotCompleted);\n this.graph.merge([subGraphs]);\n this.completed.push(...depsInScopeGraphIdsNotCompleted);\n }\n\n const allDepsIds = depsNotInScopeGraph.map((d) => d.componentId);\n const idStr = component.id.toString();\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n return allDependenciesComps;\n }\n\n private addDepEdge(idStr: string, dep: ComponentDependency) {\n const depId = dep.componentId;\n if (!this.graph.hasNode(depId.toString())) {\n if (this.shouldThrowOnMissingDep) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.logger.warn(`ignoring missing ${depId.toString()}`);\n return;\n }\n this.graph.setEdge(new Edge(idStr, depId.toString(), lifecycleToDepType(dep)));\n }\n\n private async loadManyComponents(componentsIds: ComponentID[], dependenciesOf?: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp) => {\n const idStr = comp.toString();\n const fromCache = this.loadedComponents[idStr];\n if (fromCache) return fromCache;\n try {\n const component = await this.workspace.get(comp);\n this.loadedComponents[idStr] = component;\n this.graph.setNode(new Node(idStr, component.id));\n return component;\n } catch (err: any) {\n if (\n err instanceof ComponentNotFound ||\n err instanceof ComponentNotFoundInScope ||\n err instanceof ScopeNotFound\n ) {\n if (dependenciesOf && !this.shouldThrowOnMissingDep) {\n this.logger.warn(\n `component ${idStr}, dependency of ${dependenciesOf} was not found. continuing without it`\n );\n return null;\n }\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${\n dependenciesOf || '<none>'\n }\" and is needed as part of the graph generation`\n );\n }\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n if (dependenciesOf && !this.shouldThrowOnInvalidDeps) {\n this.logger.warn(`component ${idStr}, dependency of ${dependenciesOf} is invalid. continuing without it`);\n return null;\n }\n throw new BitError(\n `error: component \"${idStr}\" is invalid (${err.message}).\\nthis component is a dependency of \"${\n dependenciesOf || '<none>'\n }\" and is needed as part of the graph generation`\n );\n }\n if (dependenciesOf) this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return compact(components);\n }\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,MAAA,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AAA,CAAAzG,qBAAA,GAAAA,qBAAA"}
@@ -0,0 +1,7 @@
1
+ import * as compositions_0 from '/Users/giladshoham/Library/Caches/Bit/capsules/root/95c2f3515392701f327019ce43202e7563a02128/teambit.workspace_workspace@1.0.174/dist/workspace.composition.js';
2
+ import * as overview_0 from '/Users/giladshoham/Library/Caches/Bit/capsules/root/95c2f3515392701f327019ce43202e7563a02128/teambit.workspace_workspace@1.0.174/dist/workspace.docs.mdx';
3
+
4
+ export const compositions = [compositions_0];
5
+ export const overview = [overview_0];
6
+
7
+ export const compositions_metadata = {"compositions":[{"displayName":"Logo","identifier":"Logo"}]};
@@ -12,8 +12,8 @@ export declare class CompFiles {
12
12
  private repository;
13
13
  private currentFiles;
14
14
  readonly compDir: PathLinux;
15
- private headFiles;
16
- constructor(id: ComponentID, repository: Repository, currentFiles: SourceFile[], compDir: PathLinux, headFiles?: SourceFileModel[]);
15
+ private modelFiles;
16
+ constructor(id: ComponentID, repository: Repository, currentFiles: SourceFile[], compDir: PathLinux, modelFiles?: SourceFileModel[]);
17
17
  isModified(): boolean;
18
18
  getCurrentFiles(): SourceFile[];
19
19
  getHeadFiles(): Promise<SourceFile[]>;
@@ -14,18 +14,18 @@ function _sources() {
14
14
  // ts fails when importing it from @teambit/legacy/dist/utils/path.
15
15
 
16
16
  class CompFiles {
17
- constructor(id, repository, currentFiles, compDir, headFiles = []) {
17
+ constructor(id, repository, currentFiles, compDir, modelFiles = []) {
18
18
  this.id = id;
19
19
  this.repository = repository;
20
20
  this.currentFiles = currentFiles;
21
21
  this.compDir = compDir;
22
- this.headFiles = headFiles;
22
+ this.modelFiles = modelFiles;
23
23
  }
24
24
  isModified() {
25
- if (!this.headFiles.length) return false;
26
- if (this.currentFiles.length !== this.headFiles.length) return true;
25
+ if (!this.modelFiles.length) return false;
26
+ if (this.currentFiles.length !== this.modelFiles.length) return true;
27
27
  return this.currentFiles.some(file => {
28
- const headFile = this.headFiles.find(h => h.relativePath === file.relative);
28
+ const headFile = this.modelFiles.find(h => h.relativePath === file.relative);
29
29
  if (!headFile) return true;
30
30
  return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());
31
31
  });
@@ -34,11 +34,11 @@ class CompFiles {
34
34
  return this.currentFiles;
35
35
  }
36
36
  async getHeadFiles() {
37
- return Promise.all(this.headFiles.map(file => _sources().SourceFile.loadFromSourceFileModel(file, this.repository)));
37
+ return Promise.all(this.modelFiles.map(file => _sources().SourceFile.loadFromSourceFileModel(file, this.repository)));
38
38
  }
39
39
  getFilesStatus() {
40
40
  const result = this.currentFiles.reduce((acc, file) => {
41
- const headFile = this.headFiles.find(h => h.relativePath === file.relative);
41
+ const headFile = this.modelFiles.find(h => h.relativePath === file.relative);
42
42
  const getType = () => {
43
43
  if (!headFile) return 'new';
44
44
  if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';
@@ -47,7 +47,7 @@ class CompFiles {
47
47
  acc[file.relative] = getType();
48
48
  return acc;
49
49
  }, {});
50
- this.headFiles.forEach(headFile => {
50
+ this.modelFiles.forEach(headFile => {
51
51
  const currentFile = this.currentFiles.find(c => c.relative === headFile.relativePath);
52
52
  if (!currentFile) {
53
53
  result[headFile.relativePath] = 'deleted';
@@ -1 +1 @@
1
- {"version":3,"names":["_sources","data","require","CompFiles","constructor","id","repository","currentFiles","compDir","headFiles","isModified","length","some","file","headFile","find","h","relativePath","relative","isEqual","toSourceAsLinuxEOL","hash","getCurrentFiles","getHeadFiles","Promise","all","map","SourceFile","loadFromSourceFileModel","getFilesStatus","result","reduce","acc","getType","forEach","currentFile","c","exports"],"sources":["comp-files.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';\nimport { Repository } from '@teambit/legacy/dist/scope/objects';\n\ntype FILE_STATUS = 'new' | 'modified' | 'deleted' | 'unchanged';\ntype PathLinux = string; // ts fails when importing it from @teambit/legacy/dist/utils/path.\nexport type FilesStatus = { [pathRelativeToCompDir: PathLinux]: FILE_STATUS };\n\nexport class CompFiles {\n constructor(\n readonly id: ComponentID,\n private repository: Repository,\n private currentFiles: SourceFile[],\n readonly compDir: PathLinux,\n private headFiles: SourceFileModel[] = []\n ) {}\n\n isModified(): boolean {\n if (!this.headFiles.length) return false;\n if (this.currentFiles.length !== this.headFiles.length) return true;\n return this.currentFiles.some((file) => {\n const headFile = this.headFiles.find((h) => h.relativePath === file.relative);\n if (!headFile) return true;\n return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());\n });\n }\n\n getCurrentFiles(): SourceFile[] {\n return this.currentFiles;\n }\n\n async getHeadFiles(): Promise<SourceFile[]> {\n return Promise.all(this.headFiles.map((file) => SourceFile.loadFromSourceFileModel(file, this.repository)));\n }\n\n getFilesStatus(): FilesStatus {\n const result = this.currentFiles.reduce((acc, file) => {\n const headFile = this.headFiles.find((h) => h.relativePath === file.relative);\n const getType = (): FILE_STATUS => {\n if (!headFile) return 'new';\n if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';\n return 'modified';\n };\n acc[file.relative] = getType();\n return acc;\n }, {});\n this.headFiles.forEach((headFile) => {\n const currentFile = this.currentFiles.find((c) => c.relative === headFile.relativePath);\n if (!currentFile) {\n result[headFile.relativePath] = 'deleted';\n }\n });\n return result;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKyB;;AAGlB,MAAME,SAAS,CAAC;EACrBC,WAAWA,CACAC,EAAe,EAChBC,UAAsB,EACtBC,YAA0B,EACzBC,OAAkB,EACnBC,SAA4B,GAAG,EAAE,EACzC;IAAA,KALSJ,EAAe,GAAfA,EAAe;IAAA,KAChBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,YAA0B,GAA1BA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C,IAAI,CAACnB,QAAQ,EAAE,OAAO,KAAK;QAC3B,IAAIA,QAAQ,CAACD,IAAI,CAACM,OAAO,CAACN,IAAI,CAACO,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,WAAW;QAC/E,OAAO,UAAU;MACnB,CAAC;MACDW,GAAG,CAACnB,IAAI,CAACK,QAAQ,CAAC,GAAGe,OAAO,CAAC,CAAC;MAC9B,OAAOD,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;IACN,IAAI,CAACvB,SAAS,CAACyB,OAAO,CAAEpB,QAAQ,IAAK;MACnC,MAAMqB,WAAW,GAAG,IAAI,CAAC5B,YAAY,CAACQ,IAAI,CAAEqB,CAAC,IAAKA,CAAC,CAAClB,QAAQ,KAAKJ,QAAQ,CAACG,YAAY,CAAC;MACvF,IAAI,CAACkB,WAAW,EAAE;QAChBL,MAAM,CAAChB,QAAQ,CAACG,YAAY,CAAC,GAAG,SAAS;MAC3C;IACF,CAAC,CAAC;IACF,OAAOa,MAAM;EACf;AACF;AAACO,OAAA,CAAAlC,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_sources","data","require","CompFiles","constructor","id","repository","currentFiles","compDir","modelFiles","isModified","length","some","file","headFile","find","h","relativePath","relative","isEqual","toSourceAsLinuxEOL","hash","getCurrentFiles","getHeadFiles","Promise","all","map","SourceFile","loadFromSourceFileModel","getFilesStatus","result","reduce","acc","getType","forEach","currentFile","c","exports"],"sources":["comp-files.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { SourceFileModel } from '@teambit/legacy/dist/scope/models/version';\nimport { Repository } from '@teambit/legacy/dist/scope/objects';\n\ntype FILE_STATUS = 'new' | 'modified' | 'deleted' | 'unchanged';\ntype PathLinux = string; // ts fails when importing it from @teambit/legacy/dist/utils/path.\nexport type FilesStatus = { [pathRelativeToCompDir: PathLinux]: FILE_STATUS };\n\nexport class CompFiles {\n constructor(\n readonly id: ComponentID,\n private repository: Repository,\n private currentFiles: SourceFile[],\n readonly compDir: PathLinux,\n private modelFiles: SourceFileModel[] = []\n ) {}\n\n isModified(): boolean {\n if (!this.modelFiles.length) return false;\n if (this.currentFiles.length !== this.modelFiles.length) return true;\n return this.currentFiles.some((file) => {\n const headFile = this.modelFiles.find((h) => h.relativePath === file.relative);\n if (!headFile) return true;\n return !headFile.file.isEqual(file.toSourceAsLinuxEOL().hash());\n });\n }\n\n getCurrentFiles(): SourceFile[] {\n return this.currentFiles;\n }\n\n async getHeadFiles(): Promise<SourceFile[]> {\n return Promise.all(this.modelFiles.map((file) => SourceFile.loadFromSourceFileModel(file, this.repository)));\n }\n\n getFilesStatus(): FilesStatus {\n const result = this.currentFiles.reduce((acc, file) => {\n const headFile = this.modelFiles.find((h) => h.relativePath === file.relative);\n const getType = (): FILE_STATUS => {\n if (!headFile) return 'new';\n if (headFile.file.isEqual(file.toSourceAsLinuxEOL().hash())) return 'unchanged';\n return 'modified';\n };\n acc[file.relative] = getType();\n return acc;\n }, {});\n this.modelFiles.forEach((headFile) => {\n const currentFile = this.currentFiles.find((c) => c.relative === headFile.relativePath);\n if (!currentFile) {\n result[headFile.relativePath] = 'deleted';\n }\n });\n return result;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAKyB;;AAGlB,MAAME,SAAS,CAAC;EACrBC,WAAWA,CACAC,EAAe,EAChBC,UAAsB,EACtBC,YAA0B,EACzBC,OAAkB,EACnBC,UAA6B,GAAG,EAAE,EAC1C;IAAA,KALSJ,EAAe,GAAfA,EAAe;IAAA,KAChBC,UAAsB,GAAtBA,UAAsB;IAAA,KACtBC,YAA0B,GAA1BA,YAA0B;IAAA,KACzBC,OAAkB,GAAlBA,OAAkB;IAAA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AAIA,QAAQ,CAACD,IAAI,CAACM,OAAO,CAACN,IAAI,CAACO,kBAAkB,CAAC,CAAC,CAACC,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,WAAW;QAC/E,OAAO,UAAU;MACnB,CAAC;MACDW,GAAG,CAACnB,IAAI,CAACK,QAAQ,CAAC,GAAGe,OAAO,CAAC,CAAC;MAC9B,OAAOD,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAC;IACN,IAAI,CAACvB,UAAU,CAACyB,OAAO,CAAEpB,QAAQ,IAAK;MACpC,MAAMqB,WAAW,GAAG,IAAI,CAAC5B,YAAY,CAACQ,IAAI,CAAEqB,CAAC,IAAKA,CAAC,CAAClB,QAAQ,KAAKJ,QAAQ,CAACG,YAAY,CAAC;MACvF,IAAI,CAACkB,WAAW,EAAE;QAChBL,MAAM,CAAChB,QAAQ,CAACG,YAAY,CAAC,GAAG,SAAS;MAC3C;IACF,CAAC,CAAC;IACF,OAAOa,MAAM;EACf;AACF;AAACO,OAAA,CAAAlC,SAAA,GAAAA,SAAA"}
package/dist/workspace.js CHANGED
@@ -803,15 +803,14 @@ it's possible that the version ${component.id.version} belong to ${idStr.split('
803
803
  return _sources().SourceFile.load(filePath, compDirAbs, this.path, {});
804
804
  });
805
805
  const repo = this.scope.legacyScope.objects;
806
- const getHeadFiles = async () => {
806
+ const getModelFiles = async () => {
807
807
  const modelComp = await this.scope.legacyScope.getModelComponentIfExist(id);
808
808
  if (!modelComp) return [];
809
- const head = modelComp.getHeadRegardlessOfLane();
810
- if (!head) return [];
811
- const verObj = await modelComp.loadVersion(head.toString(), repo);
809
+ if (!bitMapEntry.id.hasVersion()) return [];
810
+ const verObj = await modelComp.loadVersion(bitMapEntry.id.version, repo);
812
811
  return verObj.files;
813
812
  };
814
- return new (_compFiles().CompFiles)(id, repo, sourceFilesVinyls, compDir, await getHeadFiles());
813
+ return new (_compFiles().CompFiles)(id, repo, sourceFilesVinyls, compDir, await getModelFiles());
815
814
  }
816
815
 
817
816
  /**