@teambit/builder 1.0.107 → 1.0.109
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.
- package/artifacts/preview/teambit_pipelines_builder-preview.js +1 -0
- package/dist/artifact/artifact-definition.d.ts +2 -2
- package/dist/artifact/artifact-extractor.d.ts +3 -3
- package/dist/artifact/artifact-factory.d.ts +1 -1
- package/dist/artifact/artifact-factory.js +1 -2
- package/dist/artifact/artifact-factory.js.map +1 -1
- package/dist/artifact/artifact-list.d.ts +1 -1
- package/dist/artifact/artifact.d.ts +1 -1
- package/dist/artifact/artifacts.cmd.d.ts +1 -1
- package/dist/build-pipe.d.ts +3 -3
- package/dist/build-pipe.js +5 -12
- package/dist/build-pipe.js.map +1 -1
- package/dist/build-pipeline-result-list.d.ts +2 -2
- package/dist/build-pipeline-result-list.js +1 -2
- package/dist/build-pipeline-result-list.js.map +1 -1
- package/dist/build-task.d.ts +1 -1
- package/dist/build.cmd.d.ts +1 -1
- package/dist/builder.composition.d.ts +2 -2
- package/dist/builder.graphql.d.ts +17 -17
- package/dist/builder.graphql.js +4 -8
- package/dist/builder.graphql.js.map +1 -1
- package/dist/builder.main.runtime.d.ts +5 -5
- package/dist/builder.main.runtime.js +11 -14
- package/dist/builder.main.runtime.js.map +1 -1
- package/dist/builder.route.d.ts +1 -1
- package/dist/builder.route.js +3 -3
- package/dist/builder.route.js.map +1 -1
- package/dist/builder.service.d.ts +9 -9
- package/dist/builder.service.js +4 -4
- package/dist/builder.service.js.map +1 -1
- package/dist/pipeline.d.ts +1 -1
- package/dist/{preview-1703590665075.js → preview-1703698405864.js} +2 -2
- package/dist/storage/storage-resolver.d.ts +2 -2
- package/dist/task-results-list.js +2 -8
- package/dist/task-results-list.js.map +1 -1
- package/dist/tasks-queue.d.ts +1 -1
- package/dist/types.d.ts +2 -2
- package/package.json +26 -33
- package/tsconfig.json +16 -21
- package/types/asset.d.ts +15 -3
|
@@ -0,0 +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={16039:(e,n,t)=>{var i={id:"teambit.pipelines/builder@1.0.109",homepage:"https://bit.cloud/teambit/pipelines/builder",exported:!0};function a(){const e=r(t(87363));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},99509:(e,n,t)=>{var i={id:"teambit.pipelines/aspect-docs/builder@0.0.165",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0};Object.defineProperty(n,"__esModule",{value:!0}),n.default=u,o(t(87363));var a=t(40040),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},77138:(e,n,t)=>{Object.defineProperty(n,"I",{enumerable:!0,get:function(){return i.default}});var i=a(t(99509));function a(e){return e&&e.__esModule?e:{default:e}}a.__bit_component={id:"teambit.pipelines/aspect-docs/builder@0.0.165",homepage:"https://bit.cloud/teambit/pipelines/aspect-docs/builder",exported:!0}},40040:e=>{e.exports=MdxJsReact},87363: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(16039),a=(t(87363),t(40040));const r=TeambitMdxUiMdxScopeContext;var o=t(77138),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.I},mdxType:"MDXScopeProvider"},(0,a.mdx)(o.I,{mdxType:"Builder"})))}m.isMDXComponent=!0;const u=[n],c=[e],h={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),i})()));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ArtifactStorageResolver } from '..';
|
|
2
|
-
export
|
|
2
|
+
export type ArtifactDefinition = {
|
|
3
3
|
/**
|
|
4
4
|
* name of the artifact.
|
|
5
5
|
* e.g. a project might utilize two different artifacts for the same typescript compiler, one
|
|
@@ -60,6 +60,6 @@ export declare type ArtifactDefinition = {
|
|
|
60
60
|
*/
|
|
61
61
|
storageResolver?: ArtifactStorageResolver;
|
|
62
62
|
};
|
|
63
|
-
export
|
|
63
|
+
export type ArtifactModelDefinition = Omit<ArtifactDefinition, 'storageResolver'> & {
|
|
64
64
|
storageResolver?: string;
|
|
65
65
|
};
|
|
@@ -2,17 +2,17 @@ import { ComponentMain } from '@teambit/component';
|
|
|
2
2
|
import { ComponentID } from '@teambit/component-id';
|
|
3
3
|
import { BuilderMain } from '../builder.main.runtime';
|
|
4
4
|
import { ArtifactsOpts } from './artifacts.cmd';
|
|
5
|
-
export
|
|
5
|
+
export type ExtractorResult = {
|
|
6
6
|
id: ComponentID;
|
|
7
7
|
artifacts: ExtractorArtifactResult[];
|
|
8
8
|
};
|
|
9
|
-
export
|
|
9
|
+
export type ExtractorArtifactResult = {
|
|
10
10
|
artifactName: string;
|
|
11
11
|
aspectId: string;
|
|
12
12
|
taskName: string;
|
|
13
13
|
files: string[];
|
|
14
14
|
};
|
|
15
|
-
export
|
|
15
|
+
export type ExtractorResultGrouped = {
|
|
16
16
|
id: ComponentID;
|
|
17
17
|
artifacts: {
|
|
18
18
|
[aspectId: string]: ExtractorArtifactResult[];
|
|
@@ -4,7 +4,7 @@ import { ArtifactList } from './artifact-list';
|
|
|
4
4
|
import type { BuildContext, BuildTask } from '../build-task';
|
|
5
5
|
import { FsArtifact } from './fs-artifact';
|
|
6
6
|
export declare const DEFAULT_CONTEXT = "component";
|
|
7
|
-
export
|
|
7
|
+
export type ArtifactMap = ComponentMap<ArtifactList<FsArtifact>>;
|
|
8
8
|
export declare class ArtifactFactory {
|
|
9
9
|
resolvePaths(root: string, def: ArtifactDefinition): string[];
|
|
10
10
|
private getArtifactContextPath;
|
|
@@ -80,8 +80,7 @@ class ArtifactFactory {
|
|
|
80
80
|
getArtifactContextPath(context, component, def) {
|
|
81
81
|
const artifactContext = this.getArtifactContext(def);
|
|
82
82
|
if (artifactContext === 'component') {
|
|
83
|
-
|
|
84
|
-
const capsulePath = (_context$capsuleNetwo = context.capsuleNetwork.graphCapsules.getCapsule(component.id)) === null || _context$capsuleNetwo === void 0 ? void 0 : _context$capsuleNetwo.path;
|
|
83
|
+
const capsulePath = context.capsuleNetwork.graphCapsules.getCapsule(component.id)?.path;
|
|
85
84
|
if (!capsulePath) throw new (_exceptions().CapsuleNotFound)(component.id);
|
|
86
85
|
return capsulePath;
|
|
87
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_path","data","require","_globby","_interopRequireDefault","_lodash","_artifactFiles","_component","_storage","_artifactList","_exceptions","_fsArtifact","obj","__esModule","default","DEFAULT_CONTEXT","exports","ArtifactFactory","resolvePaths","root","def","patternsFlattened","flatten","globPatterns","paths","globby","sync","cwd","getArtifactContextPath","context","component","artifactContext","getArtifactContext","
|
|
1
|
+
{"version":3,"names":["_path","data","require","_globby","_interopRequireDefault","_lodash","_artifactFiles","_component","_storage","_artifactList","_exceptions","_fsArtifact","obj","__esModule","default","DEFAULT_CONTEXT","exports","ArtifactFactory","resolvePaths","root","def","patternsFlattened","flatten","globPatterns","paths","globby","sync","cwd","getArtifactContextPath","context","component","artifactContext","getArtifactContext","capsulePath","capsuleNetwork","graphCapsules","getCapsule","id","path","CapsuleNotFound","capsulesRootDir","createFromComponent","task","contextPath","rootDir","getRootDir","length","undefined","FsArtifact","ArtifactFiles","getStorageResolver","storageResolver","DefaultResolver","toComponentMap","artifactMap","ComponentMap","as","components","toString","artifacts","filter","targetId","map","artifact","ArtifactList","fromArray","join","generate","defs","tupleArr","forEach","capsuleDir","push"],"sources":["artifact-factory.ts"],"sourcesContent":["import { join } from 'path';\nimport globby from 'globby';\nimport { flatten } from 'lodash';\nimport { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport { Component, ComponentMap } from '@teambit/component';\nimport { ArtifactDefinition } from './artifact-definition';\nimport { DefaultResolver } from '../storage';\nimport { ArtifactList } from './artifact-list';\nimport type { BuildContext, BuildTask } from '../build-task';\nimport { CapsuleNotFound } from '../exceptions';\nimport { FsArtifact } from './fs-artifact';\n\nexport const DEFAULT_CONTEXT = 'component';\n\nexport type ArtifactMap = ComponentMap<ArtifactList<FsArtifact>>;\n\nexport class ArtifactFactory {\n resolvePaths(root: string, def: ArtifactDefinition): string[] {\n const patternsFlattened = flatten(def.globPatterns);\n const paths = globby.sync(patternsFlattened, { cwd: root });\n return paths;\n }\n\n private getArtifactContextPath(context: BuildContext, component: Component, def: ArtifactDefinition) {\n const artifactContext = this.getArtifactContext(def);\n if (artifactContext === 'component') {\n const capsulePath = context.capsuleNetwork.graphCapsules.getCapsule(component.id)?.path;\n if (!capsulePath) throw new CapsuleNotFound(component.id);\n return capsulePath;\n }\n\n return context.capsuleNetwork.capsulesRootDir;\n }\n\n private getArtifactContext(def: ArtifactDefinition) {\n return def.context || DEFAULT_CONTEXT;\n }\n\n createFromComponent(\n context: BuildContext,\n component: Component,\n def: ArtifactDefinition,\n task: BuildTask\n ): FsArtifact | undefined {\n const contextPath = this.getArtifactContextPath(context, component, def);\n const rootDir = this.getRootDir(contextPath, def);\n const paths = this.resolvePaths(rootDir, def);\n if (!paths || !paths.length) {\n return undefined;\n }\n return new FsArtifact(def, new ArtifactFiles(paths), task, rootDir);\n }\n\n private getStorageResolver(def: ArtifactDefinition) {\n return def.storageResolver || new DefaultResolver();\n }\n\n private toComponentMap(context: BuildContext, artifactMap: [string, FsArtifact][]) {\n return ComponentMap.as<ArtifactList<FsArtifact>>(context.components, (component) => {\n const id = component.id.toString();\n const artifacts = artifactMap.filter(([targetId]) => targetId === id).map(([, artifact]) => artifact);\n\n return ArtifactList.fromArray(artifacts);\n });\n }\n\n getRootDir(rootDir: string, def: ArtifactDefinition) {\n if (!def.rootDir) return rootDir;\n return join(rootDir, def.rootDir);\n }\n\n /**\n * generate artifacts from a build context according to the spec defined in the artifact definitions.\n */\n generate(context: BuildContext, defs: ArtifactDefinition[], task: BuildTask): ComponentMap<ArtifactList<FsArtifact>> {\n const tupleArr: [string, FsArtifact][] = [];\n\n defs.forEach((def) => {\n const artifactContext = this.getArtifactContext(def);\n if (artifactContext === 'env') {\n const capsuleDir = context.capsuleNetwork.capsulesRootDir;\n const rootDir = this.getRootDir(capsuleDir, def);\n const paths = this.resolvePaths(rootDir, def);\n if (paths && paths.length) {\n const artifact = new FsArtifact(def, new ArtifactFiles(this.resolvePaths(rootDir, def)), task, rootDir);\n\n return context.components.forEach((component) => {\n tupleArr.push([component.id.toString(), artifact]);\n });\n }\n }\n\n return context.components.forEach((component) => {\n const artifact = this.createFromComponent(context, component, def, task);\n if (artifact) {\n tupleArr.push([component.id.toString(), artifact]);\n }\n });\n });\n\n return this.toComponentMap(context, tupleArr);\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,QAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,OAAA,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;EAA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K;YAC/CuC,QAAQ,CAACG,IAAI,CAAC,CAAC1C,SAAS,CAACO,EAAE,CAACqB,QAAQ,CAAC,CAAC,EAAEK,QAAQ,CAAC,CAAC;UACpD,CAAC,CAAC;QACJ;MACF;MAEA,OAAOlC,OAAO,CAAC4B,UAAU,CAACa,OAAO,CAAExC,SAAS,IAAK;QAC/C,MAAMiC,QAAQ,GAAG,IAAI,CAACtB,mBAAmB,CAACZ,OAAO,EAAEC,SAAS,EAAEV,GAAG,EAAEsB,IAAI,CAAC;QACxE,IAAIqB,QAAQ,EAAE;UACZM,QAAQ,CAACG,IAAI,CAAC,CAAC1C,SAAS,CAACO,EAAE,CAACqB,QAAQ,CAAC,CAAC,EAAEK,QAAQ,CAAC,CAAC;QACpD;MACF,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,IAAI,CAACV,cAAc,CAACxB,OAAO,EAAEwC,QAAQ,CAAC;EAC/C;AACF;AAACrD,OAAA,CAAAC,eAAA,GAAAA,eAAA"}
|
|
@@ -4,7 +4,7 @@ import { ComponentID } from '@teambit/component-id';
|
|
|
4
4
|
import { Scope } from '@teambit/legacy/dist/scope';
|
|
5
5
|
import { ArtifactVinyl } from '@teambit/legacy/dist/consumer/component/sources/artifact';
|
|
6
6
|
import { Artifact } from './artifact';
|
|
7
|
-
export
|
|
7
|
+
export type ResolverMap<T extends Artifact> = {
|
|
8
8
|
[key: string]: T[];
|
|
9
9
|
};
|
|
10
10
|
export declare class ArtifactList<T extends Artifact> extends Array<T> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
2
|
import { ComponentMain } from '@teambit/component';
|
|
3
3
|
import { BuilderMain } from '../builder.main.runtime';
|
|
4
|
-
export
|
|
4
|
+
export type ArtifactsOpts = {
|
|
5
5
|
aspect?: string;
|
|
6
6
|
task?: string;
|
|
7
7
|
files?: string;
|
package/dist/build-pipe.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { ComponentResult } from './types';
|
|
|
7
7
|
import { TasksQueue } from './tasks-queue';
|
|
8
8
|
import { EnvsBuildContext } from './builder.service';
|
|
9
9
|
import { TaskResultsList } from './task-results-list';
|
|
10
|
-
export
|
|
10
|
+
export type TaskResults = {
|
|
11
11
|
/**
|
|
12
12
|
* task itself. useful for getting its id/description later on.
|
|
13
13
|
*/
|
|
@@ -34,7 +34,7 @@ export declare type TaskResults = {
|
|
|
34
34
|
*/
|
|
35
35
|
endTime: number;
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
type PipeOptions = {
|
|
38
38
|
exitOnFirstFailedTask?: boolean;
|
|
39
39
|
showEnvNameInOutput?: boolean;
|
|
40
40
|
showEnvVersionInOutput?: boolean;
|
|
@@ -57,7 +57,7 @@ export declare class BuildPipe {
|
|
|
57
57
|
/**
|
|
58
58
|
* array of services to apply on the components.
|
|
59
59
|
*/
|
|
60
|
-
tasksQueue: TasksQueue, envsBuildContext: EnvsBuildContext, logger: Logger, artifactFactory: ArtifactFactory, previousTaskResults?: TaskResults[]
|
|
60
|
+
tasksQueue: TasksQueue, envsBuildContext: EnvsBuildContext, logger: Logger, artifactFactory: ArtifactFactory, previousTaskResults?: TaskResults[], options?: PipeOptions);
|
|
61
61
|
get allTasksResults(): TaskResults[];
|
|
62
62
|
/**
|
|
63
63
|
* execute a pipeline of build tasks.
|
package/dist/build-pipe.js
CHANGED
|
@@ -82,7 +82,6 @@ class BuildPipe {
|
|
|
82
82
|
* execute a pipeline of build tasks.
|
|
83
83
|
*/
|
|
84
84
|
async execute() {
|
|
85
|
-
var _Object$values$;
|
|
86
85
|
this.addSignalListener();
|
|
87
86
|
await this.executePreBuild();
|
|
88
87
|
this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);
|
|
@@ -91,7 +90,7 @@ class BuildPipe {
|
|
|
91
90
|
env
|
|
92
91
|
}) => this.executeTask(task, env));
|
|
93
92
|
this.longProcessLogger.end();
|
|
94
|
-
const capsuleRootDir =
|
|
93
|
+
const capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;
|
|
95
94
|
const tasksResultsList = new (_taskResultsList().TaskResultsList)(this.tasksQueue, this.taskResults, capsuleRootDir);
|
|
96
95
|
await this.executePostBuild(tasksResultsList);
|
|
97
96
|
return tasksResultsList;
|
|
@@ -121,9 +120,8 @@ class BuildPipe {
|
|
|
121
120
|
longProcessLogger.end();
|
|
122
121
|
}
|
|
123
122
|
async executeTask(task, env) {
|
|
124
|
-
var _this$options;
|
|
125
123
|
const taskId = _buildTask().BuildTaskHelper.serializeId(task);
|
|
126
|
-
const envName =
|
|
124
|
+
const envName = this.options?.showEnvNameInOutput ? `(${this.getPrettyEnvName(env.id)}) ` : '';
|
|
127
125
|
const taskLogPrefix = `${envName}[${this.getPrettyAspectName(task.aspectId)}: ${task.name}]`;
|
|
128
126
|
this.longProcessLogger.logProgress(`${taskLogPrefix}${task.description ? ` ${task.description}` : ''}`, false);
|
|
129
127
|
this.updateFailedDependencyTask(task);
|
|
@@ -141,10 +139,7 @@ class BuildPipe {
|
|
|
141
139
|
throw err;
|
|
142
140
|
}
|
|
143
141
|
const endTime = Date.now();
|
|
144
|
-
const compsWithErrors = buildTaskResult.componentsResults.filter(c =>
|
|
145
|
-
var _c$errors;
|
|
146
|
-
return (_c$errors = c.errors) === null || _c$errors === void 0 ? void 0 : _c$errors.length;
|
|
147
|
-
});
|
|
142
|
+
const compsWithErrors = buildTaskResult.componentsResults.filter(c => c.errors?.length);
|
|
148
143
|
let artifacts;
|
|
149
144
|
const duration = (0, _prettyTime().default)(process.hrtime(startTask));
|
|
150
145
|
if (compsWithErrors.length) {
|
|
@@ -172,9 +167,8 @@ class BuildPipe {
|
|
|
172
167
|
return tokens.join(' ');
|
|
173
168
|
}
|
|
174
169
|
getPrettyEnvName(envId) {
|
|
175
|
-
var _this$options2;
|
|
176
170
|
const resolvedId = _component().ComponentID.fromString(envId);
|
|
177
|
-
const ver =
|
|
171
|
+
const ver = this.options?.showEnvVersionInOutput ? `@${resolvedId.version}` : '';
|
|
178
172
|
return `${resolvedId.fullName}${ver}`;
|
|
179
173
|
}
|
|
180
174
|
async executePostBuild(tasksResults) {
|
|
@@ -204,8 +198,7 @@ class BuildPipe {
|
|
|
204
198
|
}
|
|
205
199
|
}
|
|
206
200
|
shouldSkipTask(taskId, envId) {
|
|
207
|
-
|
|
208
|
-
if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.exitOnFirstFailedTask && this.failedTasks.length) {
|
|
201
|
+
if (this.options?.exitOnFirstFailedTask && this.failedTasks.length) {
|
|
209
202
|
const failedTaskId = _buildTask().BuildTaskHelper.serializeId(this.failedTasks[0]);
|
|
210
203
|
this.logger.consoleWarning(`env: ${envId}, task "${taskId}" has skipped due to "${failedTaskId}" failure`);
|
|
211
204
|
return true;
|
package/dist/build-pipe.js.map
CHANGED
|
@@ -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","String","r","e","Symbol","toPrimitive","call","TypeError","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","_Object$values$","addSignalListener","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","capsuleRootDir","values","capsuleNetwork","capsulesRootDir","tasksResultsList","TaskResultsList","executePostBuild","process","on","exit","setStatusLine","preBuild","getBuildContext","id","_this$options","taskId","BuildTaskHelper","serializeId","envName","showEnvNameInOutput","getPrettyEnvName","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","startTask","hrtime","taskStartTime","Date","now","buildContext","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","_c$errors","errors","artifacts","duration","prettyTime","chalk","red","getProgress","failedTasks","push","consoleSuccess","green","defs","generate","startTime","resolvedId","ComponentID","fromString","tokens","split","map","token","capitalize","join","envId","_this$options2","ver","showEnvVersionInOutput","version","fullName","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","deserializeIdAllowEmptyName","find","failedTask","_this$options3","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 this.addSignalListener();\n await this.executePreBuild();\n this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);\n await mapSeries(this.tasksQueue, async ({ task, env }) => this.executeTask(task, env));\n this.longProcessLogger.end();\n const 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 /**\n * for some reason, some tasks (such as typescript compilation) ignore ctrl+C. this fixes it.\n */\n private addSignalListener() {\n process.on('SIGTERM', () => {\n process.exit();\n });\n\n process.on('SIGINT', () => {\n process.exit();\n });\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n 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 taskLogPrefix = `${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 const buildContext = this.getBuildContext(env.id);\n let buildTaskResult: BuiltTaskResult;\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n 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 this.logger.consoleSuccess(\n chalk.green(`${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,IAA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YAAY,CAACqD,oBAAoB,GAAG,IAAI,CAACrG,eAAe;IACxD,OAAOgD,YAAY;EACrB;AACF;AAACsD,OAAA,CAAA9G,SAAA,GAAAA,SAAA"}
|
|
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","String","r","e","Symbol","toPrimitive","call","TypeError","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","addSignalListener","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","capsuleRootDir","values","capsuleNetwork","capsulesRootDir","tasksResultsList","TaskResultsList","executePostBuild","process","on","exit","setStatusLine","preBuild","getBuildContext","id","taskId","BuildTaskHelper","serializeId","envName","showEnvNameInOutput","getPrettyEnvName","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","startTask","hrtime","taskStartTime","Date","now","buildContext","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","errors","artifacts","duration","prettyTime","chalk","red","getProgress","failedTasks","push","consoleSuccess","green","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 this.addSignalListener();\n await this.executePreBuild();\n this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);\n await mapSeries(this.tasksQueue, async ({ task, env }) => this.executeTask(task, env));\n this.longProcessLogger.end();\n const 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 /**\n * for some reason, some tasks (such as typescript compilation) ignore ctrl+C. this fixes it.\n */\n private addSignalListener() {\n process.on('SIGTERM', () => {\n process.exit();\n });\n\n process.on('SIGINT', () => {\n process.exit();\n });\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n 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 taskLogPrefix = `${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 const buildContext = this.getBuildContext(env.id);\n let buildTaskResult: BuiltTaskResult;\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n 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 this.logger.consoleSuccess(\n chalk.green(`${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,K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AAE,OAAO,KAAK;IAC5C,MAAMQ,YAAY,GAAGjE,4BAAe,CAACC,WAAW,CAAC,IAAI,CAACwD,oBAAoB,CAAC;IAC3E,IAAI,CAACzF,MAAM,CAACkG,cAAc,CAAE,QAAOhB,KAAM,WAAUnD,MAAO,yBAAwBkE,YAAa,WAAU,CAAC;IAC1G,OAAO,IAAI;EACb;EAEQpE,eAAeA,CAACqD,KAAa,EAAgB;IACnD,MAAMhC,YAAY,GAAG,IAAI,CAACnD,gBAAgB,CAACmF,KAAK,CAAC;IACjD,IAAI,CAAChC,YAAY,EAAE,MAAM,IAAIiD,KAAK,CAAE,mCAAkCjB,KAAM,EAAC,CAAC;IAC9EhC,YAAY,CAACkD,oBAAoB,GAAG,IAAI,CAAChG,eAAe;IACxD,OAAO8C,YAAY;EACrB;AACF;AAACmD,OAAA,CAAAzG,SAAA,GAAAA,SAAA"}
|
|
@@ -2,7 +2,7 @@ import { ComponentID, Component } from '@teambit/component';
|
|
|
2
2
|
import type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
|
|
3
3
|
import { TaskResults } from './build-pipe';
|
|
4
4
|
import { TaskMetadata } from './types';
|
|
5
|
-
export
|
|
5
|
+
export type PipelineReport = {
|
|
6
6
|
taskId: string;
|
|
7
7
|
taskName: string;
|
|
8
8
|
taskDescription?: string;
|
|
@@ -11,7 +11,7 @@ export declare type PipelineReport = {
|
|
|
11
11
|
errors?: Array<Error | string>;
|
|
12
12
|
warnings?: string[];
|
|
13
13
|
};
|
|
14
|
-
export
|
|
14
|
+
export type AspectData = {
|
|
15
15
|
aspectId: string;
|
|
16
16
|
data: TaskMetadata;
|
|
17
17
|
};
|
|
@@ -87,8 +87,7 @@ class BuildPipelineResultList {
|
|
|
87
87
|
}));
|
|
88
88
|
}
|
|
89
89
|
getArtifactsDataOfComponent(componentId) {
|
|
90
|
-
|
|
91
|
-
return (_this$artifactListsMa = this.artifactListsMap.getValueByComponentId(componentId)) === null || _this$artifactListsMa === void 0 ? void 0 : _this$artifactListsMa.toObject();
|
|
90
|
+
return this.artifactListsMap.getValueByComponentId(componentId)?.toObject();
|
|
92
91
|
}
|
|
93
92
|
mergeDataIfPossible(currentData, existingData, taskId) {
|
|
94
93
|
if (!existingData || (0, _lodash().isEmpty)(existingData)) return currentData;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_component","data","require","_lodash","_artifact","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","BuildPipelineResultList","constructor","tasksResults","components","artifactListsMap","getFlattenedArtifactListsMapFromAllTasks","artifactListsMaps","flatMap","artifacts","ComponentMap","as","component","artifactListMap","artifactList","getValueByComponentId","id","ArtifactList","fromArray","getMetadataFromTaskResults","componentId","compResults","reduce","acc","current","foundComponent","componentsResults","find","c","isEqual","taskId","task","aspectId","metadata","mergeDataIfPossible","getPipelineReportOfComponent","map","taskResults","pipelineReport","taskName","name","taskDescription","description","errors","warnings","startTime","endTime","compact","getDataOfComponent","tasksData","getArtifactsDataOfComponent","
|
|
1
|
+
{"version":3,"names":["_component","data","require","_lodash","_artifact","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","obj","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","BuildPipelineResultList","constructor","tasksResults","components","artifactListsMap","getFlattenedArtifactListsMapFromAllTasks","artifactListsMaps","flatMap","artifacts","ComponentMap","as","component","artifactListMap","artifactList","getValueByComponentId","id","ArtifactList","fromArray","getMetadataFromTaskResults","componentId","compResults","reduce","acc","current","foundComponent","componentsResults","find","c","isEqual","taskId","task","aspectId","metadata","mergeDataIfPossible","getPipelineReportOfComponent","map","taskResults","pipelineReport","taskName","name","taskDescription","description","errors","warnings","startTime","endTime","compact","getDataOfComponent","tasksData","getArtifactsDataOfComponent","toObject","currentData","existingData","isEmpty","Error","Array","isArray","exports"],"sources":["build-pipeline-result-list.ts"],"sourcesContent":["import { ComponentID, ComponentMap, Component } from '@teambit/component';\nimport { isEmpty, compact } from 'lodash';\nimport type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport { Artifact, ArtifactList } from './artifact';\nimport { TaskResults } from './build-pipe';\nimport { TaskMetadata } from './types';\n\nexport type PipelineReport = {\n taskId: string; // task aspect-id\n taskName: string;\n taskDescription?: string;\n startTime?: number;\n endTime?: number;\n errors?: Array<Error | string>;\n warnings?: string[];\n};\n\nexport type AspectData = {\n aspectId: string;\n data: TaskMetadata;\n};\n\n/**\n * Helper to get the data and artifacts from the TasksResultsList before saving during the tag\n */\nexport class BuildPipelineResultList {\n private artifactListsMap: ComponentMap<ArtifactList<Artifact>>;\n constructor(private tasksResults: TaskResults[], private components: Component[]) {\n this.artifactListsMap = this.getFlattenedArtifactListsMapFromAllTasks();\n }\n\n private getFlattenedArtifactListsMapFromAllTasks(): ComponentMap<ArtifactList<Artifact>> {\n const artifactListsMaps = this.tasksResults.flatMap((t) => (t.artifacts ? [t.artifacts] : []));\n return ComponentMap.as<ArtifactList<Artifact>>(this.components, (component) => {\n const artifacts: Artifact[] = [];\n artifactListsMaps.forEach((artifactListMap) => {\n const artifactList = artifactListMap.getValueByComponentId(component.id);\n if (artifactList) artifacts.push(...artifactList);\n });\n return ArtifactList.fromArray(artifacts);\n });\n }\n\n public getMetadataFromTaskResults(componentId: ComponentID): { [taskId: string]: TaskMetadata } {\n const compResults = this.tasksResults.reduce((acc, current: TaskResults) => {\n const foundComponent = current.componentsResults.find((c) => c.component.id.isEqual(componentId));\n const taskId = current.task.aspectId;\n if (foundComponent && foundComponent.metadata) {\n acc[taskId] = this.mergeDataIfPossible(foundComponent.metadata, acc[taskId], taskId);\n }\n return acc;\n }, {});\n return compResults;\n }\n\n public getPipelineReportOfComponent(componentId: ComponentID): PipelineReport[] {\n const compResults = this.tasksResults.map((taskResults: TaskResults) => {\n const foundComponent = taskResults.componentsResults.find((c) => c.component.id.isEqual(componentId));\n if (!foundComponent) return null;\n const pipelineReport: PipelineReport = {\n taskId: taskResults.task.aspectId,\n taskName: taskResults.task.name,\n taskDescription: taskResults.task.description,\n errors: foundComponent.errors,\n warnings: foundComponent.warnings,\n startTime: foundComponent.startTime,\n endTime: foundComponent.endTime,\n };\n return pipelineReport;\n });\n return compact(compResults);\n }\n\n public getDataOfComponent(componentId: ComponentID): AspectData[] {\n const tasksData = this.getMetadataFromTaskResults(componentId);\n return Object.keys(tasksData).map((taskId) => ({\n aspectId: taskId,\n data: tasksData[taskId],\n }));\n }\n\n public getArtifactsDataOfComponent(componentId: ComponentID): ArtifactObject[] | undefined {\n return this.artifactListsMap.getValueByComponentId(componentId)?.toObject();\n }\n\n private mergeDataIfPossible(currentData: TaskMetadata, existingData: TaskMetadata | undefined, taskId: string) {\n if (!existingData || isEmpty(existingData)) return currentData;\n // both exist\n if (typeof currentData !== 'object') {\n throw new Error(`task data must be \"object\", get ${typeof currentData} for ${taskId}`);\n }\n if (Array.isArray(currentData)) {\n throw new Error(`task data must be \"object\", get Array for ${taskId}`);\n }\n return { ...currentData, ...existingData };\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,UAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAA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KC,YAAY;EAC1C;AACF;AAACK,OAAA,CAAAzD,uBAAA,GAAAA,uBAAA"}
|
package/dist/build-task.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { ArtifactDefinition } from './artifact';
|
|
|
7
7
|
import { TaskResultsList } from './task-results-list';
|
|
8
8
|
import { TaskResults } from './build-pipe';
|
|
9
9
|
import { PipeName } from './builder.service';
|
|
10
|
-
export
|
|
10
|
+
export type TaskLocation = 'start' | 'end';
|
|
11
11
|
/**
|
|
12
12
|
* delimiter between task.aspectId and task.name
|
|
13
13
|
*/
|
package/dist/build.cmd.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Command, CommandOptions } from '@teambit/cli';
|
|
|
2
2
|
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
6
|
all: boolean;
|
|
7
7
|
unmodified?: boolean;
|
|
8
8
|
dev: boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const Logo: () =>
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const Logo: () => JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { Component, ComponentID } from '@teambit/component';
|
|
|
2
2
|
import { Logger } from '@teambit/logger';
|
|
3
3
|
import { BuilderMain } from './builder.main.runtime';
|
|
4
4
|
import { PipelineReport } from './build-pipeline-result-list';
|
|
5
|
-
|
|
5
|
+
type ArtifactGQLFile = {
|
|
6
6
|
/**
|
|
7
7
|
* same as the path - used for GQL caching
|
|
8
8
|
*/
|
|
@@ -32,14 +32,14 @@ declare type ArtifactGQLFile = {
|
|
|
32
32
|
*/
|
|
33
33
|
size: number;
|
|
34
34
|
};
|
|
35
|
-
|
|
35
|
+
type ArtifactGQLData = {
|
|
36
36
|
name: string;
|
|
37
37
|
description?: string;
|
|
38
38
|
storage?: string;
|
|
39
39
|
generatedBy: string;
|
|
40
40
|
files: ArtifactGQLFile[];
|
|
41
41
|
};
|
|
42
|
-
|
|
42
|
+
type TaskReport = PipelineReport & {
|
|
43
43
|
artifact?: ArtifactGQLData;
|
|
44
44
|
componentId: ComponentID;
|
|
45
45
|
};
|
|
@@ -48,13 +48,13 @@ export declare function builderSchema(builder: BuilderMain, logger: Logger): {
|
|
|
48
48
|
resolvers: {
|
|
49
49
|
Component: {
|
|
50
50
|
pipelineReport: (component: Component, { taskId }: {
|
|
51
|
-
taskId?: string
|
|
51
|
+
taskId?: string;
|
|
52
52
|
}) => Promise<{
|
|
53
53
|
id: string;
|
|
54
54
|
artifact: {
|
|
55
55
|
id: string;
|
|
56
56
|
name: string;
|
|
57
|
-
description: string
|
|
57
|
+
description: string;
|
|
58
58
|
task: import("./build-task").TaskDescriptor;
|
|
59
59
|
storage: string;
|
|
60
60
|
generatedBy: string;
|
|
@@ -62,26 +62,26 @@ export declare function builderSchema(builder: BuilderMain, logger: Logger): {
|
|
|
62
62
|
id: string;
|
|
63
63
|
name: string;
|
|
64
64
|
path: string;
|
|
65
|
-
content: string
|
|
65
|
+
content: string;
|
|
66
66
|
downloadUrl: string;
|
|
67
|
-
externalUrl: string
|
|
67
|
+
externalUrl: string;
|
|
68
68
|
size: number;
|
|
69
69
|
}[];
|
|
70
|
-
}
|
|
70
|
+
};
|
|
71
71
|
taskId: string;
|
|
72
72
|
taskName: string;
|
|
73
|
-
taskDescription?: string
|
|
74
|
-
startTime?: number
|
|
75
|
-
endTime?: number
|
|
76
|
-
errors?: (string | Error)[]
|
|
77
|
-
warnings?: string[]
|
|
73
|
+
taskDescription?: string;
|
|
74
|
+
startTime?: number;
|
|
75
|
+
endTime?: number;
|
|
76
|
+
errors?: (string | Error)[];
|
|
77
|
+
warnings?: string[];
|
|
78
78
|
}[]>;
|
|
79
79
|
};
|
|
80
80
|
TaskReport: {
|
|
81
81
|
id: (taskReport: TaskReport & {
|
|
82
82
|
id?: string;
|
|
83
83
|
}) => string;
|
|
84
|
-
description: (taskReport: TaskReport) => string
|
|
84
|
+
description: (taskReport: TaskReport) => string;
|
|
85
85
|
errors: (taskReport: TaskReport) => string[];
|
|
86
86
|
warnings: (taskReport: TaskReport) => string[];
|
|
87
87
|
artifact: (taskReport: TaskReport, { path: pathFilter }: {
|
|
@@ -89,11 +89,11 @@ export declare function builderSchema(builder: BuilderMain, logger: Logger): {
|
|
|
89
89
|
}) => Promise<{
|
|
90
90
|
files: ArtifactGQLFile[];
|
|
91
91
|
name: string;
|
|
92
|
-
description?: string
|
|
93
|
-
storage?: string
|
|
92
|
+
description?: string;
|
|
93
|
+
storage?: string;
|
|
94
94
|
generatedBy: string;
|
|
95
95
|
id: string;
|
|
96
|
-
}
|
|
96
|
+
}>;
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
};
|