@teambit/builder 0.0.815 → 0.0.818

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 (50) hide show
  1. package/artifact/artifact-extractor.ts +31 -30
  2. package/artifact/artifact-factory.ts +10 -17
  3. package/artifact/artifact-list.ts +61 -19
  4. package/artifact/artifact.ts +27 -18
  5. package/artifact/fs-artifact.ts +21 -0
  6. package/artifact/index.ts +1 -0
  7. package/dist/artifact/artifact-extractor.js +43 -26
  8. package/dist/artifact/artifact-extractor.js.map +1 -1
  9. package/dist/artifact/artifact-factory.d.ts +4 -4
  10. package/dist/artifact/artifact-factory.js +9 -10
  11. package/dist/artifact/artifact-factory.js.map +1 -1
  12. package/dist/artifact/artifact-list.d.ts +15 -12
  13. package/dist/artifact/artifact-list.js +68 -13
  14. package/dist/artifact/artifact-list.js.map +1 -1
  15. package/dist/artifact/artifact.d.ts +8 -26
  16. package/dist/artifact/artifact.js +33 -14
  17. package/dist/artifact/artifact.js.map +1 -1
  18. package/dist/artifact/fs-artifact.d.ts +18 -0
  19. package/dist/artifact/fs-artifact.js +35 -0
  20. package/dist/artifact/fs-artifact.js.map +1 -0
  21. package/dist/artifact/index.d.ts +1 -0
  22. package/dist/artifact/index.js +16 -0
  23. package/dist/artifact/index.js.map +1 -1
  24. package/dist/build-pipe.d.ts +2 -2
  25. package/dist/build-pipe.js.map +1 -1
  26. package/dist/build-pipeline-result-list.js +2 -2
  27. package/dist/build-pipeline-result-list.js.map +1 -1
  28. package/dist/build-task.d.ts +5 -0
  29. package/dist/build-task.js.map +1 -1
  30. package/dist/builder.graphql.d.ts +80 -4
  31. package/dist/builder.graphql.js +122 -16
  32. package/dist/builder.graphql.js.map +1 -1
  33. package/dist/builder.main.runtime.d.ts +30 -16
  34. package/dist/builder.main.runtime.js +88 -41
  35. package/dist/builder.main.runtime.js.map +1 -1
  36. package/dist/builder.route.d.ts +20 -0
  37. package/dist/builder.route.js +145 -0
  38. package/dist/builder.route.js.map +1 -0
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/storage/default-resolver.d.ts +2 -2
  42. package/dist/storage/default-resolver.js.map +1 -1
  43. package/dist/storage/storage-resolver.d.ts +3 -3
  44. package/dist/storage/storage-resolver.js.map +1 -1
  45. package/package-tar/teambit-builder-0.0.818.tgz +0 -0
  46. package/package.json +20 -14
  47. package/{preview-1660361218837.js → preview-1660620618310.js} +2 -2
  48. package/storage/default-resolver.ts +2 -2
  49. package/storage/storage-resolver.ts +3 -3
  50. package/package-tar/teambit-builder-0.0.815.tgz +0 -0
@@ -1,7 +1,7 @@
1
1
  import { EnvDefinition } from '@teambit/envs';
2
2
  import { ComponentMap } from '@teambit/component';
3
3
  import { Logger } from '@teambit/logger';
