@teambit/workspace 0.0.1158 → 0.0.1159

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 (74) hide show
  1. package/dist/aspects-merger.js +9 -17
  2. package/dist/aspects-merger.js.map +1 -1
  3. package/dist/bit-map.js +3 -4
  4. package/dist/bit-map.js.map +1 -1
  5. package/dist/build-graph-from-fs.js +10 -18
  6. package/dist/build-graph-from-fs.js.map +1 -1
  7. package/dist/build-graph-ids-from-fs.js +11 -17
  8. package/dist/build-graph-ids-from-fs.js.map +1 -1
  9. package/dist/capsule.cmd.js +29 -35
  10. package/dist/capsule.cmd.js.map +1 -1
  11. package/dist/component-config-file/component-config-file.js +1 -3
  12. package/dist/component-config-file/component-config-file.js.map +1 -1
  13. package/dist/component-tree.widget.js +5 -9
  14. package/dist/component-tree.widget.js.map +1 -1
  15. package/dist/eject-conf.cmd.js +10 -16
  16. package/dist/eject-conf.cmd.js.map +1 -1
  17. package/dist/envs-subcommands/envs-replace.cmd.js +10 -16
  18. package/dist/envs-subcommands/envs-replace.cmd.js.map +1 -1
  19. package/dist/envs-subcommands/envs-set.cmd.js +10 -16
  20. package/dist/envs-subcommands/envs-set.cmd.js.map +1 -1
  21. package/dist/envs-subcommands/envs-unset.cmd.js +10 -16
  22. package/dist/envs-subcommands/envs-unset.cmd.js.map +1 -1
  23. package/dist/envs-subcommands/envs-update.cmd.js +10 -16
  24. package/dist/envs-subcommands/envs-update.cmd.js.map +1 -1
  25. package/dist/events/on-component-add-event.js +4 -11
  26. package/dist/events/on-component-add-event.js.map +1 -1
  27. package/dist/events/on-component-change-event.js +4 -11
  28. package/dist/events/on-component-change-event.js.map +1 -1
  29. package/dist/events/on-component-removed-event.js +4 -11
  30. package/dist/events/on-component-removed-event.js.map +1 -1
  31. package/dist/list.cmd.js +10 -18
  32. package/dist/list.cmd.js.map +1 -1
  33. package/dist/merge-conflict-file.js +5 -13
  34. package/dist/merge-conflict-file.js.map +1 -1
  35. package/dist/pattern.cmd.js +12 -18
  36. package/dist/pattern.cmd.js.map +1 -1
  37. package/dist/{preview-1694575035715.js → preview-1694624356552.js} +2 -2
  38. package/dist/scope-subcommands/scope-set.cmd.js +10 -16
  39. package/dist/scope-subcommands/scope-set.cmd.js.map +1 -1
  40. package/dist/ui/workspace/use-workspace.js +9 -18
  41. package/dist/ui/workspace/use-workspace.js.map +1 -1
  42. package/dist/ui/workspace/workspace-overview/workspace-overview.js +1 -1
  43. package/dist/ui/workspace/workspace-overview/workspace-overview.js.map +1 -1
  44. package/dist/ui/workspace/workspace-provider.js +1 -1
  45. package/dist/ui/workspace/workspace-provider.js.map +1 -1
  46. package/dist/ui/workspace/workspace.js +1 -2
  47. package/dist/ui/workspace/workspace.js.map +1 -1
  48. package/dist/use.cmd.js +14 -20
  49. package/dist/use.cmd.js.map +1 -1
  50. package/dist/workspace-aspects-loader.js +9 -16
  51. package/dist/workspace-aspects-loader.js.map +1 -1
  52. package/dist/workspace-component/comp-files.js +0 -2
  53. package/dist/workspace-component/comp-files.js.map +1 -1
  54. package/dist/workspace-component/workspace-component-loader.js +6 -13
  55. package/dist/workspace-component/workspace-component-loader.js.map +1 -1
  56. package/dist/workspace-component/workspace-component.js +0 -1
  57. package/dist/workspace-component/workspace-component.js.map +1 -1
  58. package/dist/workspace.composition.js +1 -1
  59. package/dist/workspace.composition.js.map +1 -1
  60. package/dist/workspace.graphql.js +1 -2
  61. package/dist/workspace.graphql.js.map +1 -1
  62. package/dist/workspace.js +18 -29
  63. package/dist/workspace.js.map +1 -1
  64. package/dist/workspace.main.runtime.js +1 -1
  65. package/dist/workspace.main.runtime.js.map +1 -1
  66. package/dist/workspace.provider.js +1 -3
  67. package/dist/workspace.provider.js.map +1 -1
  68. package/dist/workspace.ui-root.js +5 -11
  69. package/dist/workspace.ui-root.js.map +1 -1
  70. package/dist/workspace.ui.drawer.js +2 -9
  71. package/dist/workspace.ui.drawer.js.map +1 -1
  72. package/dist/workspace.ui.runtime.js +15 -21
  73. package/dist/workspace.ui.runtime.js.map +1 -1
  74. package/package.json +49 -51
