@teambit/builder 1.0.234 → 1.0.237

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.
@@ -1,4 +1,4 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <testsuites tests="0" failures="0" errors="0" skipped="0">
3
- <testsuite name="teambit.pipelines/builder@1.0.234" tests="0" failures="0" errors="0" skipped="0"/>
3
+ <testsuite name="teambit.pipelines/builder@1.0.237" tests="0" failures="0" errors="0" skipped="0"/>
4
4
  </testsuites>
@@ -1 +1 @@
1
- !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["teambit.pipelines/builder-preview"]=n():e["teambit.pipelines/builder-preview"]=n()}(self,(()=>(()=>{"use strict";var e={77456:(e,n,t)=>{var i={id:"teambit.pipelines/aspect-docs/builder@0.0.167",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=u,o(t(41594));var a=t(5016),r=["components"];function o(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},s.apply(this,arguments)}function l(e,n){if(null==e)return{};var t,i,a=d(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function d(e,n){if(null==e)return{};var t,i,a={},r=Object.keys(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||(a[t]=e[t]);return a}o.__bit_component=i,s.__bit_component=i,l.__bit_component=i,d.__bit_component=i;var p={},m="wrapper";function u(e){var n=e.components,t=l(e,r);return(0,a.mdx)(m,s({},p,t,{components:n,mdxType:"MDXLayout"}),(0,a.mdx)("h2",null,"Background"),(0,a.mdx)("p",null,"Bit's build process is an extensible CI for independent components. It validates a component is not dependent on its context (the workspace), tests it, and generates all artifacts necessary for it to be viewed and consumed as an independent module (its distributable code, bundled preview, etc.)."),(0,a.mdx)("p",null,"The Build Pipeline is an Environment Service responsible for sequencing and executing a component's Build Tasks. As mentioned earlier, these tasks are performed on a component only after it's been isolated from the rest of the workspace."),(0,a.mdx)("p",null,"A component's default series of Build Tasks is composed of tasks set by Bit and by its environment."),(0,a.mdx)("h2",null,"Isolated builds"),(0,a.mdx)("p",null,"Components authored in a Bit workspace are created to be completely portable, and thus independent. To address that, the build process starts by creating a component 'capsule' which is an isolated instance of a component, generated in a separate directory in your filesystem."),(0,a.mdx)("p",null,'As part of the capsule creation, all packages listed as dependencies of that component will be installed. This step is necessary to validate there are no dependency-graph issues (a component that is not totally isolated will be able to use packages installed in parent directories in your workspace, by other components. This will translate into a "false positive" result when testing for dependency-graph issues in a non-isolated location).'),(0,a.mdx)("h2",null,"Incremental builds"),(0,a.mdx)("p",null,'When a component "goes through" the build pipeline, all of its dependencies are built as well. If a dependency has not changed since its last build, the build process will use its artifacts from the previous build (and will not process it again). This optimization to the build process supplements the "innate optimization" that naturally comes from developing (and building) independent components instead of a single monolithic codebase.'),(0,a.mdx)("h2",null,"Environment-specific builds"),(0,a.mdx)("p",null,"Each Bit environment determines its own build pipeline. That means, a single workspace that uses multiple environments will run a different set of build tasks on different components depending on their associated environment. This is another Bit feature that enables seamless transitioning between different development environments, all in the same workspace. It also makes it much easier to integrate the Build Pipeline in your (remote) CI, as it only requires executing the build step - all other per-component build configurations are already set by the various environments being used."),(0,a.mdx)("p",null,"Since environments are extensible, so are the build pipelines configured by them."),(0,a.mdx)("h2",null,"Build task"),(0,a.mdx)("p",null,"An example of a build-task is ",(0,a.mdx)("inlineCode",{parentName:"p"},"compile"),", it's written in the compiler aspect and is running on each one of the capsules created by the build process. build-tasks in many cases generate artifacts, in this case, the compiler generates ",(0,a.mdx)("inlineCode",{parentName:"p"},"dists")," files and write them on the isolated capsules. There artifacts files are used later for example when creating packages."),(0,a.mdx)("h2",null,"Pipelines"),(0,a.mdx)("p",null,"There are three pipelines: ",(0,a.mdx)("inlineCode",{parentName:"p"},"build"),", ",(0,a.mdx)("inlineCode",{parentName:"p"},"tag")," and ",(0,a.mdx)("inlineCode",{parentName:"p"},"snap"),"."),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit build")," runs the build pipeline."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit tag")," runs the build pipeline and then the tag pipeline."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit snap")," runs the build pipeline and then the snap pipeline.")),(0,a.mdx)("h2",null,"List Build Tasks"),(0,a.mdx)("p",null,"To get a list of all the tasks that will be running per pipeline on a specific component, run ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit build --list-tasks <id>"),".\nHere is an example of the relevant part from the output:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre"},"➜ bit build --list-tasks ui/tooltip\nTasks List\nid: teambit.design/ui/tooltip@0.0.347\nenvId: teambit.react/react\n\nBuild Pipeline Tasks:\nteambit.harmony/aspect:CoreExporter\nteambit.compilation/compiler:TSCompiler\nteambit.defender/tester:TestComponents\nteambit.pkg/pkg:PreparePackages\nteambit.pkg/pkg:PublishDryRun\nteambit.preview/preview:GeneratePreview\n\nTag Pipeline Tasks:\nteambit.harmony/application:build_ui_application\nteambit.pkg/pkg:PublishComponents\n\nSnap Pipeline Tasks:\n<N/A>\n")),(0,a.mdx)("h2",null,"Implementing Build Tasks"),(0,a.mdx)("p",null,"The ",(0,a.mdx)("inlineCode",{parentName:"p"},"BuildTask")," interface is a good start to understand how to implement a new build-task.\nWhen writing a build task, the ",(0,a.mdx)("inlineCode",{parentName:"p"},"Network")," object is passed and it includes the seeders capsules, as well as the entire graph including the dependencies.\nKeep in mind that the entire graph may contain components from other envs."),(0,a.mdx)("p",null,"Some tasks, such as, compiling in typescript and bundling with Webpack, need the entire graph.\nOthers, such as, Babel, need only the seeders. However, normally, the bundling is running after the compilation and it expects to have the dependencies compiled, so you might need the entire graph regardless."),(0,a.mdx)("h2",null,"Adding Tasks to a pipeline"),(0,a.mdx)("p",null,"There are two ways of adding tasks to the build pipeline."),(0,a.mdx)("ol",null,(0,a.mdx)("li",{parentName:"ol"},(0,a.mdx)("inlineCode",{parentName:"li"},"getBuildPipe()")," method of the env. (or ",(0,a.mdx)("inlineCode",{parentName:"li"},"getTagPipe()")," and ",(0,a.mdx)("inlineCode",{parentName:"li"},"getSnapPipe()"),")"),(0,a.mdx)("li",{parentName:"ol"},"registering to the slot via ",(0,a.mdx)("inlineCode",{parentName:"li"},"builder.registerBuildTask()"),". (or ",(0,a.mdx)("inlineCode",{parentName:"li"},"registerTagTask()")," and ",(0,a.mdx)("inlineCode",{parentName:"li"},"registerSnapTask()"),")")),(0,a.mdx)("p",null,"in the option #1, it's possible to determine the order. e.g. ",(0,a.mdx)("inlineCode",{parentName:"p"},"getBuildPipe() { return [taskA, taskB, taskC]; }"),"\nin the option #2, the register happens once the extension is loaded, so there is no way to put\none task before/after another task as of now."),(0,a.mdx)("h2",null,"Sequencing the build tasks"),(0,a.mdx)("p",null,"The Build Pipeline takes into consideration the following factors when deciding the order of which to execute each task:"),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("strong",{parentName:"li"},"Location"),": A task can be executed either at the start or end of the build pipeline. This can be explicitly configured by the task itself."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("strong",{parentName:"li"},"Dependencies"),": A task can depend on other tasks. That means, the dependencies must be completed successfully for all envs before this task starts. The dependencies are applicable inside a location and not across locations. This is configured by the task itself."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("strong",{parentName:"li"},"An environment's list of build tasks"),": This is the array of tasks as it is defined by an environment")),(0,a.mdx)("h2",null,"Executing the pipelines"),(0,a.mdx)("p",null,"Commands that trigger the build pipeline:"),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit build")," - runs the build pipeline on your local machine, for the entire workspace. The output data will not persist. - That is most often used for testing and debugging the build process."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit tag")," - runs the tag pipeline in addition to the build pipeline, before creating a new component release version. The output data will persist."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit snap")," - runs the snap pipeline in addition to the build pipeline. The output data will persist.")),(0,a.mdx)("p",null,"Build pipelines are determined by the environments in use. That means, in order to override the default pipeline, we need to create a new environment extension or modify an existing one."),(0,a.mdx)("p",null,"The example task below, shown being used by a customized environment, prints out the component name of every component handled by it. In addition to that, the task returns the component name as custom metadata to be logged and/or stored in the component tagged version. ",(0,a.mdx)("a",{parentName:"p",href:"https://github.com/teambit/harmony-build-examples"},"See a demo project here"),"."),(0,a.mdx)("blockquote",null,(0,a.mdx)("p",{parentName:"blockquote"},"Information returned by a build task will only persist if the build-pipeline was triggered by the 'hard-tag' command (",(0,a.mdx)("inlineCode",{parentName:"p"},"bit tag <component-id>"),").")),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="print-cmp-name-task.ts"',title:'"print-cmp-name-task.ts"'},"import { BuildTask, BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\n\n// A task is an implementation of 'BuildTask' provided by the 'builder' aspect\nexport class PrintCmpNameTask implements BuildTask {\n // The constructor leaves these properties up to the hands of the environment using this task\n constructor(readonly aspectId: string, readonly name: string) {}\n\n // This is where the task logic is placed. It will be executed by the build pipeline\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults: ComponentResult[] = [];\n\n // Go through every isolated component instance\n context.capsuleNetwork.seedersCapsules.forEach((capsule) => {\n console.log(`The current component name is: ${capsule.component.id.name}`);\n\n componentsResults.push({\n component: capsule.component,\n metadata: { customProp: capsule.component.id.name },\n });\n });\n return {\n // An array of component objects, enriched with additional data produced by the task\n componentsResults,\n };\n }\n}\n")),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="customized-react.extension.ts"',title:'"customized-react.extension.ts"'},"import { EnvsMain, EnvsAspect } from '@teambit/envs';\nimport { ReactAspect, ReactMain } from '@teambit/react';\n\n// Import the task\nimport { PrintCmpNameTask } from './print-cmp-name-task';\n\nexport class CustomReact {\n constructor(private react: ReactMain) {}\n\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n static async provider([envs, react]: [EnvsMain, ReactMain]) {\n // Get the environment's default build pipeline\n const reactPipe = react.env.getBuildPipe();\n\n // Add the custom task to the end of the build tasks sequence.\n // Provide the task with the component ID of the extension using it.\n // Provide the ask with a name.\n const tasks = [...reactPipe, new PrintCompTask('extensions/custom-react', 'PrintCmpNameTask')];\n\n // Create a new environment by merging these configurations with the env's default ones\n const customReactEnv = react.compose([react.overrideBuildPipe(tasks)]);\n\n // register the extension as an environment\n envs.registerEnv(customReactEnv);\n return new CustomReact(react);\n }\n}\n")),(0,a.mdx)("h2",null,"Positioning a build task in the pipeline"),(0,a.mdx)("p",null,"A build task is positioned in the build pipeline sequence either by overriding the entire ",(0,a.mdx)("em",{parentName:"p"},"customizable")," pipeline or, by registering it to a location in the pipeline using the designated builder slot."),(0,a.mdx)("h3",null,"Override the build pipeline sequence"),(0,a.mdx)("p",null,"This methodology leaves the task completely agnostic as to its position in the build pipeline. Instead, the task position is determined by the environment using the ",(0,a.mdx)("inlineCode",{parentName:"p"},"getBuildPipe")," Environment Handler."),(0,a.mdx)("p",null,"The example above shows the React environment ",(0,a.mdx)("inlineCode",{parentName:"p"},"overrideBuildPipe")," method being used to override its default pipeline. This method uses the ",(0,a.mdx)("inlineCode",{parentName:"p"},"getBuildPipe()")," Environment Handler, internally."),(0,a.mdx)("h3",null,"Append to the start or end of the pipeline, in relation to other tasks"),(0,a.mdx)("p",null,"This methodology places the task at the start or end of the build pipeline sequence, and lists all other tasks needed to run successfully before it is executed."),(0,a.mdx)("p",null,"Example:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="print-cmp-name-task.ts"',title:'"print-cmp-name-task.ts"'},"import { BuildTask, BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\n\nexport class PrintCmpNameTask implements BuildTask {\n constructor(readonly aspectId: string, readonly name: string) {}\n\n // Place the task at the end of the build pipeline\n readonly location = 'end';\n\n // Run this task only after the '@teambit/preview' task is completed successfully\n readonly dependencies = ['@teambit/preview'];\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults: ComponentResult[] = [];\n context.capsuleNetwork.seedersCapsules.forEach((capsule) => {\n console.log(`The current component name is: ${capsule.component.id.name}`);\n\n componentsResults.push({\n component: capsule.component,\n metadata: { customProp: capsule.component.id.name },\n });\n });\n return {\n componentsResults,\n };\n }\n}\n")),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="customized-react.extension.ts"',title:'"customized-react.extension.ts"'},"import { EnvsMain, EnvsAspect } from '@teambit/envs';\nimport { ReactAspect, ReactMain } from '@teambit/react';\nimport { BuilderMain } from '@teambit/builder';\n\n// Import the task (in reality, it should be an independent component)\nimport { PrintCmpNameTask } from './print-cmp-name-task';\n\nexport class CustomReact {\n constructor(private react: ReactMain) {}\n\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n // Inject the builder\n static async provider([envs, react, builder]: [EnvsMain, ReactMain, BuilderMain]) {\n // Register this task using the registration slot, made available by the 'builder'.\n // Here, the environment has no say in the positioning of the task\n builder.registerBuildTasks([new ExampleTask('extensions/custom-react', 'PrintCmpNameTask')]);\n\n const customReactEnv = react.compose([]);\n\n envs.registerEnv(customReactEnv);\n return new CustomReact(react);\n }\n}\n")),(0,a.mdx)("h2",null,"A build task anatomy"),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"aspectId")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"aspectId: string"),(0,a.mdx)("br",null),"\nThe component ID of the environment using this task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"name")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"name: string")," ",(0,a.mdx)("br",null),"\nA name for this task. Only alphanumerical characters are allowed. PascalCase should be used as a convention.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"location")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"location?: 'start' | 'end'")," ",(0,a.mdx)("br",null),"\nThe section of the build-pipeline to which to append this task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"dependencies")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"dependencies?: string[]")," ",(0,a.mdx)("br",null),"\nAn list of tasks that must be completed before this task gets executed. ",(0,a.mdx)("br",null),"\nFor example ",(0,a.mdx)("inlineCode",{parentName:"p"},"dependencies = ['@teambit/preview']"),".")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"execute")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"execute(context: BuildContext): Promise<BuiltTaskResult>")," ",(0,a.mdx)("br",null),"\nThe execute method is where all the task logic is placed."),(0,a.mdx)("ul",{parentName:"li"},(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"context")," (argument) ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"context: BuildContext")," ",(0,a.mdx)("br",null),"\nThe context of the build pipeline. Use this object (provided by the build pipeline) to get information regarding all components handled by the build pipeline. ",(0,a.mdx)("br",null),(0,a.mdx)("br",null),"\nFor example, ",(0,a.mdx)("inlineCode",{parentName:"p"},"context.capsuleNetwork.seedersCapsules")," are models representing isolated instances of components handled by the build pipeline. These isolated instances are independent projects, generated in your local filesystem (by the build pipeline).")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"return")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"Promise<BuiltTaskResult>")," ",(0,a.mdx)("br",null),"\nA ",(0,a.mdx)("inlineCode",{parentName:"p"},"context")," method returns an object with data regarding the build task process, additional data regarding the components handled by the task and, if available, data regarding the different artifacts generated by this task.",(0,a.mdx)("br",null),"\nThe returned object has the following attributes:"),(0,a.mdx)("ul",{parentName:"li"},(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"componentsResults")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"componentsResults: ComponentResult[]"),"\nAn array of objects, each containing an instance of an object handled the task and additional information regarding the process and the component itself.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"component")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"component: Component")," ",(0,a.mdx)("br",null),"\nAn instance of the component handled by the task (see the above task example).")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"metadata")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"metadata?: { [key: string]: Serializable }")," ",(0,a.mdx)("br",null),"\nComponent metadata generated during the build task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"errors")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"errors?: Array<Error | string>")," ",(0,a.mdx)("br",null),"\nBuild task errors. A task returning errors will abort the build pipeline and log the returned errors.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"warnings")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"warnings?: string[]")," ",(0,a.mdx)("br",null),"\nwarnings generated throughout the build task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"startTime")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"startTime?: number")," ",(0,a.mdx)("br",null),"\nA timestamp (in milliseconds) of when the task started")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"endTime")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"endTime?: number")," ",(0,a.mdx)("br",null),"\nA timestamp (in milliseconds) of when the task ended")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"artifacts")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"artifacts?: ArtifactDefinition[]")," ",(0,a.mdx)("br",null),"\nAn array of artifact definitions to generate after a successful build")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"name")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"name: string")," ",(0,a.mdx)("br",null),"\nThe name of the artifact. ",(0,a.mdx)("br",null),"\nFor example, a project might utilize two different artifacts for the same typescript compiler, one that generates ES5 files and another for ES6. This prop helps to distinguish between the two.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"generatedBy")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"generatedBy?: string;")," ",(0,a.mdx)("br",null),"\nId of the component that generated this artifact.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"description")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"description?: string")," ",(0,a.mdx)("br",null),"\nA description of the artifact. ",(0,a.mdx)("br",null))),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"globPatterns")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"globPatterns: string[]")," ",(0,a.mdx)("br",null),"\nGlob patterns of files to include upon artifact creation. Minimatch is used to match the patterns. ",(0,a.mdx)("br",null),"\nFor example, ",(0,a.mdx)("inlineCode",{parentName:"p"},"['*.ts', '!foo.ts']")," matches all ts files but ignores ",(0,a.mdx)("inlineCode",{parentName:"p"},"foo.ts"),".")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"rootDir")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"rootDir?: string")," ",(0,a.mdx)("br",null),"\nDefines the root directory of the artifacts in the capsule file system. The rootDir must be unique for every artifact, otherwise data might be overridden.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"dirPrefix")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"dirPrefix?: string")," ",(0,a.mdx)("br",null),"\nAdds a directory prefix for all artifact files.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"context")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"context?: 'component' | 'env'")," ",(0,a.mdx)("br",null),"\nDetermine the context of the artifact. The default artifact context is ",(0,a.mdx)("inlineCode",{parentName:"p"},"component"),". ",(0,a.mdx)("inlineCode",{parentName:"p"},"env"),' is useful when the same file is generated for all components, for example, a "preview" task may create the same webpack file for all components of that env.')),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"storageResolver")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"storageResolver?: string")," ",(0,a.mdx)("br",null),"\nUsed to replace the location of the stored artifacts. The default resolver persists artifacts on scope (that's not recommended for large files).")))))),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"preBuild")," (advanced) ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"preBuild?(context: BuildContext): Promise<void>")," ",(0,a.mdx)("br",null),"\nRuns before the build pipeline has started. This method should only be used when preparations are needed to be done on all environments before the build starts.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"postBuild")," (advanced) ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>")," ",(0,a.mdx)("br",null),"\nRuns after the dependencies were completed for all environments."))))}u.__bit_component=i,u.isMDXComponent=!0},37606:(e,n,t)=>{Object.defineProperty(n,"M",{enumerable:!0,get:function(){return i.default}});var i=a(t(77456));function a(e){return e&&e.__esModule?e:{default:e}}a.__bit_component={id:"teambit.pipelines/aspect-docs/builder@0.0.167",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0}},80282:(e,n,t)=>{var i={id:"teambit.pipelines/builder@1.0.234",homepage:"https://bit.cloud/teambit/pipelines/builder",exported:!0};function a(){const e=r(t(41594));return a=function(){return e},e}function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Logo=void 0,a.__bit_component=i,r.__bit_component=i;const o=()=>a().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},a().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/builder.svg"}));o.__bit_component=i,n.Logo=o},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React}},n={};function t(i){var a=n[i];if(void 0!==a)return a.exports;var r=n[i]={exports:{}};return e[i](r,r.exports,t),r.exports}t.d=(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{t.r(i),t.d(i,{compositions:()=>u,compositions_metadata:()=>h,overview:()=>c});var e={};t.r(e),t.d(e,{default:()=>m});var n=t(80282),a=(t(41594),t(5016));const r=TeambitMdxUiMdxScopeContext;var o=t(37606),s=["components"];function l(){return l=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},l.apply(this,arguments)}var d={},p="wrapper";function m(e){var n=e.components,t=function(e,n){if(null==e)return{};var t,i,a=function(e,n){if(null==e)return{};var t,i,a={},r=Object.keys(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}(e,s);return(0,a.mdx)(p,l({},d,t,{components:n,mdxType:"MDXLayout"}),(0,a.mdx)(r.MDXScopeProvider,{components:{Builder:o.M},mdxType:"MDXScopeProvider"},(0,a.mdx)(o.M,{mdxType:"Builder"})))}m.isMDXComponent=!0;const u=[n],c=[e],h={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),i})()));
1
+ !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["teambit.pipelines/builder-preview"]=n():e["teambit.pipelines/builder-preview"]=n()}(self,(()=>(()=>{"use strict";var e={77456:(e,n,t)=>{var i={id:"teambit.pipelines/aspect-docs/builder@0.0.167",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=u,o(t(41594));var a=t(5016),r=["components"];function o(e){return e&&e.__esModule?e:{default:e}}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},s.apply(this,arguments)}function l(e,n){if(null==e)return{};var t,i,a=d(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function d(e,n){if(null==e)return{};var t,i,a={},r=Object.keys(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||(a[t]=e[t]);return a}o.__bit_component=i,s.__bit_component=i,l.__bit_component=i,d.__bit_component=i;var p={},m="wrapper";function u(e){var n=e.components,t=l(e,r);return(0,a.mdx)(m,s({},p,t,{components:n,mdxType:"MDXLayout"}),(0,a.mdx)("h2",null,"Background"),(0,a.mdx)("p",null,"Bit's build process is an extensible CI for independent components. It validates a component is not dependent on its context (the workspace), tests it, and generates all artifacts necessary for it to be viewed and consumed as an independent module (its distributable code, bundled preview, etc.)."),(0,a.mdx)("p",null,"The Build Pipeline is an Environment Service responsible for sequencing and executing a component's Build Tasks. As mentioned earlier, these tasks are performed on a component only after it's been isolated from the rest of the workspace."),(0,a.mdx)("p",null,"A component's default series of Build Tasks is composed of tasks set by Bit and by its environment."),(0,a.mdx)("h2",null,"Isolated builds"),(0,a.mdx)("p",null,"Components authored in a Bit workspace are created to be completely portable, and thus independent. To address that, the build process starts by creating a component 'capsule' which is an isolated instance of a component, generated in a separate directory in your filesystem."),(0,a.mdx)("p",null,'As part of the capsule creation, all packages listed as dependencies of that component will be installed. This step is necessary to validate there are no dependency-graph issues (a component that is not totally isolated will be able to use packages installed in parent directories in your workspace, by other components. This will translate into a "false positive" result when testing for dependency-graph issues in a non-isolated location).'),(0,a.mdx)("h2",null,"Incremental builds"),(0,a.mdx)("p",null,'When a component "goes through" the build pipeline, all of its dependencies are built as well. If a dependency has not changed since its last build, the build process will use its artifacts from the previous build (and will not process it again). This optimization to the build process supplements the "innate optimization" that naturally comes from developing (and building) independent components instead of a single monolithic codebase.'),(0,a.mdx)("h2",null,"Environment-specific builds"),(0,a.mdx)("p",null,"Each Bit environment determines its own build pipeline. That means, a single workspace that uses multiple environments will run a different set of build tasks on different components depending on their associated environment. This is another Bit feature that enables seamless transitioning between different development environments, all in the same workspace. It also makes it much easier to integrate the Build Pipeline in your (remote) CI, as it only requires executing the build step - all other per-component build configurations are already set by the various environments being used."),(0,a.mdx)("p",null,"Since environments are extensible, so are the build pipelines configured by them."),(0,a.mdx)("h2",null,"Build task"),(0,a.mdx)("p",null,"An example of a build-task is ",(0,a.mdx)("inlineCode",{parentName:"p"},"compile"),", it's written in the compiler aspect and is running on each one of the capsules created by the build process. build-tasks in many cases generate artifacts, in this case, the compiler generates ",(0,a.mdx)("inlineCode",{parentName:"p"},"dists")," files and write them on the isolated capsules. There artifacts files are used later for example when creating packages."),(0,a.mdx)("h2",null,"Pipelines"),(0,a.mdx)("p",null,"There are three pipelines: ",(0,a.mdx)("inlineCode",{parentName:"p"},"build"),", ",(0,a.mdx)("inlineCode",{parentName:"p"},"tag")," and ",(0,a.mdx)("inlineCode",{parentName:"p"},"snap"),"."),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit build")," runs the build pipeline."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit tag")," runs the build pipeline and then the tag pipeline."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit snap")," runs the build pipeline and then the snap pipeline.")),(0,a.mdx)("h2",null,"List Build Tasks"),(0,a.mdx)("p",null,"To get a list of all the tasks that will be running per pipeline on a specific component, run ",(0,a.mdx)("inlineCode",{parentName:"p"},"bit build --list-tasks <id>"),".\nHere is an example of the relevant part from the output:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre"},"➜ bit build --list-tasks ui/tooltip\nTasks List\nid: teambit.design/ui/tooltip@0.0.347\nenvId: teambit.react/react\n\nBuild Pipeline Tasks:\nteambit.harmony/aspect:CoreExporter\nteambit.compilation/compiler:TSCompiler\nteambit.defender/tester:TestComponents\nteambit.pkg/pkg:PreparePackages\nteambit.pkg/pkg:PublishDryRun\nteambit.preview/preview:GeneratePreview\n\nTag Pipeline Tasks:\nteambit.harmony/application:build_ui_application\nteambit.pkg/pkg:PublishComponents\n\nSnap Pipeline Tasks:\n<N/A>\n")),(0,a.mdx)("h2",null,"Implementing Build Tasks"),(0,a.mdx)("p",null,"The ",(0,a.mdx)("inlineCode",{parentName:"p"},"BuildTask")," interface is a good start to understand how to implement a new build-task.\nWhen writing a build task, the ",(0,a.mdx)("inlineCode",{parentName:"p"},"Network")," object is passed and it includes the seeders capsules, as well as the entire graph including the dependencies.\nKeep in mind that the entire graph may contain components from other envs."),(0,a.mdx)("p",null,"Some tasks, such as, compiling in typescript and bundling with Webpack, need the entire graph.\nOthers, such as, Babel, need only the seeders. However, normally, the bundling is running after the compilation and it expects to have the dependencies compiled, so you might need the entire graph regardless."),(0,a.mdx)("h2",null,"Adding Tasks to a pipeline"),(0,a.mdx)("p",null,"There are two ways of adding tasks to the build pipeline."),(0,a.mdx)("ol",null,(0,a.mdx)("li",{parentName:"ol"},(0,a.mdx)("inlineCode",{parentName:"li"},"getBuildPipe()")," method of the env. (or ",(0,a.mdx)("inlineCode",{parentName:"li"},"getTagPipe()")," and ",(0,a.mdx)("inlineCode",{parentName:"li"},"getSnapPipe()"),")"),(0,a.mdx)("li",{parentName:"ol"},"registering to the slot via ",(0,a.mdx)("inlineCode",{parentName:"li"},"builder.registerBuildTask()"),". (or ",(0,a.mdx)("inlineCode",{parentName:"li"},"registerTagTask()")," and ",(0,a.mdx)("inlineCode",{parentName:"li"},"registerSnapTask()"),")")),(0,a.mdx)("p",null,"in the option #1, it's possible to determine the order. e.g. ",(0,a.mdx)("inlineCode",{parentName:"p"},"getBuildPipe() { return [taskA, taskB, taskC]; }"),"\nin the option #2, the register happens once the extension is loaded, so there is no way to put\none task before/after another task as of now."),(0,a.mdx)("h2",null,"Sequencing the build tasks"),(0,a.mdx)("p",null,"The Build Pipeline takes into consideration the following factors when deciding the order of which to execute each task:"),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("strong",{parentName:"li"},"Location"),": A task can be executed either at the start or end of the build pipeline. This can be explicitly configured by the task itself."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("strong",{parentName:"li"},"Dependencies"),": A task can depend on other tasks. That means, the dependencies must be completed successfully for all envs before this task starts. The dependencies are applicable inside a location and not across locations. This is configured by the task itself."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("strong",{parentName:"li"},"An environment's list of build tasks"),": This is the array of tasks as it is defined by an environment")),(0,a.mdx)("h2",null,"Executing the pipelines"),(0,a.mdx)("p",null,"Commands that trigger the build pipeline:"),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit build")," - runs the build pipeline on your local machine, for the entire workspace. The output data will not persist. - That is most often used for testing and debugging the build process."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit tag")," - runs the tag pipeline in addition to the build pipeline, before creating a new component release version. The output data will persist."),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("inlineCode",{parentName:"li"},"bit snap")," - runs the snap pipeline in addition to the build pipeline. The output data will persist.")),(0,a.mdx)("p",null,"Build pipelines are determined by the environments in use. That means, in order to override the default pipeline, we need to create a new environment extension or modify an existing one."),(0,a.mdx)("p",null,"The example task below, shown being used by a customized environment, prints out the component name of every component handled by it. In addition to that, the task returns the component name as custom metadata to be logged and/or stored in the component tagged version. ",(0,a.mdx)("a",{parentName:"p",href:"https://github.com/teambit/harmony-build-examples"},"See a demo project here"),"."),(0,a.mdx)("blockquote",null,(0,a.mdx)("p",{parentName:"blockquote"},"Information returned by a build task will only persist if the build-pipeline was triggered by the 'hard-tag' command (",(0,a.mdx)("inlineCode",{parentName:"p"},"bit tag <component-id>"),").")),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="print-cmp-name-task.ts"',title:'"print-cmp-name-task.ts"'},"import { BuildTask, BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\n\n// A task is an implementation of 'BuildTask' provided by the 'builder' aspect\nexport class PrintCmpNameTask implements BuildTask {\n // The constructor leaves these properties up to the hands of the environment using this task\n constructor(readonly aspectId: string, readonly name: string) {}\n\n // This is where the task logic is placed. It will be executed by the build pipeline\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults: ComponentResult[] = [];\n\n // Go through every isolated component instance\n context.capsuleNetwork.seedersCapsules.forEach((capsule) => {\n console.log(`The current component name is: ${capsule.component.id.name}`);\n\n componentsResults.push({\n component: capsule.component,\n metadata: { customProp: capsule.component.id.name },\n });\n });\n return {\n // An array of component objects, enriched with additional data produced by the task\n componentsResults,\n };\n }\n}\n")),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="customized-react.extension.ts"',title:'"customized-react.extension.ts"'},"import { EnvsMain, EnvsAspect } from '@teambit/envs';\nimport { ReactAspect, ReactMain } from '@teambit/react';\n\n// Import the task\nimport { PrintCmpNameTask } from './print-cmp-name-task';\n\nexport class CustomReact {\n constructor(private react: ReactMain) {}\n\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n static async provider([envs, react]: [EnvsMain, ReactMain]) {\n // Get the environment's default build pipeline\n const reactPipe = react.env.getBuildPipe();\n\n // Add the custom task to the end of the build tasks sequence.\n // Provide the task with the component ID of the extension using it.\n // Provide the ask with a name.\n const tasks = [...reactPipe, new PrintCompTask('extensions/custom-react', 'PrintCmpNameTask')];\n\n // Create a new environment by merging these configurations with the env's default ones\n const customReactEnv = react.compose([react.overrideBuildPipe(tasks)]);\n\n // register the extension as an environment\n envs.registerEnv(customReactEnv);\n return new CustomReact(react);\n }\n}\n")),(0,a.mdx)("h2",null,"Positioning a build task in the pipeline"),(0,a.mdx)("p",null,"A build task is positioned in the build pipeline sequence either by overriding the entire ",(0,a.mdx)("em",{parentName:"p"},"customizable")," pipeline or, by registering it to a location in the pipeline using the designated builder slot."),(0,a.mdx)("h3",null,"Override the build pipeline sequence"),(0,a.mdx)("p",null,"This methodology leaves the task completely agnostic as to its position in the build pipeline. Instead, the task position is determined by the environment using the ",(0,a.mdx)("inlineCode",{parentName:"p"},"getBuildPipe")," Environment Handler."),(0,a.mdx)("p",null,"The example above shows the React environment ",(0,a.mdx)("inlineCode",{parentName:"p"},"overrideBuildPipe")," method being used to override its default pipeline. This method uses the ",(0,a.mdx)("inlineCode",{parentName:"p"},"getBuildPipe()")," Environment Handler, internally."),(0,a.mdx)("h3",null,"Append to the start or end of the pipeline, in relation to other tasks"),(0,a.mdx)("p",null,"This methodology places the task at the start or end of the build pipeline sequence, and lists all other tasks needed to run successfully before it is executed."),(0,a.mdx)("p",null,"Example:"),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="print-cmp-name-task.ts"',title:'"print-cmp-name-task.ts"'},"import { BuildTask, BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\n\nexport class PrintCmpNameTask implements BuildTask {\n constructor(readonly aspectId: string, readonly name: string) {}\n\n // Place the task at the end of the build pipeline\n readonly location = 'end';\n\n // Run this task only after the '@teambit/preview' task is completed successfully\n readonly dependencies = ['@teambit/preview'];\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults: ComponentResult[] = [];\n context.capsuleNetwork.seedersCapsules.forEach((capsule) => {\n console.log(`The current component name is: ${capsule.component.id.name}`);\n\n componentsResults.push({\n component: capsule.component,\n metadata: { customProp: capsule.component.id.name },\n });\n });\n return {\n componentsResults,\n };\n }\n}\n")),(0,a.mdx)("pre",null,(0,a.mdx)("code",{parentName:"pre",className:"language-ts",metastring:'title="customized-react.extension.ts"',title:'"customized-react.extension.ts"'},"import { EnvsMain, EnvsAspect } from '@teambit/envs';\nimport { ReactAspect, ReactMain } from '@teambit/react';\nimport { BuilderMain } from '@teambit/builder';\n\n// Import the task (in reality, it should be an independent component)\nimport { PrintCmpNameTask } from './print-cmp-name-task';\n\nexport class CustomReact {\n constructor(private react: ReactMain) {}\n\n static dependencies: any = [EnvsAspect, ReactAspect];\n\n // Inject the builder\n static async provider([envs, react, builder]: [EnvsMain, ReactMain, BuilderMain]) {\n // Register this task using the registration slot, made available by the 'builder'.\n // Here, the environment has no say in the positioning of the task\n builder.registerBuildTasks([new ExampleTask('extensions/custom-react', 'PrintCmpNameTask')]);\n\n const customReactEnv = react.compose([]);\n\n envs.registerEnv(customReactEnv);\n return new CustomReact(react);\n }\n}\n")),(0,a.mdx)("h2",null,"A build task anatomy"),(0,a.mdx)("ul",null,(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"aspectId")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"aspectId: string"),(0,a.mdx)("br",null),"\nThe component ID of the environment using this task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"name")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"name: string")," ",(0,a.mdx)("br",null),"\nA name for this task. Only alphanumerical characters are allowed. PascalCase should be used as a convention.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"location")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"location?: 'start' | 'end'")," ",(0,a.mdx)("br",null),"\nThe section of the build-pipeline to which to append this task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"dependencies")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"dependencies?: string[]")," ",(0,a.mdx)("br",null),"\nAn list of tasks that must be completed before this task gets executed. ",(0,a.mdx)("br",null),"\nFor example ",(0,a.mdx)("inlineCode",{parentName:"p"},"dependencies = ['@teambit/preview']"),".")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"execute")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"execute(context: BuildContext): Promise<BuiltTaskResult>")," ",(0,a.mdx)("br",null),"\nThe execute method is where all the task logic is placed."),(0,a.mdx)("ul",{parentName:"li"},(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"context")," (argument) ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"context: BuildContext")," ",(0,a.mdx)("br",null),"\nThe context of the build pipeline. Use this object (provided by the build pipeline) to get information regarding all components handled by the build pipeline. ",(0,a.mdx)("br",null),(0,a.mdx)("br",null),"\nFor example, ",(0,a.mdx)("inlineCode",{parentName:"p"},"context.capsuleNetwork.seedersCapsules")," are models representing isolated instances of components handled by the build pipeline. These isolated instances are independent projects, generated in your local filesystem (by the build pipeline).")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"return")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"Promise<BuiltTaskResult>")," ",(0,a.mdx)("br",null),"\nA ",(0,a.mdx)("inlineCode",{parentName:"p"},"context")," method returns an object with data regarding the build task process, additional data regarding the components handled by the task and, if available, data regarding the different artifacts generated by this task.",(0,a.mdx)("br",null),"\nThe returned object has the following attributes:"),(0,a.mdx)("ul",{parentName:"li"},(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"componentsResults")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"componentsResults: ComponentResult[]"),"\nAn array of objects, each containing an instance of an object handled the task and additional information regarding the process and the component itself.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"component")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"component: Component")," ",(0,a.mdx)("br",null),"\nAn instance of the component handled by the task (see the above task example).")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"metadata")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"metadata?: { [key: string]: Serializable }")," ",(0,a.mdx)("br",null),"\nComponent metadata generated during the build task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"errors")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"errors?: Array<Error | string>")," ",(0,a.mdx)("br",null),"\nBuild task errors. A task returning errors will abort the build pipeline and log the returned errors.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"warnings")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"warnings?: string[]")," ",(0,a.mdx)("br",null),"\nwarnings generated throughout the build task.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"startTime")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"startTime?: number")," ",(0,a.mdx)("br",null),"\nA timestamp (in milliseconds) of when the task started")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"endTime")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"endTime?: number")," ",(0,a.mdx)("br",null),"\nA timestamp (in milliseconds) of when the task ended")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"artifacts")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"artifacts?: ArtifactDefinition[]")," ",(0,a.mdx)("br",null),"\nAn array of artifact definitions to generate after a successful build")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"name")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"name: string")," ",(0,a.mdx)("br",null),"\nThe name of the artifact. ",(0,a.mdx)("br",null),"\nFor example, a project might utilize two different artifacts for the same typescript compiler, one that generates ES5 files and another for ES6. This prop helps to distinguish between the two.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"generatedBy")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"generatedBy?: string;")," ",(0,a.mdx)("br",null),"\nId of the component that generated this artifact.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"description")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"description?: string")," ",(0,a.mdx)("br",null),"\nA description of the artifact. ",(0,a.mdx)("br",null))),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"globPatterns")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"globPatterns: string[]")," ",(0,a.mdx)("br",null),"\nGlob patterns of files to include upon artifact creation. Minimatch is used to match the patterns. ",(0,a.mdx)("br",null),"\nFor example, ",(0,a.mdx)("inlineCode",{parentName:"p"},"['*.ts', '!foo.ts']")," matches all ts files but ignores ",(0,a.mdx)("inlineCode",{parentName:"p"},"foo.ts"),".")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"rootDir")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"rootDir?: string")," ",(0,a.mdx)("br",null),"\nDefines the root directory of the artifacts in the capsule file system. The rootDir must be unique for every artifact, otherwise data might be overridden.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"dirPrefix")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"dirPrefix?: string")," ",(0,a.mdx)("br",null),"\nAdds a directory prefix for all artifact files.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"context")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"context?: 'component' | 'env'")," ",(0,a.mdx)("br",null),"\nDetermine the context of the artifact. The default artifact context is ",(0,a.mdx)("inlineCode",{parentName:"p"},"component"),". ",(0,a.mdx)("inlineCode",{parentName:"p"},"env"),' is useful when the same file is generated for all components, for example, a "preview" task may create the same webpack file for all components of that env.')),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"storageResolver")," ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"storageResolver?: string")," ",(0,a.mdx)("br",null),"\nUsed to replace the location of the stored artifacts. The default resolver persists artifacts on scope (that's not recommended for large files).")))))),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"preBuild")," (advanced) ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"preBuild?(context: BuildContext): Promise<void>")," ",(0,a.mdx)("br",null),"\nRuns before the build pipeline has started. This method should only be used when preparations are needed to be done on all environments before the build starts.")),(0,a.mdx)("li",{parentName:"ul"},(0,a.mdx)("p",{parentName:"li"},(0,a.mdx)("strong",{parentName:"p"},"postBuild")," (advanced) ",(0,a.mdx)("br",null),"\n",(0,a.mdx)("inlineCode",{parentName:"p"},"postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>")," ",(0,a.mdx)("br",null),"\nRuns after the dependencies were completed for all environments."))))}u.__bit_component=i,u.isMDXComponent=!0},37606:(e,n,t)=>{Object.defineProperty(n,"M",{enumerable:!0,get:function(){return i.default}});var i=a(t(77456));function a(e){return e&&e.__esModule?e:{default:e}}a.__bit_component={id:"teambit.pipelines/aspect-docs/builder@0.0.167",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0}},79437:(e,n,t)=>{var i={id:"teambit.pipelines/builder@1.0.237",homepage:"https://bit.cloud/teambit/pipelines/builder",exported:!0};function a(){const e=r(t(41594));return a=function(){return e},e}function r(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0}),n.Logo=void 0,a.__bit_component=i,r.__bit_component=i;const o=()=>a().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},a().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/builder.svg"}));o.__bit_component=i,n.Logo=o},5016:e=>{e.exports=MdxJsReact},41594:e=>{e.exports=React}},n={};function t(i){var a=n[i];if(void 0!==a)return a.exports;var r=n[i]={exports:{}};return e[i](r,r.exports,t),r.exports}t.d=(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},t.o=(e,n)=>Object.prototype.hasOwnProperty.call(e,n),t.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{t.r(i),t.d(i,{compositions:()=>u,compositions_metadata:()=>h,overview:()=>c});var e={};t.r(e),t.d(e,{default:()=>m});var n=t(79437),a=(t(41594),t(5016));const r=TeambitMdxUiMdxScopeContext;var o=t(37606),s=["components"];function l(){return l=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},l.apply(this,arguments)}var d={},p="wrapper";function m(e){var n=e.components,t=function(e,n){if(null==e)return{};var t,i,a=function(e,n){if(null==e)return{};var t,i,a={},r=Object.keys(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)t=r[i],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}(e,s);return(0,a.mdx)(p,l({},d,t,{components:n,mdxType:"MDXLayout"}),(0,a.mdx)(r.MDXScopeProvider,{components:{Builder:o.M},mdxType:"MDXScopeProvider"},(0,a.mdx)(o.M,{mdxType:"Builder"})))}m.isMDXComponent=!0;const u=[n],c=[e],h={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),i})()));
@@ -1064,7 +1064,7 @@
1064
1064
  "_legacy": {
1065
1065
  "scope": "teambit.pipelines",
1066
1066
  "name": "builder",
1067
- "version": "1.0.234"
1067
+ "version": "1.0.237"
1068
1068
  },
1069
1069
  "_scope": "teambit.pipelines"
1070
1070
  }
@@ -7396,7 +7396,7 @@
7396
7396
  "_legacy": {
7397
7397
  "scope": "teambit.pipelines",
7398
7398
  "name": "builder",
7399
- "version": "1.0.234"
7399
+ "version": "1.0.237"
7400
7400
  },
7401
7401
  "_scope": "teambit.pipelines"
7402
7402
  }
@@ -8138,7 +8138,7 @@
8138
8138
  "__schema": "ClassSchema",
8139
8139
  "location": {
8140
8140
  "filePath": "task-results-list.ts",
8141
- "line": 8,
8141
+ "line": 9,
8142
8142
  "character": 1
8143
8143
  },
8144
8144
  "signature": "class TaskResultsList",
@@ -8148,17 +8148,17 @@
8148
8148
  "__schema": "ConstructorSchema",
8149
8149
  "location": {
8150
8150
  "filePath": "task-results-list.ts",
8151
- "line": 9,
8151
+ "line": 10,
8152
8152
  "character": 3
8153
8153
  },
8154
- "signature": "constructor TaskResultsList(tasksQueue: TasksQueue, tasksResults: TaskResults[], capsuleRootDir: string): TaskResultsList",
8154
+ "signature": "constructor TaskResultsList(tasksQueue: TasksQueue, tasksResults: TaskResults[], capsuleRootDir: string, logger: Logger): TaskResultsList",
8155
8155
  "name": "constructor",
8156
8156
  "params": [
8157
8157
  {
8158
8158
  "__schema": "ParameterSchema",
8159
8159
  "location": {
8160
8160
  "filePath": "task-results-list.ts",
8161
- "line": 10,
8161
+ "line": 11,
8162
8162
  "character": 5
8163
8163
  },
8164
8164
  "name": "tasksQueue",
@@ -8166,7 +8166,7 @@
8166
8166
  "__schema": "TypeRefSchema",
8167
8167
  "location": {
8168
8168
  "filePath": "task-results-list.ts",
8169
- "line": 10,
8169
+ "line": 11,
8170
8170
  "character": 24
8171
8171
  },
8172
8172
  "name": "TasksQueue",
@@ -8179,7 +8179,7 @@
8179
8179
  "__schema": "ParameterSchema",
8180
8180
  "location": {
8181
8181
  "filePath": "task-results-list.ts",
8182
- "line": 14,
8182
+ "line": 15,
8183
8183
  "character": 5
8184
8184
  },
8185
8185
  "name": "tasksResults",
@@ -8187,14 +8187,14 @@
8187
8187
  "__schema": "TypeArraySchema",
8188
8188
  "location": {
8189
8189
  "filePath": "task-results-list.ts",
8190
- "line": 14,
8190
+ "line": 15,
8191
8191
  "character": 26
8192
8192
  },
8193
8193
  "type": {
8194
8194
  "__schema": "TypeRefSchema",
8195
8195
  "location": {
8196
8196
  "filePath": "task-results-list.ts",
8197
- "line": 14,
8197
+ "line": 15,
8198
8198
  "character": 26
8199
8199
  },
8200
8200
  "name": "TaskResults"
@@ -8207,7 +8207,7 @@
8207
8207
  "__schema": "ParameterSchema",
8208
8208
  "location": {
8209
8209
  "filePath": "task-results-list.ts",
8210
- "line": 16,
8210
+ "line": 17,
8211
8211
  "character": 5
8212
8212
  },
8213
8213
  "name": "capsuleRootDir",
@@ -8215,20 +8215,44 @@
8215
8215
  "__schema": "KeywordTypeSchema",
8216
8216
  "location": {
8217
8217
  "filePath": "task-results-list.ts",
8218
- "line": 16,
8218
+ "line": 17,
8219
8219
  "character": 28
8220
8220
  },
8221
8221
  "name": "string"
8222
8222
  },
8223
8223
  "isOptional": false,
8224
8224
  "isSpread": false
8225
+ },
8226
+ {
8227
+ "__schema": "ParameterSchema",
8228
+ "location": {
8229
+ "filePath": "task-results-list.ts",
8230
+ "line": 19,
8231
+ "character": 5
8232
+ },
8233
+ "name": "logger",
8234
+ "type": {
8235
+ "__schema": "TypeRefSchema",
8236
+ "location": {
8237
+ "filePath": "task-results-list.ts",
8238
+ "line": 19,
8239
+ "character": 21
8240
+ },
8241
+ "name": "Logger",
8242
+ "componentId": {
8243
+ "scope": "teambit.harmony",
8244
+ "name": "logger"
8245
+ }
8246
+ },
8247
+ "isOptional": false,
8248
+ "isSpread": false
8225
8249
  }
8226
8250
  ],
8227
8251
  "returnType": {
8228
8252
  "__schema": "ThisTypeSchema",
8229
8253
  "location": {
8230
8254
  "filePath": "task-results-list.ts",
8231
- "line": 8,
8255
+ "line": 9,
8232
8256
  "character": 1
8233
8257
  },
8234
8258
  "name": "TaskResultsList"
@@ -8239,7 +8263,7 @@
8239
8263
  "__schema": "FunctionLikeSchema",
8240
8264
  "location": {
8241
8265
  "filePath": "task-results-list.ts",
8242
- "line": 19,
8266
+ "line": 22,
8243
8267
  "character": 3
8244
8268
  },
8245
8269
  "signature": "(method) TaskResultsList.hasErrors(): boolean",
@@ -8249,7 +8273,7 @@
8249
8273
  "__schema": "KeywordTypeSchema",
8250
8274
  "location": {
8251
8275
  "filePath": "task-results-list.ts",
8252
- "line": 19,
8276
+ "line": 22,
8253
8277
  "character": 16
8254
8278
  },
8255
8279
  "name": "boolean"
@@ -8260,7 +8284,7 @@
8260
8284
  "__schema": "FunctionLikeSchema",
8261
8285
  "location": {
8262
8286
  "filePath": "task-results-list.ts",
8263
- "line": 23,
8287
+ "line": 26,
8264
8288
  "character": 3
8265
8289
  },
8266
8290
  "signature": "(method) TaskResultsList.throwErrorsIfExist(): void",
@@ -8270,7 +8294,7 @@
8270
8294
  "__schema": "InferenceTypeSchema",
8271
8295
  "location": {
8272
8296
  "filePath": "task-results-list.ts",
8273
- "line": 23,
8297
+ "line": 26,
8274
8298
  "character": 3
8275
8299
  },
8276
8300
  "type": "void"
@@ -8281,14 +8305,14 @@
8281
8305
  "__schema": "FunctionLikeSchema",
8282
8306
  "location": {
8283
8307
  "filePath": "task-results-list.ts",
8284
- "line": 33,
8308
+ "line": 37,
8285
8309
  "character": 3
8286
8310
  },
8287
8311
  "doc": {
8288
8312
  "__schema": "DocSchema",
8289
8313
  "location": {
8290
8314
  "filePath": "task-results-list.ts",
8291
- "line": 30,
8315
+ "line": 34,
8292
8316
  "character": 3
8293
8317
  },
8294
8318
  "raw": "/**\n * group errors from all tasks and show them nicely to the user\n */",
@@ -8301,16 +8325,16 @@
8301
8325
  "__schema": "TypeUnionSchema",
8302
8326
  "location": {
8303
8327
  "filePath": "task-results-list.ts",
8304
- "line": 33,
8305
- "character": 38
8328
+ "line": 37,
8329
+ "character": 31
8306
8330
  },
8307
8331
  "types": [
8308
8332
  {
8309
8333
  "__schema": "KeywordTypeSchema",
8310
8334
  "location": {
8311
8335
  "filePath": "task-results-list.ts",
8312
- "line": 33,
8313
- "character": 38
8336
+ "line": 37,
8337
+ "character": 31
8314
8338
  },
8315
8339
  "name": "string"
8316
8340
  },
@@ -8318,16 +8342,14 @@
8318
8342
  "__schema": "LiteralTypeSchema",
8319
8343
  "location": {
8320
8344
  "filePath": "task-results-list.ts",
8321
- "line": 33,
8322
- "character": 47
8345
+ "line": 37,
8346
+ "character": 40
8323
8347
  },
8324
8348
  "name": "null"
8325
8349
  }
8326
8350
  ]
8327
8351
  },
8328
- "modifiers": [
8329
- "public"
8330
- ]
8352
+ "modifiers": []
8331
8353
  }
8332
8354
  ],
8333
8355
  "extendsNodes": [],
@@ -9621,7 +9643,7 @@
9621
9643
  "_legacy": {
9622
9644
  "scope": "teambit.pipelines",
9623
9645
  "name": "builder",
9624
- "version": "1.0.234"
9646
+ "version": "1.0.237"
9625
9647
  },
9626
9648
  "_scope": "teambit.pipelines"
9627
9649
  }
@@ -16356,7 +16378,7 @@
16356
16378
  "_legacy": {
16357
16379
  "scope": "teambit.pipelines",
16358
16380
  "name": "builder",
16359
- "version": "1.0.234"
16381
+ "version": "1.0.237"
16360
16382
  },
16361
16383
  "_scope": "teambit.pipelines"
16362
16384
  }
@@ -16380,7 +16402,7 @@
16380
16402
  "__schema": "ClassSchema",
16381
16403
  "location": {
16382
16404
  "filePath": "task-results-list.ts",
16383
- "line": 8,
16405
+ "line": 9,
16384
16406
  "character": 1
16385
16407
  },
16386
16408
  "signature": "class TaskResultsList",
@@ -16390,17 +16412,17 @@
16390
16412
  "__schema": "ConstructorSchema",
16391
16413
  "location": {
16392
16414
  "filePath": "task-results-list.ts",
16393
- "line": 9,
16415
+ "line": 10,
16394
16416
  "character": 3
16395
16417
  },
16396
- "signature": "constructor TaskResultsList(tasksQueue: TasksQueue, tasksResults: TaskResults[], capsuleRootDir: string): TaskResultsList",
16418
+ "signature": "constructor TaskResultsList(tasksQueue: TasksQueue, tasksResults: TaskResults[], capsuleRootDir: string, logger: Logger): TaskResultsList",
16397
16419
  "name": "constructor",
16398
16420
  "params": [
16399
16421
  {
16400
16422
  "__schema": "ParameterSchema",
16401
16423
  "location": {
16402
16424
  "filePath": "task-results-list.ts",
16403
- "line": 10,
16425
+ "line": 11,
16404
16426
  "character": 5
16405
16427
  },
16406
16428
  "name": "tasksQueue",
@@ -16408,7 +16430,7 @@
16408
16430
  "__schema": "TypeRefSchema",
16409
16431
  "location": {
16410
16432
  "filePath": "task-results-list.ts",
16411
- "line": 10,
16433
+ "line": 11,
16412
16434
  "character": 24
16413
16435
  },
16414
16436
  "name": "TasksQueue",
@@ -16421,7 +16443,7 @@
16421
16443
  "__schema": "ParameterSchema",
16422
16444
  "location": {
16423
16445
  "filePath": "task-results-list.ts",
16424
- "line": 14,
16446
+ "line": 15,
16425
16447
  "character": 5
16426
16448
  },
16427
16449
  "name": "tasksResults",
@@ -16429,14 +16451,14 @@
16429
16451
  "__schema": "TypeArraySchema",
16430
16452
  "location": {
16431
16453
  "filePath": "task-results-list.ts",
16432
- "line": 14,
16454
+ "line": 15,
16433
16455
  "character": 26
16434
16456
  },
16435
16457
  "type": {
16436
16458
  "__schema": "TypeRefSchema",
16437
16459
  "location": {
16438
16460
  "filePath": "task-results-list.ts",
16439
- "line": 14,
16461
+ "line": 15,
16440
16462
  "character": 26
16441
16463
  },
16442
16464
  "name": "TaskResults"
@@ -16449,7 +16471,7 @@
16449
16471
  "__schema": "ParameterSchema",
16450
16472
  "location": {
16451
16473
  "filePath": "task-results-list.ts",
16452
- "line": 16,
16474
+ "line": 17,
16453
16475
  "character": 5
16454
16476
  },
16455
16477
  "name": "capsuleRootDir",
@@ -16457,20 +16479,44 @@
16457
16479
  "__schema": "KeywordTypeSchema",
16458
16480
  "location": {
16459
16481
  "filePath": "task-results-list.ts",
16460
- "line": 16,
16482
+ "line": 17,
16461
16483
  "character": 28
16462
16484
  },
16463
16485
  "name": "string"
16464
16486
  },
16465
16487
  "isOptional": false,
16466
16488
  "isSpread": false
16489
+ },
16490
+ {
16491
+ "__schema": "ParameterSchema",
16492
+ "location": {
16493
+ "filePath": "task-results-list.ts",
16494
+ "line": 19,
16495
+ "character": 5
16496
+ },
16497
+ "name": "logger",
16498
+ "type": {
16499
+ "__schema": "TypeRefSchema",
16500
+ "location": {
16501
+ "filePath": "task-results-list.ts",
16502
+ "line": 19,
16503
+ "character": 21
16504
+ },
16505
+ "name": "Logger",
16506
+ "componentId": {
16507
+ "scope": "teambit.harmony",
16508
+ "name": "logger"
16509
+ }
16510
+ },
16511
+ "isOptional": false,
16512
+ "isSpread": false
16467
16513
  }
16468
16514
  ],
16469
16515
  "returnType": {
16470
16516
  "__schema": "ThisTypeSchema",
16471
16517
  "location": {
16472
16518
  "filePath": "task-results-list.ts",
16473
- "line": 8,
16519
+ "line": 9,
16474
16520
  "character": 1
16475
16521
  },
16476
16522
  "name": "TaskResultsList"
@@ -16481,7 +16527,7 @@
16481
16527
  "__schema": "FunctionLikeSchema",
16482
16528
  "location": {
16483
16529
  "filePath": "task-results-list.ts",
16484
- "line": 19,
16530
+ "line": 22,
16485
16531
  "character": 3
16486
16532
  },
16487
16533
  "signature": "(method) TaskResultsList.hasErrors(): boolean",
@@ -16491,7 +16537,7 @@
16491
16537
  "__schema": "KeywordTypeSchema",
16492
16538
  "location": {
16493
16539
  "filePath": "task-results-list.ts",
16494
- "line": 19,
16540
+ "line": 22,
16495
16541
  "character": 16
16496
16542
  },
16497
16543
  "name": "boolean"
@@ -16502,7 +16548,7 @@
16502
16548
  "__schema": "FunctionLikeSchema",
16503
16549
  "location": {
16504
16550
  "filePath": "task-results-list.ts",
16505
- "line": 23,
16551
+ "line": 26,
16506
16552
  "character": 3
16507
16553
  },
16508
16554
  "signature": "(method) TaskResultsList.throwErrorsIfExist(): void",
@@ -16512,7 +16558,7 @@
16512
16558
  "__schema": "InferenceTypeSchema",
16513
16559
  "location": {
16514
16560
  "filePath": "task-results-list.ts",
16515
- "line": 23,
16561
+ "line": 26,
16516
16562
  "character": 3
16517
16563
  },
16518
16564
  "type": "void"
@@ -16523,14 +16569,14 @@
16523
16569
  "__schema": "FunctionLikeSchema",
16524
16570
  "location": {
16525
16571
  "filePath": "task-results-list.ts",
16526
- "line": 33,
16572
+ "line": 37,
16527
16573
  "character": 3
16528
16574
  },
16529
16575
  "doc": {
16530
16576
  "__schema": "DocSchema",
16531
16577
  "location": {
16532
16578
  "filePath": "task-results-list.ts",
16533
- "line": 30,
16579
+ "line": 34,
16534
16580
  "character": 3
16535
16581
  },
16536
16582
  "raw": "/**\n * group errors from all tasks and show them nicely to the user\n */",
@@ -16543,16 +16589,16 @@
16543
16589
  "__schema": "TypeUnionSchema",
16544
16590
  "location": {
16545
16591
  "filePath": "task-results-list.ts",
16546
- "line": 33,
16547
- "character": 38
16592
+ "line": 37,
16593
+ "character": 31
16548
16594
  },
16549
16595
  "types": [
16550
16596
  {
16551
16597
  "__schema": "KeywordTypeSchema",
16552
16598
  "location": {
16553
16599
  "filePath": "task-results-list.ts",
16554
- "line": 33,
16555
- "character": 38
16600
+ "line": 37,
16601
+ "character": 31
16556
16602
  },
16557
16603
  "name": "string"
16558
16604
  },
@@ -16560,16 +16606,14 @@
16560
16606
  "__schema": "LiteralTypeSchema",
16561
16607
  "location": {
16562
16608
  "filePath": "task-results-list.ts",
16563
- "line": 33,
16564
- "character": 47
16609
+ "line": 37,
16610
+ "character": 40
16565
16611
  },
16566
16612
  "name": "null"
16567
16613
  }
16568
16614
  ]
16569
16615
  },
16570
- "modifiers": [
16571
- "public"
16572
- ]
16616
+ "modifiers": []
16573
16617
  }
16574
16618
  ],
16575
16619
  "extendsNodes": [],
@@ -16619,7 +16663,7 @@
16619
16663
  "componentId": {
16620
16664
  "scope": "teambit.pipelines",
16621
16665
  "name": "builder",
16622
- "version": "1.0.234"
16666
+ "version": "1.0.237"
16623
16667
  },
16624
16668
  "taggedModuleExports": []
16625
16669
  }
@@ -90,7 +90,7 @@ class BuildPipe {
90
90
  }) => this.executeTask(task, env));
91
91
  this.longProcessLogger.end();
92
92
  const capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;
93
- const tasksResultsList = new (_taskResultsList().TaskResultsList)(this.tasksQueue, this.taskResults, capsuleRootDir);
93
+ const tasksResultsList = new (_taskResultsList().TaskResultsList)(this.tasksQueue, this.taskResults, capsuleRootDir, this.logger);
94
94
  await this.executePostBuild(tasksResultsList);
95
95
  return tasksResultsList;
96
96
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_prettyTime","_toolboxString","_chalk","_buildTask","_taskResultsList","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","capsuleRootDir","values","capsuleNetwork","capsulesRootDir","tasksResultsList","TaskResultsList","executePostBuild","setStatusLine","preBuild","getBuildContext","id","taskId","BuildTaskHelper","serializeId","envName","showEnvNameInOutput","getPrettyEnvName","buildContext","hasOriginalSeeders","Boolean","_originalSeeders","dependencyStr","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","startTask","process","hrtime","taskStartTime","Date","now","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","errors","artifacts","duration","prettyTime","chalk","red","getProgress","failedTasks","push","color","green","dim","consoleSuccess","defs","generate","startTime","resolvedId","ComponentID","fromString","tokens","split","map","token","capitalize","join","envId","ver","showEnvVersionInOutput","version","fullName","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","deserializeIdAllowEmptyName","find","failedTask","exitOnFirstFailedTask","failedTaskId","consoleWarning","Error","previousTasksResults","exports"],"sources":["build-pipe.ts"],"sourcesContent":["import { EnvDefinition } from '@teambit/envs';\nimport { ComponentMap, ComponentID } from '@teambit/component';\nimport { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { capitalize } from '@teambit/toolbox.string.capitalize';\nimport chalk from 'chalk';\nimport { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';\nimport { BuildContext, 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\ntype PipeOptions = {\n exitOnFirstFailedTask?: boolean; // by default it skips only when a dependent failed.\n showEnvNameInOutput?: boolean;\n showEnvVersionInOutput?: boolean; // in case it shows the env-name, whether should show also the version\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 private options?: PipeOptions\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 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 capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;\n const tasksResultsList = new TaskResultsList(this.tasksQueue, this.taskResults, capsuleRootDir);\n await this.executePostBuild(tasksResultsList);\n\n return tasksResultsList;\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n const longProcessLogger = this.logger.createLongProcessLogger('running 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 longProcessLogger.end();\n }\n\n private async executeTask(task: BuildTask, env: EnvDefinition): Promise<void> {\n const taskId = BuildTaskHelper.serializeId(task);\n const envName = this.options?.showEnvNameInOutput ? `(${this.getPrettyEnvName(env.id)}) ` : '';\n const buildContext = this.getBuildContext(env.id);\n const hasOriginalSeeders = Boolean(buildContext.capsuleNetwork._originalSeeders?.length);\n const dependencyStr = hasOriginalSeeders ? '' : `[dependency] `;\n const taskLogPrefix = `${dependencyStr}${envName}[${this.getPrettyAspectName(task.aspectId)}: ${task.name}]`;\n this.longProcessLogger.logProgress(`${taskLogPrefix}${task.description ? ` ${task.description}` : ''}`, false);\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 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 const duration = prettyTime(process.hrtime(startTask));\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.logger.consoleFailure(\n chalk.red(`${this.longProcessLogger.getProgress()} env: ${env.id}, task \"${taskId}\" has failed in ${duration}`)\n );\n this.failedTasks.push(task);\n } else {\n const color = hasOriginalSeeders ? chalk.green : chalk.green.dim;\n this.logger.consoleSuccess(\n color(`${this.longProcessLogger.getProgress()} ${taskLogPrefix} Completed successfully in ${duration}`)\n );\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 getPrettyAspectName(aspectId: string): string {\n const resolvedId = ComponentID.fromString(aspectId);\n const tokens = resolvedId.name.split('-').map((token) => capitalize(token));\n return tokens.join(' ');\n }\n\n private getPrettyEnvName(envId: string) {\n const resolvedId = ComponentID.fromString(envId);\n const ver = this.options?.showEnvVersionInOutput ? `@${resolvedId.version}` : '';\n return `${resolvedId.fullName}${ver}`;\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n const longProcessLogger = this.logger.createLongProcessLogger('running post-build for all tasks');\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 longProcessLogger.end();\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.options?.exitOnFirstFailedTask && this.failedTasks.length) {\n const failedTaskId = BuildTaskHelper.serializeId(this.failedTasks[0]);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\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): BuildContext {\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"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OA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,SAAA","ignoreList":[]}
1
+ {"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_prettyTime","_toolboxString","_chalk","_buildTask","_taskResultsList","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","capsuleRootDir","values","capsuleNetwork","capsulesRootDir","tasksResultsList","TaskResultsList","executePostBuild","setStatusLine","preBuild","getBuildContext","id","taskId","BuildTaskHelper","serializeId","envName","showEnvNameInOutput","getPrettyEnvName","buildContext","hasOriginalSeeders","Boolean","_originalSeeders","dependencyStr","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","startTask","process","hrtime","taskStartTime","Date","now","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","errors","artifacts","duration","prettyTime","chalk","red","getProgress","failedTasks","push","color","green","dim","consoleSuccess","defs","generate","startTime","resolvedId","ComponentID","fromString","tokens","split","map","token","capitalize","join","envId","ver","showEnvVersionInOutput","version","fullName","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","deserializeIdAllowEmptyName","find","failedTask","exitOnFirstFailedTask","failedTaskId","consoleWarning","Error","previousTasksResults","exports"],"sources":["build-pipe.ts"],"sourcesContent":["import { EnvDefinition } from '@teambit/envs';\nimport { ComponentMap, ComponentID } from '@teambit/component';\nimport { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { capitalize } from '@teambit/toolbox.string.capitalize';\nimport chalk from 'chalk';\nimport { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';\nimport { BuildContext, 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\ntype PipeOptions = {\n exitOnFirstFailedTask?: boolean; // by default it skips only when a dependent failed.\n showEnvNameInOutput?: boolean;\n showEnvVersionInOutput?: boolean; // in case it shows the env-name, whether should show also the version\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 private options?: PipeOptions\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 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 capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;\n const tasksResultsList = new TaskResultsList(this.tasksQueue, this.taskResults, capsuleRootDir, this.logger);\n await this.executePostBuild(tasksResultsList);\n\n return tasksResultsList;\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n const longProcessLogger = this.logger.createLongProcessLogger('running 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 longProcessLogger.end();\n }\n\n private async executeTask(task: BuildTask, env: EnvDefinition): Promise<void> {\n const taskId = BuildTaskHelper.serializeId(task);\n const envName = this.options?.showEnvNameInOutput ? `(${this.getPrettyEnvName(env.id)}) ` : '';\n const buildContext = this.getBuildContext(env.id);\n const hasOriginalSeeders = Boolean(buildContext.capsuleNetwork._originalSeeders?.length);\n const dependencyStr = hasOriginalSeeders ? '' : `[dependency] `;\n const taskLogPrefix = `${dependencyStr}${envName}[${this.getPrettyAspectName(task.aspectId)}: ${task.name}]`;\n this.longProcessLogger.logProgress(`${taskLogPrefix}${task.description ? ` ${task.description}` : ''}`, false);\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 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 const duration = prettyTime(process.hrtime(startTask));\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.logger.consoleFailure(\n chalk.red(`${this.longProcessLogger.getProgress()} env: ${env.id}, task \"${taskId}\" has failed in ${duration}`)\n );\n this.failedTasks.push(task);\n } else {\n const color = hasOriginalSeeders ? chalk.green : chalk.green.dim;\n this.logger.consoleSuccess(\n color(`${this.longProcessLogger.getProgress()} ${taskLogPrefix} Completed successfully in ${duration}`)\n );\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 getPrettyAspectName(aspectId: string): string {\n const resolvedId = ComponentID.fromString(aspectId);\n const tokens = resolvedId.name.split('-').map((token) => capitalize(token));\n return tokens.join(' ');\n }\n\n private getPrettyEnvName(envId: string) {\n const resolvedId = ComponentID.fromString(envId);\n const ver = this.options?.showEnvVersionInOutput ? `@${resolvedId.version}` : '';\n return `${resolvedId.fullName}${ver}`;\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n const longProcessLogger = this.logger.createLongProcessLogger('running post-build for all tasks');\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 longProcessLogger.end();\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.options?.exitOnFirstFailedTask && this.failedTasks.length) {\n const failedTaskId = BuildTaskHelper.serializeId(this.failedTasks[0]);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\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): BuildContext {\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"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,OAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAQ,iBAAA;EAAA,MAAAR,IAAA,GAAAC,OAAA;EAAAO,gBAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAsD,SAAAG,uBAAAM,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,gBAAAH,GAAA,EAAAI,GAAA,EAAAC,KAAA,IAAAD,GAA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AAOhB,KAAM,WAAU1D,MAAO,yBAAwByE,YAAa,WAAU,CAAC;IAC1G,OAAO,IAAI;EACb;EAEQ3E,eAAeA,CAAC4D,KAAa,EAAgB;IACnD,MAAMpD,YAAY,GAAG,IAAI,CAAClC,gBAAgB,CAACsF,KAAK,CAAC;IACjD,IAAI,CAACpD,YAAY,EAAE,MAAM,IAAIqE,KAAK,CAAE,mCAAkCjB,KAAM,EAAC,CAAC;IAC9EpD,YAAY,CAACsE,oBAAoB,GAAG,IAAI,CAACnG,eAAe;IACxD,OAAO6B,YAAY;EACrB;AACF;AAACuE,OAAA,CAAA5G,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -3,13 +3,14 @@ import { Logger } from '@teambit/logger';
3
3
  import { Workspace } from '@teambit/workspace';
4
4
  import { BuilderMain } from './builder.main.runtime';
5
5
  type BuildOpts = {
6
- all: boolean;
7
6
  unmodified?: boolean;
8
7
  dev: boolean;
9
8
  rebuild: boolean;
10
9
  install: boolean;
11
10
  cachePackagesOnCapsulesRoot: boolean;
12
11
  reuseCapsules: boolean;
12
+ rewrite?: boolean;
13
+ reinstall?: boolean;
13
14
  tasks: string;
14
15
  listTasks?: string;
15
16
  skipTests?: boolean;
@@ -28,12 +29,16 @@ export declare class BuilderCmd implements Command {
28
29
  name: string;
29
30
  description: string;
30
31
  }[];
32
+ examples: {
33
+ cmd: string;
34
+ description: string;
35
+ }[];
31
36
  helpUrl: string;
32
37
  alias: string;
33
38
  group: string;
34
39
  options: CommandOptions;
35
40
  constructor(builder: BuilderMain, workspace: Workspace, logger: Logger);
36
- report([pattern]: [string], { all, unmodified, dev, install, cachePackagesOnCapsulesRoot, reuseCapsules, tasks, listTasks, skipTests, failFast, includeSnap, includeTag, }: BuildOpts): Promise<string>;
41
+ report([pattern]: [string], { unmodified, dev, install, cachePackagesOnCapsulesRoot, reuseCapsules, rewrite, reinstall, tasks, listTasks, skipTests, failFast, includeSnap, includeTag, }: BuildOpts): Promise<string>;
37
42
  private getListTasks;
38
43
  }
39
44
  export {};
package/dist/build.cmd.js CHANGED
@@ -43,24 +43,37 @@ class BuilderCmd {
43
43
  this.logger = logger;
44
44
  _defineProperty(this, "name", 'build [component-pattern]');
45
45
  _defineProperty(this, "description", 'run set of tasks for build.');
46
- _defineProperty(this, "extendedDescription", 'by default, only new and modified components are built');
46
+ _defineProperty(this, "extendedDescription", `by default, only new and modified components are built.
47
+ the build takes place in an isolated directories on the filesystem (called "capsules"). the component files are copied to these directories
48
+ and the package-manager installs the dependencies in the capsules root. once done, the build pipeline is running.
49
+ because 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.
50
+ `);
47
51
  _defineProperty(this, "arguments", [{
48
52
  name: 'component-pattern',
49
53
  description: _constants().COMPONENT_PATTERN_HELP
50
54
  }]);
55
+ _defineProperty(this, "examples", [{
56
+ cmd: 'build --reuse-capsules --tasks "custom-task"',
57
+ description: 'helps to debug this "custom-task" without recreating the capsules from scratch'
58
+ }, {
59
+ cmd: 'build --reuse-capsules --rewrite --tasks "BabelCompile,MochaTest"',
60
+ description: `helpful when for example the tests are failing and code changes are needed to debug it.
61
+ the "--rewrite" flag ensures the component files are fresh, and the "--tasks" ensures to re-compile them and then run the tests`
62
+ }]);
51
63
  _defineProperty(this, "helpUrl", 'reference/build-pipeline/builder-overview');
52
64
  _defineProperty(this, "alias", '');
53
65
  _defineProperty(this, "group", 'development');
54
- _defineProperty(this, "options", [['a', 'all', 'DEPRECATED. use --unmodified'], ['u', 'unmodified', 'include unmodified components (by default, only new and modified components are built)'], ['d', 'dev', 'run the pipeline in dev mode'], ['', 'install', 'install core aspects in capsules'], ['', 'reuse-capsules', 'avoid deleting the capsules root-dir before starting the build'], ['', 'tasks <string>', `build the specified task(s) only. for multiple tasks, separate by a comma and wrap with quotes.
66
+ _defineProperty(this, "options", [['u', 'unmodified', 'include unmodified components (by default, only new and modified components are built)'], ['d', 'dev', 'run the pipeline in dev mode'], ['', 'install', 'install core aspects in capsules'], ['', 'reuse-capsules', 'avoid deleting the capsules root-dir before starting the build'], ['', 'rewrite', 'use only with --reuse-capsules. rewrite the component files'], ['', 'reinstall', 'use only with --reuse-capsules. rerun the installation'], ['', 'tasks <string>', `build the specified task(s) only. for multiple tasks, separate by a comma and wrap with quotes.
55
67
  specify the task-name (e.g. "TypescriptCompiler") or the task-aspect-id (e.g. teambit.compilation/compiler)`], ['', 'cache-packages-on-capsule-root', 'set the package-manager cache on the capsule root'], ['', 'list-tasks <string>', 'list tasks of an env or a component-id for each one of the pipelines: build, tag and snap'], ['', 'skip-tests', 'skip running component tests during build process'], ['', 'fail-fast', 'stop pipeline execution on the first failed task (by default a task is skipped only when its dependency failed)'], ['', 'include-snap', 'EXPERIMENTAL. include snap pipeline tasks. Warning: this may deploy/publish if you have such tasks'], ['', 'include-tag', 'EXPERIMENTAL. include tag pipeline tasks. Warning: this may deploy/publish if you have such tasks']]);
56
68
  }
57
69
  async report([pattern], {
58
- all = false,
59
70
  unmodified = false,
60
71
  dev = false,
61
72
  install = false,
62
73
  cachePackagesOnCapsulesRoot = false,
63
74
  reuseCapsules = false,
75
+ rewrite = false,
76
+ reinstall = false,
64
77
  tasks,
65
78
  listTasks,
66
79
  skipTests,
@@ -68,11 +81,9 @@ specify the task-name (e.g. "TypescriptCompiler") or the task-aspect-id (e.g. te
68
81
  includeSnap,
69
82
  includeTag
70
83
  }) {
84
+ if (rewrite && !reuseCapsules) throw new Error('cannot use --rewrite without --reuse-capsules');
85
+ if (reinstall && !reuseCapsules) throw new Error('cannot use --reinstall without --reuse-capsules');
71
86
  if (!this.workspace) throw new (_workspace().OutsideWorkspaceError)();
72
- if (all) {
73
- this.logger.consoleWarning(`--all is deprecated, please use --unmodified instead`);
74
- unmodified = true;
75
- }
76
87
  if (listTasks) {
77
88
  return this.getListTasks(listTasks);
78
89
  }
@@ -85,13 +96,14 @@ specify the task-name (e.g. "TypescriptCompiler") or the task-aspect-id (e.g. te
85
96
  const envsExecutionResults = await this.builder.build(components, {
86
97
  installOptions: {
87
98
  installTeambitBit: install,
88
- packageManagerConfigRootDir: this.workspace.path
99
+ packageManagerConfigRootDir: this.workspace.path,
100
+ installPackages: rewrite && !reinstall ? false : true
89
101
  },
90
102
  linkingOptions: {
91
103
  linkTeambitBit: !install
92
104
  },
93
105
  emptyRootDir: !reuseCapsules,
94
- getExistingAsIs: reuseCapsules,
106
+ getExistingAsIs: reuseCapsules && !rewrite && !reinstall,
95
107
  cachePackagesOnCapsulesRoot
96
108
  }, {
97
109
  dev,
@@ -1 +1 @@
1
- {"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","_workspace","_constants","_chalk","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","BuilderCmd","constructor","builder","workspace","logger","name","description","COMPONENT_PATTERN_HELP","report","pattern","all","unmodified","dev","install","cachePackagesOnCapsulesRoot","reuseCapsules","tasks","listTasks","skipTests","failFast","includeSnap","includeTag","OutsideWorkspaceError","consoleWarning","getListTasks","setStatusLine","start","process","hrtime","components","getComponentsByUserInput","length","chalk","bold","envsExecutionResults","build","installOptions","installTeambitBit","packageManagerConfigRootDir","path","linkingOptions","linkTeambitBit","emptyRootDir","getExistingAsIs","split","map","task","trim","exitOnFirstFailedTask","console","capsuleRootDir","duration","prettyTime","succeedOrFailed","hasErrors","msg","consoleFailure","throwErrorsIfExist","green","componentIdStr","compId","resolveComponentId","component","get","results","id","toString","envId","buildTasks","join","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/dist/constants';\nimport chalk from 'chalk';\nimport { BuilderMain } from './builder.main.runtime';\n\ntype BuildOpts = {\n all: boolean; // deprecated. use unmodified\n unmodified?: boolean;\n dev: boolean;\n rebuild: boolean;\n install: boolean;\n cachePackagesOnCapsulesRoot: boolean;\n reuseCapsules: boolean;\n tasks: string;\n listTasks?: string;\n skipTests?: boolean;\n failFast?: boolean;\n includeSnap?: boolean;\n includeTag?: 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';\n arguments = [{ name: 'component-pattern', description: COMPONENT_PATTERN_HELP }];\n helpUrl = 'reference/build-pipeline/builder-overview';\n alias = '';\n group = 'development';\n options = [\n ['a', 'all', 'DEPRECATED. use --unmodified'],\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 [\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 [\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 [\n '',\n 'include-snap',\n 'EXPERIMENTAL. include snap pipeline tasks. Warning: this may deploy/publish if you have such tasks',\n ],\n [\n '',\n 'include-tag',\n 'EXPERIMENTAL. include tag pipeline tasks. Warning: this may deploy/publish if you have such tasks',\n ],\n ] as CommandOptions;\n\n constructor(private builder: BuilderMain, private workspace: Workspace, private logger: Logger) {}\n\n async report(\n [pattern]: [string],\n {\n all = false,\n unmodified = false,\n dev = false,\n install = false,\n cachePackagesOnCapsulesRoot = false,\n reuseCapsules = false,\n tasks,\n listTasks,\n skipTests,\n failFast,\n includeSnap,\n includeTag,\n }: BuildOpts\n ): Promise<string> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n if (all) {\n this.logger.consoleWarning(`--all is deprecated, please use --unmodified instead`);\n unmodified = true;\n }\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 envsExecutionResults = await this.builder.build(\n components,\n {\n installOptions: {\n installTeambitBit: install,\n packageManagerConfigRootDir: this.workspace.path,\n },\n linkingOptions: { linkTeambitBit: !install },\n emptyRootDir: !reuseCapsules,\n getExistingAsIs: reuseCapsules,\n cachePackagesOnCapsulesRoot,\n },\n {\n dev,\n tasks: tasks ? tasks.split(',').map((task) => task.trim()) : [],\n skipTests,\n exitOnFirstFailedTask: failFast,\n },\n {\n includeSnap,\n includeTag,\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() ? 'failed' : 'succeeded';\n const msg = `build ${succeedOrFailed}. completed in ${duration}.`;\n if (envsExecutionResults.hasErrors()) {\n this.logger.consoleFailure(msg);\n }\n envsExecutionResults.throwErrorsIfExist();\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/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/B,SAASF,OAAO,CAACG,KAAM;AACvB;AACA,EAAEnC,gBAAK,CAACC,IAAI,CAAC,uBAAuB,CAAE;AACtC,EAAE+B,OAAO,CAACI,UAAU,CAACC,IAAI,CAAC,IAAI,CAAE;AAChC;AACA,EAAErC,gBAAK,CAACC,IAAI,CAAC,qBAAqB,CAAE;AACpC,EAAE+B,OAAO,CAACM,QAAQ,CAACD,IAAI,CAAC,IAAI,CAAE;AAC9B;AACA,EAAErC,gBAAK,CAACC,IAAI,CAAC,sBAAsB,CAAE;AACrC,EAAE+B,OAAO,CAACO,SAAS,CAACF,IAAI,CAAC,IAAI,CAAC,IAAI,OAAQ,EAAC;EACzC;AACF;AAACG,OAAA,CAAAxE,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["_prettyTime","data","_interopRequireDefault","require","_workspace","_constants","_chalk","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","BuilderCmd","constructor","builder","workspace","logger","name","description","COMPONENT_PATTERN_HELP","cmd","report","pattern","unmodified","dev","install","cachePackagesOnCapsulesRoot","reuseCapsules","rewrite","reinstall","tasks","listTasks","skipTests","failFast","includeSnap","includeTag","Error","OutsideWorkspaceError","getListTasks","setStatusLine","start","process","hrtime","components","getComponentsByUserInput","length","chalk","bold","envsExecutionResults","build","installOptions","installTeambitBit","packageManagerConfigRootDir","path","installPackages","linkingOptions","linkTeambitBit","emptyRootDir","getExistingAsIs","split","map","task","trim","exitOnFirstFailedTask","console","capsuleRootDir","duration","prettyTime","succeedOrFailed","hasErrors","msg","consoleFailure","throwErrorsIfExist","green","componentIdStr","compId","resolveComponentId","component","get","results","id","toString","envId","buildTasks","join","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/dist/constants';\nimport chalk from 'chalk';\nimport { BuilderMain } from './builder.main.runtime';\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 failFast?: boolean;\n includeSnap?: boolean;\n includeTag?: 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 = '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 [\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 [\n '',\n 'include-snap',\n 'EXPERIMENTAL. include snap pipeline tasks. Warning: this may deploy/publish if you have such tasks',\n ],\n [\n '',\n 'include-tag',\n 'EXPERIMENTAL. include tag pipeline tasks. Warning: this may deploy/publish if you have such tasks',\n ],\n ] as CommandOptions;\n\n constructor(private builder: BuilderMain, private workspace: Workspace, private logger: Logger) {}\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 failFast,\n includeSnap,\n includeTag,\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 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 exitOnFirstFailedTask: failFast,\n },\n {\n includeSnap,\n includeTag,\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() ? 'failed' : 'succeeded';\n const msg = `build ${succeedOrFailed}. completed in ${duration}.`;\n if (envsExecutionResults.hasErrors()) {\n this.logger.consoleFailure(msg);\n }\n envsExecutionResults.throwErrorsIfExist();\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,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,sBA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uBAAuB,CAAE;AACtC,EAAEgC,OAAO,CAACI,UAAU,CAACC,IAAI,CAAC,IAAI,CAAE;AAChC;AACA,EAAEtC,gBAAK,CAACC,IAAI,CAAC,qBAAqB,CAAE;AACpC,EAAEgC,OAAO,CAACM,QAAQ,CAACD,IAAI,CAAC,IAAI,CAAE;AAC9B;AACA,EAAEtC,gBAAK,CAACC,IAAI,CAAC,sBAAsB,CAAE;AACrC,EAAEgC,OAAO,CAACO,SAAS,CAACF,IAAI,CAAC,IAAI,CAAC,IAAI,OAAQ,EAAC;EACzC;AACF;AAACG,OAAA,CAAA3E,UAAA,GAAAA,UAAA","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.pipelines_builder@1.0.234/dist/builder.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.pipelines_builder@1.0.234/dist/builder.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.pipelines_builder@1.0.237/dist/builder.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.pipelines_builder@1.0.237/dist/builder.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -1,3 +1,4 @@
1
+ import { Logger } from '@teambit/logger';
1
2
  import { TasksQueue } from './tasks-queue';
2
3
  import { TaskResults } from './build-pipe';
3
4
  export declare class TaskResultsList {
@@ -7,11 +8,12 @@ export declare class TaskResultsList {
7
8
  */
8
9
  tasksResults: TaskResults[];
9
10
  capsuleRootDir: string;
11
+ private logger;
10
12
  constructor(tasksQueue: TasksQueue,
11
13
  /**
12
14
  * results of all tasks executed in the build pipeline.
13
15
  */
14
- tasksResults: TaskResults[], capsuleRootDir: string);
16
+ tasksResults: TaskResults[], capsuleRootDir: string, logger: Logger);
15
17
  hasErrors(): boolean;
16
18
  throwErrorsIfExist(): void;
17
19
  /**
@@ -19,4 +21,5 @@ export declare class TaskResultsList {
19
21
  */
20
22
  getErrorMessageFormatted(): string | null;
21
23
  private aggregateTaskErrorsToOneString;
24
+ private logStackTrace;
22
25
  }
@@ -31,15 +31,17 @@ class TaskResultsList {
31
31
  /**
32
32
  * results of all tasks executed in the build pipeline.
33
33
  */
34
- tasksResults, capsuleRootDir) {
34
+ tasksResults, capsuleRootDir, logger) {
35
35
  this.tasksQueue = tasksQueue;
36
36
  this.tasksResults = tasksResults;
37
37
  this.capsuleRootDir = capsuleRootDir;
38
+ this.logger = logger;
38
39
  }
39
40
  hasErrors() {
40
41
  return this.tasksResults.some(taskResult => taskResult.componentsResults.find(c => c.errors?.length));
41
42
  }
42
43
  throwErrorsIfExist() {
44
+ this.logStackTrace();
43
45
  const errorMessage = this.getErrorMessageFormatted();
44
46
  if (errorMessage) {
45
47
  throw new (_bitError().BitError)(errorMessage);
@@ -77,6 +79,17 @@ class TaskResultsList {
77
79
  const errors = rawErrors.map(e => typeof e === 'string' ? e : e.toString());
78
80
  return `component: ${componentResult.component.id.toString()}\n${errors.join('\n')}`;
79
81
  }
82
+ logStackTrace() {
83
+ this.tasksResults.forEach(taskResult => {
84
+ taskResult.componentsResults.forEach(componentResult => {
85
+ componentResult.errors?.forEach(error => {
86
+ if (error instanceof Error) {
87
+ this.logger.error(`failed running task ${taskResult.task.name} on ${componentResult.component.id.toString()}`, error);
88
+ }
89
+ });
90
+ });
91
+ });
92
+ }
80
93
  }
81
94
  exports.TaskResultsList = TaskResultsList;
82
95
 
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_bitError","_buildTask","obj","__esModule","default","TaskResultsList","constructor","tasksQueue","tasksResults","capsuleRootDir","hasErrors","some","taskResult","componentsResults","find","c","errors","length","throwErrorsIfExist","errorMessage","getErrorMessageFormatted","BitError","tasksErrors","totalErrors","forEach","compsWithErrors","filter","title","chalk","bold","BuildTaskHelper","serializeId","task","env","id","errorsStr","map","compWithErrors","aggregateTaskErrorsToOneString","join","taskErrors","reduce","acc","current","summery","push","totalTasks","totalFailed","totalSucceed","totalSkipped","componentResult","rawErrors","e","toString","component","exports"],"sources":["task-results-list.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { BitError } from '@teambit/bit-error';\nimport { BuildTaskHelper } from './build-task';\nimport { TasksQueue } from './tasks-queue';\nimport { TaskResults } from './build-pipe';\nimport { ComponentResult } from './types';\n\nexport class TaskResultsList {\n constructor(\n public tasksQueue: TasksQueue,\n /**\n * results of all tasks executed in the build pipeline.\n */\n public tasksResults: TaskResults[],\n\n public capsuleRootDir: string\n ) {}\n\n hasErrors(): boolean {\n return this.tasksResults.some((taskResult) => taskResult.componentsResults.find((c) => c.errors?.length));\n }\n\n throwErrorsIfExist() {\n const errorMessage = this.getErrorMessageFormatted();\n if (errorMessage) {\n throw new BitError(errorMessage);\n }\n }\n\n /**\n * group errors from all tasks and show them nicely to the user\n */\n public getErrorMessageFormatted(): string | null {\n const tasksErrors: string[] = [];\n let totalErrors = 0;\n this.tasksResults.forEach((taskResult) => {\n const compsWithErrors = taskResult.componentsResults.filter((c) => c.errors?.length);\n if (!compsWithErrors.length) return;\n const title = chalk.bold(\n `Failed task ${tasksErrors.length + 1}: \"${BuildTaskHelper.serializeId(taskResult.task)}\" of env \"${\n taskResult.env.id\n }\"\\n`\n );\n const errorsStr = compsWithErrors\n .map((compWithErrors) => this.aggregateTaskErrorsToOneString(compWithErrors))\n .join('\\n\\n');\n const taskErrors = compsWithErrors.reduce((acc, current) => acc + (current.errors || []).length, 0);\n const summery = `\\n\\nFound ${taskErrors} errors in ${compsWithErrors.length} components`;\n totalErrors += taskErrors;\n tasksErrors.push(title + errorsStr + summery);\n });\n if (!tasksErrors.length) return null;\n const title = `\\nThe following errors were found while running the build pipeline\\n`;\n const errorsStr = tasksErrors.join('\\n\\n');\n const totalTasks = this.tasksQueue.length;\n const totalFailed = tasksErrors.length;\n const totalSucceed = this.tasksResults.length - totalFailed;\n const totalSkipped = totalTasks - this.tasksResults.length;\n const summery = `\\n\\n\\n✖ Total ${totalTasks} tasks. ${totalSucceed} succeeded. ${totalFailed} failed. ${totalSkipped} skipped. Total errors: ${totalErrors}.`;\n return title + errorsStr + summery;\n }\n\n private aggregateTaskErrorsToOneString(componentResult: ComponentResult) {\n const rawErrors = componentResult.errors || [];\n const errors = rawErrors.map((e) => (typeof e === 'string' ? e : e.toString()));\n return `component: ${componentResult.component.id.toString()}\\n${errors.join('\\n')}`;\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAKxC,MAAMG,eAAe,CAAC;EAC3BC,WAAWA,CACFC,UAAsB;EAC7B;AACJ;AACA;EACWC,YAA2B,EAE3BC,cAAsB,EAC7B;IAAA,KAPOF,UAAsB,GAAtBA,UAAsB;IAAA,KAItBC,YAA2B,GAA3BA,YAA2B;IAAA,KAE3BC,cAAsB,GAAtBA,cAAsB;EAC5B;EAEHC,SAASA,CAAA,EAAY;IACnB,OAAO,IAAI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AW,IAAIiB,UAAU;MACzBlB,WAAW,CAACuB,IAAI,CAAClB,KAAK,GAAGQ,SAAS,GAAGS,OAAO,CAAC;IAC/C,CAAC,CAAC;IACF,IAAI,CAACtB,WAAW,CAACL,MAAM,EAAE,OAAO,IAAI;IACpC,MAAMU,KAAK,GAAI,sEAAqE;IACpF,MAAMQ,SAAS,GAAGb,WAAW,CAACiB,IAAI,CAAC,MAAM,CAAC;IAC1C,MAAMO,UAAU,GAAG,IAAI,CAACvC,UAAU,CAACU,MAAM;IACzC,MAAM8B,WAAW,GAAGzB,WAAW,CAACL,MAAM;IACtC,MAAM+B,YAAY,GAAG,IAAI,CAACxC,YAAY,CAACS,MAAM,GAAG8B,WAAW;IAC3D,MAAME,YAAY,GAAGH,UAAU,GAAG,IAAI,CAACtC,YAAY,CAACS,MAAM;IAC1D,MAAM2B,OAAO,GAAI,iBAAgBE,UAAW,WAAUE,YAAa,eAAcD,WAAY,YAAWE,YAAa,2BAA0B1B,WAAY,GAAE;IAC7J,OAAOI,KAAK,GAAGQ,SAAS,GAAGS,OAAO;EACpC;EAEQN,8BAA8BA,CAACY,eAAgC,EAAE;IACvE,MAAMC,SAAS,GAAGD,eAAe,CAAClC,MAAM,IAAI,EAAE;IAC9C,MAAMA,MAAM,GAAGmC,SAAS,CAACf,GAAG,CAAEgB,CAAC,IAAM,OAAOA,CAAC,KAAK,QAAQ,GAAGA,CAAC,GAAGA,CAAC,CAACC,QAAQ,CAAC,CAAE,CAAC;IAC/E,OAAQ,cAAaH,eAAe,CAACI,SAAS,CAACpB,EAAE,CAACmB,QAAQ,CAAC,CAAE,KAAIrC,MAAM,CAACuB,IAAI,CAAC,IAAI,CAAE,EAAC;EACtF;AACF;AAACgB,OAAA,CAAAlD,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_bitError","_buildTask","obj","__esModule","default","TaskResultsList","constructor","tasksQueue","tasksResults","capsuleRootDir","logger","hasErrors","some","taskResult","componentsResults","find","c","errors","length","throwErrorsIfExist","logStackTrace","errorMessage","getErrorMessageFormatted","BitError","tasksErrors","totalErrors","forEach","compsWithErrors","filter","title","chalk","bold","BuildTaskHelper","serializeId","task","env","id","errorsStr","map","compWithErrors","aggregateTaskErrorsToOneString","join","taskErrors","reduce","acc","current","summery","push","totalTasks","totalFailed","totalSucceed","totalSkipped","componentResult","rawErrors","e","toString","component","error","Error","name","exports"],"sources":["task-results-list.ts"],"sourcesContent":["import chalk from 'chalk';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { BuildTaskHelper } from './build-task';\nimport { TasksQueue } from './tasks-queue';\nimport { TaskResults } from './build-pipe';\nimport { ComponentResult } from './types';\n\nexport class TaskResultsList {\n constructor(\n public tasksQueue: TasksQueue,\n /**\n * results of all tasks executed in the build pipeline.\n */\n public tasksResults: TaskResults[],\n\n public capsuleRootDir: string,\n\n private logger: Logger\n ) {}\n\n hasErrors(): boolean {\n return this.tasksResults.some((taskResult) => taskResult.componentsResults.find((c) => c.errors?.length));\n }\n\n throwErrorsIfExist() {\n this.logStackTrace();\n const errorMessage = this.getErrorMessageFormatted();\n if (errorMessage) {\n throw new BitError(errorMessage);\n }\n }\n\n /**\n * group errors from all tasks and show them nicely to the user\n */\n getErrorMessageFormatted(): string | null {\n const tasksErrors: string[] = [];\n let totalErrors = 0;\n this.tasksResults.forEach((taskResult) => {\n const compsWithErrors = taskResult.componentsResults.filter((c) => c.errors?.length);\n if (!compsWithErrors.length) return;\n const title = chalk.bold(\n `Failed task ${tasksErrors.length + 1}: \"${BuildTaskHelper.serializeId(taskResult.task)}\" of env \"${\n taskResult.env.id\n }\"\\n`\n );\n const errorsStr = compsWithErrors\n .map((compWithErrors) => this.aggregateTaskErrorsToOneString(compWithErrors))\n .join('\\n\\n');\n const taskErrors = compsWithErrors.reduce((acc, current) => acc + (current.errors || []).length, 0);\n const summery = `\\n\\nFound ${taskErrors} errors in ${compsWithErrors.length} components`;\n totalErrors += taskErrors;\n tasksErrors.push(title + errorsStr + summery);\n });\n if (!tasksErrors.length) return null;\n const title = `\\nThe following errors were found while running the build pipeline\\n`;\n const errorsStr = tasksErrors.join('\\n\\n');\n const totalTasks = this.tasksQueue.length;\n const totalFailed = tasksErrors.length;\n const totalSucceed = this.tasksResults.length - totalFailed;\n const totalSkipped = totalTasks - this.tasksResults.length;\n const summery = `\\n\\n\\n✖ Total ${totalTasks} tasks. ${totalSucceed} succeeded. ${totalFailed} failed. ${totalSkipped} skipped. Total errors: ${totalErrors}.`;\n return title + errorsStr + summery;\n }\n\n private aggregateTaskErrorsToOneString(componentResult: ComponentResult) {\n const rawErrors = componentResult.errors || [];\n const errors = rawErrors.map((e) => (typeof e === 'string' ? e : e.toString()));\n return `component: ${componentResult.component.id.toString()}\\n${errors.join('\\n')}`;\n }\n\n private logStackTrace() {\n this.tasksResults.forEach((taskResult) => {\n taskResult.componentsResults.forEach((componentResult) => {\n componentResult.errors?.forEach((error) => {\n if (error instanceof Error) {\n this.logger.error(\n `failed running task ${taskResult.task.name} on ${componentResult.component.id.toString()}`,\n error\n );\n }\n });\n });\n });\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,SAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,WAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,UAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF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,CAAC,CAACC,QAAQ,CAAC,CAAE,CAAC;IAC/E,OAAQ,cAAaH,eAAe,CAACI,SAAS,CAACpB,EAAE,CAACmB,QAAQ,CAAC,CAAE,KAAItC,MAAM,CAACwB,IAAI,CAAC,IAAI,CAAE,EAAC;EACtF;EAEQrB,aAAaA,CAAA,EAAG;IACtB,IAAI,CAACZ,YAAY,CAACkB,OAAO,CAAEb,UAAU,IAAK;MACxCA,UAAU,CAACC,iBAAiB,CAACY,OAAO,CAAE0B,eAAe,IAAK;QACxDA,eAAe,CAACnC,MAAM,EAAES,OAAO,CAAE+B,KAAK,IAAK;UACzC,IAAIA,KAAK,YAAYC,KAAK,EAAE;YAC1B,IAAI,CAAChD,MAAM,CAAC+C,KAAK,CACd,uBAAsB5C,UAAU,CAACqB,IAAI,CAACyB,IAAK,OAAMP,eAAe,CAACI,SAAS,CAACpB,EAAE,CAACmB,QAAQ,CAAC,CAAE,EAAC,EAC3FE,KACF,CAAC;UACH;QACF,CAAC,CAAC;MACJ,CAAC,CAAC;IACJ,CAAC,CAAC;EACJ;AACF;AAACG,OAAA,CAAAvD,eAAA,GAAAA,eAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/builder",
3
- "version": "1.0.234",
3
+ "version": "1.0.237",
4
4
  "homepage": "https://bit.cloud/teambit/pipelines/builder",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.pipelines",
8
8
  "name": "builder",
9
- "version": "1.0.234"
9
+ "version": "1.0.237"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -26,22 +26,22 @@
26
26
  "@teambit/harmony": "0.4.6",
27
27
  "@teambit/bit-error": "0.0.404",
28
28
  "@teambit/component-id": "1.2.0",
29
- "@teambit/component": "1.0.234",
30
- "@teambit/envs": "1.0.234",
29
+ "@teambit/component": "1.0.237",
30
+ "@teambit/envs": "1.0.237",
31
31
  "@teambit/logger": "0.0.955",
32
32
  "@teambit/toolbox.string.capitalize": "0.0.496",
33
- "@teambit/tester": "1.0.234",
34
- "@teambit/isolator": "1.0.234",
33
+ "@teambit/tester": "1.0.237",
34
+ "@teambit/isolator": "1.0.237",
35
35
  "@teambit/cli": "0.0.862",
36
- "@teambit/workspace": "1.0.234",
37
- "@teambit/aspect-loader": "1.0.234",
38
- "@teambit/aspect": "1.0.234",
39
- "@teambit/generator": "1.0.235",
36
+ "@teambit/workspace": "1.0.237",
37
+ "@teambit/aspect-loader": "1.0.237",
38
+ "@teambit/aspect": "1.0.237",
39
+ "@teambit/generator": "1.0.238",
40
40
  "@teambit/global-config": "0.0.865",
41
- "@teambit/graphql": "1.0.234",
42
- "@teambit/scope": "1.0.234",
41
+ "@teambit/graphql": "1.0.237",
42
+ "@teambit/scope": "1.0.237",
43
43
  "@teambit/toolbox.array.duplications-finder": "0.0.1",
44
- "@teambit/ui": "1.0.234",
44
+ "@teambit/ui": "1.0.237",
45
45
  "@teambit/express": "0.0.961"
46
46
  },
47
47
  "devDependencies": {