4
- import { ArtifactFactory, ArtifactList } from './artifact';
4
+ import { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';
5
5
  import { BuildTask } from './build-task';
6
6
  import { ComponentResult } from './types';
7
7
  import { TasksQueue } from './tasks-queue';
@@ -24,7 +24,7 @@ export declare type TaskResults = {
24
24
  * artifacts generated by the build pipeline.
25
25
  * in case the task finished with errors, this prop is undefined.
26
26
  */
27
- artifacts: ComponentMap<ArtifactList> | undefined;
27
+ artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;
28
28
  /**
29
29
  * timestamp of start initiation.
30
30
  */
@@ -1 +1 @@
1
- {"version":3,"names":["BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","allTasksResults","taskResults","execute","addSignalListener","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","tasksResultsList","TaskResultsList","executePostBuild","process","on","exit","setStatusLine","preBuild","getBuildContext","id","consoleSuccess","taskId","BuildTaskHelper","serializeId","taskName","description","logProgress","updateFailedDependencyTask","shouldSkipTask","startTask","hrtime","taskStartTime","Date","now","buildContext","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","errors","artifacts","failedTasks","push","duration","prettyTime","defs","generate","startTime","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","aspectId","name","deserializeIdAllowEmptyName","find","failedTask","envId","failedTaskId","consoleWarning","Error","previousTasksResults","from"],"sources":["build-pipe.ts"],"sourcesContent":["import { EnvDefinition } from '@teambit/envs';\nimport { ComponentMap } from '@teambit/component';\nimport { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { ArtifactFactory, ArtifactList } from './artifact';\nimport { BuildTask, BuildTaskHelper, BuiltTaskResult } from './build-task';\nimport { ComponentResult } from './types';\nimport { TasksQueue } from './tasks-queue';\nimport { EnvsBuildContext } from './builder.service';\nimport { TaskResultsList } from './task-results-list';\n\nexport type TaskResults = {\n /**\n * task itself. useful for getting its id/description later on.\n */\n task: BuildTask;\n\n /**\n * environment were the task was running\n */\n env: EnvDefinition;\n\n /**\n * component build results.\n */\n componentsResults: ComponentResult[];\n\n /**\n * artifacts generated by the build pipeline.\n * in case the task finished with errors, this prop is undefined.\n */\n artifacts: ComponentMap<ArtifactList> | undefined;\n\n /**\n * timestamp of start initiation.\n */\n startTime: number;\n\n /**\n * timestamp of task completion.\n */\n endTime: number;\n};\n\nexport class BuildPipe {\n private failedTasks: BuildTask[] = [];\n private failedDependencyTask: BuildTask | undefined;\n private longProcessLogger: LongProcessLogger;\n private taskResults: TaskResults[] = [];\n constructor(\n /**\n * array of services to apply on the components.\n */\n readonly tasksQueue: TasksQueue,\n readonly envsBuildContext: EnvsBuildContext,\n readonly logger: Logger,\n readonly artifactFactory: ArtifactFactory,\n private previousTaskResults?: TaskResults[]\n ) {}\n\n get allTasksResults(): TaskResults[] {\n return [...(this.previousTaskResults || []), ...(this.taskResults || [])];\n }\n\n /**\n * execute a pipeline of build tasks.\n */\n async execute(): Promise<TaskResultsList> {\n this.addSignalListener();\n await this.executePreBuild();\n this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);\n await mapSeries(this.tasksQueue, async ({ task, env }) => this.executeTask(task, env));\n this.longProcessLogger.end();\n const tasksResultsList = new TaskResultsList(this.tasksQueue, this.taskResults);\n await this.executePostBuild(tasksResultsList);\n\n return tasksResultsList;\n }\n\n /**\n * for some reason, some tasks (such as typescript compilation) ignore ctrl+C. this fixes it.\n */\n private addSignalListener() {\n process.on('SIGTERM', () => {\n process.exit();\n });\n\n process.on('SIGINT', () => {\n process.exit();\n });\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.preBuild) return;\n await task.preBuild(this.getBuildContext(env.id));\n });\n this.logger.consoleSuccess();\n }\n\n private async executeTask(task: BuildTask, env: EnvDefinition): Promise<void> {\n const taskId = BuildTaskHelper.serializeId(task);\n const taskName = `${taskId}${task.description ? ` (${task.description})` : ''}`;\n this.longProcessLogger.logProgress(`env \"${env.id}\", task \"${taskName}\"`);\n this.updateFailedDependencyTask(task);\n if (this.shouldSkipTask(taskId, env.id)) {\n return;\n }\n const startTask = process.hrtime();\n const taskStartTime = Date.now();\n const buildContext = this.getBuildContext(env.id);\n let buildTaskResult: BuiltTaskResult;\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts;\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.failedTasks.push(task);\n } else {\n const duration = prettyTime(process.hrtime(startTask));\n this.logger.consoleSuccess(`env \"${env.id}\", task \"${taskName}\" has completed successfully in ${duration}`);\n const defs = buildTaskResult.artifacts || [];\n artifacts = this.artifactFactory.generate(buildContext, defs, task);\n }\n\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults: buildTaskResult.componentsResults,\n artifacts,\n startTime: taskStartTime,\n endTime,\n };\n\n this.taskResults.push(taskResults);\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n this.logger.setStatusLine('executing post-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.postBuild) return;\n await task.postBuild(this.getBuildContext(env.id), tasksResults);\n });\n this.logger.consoleSuccess();\n }\n\n private updateFailedDependencyTask(task: BuildTask) {\n if (!this.failedDependencyTask && this.failedTasks.length && task.dependencies) {\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n this.failedDependencyTask = this.failedTasks.find((failedTask) => {\n if (name && name !== failedTask.name) return false;\n return aspectId === failedTask.aspectId;\n });\n });\n }\n }\n\n private shouldSkipTask(taskId: string, envId: string): boolean {\n if (!this.failedDependencyTask) return false;\n const failedTaskId = BuildTaskHelper.serializeId(this.failedDependencyTask);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n\n private getBuildContext(envId: string) {\n const buildContext = this.envsBuildContext[envId];\n if (!buildContext) throw new Error(`unable to find buildContext for ${envId}`);\n buildContext.previousTasksResults = this.allTasksResults;\n return buildContext;\n }\n\n /**\n * create a build pipe from an array of tasks.\n */\n static from(\n tasksQueue: TasksQueue,\n envsBuildContext: EnvsBuildContext,\n logger: Logger,\n artifactFactory: ArtifactFactory,\n previousTaskResults?: TaskResults[]\n ) {\n return new BuildPipe(tasksQueue, envsBuildContext, logger, artifactFactory, previousTaskResults);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAmCO,MAAMA,SAAN,CAAgB;EAKr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7B,YAAL,EAAmB,MAAM,IAAIgC,KAAJ,CAAW,mCAAkCH,KAAM,EAAnD,CAAN;IACnB7B,YAAY,CAACiC,oBAAb,GAAoC,KAAKtE,eAAzC;IACA,OAAOqC,YAAP;EACD;EAED;AACF;AACA;;;EACa,OAAJkC,IAAI,CACT5E,UADS,EAETC,gBAFS,EAGTC,MAHS,EAITC,eAJS,EAKTC,mBALS,EAMT;IACA,OAAO,IAAIN,SAAJ,CAAcE,UAAd,EAA0BC,gBAA1B,EAA4CC,MAA5C,EAAoDC,eAApD,EAAqEC,mBAArE,CAAP;EACD;;AAnJoB"}
1
+ {"version":3,"names":["BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","allTasksResults","taskResults","execute","addSignalListener","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","tasksResultsList","TaskResultsList","executePostBuild","process","on","exit","setStatusLine","preBuild","getBuildContext","id","consoleSuccess","taskId","BuildTaskHelper","serializeId","taskName","description","logProgress","updateFailedDependencyTask","shouldSkipTask","startTask","hrtime","taskStartTime","Date","now","buildContext","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","errors","artifacts","failedTasks","push","duration","prettyTime","defs","generate","startTime","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","aspectId","name","deserializeIdAllowEmptyName","find","failedTask","envId","failedTaskId","consoleWarning","Error","previousTasksResults","from"],"sources":["build-pipe.ts"],"sourcesContent":["import { EnvDefinition } from '@teambit/envs';\nimport { ComponentMap } from '@teambit/component';\nimport { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';\nimport { BuildTask, BuildTaskHelper, BuiltTaskResult } from './build-task';\nimport { ComponentResult } from './types';\nimport { TasksQueue } from './tasks-queue';\nimport { EnvsBuildContext } from './builder.service';\nimport { TaskResultsList } from './task-results-list';\n\nexport type TaskResults = {\n /**\n * task itself. useful for getting its id/description later on.\n */\n task: BuildTask;\n\n /**\n * environment were the task was running\n */\n env: EnvDefinition;\n\n /**\n * component build results.\n */\n componentsResults: ComponentResult[];\n\n /**\n * artifacts generated by the build pipeline.\n * in case the task finished with errors, this prop is undefined.\n */\n artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n\n /**\n * timestamp of start initiation.\n */\n startTime: number;\n\n /**\n * timestamp of task completion.\n */\n endTime: number;\n};\n\nexport class BuildPipe {\n private failedTasks: BuildTask[] = [];\n private failedDependencyTask: BuildTask | undefined;\n private longProcessLogger: LongProcessLogger;\n private taskResults: TaskResults[] = [];\n constructor(\n /**\n * array of services to apply on the components.\n */\n readonly tasksQueue: TasksQueue,\n readonly envsBuildContext: EnvsBuildContext,\n readonly logger: Logger,\n readonly artifactFactory: ArtifactFactory,\n private previousTaskResults?: TaskResults[]\n ) {}\n\n get allTasksResults(): TaskResults[] {\n return [...(this.previousTaskResults || []), ...(this.taskResults || [])];\n }\n\n /**\n * execute a pipeline of build tasks.\n */\n async execute(): Promise<TaskResultsList> {\n this.addSignalListener();\n await this.executePreBuild();\n this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);\n await mapSeries(this.tasksQueue, async ({ task, env }) => this.executeTask(task, env));\n this.longProcessLogger.end();\n const tasksResultsList = new TaskResultsList(this.tasksQueue, this.taskResults);\n await this.executePostBuild(tasksResultsList);\n\n return tasksResultsList;\n }\n\n /**\n * for some reason, some tasks (such as typescript compilation) ignore ctrl+C. this fixes it.\n */\n private addSignalListener() {\n process.on('SIGTERM', () => {\n process.exit();\n });\n\n process.on('SIGINT', () => {\n process.exit();\n });\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.preBuild) return;\n await task.preBuild(this.getBuildContext(env.id));\n });\n this.logger.consoleSuccess();\n }\n\n private async executeTask(task: BuildTask, env: EnvDefinition): Promise<void> {\n const taskId = BuildTaskHelper.serializeId(task);\n const taskName = `${taskId}${task.description ? ` (${task.description})` : ''}`;\n this.longProcessLogger.logProgress(`env \"${env.id}\", task \"${taskName}\"`);\n this.updateFailedDependencyTask(task);\n if (this.shouldSkipTask(taskId, env.id)) {\n return;\n }\n const startTask = process.hrtime();\n const taskStartTime = Date.now();\n const buildContext = this.getBuildContext(env.id);\n let buildTaskResult: BuiltTaskResult;\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.failedTasks.push(task);\n } else {\n const duration = prettyTime(process.hrtime(startTask));\n this.logger.consoleSuccess(`env \"${env.id}\", task \"${taskName}\" has completed successfully in ${duration}`);\n const defs = buildTaskResult.artifacts || [];\n artifacts = this.artifactFactory.generate(buildContext, defs, task);\n }\n\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults: buildTaskResult.componentsResults,\n artifacts,\n startTime: taskStartTime,\n endTime,\n };\n\n this.taskResults.push(taskResults);\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n this.logger.setStatusLine('executing post-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.postBuild) return;\n await task.postBuild(this.getBuildContext(env.id), tasksResults);\n });\n this.logger.consoleSuccess();\n }\n\n private updateFailedDependencyTask(task: BuildTask) {\n if (!this.failedDependencyTask && this.failedTasks.length && task.dependencies) {\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n this.failedDependencyTask = this.failedTasks.find((failedTask) => {\n if (name && name !== failedTask.name) return false;\n return aspectId === failedTask.aspectId;\n });\n });\n }\n }\n\n private shouldSkipTask(taskId: string, envId: string): boolean {\n if (!this.failedDependencyTask) return false;\n const failedTaskId = BuildTaskHelper.serializeId(this.failedDependencyTask);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n\n private getBuildContext(envId: string) {\n const buildContext = this.envsBuildContext[envId];\n if (!buildContext) throw new Error(`unable to find buildContext for ${envId}`);\n buildContext.previousTasksResults = this.allTasksResults;\n return buildContext;\n }\n\n /**\n * create a build pipe from an array of tasks.\n */\n static from(\n tasksQueue: TasksQueue,\n envsBuildContext: EnvsBuildContext,\n logger: Logger,\n artifactFactory: ArtifactFactory,\n previousTaskResults?: TaskResults[]\n ) {\n return new BuildPipe(tasksQueue, envsBuildContext, logger, artifactFactory, previousTaskResults);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAmCO,MAAMA,SAAN,CAAgB;EAKrBC,WAAW;EACT;AACJ;AACA;EACaC,UAJA,EAKAC,gBALA,EAMAC,MANA,EAOAC,eAPA,EAQDC,mBARC,EAST;IAAA,KALSJ,UAKT,GALSA,UAKT;IAAA,KAJSC,gBAIT,GAJSA,gBAIT;IAAA,KAHSC,MAGT,GAHSA,MAGT;IAAA,KAFSC,eAET,GAFSA,eAET;IAAA,KADQC,mBACR,GADQA,mBACR;IAAA,qDAbiC,EAajC;IAAA;IAAA;IAAA,qDAVmC,EAUnC;EAAE;;EAEe,IAAfC,eAAe,GAAkB;IACnC,OAAO,CAAC,IAAI,KAAKD,mBAAL,IAA4B,EAAhC,CAAD,EAAsC,IAAI,KAAKE,WAAL,IAAoB,EAAxB,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ListsMaps.forEach(artifactListMap => {
78
78
  const artifactList = artifactListMap.getValueByComponentId(component.id);
79
- if (artifactList) artifacts.push(...artifactList.toArray());
79
+ if (artifactList) artifacts.push(...artifactList);
80
80
  });
81
- return new (_artifact().ArtifactList)(artifacts);
81
+ return _artifact().ArtifactList.fromArray(artifacts);
82
82
  });
83
83
  }
