@teambit/builder 1.0.666 → 1.0.668

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/artifact/artifact-definition.ts +1 -1
  2. package/artifact/artifact-extractor.ts +7 -5
  3. package/artifact/artifact-factory.ts +5 -3
  4. package/artifact/artifact-list.ts +7 -12
  5. package/artifact/artifacts.cmd.ts +5 -4
  6. package/artifact/extension-artifact.ts +1 -1
  7. package/artifact/fs-artifact.ts +1 -1
  8. package/dist/artifact/artifact-definition.d.ts +1 -1
  9. package/dist/artifact/artifact-definition.js.map +1 -1
  10. package/dist/artifact/artifact-extractor.d.ts +4 -4
  11. package/dist/artifact/artifact-extractor.js.map +1 -1
  12. package/dist/artifact/artifact-factory.d.ts +3 -2
  13. package/dist/artifact/artifact-factory.js.map +1 -1
  14. package/dist/artifact/artifact-list.d.ts +4 -5
  15. package/dist/artifact/artifact-list.js.map +1 -1
  16. package/dist/artifact/artifacts.cmd.d.ts +3 -3
  17. package/dist/artifact/artifacts.cmd.js.map +1 -1
  18. package/dist/artifact/extension-artifact.d.ts +1 -1
  19. package/dist/artifact/extension-artifact.js.map +1 -1
  20. package/dist/artifact/fs-artifact.d.ts +1 -1
  21. package/dist/artifact/fs-artifact.js.map +1 -1
  22. package/dist/build-pipe.d.ts +8 -8
  23. package/dist/build-pipe.js.map +1 -1
  24. package/dist/build-pipeline-order.d.ts +2 -2
  25. package/dist/build-pipeline-order.js.map +1 -1
  26. package/dist/build-pipeline-result-list.d.ts +3 -3
  27. package/dist/build-pipeline-result-list.js.map +1 -1
  28. package/dist/build-task.d.ts +5 -5
  29. package/dist/build-task.js.map +1 -1
  30. package/dist/build.cmd.d.ts +4 -4
  31. package/dist/build.cmd.js.map +1 -1
  32. package/dist/builder-env-type.d.ts +1 -1
  33. package/dist/builder-env-type.js.map +1 -1
  34. package/dist/builder.graphql.d.ts +4 -4
  35. package/dist/builder.graphql.js.map +1 -1
  36. package/dist/builder.main.runtime.d.ts +23 -21
  37. package/dist/builder.main.runtime.js.map +1 -1
  38. package/dist/builder.route.d.ts +4 -4
  39. package/dist/builder.route.js.map +1 -1
  40. package/dist/builder.service.d.ts +11 -11
  41. package/dist/builder.service.js.map +1 -1
  42. package/dist/exceptions/capsule-not-found.d.ts +1 -1
  43. package/dist/exceptions/capsule-not-found.js.map +1 -1
  44. package/dist/exceptions/components-have-issues.d.ts +1 -1
  45. package/dist/exceptions/components-have-issues.js.map +1 -1
  46. package/dist/pipeline.d.ts +3 -3
  47. package/dist/pipeline.js.map +1 -1
  48. package/dist/{preview-1753803956605.js → preview-1753833698619.js} +2 -2
  49. package/dist/storage/default-resolver.d.ts +3 -3
  50. package/dist/storage/default-resolver.js.map +1 -1
  51. package/dist/storage/storage-resolver.d.ts +3 -3
  52. package/dist/storage/storage-resolver.js.map +1 -1
  53. package/dist/task-results-list.d.ts +3 -3
  54. package/dist/task-results-list.js.map +1 -1
  55. package/dist/task.d.ts +2 -2
  56. package/dist/task.js.map +1 -1
  57. package/dist/tasks-queue.d.ts +2 -2
  58. package/dist/tasks-queue.js.map +1 -1
  59. package/dist/templates/build-task/files/index-file.d.ts +1 -1
  60. package/dist/templates/build-task/files/index-file.js.map +1 -1
  61. package/dist/templates/build-task/files/task-file.d.ts +1 -1
  62. package/dist/templates/build-task/files/task-file.js.map +1 -1
  63. package/dist/templates/build-task/index.d.ts +1 -1
  64. package/dist/templates/build-task/index.js.map +1 -1
  65. package/dist/types.d.ts +1 -1
  66. package/dist/types.js.map +1 -1
  67. package/exceptions/capsule-not-found.ts +1 -1
  68. package/exceptions/components-have-issues.ts +1 -1
  69. package/package.json +21 -21
  70. package/storage/default-resolver.ts +3 -3
  71. package/storage/storage-resolver.ts +3 -3
  72. package/templates/build-task/files/index-file.ts +1 -1
  73. package/templates/build-task/files/task-file.ts +1 -1
  74. package/templates/build-task/index.ts +1 -1