@@ -1 +1 @@
1
- {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_graph","_lodash","_component","_bitIds","_exceptions","_scope","_lodash2","_bitError","lifecycleToDepType","compDep","isExtension","lifecycle","Error","GraphIdsFromFsBuilder","constructor","workspace","logger","dependencyResolver","shouldThrowOnMissingDep","_defineProperty2","default","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","withScope","_legacy","dep","hasScope","scopeComponentsImporter","scope","scopeImporter","importMany","BitIds","uniqFromArray","throwForDependencyNotFound","throwForSeederNotFound","reFetchUnBuiltVersion","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 BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\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 withScope = notImported.map((id) => id._legacy).filter((dep) => dep.hasScope());\n const scopeComponentsImporter = this.consumer.scope.scopeImporter;\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(withScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n throwForSeederNotFound: this.shouldThrowOnMissingDep,\n reFetchUnBuiltVersion: false,\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,M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C,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,EAACtF,UAAU,CAAC;EAC5B;AACF;AAACuF,OAAA,CAAAzG,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_graph","_lodash","_component","_bitIds","_exceptions","_scope","_lodash2","_bitError","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","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","withScope","_legacy","dep","hasScope","scopeComponentsImporter","scope","scopeImporter","importMany","BitIds","uniqFromArray","throwForDependencyNotFound","throwForSeederNotFound","reFetchUnBuiltVersion","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 BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\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 withScope = notImported.map((id) => id._legacy).filter((dep) => dep.hasScope());\n const scopeComponentsImporter = this.consumer.scope.scopeImporter;\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(withScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n throwForSeederNotFound: this.shouldThrowOnMissingDep,\n reFetchUnBuiltVersion: false,\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,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AC;IACF,OAAO,IAAAS,kBAAO,EAACtF,UAAU,CAAC;EAC5B;AACF;AAACuF,OAAA,CAAAvG,qBAAA,GAAAA,qBAAA"}
@@ -1,19 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- require("core-js/modules/es.array.iterator.js");
5
- require("core-js/modules/es.promise.js");
6
3
  Object.defineProperty(exports, "__esModule", {
7
4
  value: true
8
5
  });
9
6
  exports.CapsuleListCmd = exports.CapsuleDeleteCmd = exports.CapsuleCreateCmd = exports.CapsuleCmd = void 0;
10
- function _defineProperty2() {
11
- const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- _defineProperty2 = function () {
13
- return data;
14
- };
15
- return data;
16
- }
17
7
  function _chalk() {
18
8
  const data = _interopRequireDefault(require("chalk"));
19
9
  _chalk = function () {
@@ -21,19 +11,23 @@ function _chalk() {
21
11
  };
22
12
  return data;
23
13
  }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
25
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } // eslint-disable-next-line max-classes-per-file
16
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
19
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // eslint-disable-next-line max-classes-per-file
26
20
  class CapsuleCreateCmd {
27
21
  constructor(workspace, scope, isolator) {
28
22
  this.workspace = workspace;
29
23
  this.scope = scope;
30
24
  this.isolator = isolator;
31
- (0, _defineProperty2().default)(this, "name", 'create [component-id...]');
32
- (0, _defineProperty2().default)(this, "description", `create capsules for components`);
33
- (0, _defineProperty2().default)(this, "helpUrl", 'reference/build-pipeline/capsule');
34
- (0, _defineProperty2().default)(this, "group", 'capsules');
35
- (0, _defineProperty2().default)(this, "alias", '');
36
- (0, _defineProperty2().default)(this, "options", [['b', 'base-dir <name>', 'set base dir of all capsules (hashed to create the base dir inside the root dir - host path by default)'], ['r', 'root-base-dir <name>', 'set root base dir of all capsules (absolute path to use as root dir)'], ['a', 'always-new', 'create new environment for capsule'], ['s', 'seeders-only', 'create capsules for the seeders only (not for the entire graph)'], ['i', 'id <name>', 'reuse capsule of certain name'], ['', 'use-hash', 'whether to use hash function (of base dir) as capsules root dir name'], ['j', 'json', 'json format'], ['d', 'install-packages', 'install packages by the package-manager'], ['p', 'package-manager <name>', 'npm, yarn or pnpm, default to npm']]);
25
+ _defineProperty(this, "name", 'create [component-id...]');
26
+ _defineProperty(this, "description", `create capsules for components`);
27
+ _defineProperty(this, "helpUrl", 'reference/build-pipeline/capsule');
28
+ _defineProperty(this, "group", 'capsules');
29
+ _defineProperty(this, "alias", '');
30
+ _defineProperty(this, "options", [['b', 'base-dir <name>', 'set base dir of all capsules (hashed to create the base dir inside the root dir - host path by default)'], ['r', 'root-base-dir <name>', 'set root base dir of all capsules (absolute path to use as root dir)'], ['a', 'always-new', 'create new environment for capsule'], ['s', 'seeders-only', 'create capsules for the seeders only (not for the entire graph)'], ['i', 'id <name>', 'reuse capsule of certain name'], ['', 'use-hash', 'whether to use hash function (of base dir) as capsules root dir name'], ['j', 'json', 'json format'], ['d', 'install-packages', 'install packages by the package-manager'], ['p', 'package-manager <name>', 'npm, yarn or pnpm, default to npm']]);
37
31
  }
38
32
  async create([componentIds = []], {
39
33
  baseDir,
@@ -103,11 +97,11 @@ class CapsuleListCmd {
103
97
  this.isolator = isolator;
104
98
  this.workspace = workspace;
105
99
  this.scope = scope;
106
- (0, _defineProperty2().default)(this, "name", 'list');
107
- (0, _defineProperty2().default)(this, "description", `list the capsules generated for this workspace`);
108
- (0, _defineProperty2().default)(this, "group", 'capsules');
109
- (0, _defineProperty2().default)(this, "alias", '');
110
- (0, _defineProperty2().default)(this, "options", [['j', 'json', 'json format']]);
100
+ _defineProperty(this, "name", 'list');
101
+ _defineProperty(this, "description", `list the capsules generated for this workspace`);
102
+ _defineProperty(this, "group", 'capsules');
103
+ _defineProperty(this, "alias", '');
104
+ _defineProperty(this, "options", [['j', 'json', 'json format']]);
111
105
  }
112
106
  async report() {
113
107
  const {
@@ -149,12 +143,12 @@ class CapsuleDeleteCmd {
149
143
  this.isolator = isolator;
150
144
  this.scope = scope;
151
145
  this.workspace = workspace;
152
- (0, _defineProperty2().default)(this, "name", 'delete');
153
- (0, _defineProperty2().default)(this, "description", `delete capsules`);
154
- (0, _defineProperty2().default)(this, "extendedDescription", `with no args, only workspace's capsules are deleted`);
155
- (0, _defineProperty2().default)(this, "group", 'capsules');
156
- (0, _defineProperty2().default)(this, "alias", '');
157
- (0, _defineProperty2().default)(this, "options", [['', 'scope-aspects', 'delete scope-aspects capsules'], ['a', 'all', 'delete all capsules for all workspaces and scopes']]);
146
+ _defineProperty(this, "name", 'delete');
147
+ _defineProperty(this, "description", `delete capsules`);
148
+ _defineProperty(this, "extendedDescription", `with no args, only workspace's capsules are deleted`);
149
+ _defineProperty(this, "group", 'capsules');
150
+ _defineProperty(this, "alias", '');
151
+ _defineProperty(this, "options", [['', 'scope-aspects', 'delete scope-aspects capsules'], ['a', 'all', 'delete all capsules for all workspaces and scopes']]);
158
152
  }
159
153
  async report(args, {
160
154
  all,
@@ -181,16 +175,16 @@ class CapsuleCmd {
181
175
  this.isolator = isolator;
182
176
  this.workspace = workspace;
183
177
  this.scope = scope;
184
- (0, _defineProperty2().default)(this, "name", 'capsule');
185
- (0, _defineProperty2().default)(this, "description", 'manage capsules');
186
- (0, _defineProperty2().default)(this, "extendedDescription", `a capsule is a directory containing the component code, isolated from the workspace.
178
+ _defineProperty(this, "name", 'capsule');
179
+ _defineProperty(this, "description", 'manage capsules');
180
+ _defineProperty(this, "extendedDescription", `a capsule is a directory containing the component code, isolated from the workspace.
187
181
  normally, capsules are created during the build process, the component files are copied and the packages are installed
188
182
  via the configured package-manager. the purpose is to compile/test them in isolation to make sure they will work for
189
183
  other users after publishing/exporting them.`);
190
- (0, _defineProperty2().default)(this, "alias", '');
191
- (0, _defineProperty2().default)(this, "group", 'capsules');
192
- (0, _defineProperty2().default)(this, "commands", []);
193
- (0, _defineProperty2().default)(this, "options", [['j', 'json', 'json format']]);
184
+ _defineProperty(this, "alias", '');
185
+ _defineProperty(this, "group", 'capsules');
186
+ _defineProperty(this, "commands", []);
187
+ _defineProperty(this, "options", [['j', 'json', 'json format']]);
194
188
  }
195
189
 
196
190
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","ownKeys","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty2","default","getOwnPropertyDescriptors","defineProperties","defineProperty","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,SAAAG,QAAAC,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,SAAAU,cAAAC,MAAA,aAAAC,CAAA,MAAAA,CAAA,GAAAC,SAAA,CAAAC,MAAA,EAAAF,CAAA,UAAAG,MAAA,WAAAF,SAAA,CAAAD,CAAA,IAAAC,SAAA,CAAAD,CAAA,QAAAA,CAAA,OAAAf,OAAA,CAAAI,MAAA,CAAAc,MAAA,OAAAC,OAAA,WAAAC,GAAA,QAAAC,gBAAA,GAAAC,OAAA,EAAAR,MAAA,EAAAM,GAAA,EAAAF,MAAA,CAAAE,GAAA,SAAAhB,MAAA,CAAAmB,yBAAA,GAAAnB,MAAA,CAAAoB,gBAAA,CAAAV,MAAA,EAAAV,MAAA,CAAAmB,yBAAA,CAAA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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","object","enumerableOnly","keys","Object","getOwnPropertySymbols","symbols","filter","sym","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","target","i","arguments","length","source","forEach","key","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","value","_toPropertyKey","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","CapsuleCreateCmd","constructor","workspace","scope","isolator","create","componentIds","baseDir","rootBaseDir","alwaysNew","id","installPackages","seedersOnly","useHash","Array","isArray","finalUseHash","_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,MAAA,EAAAC,cAAA,QAAAC,IAAA,GAAAC,MAAA,CAAAD,IAAA,CAAAF,MAAA,OAAAG,MAAA,CAAAC,qBAAA,QAAAC,OAAA,GAAAF,MAAA,CAAAC,qBAAA,CAAAJ,MAAA,GAAAC,cAAA,KAAAI,OAAA,GAAAA,OAAA,CAAAC,MAAA,WAAAC,GAAA,WAAAJ,MAAA,CAAAK,wBAAA,CAAAR,MAAA,EAAAO,GAAA,EAAAE,UAAA,OAAAP,IAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,IAAA,EAAAG,OAAA,YAAAH,IAAA;AAAA,S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AA,gBACF,UAAU;IAAAA,eAAA,mBACI,EAAE;IAAAA,eAAA,kBACd,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC;EAEyE;;EAEjH;EACA,MAAMyD,MAAMA,CAACmC,IAAc,EAAE;IAC3B,OAAO,IAAInB,cAAc,CAAC,IAAI,CAAChD,QAAQ,EAAE,IAAI,CAACF,SAAS,EAAE,IAAI,CAACC,KAAK,CAAC,CAACiC,MAAM,CAAC,CAAC;EAC/E;AACF;AAACe,OAAA,CAAA2B,UAAA,GAAAA,UAAA;AAED,SAASvB,mBAAmBA,CAACnD,QAAQ,EAAED,KAAK,EAAED,SAAS,EAAE;EACvD,MAAMmD,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,GACFvB,SAAS;EACb,MAAM2D,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"}
@@ -1,8 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- require("core-js/modules/es.array.iterator.js");
5
- require("core-js/modules/es.promise.js");
6
3
  Object.defineProperty(exports, "__esModule", {
7
4
  value: true
8
5
  });
@@ -84,6 +81,7 @@ function _exceptions() {
84
81
  };
85
82
  return data;
86
83
  }
84
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
87
85
  const DEFAULT_INDENT = 2;
88
86
  const DEFAULT_NEWLINE = '\n';
89
87
  class ComponentConfigFile {
@@ -1 +1 @@
1
- {"version":3,"names":["_component","data","require","_constants","_extensionData","_detectIndent","_interopRequireDefault","_detectNewline","_fsExtra","_path","_stringifyPackage","_config","_lodash","_exceptions","DEFAULT_INDENT","DEFAULT_NEWLINE","ComponentConfigFile","constructor","componentId","aspects","componentDir","propagate","options","indent","newLine","defaultScope","load","aspectListFactory","outsideDefaultScope","filePath","composePath","isExist","fs","pathExists","undefined","content","readFile","parsed","parseComponentJsonContent","detectIndent","amount","detectNewline","ComponentID","fromObject","ExtensionDataList","fromConfigObject","extensions","Boolean","componentRootFolder","path","join","COMPONENT_CONFIG_FILE_NAME","write","json","toJson","override","AlreadyExistsError","writeJsonSync","spaces","EOL","addAspect","aspectId","config","resolveComponentId","shouldMergeConfig","existing","get","getNewConfig","merge","aspectEntry","aspectEntryFromConfigObject","entries","push","removeAspect","markWithMinusIfNotExist","aspectList","withoutEntries","REMOVE_EXTENSION_SPECIAL_SIGN","id","legacyEntry","configEntryToDataEntry","AspectEntry","toObject","toConfigObject","toString","stringifyPackage","exports","str","dir","JSON","parse","err","Error","message"],"sources":["component-config-file.ts"],"sourcesContent":["import { ComponentID, AspectList, AspectEntry, ResolveComponentIdFunc } from '@teambit/component';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';\nimport { ExtensionDataList, configEntryToDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport detectIndent from 'detect-indent';\nimport detectNewline from 'detect-newline';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport stringifyPackage from 'stringify-package';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { merge } from 'lodash';\nimport { AlreadyExistsError } from './exceptions';\n\ninterface ComponentConfigFileOptions {\n indent: number;\n newLine: '\\r\\n' | '\\n' | undefined;\n}\n\ninterface WriteConfigFileOptions {\n override?: boolean;\n}\n\ninterface ComponentConfigFileJson {\n componentId: any;\n // TODO: think if we want to change it to aspects\n extensions: any;\n propagate: boolean;\n defaultScope?: string;\n}\n\nconst DEFAULT_INDENT = 2;\nconst DEFAULT_NEWLINE = '\\n';\n\nexport class ComponentConfigFile {\n constructor(\n public componentId: ComponentID,\n public aspects: AspectList,\n private componentDir: PathOsBasedAbsolute,\n public propagate: boolean = false,\n private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },\n public defaultScope?: string\n ) {}\n\n static async load(\n componentDir: PathOsBasedAbsolute,\n aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,\n outsideDefaultScope?: string\n ): Promise<ComponentConfigFile | undefined> {\n const filePath = ComponentConfigFile.composePath(componentDir);\n const isExist = await fs.pathExists(filePath);\n if (!isExist) {\n return undefined;\n }\n const content = await fs.readFile(filePath, 'utf-8');\n const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);\n const indent = detectIndent(content).amount;\n const newLine = detectNewline(content);\n const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);\n const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));\n\n return new ComponentConfigFile(\n componentId,\n aspects,\n componentDir,\n Boolean(parsed.propagate),\n { indent, newLine },\n parsed.defaultScope\n );\n }\n\n static composePath(componentRootFolder: string) {\n return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);\n }\n\n async write(options: WriteConfigFileOptions = {}): Promise<void> {\n const json = this.toJson();\n const filePath = ComponentConfigFile.composePath(this.componentDir);\n const isExist = await fs.pathExists(filePath);\n if (isExist && !options.override) {\n throw new AlreadyExistsError(filePath);\n }\n return fs.writeJsonSync(filePath, json, { spaces: this.options.indent, EOL: this.options.newLine });\n }\n\n async addAspect(\n aspectId: string,\n config: any,\n resolveComponentId: ResolveComponentIdFunc,\n shouldMergeConfig = false\n ) {\n const existing = this.aspects.get(aspectId);\n\n if (existing) {\n const getNewConfig = () => {\n if (!shouldMergeConfig) return config;\n if (!config || config === '-') return config;\n if (!existing.config) return config;\n // @ts-ignore\n if (existing.config === '-') return config;\n return merge(existing.config, config);\n };\n existing.config = getNewConfig();\n } else {\n const aspectEntry = await this.aspectEntryFromConfigObject(aspectId, config, resolveComponentId);\n this.aspects.entries.push(aspectEntry);\n }\n }\n\n async removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc) {\n const existing = this.aspects.get(aspectId);\n if (existing) {\n const aspectList = this.aspects.withoutEntries([aspectId]);\n this.aspects = aspectList;\n } else if (markWithMinusIfNotExist) {\n await this.addAspect(aspectId, REMOVE_EXTENSION_SPECIAL_SIGN, resolveComponentId);\n }\n }\n\n private async aspectEntryFromConfigObject(id: string, config: any, resolveComponentId: ResolveComponentIdFunc) {\n const aspectId = await resolveComponentId(id);\n const legacyEntry = configEntryToDataEntry(id, config);\n return new AspectEntry(aspectId, legacyEntry);\n }\n\n toJson(): ComponentConfigFileJson {\n return {\n componentId: this.componentId.toObject(),\n propagate: this.propagate,\n defaultScope: this.defaultScope,\n extensions: this.aspects.toConfigObject(),\n };\n }\n\n toString(): string {\n const json = this.toJson();\n return stringifyPackage(json, this.options.indent, this.options.newLine);\n }\n}\n\nfunction parseComponentJsonContent(str: string, dir: string) {\n try {\n return JSON.parse(str);\n } catch (err: any) {\n throw new Error(`failed parsing component.json file at ${dir}. original error: ${err.message}`);\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,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;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AAW,EAAE,IAAI,CAACA,WAAW,CAACgE,QAAQ,CAAC,CAAC;MACxC7D,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBI,YAAY,EAAE,IAAI,CAACA,YAAY;MAC/BqB,UAAU,EAAE,IAAI,CAAC3B,OAAO,CAACgE,cAAc,CAAC;IAC1C,CAAC;EACH;EAEAC,QAAQA,CAAA,EAAW;IACjB,MAAM/B,IAAI,GAAG,IAAI,CAACC,MAAM,CAAC,CAAC;IAC1B,OAAO,IAAA+B,2BAAgB,EAAChC,IAAI,EAAE,IAAI,CAAC/B,OAAO,CAACC,MAAM,EAAE,IAAI,CAACD,OAAO,CAACE,OAAO,CAAC;EAC1E;AACF;AAAC8D,OAAA,CAAAtE,mBAAA,GAAAA,mBAAA;AAED,SAASsB,yBAAyBA,CAACiD,GAAW,EAAEC,GAAW,EAAE;EAC3D,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACH,GAAG,CAAC;EACxB,CAAC,CAAC,OAAOI,GAAQ,EAAE;IACjB,MAAM,IAAIC,KAAK,CAAE,yCAAwCJ,GAAI,qBAAoBG,GAAG,CAACE,OAAQ,EAAC,CAAC;EACjG;AACF"}
1
+ {"version":3,"names":["_component","data","require","_constants","_extensionData","_detectIndent","_interopRequireDefault","_detectNewline","_fsExtra","_path","_stringifyPackage","_config","_lodash","_exceptions","obj","__esModule","default","DEFAULT_INDENT","DEFAULT_NEWLINE","ComponentConfigFile","constructor","componentId","aspects","componentDir","propagate","options","indent","newLine","defaultScope","load","aspectListFactory","outsideDefaultScope","filePath","composePath","isExist","fs","pathExists","undefined","content","readFile","parsed","parseComponentJsonContent","detectIndent","amount","detectNewline","ComponentID","fromObject","ExtensionDataList","fromConfigObject","extensions","Boolean","componentRootFolder","path","join","COMPONENT_CONFIG_FILE_NAME","write","json","toJson","override","AlreadyExistsError","writeJsonSync","spaces","EOL","addAspect","aspectId","config","resolveComponentId","shouldMergeConfig","existing","get","getNewConfig","merge","aspectEntry","aspectEntryFromConfigObject","entries","push","removeAspect","markWithMinusIfNotExist","aspectList","withoutEntries","REMOVE_EXTENSION_SPECIAL_SIGN","id","legacyEntry","configEntryToDataEntry","AspectEntry","toObject","toConfigObject","toString","stringifyPackage","exports","str","dir","JSON","parse","err","Error","message"],"sources":["component-config-file.ts"],"sourcesContent":["import { ComponentID, AspectList, AspectEntry, ResolveComponentIdFunc } from '@teambit/component';\nimport { COMPONENT_CONFIG_FILE_NAME } from '@teambit/legacy/dist/constants';\nimport { ExtensionDataList, configEntryToDataEntry } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport { PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport detectIndent from 'detect-indent';\nimport detectNewline from 'detect-newline';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport stringifyPackage from 'stringify-package';\nimport { REMOVE_EXTENSION_SPECIAL_SIGN } from '@teambit/legacy/dist/consumer/config';\nimport { merge } from 'lodash';\nimport { AlreadyExistsError } from './exceptions';\n\ninterface ComponentConfigFileOptions {\n indent: number;\n newLine: '\\r\\n' | '\\n' | undefined;\n}\n\ninterface WriteConfigFileOptions {\n override?: boolean;\n}\n\ninterface ComponentConfigFileJson {\n componentId: any;\n // TODO: think if we want to change it to aspects\n extensions: any;\n propagate: boolean;\n defaultScope?: string;\n}\n\nconst DEFAULT_INDENT = 2;\nconst DEFAULT_NEWLINE = '\\n';\n\nexport class ComponentConfigFile {\n constructor(\n public componentId: ComponentID,\n public aspects: AspectList,\n private componentDir: PathOsBasedAbsolute,\n public propagate: boolean = false,\n private options: ComponentConfigFileOptions = { indent: DEFAULT_INDENT, newLine: DEFAULT_NEWLINE },\n public defaultScope?: string\n ) {}\n\n static async load(\n componentDir: PathOsBasedAbsolute,\n aspectListFactory: (extensionDataList: ExtensionDataList) => Promise<AspectList>,\n outsideDefaultScope?: string\n ): Promise<ComponentConfigFile | undefined> {\n const filePath = ComponentConfigFile.composePath(componentDir);\n const isExist = await fs.pathExists(filePath);\n if (!isExist) {\n return undefined;\n }\n const content = await fs.readFile(filePath, 'utf-8');\n const parsed: ComponentConfigFileJson = parseComponentJsonContent(content, componentDir);\n const indent = detectIndent(content).amount;\n const newLine = detectNewline(content);\n const componentId = ComponentID.fromObject(parsed.componentId, parsed.defaultScope || outsideDefaultScope);\n const aspects = await aspectListFactory(ExtensionDataList.fromConfigObject(parsed.extensions));\n\n return new ComponentConfigFile(\n componentId,\n aspects,\n componentDir,\n Boolean(parsed.propagate),\n { indent, newLine },\n parsed.defaultScope\n );\n }\n\n static composePath(componentRootFolder: string) {\n return path.join(componentRootFolder, COMPONENT_CONFIG_FILE_NAME);\n }\n\n async write(options: WriteConfigFileOptions = {}): Promise<void> {\n const json = this.toJson();\n const filePath = ComponentConfigFile.composePath(this.componentDir);\n const isExist = await fs.pathExists(filePath);\n if (isExist && !options.override) {\n throw new AlreadyExistsError(filePath);\n }\n return fs.writeJsonSync(filePath, json, { spaces: this.options.indent, EOL: this.options.newLine });\n }\n\n async addAspect(\n aspectId: string,\n config: any,\n resolveComponentId: ResolveComponentIdFunc,\n shouldMergeConfig = false\n ) {\n const existing = this.aspects.get(aspectId);\n\n if (existing) {\n const getNewConfig = () => {\n if (!shouldMergeConfig) return config;\n if (!config || config === '-') return config;\n if (!existing.config) return config;\n // @ts-ignore\n if (existing.config === '-') return config;\n return merge(existing.config, config);\n };\n existing.config = getNewConfig();\n } else {\n const aspectEntry = await this.aspectEntryFromConfigObject(aspectId, config, resolveComponentId);\n this.aspects.entries.push(aspectEntry);\n }\n }\n\n async removeAspect(aspectId: string, markWithMinusIfNotExist: boolean, resolveComponentId: ResolveComponentIdFunc) {\n const existing = this.aspects.get(aspectId);\n if (existing) {\n const aspectList = this.aspects.withoutEntries([aspectId]);\n this.aspects = aspectList;\n } else if (markWithMinusIfNotExist) {\n await this.addAspect(aspectId, REMOVE_EXTENSION_SPECIAL_SIGN, resolveComponentId);\n }\n }\n\n private async aspectEntryFromConfigObject(id: string, config: any, resolveComponentId: ResolveComponentIdFunc) {\n const aspectId = await resolveComponentId(id);\n const legacyEntry = configEntryToDataEntry(id, config);\n return new AspectEntry(aspectId, legacyEntry);\n }\n\n toJson(): ComponentConfigFileJson {\n return {\n componentId: this.componentId.toObject(),\n propagate: this.propagate,\n defaultScope: this.defaultScope,\n extensions: this.aspects.toConfigObject(),\n };\n }\n\n toString(): string {\n const json = this.toJson();\n return stringifyPackage(json, this.options.indent, this.options.newLine);\n }\n}\n\nfunction parseComponentJsonContent(str: string, dir: string) {\n try {\n return JSON.parse(str);\n } catch (err: any) {\n throw new Error(`failed parsing component.json file at ${dir}. original error: ${err.message}`);\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,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,eAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,cAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,eAAA;EAAA,MAAAN,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAK,cAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,SAAA;EAAA,MAAAP,IAAA,GAAAK,sBAAA,CAAAJ,OAAA;EAAAM,QAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,M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AC;EAC1E;AACF;AAAC8D,OAAA,CAAAtE,mBAAA,GAAAA,mBAAA;AAED,SAASsB,yBAAyBA,CAACiD,GAAW,EAAEC,GAAW,EAAE;EAC3D,IAAI;IACF,OAAOC,IAAI,CAACC,KAAK,CAACH,GAAG,CAAC;EACxB,CAAC,CAAC,OAAOI,GAAQ,EAAE;IACjB,MAAM,IAAIC,KAAK,CAAE,yCAAwCJ,GAAI,qBAAoBG,GAAG,CAACE,OAAQ,EAAC,CAAC;EACjG;AACF"}
@@ -1,17 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.ComponentTreeWidget = void 0;
8
- function _defineProperty2() {
9
- const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- _defineProperty2 = function () {
11
- return data;
12
- };
13
- return data;
14
- }
15
7
  function _react() {
16
8
  const data = _interopRequireDefault(require("react"));
17
9
  _react = function () {
@@ -26,9 +18,13 @@ function _componentUi() {
26
18
  };
27
19
  return data;
28
20
  }
21
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
23
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
24
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
29
25
  class ComponentTreeWidget {
30
26
  constructor() {
31
- (0, _defineProperty2().default)(this, "widget", ({
27
+ _defineProperty(this, "widget", ({
32
28
  component
33
29
  }) => {
34
30
  return /*#__PURE__*/_react().default.createElement(_componentUi().ComponentStatusResolver, {
@@ -1 +1 @@
1
- {"version":3,"names":["_react","data","_interopRequireDefault","require","_componentUi","ComponentTreeWidget","constructor","_defineProperty2","default","component","createElement","ComponentStatusResolver","status","issuesCount","exports"],"sources":["component-tree.widget.tsx"],"sourcesContent":["import React from 'react';\nimport { ComponentTreeNode, ComponentTreeNodeProps } from '@teambit/component-tree';\nimport { ComponentStatusResolver } from '@teambit/component.ui.component-status-resolver';\n\nexport class ComponentTreeWidget implements ComponentTreeNode {\n widget = ({ component }: ComponentTreeNodeProps) => {\n return <ComponentStatusResolver status={component.status} issuesCount={component.issuesCount} />;\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAMI,mBAAmB,CAA8B;EAAAC,YAAA;IAAA,IAAAC,gBAAA,GAAAC,OAAA,kBACnD,CAAC;MAAEC;IAAkC,CAAC,KAAK;MAClD,oBAAOT,MAAA,GAAAQ,OAAA,CAAAE,aAAA,CAACN,YAAA,GAAAO,uBAAuB;QAACC,MAAM,EAAEH,SAAS,CAACG,MAAO;QAACC,WAAW,EAAEJ,SAAS,CAACI;MAAY,CAAE,CAAC;IAClG,CAAC;EAAA;AACH;AAACC,OAAA,CAAAT,mBAAA,GAAAA,mBAAA"}
1
+ {"version":3,"names":["_react","data","_interopRequireDefault","require","_componentUi","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","ComponentTreeWidget","constructor","component","createElement","ComponentStatusResolver","status","issuesCount","exports"],"sources":["component-tree.widget.tsx"],"sourcesContent":["import React from 'react';\nimport { ComponentTreeNode, ComponentTreeNodeProps } from '@teambit/component-tree';\nimport { ComponentStatusResolver } from '@teambit/component.ui.component-status-resolver';\n\nexport class ComponentTreeWidget implements ComponentTreeNode {\n widget = ({ component }: ComponentTreeNodeProps) => {\n return <ComponentStatusResolver status={component.status} issuesCount={component.issuesCount} />;\n };\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,aAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0F,SAAAC,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,GAAA,CAAAI,GAAA,IAAAC,KAAA,WAAAL,GAAA;AAAA,SAAAM,eAAAM,GAAA,QAAAR,GAAA,GAAAS,YAAA,CAAAD,GAAA,2BAAAR,GAAA,gBAAAA,GAAA,GAAAU,MAAA,CAAAV,GAAA;AAAA,SAAAS,aAAAE,KAAA,EAAAC,IAAA,eAAAD,KAAA,iBAAAA,KAAA,kBAAAA,KAAA,MAAAE,IAAA,GAAAF,KAAA,CAAAG,MAAA,CAAAC,WAAA,OAAAF,IAAA,KAAAG,SAAA,QAAAC,GAAA,GAAAJ,IAAA,CAAAK,IAAA,CAAAP,KAAA,EAAAC,IAAA,2BAAAK,GAAA,sBAAAA,GAAA,YAAAE,SAAA,4DAAAP,IAAA,gBAAAF,MAAA,GAAAU,MAAA,EAAAT,KAAA;AAEnF,MAAMU,mBAAmB,CAA8B;EAAAC,YAAA;IAAAvB,eAAA,iBACnD,CAAC;MAAEwB;IAAkC,CAAC,KAAK;MAClD,oBAAOhC,MAAA,GAAAO,OAAA,CAAA0B,aAAA,CAAC7B,YAAA,GAAA8B,uBAAuB;QAACC,MAAM,EAAEH,SAAS,CAACG,MAAO;QAACC,WAAW,EAAEJ,SAAS,CAACI;MAAY,CAAE,CAAC;IAClG,CAAC;EAAA;AACH;AAACC,OAAA,CAAAP,mBAAA,GAAAA,mBAAA"}
@@ -1,19 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- require("core-js/modules/es.array.iterator.js");
5
- require("core-js/modules/es.promise.js");
6
3
  Object.defineProperty(exports, "__esModule", {
7
4
  value: true
8
5
  });
9
6
  exports.default = void 0;
10
- function _defineProperty2() {
11
- const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- _defineProperty2 = function () {
13
- return data;
14
- };
15
- return data;
16
- }
17
7
  function _path() {
18
8
  const data = _interopRequireDefault(require("path"));
19
9
  _path = function () {
@@ -35,17 +25,21 @@ function _constants() {
35
25
  };
36
26
  return data;
37
27
  }
28
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
31
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
38
32
  // From the cli we might get those as string in case we run it like --propagate true (return string) as opposed to only --propagate
39
33
 
40
34
  class EjectConfCmd {
41
35
  constructor(workspace) {
42
36
  this.workspace = workspace;
43
- (0, _defineProperty2().default)(this, "name", 'eject-conf <pattern>');
44
- (0, _defineProperty2().default)(this, "description", 'eject components configuration (create a `component.json` file)');
45
- (0, _defineProperty2().default)(this, "extendedDescription", `note this can be reversed at any time by snapping/tagging changes and deleting the component.json file \n${(0, _constants().PATTERN_HELP)('eject-conf')}`);
46
- (0, _defineProperty2().default)(this, "alias", '');
47
- (0, _defineProperty2().default)(this, "group", 'development');
48
- (0, _defineProperty2().default)(this, "options", [['p', 'propagate', 'mark propagate true in the config file, so that component.json configs will be merge with workspace configs'], ['o', 'override', 'override file if exist']]);
37
+ _defineProperty(this, "name", 'eject-conf <pattern>');
38
+ _defineProperty(this, "description", 'eject components configuration (create a `component.json` file)');
39
+ _defineProperty(this, "extendedDescription", `note this can be reversed at any time by snapping/tagging changes and deleting the component.json file \n${(0, _constants().PATTERN_HELP)('eject-conf')}`);
40
+ _defineProperty(this, "alias", '');
41
+ _defineProperty(this, "group", 'development');
42
+ _defineProperty(this, "options", [['p', 'propagate', 'mark propagate true in the config file, so that component.json configs will be merge with workspace configs'], ['o', 'override', 'override file if exist']]);
49
43
  }
50
44
  async report(args, options) {
51
45
  const ejectResult = await this.json(args, options);
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","_interopRequireDefault","require","_chalk","_constants","EjectConfCmd","constructor","workspace","_defineProperty2","default","PATTERN_HELP","report","args","options","ejectResult","json","paths","map","result","configPath","p","path","relative","join","chalk","green","bold","pattern","ejectOptions","propagate","override","componentIds","idsByPattern","results","ejectMultipleConfigs","exports"],"sources":["eject-conf.cmd.ts"],"sourcesContent":["import path from 'path';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { PATTERN_HELP } from '@teambit/legacy/dist/constants';\n\nimport { EjectConfOptions, EjectConfResult, Workspace } from './workspace';\n\ntype EjectConfArgs = [string];\n// From the cli we might get those as string in case we run it like --propagate true (return string) as opposed to only --propagate\ntype EjectConfOptionsCLI = {\n propagate: string | boolean | undefined;\n override: string | boolean | undefined;\n};\n\nexport default class EjectConfCmd implements Command {\n name = 'eject-conf <pattern>';\n description = 'eject components configuration (create a `component.json` file)';\n extendedDescription = `note this can be reversed at any time by snapping/tagging changes and deleting the component.json file \\n${PATTERN_HELP(\n 'eject-conf'\n )}`;\n alias = '';\n group = 'development';\n options = [\n [\n 'p',\n 'propagate',\n 'mark propagate true in the config file, so that component.json configs will be merge with workspace configs',\n ],\n ['o', 'override', 'override file if exist'],\n ] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report(args: EjectConfArgs, options: EjectConfOptionsCLI): Promise<string> {\n const ejectResult = await this.json(args, options);\n const paths = ejectResult\n .map((result) => result.configPath)\n .map((p) => path.relative(this.workspace.path, p))\n .join('\\n');\n return chalk.green(`successfully ejected config to the following path(s)\n${chalk.bold(paths)}`);\n }\n\n async json([pattern]: EjectConfArgs, options: EjectConfOptionsCLI): Promise<EjectConfResult[]> {\n const ejectOptions = options;\n if (ejectOptions.propagate === 'true') {\n ejectOptions.propagate = true;\n }\n if (ejectOptions.override === 'true') {\n ejectOptions.override = true;\n }\n\n const componentIds = await this.workspace.idsByPattern(pattern);\n const results = await this.workspace.ejectMultipleConfigs(componentIds, ejectOptions as EjectConfOptions);\n return results;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,OAAA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AACV,KAAK,CAAE,EAAC,CAAC;EACpB;EAEA,MAAMD,IAAIA,CAAC,CAACY,OAAO,CAAgB,EAAEd,OAA4B,EAA8B;IAC7F,MAAMe,YAAY,GAAGf,OAAO;IAC5B,IAAIe,YAAY,CAACC,SAAS,KAAK,MAAM,EAAE;MACrCD,YAAY,CAACC,SAAS,GAAG,IAAI;IAC/B;IACA,IAAID,YAAY,CAACE,QAAQ,KAAK,MAAM,EAAE;MACpCF,YAAY,CAACE,QAAQ,GAAG,IAAI;IAC9B;IAEA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACxB,SAAS,CAACyB,YAAY,CAACL,OAAO,CAAC;IAC/D,MAAMM,OAAO,GAAG,MAAM,IAAI,CAAC1B,SAAS,CAAC2B,oBAAoB,CAACH,YAAY,EAAEH,YAAgC,CAAC;IACzG,OAAOK,OAAO;EAChB;AACF;AAACE,OAAA,CAAA1B,OAAA,GAAAJ,YAAA"}
1
+ {"version":3,"names":["_path","data","_interopRequireDefault","require","_chalk","_constants","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","EjectConfCmd","constructor","workspace","PATTERN_HELP","report","args","options","ejectResult","json","paths","map","result","configPath","p","path","relative","join","chalk","green","bold","pattern","ejectOptions","propagate","override","componentIds","idsByPattern","results","ejectMultipleConfigs","exports"],"sources":["eject-conf.cmd.ts"],"sourcesContent":["import path from 'path';\nimport { Command, CommandOptions } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { PATTERN_HELP } from '@teambit/legacy/dist/constants';\n\nimport { EjectConfOptions, EjectConfResult, Workspace } from './workspace';\n\ntype EjectConfArgs = [string];\n// From the cli we might get those as string in case we run it like --propagate true (return string) as opposed to only --propagate\ntype EjectConfOptionsCLI = {\n propagate: string | boolean | undefined;\n override: string | boolean | undefined;\n};\n\nexport default class EjectConfCmd implements Command {\n name = 'eject-conf <pattern>';\n description = 'eject components configuration (create a `component.json` file)';\n extendedDescription = `note this can be reversed at any time by snapping/tagging changes and deleting the component.json file \\n${PATTERN_HELP(\n 'eject-conf'\n )}`;\n alias = '';\n group = 'development';\n options = [\n [\n 'p',\n 'propagate',\n 'mark propagate true in the config file, so that component.json configs will be merge with workspace configs',\n ],\n ['o', 'override', 'override file if exist'],\n ] as CommandOptions;\n\n constructor(private workspace: Workspace) {}\n\n async report(args: EjectConfArgs, options: EjectConfOptionsCLI): Promise<string> {\n const ejectResult = await this.json(args, options);\n const paths = ejectResult\n .map((result) => result.configPath)\n .map((p) => path.relative(this.workspace.path, p))\n .join('\\n');\n return chalk.green(`successfully ejected config to the following path(s)\n${chalk.bold(paths)}`);\n }\n\n async json([pattern]: EjectConfArgs, options: EjectConfOptionsCLI): Promise<EjectConfResult[]> {\n const ejectOptions = options;\n if (ejectOptions.propagate === 'true') {\n ejectOptions.propagate = true;\n }\n if (ejectOptions.override === 'true') {\n ejectOptions.override = true;\n }\n\n const componentIds = await this.workspace.idsByPattern(pattern);\n const results = await this.workspace.ejectMultipleConfigs(componentIds, ejectOptions as EjectConfOptions);\n return results;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8D,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAA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AA4B,EAAmB;IAC/E,MAAMC,WAAW,GAAG,MAAM,IAAI,CAACC,IAAI,CAACH,IAAI,EAAEC,OAAO,CAAC;IAClD,MAAMG,KAAK,GAAGF,WAAW,CACtBG,GAAG,CAAEC,MAAM,IAAKA,MAAM,CAACC,UAAU,CAAC,CAClCF,GAAG,CAAEG,CAAC,IAAKC,eAAI,CAACC,QAAQ,CAAC,IAAI,CAACb,SAAS,CAACY,IAAI,EAAED,CAAC,CAAC,CAAC,CACjDG,IAAI,CAAC,IAAI,CAAC;IACb,OAAOC,gBAAK,CAACC,KAAK,CAAE;AACxB,EAAED,gBAAK,CAACE,IAAI,CAACV,KAAK,CAAE,EAAC,CAAC;EACpB;EAEA,MAAMD,IAAIA,CAAC,CAACY,OAAO,CAAgB,EAAEd,OAA4B,EAA8B;IAC7F,MAAMe,YAAY,GAAGf,OAAO;IAC5B,IAAIe,YAAY,CAACC,SAAS,KAAK,MAAM,EAAE;MACrCD,YAAY,CAACC,SAAS,GAAG,IAAI;IAC/B;IACA,IAAID,YAAY,CAACE,QAAQ,KAAK,MAAM,EAAE;MACpCF,YAAY,CAACE,QAAQ,GAAG,IAAI;IAC9B;IAEA,MAAMC,YAAY,GAAG,MAAM,IAAI,CAACtB,SAAS,CAACuB,YAAY,CAACL,OAAO,CAAC;IAC/D,MAAMM,OAAO,GAAG,MAAM,IAAI,CAACxB,SAAS,CAACyB,oBAAoB,CAACH,YAAY,EAAEH,YAAgC,CAAC;IACzG,OAAOK,OAAO;EAChB;AACF;AAACE,OAAA,CAAAnD,OAAA,GAAAuB,YAAA"}
@@ -1,19 +1,9 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- require("core-js/modules/es.array.iterator.js");
5
- require("core-js/modules/es.promise.js");
6
3
  Object.defineProperty(exports, "__esModule", {
7
4
  value: true
8
5
  });
9
6
  exports.EnvsReplaceCmd = void 0;
10
- function _defineProperty2() {
11
- const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
- _defineProperty2 = function () {
13
- return data;
14
- };
15
- return data;
16
- }
17
7
  function _chalk() {
18
8
  const data = _interopRequireDefault(require("chalk"));
19
9
  _chalk = function () {
@@ -21,21 +11,25 @@ function _chalk() {
21
11
  };
22
12
  return data;
23
13
  }
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
17
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
24
18
  class EnvsReplaceCmd {
25
19
  constructor(workspace) {
26
20
  this.workspace = workspace;
27
- (0, _defineProperty2().default)(this, "name", 'replace <current-env> <new-env>');
28
- (0, _defineProperty2().default)(this, "description", 'replace an existing env with another env for all components using the old env');
29
- (0, _defineProperty2().default)(this, "options", []);
30
- (0, _defineProperty2().default)(this, "group", 'development');
31
- (0, _defineProperty2().default)(this, "arguments", [{
21
+ _defineProperty(this, "name", 'replace <current-env> <new-env>');
22
+ _defineProperty(this, "description", 'replace an existing env with another env for all components using the old env');
23
+ _defineProperty(this, "options", []);
24
+ _defineProperty(this, "group", 'development');
25
+ _defineProperty(this, "arguments", [{
32
26
  name: 'current-env',
33
27
  description: 'the component id of the env to be replaced'
34
28
  }, {
35
29
  name: 'new-env',
36
30
  description: 'the component id of the new env'
37
31
  }]);
38
- (0, _defineProperty2().default)(this, "examples", [{
32
+ _defineProperty(this, "examples", [{
39
33
  cmd: 'replace teambit.harmony/aspect teambit.harmony/node',
40
34
  description: "components configured to use the 'aspect' env will be configured to use the 'node' env, instead"
41
35
  }]);
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","EnvsReplaceCmd","constructor","workspace","_defineProperty2","default","name","description","cmd","report","oldEnv","env","envId","resolveComponentId","components","getComponentsUsingEnv","componentIds","map","comp","id","setEnvToComponents","chalk","bold","toString","compId","join","exports"],"sources":["envs-replace.cmd.ts"],"sourcesContent":["import { Command } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from '../workspace';\n\nexport class EnvsReplaceCmd implements Command {\n name = 'replace <current-env> <new-env>';\n description = 'replace an existing env with another env for all components using the old env';\n options = [];\n group = 'development';\n arguments = [\n { name: 'current-env', description: 'the component id of the env to be replaced' },\n { name: 'new-env', description: 'the component id of the new env' },\n ];\n examples = [\n {\n cmd: 'replace teambit.harmony/aspect teambit.harmony/node',\n description: \"components configured to use the 'aspect' env will be configured to use the 'node' env, instead\",\n },\n ];\n\n constructor(private workspace: Workspace) {}\n\n async report([oldEnv, env]: [string, string]) {\n const envId = await this.workspace.resolveComponentId(env);\n const components = await this.workspace.getComponentsUsingEnv(oldEnv, true, true);\n const componentIds = components.map((comp) => comp.id);\n await this.workspace.setEnvToComponents(envId, componentIds);\n return `added ${chalk.bold(envId.toString())} env to the following component(s):\n${componentIds.map((compId) => compId.toString()).join('\\n')}`;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AACA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGO,MAAMG,cAAc,CAAoB;EAgB7CC,WAAWA,CAASC,SAAoB,EAAE;IAAA,KAAtBA,SAAoB,GAApBA,SAAoB;IAAA,IAAAC,gBAAA,GAAAC,OAAA,gBAfjC,iCAAiC;IAAA,IAAAD,gBAAA,GAAAC,OAAA,uBAC1B,+EAA+E;IAAA,IAAAD,gBAAA,GAAAC,OAAA,mBACnF,EAAE;IAAA,IAAAD,gBAAA,GAAAC,OAAA,iBACJ,aAAa;IAAA,IAAAD,gBAAA,GAAAC,OAAA,qBACT,CACV;MAAEC,IAAI,EAAE,aAAa;MAAEC,WAAW,EAAE;IAA6C,CAAC,EAClF;MAAED,IAAI,EAAE,SAAS;MAAEC,WAAW,EAAE;IAAkC,CAAC,CACpE;IAAA,IAAAH,gBAAA,GAAAC,OAAA,oBACU,CACT;MACEG,GAAG,EAAE,qDAAqD;MAC1DD,WAAW,EAAE;IACf,CAAC,CACF;EAE0C;EAE3C,MAAME,MAAMA,CAAC,CAACC,MAAM,EAAEC,GAAG,CAAmB,EAAE;IAC5C,MAAMC,KAAK,GAAG,MAAM,IAAI,CAACT,SAAS,CAACU,kBAAkB,CAACF,GAAG,CAAC;IAC1D,MAAMG,UAAU,GAAG,MAAM,IAAI,CAACX,SAAS,CAACY,qBAAqB,CAACL,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC;IACjF,MAAMM,YAAY,GAAGF,UAAU,CAACG,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,EAAE,CAAC;IACtD,MAAM,IAAI,CAAChB,SAAS,CAACiB,kBAAkB,CAACR,KAAK,EAAEI,YAAY,CAAC;IAC5D,OAAQ,SAAQK,gBAAK,CAACC,IAAI,CAACV,KAAK,CAACW,QAAQ,CAAC,CAAC,CAAE;AACjD,EAAEP,YAAY,CAACC,GAAG,CAAEO,MAAM,IAAKA,MAAM,CAACD,QAAQ,CAAC,CAAC,CAAC,CAACE,IAAI,CAAC,IAAI,CAAE,EAAC;EAC5D;AACF;AAACC,OAAA,CAAAzB,cAAA,GAAAA,cAAA"}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","arg","_toPrimitive","String","input","hint","prim","Symbol","toPrimitive","undefined","res","call","TypeError","Number","EnvsReplaceCmd","constructor","workspace","name","description","cmd","report","oldEnv","env","envId","resolveComponentId","components","getComponentsUsingEnv","componentIds","map","comp","id","setEnvToComponents","chalk","bold","toString","compId","join","exports"],"sources":["envs-replace.cmd.ts"],"sourcesContent":["import { Command } from '@teambit/cli';\nimport chalk from 'chalk';\nimport { Workspace } from '../workspace';\n\nexport class EnvsReplaceCmd implements Command {\n name = 'replace <current-env> <new-env>';\n description = 'replace an existing env with another env for all components using the old env';\n options = [];\n group = 'development';\n arguments = [\n { name: 'current-env', description: 'the component id of the env to be replaced' },\n { name: 'new-env', description: 'the component id of the new env' },\n ];\n examples = [\n {\n cmd: 'replace teambit.harmony/aspect teambit.harmony/node',\n description: \"components configured to use the 'aspect' env will be configured to use the 'node' env, instead\",\n },\n ];\n\n constructor(private workspace: Workspace) {}\n\n async report([oldEnv, env]: [string, string]) {\n const envId = await this.workspace.resolveComponentId(env);\n const components = await this.workspace.getComponentsUsingEnv(oldEnv, true, true);\n const componentIds = components.map((comp) => comp.id);\n await this.workspace.setEnvToComponents(envId, componentIds);\n return `added ${chalk.bold(envId.toString())} env to the following component(s):\n${componentIds.map((compId) => compId.toString()).join('\\n')}`;\n }\n}\n"],"mappings":";;;;;;AACA,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,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAAA,GAAAE,cAAA,CAAAF,GAAA,OAAAA,GAAA,IAAAJ,GAAA,IAAAO,MAAA,CAAAC,cAAA,CAAAR,GAAA,EAAAI,GAAA,IAAAC,KAAA,EAAAA,KAAA,EAAAI,UAAA,QAAAC,YAAA,QAAAC,QAAA,oBAAAX,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