84
84
 
@@ -1 +1 @@
1
- {"version":3,"names":["BuildPipelineResultList","constructor","tasksResults","components","artifactListsMap","getFlattenedArtifactListsMapFromAllTasks","artifactListsMaps","flatMap","t","artifacts","ComponentMap","as","component","forEach","artifactListMap","artifactList","getValueByComponentId","id","push","toArray","ArtifactList","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","Object","keys","data","getArtifactsDataOfComponent","toObject","currentData","existingData","isEmpty","Error","Array","isArray"],"sources":["build-pipeline-result-list.ts"],"sourcesContent":["import { ComponentID, ComponentMap, Component } from '@teambit/component';\nimport { isEmpty, compact } from 'lodash';\nimport type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport { Artifact, ArtifactList } from './artifact';\nimport { TaskResults } from './build-pipe';\nimport { Serializable, 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: Serializable;\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>;\n constructor(private tasksResults: TaskResults[], private components: Component[]) {\n this.artifactListsMap = this.getFlattenedArtifactListsMapFromAllTasks();\n }\n\n private getFlattenedArtifactListsMapFromAllTasks(): ComponentMap<ArtifactList> {\n const artifactListsMaps = this.tasksResults.flatMap((t) => (t.artifacts ? [t.artifacts] : []));\n return ComponentMap.as<ArtifactList>(this.components, (component) => {\n const artifacts: Artifact[] = [];\n artifactListsMaps.forEach((artifactListMap) => {\n const artifactList = artifactListMap.getValueByComponentId(component.id);\n if (artifactList) artifacts.push(...artifactList.toArray());\n });\n return new ArtifactList(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: Serializable, existingData: Serializable | 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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAmBA;AACA;AACA;AACO,MAAMA,uBAAN,CAA8B;EAEnCC,WAAW,CAASC,YAAT,EAA8CC,UAA9C,EAAuE;IAAA,KAA9DD,YAA8D,GAA9DA,YAA8D;IAAA,KAAzBC,UAAyB,GAAzBA,UAAyB;IAAA;IAChF,KAAKC,gBAAL,GAAwB,KAAKC,wCAAL,EAAxB;EACD;;EAEOA,wCAAwC,GAA+B;IAC7E,MAAMC,iBAAiB,GAAG,KAAKJ,YAAL,CAAkBK,OAAlB,CAA2BC,CAAD,IAAQA,CAAC,CAACC,SAAF,GAAc,CAACD,CAAC,CAACC,SAAH,CAAd,GAA8B,EAAhE,CAA1B;IACA,OAAOC,yBAAA,CAAaC,EAAb,CAA8B,KAAKR,UAAnC,EAAgDS,SAAD,IAAe;MACnE,MAAMH,SAAqB,GAAG,EAA9B;MACAH,iBAAiB,CAACO,OAAlB,CAA2BC,eAAD,IAAqB;QAC7C,MAAMC,YAAY,GAAGD,eAAe,CAACE,qBAAhB,CAAsCJ,SAAS,CAACK,EAAhD,CAArB;QACA,IAAIF,YAAJ,EAAkBN,SAAS,CAACS,IAAV,CAAe,GAAGH,YAAY,CAACI,OAAb,EAAlB;MACnB,CAHD;MAIA,OAAO,KAAIC,wBAAJ,EAAiBX,SAAjB,CAAP;IACD,CAPM,CAAP;EAQD;;EAEMY,0BAA0B,CAACC,WAAD,EAA+D;IAC9F,MAAMC,WAAW,GAAG,KAAKrB,YAAL,CAAkBsB,MAAlB,CAAyB,CAACC,GAAD,EAAMC,OAAN,K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BAAA,EAAQ1B,WAAR,CAAP;EACD;;EAEM2B,kBAAkB,CAAC5B,WAAD,EAAyC;IAChE,MAAM6B,SAAS,GAAG,KAAK9B,0BAAL,CAAgCC,WAAhC,CAAlB;IACA,OAAO8B,MAAM,CAACC,IAAP,CAAYF,SAAZ,EAAuBb,GAAvB,CAA4BN,MAAD,KAAa;MAC7CE,QAAQ,EAAEF,MADmC;MAE7CsB,IAAI,EAAEH,SAAS,CAACnB,MAAD;IAF8B,CAAb,CAA3B,CAAP;EAID;;EAEMuB,2BAA2B,CAACjC,WAAD,EAAyD;IAAA;;IACzF,gCAAO,KAAKlB,gBAAL,CAAsBY,qBAAtB,CAA4CM,WAA5C,CAAP,0DAAO,sBAA0DkC,QAA1D,EAAP;EACD;;EAEOpB,mBAAmB,CAACqB,WAAD,EAA4BC,YAA5B,EAAoE1B,MAApE,EAAoF;IAC7G,IAAI,CAAC0B,YAAD,IAAiB,IAAAC,iBAAA,EAAQD,YAAR,CAArB,EAA4C,OAAOD,WAAP,CADiE,CAE7G;;IACA,IAAI,OAAOA,WAAP,KAAuB,QAA3B,EAAqC;MACnC,MAAM,IAAIG,KAAJ,CAAW,mCAAkC,OAAOH,WAAY,QAAOzB,MAAO,EAA9E,CAAN;IACD;;IACD,IAAI6B,KAAK,CAACC,OAAN,CAAcL,WAAd,CAAJ,EAAgC;MAC9B,MAAM,IAAIG,KAAJ,CAAW,6CAA4C5B,MAAO,EAA9D,CAAN;IACD;;IACD,uCAAYyB,WAAZ,GAA4BC,YAA5B;EACD;;AAtEkC"}
1
+ {"version":3,"names":["BuildPipelineResultList","constructor","tasksResults","components","artifactListsMap","getFlattenedArtifactListsMapFromAllTasks","artifactListsMaps","flatMap","t","artifacts","ComponentMap","as","component","forEach","artifactListMap","artifactList","getValueByComponentId","id","push","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","Object","keys","data","getArtifactsDataOfComponent","toObject","currentData","existingData","isEmpty","Error","Array","isArray"],"sources":["build-pipeline-result-list.ts"],"sourcesContent":["import { ComponentID, ComponentMap, Component } from '@teambit/component';\nimport { isEmpty, compact } from 'lodash';\nimport type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport { Artifact, ArtifactList } from './artifact';\nimport { TaskResults } from './build-pipe';\nimport { Serializable, 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: Serializable;\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(private tasksResults: TaskResults[], private components: Component[]) {\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: Serializable, existingData: Serializable | 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;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAmBA;AACA;AACA;AACO,MAAMA,uBAAN,CAA8B;EAEnCC,WAAW,CAASC,YAAT,EAA8CC,UAA9C,EAAuE;IAAA,KAA9DD,YAA8D,GAA9DA,YAA8D;IAAA,KAAzBC,UAAyB,GAAzBA,UAAyB;IAAA;IAChF,KAAKC,gBAAL,GA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WAAD,EAA4BC,YAA5B,EAAoE1B,MAApE,EAAoF;IAC7G,IAAI,CAAC0B,YAAD,IAAiB,IAAAC,iBAAA,EAAQD,YAAR,CAArB,EAA4C,OAAOD,WAAP,CADiE,CAE7G;;IACA,IAAI,OAAOA,WAAP,KAAuB,QAA3B,EAAqC;MACnC,MAAM,IAAIG,KAAJ,CAAW,mCAAkC,OAAOH,WAAY,QAAOzB,MAAO,EAA9E,CAAN;IACD;;IACD,IAAI6B,KAAK,CAACC,OAAN,CAAcL,WAAd,CAAJ,EAAgC;MAC9B,MAAM,IAAIG,KAAJ,CAAW,6CAA4C5B,MAAO,EAA9D,CAAN;IACD;;IACD,uCAAYyB,WAAZ,GAA4BC,YAA5B;EACD;;AAtEkC"}
@@ -33,6 +33,11 @@ export interface BuildContext extends ExecutionContext {
33
33
  */
34
34
  dev?: boolean;
35
35
  }
36
+ export interface TaskDescriptor {
37
+ aspectId: string;
38
+ name?: string;
39
+ description?: string;
40
+ }
36
41
  export interface BuildTask {
37
42
  /**
38
43
  * aspect id serialized of the creator of the task.
@@ -1 +1 @@
1
- {"version":3,"names":["TaskIdDelimiter","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 { 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';\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\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":";;;;;;;;;AAUA;AACA;AACA;AACO,MAAMA,eAAe,GAAG,GAAxB;AAEP;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,WAA9B;;;AA8FA,MAAMC,eAAN,CAAsB;EACT,OAAXC,WAAW,CAAC;IAAEC,QAAF;IAAYC;EAAZ,CAAD,EAAiE;IACjF,OAAOD,QAAQ,GAAGJ,eAAX,GAA6BK,IAApC;EACD;;EACmB,OAAbC,aAAa,CAACC,EAAD,EAAiD;IACnE,MAAMC,KAAK,GAAGD,EAAE,CAACC,KAAH,CAASR,eAAT,CAAd;IACA,IAAIQ,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB,MAAM,IAAIC,KAAJ,CAAW,kBAAiBH,EAAG,WAA/B,CAAN;IACxB,IAAIC,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB,MAAM,IAAIC,KAAJ,CAAW,kBAAiBH,EAAG,kCAA/B,CAAN;IACxB,IAAIC,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB,OAAO;MAAEL,QAAQ,EAAEI,KAAK,CAAC,CAAD,CAAjB;MAAsBH,IAAI,EAAEG,KAAK,CAAC,CAAD;IAAjC,CAAP;IACxB,MAAM,IAAIE,KAAJ,CAAW,qBAAoBH,EAAG,sBAAqBP,eAAgB,EAAvE,CAAN;EACD;EACD;AACF;AACA;AACA;;;EACoC,OAA3BW,2BAA2B,CAACJ,EAAD,EAAkD;IAClF,OAAOA,EAAE,CAACK,QAAH,CAAYZ,eAAZ,IAA+BE,eAAe,CAACI,aAAhB,CAA8BC,EAA9B,CAA/B,GAAmE;MAAEH,QAAQ,EAAEG,EAAZ;MAAgBF,IAAI,EAAEQ;IAAtB,CAA1E;EACD;;AAjB0B"}
1
+ {"version":3,"names":["TaskIdDelimiter","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 { 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';\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\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":";;;;;;;;;AAUA;AACA;AACA;AACO,MAAMA,eAAe,GAAG,GAAxB;AAEP;AACA;AACA;AACA;;;AACO,MAAMC,qBAAqB,GAAG,WAA9B;;;AAoGA,MAAMC,eAAN,CAAsB;EACT,OAAXC,WAAW,CAAC;IAAEC,QAAF;IAAYC;EAAZ,CAAD,EAAiE;IACjF,OAAOD,QAAQ,GAAGJ,eAAX,GAA6BK,IAApC;EACD;;EACmB,OAAbC,aAAa,CAACC,EAAD,EAAiD;IACnE,MAAMC,KAAK,GAAGD,EAAE,CAACC,KAAH,CAASR,eAAT,CAAd;IACA,IAAIQ,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB,MAAM,IAAIC,KAAJ,CAAW,kBAAiBH,EAAG,WAA/B,CAAN;IACxB,IAAIC,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB,MAAM,IAAIC,KAAJ,CAAW,kBAAiBH,EAAG,kCAA/B,CAAN;IACxB,IAAIC,KAAK,CAACC,MAAN,KAAiB,CAArB,EAAwB,OAAO;MAAEL,QAAQ,EAAEI,KAAK,CAAC,CAAD,CAAjB;MAAsBH,IAAI,EAAEG,KAAK,CAAC,CAAD;IAAjC,CAAP;IACxB,MAAM,IAAIE,KAAJ,CAAW,qBAAoBH,EAAG,sBAAqBP,eAAgB,EAAvE,CAAN;EACD;EACD;AACF;AACA;AACA;;;EACoC,OAA3BW,2BAA2B,CAACJ,EAAD,EAAkD;IAClF,OAAOA,EAAE,CAACK,QAAH,CAAYZ,eAAZ,IAA+BE,eAAe,CAACI,aAAhB,CAA8BC,EAA9B,CAA/B,GAAmE;MAAEH,QAAQ,EAAEG,EAAZ;MAAgBF,IAAI,EAAEQ;IAAtB,CAA1E;EACD;;AAjB0B"}
@@ -1,12 +1,88 @@
1
- import { Component } from '@teambit/component';
1
+ import { Component, ComponentID } from '@teambit/component';
2
2
  import { BuilderMain } from './builder.main.runtime';
3
+ import { PipelineReport } from './build-pipeline-result-list';
4
+ declare type ArtifactGQLFile = {
5
+ /**
6
+ * same as the path - used for GQL caching
7
+ */
8
+ id: string;
9
+ /**
10
+ * name of the artifact file
11
+ */
12
+ name: string;
13
+ /**
14
+ * path of the artifact file
15
+ */
16
+ path: string;
17
+ /**
18
+ * artifact file content (only for text files). Use /api/<component-id>/~aspect/builder/<extension-id>/~<path> to fetch binary file data
19
+ */
20
+ content?: string;
21
+ /**
22
+ * REST endpoint to fetch artifact data from. /api/<component-id>/~aspect/builder/<extension-id>/~<pat
23
+ */
24
+ downloadUrl?: string;
25
+ /**
26
+ * Remote storage url to resolve artifact file from
27
+ */
28
+ externalUrl?: string;
29
+ };
30
+ declare type ArtifactGQLData = {
31
+ name: string;
32
+ description?: string;
33
+ storage?: string;
34
+ generatedBy: string;
35
+ files: ArtifactGQLFile[];
36
+ };
37
+ declare type TaskReport = PipelineReport & {
38
+ artifact?: ArtifactGQLData;
39
+ componentId: ComponentID;
40
+ };
3
41
  export declare function builderSchema(builder: BuilderMain): {
4
42
  typeDefs: import("graphql").DocumentNode;
5
43
  resolvers: {
6
44
  Component: {
7
- getArtifacts: (component: Component, { hash }: {
8
- hash: string;
9
- }) => Promise<void>;
45
+ pipelineReport: (component: Component, { taskId }: {
46
+ taskId?: string | undefined;
47
+ }) => Promise<{
48
+ artifact: {
49
+ files: {
50
+ id: string;
51
+ name: string;
52
+ path: string;
53
+ content: string | undefined;
54
+ downloadUrl: string;
55
+ externalUrl: string | undefined;
56
+ }[];
57
+ def: import("./artifact").ArtifactDefinition;
58
+ task: import("./build-task").TaskDescriptor;
59
+ timestamp: number;
60
+ } | undefined;
61
+ taskId: string;
62
+ taskName: string;
63
+ taskDescription?: string | undefined;
64
+ startTime?: number | undefined;
65
+ endTime?: number | undefined;
66
+ errors?: (string | Error)[] | undefined;
67
+ warnings?: string[] | undefined;
68
+ }[]>;
69
+ };
70
+ TaskReport: {
71
+ id: (taskReport: TaskReport) => string;
72
+ description: (taskReport: TaskReport) => string | undefined;
73
+ errors: (taskReport: TaskReport) => string[];
74
+ warnings: (taskReport: TaskReport) => string[];
75
+ artifact: (taskReport: TaskReport, { path: pathFilter }: {
76
+ path?: string;
77
+ }) => Promise<{
78
+ files: ArtifactGQLFile[];
79
+ name: string;
80
+ description?: string | undefined;
81
+ storage?: string | undefined;
82
+ generatedBy: string;
83
+ id: string;
84
+ } | undefined>;
10
85
  };
11
86
  };
12
87
  };
88
+ export {};
@@ -2,6 +2,8 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ require("core-js/modules/es.array.iterator.js");
6
+
5
7
  require("core-js/modules/es.promise.js");
6
8
 
7
9
  Object.defineProperty(exports, "__esModule", {
@@ -9,6 +11,16 @@ Object.defineProperty(exports, "__esModule", {
9
11
  });
10
12
  exports.builderSchema = builderSchema;
11
13
 
14
+ function _defineProperty2() {
15
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+
17
+ _defineProperty2 = function () {
18
+ return data;
19
+ };
20
+
21
+ return data;
22
+ }
23
+
12
24
  function _graphqlTag() {
13
25
  const data = _interopRequireDefault(require("graphql-tag"));
14
26
 
@@ -19,35 +31,129 @@ function _graphqlTag() {
19
31
  return data;
20
32
  }
21
33
 
22
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
+ function _isBinaryPath() {
35
+ const data = _interopRequireDefault(require("is-binary-path"));
36
+
37
+ _isBinaryPath = function () {
38
+ return data;
39
+ };
40
+
41
+ return data;
42
+ }
43
+
44
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
45
+
46
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
47
+
23
48
  function builderSchema(builder) {
24
49
  return {
25
50
  typeDefs: (0, _graphqlTag().default)`
26
- type ExtensionDescriptor {
27
- # extension ID.
28
- id: String
51
+ type TaskReport {
52
+ # for GQL caching - taskId + taskName
53
+ id: String!
54
+ taskId: String!
55
+ taskName: String!
56
+ description: String
57
+ startTime: String
58
+ endTime: String
59
+ errors: [String!]
60
+ warnings: [String!]
61
+ artifact(path: String): Artifact
62
+ }
29
63
 
30
- # icon of the extension.
31
- icon: String
64
+ type ArtifactFile {
65
+ # for GQL caching - same as the path
66
+ id: String!
67
+ # name of the artifact file
68
+ name: String
69
+ # path of the artifact file
70
+ path: String!
71
+ # artifact file content (only for text files). Use /api/<component-id>/~aspect/builder/<extension-id>/~<path> to fetch binary file data
72
+ content: String
73
+ # REST endpoint to fetch artifact data from. /api/<component-id>/~aspect/builder/<extension-id>/~<pat
74
+ downloadUrl: String
75
+ # Remote storage url to resolve artifact file from
76
+ externalUrl: String
32
77
  }
33
78
 
34
- type ExtensionArtifact {
35
- # descriptor of the artifact's extension
36
- extensionDescriptor: ExtensionDescriptor
79
+ type Artifact {
80
+ # for GQL caching - PipelineId + Artifact Name
81
+ id: String!
82
+ # artifact name
83
+ name: String!
84
+ description: String
85
+ storage: String
86
+ generatedBy: String
87
+ files: [ArtifactFile!]!
37
88
  }
38
89
 
39
90
  extend type Component {
40
- # list of extension artifacts.
41
- getArtifacts(hash: String!): [ExtensionArtifact]
91
+ pipelineReport(taskId: String): [TaskReport!]!
42
92
  }
43
93
  `,
44
94
  resolvers: {
45
95
  Component: {
46
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
47
- getArtifacts: async (component, {
48
- hash
49
- }) => {// const artifacts = await builder.getArtifacts(component.id, hash);
50
- // return artifacts.map((artifact) => artifact.toObject());
96
+ pipelineReport: async (component, {
97
+ taskId
98
+ }) => {
99
+ const builderData = builder.getBuilderData(component);
100
+ const pipeline = (builderData === null || builderData === void 0 ? void 0 : builderData.pipeline) || [];
101
+ const artifacts = taskId ? builder.getArtifactsByAspect(component, taskId) : builder.getArtifacts(component);
102
+ const artifactsWithVinyl = await Promise.all(artifacts.map(async artifact => {
103
+ const id = artifact.task.aspectId;
104
+ const name = artifact.task.name;
105
+ const artifactFiles = (await builder.getArtifactsVinylByAspectAndTaskName(component, id, name)).map(vinyl => {
106
+ const {
107
+ basename,
108
+ path,
109
+ contents
110
+ } = vinyl || {};
111
+ const isBinary = path && (0, _isBinaryPath().default)(path);
112
+ const content = !isBinary ? contents === null || contents === void 0 ? void 0 : contents.toString('utf-8') : undefined;
113
+ const downloadUrl = encodeURI(builder.getDownloadUrlForArtifact(component.id, artifact.task.aspectId, path));
114
+ const externalUrl = vinyl.url;
115
+ return {
116
+ id: path,
117
+ name: basename,
118
+ path,
119
+ content,
120
+ downloadUrl,
121
+ externalUrl
122
+ };
123
+ });
124
+
125
+ const artifactObj = _objectSpread(_objectSpread({}, artifact), {}, {
126
+ files: artifactFiles
127
+ });
128
+
129
+ return artifactObj;
130
+ }));
131
+ const result = pipeline.map(task => _objectSpread(_objectSpread({}, task), {}, {
132
+ artifact: artifactsWithVinyl.find(data => data.task.aspectId === task.taskId && data.task.name === task.taskName)
133
+ }));
134
+ return result;
135
+ }
136
+ },
137
+ TaskReport: {
138
+ id: taskReport => `${taskReport.taskId}-${taskReport.taskName}`,
139
+ description: taskReport => taskReport.taskDescription,
140
+ errors: taskReport => {
141
+ var _taskReport$errors;
142
+
143
+ return ((_taskReport$errors = taskReport.errors) === null || _taskReport$errors === void 0 ? void 0 : _taskReport$errors.map(e => e.toString())) || [];
144
+ },
145
+ warnings: taskReport => taskReport.warnings || [],
146
+ artifact: async (taskReport, {
147
+ path: pathFilter
148
+ }) => {
149
+ var _taskReport$artifact;
150
+
151
+ if (!taskReport.artifact) return undefined;
152
+ return _objectSpread(_objectSpread({
153
+ id: `${taskReport.taskId}-${taskReport.taskName}-${(_taskReport$artifact = taskReport.artifact) === null || _taskReport$artifact === void 0 ? void 0 : _taskReport$artifact.name}`
154
+ }, taskReport.artifact), {}, {
155
+ files: taskReport.artifact.files.filter(file => !pathFilter || file.path === pathFilter)
156
+ });
51
157
  }
52
158
  }
53
159
  }
@@ -1 +1 @@
1
- {"version":3,"names":["builderSchema","builder","typeDefs","gql","resolvers","Component","getArtifacts","component","hash"],"sources":["builder.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport gql from 'graphql-tag';\n\nimport { BuilderMain } from './builder.main.runtime';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function builderSchema(builder: BuilderMain) {\n return {\n typeDefs: gql`\n type ExtensionDescriptor {\n # extension ID.\n id: String\n\n # icon of the extension.\n icon: String\n }\n\n type ExtensionArtifact {\n # descriptor of the artifact's extension\n extensionDescriptor: ExtensionDescriptor\n }\n\n extend type Component {\n # list of extension artifacts.\n getArtifacts(hash: String!): [ExtensionArtifact]\n }\n `,\n resolvers: {\n Component: {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n getArtifacts: async (component: Component, { hash }: { hash: string }) => {\n // const artifacts = await builder.getArtifacts(component.id, hash);\n // return artifacts.map((artifact) => artifact.toObject());\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;AACO,SAASA,aAAT,CAAuBC,OAAvB,EAA6C;EAClD,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAA,CAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAnBS;IAoBLC,SAAS,EAAE;MACTC,SAAS,EAAE;QACT;QACAC,YAAY,EAAE,OAAOC,SAAP,EAA6B;UAAEC;QAAF,CAA7B,KAA4D,CACxE;UACA;QACD;MALQ;IADF;EApBN,CAAP;AA8BD"}
1
+ {"version":3,"names":["builderSchema","builder","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","downloadUrl","encodeURI","getDownloadUrlForArtifact","externalUrl","url","artifactObj","files","result","find","data","taskName","TaskReport","taskReport","description","taskDescription","errors","e","warnings","pathFilter","filter","file"],"sources":["builder.graphql.ts"],"sourcesContent":["import { Component, ComponentID } from '@teambit/component';\nimport gql from 'graphql-tag';\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\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) {\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>/~<pat\n downloadUrl: String\n # Remote storage url to resolve artifact file from\n externalUrl: String\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 const builderData = builder.getBuilderData(component);\n const pipeline = builderData?.pipeline || [];\n const artifacts = taskId ? builder.getArtifactsByAspect(component, taskId) : builder.getArtifacts(component);\n\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 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 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 };\n }\n );\n const artifactObj = { ...artifact, files: artifactFiles };\n return artifactObj;\n })\n );\n\n const result = pipeline.map((task) => ({\n ...task,\n artifact: artifactsWithVinyl.find(\n (data) => data.task.aspectId === task.taskId && data.task.name === task.taskName\n ),\n }));\n\n return result;\n },\n },\n TaskReport: {\n id: (taskReport: TaskReport) => `${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}`,\n ...taskReport.artifact,\n files: taskReport.artifact.files.filter((file) => !pathFilter || file.path === pathFilter),\n };\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AA2CO,SAASA,aAAT,CAAuBC,OAAvB,EAA6C;EAClD,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAA,CAAI;AAClB;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KA5CS;IA8CLC,SAAS,EAAE;MACTC,SAAS,EAAE;QACTC,cAAc,EAAE,OAAOC,SAAP,EAA6B;UAAEC;QAAF,CAA7B,KAAiE;UAC/E,MAAMC,WAAW,GAAGR,OAAO,CAACS,cAAR,CAAuBH,SAAvB,CAApB;UACA,MAAMI,QAAQ,GAAG,CAAAF,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEE,QAAb,KAAyB,EAA1C;UACA,MAAMC,SAAS,GAAGJ,MAAM,GAAGP,OAAO,CAACY,oBAAR,CAA6BN,SAA7B,EAAwCC,MAAxC,CAAH,GAAqDP,OAAO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1,7 +1,8 @@
1
1
  import { ArtifactVinyl } from '@teambit/legacy/dist/consumer/component/sources/artifact';
2
+ import { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
2
3
  import { AspectLoaderMain } from '@teambit/aspect-loader';
3
4
  import { CLIMain } from '@teambit/cli';
4
- import { Component, IComponent } from '@teambit/component';
5
+ import { Component, IComponent, ComponentMain, ComponentID } from '@teambit/component';
5
6
  import { EnvsMain } from '@teambit/envs';
6
7
  import { GraphqlMain } from '@teambit/graphql';
7
8
  import { SlotRegistry } from '@teambit/harmony';
@@ -10,8 +11,8 @@ import { ScopeMain, OnTagResults } from '@teambit/scope';
10
11
  import { Workspace } from '@teambit/workspace';
11
12
  import { IsolateComponentsOptions, IsolatorMain } from '@teambit/isolator';
12
13
  import { OnTagOpts } from '@teambit/legacy/dist/scope/scope';
13
- import { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
14
14
  import { GeneratorMain } from '@teambit/generator';
15
+ import { Artifact, ArtifactList } from './artifact';
15
16
  import { BuilderService, BuilderServiceOptions } from './builder.service';
16
17
  import { BuildTask } from './build-task';
17
18
  import { TaskResults } from './build-pipe';
@@ -19,12 +20,22 @@ import { TaskResultsList } from './task-results-list';
19
20
  import { AspectData, PipelineReport } from './build-pipeline-result-list';
20
21
  import { Serializable } from './types';
21
22
  export declare type TaskSlot = SlotRegistry<BuildTask[]>;
22
- export declare type BuilderData = {
23
+ export declare const FILE_PATH_PARAM_DELIM = "~";
24
+ /**
25
+ * builder data format for the bit object store
26
+ */
27
+ export declare type RawBuilderData = {
23
28
  pipeline: PipelineReport[];
24
- artifacts: ArtifactObject[] | undefined;
29
+ artifacts?: ArtifactObject[];
25
30
  aspectsData: AspectData[];
26
31
  bitVersion?: string;
27
32
  };
33
+ /**
34
+ * builder data mapped to an ArtifactList instance
35
+ */
36
+ export declare type BuilderData = Omit<RawBuilderData, 'artifacts'> & {
37
+ artifacts: ArtifactList<Artifact>;
38
+ };
28
39
  export declare class BuilderMain {
29
40
  private envs;
30
41
  private workspace;
@@ -34,23 +45,24 @@ export declare class BuilderMain {
34
45
  private scope;
35
46
  private isolator;
36
47
  private aspectLoader;
48
+ private componentAspect;
37
49
  private buildTaskSlot;
38
50
  private tagTaskSlot;
39
51
  private snapTaskSlot;
40
- constructor(envs: EnvsMain, workspace: Workspace, buildService: BuilderService, tagService: BuilderService, snapService: BuilderService, scope: ScopeMain, isolator: IsolatorMain, aspectLoader: AspectLoaderMain, buildTaskSlot: TaskSlot, tagTaskSlot: TaskSlot, snapTaskSlot: TaskSlot);
52
+ constructor(envs: EnvsMain, workspace: Workspace, buildService: BuilderService, tagService: BuilderService, snapService: BuilderService, scope: ScopeMain, isolator: IsolatorMain, aspectLoader: AspectLoaderMain, componentAspect: ComponentMain, buildTaskSlot: TaskSlot, tagTaskSlot: TaskSlot, snapTaskSlot: TaskSlot);
41
53
  private storeArtifacts;
42
54
  private pipelineResultsToBuilderData;
43
55
  tagListener(components: Component[], options?: OnTagOpts, isolateOptions?: IsolateComponentsOptions): Promise<OnTagResults>;
44
56
  private validateBuilderDataMap;
45
- getArtifactsVinylByExtension(component: Component, aspectName: string): Promise<ArtifactVinyl[]>;
46
- getArtifactsVinylByExtensionAndName(component: Component, aspectName: string, name: string): Promise<ArtifactVinyl[]>;
47
- getArtifactsVinylByExtensionAndTaskName(component: Component, aspectName: string, taskName: string): Promise<ArtifactVinyl[]>;
48
- getArtifactsByName(component: Component, name: string): ArtifactObject[] | undefined;
49
- getArtifactsByExtension(component: Component, aspectName: string): ArtifactObject[] | undefined;
50
- getArtifactsByExtensionAndName(component: Component, aspectName: string, name: string): ArtifactObject[] | undefined;
51
- getArtifactsByExtensionAndTaskName(component: Component, aspectName: string, taskName: string): ArtifactObject[] | undefined;
57
+ getArtifactsVinylByAspect(component: Component, aspectName: string): Promise<ArtifactVinyl[]>;
58
+ getArtifactsVinylByAspectAndName(component: Component, aspectName: string, name: string): Promise<ArtifactVinyl[]>;
59
+ getArtifactsVinylByAspectAndTaskName(component: Component, aspectName: string, name: string): Promise<ArtifactVinyl[]>;
60
+ getArtifactsByName(component: Component, name: string): ArtifactList<Artifact>;
61
+ getArtifactsByAspect(component: Component, aspectName: string): ArtifactList<Artifact>;
62
+ getArtifactsByAspectAndName(component: Component, aspectName: string, name: string): ArtifactList<Artifact>;
63
+ getArtifactsbyAspectAndTaskName(component: Component, aspectName: string, taskName: string): ArtifactList<Artifact>;
52
64
  getDataByAspect(component: IComponent, aspectName: string): Serializable | undefined;
53
- getArtifacts(component: Component): ArtifactObject[] | undefined;
65
+ getArtifacts(component: Component): ArtifactList<Artifact>;
54
66
  getBuilderData(component: IComponent): BuilderData | undefined;
55
67
  /**
56
68
  * build given components for release.
@@ -62,7 +74,7 @@ export declare class BuilderMain {
62
74
  runTagTasks(components: Component[], isolateOptions?: IsolateComponentsOptions, previousTasksResults?: TaskResults[]): Promise<TaskResultsList>;
63
75
  runSnapTasks(components: Component[], isolateOptions?: IsolateComponentsOptions, previousTasksResults?: TaskResults[]): Promise<TaskResultsList>;
64
76
  listTasks(component: Component): {
65
- id: import("@teambit/component").ComponentID;
77
+ id: ComponentID;
66
78
  envId: string;
67
79
  buildTasks: string[];
68
80
  tagTasks: string[];
@@ -87,10 +99,11 @@ export declare class BuilderMain {
87
99
  * this pipeline is running once the build-pipeline has completed.
88
100
  */
89
101
  registerSnapTasks(tasks: BuildTask[]): this;
102
+ getDownloadUrlForArtifact(componentId: ComponentID, taskId: string, path?: string): string;
90
103
  static slots: ((registerFn: () => string) => SlotRegistry<BuildTask>)[];
91
104
  static runtime: import("@teambit/harmony").RuntimeDefinition;
92
105
  static dependencies: import("@teambit/harmony").Aspect[];
93
- static provider([cli, envs, workspace, scope, isolator, loggerExt, aspectLoader, graphql, generator]: [
106
+ static provider([cli, envs, workspace, scope, isolator, loggerExt, aspectLoader, graphql, generator, component]: [
94
107
  CLIMain,
95
108
  EnvsMain,
96
109
  Workspace,
@@ -99,6 +112,7 @@ export declare class BuilderMain {
99
112
  LoggerMain,
100
113
  AspectLoaderMain,
101
114
  GraphqlMain,
102
- GeneratorMain
115
+ GeneratorMain,
116
+ ComponentMain
103
117
  ], config: any, [buildTaskSlot, tagTaskSlot, snapTaskSlot]: [TaskSlot, TaskSlot, TaskSlot]): Promise<BuilderMain>;
104
118
  }