@teambit/builder 1.0.516 → 1.0.518
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,5 +1,5 @@
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.518/dist/builder.composition.js';
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.pipelines_builder@1.0.518/dist/builder.docs.mdx';
|
3
3
|
|
4
4
|
export const compositions = [compositions_0];
|
5
5
|
export const overview = [overview_0];
|
package/package.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@teambit/builder",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.518",
|
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.
|
9
|
+
"version": "1.0.518"
|
10
10
|
},
|
11
11
|
"dependencies": {
|
12
12
|
"chalk": "2.4.2",
|
@@ -26,29 +26,29 @@
|
|
26
26
|
"@teambit/harmony": "0.4.6",
|
27
27
|
"@teambit/bit-error": "0.0.404",
|
28
28
|
"@teambit/component-id": "1.2.2",
|
29
|
-
"@teambit/component": "1.0.
|
30
|
-
"@teambit/envs": "1.0.
|
31
|
-
"@teambit/logger": "0.0.
|
29
|
+
"@teambit/component": "1.0.518",
|
30
|
+
"@teambit/envs": "1.0.518",
|
31
|
+
"@teambit/logger": "0.0.1188",
|
32
32
|
"@teambit/toolbox.string.capitalize": "0.0.498",
|
33
|
-
"@teambit/tester": "1.0.
|
33
|
+
"@teambit/tester": "1.0.518",
|
34
34
|
"@teambit/component.sources": "0.0.73",
|
35
|
-
"@teambit/isolator": "1.0.
|
36
|
-
"@teambit/cli": "0.0.
|
35
|
+
"@teambit/isolator": "1.0.518",
|
36
|
+
"@teambit/cli": "0.0.1095",
|
37
37
|
"@teambit/component-issues": "0.0.153",
|
38
38
|
"@teambit/legacy.constants": "0.0.7",
|
39
|
-
"@teambit/workspace": "1.0.
|
40
|
-
"@teambit/aspect-loader": "1.0.
|
41
|
-
"@teambit/aspect": "1.0.
|
39
|
+
"@teambit/workspace": "1.0.518",
|
40
|
+
"@teambit/aspect-loader": "1.0.518",
|
41
|
+
"@teambit/aspect": "1.0.518",
|
42
42
|
"@teambit/bit.get-bit-version": "0.0.3",
|
43
|
-
"@teambit/generator": "1.0.
|
44
|
-
"@teambit/global-config": "0.0.
|
45
|
-
"@teambit/graphql": "1.0.
|
46
|
-
"@teambit/issues": "1.0.
|
43
|
+
"@teambit/generator": "1.0.519",
|
44
|
+
"@teambit/global-config": "0.0.1098",
|
45
|
+
"@teambit/graphql": "1.0.518",
|
46
|
+
"@teambit/issues": "1.0.518",
|
47
47
|
"@teambit/legacy.consumer-component": "0.0.22",
|
48
|
-
"@teambit/scope": "1.0.
|
48
|
+
"@teambit/scope": "1.0.518",
|
49
49
|
"@teambit/toolbox.array.duplications-finder": "0.0.3",
|
50
|
-
"@teambit/ui": "1.0.
|
51
|
-
"@teambit/express": "0.0.
|
50
|
+
"@teambit/ui": "1.0.518",
|
51
|
+
"@teambit/express": "0.0.1194",
|
52
52
|
"@teambit/legacy.utils": "0.0.14",
|
53
53
|
"@teambit/legacy.scope": "0.0.21"
|
54
54
|
},
|
@@ -60,7 +60,7 @@
|
|
60
60
|
"@types/fs-extra": "9.0.7",
|
61
61
|
"@types/minimatch": "3.0.4",
|
62
62
|
"@types/mocha": "9.1.0",
|
63
|
-
"@teambit/harmony.envs.core-aspect-env": "0.0.
|
63
|
+
"@teambit/harmony.envs.core-aspect-env": "0.0.69",
|
64
64
|
"@teambit/pipelines.aspect-docs.builder": "0.0.172"
|
65
65
|
},
|
66
66
|
"peerDependencies": {
|
@@ -1 +0,0 @@
|
|
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={93:(e,n,t)=>{var i={id:"teambit.pipelines/aspect-docs/builder@0.0.172",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=u,o(t(594));var a=t(16),r=["components"];function o(e){return e&&e.__esModule?e:{default:e}}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)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},l.apply(null,arguments)}function s(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.includes(t)||{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function d(e,n){if(null==e)return{};var t={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(n.includes(i))continue;t[i]=e[i]}return t}o.__bit_component=i,l.__bit_component=i,s.__bit_component=i,d.__bit_component=i;var p={},m="wrapper";function u(e){var n=e.components,t=s(e,r);return(0,a.mdx)(m,l({},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(\n readonly aspectId: string,\n readonly name: string\n ) {}\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(\n readonly aspectId: string,\n readonly name: string\n ) {}\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},871:(e,n,t)=>{Object.defineProperty(n,"M",{enumerable:!0,get:function(){return i.default}});var i=a(t(93));function a(e){return e&&e.__esModule?e:{default:e}}a.__bit_component={id:"teambit.pipelines/aspect-docs/builder@0.0.172",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0}},722:(e,n,t)=>{var i={id:"teambit.pipelines/builder@1.0.516",homepage:"https://bit.cloud/teambit/pipelines/builder",exported:!0};function a(){const e=r(t(594));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},16:e=>{e.exports=MdxJsReact},594: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={};t.r(i),t.d(i,{compositions:()=>h,compositions_metadata:()=>b,overview:()=>x});var a={};t.r(a),t.d(a,{default:()=>c});var r=t(722),o=(t(594),t(16));const l=TeambitMdxUiMdxScopeContext;var s=t(871),d=["components"];function p(){return p=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)({}).hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},p.apply(null,arguments)}var m={},u="wrapper";function c(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={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(n.includes(i))continue;t[i]=e[i]}return t}(e,n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(i=0;i<r.length;i++)t=r[i],n.includes(t)||{}.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}(e,d);return(0,o.mdx)(u,p({},m,t,{components:n,mdxType:"MDXLayout"}),(0,o.mdx)(l.MDXScopeProvider,{components:{Builder:s.M},mdxType:"MDXScopeProvider"},(0,o.mdx)(s.M,{mdxType:"Builder"})))}c.isMDXComponent=!0;const h=[r],x=[a],b={compositions:[{displayName:"Logo",identifier:"Logo"}]};return i})()));
|