@teambit/workspace 1.0.107 → 1.0.109

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.
Files changed (68) hide show
  1. package/artifacts/preview/static/css/teambit.workspace/workspace-preview.115618a8.css +55 -0
  2. package/artifacts/preview/static/images/2f046646df38433e90d7.png +0 -0
  3. package/artifacts/preview/static/images/b40d450de296e275550f.png +0 -0
  4. package/artifacts/preview/static/images/cb67fb802479e2710016.png +0 -0
  5. package/artifacts/preview/teambit_workspace_workspace-preview.js +2 -0
  6. package/dist/aspects-merger.js +13 -22
  7. package/dist/aspects-merger.js.map +1 -1
  8. package/dist/bit-map.d.ts +1 -1
  9. package/dist/build-graph-from-fs.d.ts +2 -2
  10. package/dist/build-graph-from-fs.js +1 -2
  11. package/dist/build-graph-from-fs.js.map +1 -1
  12. package/dist/build-graph-ids-from-fs.js +1 -1
  13. package/dist/build-graph-ids-from-fs.js.map +1 -1
  14. package/dist/capsule.cmd.d.ts +2 -2
  15. package/dist/capsule.cmd.js +1 -2
  16. package/dist/capsule.cmd.js.map +1 -1
  17. package/dist/component-config-file/component-config-file.d.ts +2 -2
  18. package/dist/component-tree.widget.d.ts +2 -2
  19. package/dist/eject-conf.cmd.d.ts +2 -2
  20. package/dist/envs-subcommands/envs-replace.cmd.d.ts +1 -1
  21. package/dist/envs-subcommands/envs-set.cmd.d.ts +1 -1
  22. package/dist/envs-subcommands/envs-unset.cmd.d.ts +1 -1
  23. package/dist/envs-subcommands/envs-update.cmd.d.ts +1 -1
  24. package/dist/filter.d.ts +1 -1
  25. package/dist/filter.js +1 -1
  26. package/dist/filter.js.map +1 -1
  27. package/dist/merge-conflict-file.d.ts +1 -1
  28. package/dist/merge-conflict-file.js +1 -2
  29. package/dist/merge-conflict-file.js.map +1 -1
  30. package/dist/on-component-events.d.ts +6 -6
  31. package/dist/{preview-1703590665075.js → preview-1703698405864.js} +2 -2
  32. package/dist/scope-subcommands/scope-set.cmd.d.ts +1 -1
  33. package/dist/ui/workspace/use-workspace.d.ts +8 -8
  34. package/dist/ui/workspace/use-workspace.js +7 -18
  35. package/dist/ui/workspace/use-workspace.js.map +1 -1
  36. package/dist/ui/workspace/workspace-model.d.ts +3 -3
  37. package/dist/ui/workspace/workspace-overview/workspace-overview.d.ts +2 -2
  38. package/dist/ui/workspace/workspace-overview/workspace-overview.js +1 -2
  39. package/dist/ui/workspace/workspace-overview/workspace-overview.js.map +1 -1
  40. package/dist/ui/workspace/workspace-provider.d.ts +3 -3
  41. package/dist/ui/workspace/workspace.d.ts +3 -3
  42. package/dist/workspace-aspects-loader.d.ts +3 -3
  43. package/dist/workspace-aspects-loader.js +7 -11
  44. package/dist/workspace-aspects-loader.js.map +1 -1
  45. package/dist/workspace-component/comp-files.d.ts +3 -3
  46. package/dist/workspace-component/component-status.d.ts +3 -3
  47. package/dist/workspace-component/workspace-component-loader.d.ts +5 -5
  48. package/dist/workspace-component/workspace-component-loader.js +11 -12
  49. package/dist/workspace-component/workspace-component-loader.js.map +1 -1
  50. package/dist/workspace.composition.d.ts +2 -2
  51. package/dist/workspace.d.ts +6 -6
  52. package/dist/workspace.graphql.d.ts +2 -2
  53. package/dist/workspace.graphql.js +2 -4
  54. package/dist/workspace.graphql.js.map +1 -1
  55. package/dist/workspace.js +16 -23
  56. package/dist/workspace.js.map +1 -1
  57. package/dist/workspace.provider.d.ts +12 -12
  58. package/dist/workspace.provider.js +8 -11
  59. package/dist/workspace.provider.js.map +1 -1
  60. package/dist/workspace.ui.drawer.d.ts +1 -1
  61. package/dist/workspace.ui.drawer.js +5 -6
  62. package/dist/workspace.ui.drawer.js.map +1 -1
  63. package/dist/workspace.ui.runtime.d.ts +1 -1
  64. package/dist/workspace.ui.runtime.js +2 -8
  65. package/dist/workspace.ui.runtime.js.map +1 -1
  66. package/package.json +39 -46
  67. package/tsconfig.json +16 -21
  68. package/types/asset.d.ts +15 -3
@@ -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;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;A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C,KAAIC,aAAI,EAACnC,KAAK,EAAEnC,SAAS,CAACU,EAAE,CAAC,CAAC;QACjD,OAAOV,SAAS;MAClB,CAAC,CAAC,OAAOuE,GAAQ,EAAE;QACjB,IACEA,GAAG,YAAYC,+BAAiB,IAChCD,GAAG,YAAYE,0BAAwB,IACvCF,GAAG,YAAYG,2BAAa,EAC5B;UACA,IAAIT,cAAc,IAAI,CAAC,IAAI,CAACpF,uBAAuB,EAAE;YACnD,IAAI,CAACF,MAAM,CAACkF,IAAI,CACb,aAAY1B,KAAM,mBAAkB8B,cAAe,uCACtD,CAAC;YACD,OAAO,IAAI;UACb;UACA,MAAM,KAAIU,oBAAQ,EACf,qBAAoBxC,KAAM,wDACzB8B,cAAc,IAAI,QACnB,iDACH,CAAC;QACH;QACA,IAAIW,oBAAiB,CAACC,6BAA6B,CAACN,GAAG,CAAC,EAAE;UACxD,IAAIN,cAAc,IAAI,CAAC,IAAI,CAACjF,wBAAwB,EAAE;YACpD,IAAI,CAACL,MAAM,CAACkF,IAAI,CAAE,aAAY1B,KAAM,mBAAkB8B,cAAe,oCAAmC,CAAC;YACzG,OAAO,IAAI;UACb;UACA,MAAM,KAAIU,oBAAQ,EACf,qBAAoBxC,KAAM,iBAAgBoC,GAAG,CAACO,OAAQ,0CACrDb,cAAc,IAAI,QACnB,iDACH,CAAC;QACH;QACA,IAAIA,cAAc,EAAE,IAAI,CAACtF,MAAM,CAACoG,KAAK,CAAE,kCAAiCd,cAAe,EAAC,CAAC;QACzF,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 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,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA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AiB,IAChCD,GAAG,YAAYE,0BAAwB,IACvCF,GAAG,YAAYG,2BAAa,EAC5B;UACA,IAAIT,cAAc,IAAI,CAAC,IAAI,CAACpF,uBAAuB,EAAE;YACnD,IAAI,CAACF,MAAM,CAACkF,IAAI,CACb,aAAY1B,KAAM,mBAAkB8B,cAAe,uCACtD,CAAC;YACD,OAAO,IAAI;UACb;UACA,MAAM,KAAIU,oBAAQ,EACf,qBAAoBxC,KAAM,wDACzB8B,cAAc,IAAI,QACnB,iDACH,CAAC;QACH;QACA,IAAIW,oBAAiB,CAACC,6BAA6B,CAACN,GAAG,CAAC,EAAE;UACxD,IAAIN,cAAc,IAAI,CAAC,IAAI,CAACjF,wBAAwB,EAAE;YACpD,IAAI,CAACL,MAAM,CAACkF,IAAI,CAAE,aAAY1B,KAAM,mBAAkB8B,cAAe,oCAAmC,CAAC;YACzG,OAAO,IAAI;UACb;UACA,MAAM,KAAIU,oBAAQ,EACf,qBAAoBxC,KAAM,iBAAgBoC,GAAG,CAACO,OAAQ,0CACrDb,cAAc,IAAI,QACnB,iDACH,CAAC;QACH;QACA,IAAIA,cAAc,EAAE,IAAI,CAACtF,MAAM,CAACoG,KAAK,CAAE,kCAAiCd,cAAe,EAAC,CAAC;QACzF,MAAMM,GAAG;MACX;IACF,CAAC,CAAC;IACF,OAAO,IAAAS,kBAAO,EAACxF,UAAU,CAAC;EAC5B;AACF;AAACyF,OAAA,CAAAzG,qBAAA,GAAAA,qBAAA"}
@@ -2,7 +2,7 @@ import { Command, CommandOptions } from '@teambit/cli';
2
2
  import { CapsuleList, IsolatorMain } from '@teambit/isolator';
3
3
  import type { ScopeMain } from '@teambit/scope';
4
4
  import { Workspace } from '.';