@@ -1 +1 @@
1
- {"version":3,"names":["_graph","data","require","_tester","_buildTask","_tasksQueue","calculatePipelineOrder","taskSlot","envs","pipeNameOnEnv","tasks","skipTests","skipTasks","graphs","locations","forEach","location","push","graph","Graph","pipelineEnvs","envDefinition","pipeline","getPipelineForEnv","env","flattenedPipeline","map","pipelineEnv","flat","task","addDependenciesToGraph","dataPerLocation","pipelineEnvsPerLocation","filter","tasksQueue","TasksQueue","addTasksToGraph","length","includes","name","aspectId","TesterAspect","id","find","d","sorted","toposort","taskNode","BuildTaskHelper","deserializeId","attr","taskIndex","findIndex","pipelineTask","splice","dependencies","taskId","serializeId","dependency","deserializeIdAllowEmptyName","dependencyTasks","Error","dependencyTask","getLocation","graphLocation","g","dependencyId","setNode","Node","setEdge","Edge","taskLocation","dependencyLocation","isDependencyAhead","isDependencyEqual","buildTasks","slotsTasks","values","tasksAtStart","tasksAtEnd","mergedTasks"],"sources":["build-pipeline-order.ts"],"sourcesContent":["import { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { TesterAspect } from '@teambit/tester';\nimport { EnvDefinition, Environment } from '@teambit/envs';\nimport { BuildTask, BuildTaskHelper } from './build-task';\nimport type { TaskSlot } from './builder.main.runtime';\nimport { TasksQueue } from './tasks-queue';\nimport { PipeFunctionNames } from './builder.service';\n\ntype TaskDependenciesGraph = Graph<string, string>;\ntype Location = 'start' | 'middle' | 'end';\ntype TasksLocationGraph = { location: Location; graph: TaskDependenciesGraph };\ntype PipelineEnv = { env: EnvDefinition; pipeline: BuildTask[] };\ntype DataPerLocation = { location: Location; graph: TaskDependenciesGraph; pipelineEnvs: PipelineEnv[] };\n\n/**\n * there are two ways how to add tasks to build pipeline.\n * 1. `getBuildPipe()` method of the env.\n * 2. registering to the `builder.registerBuildTask()`.\n *\n * in the option #1, it's possible to determine the order. e.g. `getBuildPipe() { return [taskA, taskB, taskC]; }`\n * in the option #2, the register happens once the extension is loaded, so there is no way to put\n * one task before/after another task.\n *\n * To be able to determine the order, you can do the following\n * 1. \"task.location\", it has two options \"start\" and \"end\". the rest are \"middle\".\n * 2. \"task.dependencies\", the dependencies must be completed for all envs before this task starts.\n * the dependencies are applicable inside a location and not across locations. see getLocation()\n * or/and continue reading for more info about this.\n *\n * to determine the final order of the tasks, the following is done:\n * 1. split all tasks to three groups: start, middle and end.\n * 2. for each group define a dependencies graph for the tasks with \"dependencies\" prop and the pipeline.\n * 3. start with the first group \"start\", toposort the dependencies graph and push the found tasks\n * to a queue. once completed, iterate the pipeline and add all tasks to the queue.\n * 4. do the same for the \"middle\" and \"end\" groups.\n *\n * the reason for splitting the tasks to the three groups and not using the \"dependencies\" field\n * alone to determine the order is that the \"start\" and \"end\" groups are mostly core and \"middle\"\n * is mostly the user entering tasks to the pipeline and we as the core don't know about the users\n * tasks. For example, a core task \"PublishComponent\" must happen after the compiler, however, a\n * user might have an env without a compiler. if we determine the order only by the dependencies\n * field, the \"PublishComponent\" would have a dependency \"compiler\" and because in this case there\n * is no compiler task, it would throw an error about missing dependencies.\n */\nexport function calculatePipelineOrder(\n taskSlot: TaskSlot,\n envs: EnvDefinition[],\n pipeNameOnEnv: PipeFunctionNames,\n tasks: string[] = [],\n skipTests = false,\n skipTasks: string[] = []\n): TasksQueue {\n const graphs: TasksLocationGraph[] = [];\n const locations: Location[] = ['start', 'middle', 'end']; // the order is important here!\n locations.forEach((location) => {\n graphs.push({ location, graph: new Graph<string, string>() });\n });\n const pipelineEnvs: PipelineEnv[] = [];\n envs.forEach((envDefinition) => {\n const pipeline = getPipelineForEnv(taskSlot, envDefinition.env, pipeNameOnEnv);\n pipelineEnvs.push({ env: envDefinition, pipeline });\n });\n\n const flattenedPipeline: BuildTask[] = pipelineEnvs.map((pipelineEnv) => pipelineEnv.pipeline).flat();\n flattenedPipeline.forEach((task) => addDependenciesToGraph(graphs, flattenedPipeline, task));\n\n const dataPerLocation: DataPerLocation[] = graphs.map(({ location, graph }) => {\n const pipelineEnvsPerLocation: PipelineEnv[] = pipelineEnvs.map(({ env, pipeline }) => {\n return { env, pipeline: pipeline.filter((task) => (task.location || 'middle') === location) };\n });\n return { location, graph, pipelineEnvs: pipelineEnvsPerLocation };\n });\n\n let tasksQueue = new TasksQueue();\n locations.forEach((location) => addTasksToGraph(tasksQueue, dataPerLocation, location));\n if (tasks.length) {\n tasksQueue = new TasksQueue(\n ...tasksQueue.filter(({ task }) => tasks.includes(task.name) || tasks.includes(task.aspectId))\n );\n }\n if (skipTests) {\n tasksQueue = new TasksQueue(...tasksQueue.filter(({ task }) => task.aspectId !== TesterAspect.id));\n }\n if (skipTasks.length) {\n tasksQueue = new TasksQueue(\n ...tasksQueue.filter(({ task }) => !skipTasks.includes(task.name) && !skipTasks.includes(task.aspectId))\n );\n }\n\n return tasksQueue;\n}\n\nfunction addTasksToGraph(tasksQueue: TasksQueue, dataPerLocation: DataPerLocation[], location: Location) {\n const data = dataPerLocation.find((d) => d.location === location);\n if (!data) return;\n const sorted = data.graph.toposort();\n sorted.forEach((taskNode) => {\n const { aspectId, name } = BuildTaskHelper.deserializeId(taskNode.attr);\n data.pipelineEnvs.forEach(({ env, pipeline }) => {\n const taskIndex = pipeline.findIndex(\n (pipelineTask) => pipelineTask.aspectId === aspectId && pipelineTask.name === name\n );\n if (taskIndex < 0) return;\n const task = pipeline[taskIndex];\n tasksQueue.push({ env, task });\n pipeline.splice(taskIndex, 1); // delete the task from the pipeline\n });\n });\n data.pipelineEnvs.forEach(({ env, pipeline }) => {\n pipeline.forEach((task) => tasksQueue.push({ env, task }));\n });\n}\n\nfunction addDependenciesToGraph(graphs: TasksLocationGraph[], pipeline: BuildTask[], task: BuildTask) {\n if (!task.dependencies || !task.dependencies.length) return;\n const taskId = BuildTaskHelper.serializeId(task);\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n const dependencyTasks = pipeline.filter((pipelineTask) => {\n if (pipelineTask.aspectId !== aspectId) return false;\n return name ? name === pipelineTask.name : true;\n });\n if (dependencyTasks.length === 0) {\n throw new Error(\n `Pipeline error - missing task dependency \"${dependency}\" of the \"${BuildTaskHelper.serializeId(task)}\"`\n );\n }\n dependencyTasks.forEach((dependencyTask) => {\n const location = getLocation(task, dependencyTask);\n if (!location) {\n // the dependency is behind and will be in the correct order regardless the graph.\n return;\n }\n const graphLocation = graphs.find((g) => g.location === location);\n if (!graphLocation) throw new Error(`unable to find graph for location ${location}`);\n const dependencyId = BuildTaskHelper.serializeId(dependencyTask);\n const graph = graphLocation.graph;\n graph.setNode(new Node(taskId, taskId));\n graph.setNode(new Node(dependencyId, dependencyId));\n graph.setEdge(new Edge(dependencyId, taskId, 'dependency'));\n });\n });\n}\n\n/**\n * since the task execution is happening per group: \"start\", \"middle\" and \"end\", the dependencies\n * need to be inside the same group.\n * e.g. if a dependency located at \"end\" group and the task located at \"start\", it's impossible to\n * complete the dependency before the task, there it throws an error.\n * it's ok to have the dependency located earlier, e.g. \"start\" and the task at \"end\", and in this\n * case, it will not be part of the graph because there is no need to do any special calculation.\n */\nfunction getLocation(task: BuildTask, dependencyTask: BuildTask): Location | null {\n const taskLocation = task.location || 'middle';\n const dependencyLocation = dependencyTask.location || 'middle';\n\n const isDependencyAhead =\n (taskLocation === 'start' && dependencyLocation !== 'start') ||\n (taskLocation === 'middle' && dependencyLocation === 'end');\n\n const isDependencyEqual = taskLocation === dependencyLocation;\n\n if (isDependencyAhead) {\n throw new Error(`a task \"${BuildTaskHelper.serializeId(task)}\" located at ${taskLocation}\nhas a dependency \"${BuildTaskHelper.serializeId(dependencyTask)} located at ${dependencyLocation},\nwhich is invalid. the dependency must be located earlier or in the same location as the task\"`);\n }\n\n if (isDependencyEqual) {\n return taskLocation;\n }\n\n // dependency is behind. e.g. task is \"end\" and dependency is \"start\". no need to enter to the\n // graph as it's going to be executed in the right order regardless the graph.\n return null;\n}\n\nfunction getPipelineForEnv(taskSlot: TaskSlot, env: Environment, pipeNameOnEnv: string): BuildTask[] {\n const buildTasks: BuildTask[] = env[pipeNameOnEnv] ? env[pipeNameOnEnv]() : [];\n const slotsTasks = taskSlot.values().flat();\n const tasksAtStart: BuildTask[] = [];\n const tasksAtEnd: BuildTask[] = [];\n slotsTasks.forEach((task) => {\n if (task.location === 'start') {\n tasksAtStart.push(task);\n return;\n }\n if (task.location === 'end') {\n tasksAtEnd.push(task);\n return;\n }\n tasksAtStart.push(task);\n });\n\n // merge with extension registered tasks.\n const mergedTasks = [...tasksAtStart, ...buildTasks, ...tasksAtEnd];\n\n return mergedTasks;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,sBAAsBA,CACpCC,QAAkB,EAClBC,IAAqB,EACrBC,aAAgC,EAChCC,KAAe,GAAG,EAAE,EACpBC,SAAS,GAAG,KAAK,EACjBC,SAAmB,GAAG,EAAE,EACZ;EACZ,MAAMC,MAA4B,GAAG,EAAE;EACvC,MAAMC,SAAqB,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC;EAC1DA,SAAS,CAACC,OAAO,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ACA,MAAMmD,WAAW,GAAG,CAAC,GAAGF,YAAY,EAAE,GAAGH,UAAU,EAAE,GAAGI,UAAU,CAAC;EAEnE,OAAOC,WAAW;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["_graph","data","require","_tester","_buildTask","_tasksQueue","calculatePipelineOrder","taskSlot","envs","pipeNameOnEnv","tasks","skipTests","skipTasks","graphs","locations","forEach","location","push","graph","Graph","pipelineEnvs","envDefinition","pipeline","getPipelineForEnv","env","flattenedPipeline","map","pipelineEnv","flat","task","addDependenciesToGraph","dataPerLocation","pipelineEnvsPerLocation","filter","tasksQueue","TasksQueue","addTasksToGraph","length","includes","name","aspectId","TesterAspect","id","find","d","sorted","toposort","taskNode","BuildTaskHelper","deserializeId","attr","taskIndex","findIndex","pipelineTask","splice","dependencies","taskId","serializeId","dependency","deserializeIdAllowEmptyName","dependencyTasks","Error","dependencyTask","getLocation","graphLocation","g","dependencyId","setNode","Node","setEdge","Edge","taskLocation","dependencyLocation","isDependencyAhead","isDependencyEqual","buildTasks","slotsTasks","values","tasksAtStart","tasksAtEnd","mergedTasks"],"sources":["build-pipeline-order.ts"],"sourcesContent":["import { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { TesterAspect } from '@teambit/tester';\nimport type { EnvDefinition, Environment } from '@teambit/envs';\nimport type { BuildTask } from './build-task';\nimport { BuildTaskHelper } from './build-task';\nimport type { TaskSlot } from './builder.main.runtime';\nimport { TasksQueue } from './tasks-queue';\nimport type { PipeFunctionNames } from './builder.service';\n\ntype TaskDependenciesGraph = Graph<string, string>;\ntype Location = 'start' | 'middle' | 'end';\ntype TasksLocationGraph = { location: Location; graph: TaskDependenciesGraph };\ntype PipelineEnv = { env: EnvDefinition; pipeline: BuildTask[] };\ntype DataPerLocation = { location: Location; graph: TaskDependenciesGraph; pipelineEnvs: PipelineEnv[] };\n\n/**\n * there are two ways how to add tasks to build pipeline.\n * 1. `getBuildPipe()` method of the env.\n * 2. registering to the `builder.registerBuildTask()`.\n *\n * in the option #1, it's possible to determine the order. e.g. `getBuildPipe() { return [taskA, taskB, taskC]; }`\n * in the option #2, the register happens once the extension is loaded, so there is no way to put\n * one task before/after another task.\n *\n * To be able to determine the order, you can do the following\n * 1. \"task.location\", it has two options \"start\" and \"end\". the rest are \"middle\".\n * 2. \"task.dependencies\", the dependencies must be completed for all envs before this task starts.\n * the dependencies are applicable inside a location and not across locations. see getLocation()\n * or/and continue reading for more info about this.\n *\n * to determine the final order of the tasks, the following is done:\n * 1. split all tasks to three groups: start, middle and end.\n * 2. for each group define a dependencies graph for the tasks with \"dependencies\" prop and the pipeline.\n * 3. start with the first group \"start\", toposort the dependencies graph and push the found tasks\n * to a queue. once completed, iterate the pipeline and add all tasks to the queue.\n * 4. do the same for the \"middle\" and \"end\" groups.\n *\n * the reason for splitting the tasks to the three groups and not using the \"dependencies\" field\n * alone to determine the order is that the \"start\" and \"end\" groups are mostly core and \"middle\"\n * is mostly the user entering tasks to the pipeline and we as the core don't know about the users\n * tasks. For example, a core task \"PublishComponent\" must happen after the compiler, however, a\n * user might have an env without a compiler. if we determine the order only by the dependencies\n * field, the \"PublishComponent\" would have a dependency \"compiler\" and because in this case there\n * is no compiler task, it would throw an error about missing dependencies.\n */\nexport function calculatePipelineOrder(\n taskSlot: TaskSlot,\n envs: EnvDefinition[],\n pipeNameOnEnv: PipeFunctionNames,\n tasks: string[] = [],\n skipTests = false,\n skipTasks: string[] = []\n): TasksQueue {\n const graphs: TasksLocationGraph[] = [];\n const locations: Location[] = ['start', 'middle', 'end']; // the order is important here!\n locations.forEach((location) => {\n graphs.push({ location, graph: new Graph<string, string>() });\n });\n const pipelineEnvs: PipelineEnv[] = [];\n envs.forEach((envDefinition) => {\n const pipeline = getPipelineForEnv(taskSlot, envDefinition.env, pipeNameOnEnv);\n pipelineEnvs.push({ env: envDefinition, pipeline });\n });\n\n const flattenedPipeline: BuildTask[] = pipelineEnvs.map((pipelineEnv) => pipelineEnv.pipeline).flat();\n flattenedPipeline.forEach((task) => addDependenciesToGraph(graphs, flattenedPipeline, task));\n\n const dataPerLocation: DataPerLocation[] = graphs.map(({ location, graph }) => {\n const pipelineEnvsPerLocation: PipelineEnv[] = pipelineEnvs.map(({ env, pipeline }) => {\n return { env, pipeline: pipeline.filter((task) => (task.location || 'middle') === location) };\n });\n return { location, graph, pipelineEnvs: pipelineEnvsPerLocation };\n });\n\n let tasksQueue = new TasksQueue();\n locations.forEach((location) => addTasksToGraph(tasksQueue, dataPerLocation, location));\n if (tasks.length) {\n tasksQueue = new TasksQueue(\n ...tasksQueue.filter(({ task }) => tasks.includes(task.name) || tasks.includes(task.aspectId))\n );\n }\n if (skipTests) {\n tasksQueue = new TasksQueue(...tasksQueue.filter(({ task }) => task.aspectId !== TesterAspect.id));\n }\n if (skipTasks.length) {\n tasksQueue = new TasksQueue(\n ...tasksQueue.filter(({ task }) => !skipTasks.includes(task.name) && !skipTasks.includes(task.aspectId))\n );\n }\n\n return tasksQueue;\n}\n\nfunction addTasksToGraph(tasksQueue: TasksQueue, dataPerLocation: DataPerLocation[], location: Location) {\n const data = dataPerLocation.find((d) => d.location === location);\n if (!data) return;\n const sorted = data.graph.toposort();\n sorted.forEach((taskNode) => {\n const { aspectId, name } = BuildTaskHelper.deserializeId(taskNode.attr);\n data.pipelineEnvs.forEach(({ env, pipeline }) => {\n const taskIndex = pipeline.findIndex(\n (pipelineTask) => pipelineTask.aspectId === aspectId && pipelineTask.name === name\n );\n if (taskIndex < 0) return;\n const task = pipeline[taskIndex];\n tasksQueue.push({ env, task });\n pipeline.splice(taskIndex, 1); // delete the task from the pipeline\n });\n });\n data.pipelineEnvs.forEach(({ env, pipeline }) => {\n pipeline.forEach((task) => tasksQueue.push({ env, task }));\n });\n}\n\nfunction addDependenciesToGraph(graphs: TasksLocationGraph[], pipeline: BuildTask[], task: BuildTask) {\n if (!task.dependencies || !task.dependencies.length) return;\n const taskId = BuildTaskHelper.serializeId(task);\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n const dependencyTasks = pipeline.filter((pipelineTask) => {\n if (pipelineTask.aspectId !== aspectId) return false;\n return name ? name === pipelineTask.name : true;\n });\n if (dependencyTasks.length === 0) {\n throw new Error(\n `Pipeline error - missing task dependency \"${dependency}\" of the \"${BuildTaskHelper.serializeId(task)}\"`\n );\n }\n dependencyTasks.forEach((dependencyTask) => {\n const location = getLocation(task, dependencyTask);\n if (!location) {\n // the dependency is behind and will be in the correct order regardless the graph.\n return;\n }\n const graphLocation = graphs.find((g) => g.location === location);\n if (!graphLocation) throw new Error(`unable to find graph for location ${location}`);\n const dependencyId = BuildTaskHelper.serializeId(dependencyTask);\n const graph = graphLocation.graph;\n graph.setNode(new Node(taskId, taskId));\n graph.setNode(new Node(dependencyId, dependencyId));\n graph.setEdge(new Edge(dependencyId, taskId, 'dependency'));\n });\n });\n}\n\n/**\n * since the task execution is happening per group: \"start\", \"middle\" and \"end\", the dependencies\n * need to be inside the same group.\n * e.g. if a dependency located at \"end\" group and the task located at \"start\", it's impossible to\n * complete the dependency before the task, there it throws an error.\n * it's ok to have the dependency located earlier, e.g. \"start\" and the task at \"end\", and in this\n * case, it will not be part of the graph because there is no need to do any special calculation.\n */\nfunction getLocation(task: BuildTask, dependencyTask: BuildTask): Location | null {\n const taskLocation = task.location || 'middle';\n const dependencyLocation = dependencyTask.location || 'middle';\n\n const isDependencyAhead =\n (taskLocation === 'start' && dependencyLocation !== 'start') ||\n (taskLocation === 'middle' && dependencyLocation === 'end');\n\n const isDependencyEqual = taskLocation === dependencyLocation;\n\n if (isDependencyAhead) {\n throw new Error(`a task \"${BuildTaskHelper.serializeId(task)}\" located at ${taskLocation}\nhas a dependency \"${BuildTaskHelper.serializeId(dependencyTask)} located at ${dependencyLocation},\nwhich is invalid. the dependency must be located earlier or in the same location as the task\"`);\n }\n\n if (isDependencyEqual) {\n return taskLocation;\n }\n\n // dependency is behind. e.g. task is \"end\" and dependency is \"start\". no need to enter to the\n // graph as it's going to be executed in the right order regardless the graph.\n return null;\n}\n\nfunction getPipelineForEnv(taskSlot: TaskSlot, env: Environment, pipeNameOnEnv: string): BuildTask[] {\n const buildTasks: BuildTask[] = env[pipeNameOnEnv] ? env[pipeNameOnEnv]() : [];\n const slotsTasks = taskSlot.values().flat();\n const tasksAtStart: BuildTask[] = [];\n const tasksAtEnd: BuildTask[] = [];\n slotsTasks.forEach((task) => {\n if (task.location === 'start') {\n tasksAtStart.push(task);\n return;\n }\n if (task.location === 'end') {\n tasksAtEnd.push(task);\n return;\n }\n tasksAtStart.push(task);\n });\n\n // merge with extension registered tasks.\n const mergedTasks = [...tasksAtStart, ...buildTasks, ...tasksAtEnd];\n\n return mergedTasks;\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,sBAAsBA,CACpCC,QAAkB,EAClBC,IAAqB,EACrBC,aAAgC,EAChCC,KAAe,GAAG,EAAE,EACpBC,SAAS,GAAG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IACA,IAAIA,IAAI,CAACb,QAAQ,KAAK,KAAK,EAAE;MAC3B+D,UAAU,CAAC9D,IAAI,CAACY,IAAI,CAAC;MACrB;IACF;IACAiD,YAAY,CAAC7D,IAAI,CAACY,IAAI,CAAC;EACzB,CAAC,CAAC;;EAEF;EACA,MAAMmD,WAAW,GAAG,CAAC,GAAGF,YAAY,EAAE,GAAGH,UAAU,EAAE,GAAGI,UAAU,CAAC;EAEnE,OAAOC,WAAW;AACpB","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { ComponentID, Component } from '@teambit/component';
1
+ import type { ComponentID, Component } from '@teambit/component';
2
2
  import type { ArtifactObject } from '@teambit/component.sources';
3
- import { TaskResults } from './build-pipe';
4
- import { TaskMetadata } from './types';
3
+ import type { TaskResults } from './build-pipe';
4
+ import type { TaskMetadata } from './types';
5
5
  export type PipelineReport = {
6
6
  taskId: string;
7
7
  taskName: string;
@@ -1 +1 @@
1
- {"version":3,"names":["_component","data","require","_lodash","_artifact","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipelineResultList","constructor","tasksResults","components","artifactListsMap","getFlattenedArtifactListsMapFromAllTasks","artifactListsMaps","flatMap","artifacts","ComponentMap","as","component","artifactListMap","artifactList","getValueByComponentId","id","ArtifactList","fromArray","getMetadataFromTaskResults","componentId","compResults","reduce","acc","current","foundComponent","componentsResults","find","c","isEqual","taskId","task","aspectId","metadata","mergeDataIfPossible","getPipelineReportOfComponent","map","taskResults","pipelineReport","taskName","name","taskDescription","description","errors","warnings","startTime","endTime","compact","getDataOfComponent","tasksData","getArtifactsDataOfComponent","toObject","currentData","existingData","isEmpty","Error","Array","isArray","exports"],"sources":["build-pipeline-result-list.ts"],"sourcesContent":["import { ComponentID, ComponentMap, Component } from '@teambit/component';\nimport { isEmpty, compact } from 'lodash';\nimport type { ArtifactObject } from '@teambit/component.sources';\nimport { Artifact, ArtifactList } from './artifact';\nimport { TaskResults } from './build-pipe';\nimport { TaskMetadata } from './types';\n\nexport type PipelineReport = {\n taskId: string; // task aspect-id\n taskName: string;\n taskDescription?: string;\n startTime?: number;\n endTime?: number;\n errors?: Array<Error | string>;\n warnings?: string[];\n};\n\nexport type AspectData = {\n aspectId: string;\n data: TaskMetadata;\n};\n\n/**\n * Helper to get the data and artifacts from the TasksResultsList before saving during the tag\n */\nexport class BuildPipelineResultList {\n private artifactListsMap: ComponentMap<ArtifactList<Artifact>>;\n constructor(\n private tasksResults: TaskResults[],\n private components: Component[]\n ) {\n this.artifactListsMap = this.getFlattenedArtifactListsMapFromAllTasks();\n }\n\n private getFlattenedArtifactListsMapFromAllTasks(): ComponentMap<ArtifactList<Artifact>> {\n const artifactListsMaps = this.tasksResults.flatMap((t) => (t.artifacts ? [t.artifacts] : []));\n return ComponentMap.as<ArtifactList<Artifact>>(this.components, (component) => {\n const artifacts: Artifact[] = [];\n artifactListsMaps.forEach((artifactListMap) => {\n const artifactList = artifactListMap.getValueByComponentId(component.id);\n if (artifactList) artifacts.push(...artifactList);\n });\n return ArtifactList.fromArray(artifacts);\n });\n }\n\n public getMetadataFromTaskResults(componentId: ComponentID): { [taskId: string]: TaskMetadata } {\n const compResults = this.tasksResults.reduce((acc, current: TaskResults) => {\n const foundComponent = current.componentsResults.find((c) => c.component.id.isEqual(componentId));\n const taskId = current.task.aspectId;\n if (foundComponent && foundComponent.metadata) {\n acc[taskId] = this.mergeDataIfPossible(foundComponent.metadata, acc[taskId], taskId);\n }\n return acc;\n }, {});\n return compResults;\n }\n\n public getPipelineReportOfComponent(componentId: ComponentID): PipelineReport[] {\n const compResults = this.tasksResults.map((taskResults: TaskResults) => {\n const foundComponent = taskResults.componentsResults.find((c) => c.component.id.isEqual(componentId));\n if (!foundComponent) return null;\n const pipelineReport: PipelineReport = {\n taskId: taskResults.task.aspectId,\n taskName: taskResults.task.name,\n taskDescription: taskResults.task.description,\n errors: foundComponent.errors,\n warnings: foundComponent.warnings,\n startTime: foundComponent.startTime,\n endTime: foundComponent.endTime,\n };\n return pipelineReport;\n });\n return compact(compResults);\n }\n\n public getDataOfComponent(componentId: ComponentID): AspectData[] {\n const tasksData = this.getMetadataFromTaskResults(componentId);\n return Object.keys(tasksData).map((taskId) => ({\n aspectId: taskId,\n data: tasksData[taskId],\n }));\n }\n\n public getArtifactsDataOfComponent(componentId: ComponentID): ArtifactObject[] | undefined {\n return this.artifactListsMap.getValueByComponentId(componentId)?.toObject();\n }\n\n private mergeDataIfPossible(currentData: TaskMetadata, existingData: TaskMetadata | undefined, taskId: string) {\n if (!existingData || isEmpty(existingData)) return currentData;\n // both exist\n if (typeof currentData !== 'object') {\n throw new Error(`task data must be \"object\", get ${typeof currentData} for ${taskId}`);\n }\n if (Array.isArray(currentData)) {\n throw new Error(`task data must be \"object\", get Array for ${taskId}`);\n }\n return { ...currentData, ...existingData };\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,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAoD,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAA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AOR,cAAc;IACvB,CAAC,CAAC;IACF,OAAO,IAAAS,iBAAO,EAAC1B,WAAW,CAAC;EAC7B;EAEO2B,kBAAkBA,CAAC5B,WAAwB,EAAgB;IAChE,MAAM6B,SAAS,GAAG,IAAI,CAAC9B,0BAA0B,CAACC,WAAW,CAAC;IAC9D,OAAOhD,MAAM,CAACC,IAAI,CAAC4E,SAAS,CAAC,CAACb,GAAG,CAAEN,MAAM,KAAM;MAC7CE,QAAQ,EAAEF,MAAM;MAChBlE,IAAI,EAAEqF,SAAS,CAACnB,MAAM;IACxB,CAAC,CAAC,CAAC;EACL;EAEOoB,2BAA2BA,CAAC9B,WAAwB,EAAgC;IACzF,OAAO,IAAI,CAACf,gBAAgB,CAACU,qBAAqB,CAACK,WAAW,CAAC,EAAE+B,QAAQ,CAAC,CAAC;EAC7E;EAEQjB,mBAAmBA,CAACkB,WAAyB,EAAEC,YAAsC,EAAEvB,MAAc,EAAE;IAC7G,IAAI,CAACuB,YAAY,IAAI,IAAAC,iBAAO,EAACD,YAAY,CAAC,EAAE,OAAOD,WAAW;IAC9D;IACA,IAAI,OAAOA,WAAW,KAAK,QAAQ,EAAE;MACnC,MAAM,IAAIG,KAAK,CAAC,mCAAmC,OAAOH,WAAW,QAAQtB,MAAM,EAAE,CAAC;IACxF;IACA,IAAI0B,KAAK,CAACC,OAAO,CAACL,WAAW,CAAC,EAAE;MAC9B,MAAM,IAAIG,KAAK,CAAC,6CAA6CzB,MAAM,EAAE,CAAC;IACxE;IACA,OAAAjD,aAAA,CAAAA,aAAA,KAAYuE,WAAW,GAAKC,YAAY;EAC1C;AACF;AAACK,OAAA,CAAAzD,uBAAA,GAAAA,uBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_component","data","require","_lodash","_artifact","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipelineResultList","constructor","tasksResults","components","artifactListsMap","getFlattenedArtifactListsMapFromAllTasks","artifactListsMaps","flatMap","artifacts","ComponentMap","as","component","artifactListMap","artifactList","getValueByComponentId","id","ArtifactList","fromArray","getMetadataFromTaskResults","componentId","compResults","reduce","acc","current","foundComponent","componentsResults","find","c","isEqual","taskId","task","aspectId","metadata","mergeDataIfPossible","getPipelineReportOfComponent","map","taskResults","pipelineReport","taskName","name","taskDescription","description","errors","warnings","startTime","endTime","compact","getDataOfComponent","tasksData","getArtifactsDataOfComponent","toObject","currentData","existingData","isEmpty","Error","Array","isArray","exports"],"sources":["build-pipeline-result-list.ts"],"sourcesContent":["import type { ComponentID, Component } from '@teambit/component';\nimport { ComponentMap } from '@teambit/component';\nimport { isEmpty, compact } from 'lodash';\nimport type { ArtifactObject } from '@teambit/component.sources';\nimport type { Artifact } from './artifact';\nimport { ArtifactList } from './artifact';\nimport type { TaskResults } from './build-pipe';\nimport type { TaskMetadata } from './types';\n\nexport type PipelineReport = {\n taskId: string; // task aspect-id\n taskName: string;\n taskDescription?: string;\n startTime?: number;\n endTime?: number;\n errors?: Array<Error | string>;\n warnings?: string[];\n};\n\nexport type AspectData = {\n aspectId: string;\n data: TaskMetadata;\n};\n\n/**\n * Helper to get the data and artifacts from the TasksResultsList before saving during the tag\n */\nexport class BuildPipelineResultList {\n private artifactListsMap: ComponentMap<ArtifactList<Artifact>>;\n constructor(\n private tasksResults: TaskResults[],\n private components: Component[]\n ) {\n this.artifactListsMap = this.getFlattenedArtifactListsMapFromAllTasks();\n }\n\n private getFlattenedArtifactListsMapFromAllTasks(): ComponentMap<ArtifactList<Artifact>> {\n const artifactListsMaps = this.tasksResults.flatMap((t) => (t.artifacts ? [t.artifacts] : []));\n return ComponentMap.as<ArtifactList<Artifact>>(this.components, (component) => {\n const artifacts: Artifact[] = [];\n artifactListsMaps.forEach((artifactListMap) => {\n const artifactList = artifactListMap.getValueByComponentId(component.id);\n if (artifactList) artifacts.push(...artifactList);\n });\n return ArtifactList.fromArray(artifacts);\n });\n }\n\n public getMetadataFromTaskResults(componentId: ComponentID): { [taskId: string]: TaskMetadata } {\n const compResults = this.tasksResults.reduce((acc, current: TaskResults) => {\n const foundComponent = current.componentsResults.find((c) => c.component.id.isEqual(componentId));\n const taskId = current.task.aspectId;\n if (foundComponent && foundComponent.metadata) {\n acc[taskId] = this.mergeDataIfPossible(foundComponent.metadata, acc[taskId], taskId);\n }\n return acc;\n }, {});\n return compResults;\n }\n\n public getPipelineReportOfComponent(componentId: ComponentID): PipelineReport[] {\n const compResults = this.tasksResults.map((taskResults: TaskResults) => {\n const foundComponent = taskResults.componentsResults.find((c) => c.component.id.isEqual(componentId));\n if (!foundComponent) return null;\n const pipelineReport: PipelineReport = {\n taskId: taskResults.task.aspectId,\n taskName: taskResults.task.name,\n taskDescription: taskResults.task.description,\n errors: foundComponent.errors,\n warnings: foundComponent.warnings,\n startTime: foundComponent.startTime,\n endTime: foundComponent.endTime,\n };\n return pipelineReport;\n });\n return compact(compResults);\n }\n\n public getDataOfComponent(componentId: ComponentID): AspectData[] {\n const tasksData = this.getMetadataFromTaskResults(componentId);\n return Object.keys(tasksData).map((taskId) => ({\n aspectId: taskId,\n data: tasksData[taskId],\n }));\n }\n\n public getArtifactsDataOfComponent(componentId: ComponentID): ArtifactObject[] | undefined {\n return this.artifactListsMap.getValueByComponentId(componentId)?.toObject();\n }\n\n private mergeDataIfPossible(currentData: TaskMetadata, existingData: TaskMetadata | undefined, taskId: string) {\n if (!existingData || isEmpty(existingData)) return currentData;\n // both exist\n if (typeof currentData !== 'object') {\n throw new Error(`task data must be \"object\", get ${typeof currentData} for ${taskId}`);\n }\n if (Array.isArray(currentData)) {\n throw new Error(`task data must be \"object\", get Array for ${taskId}`);\n }\n return { ...currentData, ...existingData };\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC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MAAM,IAAIG,KAAK,CAAC,mCAAmC,OAAOH,WAAW,QAAQtB,MAAM,EAAE,CAAC;IACxF;IACA,IAAI0B,KAAK,CAACC,OAAO,CAACL,WAAW,CAAC,EAAE;MAC9B,MAAM,IAAIG,KAAK,CAAC,6CAA6CzB,MAAM,EAAE,CAAC;IACxE;IACA,OAAAjD,aAAA,CAAAA,aAAA,KAAYuE,WAAW,GAAKC,YAAY;EAC1C;AACF;AAACK,OAAA,CAAAzD,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -1,12 +1,12 @@
1
1
  import type { Component } from '@teambit/component';
2
- import { LaneId } from '@teambit/lane-id';
3
- import { ExecutionContext } from '@teambit/envs';
2
+ import type { LaneId } from '@teambit/lane-id';
3
+ import type { ExecutionContext } from '@teambit/envs';
4
4
  import type { Network } from '@teambit/isolator';
5
5
  import type { ComponentResult } from './types';
6
6
  import type { ArtifactDefinition } from './artifact';
7
- import { TaskResultsList } from './task-results-list';
8
- import { TaskResults } from './build-pipe';
9
- import { PipeName } from './builder.service';
7
+ import type { TaskResultsList } from './task-results-list';
8
+ import type { TaskResults } from './build-pipe';
9
+ import type { PipeName } from './builder.service';
10
10
  export type TaskLocation = 'start' | 'end';
11
11
  /**
12
12
  * delimiter between task.aspectId and task.name
@@ -1 +1 @@
1
- {"version":3,"names":["TaskIdDelimiter","exports","CAPSULE_ARTIFACTS_DIR","BuildTaskHelper","serializeId","aspectId","name","deserializeId","id","split","length","Error","deserializeIdAllowEmptyName","includes","undefined"],"sources":["build-task.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport { LaneId } from '@teambit/lane-id';\nimport { ExecutionContext } from '@teambit/envs';\nimport type { Network } from '@teambit/isolator';\nimport type { ComponentResult } from './types';\nimport type { ArtifactDefinition } from './artifact';\nimport { TaskResultsList } from './task-results-list';\nimport { TaskResults } from './build-pipe';\nimport { PipeName } from './builder.service';\n\nexport type TaskLocation = 'start' | 'end';\n\n/**\n * delimiter between task.aspectId and task.name\n */\nexport const TaskIdDelimiter = ':';\n\n/**\n * A folder to write artifacts generated during a build task\n * This folder is used in the core envs and excluded by default from the package tar file (the core envs is writing this into the npmignore file)\n */\nexport const CAPSULE_ARTIFACTS_DIR = 'artifacts';\n\nexport interface BuildContext extends ExecutionContext {\n /**\n * all components about to be built/tagged.\n */\n components: Component[];\n\n /**\n * network of capsules ready to be built.\n */\n capsuleNetwork: Network;\n\n /**\n * data generated by tasks that were running before this task\n */\n previousTasksResults: TaskResults[];\n\n /**\n * Run the build pipeline in dev mode\n */\n dev?: boolean;\n\n /**\n * pipe name such as \"build\", \"tas\", \"snap\".\n * an example usage is \"deploy\" task which is running in snap and tag pipeline and has different needs in each one.\n */\n pipeName: PipeName;\n\n /**\n * current lane-id if exists. empty when on main.\n */\n laneId?: LaneId;\n}\n\nexport interface TaskDescriptor {\n aspectId: string;\n name?: string;\n description?: string;\n}\n\nexport interface BuildTask {\n /**\n * aspect id serialized of the creator of the task.\n * todo: automate this so then it won't be needed to pass manually.\n */\n aspectId: string;\n\n /**\n * name of the task. function as an identifier among other tasks of the same aspectId.\n * spaces and special characters are not allowed. as a convention, use UpperCamelCase style.\n * (e.g. TypescriptCompiler).\n */\n name: string;\n\n /**\n * description of what the task does.\n * if available, the logger will log it show it in the status-line.\n */\n description?: string;\n\n /**\n * where to put the task, before the env pipeline or after\n */\n location?: TaskLocation;\n\n /**\n * execute a task in a build context\n */\n execute(context: BuildContext): Promise<BuiltTaskResult>;\n\n /**\n * run before the build pipeline has started. this is useful when some preparation are needed to\n * be done on all envs before the build starts.\n * e.g. typescript compiler needs to write the tsconfig file. doing it during the task, will\n * cause dependencies from other envs to get this tsconfig written.\n */\n preBuild?(context: BuildContext): Promise<void>;\n\n /**\n * run after the build pipeline completed for all envs. useful for doing some cleanup on the\n * capsules before the deployment starts.\n */\n postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;\n\n /**\n * needed if you want the task to be running only after the dependencies were completed\n * for *all* envs.\n * normally this is not needed because the build-pipeline runs the tasks in the same order\n * they're located in the `getBuildPipe()` array and according to the task.location.\n * the case where this is useful is when a task not only needs to be after another task, but also\n * after all environments were running that task.\n * a dependency is task.aspectId. if an aspect has multiple tasks, to be more specific, use\n * \"aspectId:name\", e.g. \"teambit.compilation/compiler:TypescriptCompiler\".\n */\n dependencies?: string[];\n}\n\n// TODO: rename to BuildTaskResults\nexport interface BuiltTaskResult {\n /**\n * build results for each of the components in the build context.\n */\n componentsResults: ComponentResult[];\n\n /**\n * array of artifact definitions to generate after a successful build.\n */\n artifacts?: ArtifactDefinition[];\n}\n\nexport class BuildTaskHelper {\n static serializeId({ aspectId, name }: { aspectId: string; name: string }): string {\n return aspectId + TaskIdDelimiter + name;\n }\n static deserializeId(id: string): { aspectId: string; name: string } {\n const split = id.split(TaskIdDelimiter);\n if (split.length === 0) throw new Error(`deserializeId, ${id} is empty`);\n if (split.length === 1) throw new Error(`deserializeId, ${id} has only aspect-id without name`);\n if (split.length === 2) return { aspectId: split[0], name: split[1] };\n throw new Error(`deserializeId, id ${id} has more than one ${TaskIdDelimiter}`);\n }\n /**\n * don't throw an error when the id includes only the aspect-id without the task name.\n * useful for task dependencies, when it's allowed to specify the aspect-id only.\n */\n static deserializeIdAllowEmptyName(id: string): { aspectId: string; name?: string } {\n return id.includes(TaskIdDelimiter) ? BuildTaskHelper.deserializeId(id) : { aspectId: id, name: undefined };\n }\n}\n"],"mappings":";;;;;;AAYA;AACA;AACA;AACO,MAAMA,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,GAAG;;AAElC;AACA;AACA;AACA;AACO,MAAME,qBAAqB,GAAAD,OAAA,CAAAC,qBAAA,GAAG,WAAW;;AAkGhD;;AAaO,MAAMC,eAAe,CAAC;EAC3B,OAAOC,WAAWA,CAAC;IAAEC,QAAQ;IAAEC;EAAyC,CAAC,EAAU;IACjF,OAAOD,QAAQ,GAAGL,eAAe,GAAGM,IAAI;EAC1C;EACA,OAAOC,aAAaA,CAACC,EAAU,EAAsC;IACnE,MAAMC,KAAK,GAAGD,EAAE,CAACC,KAAK,CAACT,eAAe,CAAC;IACvC,IAAIS,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,MAAM,IAAIC,KAAK,CAAC,kBAAkBH,EAAE,WAAW,CAAC;IACxE,IAAIC,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,MAAM,IAAIC,KAAK,CAAC,kBAAkBH,EAAE,kCAAkC,CAAC;IAC/F,IAAIC,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO;MAAEL,QAAQ,EAAEI,KAAK,CAAC,CAAC,CAAC;MAAEH,IAAI,EAAEG,KAAK,CAAC,CAAC;IAAE,CAAC;IACrE,MAAM,IAAIE,KAAK,CAAC,qBAAqBH,EAAE,sBAAsBR,eAAe,EAAE,CAAC;EACjF;EACA;AACF;AACA;AACA;EACE,OAAOY,2BAA2BA,CAACJ,EAAU,EAAuC;IAClF,OAAOA,EAAE,CAACK,QAAQ,CAACb,eAAe,CAAC,GAAGG,eAAe,CAACI,aAAa,CAACC,EAAE,CAAC,GAAG;MAAEH,QAAQ,EAAEG,EAAE;MAAEF,IAAI,EAAEQ;IAAU,CAAC;EAC7G;AACF;AAACb,OAAA,CAAAE,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["TaskIdDelimiter","exports","CAPSULE_ARTIFACTS_DIR","BuildTaskHelper","serializeId","aspectId","name","deserializeId","id","split","length","Error","deserializeIdAllowEmptyName","includes","undefined"],"sources":["build-task.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport type { LaneId } from '@teambit/lane-id';\nimport type { ExecutionContext } from '@teambit/envs';\nimport type { Network } from '@teambit/isolator';\nimport type { ComponentResult } from './types';\nimport type { ArtifactDefinition } from './artifact';\nimport type { TaskResultsList } from './task-results-list';\nimport type { TaskResults } from './build-pipe';\nimport type { PipeName } from './builder.service';\n\nexport type TaskLocation = 'start' | 'end';\n\n/**\n * delimiter between task.aspectId and task.name\n */\nexport const TaskIdDelimiter = ':';\n\n/**\n * A folder to write artifacts generated during a build task\n * This folder is used in the core envs and excluded by default from the package tar file (the core envs is writing this into the npmignore file)\n */\nexport const CAPSULE_ARTIFACTS_DIR = 'artifacts';\n\nexport interface BuildContext extends ExecutionContext {\n /**\n * all components about to be built/tagged.\n */\n components: Component[];\n\n /**\n * network of capsules ready to be built.\n */\n capsuleNetwork: Network;\n\n /**\n * data generated by tasks that were running before this task\n */\n previousTasksResults: TaskResults[];\n\n /**\n * Run the build pipeline in dev mode\n */\n dev?: boolean;\n\n /**\n * pipe name such as \"build\", \"tas\", \"snap\".\n * an example usage is \"deploy\" task which is running in snap and tag pipeline and has different needs in each one.\n */\n pipeName: PipeName;\n\n /**\n * current lane-id if exists. empty when on main.\n */\n laneId?: LaneId;\n}\n\nexport interface TaskDescriptor {\n aspectId: string;\n name?: string;\n description?: string;\n}\n\nexport interface BuildTask {\n /**\n * aspect id serialized of the creator of the task.\n * todo: automate this so then it won't be needed to pass manually.\n */\n aspectId: string;\n\n /**\n * name of the task. function as an identifier among other tasks of the same aspectId.\n * spaces and special characters are not allowed. as a convention, use UpperCamelCase style.\n * (e.g. TypescriptCompiler).\n */\n name: string;\n\n /**\n * description of what the task does.\n * if available, the logger will log it show it in the status-line.\n */\n description?: string;\n\n /**\n * where to put the task, before the env pipeline or after\n */\n location?: TaskLocation;\n\n /**\n * execute a task in a build context\n */\n execute(context: BuildContext): Promise<BuiltTaskResult>;\n\n /**\n * run before the build pipeline has started. this is useful when some preparation are needed to\n * be done on all envs before the build starts.\n * e.g. typescript compiler needs to write the tsconfig file. doing it during the task, will\n * cause dependencies from other envs to get this tsconfig written.\n */\n preBuild?(context: BuildContext): Promise<void>;\n\n /**\n * run after the build pipeline completed for all envs. useful for doing some cleanup on the\n * capsules before the deployment starts.\n */\n postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;\n\n /**\n * needed if you want the task to be running only after the dependencies were completed\n * for *all* envs.\n * normally this is not needed because the build-pipeline runs the tasks in the same order\n * they're located in the `getBuildPipe()` array and according to the task.location.\n * the case where this is useful is when a task not only needs to be after another task, but also\n * after all environments were running that task.\n * a dependency is task.aspectId. if an aspect has multiple tasks, to be more specific, use\n * \"aspectId:name\", e.g. \"teambit.compilation/compiler:TypescriptCompiler\".\n */\n dependencies?: string[];\n}\n\n// TODO: rename to BuildTaskResults\nexport interface BuiltTaskResult {\n /**\n * build results for each of the components in the build context.\n */\n componentsResults: ComponentResult[];\n\n /**\n * array of artifact definitions to generate after a successful build.\n */\n artifacts?: ArtifactDefinition[];\n}\n\nexport class BuildTaskHelper {\n static serializeId({ aspectId, name }: { aspectId: string; name: string }): string {\n return aspectId + TaskIdDelimiter + name;\n }\n static deserializeId(id: string): { aspectId: string; name: string } {\n const split = id.split(TaskIdDelimiter);\n if (split.length === 0) throw new Error(`deserializeId, ${id} is empty`);\n if (split.length === 1) throw new Error(`deserializeId, ${id} has only aspect-id without name`);\n if (split.length === 2) return { aspectId: split[0], name: split[1] };\n throw new Error(`deserializeId, id ${id} has more than one ${TaskIdDelimiter}`);\n }\n /**\n * don't throw an error when the id includes only the aspect-id without the task name.\n * useful for task dependencies, when it's allowed to specify the aspect-id only.\n */\n static deserializeIdAllowEmptyName(id: string): { aspectId: string; name?: string } {\n return id.includes(TaskIdDelimiter) ? BuildTaskHelper.deserializeId(id) : { aspectId: id, name: undefined };\n }\n}\n"],"mappings":";;;;;;AAYA;AACA;AACA;AACO,MAAMA,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,GAAG;;AAElC;AACA;AACA;AACA;AACO,MAAME,qBAAqB,GAAAD,OAAA,CAAAC,qBAAA,GAAG,WAAW;;AAkGhD;;AAaO,MAAMC,eAAe,CAAC;EAC3B,OAAOC,WAAWA,CAAC;IAAEC,QAAQ;IAAEC;EAAyC,CAAC,EAAU;IACjF,OAAOD,QAAQ,GAAGL,eAAe,GAAGM,IAAI;EAC1C;EACA,OAAOC,aAAaA,CAACC,EAAU,EAAsC;IACnE,MAAMC,KAAK,GAAGD,EAAE,CAACC,KAAK,CAACT,eAAe,CAAC;IACvC,IAAIS,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,MAAM,IAAIC,KAAK,CAAC,kBAAkBH,EAAE,WAAW,CAAC;IACxE,IAAIC,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,MAAM,IAAIC,KAAK,CAAC,kBAAkBH,EAAE,kCAAkC,CAAC;IAC/F,IAAIC,KAAK,CAACC,MAAM,KAAK,CAAC,EAAE,OAAO;MAAEL,QAAQ,EAAEI,KAAK,CAAC,CAAC,CAAC;MAAEH,IAAI,EAAEG,KAAK,CAAC,CAAC;IAAE,CAAC;IACrE,MAAM,IAAIE,KAAK,CAAC,qBAAqBH,EAAE,sBAAsBR,eAAe,EAAE,CAAC;EACjF;EACA;AACF;AACA;AACA;EACE,OAAOY,2BAA2BA,CAACJ,EAAU,EAAuC;IAClF,OAAOA,EAAE,CAACK,QAAQ,CAACb,eAAe,CAAC,GAAGG,eAAe,CAACI,aAAa,CAACC,EAAE,CAAC,GAAG;MAAEH,QAAQ,EAAEG,EAAE;MAAEF,IAAI,EAAEQ;IAAU,CAAC;EAC7G;AACF;AAACb,OAAA,CAAAE,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { Command, CommandOptions } from '@teambit/cli';
2
- import { Logger } from '@teambit/logger';
3
- import { Workspace } from '@teambit/workspace';
4
- import { BuilderMain } from './builder.main.runtime';
1
+ import type { Command, CommandOptions } from '@teambit/cli';
2
+ import type { Logger } from '@teambit/logger';
3
+ import type { Workspace } from '@teambit/workspace';
4
+ import type { BuilderMain } from './builder.main.runtime';
5
5
  type BuildOpts = {
6
6
  unmodified?: boolean;
7
7
  dev: boolean;
@@ -1 +1 @@
1
- {"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","_workspace","_legacy","_chalk","_componentIssues","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BuilderCmd","constructor","builder","workspace","logger","name","description","COMPONENT_PATTERN_HELP","cmd","keys","IssuesClasses","join","report","pattern","unmodified","dev","install","cachePackagesOnCapsulesRoot","reuseCapsules","rewrite","reinstall","tasks","listTasks","skipTests","skipTasks","failFast","includeSnap","includeTag","ignoreIssues","loose","Error","OutsideWorkspaceError","getListTasks","setStatusLine","start","process","hrtime","components","getComponentsByUserInput","length","chalk","bold","skipTasksParsed","split","map","trim","undefined","envsExecutionResults","build","installOptions","installTeambitBit","packageManagerConfigRootDir","path","installPackages","linkingOptions","linkTeambitBit","emptyRootDir","getExistingAsIs","task","exitOnFirstFailedTask","console","capsuleRootDir","duration","prettyTime","succeedOrFailed","hasErrors","msg","consoleFailure","throwErrorsIfExist","green","componentIdStr","compId","resolveComponentId","component","get","results","id","toString","envId","buildTasks","tagTasks","snapTasks","exports"],"sources":["build.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { Logger } from '@teambit/logger';\nimport prettyTime from 'pretty-time';\nimport { OutsideWorkspaceError, Workspace } from '@teambit/workspace';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport chalk from 'chalk';\nimport { BuilderMain } from './builder.main.runtime';\nimport { IssuesClasses } from '@teambit/component-issues';\n\ntype BuildOpts = {\n unmodified?: boolean;\n dev: boolean;\n rebuild: boolean;\n install: boolean;\n cachePackagesOnCapsulesRoot: boolean;\n reuseCapsules: boolean;\n rewrite?: boolean; //relevant only when reuseCapsules is set\n reinstall?: boolean; //relevant only when reuseCapsules is set\n tasks: string;\n listTasks?: string;\n skipTests?: boolean;\n skipTasks?: string;\n failFast?: boolean;\n includeSnap?: boolean;\n includeTag?: boolean;\n ignoreIssues?: string;\n loose?: boolean;\n};\n\nexport class BuilderCmd implements Command {\n name = 'build [component-pattern]';\n description = 'run set of tasks for build.';\n extendedDescription = `by default, only new and modified components are built.\nthe build takes place in an isolated directories on the filesystem (called \"capsules\"). the component files are copied to these directories\nand the package-manager installs the dependencies in the capsules root. once done, the build pipeline is running.\nbecause this process can take a while on a large workspace, some flags are available to shorten the process. See the example section for more info.\n `;\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\n examples = [\n {\n cmd: 'build --reuse-capsules --tasks \"custom-task\"',\n description: 'helps to debug this \"custom-task\" without recreating the capsules from scratch',\n },\n {\n cmd: 'build --reuse-capsules --rewrite --tasks \"BabelCompile,MochaTest\"',\n description: `helpful when for example the tests are failing and code changes are needed to debug it.\nthe \"--rewrite\" flag ensures the component files are fresh, and the \"--tasks\" ensures to re-compile them and then run the tests`,\n },\n ];\n helpUrl = 'reference/build-pipeline/builder-overview';\n alias = '';\n group = 'component-development';\n options = [\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are built)'],\n ['d', 'dev', 'run the pipeline in dev mode'],\n ['', 'install', 'install core aspects in capsules'],\n ['', 'reuse-capsules', 'avoid deleting the capsules root-dir before starting the build'],\n ['', 'rewrite', 'use only with --reuse-capsules. rewrite the component files'],\n ['', 'reinstall', 'use only with --reuse-capsules. rerun the installation'],\n [\n '',\n 'tasks <string>',\n `build the specified task(s) only. for multiple tasks, separate by a comma and wrap with quotes.\nspecify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n ['', 'cache-packages-on-capsule-root', 'set the package-manager cache on the capsule root'],\n [\n '',\n 'list-tasks <string>',\n 'list tasks of an env or a component-id for each one of the pipelines: build, tag and snap',\n ],\n ['', 'skip-tests', 'skip running component tests during build process'],\n ['', 'loose', 'allow build to succeed even if tasks like tests or lint fail'],\n [\n '',\n 'skip-tasks <string>',\n `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.\n specify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n [\n '',\n 'fail-fast',\n 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)',\n ],\n ['', 'include-snap', 'include snap pipeline tasks. Warning: this may deploy/publish if you have such tasks'],\n ['', 'include-tag', 'include tag pipeline tasks. Warning: this may deploy/publish if you have such tasks'],\n [\n 'i',\n 'ignore-issues <issues>',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n ] as CommandOptions;\n\n constructor(\n private builder: BuilderMain,\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n async report(\n [pattern]: [string],\n {\n unmodified = false,\n dev = false,\n install = false,\n cachePackagesOnCapsulesRoot = false,\n reuseCapsules = false,\n rewrite = false,\n reinstall = false,\n tasks,\n listTasks,\n skipTests,\n skipTasks,\n failFast,\n includeSnap,\n includeTag,\n ignoreIssues,\n loose = false,\n }: BuildOpts\n ): Promise<string> {\n if (rewrite && !reuseCapsules) throw new Error('cannot use --rewrite without --reuse-capsules');\n if (reinstall && !reuseCapsules) throw new Error('cannot use --reinstall without --reuse-capsules');\n if (!this.workspace) throw new OutsideWorkspaceError();\n if (listTasks) {\n return this.getListTasks(listTasks);\n }\n\n this.logger.setStatusLine('build');\n const start = process.hrtime();\n const components = await this.workspace.getComponentsByUserInput(unmodified, pattern, true);\n if (!components.length) {\n return chalk.bold(\n `no components found to build. use \"--unmodified\" flag to build all components or specify the ids to build, otherwise, only new and modified components will be built`\n );\n }\n\n const skipTasksParsed = skipTasks ? skipTasks.split(',').map((t) => t.trim()) : undefined;\n\n const envsExecutionResults = await this.builder.build(\n components,\n {\n installOptions: {\n installTeambitBit: install,\n packageManagerConfigRootDir: this.workspace.path,\n installPackages: rewrite && !reinstall ? false : true,\n },\n linkingOptions: { linkTeambitBit: !install },\n emptyRootDir: !reuseCapsules,\n getExistingAsIs: reuseCapsules && !rewrite && !reinstall,\n cachePackagesOnCapsulesRoot,\n },\n {\n dev,\n tasks: tasks ? tasks.split(',').map((task) => task.trim()) : [],\n skipTests,\n skipTasks: skipTasksParsed,\n exitOnFirstFailedTask: failFast,\n },\n {\n includeSnap,\n includeTag,\n ignoreIssues,\n }\n );\n this.logger.console(`build output can be found in path: ${envsExecutionResults.capsuleRootDir}`);\n const duration = prettyTime(process.hrtime(start));\n const succeedOrFailed = envsExecutionResults.hasErrors(loose) ? 'failed' : 'succeeded';\n const msg = `build ${succeedOrFailed}. completed in ${duration}.`;\n if (envsExecutionResults.hasErrors(loose)) {\n this.logger.consoleFailure(msg);\n }\n envsExecutionResults.throwErrorsIfExist(loose);\n return chalk.green(msg);\n }\n\n private async getListTasks(componentIdStr: string): Promise<string> {\n const compId = await this.workspace.resolveComponentId(componentIdStr);\n const component = await this.workspace.get(compId);\n const results = this.builder.listTasks(component);\n return `${chalk.green('Task List')}\nid: ${results.id.toString()}\nenvId: ${results.envId}\n\n${chalk.bold('Build Pipeline Tasks:')}\n${results.buildTasks.join('\\n')}\n\n${chalk.bold('Tag Pipeline Tasks:')}\n${results.tagTasks.join('\\n')}\n\n${chalk.bold('Snap Pipeline Tasks:')}\n${results.snapTasks.join('\\n') || '<N/A>'}`;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,UAAA,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;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAL,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nB,oBAAoB,CAACqB,kBAAkB,CAACvC,KAAK,CAAC;IAC9C,OAAOW,gBAAK,CAAC6B,KAAK,CAACH,GAAG,CAAC;EACzB;EAEA,MAAclC,YAAYA,CAACsC,cAAsB,EAAmB;IAClE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACpE,SAAS,CAACqE,kBAAkB,CAACF,cAAc,CAAC;IACtE,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACtE,SAAS,CAACuE,GAAG,CAACH,MAAM,CAAC;IAClD,MAAMI,OAAO,GAAG,IAAI,CAACzE,OAAO,CAACoB,SAAS,CAACmD,SAAS,CAAC;IACjD,OAAO,GAAGjC,gBAAK,CAAC6B,KAAK,CAAC,WAAW,CAAC;AACtC,SAASM,OAAO,CAACC,EAAE,CAACC,QAAQ,CAAC,CAAC;AAC9B,SAASF,OAAO,CAACG,KAAK;AACtB;AACA,EAAEtC,gBAAK,CAACC,IAAI,CAAC,uBAAuB,CAAC;AACrC,EAAEkC,OAAO,CAACI,UAAU,CAACpE,IAAI,CAAC,IAAI,CAAC;AAC/B;AACA,EAAE6B,gBAAK,CAACC,IAAI,CAAC,qBAAqB,CAAC;AACnC,EAAEkC,OAAO,CAACK,QAAQ,CAACrE,IAAI,CAAC,IAAI,CAAC;AAC7B;AACA,EAAE6B,gBAAK,CAACC,IAAI,CAAC,sBAAsB,CAAC;AACpC,EAAEkC,OAAO,CAACM,SAAS,CAACtE,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,EAAE;EACzC;AACF;AAACuE,OAAA,CAAAlF,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","_workspace","_legacy","_chalk","_componentIssues","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BuilderCmd","constructor","builder","workspace","logger","name","description","COMPONENT_PATTERN_HELP","cmd","keys","IssuesClasses","join","report","pattern","unmodified","dev","install","cachePackagesOnCapsulesRoot","reuseCapsules","rewrite","reinstall","tasks","listTasks","skipTests","skipTasks","failFast","includeSnap","includeTag","ignoreIssues","loose","Error","OutsideWorkspaceError","getListTasks","setStatusLine","start","process","hrtime","components","getComponentsByUserInput","length","chalk","bold","skipTasksParsed","split","map","trim","undefined","envsExecutionResults","build","installOptions","installTeambitBit","packageManagerConfigRootDir","path","installPackages","linkingOptions","linkTeambitBit","emptyRootDir","getExistingAsIs","task","exitOnFirstFailedTask","console","capsuleRootDir","duration","prettyTime","succeedOrFailed","hasErrors","msg","consoleFailure","throwErrorsIfExist","green","componentIdStr","compId","resolveComponentId","component","get","results","id","toString","envId","buildTasks","tagTasks","snapTasks","exports"],"sources":["build.cmd.ts"],"sourcesContent":["import type { Command, CommandOptions } from '@teambit/cli';\nimport type { Logger } from '@teambit/logger';\nimport prettyTime from 'pretty-time';\nimport type { Workspace } from '@teambit/workspace';\nimport { OutsideWorkspaceError } from '@teambit/workspace';\nimport { COMPONENT_PATTERN_HELP } from '@teambit/legacy.constants';\nimport chalk from 'chalk';\nimport type { BuilderMain } from './builder.main.runtime';\nimport { IssuesClasses } from '@teambit/component-issues';\n\ntype BuildOpts = {\n unmodified?: boolean;\n dev: boolean;\n rebuild: boolean;\n install: boolean;\n cachePackagesOnCapsulesRoot: boolean;\n reuseCapsules: boolean;\n rewrite?: boolean; //relevant only when reuseCapsules is set\n reinstall?: boolean; //relevant only when reuseCapsules is set\n tasks: string;\n listTasks?: string;\n skipTests?: boolean;\n skipTasks?: string;\n failFast?: boolean;\n includeSnap?: boolean;\n includeTag?: boolean;\n ignoreIssues?: string;\n loose?: boolean;\n};\n\nexport class BuilderCmd implements Command {\n name = 'build [component-pattern]';\n description = 'run set of tasks for build.';\n extendedDescription = `by default, only new and modified components are built.\nthe build takes place in an isolated directories on the filesystem (called \"capsules\"). the component files are copied to these directories\nand the package-manager installs the dependencies in the capsules root. once done, the build pipeline is running.\nbecause this process can take a while on a large workspace, some flags are available to shorten the process. See the example section for more info.\n `;\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\n examples = [\n {\n cmd: 'build --reuse-capsules --tasks \"custom-task\"',\n description: 'helps to debug this \"custom-task\" without recreating the capsules from scratch',\n },\n {\n cmd: 'build --reuse-capsules --rewrite --tasks \"BabelCompile,MochaTest\"',\n description: `helpful when for example the tests are failing and code changes are needed to debug it.\nthe \"--rewrite\" flag ensures the component files are fresh, and the \"--tasks\" ensures to re-compile them and then run the tests`,\n },\n ];\n helpUrl = 'reference/build-pipeline/builder-overview';\n alias = '';\n group = 'component-development';\n options = [\n ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are built)'],\n ['d', 'dev', 'run the pipeline in dev mode'],\n ['', 'install', 'install core aspects in capsules'],\n ['', 'reuse-capsules', 'avoid deleting the capsules root-dir before starting the build'],\n ['', 'rewrite', 'use only with --reuse-capsules. rewrite the component files'],\n ['', 'reinstall', 'use only with --reuse-capsules. rerun the installation'],\n [\n '',\n 'tasks <string>',\n `build the specified task(s) only. for multiple tasks, separate by a comma and wrap with quotes.\nspecify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n ['', 'cache-packages-on-capsule-root', 'set the package-manager cache on the capsule root'],\n [\n '',\n 'list-tasks <string>',\n 'list tasks of an env or a component-id for each one of the pipelines: build, tag and snap',\n ],\n ['', 'skip-tests', 'skip running component tests during build process'],\n ['', 'loose', 'allow build to succeed even if tasks like tests or lint fail'],\n [\n '',\n 'skip-tasks <string>',\n `skip the given tasks. for multiple tasks, separate by a comma and wrap with quotes.\n specify the task-name (e.g. \"TypescriptCompiler\") or the task-aspect-id (e.g. teambit.compilation/compiler)`,\n ],\n [\n '',\n 'fail-fast',\n 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)',\n ],\n ['', 'include-snap', 'include snap pipeline tasks. Warning: this may deploy/publish if you have such tasks'],\n ['', 'include-tag', 'include tag pipeline tasks. Warning: this may deploy/publish if you have such tasks'],\n [\n 'i',\n 'ignore-issues <issues>',\n `ignore component issues (shown in \"bit status\" as \"issues found\"), issues to ignore:\n[${Object.keys(IssuesClasses).join(', ')}]\nto ignore multiple issues, separate them by a comma and wrap with quotes. to ignore all issues, specify \"*\".`,\n ],\n ] as CommandOptions;\n\n constructor(\n private builder: BuilderMain,\n private workspace: Workspace,\n private logger: Logger\n ) {}\n\n async report(\n [pattern]: [string],\n {\n unmodified = false,\n dev = false,\n install = false,\n cachePackagesOnCapsulesRoot = false,\n reuseCapsules = false,\n rewrite = false,\n reinstall = false,\n tasks,\n listTasks,\n skipTests,\n skipTasks,\n failFast,\n includeSnap,\n includeTag,\n ignoreIssues,\n loose = false,\n }: BuildOpts\n ): Promise<string> {\n if (rewrite && !reuseCapsules) throw new Error('cannot use --rewrite without --reuse-capsules');\n if (reinstall && !reuseCapsules) throw new Error('cannot use --reinstall without --reuse-capsules');\n if (!this.workspace) throw new OutsideWorkspaceError();\n if (listTasks) {\n return this.getListTasks(listTasks);\n }\n\n this.logger.setStatusLine('build');\n const start = process.hrtime();\n const components = await this.workspace.getComponentsByUserInput(unmodified, pattern, true);\n if (!components.length) {\n return chalk.bold(\n `no components found to build. use \"--unmodified\" flag to build all components or specify the ids to build, otherwise, only new and modified components will be built`\n );\n }\n\n const skipTasksParsed = skipTasks ? skipTasks.split(',').map((t) => t.trim()) : undefined;\n\n const envsExecutionResults = await this.builder.build(\n components,\n {\n installOptions: {\n installTeambitBit: install,\n packageManagerConfigRootDir: this.workspace.path,\n installPackages: rewrite && !reinstall ? false : true,\n },\n linkingOptions: { linkTeambitBit: !install },\n emptyRootDir: !reuseCapsules,\n getExistingAsIs: reuseCapsules && !rewrite && !reinstall,\n cachePackagesOnCapsulesRoot,\n },\n {\n dev,\n tasks: tasks ? tasks.split(',').map((task) => task.trim()) : [],\n skipTests,\n skipTasks: skipTasksParsed,\n exitOnFirstFailedTask: failFast,\n },\n {\n includeSnap,\n includeTag,\n ignoreIssues,\n }\n );\n this.logger.console(`build output can be found in path: ${envsExecutionResults.capsuleRootDir}`);\n const duration = prettyTime(process.hrtime(start));\n const succeedOrFailed = envsExecutionResults.hasErrors(loose) ? 'failed' : 'succeeded';\n const msg = `build ${succeedOrFailed}. completed in ${duration}.`;\n if (envsExecutionResults.hasErrors(loose)) {\n this.logger.consoleFailure(msg);\n }\n envsExecutionResults.throwErrorsIfExist(loose);\n return chalk.green(msg);\n }\n\n private async getListTasks(componentIdStr: string): Promise<string> {\n const compId = await this.workspace.resolveComponentId(componentIdStr);\n const component = await this.workspace.get(compId);\n const results = this.builder.listTasks(component);\n return `${chalk.green('Task List')}\nid: ${results.id.toString()}\nenvId: ${results.envId}\n\n${chalk.bold('Build Pipeline Tasks:')}\n${results.buildTasks.join('\\n')}\n\n${chalk.bold('Tag Pipeline Tasks:')}\n${results.tagTasks.join('\\n')}\n\n${chalk.bold('Snap Pipeline Tasks:')}\n${results.snapTasks.join('\\n') || '<N/A>'}`;\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,WAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,UAAA,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;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAG,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,iBAAA;EAAA,MAAAN,IAAA,G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AAK,CAACH,GAAG,CAAC;EACzB;EAEA,MAAclC,YAAYA,CAACsC,cAAsB,EAAmB;IAClE,MAAMC,MAAM,GAAG,MAAM,IAAI,CAACpE,SAAS,CAACqE,kBAAkB,CAACF,cAAc,CAAC;IACtE,MAAMG,SAAS,GAAG,MAAM,IAAI,CAACtE,SAAS,CAACuE,GAAG,CAACH,MAAM,CAAC;IAClD,MAAMI,OAAO,GAAG,IAAI,CAACzE,OAAO,CAACoB,SAAS,CAACmD,SAAS,CAAC;IACjD,OAAO,GAAGjC,gBAAK,CAAC6B,KAAK,CAAC,WAAW,CAAC;AACtC,SAASM,OAAO,CAACC,EAAE,CAACC,QAAQ,CAAC,CAAC;AAC9B,SAASF,OAAO,CAACG,KAAK;AACtB;AACA,EAAEtC,gBAAK,CAACC,IAAI,CAAC,uBAAuB,CAAC;AACrC,EAAEkC,OAAO,CAACI,UAAU,CAACpE,IAAI,CAAC,IAAI,CAAC;AAC/B;AACA,EAAE6B,gBAAK,CAACC,IAAI,CAAC,qBAAqB,CAAC;AACnC,EAAEkC,OAAO,CAACK,QAAQ,CAACrE,IAAI,CAAC,IAAI,CAAC;AAC7B;AACA,EAAE6B,gBAAK,CAACC,IAAI,CAAC,sBAAsB,CAAC;AACpC,EAAEkC,OAAO,CAACM,SAAS,CAACtE,IAAI,CAAC,IAAI,CAAC,IAAI,OAAO,EAAE;EACzC;AACF;AAACuE,OAAA,CAAAlF,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { Pipeline } from './pipeline';
1
+ import type { Pipeline } from './pipeline';
2
2
  export interface BuilderEnv {
3
3
  /**
4
4
  * return a build pipeline instance.
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["builder-env-type.ts"],"sourcesContent":["import { Pipeline } from './pipeline';\n\nexport interface BuilderEnv {\n /**\n * return a build pipeline instance.\n */\n build(): Pipeline;\n /**\n * return a snap pipeline instance.\n */\n snap(): Pipeline;\n /**\n * return a tag pipeline instance.\n */\n tag(): Pipeline;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["builder-env-type.ts"],"sourcesContent":["import type { Pipeline } from './pipeline';\n\nexport interface BuilderEnv {\n /**\n * return a build pipeline instance.\n */\n build(): Pipeline;\n /**\n * return a snap pipeline instance.\n */\n snap(): Pipeline;\n /**\n * return a tag pipeline instance.\n */\n tag(): Pipeline;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { Component, ComponentID } from '@teambit/component';
2
- import { Logger } from '@teambit/logger';
3
- import { BuilderMain } from './builder.main.runtime';
4
- import { PipelineReport } from './build-pipeline-result-list';
1
+ import type { Component, ComponentID } from '@teambit/component';
2
+ import type { Logger } from '@teambit/logger';
3
+ import type { BuilderMain } from './builder.main.runtime';
4
+ import type { PipelineReport } from './build-pipeline-result-list';
5
5
  type ArtifactGQLFile = {
6
6
  /**
7
7
  * same as the path - used for GQL caching
@@ -1 +1 @@
1
- {"version":3,"names":["_graphqlTag","data","require","_isBinaryPath","_interopRequireDefault","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","builderSchema","builder","logger","typeDefs","gql","resolvers","Component","pipelineReport","component","taskId","builderData","getBuilderData","pipeline","artifacts","getArtifactsByAspect","getArtifacts","artifactsWithVinyl","Promise","all","map","artifact","id","task","aspectId","name","artifactFiles","getArtifactsVinylByAspectAndTaskName","vinyl","basename","path","contents","isBinary","isBinaryPath","content","toString","undefined","size","byteLength","downloadUrl","encodeURI","getDownloadUrlForArtifact","externalUrl","url","description","storage","generatedBy","files","error","result","find","taskName","TaskReport","taskReport","taskDescription","errors","warnings","pathFilter","file"],"sources":["builder.graphql.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport { gql } from 'graphql-tag';\nimport { Logger } from '@teambit/logger';\nimport isBinaryPath from 'is-binary-path';\nimport { BuilderMain } from './builder.main.runtime';\nimport { PipelineReport } from './build-pipeline-result-list';\n\ntype ArtifactGQLFile = {\n /**\n * same as the path - used for GQL caching\n */\n id: string;\n /**\n * name of the artifact file\n */\n name: string;\n /**\n * path of the artifact file\n */\n path: string;\n /**\n * artifact file content (only for text files). Use /api/<component-id>/~aspect/builder/<extension-id>/~<path> to fetch binary file data\n */\n content?: string;\n /**\n * REST endpoint to fetch artifact data from. /api/<component-id>/~aspect/builder/<extension-id>/~<pat\n */\n downloadUrl?: string;\n /**\n * Remote storage url to resolve artifact file from\n */\n externalUrl?: string;\n /**\n * Size in bytes\n */\n size: number;\n};\n\ntype ArtifactGQLData = {\n name: string;\n description?: string;\n storage?: string;\n generatedBy: string;\n files: ArtifactGQLFile[];\n};\ntype TaskReport = PipelineReport & {\n artifact?: ArtifactGQLData;\n componentId: ComponentID;\n};\n\nexport function builderSchema(builder: BuilderMain, logger: Logger) {\n return {\n typeDefs: gql`\n type TaskReport {\n # for GQL caching - taskId + taskName\n id: String!\n taskId: String!\n taskName: String!\n description: String\n startTime: String\n endTime: String\n errors: [String!]\n warnings: [String!]\n artifact(path: String): Artifact\n }\n\n type ArtifactFile {\n # for GQL caching - same as the path\n id: String!\n # name of the artifact file\n name: String\n # path of the artifact file\n path: String!\n # artifact file content (only for text files). Use /api/<component-id>/~aspect/builder/<extension-id>/~<path> to fetch binary file data\n content: String\n # REST endpoint to fetch artifact data from. /api/<component-id>/~aspect/builder/<extension-id>/~<path>\n downloadUrl: String\n # Remote storage url to resolve artifact file from\n externalUrl: String\n # size in bytes\n size: Int!\n }\n\n type Artifact {\n # for GQL caching - PipelineId + Artifact Name\n id: String!\n # artifact name\n name: String!\n description: String\n storage: String\n generatedBy: String\n files: [ArtifactFile!]!\n }\n\n extend type Component {\n pipelineReport(taskId: String): [TaskReport!]!\n }\n `,\n\n resolvers: {\n Component: {\n pipelineReport: async (component: Component, { taskId }: { taskId?: string }) => {\n try {\n const builderData = builder.getBuilderData(component);\n const pipeline = builderData?.pipeline || [];\n const artifacts = taskId\n ? builder.getArtifactsByAspect(component, taskId)\n : builder.getArtifacts(component);\n const artifactsWithVinyl = await Promise.all(\n artifacts.map(async (artifact) => {\n const id = artifact.task.aspectId;\n const name = artifact.task.name as string;\n try {\n const artifactFiles = (await builder.getArtifactsVinylByAspectAndTaskName(component, id, name)).map(\n (vinyl) => {\n const { basename, path, contents } = vinyl || {};\n const isBinary = path && isBinaryPath(path);\n const content = !isBinary ? contents?.toString('utf-8') : undefined;\n const size = contents.byteLength;\n const downloadUrl = encodeURI(\n builder.getDownloadUrlForArtifact(component.id, artifact.task.aspectId, path)\n );\n const externalUrl = vinyl.url;\n return { id: path, name: basename, path, content, downloadUrl, externalUrl, size };\n }\n );\n return {\n id: `${id}-${name}-${artifact.name}`,\n name: artifact.name,\n description: artifact.description,\n task: artifact.task,\n storage: artifact.storage,\n generatedBy: artifact.generatedBy,\n files: artifactFiles,\n };\n } catch (e: any) {\n logger.error(e.toString());\n return {\n id: `${id}-${name}-${artifact.name}`,\n name: artifact.name,\n description: artifact.description,\n task: artifact.task,\n storage: artifact.storage,\n generatedBy: artifact.generatedBy,\n files: [],\n };\n }\n })\n );\n\n const result = pipeline\n .filter((task) => !taskId || task.taskId === taskId)\n .map((task) => ({\n ...task,\n id: `filter-${taskId || ''}`,\n artifact: artifactsWithVinyl.find(\n (data) => data.task.aspectId === task.taskId && data.task.name === task.taskName\n ),\n }));\n\n return result;\n } catch (e: any) {\n logger.error(e.toString());\n return [];\n }\n },\n },\n TaskReport: {\n id: (taskReport: TaskReport & { id?: string }) =>\n `${(taskReport.id && `${taskReport.id}-`) || ''}${taskReport.taskId}-${taskReport.taskName}`,\n description: (taskReport: TaskReport) => taskReport.taskDescription,\n errors: (taskReport: TaskReport) => taskReport.errors?.map((e) => e.toString()) || [],\n warnings: (taskReport: TaskReport) => taskReport.warnings || [],\n artifact: async (taskReport: TaskReport, { path: pathFilter }: { path?: string }) => {\n if (!taskReport.artifact) return undefined;\n return {\n id: `${taskReport.taskId}-${taskReport.taskName}-${taskReport.artifact?.name}-${pathFilter || ''}`,\n ...taskReport.artifact,\n files: taskReport.artifact.files.filter((file) => !pathFilter || file.path === pathFilter),\n };\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,cAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,aAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA0C,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,QAAAH,CAAA,EAAAI,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAP,CAAA,OAAAM,MAAA,CAAAE,qBAAA,QAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAR,CAAA,GAAAI,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,WAAAN,CAAA,WAAAE,MAAA,CAAAK,wBAAA,CAAAX,CAAA,EAAAI,CAAA,EAAAQ,UAAA,OAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,YAAAJ,CAAA;AAAA,SAAAU,cAAAf,CAAA,aAAAI,CAAA,MAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA,UAAAC,CAAA,WAAAW,SAAA,CAAAZ,CAAA,IAAAY,SAAA,CAAAZ,CAAA,QAAAA,CAAA,OAAAD,OAAA,CAAAG,MAAA,CAAAD,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AChC,QAAQ,EAAE,OAAOe,SAAS;UAC1C,OAAAvD,aAAA,CAAAA,aAAA;YACEyC,EAAE,EAAE,GAAG+B,UAAU,CAAC3C,MAAM,IAAI2C,UAAU,CAACF,QAAQ,IAAIE,UAAU,CAAChC,QAAQ,EAAEI,IAAI,IAAIgC,UAAU,IAAI,EAAE;UAAE,GAC/FJ,UAAU,CAAChC,QAAQ;YACtB0B,KAAK,EAAEM,UAAU,CAAChC,QAAQ,CAAC0B,KAAK,CAACvE,MAAM,CAAEkF,IAAI,IAAK,CAACD,UAAU,IAAIC,IAAI,CAAC5B,IAAI,KAAK2B,UAAU;UAAC;QAE9F;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_graphqlTag","data","require","_isBinaryPath","_interopRequireDefault","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","builderSchema","builder","logger","typeDefs","gql","resolvers","Component","pipelineReport","component","taskId","builderData","getBuilderData","pipeline","artifacts","getArtifactsByAspect","getArtifacts","artifactsWithVinyl","Promise","all","map","artifact","id","task","aspectId","name","artifactFiles","getArtifactsVinylByAspectAndTaskName","vinyl","basename","path","contents","isBinary","isBinaryPath","content","toString","undefined","size","byteLength","downloadUrl","encodeURI","getDownloadUrlForArtifact","externalUrl","url","description","storage","generatedBy","files","error","result","find","taskName","TaskReport","taskReport","taskDescription","errors","warnings","pathFilter","file"],"sources":["builder.graphql.ts"],"sourcesContent":["import type { Component, ComponentID } from '@teambit/component';\nimport { gql } from 'graphql-tag';\nimport type { Logger } from '@teambit/logger';\nimport isBinaryPath from 'is-binary-path';\nimport type { BuilderMain } from './builder.main.runtime';\nimport type { PipelineReport } from './build-pipeline-result-list';\n\ntype ArtifactGQLFile = {\n /**\n * same as the path - used for GQL caching\n */\n id: string;\n /**\n * name of the artifact file\n */\n name: string;\n /**\n * path of the artifact file\n */\n path: string;\n /**\n * artifact file content (only for text files). Use /api/<component-id>/~aspect/builder/<extension-id>/~<path> to fetch binary file data\n */\n content?: string;\n /**\n * REST endpoint to fetch artifact data from. /api/<component-id>/~aspect/builder/<extension-id>/~<pat\n */\n downloadUrl?: string;\n /**\n * Remote storage url to resolve artifact file from\n */\n externalUrl?: string;\n /**\n * Size in bytes\n */\n size: number;\n};\n\ntype ArtifactGQLData = {\n name: string;\n description?: string;\n storage?: string;\n generatedBy: string;\n files: ArtifactGQLFile[];\n};\ntype TaskReport = PipelineReport & {\n artifact?: ArtifactGQLData;\n componentId: ComponentID;\n};\n\nexport function builderSchema(builder: BuilderMain, logger: Logger) {\n return {\n typeDefs: gql`\n type TaskReport {\n # for GQL caching - taskId + taskName\n id: String!\n taskId: String!\n taskName: String!\n description: String\n startTime: String\n endTime: String\n errors: [String!]\n warnings: [String!]\n artifact(path: String): Artifact\n }\n\n type ArtifactFile {\n # for GQL caching - same as the path\n id: String!\n # name of the artifact file\n name: String\n # path of the artifact file\n path: String!\n # artifact file content (only for text files). Use /api/<component-id>/~aspect/builder/<extension-id>/~<path> to fetch binary file data\n content: String\n # REST endpoint to fetch artifact data from. /api/<component-id>/~aspect/builder/<extension-id>/~<path>\n downloadUrl: String\n # Remote storage url to resolve artifact file from\n externalUrl: String\n # size in bytes\n size: Int!\n }\n\n type Artifact {\n # for GQL caching - PipelineId + Artifact Name\n id: String!\n # artifact name\n name: String!\n description: String\n storage: String\n generatedBy: String\n files: [ArtifactFile!]!\n }\n\n extend type Component {\n pipelineReport(taskId: String): [TaskReport!]!\n }\n `,\n\n resolvers: {\n Component: {\n pipelineReport: async (component: Component, { taskId }: { taskId?: string }) => {\n try {\n const builderData = builder.getBuilderData(component);\n const pipeline = builderData?.pipeline || [];\n const artifacts = taskId\n ? builder.getArtifactsByAspect(component, taskId)\n : builder.getArtifacts(component);\n const artifactsWithVinyl = await Promise.all(\n artifacts.map(async (artifact) => {\n const id = artifact.task.aspectId;\n const name = artifact.task.name as string;\n try {\n const artifactFiles = (await builder.getArtifactsVinylByAspectAndTaskName(component, id, name)).map(\n (vinyl) => {\n const { basename, path, contents } = vinyl || {};\n const isBinary = path && isBinaryPath(path);\n const content = !isBinary ? contents?.toString('utf-8') : undefined;\n const size = contents.byteLength;\n const downloadUrl = encodeURI(\n builder.getDownloadUrlForArtifact(component.id, artifact.task.aspectId, path)\n );\n const externalUrl = vinyl.url;\n return { id: path, name: basename, path, content, downloadUrl, externalUrl, size };\n }\n );\n return {\n id: `${id}-${name}-${artifact.name}`,\n name: artifact.name,\n description: artifact.description,\n task: artifact.task,\n storage: artifact.storage,\n generatedBy: artifact.generatedBy,\n files: artifactFiles,\n };\n } catch (e: any) {\n logger.error(e.toString());\n return {\n id: `${id}-${name}-${artifact.name}`,\n name: artifact.name,\n description: artifact.description,\n task: artifact.task,\n storage: artifact.storage,\n generatedBy: artifact.generatedBy,\n files: [],\n };\n }\n })\n );\n\n const result = pipeline\n .filter((task) => !taskId || task.taskId === taskId)\n .map((task) => ({\n ...task,\n id: `filter-${taskId || ''}`,\n artifact: artifactsWithVinyl.find(\n (data) => data.task.aspectId === task.taskId && data.task.name === task.taskName\n ),\n }));\n\n return result;\n } catch (e: any) {\n logger.error(e.toString());\n return [];\n }\n },\n },\n TaskReport: {\n id: (taskReport: TaskReport & { id?: string }) =>\n `${(taskReport.id && `${taskReport.id}-`) || ''}${taskReport.taskId}-${taskReport.taskName}`,\n description: (taskReport: TaskReport) => taskReport.taskDescription,\n errors: (taskReport: TaskReport) => taskReport.errors?.map((e) => e.toString()) || [],\n warnings: (taskReport: TaskReport) => taskReport.warnings || [],\n artifact: async (taskReport: TaskReport, { path: pathFilter }: { path?: string }) => {\n if (!taskReport.artifact) return undefined;\n return {\n id: `${taskReport.taskId}-${taskReport.taskName}-${taskReport.artifact?.name}-${pathFilter || ''}`,\n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CAAChC,QAAQ,EAAEI,IAAI,IAAIgC,UAAU,IAAI,EAAE;UAAE,GAC/FJ,UAAU,CAAChC,QAAQ;YACtB0B,KAAK,EAAEM,UAAU,CAAChC,QAAQ,CAAC0B,KAAK,CAACvE,MAAM,CAAEkF,IAAI,IAAK,CAACD,UAAU,IAAIC,IAAI,CAAC5B,IAAI,KAAK2B,UAAU;UAAC;QAE9F;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,25 +1,27 @@
1
- import { ArtifactVinyl, ArtifactObject } from '@teambit/component.sources';
2
- import { AspectLoaderMain } from '@teambit/aspect-loader';
3
- import { CLIMain } from '@teambit/cli';
4
- import { Component, ComponentMap, IComponent, ComponentMain, ComponentID } from '@teambit/component';
5
- import { EnvsMain } from '@teambit/envs';
6
- import { GraphqlMain } from '@teambit/graphql';
7
- import { SlotRegistry } from '@teambit/harmony';
8
- import { Logger, LoggerMain } from '@teambit/logger';
9
- import { ScopeMain } from '@teambit/scope';
10
- import { Workspace } from '@teambit/workspace';
11
- import { IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';
12
- import { GeneratorMain } from '@teambit/generator';
13
- import { UiMain } from '@teambit/ui';
14
- import { IssuesMain } from '@teambit/issues';
1
+ import type { ArtifactVinyl, ArtifactObject } from '@teambit/component.sources';
2
+ import type { AspectLoaderMain } from '@teambit/aspect-loader';
3
+ import type { CLIMain } from '@teambit/cli';
4
+ import type { Component, IComponent, ComponentMain } from '@teambit/component';
5
+ import { ComponentMap, ComponentID } from '@teambit/component';
6
+ import type { EnvsMain } from '@teambit/envs';
7
+ import type { GraphqlMain } from '@teambit/graphql';
8
+ import type { SlotRegistry } from '@teambit/harmony';
9
+ import type { Logger, LoggerMain } from '@teambit/logger';
10
+ import type { ScopeMain } from '@teambit/scope';
11
+ import type { Workspace } from '@teambit/workspace';
12
+ import type { IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';
13
+ import type { GeneratorMain } from '@teambit/generator';
14
+ import type { UiMain } from '@teambit/ui';
15
+ import type { IssuesMain } from '@teambit/issues';
15
16
  import { Artifact, ArtifactList } from './artifact';
16
- import { BuilderService, BuilderServiceOptions } from './builder.service';
17
- import { BuildTask } from './build-task';
18
- import { TaskResults } from './build-pipe';
19
- import { TaskResultsList } from './task-results-list';
20
- import { AspectData, PipelineReport } from './build-pipeline-result-list';
21
- import { TaskMetadata } from './types';
22
- import { ConfigStoreMain } from '@teambit/config-store';
17
+ import type { BuilderServiceOptions } from './builder.service';
18
+ import { BuilderService } from './builder.service';
19
+ import type { BuildTask } from './build-task';
20
+ import type { TaskResults } from './build-pipe';
21
+ import type { TaskResultsList } from './task-results-list';
22
+ import type { AspectData, PipelineReport } from './build-pipeline-result-list';
23
+ import type { TaskMetadata } from './types';
24
+ import type { ConfigStoreMain } from '@teambit/config-store';
23
25
  export type TaskSlot = SlotRegistry<BuildTask[]>;
24
26
  export type OnTagResults = {
25
27
  builderDataMap: ComponentMap<RawBuilderData>;