5
- declare type CreateOpts = {
5
+ type CreateOpts = {
6
6
  baseDir?: string;
7
7
  rootBaseDir?: string;
8
8
  alwaysNew?: boolean;
@@ -58,7 +58,7 @@ export declare class CapsuleDeleteCmd implements Command {
58
58
  group: string;
59
59
  alias: string;
60
60
  options: CommandOptions;
61
- constructor(isolator: IsolatorMain, scope: ScopeMain, workspace?: Workspace | undefined);
61
+ constructor(isolator: IsolatorMain, scope: ScopeMain, workspace?: Workspace);
62
62
  report(args: [], { all, scopeAspects }: {
63
63
  all: boolean;
64
64
  scopeAspects: boolean;
@@ -45,8 +45,7 @@ class CapsuleCreateCmd {
45
45
  if (baseDir) {
46
46
  finalUseHash = false;
47
47
  } else {
48
- var _this$workspace;
49
- finalUseHash = this.workspace ? (_this$workspace = this.workspace) === null || _this$workspace === void 0 ? void 0 : _this$workspace.shouldUseHashForCapsules() : this.scope.shouldUseHashForCapsules();
48
+ finalUseHash = this.workspace ? this.workspace?.shouldUseHashForCapsules() : this.scope.shouldUseHashForCapsules();
50
49
  }
51
50
  }
52
51
  const baseInstallOptions = {
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","CapsuleCreateCmd","constructor","workspace","scope","isolator","create","componentIds","baseDir","rootBaseDir","alwaysNew","id","installPackages","seedersOnly","useHash","Array","isArray","finalUseHash","undefined","_this$workspace","shouldUseHashForCapsules","baseInstallOptions","additionalInstallOptions","copyPeerToRuntimeOnRoot","useNesting","copyPeerToRuntimeOnComponents","installPeersFromEnvs","installOptions","capsuleOptions","includeFromNestedHosts","name","host","ids","resolveMultipleComponentIds","network","isolateComponents","capsules","graphCapsules","report","opts","capsuleOutput","map","capsule","chalk","bold","component","toString","path","join","title","green","json","c","exports","CapsuleListCmd","workspaceCapsulesRootDir","scopeAspectsCapsulesRootDir","getCapsulesRootDirs","listWs","list","listScope","hostPath","numOfWsCapsules","hostType","cyan","wsLine","scopeLine","suggestLine","lines","x","rootDirs","scopeCapsules","CapsuleDeleteCmd","args","all","scopeAspects","capsuleBaseDirToDelete","capsuleBaseDir","deletedDir","deleteCapsules","CapsuleCmd","getCapsulesRootDir","getCapsulePath","getAspectCapsulePath"],"sources":["capsule.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { CapsuleList, IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';\nimport type { ScopeMain } from '@teambit/scope';\nimport chalk from 'chalk';\n\nimport { Workspace } from '.';\n\ntype CreateOpts = {\n baseDir?: string;\n rootBaseDir?: string;\n alwaysNew?: boolean;\n seedersOnly?: boolean;\n useHash?: boolean;\n id: string;\n installPackages?: boolean;\n};\n\nexport class CapsuleCreateCmd implements Command {\n name = 'create [component-id...]';\n description = `create capsules for components`;\n helpUrl = 'reference/build-pipeline/capsule';\n group = 'capsules';\n alias = '';\n options = [\n [\n 'b',\n 'base-dir <name>',\n 'set base dir of all capsules (hashed to create the base dir inside the root dir - host path by default)',\n ],\n ['r', 'root-base-dir <name>', 'set root base dir of all capsules (absolute path to use as root dir)'],\n ['a', 'always-new', 'create new environment for capsule'],\n ['s', 'seeders-only', 'create capsules for the seeders only (not for the entire graph)'],\n ['i', 'id <name>', 'reuse capsule of certain name'],\n ['', 'use-hash', 'whether to use hash function (of base dir) as capsules root dir name'],\n ['j', 'json', 'json format'],\n ['d', 'install-packages', 'install packages by the package-manager'],\n ['p', 'package-manager <name>', 'npm, yarn or pnpm, default to npm'],\n ] as CommandOptions;\n\n constructor(private workspace: Workspace | undefined, private scope: ScopeMain, private isolator: IsolatorMain) {}\n\n async create(\n [componentIds = []]: [string[]],\n { baseDir, rootBaseDir, alwaysNew = false, id, installPackages = false, seedersOnly = false, useHash }: CreateOpts\n ): Promise<CapsuleList> {\n // @todo: why it is not an array?\n if (componentIds && !Array.isArray(componentIds)) componentIds = [componentIds];\n let finalUseHash = useHash;\n if (useHash === undefined) {\n if (baseDir) {\n finalUseHash = false;\n } else {\n finalUseHash = this.workspace\n ? this.workspace?.shouldUseHashForCapsules()\n : this.scope.shouldUseHashForCapsules();\n }\n }\n\n const baseInstallOptions = { installPackages };\n const additionalInstallOptions = this.workspace\n ? {}\n : {\n copyPeerToRuntimeOnRoot: true,\n useNesting: true,\n copyPeerToRuntimeOnComponents: true,\n installPeersFromEnvs: true,\n };\n const installOptions = { ...baseInstallOptions, ...additionalInstallOptions };\n\n const capsuleOptions: IsolateComponentsOptions = {\n baseDir,\n rootBaseDir,\n installOptions,\n alwaysNew,\n seedersOnly,\n includeFromNestedHosts: true,\n name: id,\n useHash: finalUseHash,\n };\n const host = this.workspace || this.scope;\n const ids = await host.resolveMultipleComponentIds(componentIds);\n const network = await this.isolator.isolateComponents(ids, capsuleOptions);\n const capsules = network.graphCapsules;\n return capsules;\n }\n\n async report([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n const capsuleOutput = capsules\n .map((capsule) => `${chalk.bold(capsule.component.id.toString())} - ${capsule.path}`)\n .join('\\n');\n const title = `${capsules.length} capsule(s) were created successfully`;\n return `${chalk.green(title)}\\n${capsuleOutput}`;\n }\n\n async json([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n return capsules.map((c) => ({\n id: c.component.id.toString(),\n path: c.path,\n }));\n }\n}\n\nexport class CapsuleListCmd implements Command {\n name = 'list';\n description = `list the capsules generated for this workspace`;\n group = 'capsules';\n alias = '';\n options = [['j', 'json', 'json format']] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace | undefined, private scope: ScopeMain) {}\n\n async report() {\n const { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir } = this.getCapsulesRootDirs();\n const listWs = workspaceCapsulesRootDir ? await this.isolator.list(workspaceCapsulesRootDir) : undefined;\n const listScope = await this.isolator.list(scopeAspectsCapsulesRootDir);\n\n const hostPath = this.workspace ? this.workspace.path : this.scope.path;\n const numOfWsCapsules = listWs ? listWs.capsules.length : listScope.capsules.length;\n const hostType = this.workspace ? 'workspace' : 'scope';\n\n const title = chalk.green(\n `found ${chalk.cyan(numOfWsCapsules.toString())} capsule(s) for ${hostType}: ${chalk.cyan(hostPath)}`\n );\n const wsLine = listWs\n ? chalk.green(`workspace capsules root-dir: ${chalk.cyan(workspaceCapsulesRootDir)}`)\n : undefined;\n const scopeLine = chalk.green(`scope's aspects capsules root-dir: ${chalk.cyan(scopeAspectsCapsulesRootDir)}`);\n const suggestLine = chalk.green(`use --json to get the list of all capsules`);\n const lines = [title, wsLine, scopeLine, suggestLine].filter((x) => x).join('\\n');\n\n // TODO: improve output\n return lines;\n }\n\n async json() {\n const rootDirs = this.getCapsulesRootDirs();\n const listWs = rootDirs.workspaceCapsulesRootDir\n ? await this.isolator.list(rootDirs.workspaceCapsulesRootDir)\n : undefined;\n const listScope = await this.isolator.list(rootDirs.scopeAspectsCapsulesRootDir);\n const capsules = listWs ? listWs.capsules : [];\n const scopeCapsules = listScope ? listScope.capsules : [];\n return { ...rootDirs, capsules, scopeCapsules };\n }\n\n private getCapsulesRootDirs() {\n return getCapsulesRootDirs(this.isolator, this.scope, this.workspace);\n }\n}\n\nexport class CapsuleDeleteCmd implements Command {\n name = 'delete';\n description = `delete capsules`;\n extendedDescription = `with no args, only workspace's capsules are deleted`;\n group = 'capsules';\n alias = '';\n options = [\n ['', 'scope-aspects', 'delete scope-aspects capsules'],\n ['a', 'all', 'delete all capsules for all workspaces and scopes'],\n ] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private scope: ScopeMain, private workspace?: Workspace) {}\n\n async report(args: [], { all, scopeAspects }: { all: boolean; scopeAspects: boolean }) {\n const capsuleBaseDirToDelete = (): string | undefined => {\n if (all) return undefined;\n if (scopeAspects) {\n const { scopeAspectsCapsulesRootDir } = getCapsulesRootDirs(this.isolator, this.scope, this.workspace);\n return scopeAspectsCapsulesRootDir;\n }\n return undefined;\n };\n const capsuleBaseDir = capsuleBaseDirToDelete();\n const deletedDir = await this.isolator.deleteCapsules(capsuleBaseDir);\n return chalk.green(`the following capsules dir has been deleted ${chalk.bold(deletedDir)}`);\n }\n}\n\nexport class CapsuleCmd implements Command {\n name = 'capsule';\n description = 'manage capsules';\n extendedDescription = `a capsule is a directory containing the component code, isolated from the workspace.\nnormally, capsules are created during the build process, the component files are copied and the packages are installed\nvia the configured package-manager. the purpose is to compile/test them in isolation to make sure they will work for\nother users after publishing/exporting them.`;\n alias = '';\n group = 'capsules';\n commands: Command[] = [];\n options = [['j', 'json', 'json format']] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace | undefined, private scope: ScopeMain) {}\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async report(args: [string]) {\n return new CapsuleListCmd(this.isolator, this.workspace, this.scope).report();\n }\n}\n\nfunction getCapsulesRootDirs(isolator, scope, workspace) {\n const workspaceCapsulesRootDir = workspace\n ? isolator.getCapsulesRootDir({\n baseDir: workspace.getCapsulePath(),\n useHash: workspace.shouldUseHashForCapsules(),\n })\n : undefined;\n const scopeAspectsCapsulesRootDir = isolator.getCapsulesRootDir({\n baseDir: scope.getAspectCapsulePath(),\n useHash: scope.shouldUseHashForCapsules(),\n });\n\n return { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir };\n}\n"],"mappings":";;;;;;AAIA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,C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,EAAE;IAAA,KAA5FC,QAAsB,GAAtBA,QAAsB;IAAA,KAAUF,SAAgC,GAAhCA,SAAgC;IAAA,KAAUC,KAAgB,GAAhBA,KAAgB;IAAApB,eAAA,eAXvG,SAAS;IAAAA,eAAA,sBACF,iBAAiB;IAAAA,eAAA,8BACR;AACzB;AACA;AACA,6CAA6C;IAAAA,eAAA,gBACnC,EAAE;IAAAA,eAAA,gBACF,UAAU;IAAAA,eAAA,mBACI,EAAE;IAAAA,eAAA,kBACd,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;EAEyE;;EAEjH;EACA,MAAMsD,MAAMA,CAACmC,IAAc,EAAE;IAC3B,OAAO,IAAInB,cAAc,CAAC,IAAI,CAACjD,QAAQ,EAAE,IAAI,CAACF,SAAS,EAAE,IAAI,CAACC,KAAK,CAAC,CAACkC,MAAM,CAAC,CAAC;EAC/E;AACF;AAACe,OAAA,CAAA2B,UAAA,GAAAA,UAAA;AAED,SAASvB,mBAAmBA,CAACpD,QAAQ,EAAED,KAAK,EAAED,SAAS,EAAE;EACvD,MAAMoD,wBAAwB,GAAGpD,SAAS,GACtCE,QAAQ,CAAC4E,kBAAkB,CAAC;IAC1BzE,OAAO,EAAEL,SAAS,CAAC+E,cAAc,CAAC,CAAC;IACnCpE,OAAO,EAAEX,SAAS,CAACiB,wBAAwB,CAAC;EAC9C,CAAC,CAAC,GACFF,SAAS;EACb,MAAMsC,2BAA2B,GAAGnD,QAAQ,CAAC4E,kBAAkB,CAAC;IAC9DzE,OAAO,EAAEJ,KAAK,CAAC+E,oBAAoB,CAAC,CAAC;IACrCrE,OAAO,EAAEV,KAAK,CAACgB,wBAAwB,CAAC;EAC1C,CAAC,CAAC;EAEF,OAAO;IAAEmC,wBAAwB;IAAEC;EAA4B,CAAC;AAClE"}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","CapsuleCreateCmd","constructor","workspace","scope","isolator","create","componentIds","baseDir","rootBaseDir","alwaysNew","id","installPackages","seedersOnly","useHash","Array","isArray","finalUseHash","undefined","shouldUseHashForCapsules","baseInstallOptions","additionalInstallOptions","copyPeerToRuntimeOnRoot","useNesting","copyPeerToRuntimeOnComponents","installPeersFromEnvs","installOptions","capsuleOptions","includeFromNestedHosts","name","host","ids","resolveMultipleComponentIds","network","isolateComponents","capsules","graphCapsules","report","opts","capsuleOutput","map","capsule","chalk","bold","component","toString","path","join","title","green","json","c","exports","CapsuleListCmd","workspaceCapsulesRootDir","scopeAspectsCapsulesRootDir","getCapsulesRootDirs","listWs","list","listScope","hostPath","numOfWsCapsules","hostType","cyan","wsLine","scopeLine","suggestLine","lines","x","rootDirs","scopeCapsules","CapsuleDeleteCmd","args","all","scopeAspects","capsuleBaseDirToDelete","capsuleBaseDir","deletedDir","deleteCapsules","CapsuleCmd","getCapsulesRootDir","getCapsulePath","getAspectCapsulePath"],"sources":["capsule.cmd.ts"],"sourcesContent":["// eslint-disable-next-line max-classes-per-file\nimport { Command, CommandOptions } from '@teambit/cli';\nimport { CapsuleList, IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';\nimport type { ScopeMain } from '@teambit/scope';\nimport chalk from 'chalk';\n\nimport { Workspace } from '.';\n\ntype CreateOpts = {\n baseDir?: string;\n rootBaseDir?: string;\n alwaysNew?: boolean;\n seedersOnly?: boolean;\n useHash?: boolean;\n id: string;\n installPackages?: boolean;\n};\n\nexport class CapsuleCreateCmd implements Command {\n name = 'create [component-id...]';\n description = `create capsules for components`;\n helpUrl = 'reference/build-pipeline/capsule';\n group = 'capsules';\n alias = '';\n options = [\n [\n 'b',\n 'base-dir <name>',\n 'set base dir of all capsules (hashed to create the base dir inside the root dir - host path by default)',\n ],\n ['r', 'root-base-dir <name>', 'set root base dir of all capsules (absolute path to use as root dir)'],\n ['a', 'always-new', 'create new environment for capsule'],\n ['s', 'seeders-only', 'create capsules for the seeders only (not for the entire graph)'],\n ['i', 'id <name>', 'reuse capsule of certain name'],\n ['', 'use-hash', 'whether to use hash function (of base dir) as capsules root dir name'],\n ['j', 'json', 'json format'],\n ['d', 'install-packages', 'install packages by the package-manager'],\n ['p', 'package-manager <name>', 'npm, yarn or pnpm, default to npm'],\n ] as CommandOptions;\n\n constructor(private workspace: Workspace | undefined, private scope: ScopeMain, private isolator: IsolatorMain) {}\n\n async create(\n [componentIds = []]: [string[]],\n { baseDir, rootBaseDir, alwaysNew = false, id, installPackages = false, seedersOnly = false, useHash }: CreateOpts\n ): Promise<CapsuleList> {\n // @todo: why it is not an array?\n if (componentIds && !Array.isArray(componentIds)) componentIds = [componentIds];\n let finalUseHash = useHash;\n if (useHash === undefined) {\n if (baseDir) {\n finalUseHash = false;\n } else {\n finalUseHash = this.workspace\n ? this.workspace?.shouldUseHashForCapsules()\n : this.scope.shouldUseHashForCapsules();\n }\n }\n\n const baseInstallOptions = { installPackages };\n const additionalInstallOptions = this.workspace\n ? {}\n : {\n copyPeerToRuntimeOnRoot: true,\n useNesting: true,\n copyPeerToRuntimeOnComponents: true,\n installPeersFromEnvs: true,\n };\n const installOptions = { ...baseInstallOptions, ...additionalInstallOptions };\n\n const capsuleOptions: IsolateComponentsOptions = {\n baseDir,\n rootBaseDir,\n installOptions,\n alwaysNew,\n seedersOnly,\n includeFromNestedHosts: true,\n name: id,\n useHash: finalUseHash,\n };\n const host = this.workspace || this.scope;\n const ids = await host.resolveMultipleComponentIds(componentIds);\n const network = await this.isolator.isolateComponents(ids, capsuleOptions);\n const capsules = network.graphCapsules;\n return capsules;\n }\n\n async report([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n const capsuleOutput = capsules\n .map((capsule) => `${chalk.bold(capsule.component.id.toString())} - ${capsule.path}`)\n .join('\\n');\n const title = `${capsules.length} capsule(s) were created successfully`;\n return `${chalk.green(title)}\\n${capsuleOutput}`;\n }\n\n async json([componentIds]: [string[]], opts: CreateOpts) {\n // @ts-ignore\n const capsules = await this.create(componentIds, opts);\n return capsules.map((c) => ({\n id: c.component.id.toString(),\n path: c.path,\n }));\n }\n}\n\nexport class CapsuleListCmd implements Command {\n name = 'list';\n description = `list the capsules generated for this workspace`;\n group = 'capsules';\n alias = '';\n options = [['j', 'json', 'json format']] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace | undefined, private scope: ScopeMain) {}\n\n async report() {\n const { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir } = this.getCapsulesRootDirs();\n const listWs = workspaceCapsulesRootDir ? await this.isolator.list(workspaceCapsulesRootDir) : undefined;\n const listScope = await this.isolator.list(scopeAspectsCapsulesRootDir);\n\n const hostPath = this.workspace ? this.workspace.path : this.scope.path;\n const numOfWsCapsules = listWs ? listWs.capsules.length : listScope.capsules.length;\n const hostType = this.workspace ? 'workspace' : 'scope';\n\n const title = chalk.green(\n `found ${chalk.cyan(numOfWsCapsules.toString())} capsule(s) for ${hostType}: ${chalk.cyan(hostPath)}`\n );\n const wsLine = listWs\n ? chalk.green(`workspace capsules root-dir: ${chalk.cyan(workspaceCapsulesRootDir)}`)\n : undefined;\n const scopeLine = chalk.green(`scope's aspects capsules root-dir: ${chalk.cyan(scopeAspectsCapsulesRootDir)}`);\n const suggestLine = chalk.green(`use --json to get the list of all capsules`);\n const lines = [title, wsLine, scopeLine, suggestLine].filter((x) => x).join('\\n');\n\n // TODO: improve output\n return lines;\n }\n\n async json() {\n const rootDirs = this.getCapsulesRootDirs();\n const listWs = rootDirs.workspaceCapsulesRootDir\n ? await this.isolator.list(rootDirs.workspaceCapsulesRootDir)\n : undefined;\n const listScope = await this.isolator.list(rootDirs.scopeAspectsCapsulesRootDir);\n const capsules = listWs ? listWs.capsules : [];\n const scopeCapsules = listScope ? listScope.capsules : [];\n return { ...rootDirs, capsules, scopeCapsules };\n }\n\n private getCapsulesRootDirs() {\n return getCapsulesRootDirs(this.isolator, this.scope, this.workspace);\n }\n}\n\nexport class CapsuleDeleteCmd implements Command {\n name = 'delete';\n description = `delete capsules`;\n extendedDescription = `with no args, only workspace's capsules are deleted`;\n group = 'capsules';\n alias = '';\n options = [\n ['', 'scope-aspects', 'delete scope-aspects capsules'],\n ['a', 'all', 'delete all capsules for all workspaces and scopes'],\n ] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private scope: ScopeMain, private workspace?: Workspace) {}\n\n async report(args: [], { all, scopeAspects }: { all: boolean; scopeAspects: boolean }) {\n const capsuleBaseDirToDelete = (): string | undefined => {\n if (all) return undefined;\n if (scopeAspects) {\n const { scopeAspectsCapsulesRootDir } = getCapsulesRootDirs(this.isolator, this.scope, this.workspace);\n return scopeAspectsCapsulesRootDir;\n }\n return undefined;\n };\n const capsuleBaseDir = capsuleBaseDirToDelete();\n const deletedDir = await this.isolator.deleteCapsules(capsuleBaseDir);\n return chalk.green(`the following capsules dir has been deleted ${chalk.bold(deletedDir)}`);\n }\n}\n\nexport class CapsuleCmd implements Command {\n name = 'capsule';\n description = 'manage capsules';\n extendedDescription = `a capsule is a directory containing the component code, isolated from the workspace.\nnormally, capsules are created during the build process, the component files are copied and the packages are installed\nvia the configured package-manager. the purpose is to compile/test them in isolation to make sure they will work for\nother users after publishing/exporting them.`;\n alias = '';\n group = 'capsules';\n commands: Command[] = [];\n options = [['j', 'json', 'json format']] as CommandOptions;\n\n constructor(private isolator: IsolatorMain, private workspace: Workspace | undefined, private scope: ScopeMain) {}\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async report(args: [string]) {\n return new CapsuleListCmd(this.isolator, this.workspace, this.scope).report();\n }\n}\n\nfunction getCapsulesRootDirs(isolator, scope, workspace) {\n const workspaceCapsulesRootDir = workspace\n ? isolator.getCapsulesRootDir({\n baseDir: workspace.getCapsulePath(),\n useHash: workspace.shouldUseHashForCapsules(),\n })\n : undefined;\n const scopeAspectsCapsulesRootDir = isolator.getCapsulesRootDir({\n baseDir: scope.getAspectCapsulePath(),\n useHash: scope.shouldUseHashForCapsules(),\n });\n\n return { workspaceCapsulesRootDir, scopeAspectsCapsulesRootDir };\n}\n"],"mappings":";;;;;;AAIA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0B,SAAAC,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,GAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAZ,CAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAF,OAAA,CAAAI,MAAA,CAAAD,CAAA,OAAAa,OAAA,WAAAd,CAAA,IAAAe,eAAA,CAAAhB,CAAA,EAAAC,CAAA,EAAAC,CAAA,CAAAD,CAAA,SAAAE,MAAA,CAAAc,yBAAA,GAAAd,MAAA,CAAAe,gBAAA,CA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mD,wBAAwB,GAAGnD,SAAS,GACtCE,QAAQ,CAAC2E,kBAAkB,CAAC;IAC1BxE,OAAO,EAAEL,SAAS,CAAC8E,cAAc,CAAC,CAAC;IACnCnE,OAAO,EAAEX,SAAS,CAACgB,wBAAwB,CAAC;EAC9C,CAAC,CAAC,GACFD,SAAS;EACb,MAAMqC,2BAA2B,GAAGlD,QAAQ,CAAC2E,kBAAkB,CAAC;IAC9DxE,OAAO,EAAEJ,KAAK,CAAC8E,oBAAoB,CAAC,CAAC;IACrCpE,OAAO,EAAEV,KAAK,CAACe,wBAAwB,CAAC;EAC1C,CAAC,CAAC;EAEF,OAAO;IAAEmC,wBAAwB;IAAEC;EAA4B,CAAC;AAClE"}
@@ -20,8 +20,8 @@ export declare class ComponentConfigFile {
20
20
  private componentDir;
21
21
  propagate: boolean;
22
22
  private options;
23
- defaultScope?: string | undefined;
24
- constructor(componentId: ComponentID, aspects: AspectList, componentDir: PathOsBasedAbsolute, propagate?: boolean, options?: ComponentConfigFileOptions, defaultScope?: string | undefined);
23
+ defaultScope?: string;
24
+ constructor(componentId: ComponentID, aspects: AspectList, componentDir: PathOsBasedAbsolute, propagate?: boolean, options?: ComponentConfigFileOptions, defaultScope?: string);
25
25
  static load(componentDir: PathOsBasedAbsolute, aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>, outsideDefaultScope?: string): Promise<ComponentConfigFile | undefined>;
26
26
  static composePath(componentRootFolder: string): string;
27
27
  write(options?: WriteConfigFileOptions): Promise<void>;
@@ -1,5 +1,5 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { ComponentTreeNode, ComponentTreeNodeProps } from '@teambit/component-tree';
3
3
  export declare class ComponentTreeWidget implements ComponentTreeNode {
4
- widget: ({ component }: ComponentTreeNodeProps) => React.JSX.Element;
4
+ widget: ({ component }: ComponentTreeNodeProps) => JSX.Element;
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import { Command, CommandOptions } from '@teambit/cli';
2
2
  import { EjectConfResult, Workspace } from './workspace';
3
- declare type EjectConfArgs = [string];
4
- declare type EjectConfOptionsCLI = {
3
+ type EjectConfArgs = [string];
4
+ type EjectConfOptionsCLI = {
5
5
  propagate: string | boolean | undefined;
6
6
  override: string | boolean | undefined;
7
7
  };
@@ -4,7 +4,7 @@ export declare class EnvsReplaceCmd implements Command {
4
4
  private workspace;
5
5
  name: string;
6
6
  description: string;
7
- options: never[];
7
+ options: any[];
8
8
  group: string;
9
9
  arguments: {
10
10
  name: string;
@@ -12,7 +12,7 @@ export declare class EnvsSetCmd implements Command {
12
12
  cmd: string;
13
13
  description: string;
14
14
  }[];
15
- options: never[];
15
+ options: any[];
16
16
  group: string;
17
17
  constructor(workspace: Workspace);
18
18
  report([pattern, env]: [string, string]): Promise<string>;
@@ -8,7 +8,7 @@ export declare class EnvsUnsetCmd implements Command {
8
8
  name: string;
9
9
  description: string;
10
10
  }[];
11
- options: never[];
11
+ options: any[];
12
12
  group: string;
13
13
  extendedDescription: string;
14
14
  constructor(workspace: Workspace);
@@ -12,7 +12,7 @@ export declare class EnvsUpdateCmd implements Command {
12
12
  cmd: string;
13
13
  description: string;
14
14
  }[];
15
- options: never[];
15
+ options: any[];
16
16
  group: string;
17
17
  constructor(workspace: Workspace);
18
18
  report([aspectId, pattern]: [string, string]): Promise<string>;
package/dist/filter.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ComponentID, ComponentIdList } from '@teambit/component-id';
2
2
  import { Workspace } from './workspace';
3
3
  export declare const statesFilter: readonly ["new", "modified", "deprecated", "deleted", "snappedOnMain", "softTagged", "codeModified"];
4
- export declare type StatesFilter = typeof statesFilter[number];
4
+ export type StatesFilter = typeof statesFilter[number];
5
5
  export declare class Filter {
6
6
  private workspace;
7
7
  constructor(workspace: Workspace);
package/dist/filter.js CHANGED
@@ -91,7 +91,7 @@ class Filter {
91
91
  const comps = await this.workspace.getMany(ids);
92
92
  const results = await Promise.all(comps.map(async c => {
93
93
  const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);
94
- const deprecated = await (modelComponent === null || modelComponent === void 0 ? void 0 : modelComponent.isDeprecated(this.workspace.consumer.scope.objects));
94
+ const deprecated = await modelComponent?.isDeprecated(this.workspace.consumer.scope.objects);
95
95
  return deprecated ? c.id : null;
96
96
  }));
97
97
  return (0, _lodash().compact)(results);
@@ -1 +1 @@
1
- {"version":3,"names":["_componentId","data","require","_pMapSeries","_interopRequireDefault","_lodash","obj","__esModule","default","statesFilter","exports","Filter","constructor","workspace","by","criteria","ids","includes","byMultiParamState","byState","state","statePerMethod","new","byNew","modified","byModified","deprecated","byDeprecated","deleted","byDeleted","snappedOnMain","bySnappedOnMain","softTagged","bySoftTagged","codeModified","byCodeModified","Error","join","bind","stateSplit","split","length","stateName","stateParams","byEnv","env","withinIds","listIds","comps","getMany","compsUsingEnv","filter","c","envId","envs","getEnvId","envIdWithoutVer","ComponentID","getStringWithoutVersion","map","id","modifiedIds","Promise","all","comp","isModified","undefined","compact","compFiles","pMapSeries","getFilesModification","hasVersion","results","modelComponent","consumer","scope","getModelComponentIfExist","isDeprecated","objects","deletedIds","isDeleted","byDuringMergeState","unmergedComponents","legacyScope","getComponents","ComponentIdList","fromArray","u","fromObject","isOnMain","compIds","componentsFromModel","getModelComps","compsDuringMerge","hasWithoutVersion","toComponentId","isHeadSnap","toComponentIdWithHead","withCompIds","bitMap","components","nextVersion","getBitObjectModelComponent"],"sources":["filter.ts"],"sourcesContent":["import { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport pMapSeries from 'p-map-series';\nimport { ModelComponent } from '@teambit/legacy/dist/scope/models';\nimport { compact } from 'lodash';\nimport { Workspace } from './workspace';\n\nexport const statesFilter = [\n 'new',\n 'modified',\n 'deprecated',\n 'deleted',\n 'snappedOnMain',\n 'softTagged',\n 'codeModified',\n] as const;\nexport type StatesFilter = typeof statesFilter[number];\n\nexport class Filter {\n constructor(private workspace: Workspace) {}\n\n async by(criteria: StatesFilter | string, ids: ComponentID[]): Promise<ComponentID[]> {\n return criteria.includes(':') ? this.byMultiParamState(criteria, ids) : this.byState(criteria as StatesFilter, ids);\n }\n\n async byState(state: StatesFilter, ids: ComponentID[]): Promise<ComponentID[]> {\n const statePerMethod = {\n new: this.byNew,\n modified: this.byModified,\n deprecated: this.byDeprecated,\n deleted: this.byDeleted,\n snappedOnMain: this.bySnappedOnMain,\n softTagged: this.bySoftTagged,\n codeModified: this.byCodeModified,\n };\n if (!statePerMethod[state]) {\n throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);\n }\n return statePerMethod[state].bind(this)(ids);\n }\n\n async byMultiParamState(state: string, ids: ComponentID[]): Promise<ComponentID[]> {\n const stateSplit = state.split(':');\n if (stateSplit.length < 2) {\n throw new Error(`byMultiParamState expect the state to have at least one param after the colon, got ${state}`);\n }\n const [stateName, ...stateParams] = stateSplit;\n if (stateName === 'env') {\n return this.byEnv(stateParams[0], ids);\n }\n throw new Error(`byMultiParamState expect the state to be one of the following: ['env'], got ${stateName}`);\n }\n\n async byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const compsUsingEnv = comps.filter((c) => {\n const envId = this.workspace.envs.getEnvId(c);\n const envIdWithoutVer = ComponentID.getStringWithoutVersion(envId);\n return envIdWithoutVer === env;\n });\n return compsUsingEnv.map((c) => c.id);\n }\n\n async byModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const modifiedIds = await Promise.all(comps.map(async (comp) => ((await comp.isModified()) ? comp.id : undefined)));\n return compact(modifiedIds);\n }\n\n async byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const compFiles = await pMapSeries(ids, (id) => this.workspace.getFilesModification(id));\n const modifiedIds = compFiles.filter((c) => c.isModified()).map((c) => c.id);\n return compact(modifiedIds);\n }\n\n async byNew(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n return ids.filter((id) => !id.hasVersion());\n }\n\n async byDeprecated(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const results = await Promise.all(\n comps.map(async (c) => {\n const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);\n const deprecated = await modelComponent?.isDeprecated(this.workspace.consumer.scope.objects);\n return deprecated ? c.id : null;\n })\n );\n return compact(results);\n }\n\n async byDeleted(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const deletedIds = comps.filter((c) => c.isDeleted()).map((c) => c.id);\n return compact(deletedIds);\n }\n\n byDuringMergeState(): ComponentIdList {\n const unmergedComponents = this.workspace.scope.legacyScope.objects.unmergedComponents.getComponents();\n return ComponentIdList.fromArray(unmergedComponents.map((u) => ComponentID.fromObject(u.id)));\n }\n\n /**\n * list components that their head is a snap, not a tag.\n * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.\n * components that are during-merge are filtered out, we don't want them during tag and don't want\n * to show them in the \"snapped\" section in bit-status.\n */\n async bySnappedOnMain(withinIds?: ComponentID[]) {\n if (!this.workspace.isOnMain()) {\n return [];\n }\n const ids = withinIds || (await this.workspace.listIds());\n const compIds = ComponentIdList.fromArray(ids);\n const componentsFromModel = await this.getModelComps(ids);\n const compsDuringMerge = this.byDuringMergeState();\n const comps = componentsFromModel\n .filter((c) => compIds.hasWithoutVersion(c.toComponentId()))\n .filter((c) => !compsDuringMerge.hasWithoutVersion(c.toComponentId()))\n .filter((c) => c.isHeadSnap());\n return comps.map((c) => c.toComponentIdWithHead());\n }\n\n bySoftTagged(withinIds?: ComponentID[]): ComponentID[] {\n const withCompIds = ComponentIdList.fromArray(withinIds || []);\n const all = this.workspace.consumer.bitMap.components.filter((c) => c.nextVersion).map((c) => c.id);\n return withinIds ? all.filter((id) => withCompIds.hasWithoutVersion(id)) : all;\n }\n\n private async getModelComps(ids: ComponentID[]): Promise<ModelComponent[]> {\n const comps = await Promise.all(ids.map((id) => this.workspace.scope.getBitObjectModelComponent(id, false)));\n return compact(comps);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAiC,SAAAG,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAG1B,MAAMG,YAAY,GAAAC,OAAA,CAAAD,YAAA,GAAG,CAC1B,KAAK,EACL,UAAU,EACV,YAAY,EACZ,SAAS,EACT,eAAe,EACf,YAAY,EACZ,cAAc,CACN;AAGH,MAAME,MAAM,CAAC;EAClBC,WAAWA,CAASC,SAAoB,EAAE;IAAA,KAAtBA,SAAoB,GAApBA,SAAoB;EAAG;EAE3C,MAAMC,EAAEA,CAACC,QAA+B,EAAEC,GAAkB,EAA0B;IACpF,OAAOD,QAAQ,CAACE,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAACC,iBAAiB,CAACH,QAAQ,EAAEC,GAAG,CAAC,GAAG,IAAI,CAACG,OAAO,CAACJ,QAAQ,EAAkBC,GAAG,CAAC;EACrH;EAEA,MAAMG,OAAOA,CAACC,KAAmB,EAAEJ,GAAkB,EAA0B;IAC7E,MAAMK,c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C,CAAC,CAC3D5C,MAAM,CAAEC,CAAC,IAAK,CAACyC,gBAAgB,CAACC,iBAAiB,CAAC1C,CAAC,CAAC2C,aAAa,CAAC,CAAC,CAAC,CAAC,CACrE5C,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAAC4C,UAAU,CAAC,CAAC,CAAC;IAChC,OAAOhD,KAAK,CAACW,GAAG,CAAEP,CAAC,IAAKA,CAAC,CAAC6C,qBAAqB,CAAC,CAAC,CAAC;EACpD;EAEAhE,YAAYA,CAACa,SAAyB,EAAiB;IACrD,MAAMoD,WAAW,GAAGb,8BAAe,CAACC,SAAS,CAACxC,SAAS,IAAI,EAAE,CAAC;IAC9D,MAAMiB,GAAG,GAAG,IAAI,CAAClD,SAAS,CAAC6D,QAAQ,CAACyB,MAAM,CAACC,UAAU,CAACjD,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACiD,WAAW,CAAC,CAAC1C,GAAG,CAAEP,CAAC,IAAKA,CAAC,CAACQ,EAAE,CAAC;IACnG,OAAOd,SAAS,GAAGiB,GAAG,CAACZ,MAAM,CAAES,EAAE,IAAKsC,WAAW,CAACJ,iBAAiB,CAAClC,EAAE,CAAC,CAAC,GAAGG,GAAG;EAChF;EAEA,MAAc6B,aAAaA,CAAC5E,GAAkB,EAA6B;IACzE,MAAMgC,KAAK,GAAG,MAAMc,OAAO,CAACC,GAAG,CAAC/C,GAAG,CAAC2C,GAAG,CAAEC,EAAE,IAAK,IAAI,CAAC/C,SAAS,CAAC8D,KAAK,CAAC2B,0BAA0B,CAAC1C,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5G,OAAO,IAAAO,iBAAO,EAACnB,KAAK,CAAC;EACvB;AACF;AAACtC,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
1
+ {"version":3,"names":["_componentId","data","require","_pMapSeries","_interopRequireDefault","_lodash","obj","__esModule","default","statesFilter","exports","Filter","constructor","workspace","by","criteria","ids","includes","byMultiParamState","byState","state","statePerMethod","new","byNew","modified","byModified","deprecated","byDeprecated","deleted","byDeleted","snappedOnMain","bySnappedOnMain","softTagged","bySoftTagged","codeModified","byCodeModified","Error","join","bind","stateSplit","split","length","stateName","stateParams","byEnv","env","withinIds","listIds","comps","getMany","compsUsingEnv","filter","c","envId","envs","getEnvId","envIdWithoutVer","ComponentID","getStringWithoutVersion","map","id","modifiedIds","Promise","all","comp","isModified","undefined","compact","compFiles","pMapSeries","getFilesModification","hasVersion","results","modelComponent","consumer","scope","getModelComponentIfExist","isDeprecated","objects","deletedIds","isDeleted","byDuringMergeState","unmergedComponents","legacyScope","getComponents","ComponentIdList","fromArray","u","fromObject","isOnMain","compIds","componentsFromModel","getModelComps","compsDuringMerge","hasWithoutVersion","toComponentId","isHeadSnap","toComponentIdWithHead","withCompIds","bitMap","components","nextVersion","getBitObjectModelComponent"],"sources":["filter.ts"],"sourcesContent":["import { ComponentID, ComponentIdList } from '@teambit/component-id';\nimport pMapSeries from 'p-map-series';\nimport { ModelComponent } from '@teambit/legacy/dist/scope/models';\nimport { compact } from 'lodash';\nimport { Workspace } from './workspace';\n\nexport const statesFilter = [\n 'new',\n 'modified',\n 'deprecated',\n 'deleted',\n 'snappedOnMain',\n 'softTagged',\n 'codeModified',\n] as const;\nexport type StatesFilter = typeof statesFilter[number];\n\nexport class Filter {\n constructor(private workspace: Workspace) {}\n\n async by(criteria: StatesFilter | string, ids: ComponentID[]): Promise<ComponentID[]> {\n return criteria.includes(':') ? this.byMultiParamState(criteria, ids) : this.byState(criteria as StatesFilter, ids);\n }\n\n async byState(state: StatesFilter, ids: ComponentID[]): Promise<ComponentID[]> {\n const statePerMethod = {\n new: this.byNew,\n modified: this.byModified,\n deprecated: this.byDeprecated,\n deleted: this.byDeleted,\n snappedOnMain: this.bySnappedOnMain,\n softTagged: this.bySoftTagged,\n codeModified: this.byCodeModified,\n };\n if (!statePerMethod[state]) {\n throw new Error(`state ${state} is not recognized, possible values: ${statesFilter.join(', ')}`);\n }\n return statePerMethod[state].bind(this)(ids);\n }\n\n async byMultiParamState(state: string, ids: ComponentID[]): Promise<ComponentID[]> {\n const stateSplit = state.split(':');\n if (stateSplit.length < 2) {\n throw new Error(`byMultiParamState expect the state to have at least one param after the colon, got ${state}`);\n }\n const [stateName, ...stateParams] = stateSplit;\n if (stateName === 'env') {\n return this.byEnv(stateParams[0], ids);\n }\n throw new Error(`byMultiParamState expect the state to be one of the following: ['env'], got ${stateName}`);\n }\n\n async byEnv(env: string, withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const compsUsingEnv = comps.filter((c) => {\n const envId = this.workspace.envs.getEnvId(c);\n const envIdWithoutVer = ComponentID.getStringWithoutVersion(envId);\n return envIdWithoutVer === env;\n });\n return compsUsingEnv.map((c) => c.id);\n }\n\n async byModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const modifiedIds = await Promise.all(comps.map(async (comp) => ((await comp.isModified()) ? comp.id : undefined)));\n return compact(modifiedIds);\n }\n\n async byCodeModified(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n const compFiles = await pMapSeries(ids, (id) => this.workspace.getFilesModification(id));\n const modifiedIds = compFiles.filter((c) => c.isModified()).map((c) => c.id);\n return compact(modifiedIds);\n }\n\n async byNew(withinIds?: ComponentID[]): Promise<ComponentID[]> {\n const ids = withinIds || (await this.workspace.listIds());\n return ids.filter((id) => !id.hasVersion());\n }\n\n async byDeprecated(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const results = await Promise.all(\n comps.map(async (c) => {\n const modelComponent = await this.workspace.consumer.scope.getModelComponentIfExist(c.id);\n const deprecated = await modelComponent?.isDeprecated(this.workspace.consumer.scope.objects);\n return deprecated ? c.id : null;\n })\n );\n return compact(results);\n }\n\n async byDeleted(withinIds?: ComponentID[]) {\n const ids = withinIds || (await this.workspace.listIds());\n const comps = await this.workspace.getMany(ids);\n const deletedIds = comps.filter((c) => c.isDeleted()).map((c) => c.id);\n return compact(deletedIds);\n }\n\n byDuringMergeState(): ComponentIdList {\n const unmergedComponents = this.workspace.scope.legacyScope.objects.unmergedComponents.getComponents();\n return ComponentIdList.fromArray(unmergedComponents.map((u) => ComponentID.fromObject(u.id)));\n }\n\n /**\n * list components that their head is a snap, not a tag.\n * this is relevant only when the lane is the default (main), otherwise, the head is always a snap.\n * components that are during-merge are filtered out, we don't want them during tag and don't want\n * to show them in the \"snapped\" section in bit-status.\n */\n async bySnappedOnMain(withinIds?: ComponentID[]) {\n if (!this.workspace.isOnMain()) {\n return [];\n }\n const ids = withinIds || (await this.workspace.listIds());\n const compIds = ComponentIdList.fromArray(ids);\n const componentsFromModel = await this.getModelComps(ids);\n const compsDuringMerge = this.byDuringMergeState();\n const comps = componentsFromModel\n .filter((c) => compIds.hasWithoutVersion(c.toComponentId()))\n .filter((c) => !compsDuringMerge.hasWithoutVersion(c.toComponentId()))\n .filter((c) => c.isHeadSnap());\n return comps.map((c) => c.toComponentIdWithHead());\n }\n\n bySoftTagged(withinIds?: ComponentID[]): ComponentID[] {\n const withCompIds = ComponentIdList.fromArray(withinIds || []);\n const all = this.workspace.consumer.bitMap.components.filter((c) => c.nextVersion).map((c) => c.id);\n return withinIds ? all.filter((id) => withCompIds.hasWithoutVersion(id)) : all;\n }\n\n private async getModelComps(ids: ComponentID[]): Promise<ModelComponent[]> {\n const comps = await Promise.all(ids.map((id) => this.workspace.scope.getBitObjectModelComponent(id, false)));\n return compact(comps);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF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S,IAAI,EAAE,CAAC;IAC9D,MAAMiB,GAAG,GAAG,IAAI,CAAClD,SAAS,CAAC6D,QAAQ,CAACyB,MAAM,CAACC,UAAU,CAACjD,MAAM,CAAEC,CAAC,IAAKA,CAAC,CAACiD,WAAW,CAAC,CAAC1C,GAAG,CAAEP,CAAC,IAAKA,CAAC,CAACQ,EAAE,CAAC;IACnG,OAAOd,SAAS,GAAGiB,GAAG,CAACZ,MAAM,CAAES,EAAE,IAAKsC,WAAW,CAACJ,iBAAiB,CAAClC,EAAE,CAAC,CAAC,GAAGG,GAAG;EAChF;EAEA,MAAc6B,aAAaA,CAAC5E,GAAkB,EAA6B;IACzE,MAAMgC,KAAK,GAAG,MAAMc,OAAO,CAACC,GAAG,CAAC/C,GAAG,CAAC2C,GAAG,CAAEC,EAAE,IAAK,IAAI,CAAC/C,SAAS,CAAC8D,KAAK,CAAC2B,0BAA0B,CAAC1C,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;IAC5G,OAAO,IAAAO,iBAAO,EAACnB,KAAK,CAAC;EACvB;AACF;AAACtC,OAAA,CAAAC,MAAA,GAAAA,MAAA"}
@@ -1,4 +1,4 @@
1
- declare type ConflictPerId = {
1
+ type ConflictPerId = {
2
2
  [compIdWithoutVersion: string]: string;
3
3
  };
4
4
  export declare class MergeConflictFile {
@@ -48,8 +48,7 @@ class MergeConflictFile {
48
48
  this.conflictPerId[id] = conflict;
49
49
  }
50
50
  removeConflict(id) {
51
- var _this$conflictPerId;
52
- (_this$conflictPerId = this.conflictPerId) === null || _this$conflictPerId === void 0 || delete _this$conflictPerId[id];
51
+ delete this.conflictPerId?.[id];
53
52
  }
54
53
  async getConflict(id) {
55
54
  await this.loadIfNeeded();
@@ -1 +1 @@
1
- {"version":3,"names":["_constants","data","require","_path","_interopRequireDefault","_fsExtra","_mergeConfigConflict","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","idPrefix","idDivider","repeat","MergeConflictFile","constructor","workspacePath","addConflict","id","conflict","conflictPerId","removeConflict","_this$conflictPerId","getConflict","loadIfNeeded","Error","getConflictAssumeIsLoaded","getConflictParsed","configMergeContent","undefined","JSON","parse","err","stringHasConflictMarker","MergeConfigConflict","getPath","message","hasConflict","Boolean","keys","length","path","join","MergeConfigFilename","fileContent","getFileContentIfExists","parsedConflict","parseConflict","write","afterFormat","formatConflicts","fs","writeFile","delete","remove","title","conflicts","map","str","includes","split","filter","line","startsWith","forEach","conflictItem","conflictItemSplit","rawId","conflictStr","trim","filePath","readFile","code","exports"],"sources":["merge-conflict-file.ts"],"sourcesContent":["import { MergeConfigFilename } from '@teambit/legacy/dist/constants';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport { MergeConfigConflict } from './exceptions/merge-config-conflict';\n\nconst idPrefix = `[*]`;\nconst idDivider = '-'.repeat(80);\ntype ConflictPerId = { [compIdWithoutVersion: string]: string };\n\nexport class MergeConflictFile {\n conflictPerId: ConflictPerId | undefined;\n constructor(private workspacePath: string) {}\n\n addConflict(id: string, conflict: string) {\n if (!this.conflictPerId) this.conflictPerId = {};\n this.conflictPerId[id] = conflict;\n }\n\n removeConflict(id: string) {\n delete this.conflictPerId?.[id];\n }\n\n async getConflict(id: string): Promise<string | undefined> {\n await this.loadIfNeeded();\n if (!this.conflictPerId) throw new Error(`this.conflictPerId must be instantiated after load`);\n return this.conflictPerId[id];\n }\n\n getConflictAssumeIsLoaded(id: string): string | undefined {\n if (!this.conflictPerId)\n throw new Error(`MergeConflictFile was not loaded yet, please load it before calling this function`);\n return this.conflictPerId[id];\n }\n\n getConflictParsed(id: string): Record<string, any> | undefined {\n const configMergeContent = this.getConflictAssumeIsLoaded(id);\n if (!configMergeContent) return undefined;\n try {\n return JSON.parse(configMergeContent);\n } catch (err: any) {\n if (this.stringHasConflictMarker(configMergeContent)) {\n throw new MergeConfigConflict(this.getPath());\n }\n throw new Error(`unable to parse the merge-conflict entry for ${id} as the JSON is invalid. err: ${err.message}`);\n }\n }\n\n hasConflict(): boolean {\n return Boolean(this.conflictPerId && Object.keys(this.conflictPerId).length);\n }\n\n getPath() {\n return path.join(this.workspacePath, MergeConfigFilename);\n }\n\n async loadIfNeeded() {\n if (this.conflictPerId) return; // already loaded\n const fileContent = await this.getFileContentIfExists();\n if (!fileContent) {\n this.conflictPerId = {}; // to indicate that it's loaded\n return;\n }\n const parsedConflict = this.parseConflict(fileContent);\n this.conflictPerId = parsedConflict;\n }\n\n async write() {\n if (!this.hasConflict()) return;\n const afterFormat = this.formatConflicts();\n await fs.writeFile(this.getPath(), afterFormat);\n }\n\n async delete() {\n await fs.remove(this.getPath());\n }\n\n private formatConflicts(): string {\n const conflictPerId = this.conflictPerId;\n if (!conflictPerId) throw new Error('conflictPerId is not populated');\n const title = `# Resolve configuration conflicts per component and make sure the Component ID remain in place`;\n const conflicts = Object.keys(conflictPerId)\n .map((id) => {\n const conflict = conflictPerId[id];\n return `${idDivider}\n${idPrefix} ${id}\n${idDivider}\n${conflict}`;\n })\n .join('\\n\\n');\n return `${title}\\n\\n${conflicts}`;\n }\n\n private stringHasConflictMarker(str: string): boolean {\n return str.includes('<<<<<<<') || str.includes('>>>>>>>');\n }\n\n private parseConflict(conflict: string): ConflictPerId {\n // remove irrelevant lines\n conflict = conflict\n .split('\\n')\n .filter((line) => line !== idDivider && !line.startsWith('#'))\n .join('\\n');\n // split by id\n const conflictPerId: ConflictPerId = {};\n const split = conflict.split(idPrefix);\n split.forEach((conflictItem) => {\n const conflictItemSplit = conflictItem.split('\\n');\n const [rawId, ...conflictStr] = conflictItemSplit;\n const id = rawId.trim();\n if (!id) return; // first line has it empty\n conflictPerId[id] = conflictStr.join('\\n');\n });\n return conflictPerId;\n }\n\n private async getFileContentIfExists(): Promise<string | undefined> {\n const filePath = this.getPath();\n let fileContent: string;\n try {\n fileContent = await fs.readFile(filePath, 'utf-8');\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n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K;MAC9B,MAAMC,iBAAiB,GAAGD,YAAY,CAACL,KAAK,CAAC,IAAI,CAAC;MAClD,MAAM,CAACO,KAAK,EAAE,GAAGC,WAAW,CAAC,GAAGF,iBAAiB;MACjD,MAAMhD,EAAE,GAAGiD,KAAK,CAACE,IAAI,CAAC,CAAC;MACvB,IAAI,CAACnD,EAAE,EAAE,OAAO,CAAC;MACjBE,aAAa,CAACF,EAAE,CAAC,GAAGkD,WAAW,CAAC1B,IAAI,CAAC,IAAI,CAAC;IAC5C,CAAC,CAAC;IACF,OAAOtB,aAAa;EACtB;EAEA,MAAcyB,sBAAsBA,CAAA,EAAgC;IAClE,MAAMyB,QAAQ,GAAG,IAAI,CAACnC,OAAO,CAAC,CAAC;IAC/B,IAAIS,WAAmB;IACvB,IAAI;MACFA,WAAW,GAAG,MAAMO,kBAAE,CAACoB,QAAQ,CAACD,QAAQ,EAAE,OAAO,CAAC;IACpD,CAAC,CAAC,OAAOtC,GAAQ,EAAE;MACjB,IAAIA,GAAG,CAACwC,IAAI,KAAK,QAAQ,EAAE;QACzB,OAAO3C,SAAS;MAClB;MACA,MAAMG,GAAG;IACX;IACA,OAAOY,WAAW;EACpB;AACF;AAAC6B,OAAA,CAAA3D,iBAAA,GAAAA,iBAAA"}
1
+ {"version":3,"names":["_constants","data","require","_path","_interopRequireDefault","_fsExtra","_mergeConfigConflict","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","String","r","e","Symbol","toPrimitive","call","TypeError","Number","idPrefix","idDivider","repeat","MergeConflictFile","constructor","workspacePath","addConflict","id","conflict","conflictPerId","removeConflict","getConflict","loadIfNeeded","Error","getConflictAssumeIsLoaded","getConflictParsed","configMergeContent","undefined","JSON","parse","err","stringHasConflictMarker","MergeConfigConflict","getPath","message","hasConflict","Boolean","keys","length","path","join","MergeConfigFilename","fileContent","getFileContentIfExists","parsedConflict","parseConflict","write","afterFormat","formatConflicts","fs","writeFile","delete","remove","title","conflicts","map","str","includes","split","filter","line","startsWith","forEach","conflictItem","conflictItemSplit","rawId","conflictStr","trim","filePath","readFile","code","exports"],"sources":["merge-conflict-file.ts"],"sourcesContent":["import { MergeConfigFilename } from '@teambit/legacy/dist/constants';\nimport path from 'path';\nimport fs from 'fs-extra';\nimport { MergeConfigConflict } from './exceptions/merge-config-conflict';\n\nconst idPrefix = `[*]`;\nconst idDivider = '-'.repeat(80);\ntype ConflictPerId = { [compIdWithoutVersion: string]: string };\n\nexport class MergeConflictFile {\n conflictPerId: ConflictPerId | undefined;\n constructor(private workspacePath: string) {}\n\n addConflict(id: string, conflict: string) {\n if (!this.conflictPerId) this.conflictPerId = {};\n this.conflictPerId[id] = conflict;\n }\n\n removeConflict(id: string) {\n delete this.conflictPerId?.[id];\n }\n\n async getConflict(id: string): Promise<string | undefined> {\n await this.loadIfNeeded();\n if (!this.conflictPerId) throw new Error(`this.conflictPerId must be instantiated after load`);\n return this.conflictPerId[id];\n }\n\n getConflictAssumeIsLoaded(id: string): string | undefined {\n if (!this.conflictPerId)\n throw new Error(`MergeConflictFile was not loaded yet, please load it before calling this function`);\n return this.conflictPerId[id];\n }\n\n getConflictParsed(id: string): Record<string, any> | undefined {\n const configMergeContent = this.getConflictAssumeIsLoaded(id);\n if (!configMergeContent) return undefined;\n try {\n return JSON.parse(configMergeContent);\n } catch (err: any) {\n if (this.stringHasConflictMarker(configMergeContent)) {\n throw new MergeConfigConflict(this.getPath());\n }\n throw new Error(`unable to parse the merge-conflict entry for ${id} as the JSON is invalid. err: ${err.message}`);\n }\n }\n\n hasConflict(): boolean {\n return Boolean(this.conflictPerId && Object.keys(this.conflictPerId).length);\n }\n\n getPath() {\n return path.join(this.workspacePath, MergeConfigFilename);\n }\n\n async loadIfNeeded() {\n if (this.conflictPerId) return; // already loaded\n const fileContent = await this.getFileContentIfExists();\n if (!fileContent) {\n this.conflictPerId = {}; // to indicate that it's loaded\n return;\n }\n const parsedConflict = this.parseConflict(fileContent);\n this.conflictPerId = parsedConflict;\n }\n\n async write() {\n if (!this.hasConflict()) return;\n const afterFormat = this.formatConflicts();\n await fs.writeFile(this.getPath(), afterFormat);\n }\n\n async delete() {\n await fs.remove(this.getPath());\n }\n\n private formatConflicts(): string {\n const conflictPerId = this.conflictPerId;\n if (!conflictPerId) throw new Error('conflictPerId is not populated');\n const title = `# Resolve configuration conflicts per component and make sure the Component ID remain in place`;\n const conflicts = Object.keys(conflictPerId)\n .map((id) => {\n const conflict = conflictPerId[id];\n return `${idDivider}\n${idPrefix} ${id}\n${idDivider}\n${conflict}`;\n })\n .join('\\n\\n');\n return `${title}\\n\\n${conflicts}`;\n }\n\n private stringHasConflictMarker(str: string): boolean {\n return str.includes('<<<<<<<') || str.includes('>>>>>>>');\n }\n\n private parseConflict(conflict: string): ConflictPerId {\n // remove irrelevant lines\n conflict = conflict\n .split('\\n')\n .filter((line) => line !== idDivider && !line.startsWith('#'))\n .join('\\n');\n // split by id\n const conflictPerId: ConflictPerId = {};\n const split = conflict.split(idPrefix);\n split.forEach((conflictItem) => {\n const conflictItemSplit = conflictItem.split('\\n');\n const [rawId, ...conflictStr] = conflictItemSplit;\n const id = rawId.trim();\n if (!id) return; // first line has it empty\n conflictPerId[id] = conflictStr.join('\\n');\n });\n return conflictPerId;\n }\n\n private async getFileContentIfExists(): Promise<string | undefined> {\n const filePath = this.getPath();\n let fileContent: string;\n try {\n fileContent = await fs.readFile(filePath, 'utf-8');\n } catch (err: any) {\n if (err.code === 'ENOENT') {\n return undefined;\n }\n throw err;\n }\n return fileContent;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,MAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;E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sBA,CAAA,EAAgC;IAClE,MAAMyB,QAAQ,GAAG,IAAI,CAACnC,OAAO,CAAC,CAAC;IAC/B,IAAIS,WAAmB;IACvB,IAAI;MACFA,WAAW,GAAG,MAAMO,kBAAE,CAACoB,QAAQ,CAACD,QAAQ,EAAE,OAAO,CAAC;IACpD,CAAC,CAAC,OAAOtC,GAAQ,EAAE;MACjB,IAAIA,GAAG,CAACwC,IAAI,KAAK,QAAQ,EAAE;QACzB,OAAO3C,SAAS;MAClB;MACA,MAAMG,GAAG;IACX;IACA,OAAOY,WAAW;EACpB;AACF;AAAC6B,OAAA,CAAA1D,iBAAA,GAAAA,iBAAA"}
@@ -2,15 +2,15 @@ import { Component, ComponentID, AspectData } from '@teambit/component';
2
2
  import { ComponentLoadOptions } from '@teambit/legacy/dist/consumer/component/component-loader';
3
3
  import type { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';
4
4
  import { WatchOptions } from '@teambit/watcher';
5
- export declare type SerializableResults = {
5
+ export type SerializableResults = {
6
6
  results: any;
7
7
  toString: () => string;
8
8
  };
9
- export declare type OnComponentChange = (component: Component, files: PathOsBasedAbsolute[], removedFiles: PathOsBasedAbsolute[], watchOpts: WatchOptions) => Promise<SerializableResults | void>;
10
- export declare type OnComponentAdd = (component: Component, files: string[], watchOpts: WatchOptions) => Promise<SerializableResults | void>;
11
- export declare type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;
12
- export declare type OnComponentEventResult = {
9
+ export type OnComponentChange = (component: Component, files: PathOsBasedAbsolute[], removedFiles: PathOsBasedAbsolute[], watchOpts: WatchOptions) => Promise<SerializableResults | void>;
10
+ export type OnComponentAdd = (component: Component, files: string[], watchOpts: WatchOptions) => Promise<SerializableResults | void>;
11
+ export type OnComponentRemove = (componentId: ComponentID) => Promise<SerializableResults>;
12
+ export type OnComponentEventResult = {
13
13
  extensionId: string;
14
14
  results: SerializableResults;
15
15
  };
16
- export declare type OnComponentLoad = (component: Component, loadOpts?: ComponentLoadOptions) => Promise<AspectData | undefined>;
16
+ export type OnComponentLoad = (component: Component, loadOpts?: ComponentLoadOptions) => Promise<AspectData | undefined>;
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.107/dist/workspace.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.107/dist/workspace.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.109/dist/workspace.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@1.0.109/dist/workspace.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -8,7 +8,7 @@ export declare class ScopeSetCmd implements Command {
8
8
  name: string;
9
9
  description: string;
10
10
  }[];
11
- options: never[];
11
+ options: any[];
12
12
  group: string;
13
13
  extendedDescription: string;
14
14
  constructor(workspace: Workspace);
@@ -1,7 +1,7 @@
1
1
  import { ComponentModel } from '@teambit/component';
2
2
  import { ComponentID } from '@teambit/component-id';
3
3
  import { Workspace } from './workspace-model';
4
- declare type UseWorkspaceOptions = {
4
+ type UseWorkspaceOptions = {
5
5
  onComponentAdded?: (component: ComponentModel[]) => void;
6
6
  onComponentUpdated?: (component: ComponentModel[]) => void;
7
7
  onComponentRemoved?: (compId: ComponentID[]) => void;
@@ -10,23 +10,23 @@ export declare function useWorkspace(options?: UseWorkspaceOptions): {
10
10
  client: import("@apollo/client").ApolloClient<any>;
11
11
  observable: import("@apollo/client").ObservableQuery<any, import("@apollo/client").OperationVariables>;
12
12
  previousData?: any;
13
- error?: import("@apollo/client").ApolloError | undefined;
13
+ error?: import("@apollo/client").ApolloError;
14
14
  loading: boolean;
15
15
  networkStatus: import("@apollo/client").NetworkStatus;
16
16
  called: boolean;
17
- variables: import("@apollo/client").OperationVariables | undefined;
17
+ variables: import("@apollo/client").OperationVariables;
18
18
  startPolling: (pollInterval: number) => void;
19
19
  stopPolling: () => void;
20
20
  updateQuery: <TVars = import("@apollo/client").OperationVariables>(mapFn: (previousQueryResult: any, options: Pick<import("@apollo/client").WatchQueryOptions<TVars, any>, "variables">) => any) => void;
21
- refetch: (variables?: Partial<import("@apollo/client").OperationVariables> | undefined) => Promise<import("@apollo/client").ApolloQueryResult<any>>;
22
- reobserve: (newOptions?: Partial<import("@apollo/client").WatchQueryOptions<import("@apollo/client").OperationVariables, any>> | undefined, newNetworkStatus?: import("@apollo/client").NetworkStatus | undefined) => Promise<import("@apollo/client").ApolloQueryResult<any>>;
21
+ refetch: (variables?: Partial<import("@apollo/client").OperationVariables>) => Promise<import("@apollo/client").ApolloQueryResult<any>>;
22
+ reobserve: (newOptions?: Partial<import("@apollo/client").WatchQueryOptions<import("@apollo/client").OperationVariables, any>>, newNetworkStatus?: import("@apollo/client").NetworkStatus) => Promise<import("@apollo/client").ApolloQueryResult<any>>;
23
23
  fetchMore: <TFetchData = any, TFetchVars = import("@apollo/client").OperationVariables>(fetchMoreOptions: import("@apollo/client").FetchMoreQueryOptions<TFetchVars, TFetchData> & {
24
- updateQuery?: ((previousQueryResult: any, options: {
24
+ updateQuery?: (previousQueryResult: any, options: {
25
25
  fetchMoreResult: TFetchData;
26
26
  variables: TFetchVars;
27
- }) => any) | undefined;
27
+ }) => any;
28
28
  }) => Promise<import("@apollo/client").ApolloQueryResult<TFetchData>>;
29
- workspace: Workspace | undefined;
29
+ workspace: Workspace;
30
30
  subscribeToMore: <TSubscriptionData = any, TSubscriptionVariables = import("@apollo/client").OperationVariables>(options: import("@apollo/client").SubscribeToMoreOptions<any, TSubscriptionVariables, TSubscriptionData>) => () => void;
31
31
  };
32
32
  export {};