@teambit/builder 1.0.227 → 1.0.229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/artifacts/__bit_junit.xml +1 -1
  2. package/artifacts/preview/teambit_pipelines_builder-preview.js +1 -1
  3. package/artifacts/schema.json +708 -182
  4. package/dist/artifact/artifact-definition.d.ts +65 -0
  5. package/dist/artifact/artifact-extractor.d.ts +35 -0
  6. package/dist/artifact/artifact-factory.d.ts +20 -0
  7. package/dist/artifact/artifact-list.d.ts +52 -0
  8. package/dist/artifact/artifact.d.ts +59 -0
  9. package/dist/artifact/artifacts.cmd.d.ts +26 -0
  10. package/dist/artifact/extension-artifact.d.ts +10 -0
  11. package/dist/artifact/fs-artifact.d.ts +18 -0
  12. package/dist/artifact/index.d.ts +6 -0
  13. package/dist/build-pipe.d.ts +75 -0
  14. package/dist/build-pipe.js +0 -13
  15. package/dist/build-pipe.js.map +1 -1
  16. package/dist/build-pipeline-order.d.ts +35 -0
  17. package/dist/build-pipeline-result-list.d.ts +34 -0
  18. package/dist/build-task.d.ts +128 -0
  19. package/dist/build.cmd.d.ts +39 -0
  20. package/dist/builder-env-type.d.ts +15 -0
  21. package/dist/builder.aspect.d.ts +2 -0
  22. package/dist/builder.composition.d.ts +1 -0
  23. package/dist/builder.graphql.d.ts +102 -0
  24. package/dist/builder.main.runtime.d.ts +153 -0
  25. package/dist/builder.route.d.ts +20 -0
  26. package/dist/builder.service.d.ts +105 -0
  27. package/dist/exceptions/artifact-definition-no-glob.d.ts +3 -0
  28. package/dist/exceptions/artifact-storage-error.d.ts +7 -0
  29. package/dist/exceptions/capsule-not-found.d.ts +5 -0
  30. package/dist/exceptions/index.d.ts +3 -0
  31. package/dist/exceptions/invalid-task.d.ts +5 -0
  32. package/dist/index.d.ts +19 -0
  33. package/dist/pipeline/index.d.ts +1 -0
  34. package/dist/pipeline/pipeline-results.d.ts +2 -0
  35. package/dist/pipeline.d.ts +43 -0
  36. package/dist/{preview-1712719054377.js → preview-1712822929999.js} +2 -2
  37. package/dist/storage/default-resolver.d.ts +7 -0
  38. package/dist/storage/index.d.ts +2 -0
  39. package/dist/storage/s3-resolver.d.ts +0 -0
  40. package/dist/storage/storage-resolver.d.ts +26 -0
  41. package/dist/task-results-list.d.ts +22 -0
  42. package/dist/task.d.ts +44 -0
  43. package/dist/tasks-queue.d.ts +16 -0
  44. package/dist/templates/build-task/files/index-file.d.ts +2 -0
  45. package/dist/templates/build-task/files/task-file.d.ts +2 -0
  46. package/dist/templates/build-task/index.d.ts +2 -0
  47. package/dist/types.d.ts +32 -0
  48. package/package.json +18 -18
  49. package/tsconfig.json +1 -49
@@ -0,0 +1,65 @@
1
+ import { ArtifactStorageResolver } from '..';
2
+ export type ArtifactDefinition = {
3
+ /**
4
+ * name of the artifact.
5
+ * e.g. a project might utilize two different artifacts for the same typescript compiler, one
6
+ * that generates ES5 files and another for ES6, this prop helps to distinguish between the two.
7
+ */
8
+ name: string;
9
+ /**
10
+ * aspect id that created the artifact. sometimes it's not the same as the task.id.
11
+ * e.g. teambit.compilation/compiler executes teambit.typescript/typescript code that generates dists artifacts
12
+ * the generatedBy in this case is the teambit.typescript/typescript while the task.id is
13
+ * teambit.compilation/compiler
14
+ */
15
+ generatedBy?: string;
16
+ /**
17
+ * description of the artifact.
18
+ */
19
+ description?: string;
20
+ /**
21
+ * glob patterns of files to include upon artifact creation.
22
+ * examples:
23
+ * ['*.ts', '!foo.ts'] - matches all ts files but ignores foo.ts.
24
+ * ['dist'] - matches all files recursively from dist dir. (similar to 'dist/**').
25
+ *
26
+ * the glob array are passed to [globby](https://www.npmjs.com/package/globby), which interprets the patterns
27
+ * according to [minimatch](https://github.com/isaacs/minimatch#usage).
28
+ */
29
+ globPatterns?: string[];
30
+ /**
31
+ * @deprecated use globPatterns instead.
32
+ *
33
+ * directories of files to include upon artifact creation. minimatch is used to match the patterns.
34
+ * e.g. ['/tmp'] will include all files from tmp dir
35
+ */
36
+ directories?: string[];
37
+ /**
38
+ * @deprecated use globPatterns instead.
39
+ *
40
+ * define the root directory for reading the artifacts from the capsule file system.
41
+ * the rootDir must be unique per artifacts, otherwise we risk overriding data between artifacts.
42
+ */
43
+ rootDir?: string;
44
+ /**
45
+ * @deprecated use globPatterns instead.
46
+ *
47
+ * adds a directory prefix for all artifact files.
48
+ */
49
+ dirPrefix?: string;
50
+ /**
51
+ * determine the context of the artifact.
52
+ * default artifact context is `component`.
53
+ * "env" is useful when the same file is generated for all components, for example, "preview"
54
+ * task may create the same webpack file for all components of that env.
55
+ */
56
+ context?: 'component' | 'env';
57
+ /**
58
+ * storage resolver. can be used to replace where artifacts are stored.
59
+ * default resolver persists artifacts on scope. (not recommended for large files!)
60
+ */
61
+ storageResolver?: ArtifactStorageResolver;
62
+ };
63
+ export type ArtifactModelDefinition = Omit<ArtifactDefinition, 'storageResolver'> & {
64
+ storageResolver?: string;
65
+ };
@@ -0,0 +1,35 @@
1
+ import { ComponentMain } from '@teambit/component';
2
+ import { ComponentID } from '@teambit/component-id';
3
+ import { BuilderMain } from '../builder.main.runtime';
4
+ import { ArtifactsOpts } from './artifacts.cmd';
5
+ export type ExtractorResult = {
6
+ id: ComponentID;
7
+ artifacts: ExtractorArtifactResult[];
8
+ };
9
+ export type ExtractorArtifactResult = {
10
+ artifactName: string;
11
+ aspectId: string;
12
+ taskName: string;
13
+ files: string[];
14
+ };
15
+ export type ExtractorResultGrouped = {
16
+ id: ComponentID;
17
+ artifacts: {
18
+ [aspectId: string]: ExtractorArtifactResult[];
19
+ };
20
+ };
21
+ export declare class ArtifactExtractor {
22
+ private componentMain;
23
+ private builder;
24
+ private pattern;
25
+ private options;
26
+ constructor(componentMain: ComponentMain, builder: BuilderMain, pattern: string, options: ArtifactsOpts);
27
+ list(): Promise<ExtractorResult[]>;
28
+ groupResultsByAspect(extractorResult: ExtractorResult[]): {
29
+ id: ComponentID;
30
+ artifacts: {};
31
+ }[];
32
+ private saveFilesInFileSystemIfAsked;
33
+ private artifactsObjectsToExtractorResults;
34
+ private filterByOptions;
35
+ }
@@ -0,0 +1,20 @@
1
+ import { Component, ComponentMap } from '@teambit/component';
2
+ import { ArtifactDefinition } from './artifact-definition';
3
+ import { ArtifactList } from './artifact-list';
4
+ import type { BuildContext, BuildTask } from '../build-task';
5
+ import { FsArtifact } from './fs-artifact';
6
+ export declare const DEFAULT_CONTEXT = "component";
7
+ export type ArtifactMap = ComponentMap<ArtifactList<FsArtifact>>;
8
+ export declare class ArtifactFactory {
9
+ resolvePaths(root: string, def: ArtifactDefinition): string[];
10
+ private getArtifactContextPath;
11
+ private getArtifactContext;
12
+ createFromComponent(context: BuildContext, component: Component, def: ArtifactDefinition, task: BuildTask): FsArtifact | undefined;
13
+ private getStorageResolver;
14
+ private toComponentMap;
15
+ getRootDir(rootDir: string, def: ArtifactDefinition): string;
16
+ /**
17
+ * generate artifacts from a build context according to the spec defined in the artifact definitions.
18
+ */
19
+ generate(context: BuildContext, defs: ArtifactDefinition[], task: BuildTask): ComponentMap<ArtifactList<FsArtifact>>;
20
+ }
@@ -0,0 +1,52 @@
1
+ import { Component } from '@teambit/component';
2
+ import type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
3
+ import { ComponentID } from '@teambit/component-id';
4
+ import { Scope } from '@teambit/legacy/dist/scope';
5
+ import { ArtifactVinyl } from '@teambit/legacy/dist/consumer/component/sources/artifact';
6
+ import { Artifact } from './artifact';
7
+ export type ResolverMap<T extends Artifact> = {
8
+ [key: string]: T[];
9
+ };
10
+ export declare class ArtifactList<T extends Artifact> extends Array<T> {
11
+ byAspectNameAndName(aspectName?: string, name?: string): ArtifactList<T>;
12
+ byAspectNameAndTaskName(aspectName?: string, name?: string): ArtifactList<T>;
13
+ /**
14
+ * find by the artifact name. it's possible to have multiple artifacts with the same name, in which case it returns the first.
15
+ */
16
+ findByName(name: string): Artifact | undefined;
17
+ /**
18
+ * find by the task name. it's possible to have multiple tasks with the same name (different aspects), in which case it returns the first.
19
+ */
20
+ findByTaskName(name: string): Artifact | undefined;
21
+ isEmpty(): boolean;
22
+ /**
23
+ * group artifacts by the storage resolver.
24
+ */
25
+ groupByResolver(): ResolverMap<T>;
26
+ toObject(): ArtifactObject[];
27
+ groupByTaskId(): {
28
+ [key: string]: T;
29
+ };
30
+ getVinylsAndImportIfMissing(id: ComponentID, scope: Scope): Promise<ArtifactVinyl[]>;
31
+ /**
32
+ * store all artifacts using the configured storage resolvers.
33
+ */
34
+ store(component: Component): Promise<void[]>;
35
+ private storeArtifact;
36
+ /**
37
+ * Send the entire artifact to the resolver then get back the result for all files from the resolver
38
+ * @param storageResolver
39
+ * @param artifact
40
+ * @param component
41
+ */
42
+ private storeWholeArtifactByResolver;
43
+ /**
44
+ * Go over the artifact files and send them to the resolver one by one
45
+ * @param storageResolver
46
+ * @param artifact
47
+ * @param component
48
+ */
49
+ private storeArtifactFilesByResolver;
50
+ static fromArtifactObjects(artifactObjects: ArtifactObject[]): ArtifactList<Artifact>;
51
+ static fromArray<T extends Artifact>(artifacts: T[]): ArtifactList<T>;
52
+ }
@@ -0,0 +1,59 @@
1
+ import type { ArtifactFiles, ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
2
+ import type { TaskDescriptor } from '../build-task';
3
+ import type { ArtifactDefinition } from './artifact-definition';
4
+ export declare class Artifact {
5
+ /**
6
+ * definition of the artifact.
7
+ */
8
+ readonly def: ArtifactDefinition;
9
+ readonly files: ArtifactFiles;
10
+ /**
11
+ * the declaring task.
12
+ */
13
+ readonly task: TaskDescriptor;
14
+ /**
15
+ * timestamp of the artifact creation.
16
+ */
17
+ readonly timestamp: number;
18
+ constructor(
19
+ /**
20
+ * definition of the artifact.
21
+ */
22
+ def: ArtifactDefinition, files: ArtifactFiles,
23
+ /**
24
+ * the declaring task.
25
+ */
26
+ task: TaskDescriptor,
27
+ /**
28
+ * timestamp of the artifact creation.
29
+ */
30
+ timestamp?: number);
31
+ get storage(): string;
32
+ get storageResolver(): import("..").ArtifactStorageResolver;
33
+ /**
34
+ * name of the artifact.
35
+ */
36
+ get name(): string;
37
+ /**
38
+ * description of the artifact.
39
+ */
40
+ get description(): string | undefined;
41
+ /**
42
+ * aspect id (string) that generated the artifact
43
+ */
44
+ get generatedBy(): string;
45
+ /**
46
+ * calculate what could possibly be the root directory of the artifact.
47
+ * in case the deprecated rootDir is set, use it.
48
+ * otherwise, get the common first directory of all files.
49
+ * if there is no common directory, or there are multiple directories return undefined.
50
+ */
51
+ get artifactDir(): string | undefined;
52
+ isEmpty(): boolean;
53
+ /**
54
+ * archive all artifact files into a tar.
55
+ */
56
+ tar(): void;
57
+ toObject(): ArtifactObject;
58
+ static fromArtifactObject(object: ArtifactObject): Artifact;
59
+ }
@@ -0,0 +1,26 @@
1
+ import { Command, CommandOptions } from '@teambit/cli';
2
+ import { ComponentMain } from '@teambit/component';
3
+ import { BuilderMain } from '../builder.main.runtime';
4
+ export type ArtifactsOpts = {
5
+ aspect?: string;
6
+ task?: string;
7
+ files?: string;
8
+ outDir?: string;
9
+ };
10
+ export declare class ArtifactsCmd implements Command {
11
+ private builder;
12
+ private componentMain;
13
+ name: string;
14
+ description: string;
15
+ extendedDescription: string;
16
+ arguments: {
17
+ name: string;
18
+ description: string;
19
+ }[];
20
+ alias: string;
21
+ group: string;
22
+ helpUrl: string;
23
+ options: CommandOptions;
24
+ constructor(builder: BuilderMain, componentMain: ComponentMain);
25
+ report([componentPattern]: [string], artifactsOpts: ArtifactsOpts): Promise<string>;
26
+ }
@@ -0,0 +1,10 @@
1
+ import type { AspectDescriptor } from '@teambit/aspect-loader';
2
+ import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
3
+ export declare class ExtensionArtifact {
4
+ readonly files: AbstractVinyl[];
5
+ readonly extensionDescriptor: AspectDescriptor;
6
+ constructor(files: AbstractVinyl[], extensionDescriptor: AspectDescriptor);
7
+ toObject(): {
8
+ extensionDescriptor: AspectDescriptor;
9
+ };
10
+ }
@@ -0,0 +1,18 @@
1
+ import type { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
2
+ import type { ArtifactDefinition } from './artifact-definition';
3
+ import { Artifact } from './artifact';
4
+ import { TaskDescriptor } from '../build-task';
5
+ export declare class FsArtifact extends Artifact {
6
+ /**
7
+ * definition of the artifact.
8
+ */
9
+ readonly def: ArtifactDefinition;
10
+ readonly files: ArtifactFiles;
11
+ readonly task: TaskDescriptor;
12
+ readonly rootDir: string;
13
+ constructor(
14
+ /**
15
+ * definition of the artifact.
16
+ */
17
+ def: ArtifactDefinition, files: ArtifactFiles, task: TaskDescriptor, rootDir: string);
18
+ }
@@ -0,0 +1,6 @@
1
+ export { ArtifactDefinition, ArtifactModelDefinition } from './artifact-definition';
2
+ export { ExtensionArtifact } from './extension-artifact';
3
+ export { Artifact } from './artifact';
4
+ export { ArtifactList } from './artifact-list';
5
+ export { ArtifactFactory, ArtifactMap } from './artifact-factory';
6
+ export { FsArtifact } from './fs-artifact';
@@ -0,0 +1,75 @@
1
+ import { EnvDefinition } from '@teambit/envs';
2
+ import { ComponentMap } from '@teambit/component';
3
+ import { Logger } from '@teambit/logger';
4
+ import { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';
5
+ import { BuildTask } from './build-task';
6
+ import { ComponentResult } from './types';
7
+ import { TasksQueue } from './tasks-queue';
8
+ import { EnvsBuildContext } from './builder.service';
9
+ import { TaskResultsList } from './task-results-list';
10
+ export type TaskResults = {
11
+ /**
12
+ * task itself. useful for getting its id/description later on.
13
+ */
14
+ task: BuildTask;
15
+ /**
16
+ * environment were the task was running
17
+ */
18
+ env: EnvDefinition;
19
+ /**
20
+ * component build results.
21
+ */
22
+ componentsResults: ComponentResult[];
23
+ /**
24
+ * artifacts generated by the build pipeline.
25
+ * in case the task finished with errors, this prop is undefined.
26
+ */
27
+ artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;
28
+ /**
29
+ * timestamp of start initiation.
30
+ */
31
+ startTime: number;
32
+ /**
33
+ * timestamp of task completion.
34
+ */
35
+ endTime: number;
36
+ };
37
+ type PipeOptions = {
38
+ exitOnFirstFailedTask?: boolean;
39
+ showEnvNameInOutput?: boolean;
40
+ showEnvVersionInOutput?: boolean;
41
+ };
42
+ export declare class BuildPipe {
43
+ /**
44
+ * array of services to apply on the components.
45
+ */
46
+ readonly tasksQueue: TasksQueue;
47
+ readonly envsBuildContext: EnvsBuildContext;
48
+ readonly logger: Logger;
49
+ readonly artifactFactory: ArtifactFactory;
50
+ private previousTaskResults?;
51
+ private options?;
52
+ private failedTasks;
53
+ private failedDependencyTask;
54
+ private longProcessLogger;
55
+ private taskResults;
56
+ constructor(
57
+ /**
58
+ * array of services to apply on the components.
59
+ */
60
+ tasksQueue: TasksQueue, envsBuildContext: EnvsBuildContext, logger: Logger, artifactFactory: ArtifactFactory, previousTaskResults?: TaskResults[] | undefined, options?: PipeOptions | undefined);
61
+ get allTasksResults(): TaskResults[];
62
+ /**
63
+ * execute a pipeline of build tasks.
64
+ */
65
+ execute(): Promise<TaskResultsList>;
66
+ private executePreBuild;
67
+ private executeTask;
68
+ private getPrettyAspectName;
69
+ private getPrettyEnvName;
70
+ private executePostBuild;
71
+ private updateFailedDependencyTask;
72
+ private shouldSkipTask;
73
+ private getBuildContext;
74
+ }
75
+ export {};
@@ -82,7 +82,6 @@ class BuildPipe {
82
82
  * execute a pipeline of build tasks.
83
83
  */
84
84
  async execute() {
85
- this.addSignalListener();
86
85
  await this.executePreBuild();
87
86
  this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);
88
87
  await (0, _pMapSeries().default)(this.tasksQueue, async ({
@@ -95,18 +94,6 @@ class BuildPipe {
95
94
  await this.executePostBuild(tasksResultsList);
96
95
  return tasksResultsList;
97
96
  }
98
-
99
- /**
100
- * for some reason, some tasks (such as typescript compilation) ignore ctrl+C. this fixes it.
101
- */
102
- addSignalListener() {
103
- process.on('SIGTERM', () => {
104
- process.exit();
105
- });
106
- process.on('SIGINT', () => {
107
- process.exit();
108
- });
109
- }
110
97
  async executePreBuild() {
111
98
  this.logger.setStatusLine('executing pre-build for all tasks');
112
99
  const longProcessLogger = this.logger.createLongProcessLogger('running pre-build for all tasks');
@@ -1 +1 @@
1
- {"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_prettyTime","_toolboxString","_chalk","_buildTask","_taskResultsList","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","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","buildContext","hasOriginalSeeders","Boolean","_originalSeeders","dependencyStr","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","startTask","hrtime","taskStartTime","Date","now","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","errors","artifacts","duration","prettyTime","chalk","red","getProgress","failedTasks","push","color","green","dim","consoleSuccess","defs","generate","startTime","resolvedId","ComponentID","fromString","tokens","split","map","token","capitalize","join","envId","ver","showEnvVersionInOutput","version","fullName","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","deserializeIdAllowEmptyName","find","failedTask","exitOnFirstFailedTask","failedTaskId","consoleWarning","Error","previousTasksResults","exports"],"sources":["build-pipe.ts"],"sourcesContent":["import { EnvDefinition } from '@teambit/envs';\nimport { ComponentMap, ComponentID } from '@teambit/component';\nimport { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { capitalize } from '@teambit/toolbox.string.capitalize';\nimport chalk from 'chalk';\nimport { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';\nimport { BuildContext, BuildTask, BuildTaskHelper, BuiltTaskResult } from './build-task';\nimport { ComponentResult } from './types';\nimport { TasksQueue } from './tasks-queue';\nimport { EnvsBuildContext } from './builder.service';\nimport { TaskResultsList } from './task-results-list';\n\nexport type TaskResults = {\n /**\n * task itself. useful for getting its id/description later on.\n */\n task: BuildTask;\n\n /**\n * environment were the task was running\n */\n env: EnvDefinition;\n\n /**\n * component build results.\n */\n componentsResults: ComponentResult[];\n\n /**\n * artifacts generated by the build pipeline.\n * in case the task finished with errors, this prop is undefined.\n */\n artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n\n /**\n * timestamp of start initiation.\n */\n startTime: number;\n\n /**\n * timestamp of task completion.\n */\n endTime: number;\n};\n\ntype PipeOptions = {\n exitOnFirstFailedTask?: boolean; // by default it skips only when a dependent failed.\n showEnvNameInOutput?: boolean;\n showEnvVersionInOutput?: boolean; // in case it shows the env-name, whether should show also the version\n};\n\nexport class BuildPipe {\n private failedTasks: BuildTask[] = [];\n private failedDependencyTask: BuildTask | undefined;\n private longProcessLogger: LongProcessLogger;\n private taskResults: TaskResults[] = [];\n constructor(\n /**\n * array of services to apply on the components.\n */\n readonly tasksQueue: TasksQueue,\n readonly envsBuildContext: EnvsBuildContext,\n readonly logger: Logger,\n readonly artifactFactory: ArtifactFactory,\n private previousTaskResults?: TaskResults[],\n private options?: PipeOptions\n ) {}\n\n get allTasksResults(): TaskResults[] {\n return [...(this.previousTaskResults || []), ...(this.taskResults || [])];\n }\n\n /**\n * execute a pipeline of build tasks.\n */\n async execute(): Promise<TaskResultsList> {\n 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 buildContext = this.getBuildContext(env.id);\n const hasOriginalSeeders = Boolean(buildContext.capsuleNetwork._originalSeeders?.length);\n const dependencyStr = hasOriginalSeeders ? '' : `[dependency] `;\n const taskLogPrefix = `${dependencyStr}${envName}[${this.getPrettyAspectName(task.aspectId)}: ${task.name}]`;\n this.longProcessLogger.logProgress(`${taskLogPrefix}${task.description ? ` ${task.description}` : ''}`, false);\n this.updateFailedDependencyTask(task);\n if (this.shouldSkipTask(taskId, env.id)) {\n return;\n }\n const startTask = process.hrtime();\n const taskStartTime = Date.now();\n let buildTaskResult: BuiltTaskResult;\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n const duration = prettyTime(process.hrtime(startTask));\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.logger.consoleFailure(\n chalk.red(`${this.longProcessLogger.getProgress()} env: ${env.id}, task \"${taskId}\" has failed in ${duration}`)\n );\n this.failedTasks.push(task);\n } else {\n const color = hasOriginalSeeders ? chalk.green : chalk.green.dim;\n this.logger.consoleSuccess(\n color(`${this.longProcessLogger.getProgress()} ${taskLogPrefix} Completed successfully in ${duration}`)\n );\n const defs = buildTaskResult.artifacts || [];\n artifacts = this.artifactFactory.generate(buildContext, defs, task);\n }\n\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults: buildTaskResult.componentsResults,\n artifacts,\n startTime: taskStartTime,\n endTime,\n };\n\n this.taskResults.push(taskResults);\n }\n\n private getPrettyAspectName(aspectId: string): string {\n const resolvedId = ComponentID.fromString(aspectId);\n const tokens = resolvedId.name.split('-').map((token) => capitalize(token));\n return tokens.join(' ');\n }\n\n private getPrettyEnvName(envId: string) {\n const resolvedId = ComponentID.fromString(envId);\n const ver = this.options?.showEnvVersionInOutput ? `@${resolvedId.version}` : '';\n return `${resolvedId.fullName}${ver}`;\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n const longProcessLogger = this.logger.createLongProcessLogger('running post-build for all tasks');\n this.logger.setStatusLine('executing post-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.postBuild) return;\n await task.postBuild(this.getBuildContext(env.id), tasksResults);\n });\n longProcessLogger.end();\n }\n\n private updateFailedDependencyTask(task: BuildTask) {\n if (!this.failedDependencyTask && this.failedTasks.length && task.dependencies) {\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n this.failedDependencyTask = this.failedTasks.find((failedTask) => {\n if (name && name !== failedTask.name) return false;\n return aspectId === failedTask.aspectId;\n });\n });\n }\n }\n\n private shouldSkipTask(taskId: string, envId: string): boolean {\n if (this.options?.exitOnFirstFailedTask && this.failedTasks.length) {\n const failedTaskId = BuildTaskHelper.serializeId(this.failedTasks[0]);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n if (!this.failedDependencyTask) return false;\n const failedTaskId = BuildTaskHelper.serializeId(this.failedDependencyTask);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n\n private getBuildContext(envId: string): BuildContext {\n const buildContext = this.envsBuildContext[envId];\n if (!buildContext) throw new Error(`unable to find buildContext for ${envId}`);\n buildContext.previousTasksResults = this.allTasksResults;\n return buildContext;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,eAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,cAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,OAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,WAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,UAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAQ,iBAAA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ACJ,CAAC,CAAC;IACJ;EACF;EAEQK,cAAcA,CAAClB,MAAc,EAAEyD,KAAa,EAAW;IAC7D,IAAI,IAAI,CAACrF,OAAO,EAAEmG,qBAAqB,IAAI,IAAI,CAAChC,WAAW,CAAC3D,MAAM,EAAE;MAClE,MAAM4F,YAAY,GAAGvE,4BAAe,CAACC,WAAW,CAAC,IAAI,CAACqC,WAAW,CAAC,CAAC,CAAC,CAAC;MACrE,IAAI,CAACtE,MAAM,CAACwG,cAAc,CAAE,QAAOhB,KAAM,WAAUzD,MAAO,yBAAwBwE,YAAa,WAAU,CAAC;MAC1G,OAAO,IAAI;IACb;IACA,IAAI,CAAC,IAAI,CAACR,oBAAoB,EAAE,OAAO,KAAK;IAC5C,MAAMQ,YAAY,GAAGvE,4BAAe,CAACC,WAAW,CAAC,IAAI,CAAC8D,oBAAoB,CAAC;IAC3E,IAAI,CAAC/F,MAAM,CAACwG,cAAc,CAAE,QAAOhB,KAAM,WAAUzD,MAAO,yBAAwBwE,YAAa,WAAU,CAAC;IAC1G,OAAO,IAAI;EACb;EAEQ1E,eAAeA,CAAC2D,KAAa,EAAgB;IACnD,MAAMnD,YAAY,GAAG,IAAI,CAACtC,gBAAgB,CAACyF,KAAK,CAAC;IACjD,IAAI,CAACnD,YAAY,EAAE,MAAM,IAAIoE,KAAK,CAAE,mCAAkCjB,KAAM,EAAC,CAAC;IAC9EnD,YAAY,CAACqE,oBAAoB,GAAG,IAAI,CAACtG,eAAe;IACxD,OAAOiC,YAAY;EACrB;AACF;AAACsE,OAAA,CAAA/G,SAAA,GAAAA,SAAA","ignoreList":[]}
1
+ {"version":3,"names":["_component","data","require","_pMapSeries","_interopRequireDefault","_prettyTime","_toolboxString","_chalk","_buildTask","_taskResultsList","obj","__esModule","default","_defineProperty","key","value","_toPropertyKey","Object","defineProperty","enumerable","configurable","writable","t","i","_toPrimitive","r","e","Symbol","toPrimitive","call","TypeError","String","Number","BuildPipe","constructor","tasksQueue","envsBuildContext","logger","artifactFactory","previousTaskResults","options","allTasksResults","taskResults","execute","executePreBuild","longProcessLogger","createLongProcessLogger","length","mapSeries","task","env","executeTask","end","capsuleRootDir","values","capsuleNetwork","capsulesRootDir","tasksResultsList","TaskResultsList","executePostBuild","setStatusLine","preBuild","getBuildContext","id","taskId","BuildTaskHelper","serializeId","envName","showEnvNameInOutput","getPrettyEnvName","buildContext","hasOriginalSeeders","Boolean","_originalSeeders","dependencyStr","taskLogPrefix","getPrettyAspectName","aspectId","name","logProgress","description","updateFailedDependencyTask","shouldSkipTask","startTask","process","hrtime","taskStartTime","Date","now","buildTaskResult","err","consoleFailure","endTime","compsWithErrors","componentsResults","filter","c","errors","artifacts","duration","prettyTime","chalk","red","getProgress","failedTasks","push","color","green","dim","consoleSuccess","defs","generate","startTime","resolvedId","ComponentID","fromString","tokens","split","map","token","capitalize","join","envId","ver","showEnvVersionInOutput","version","fullName","tasksResults","postBuild","failedDependencyTask","dependencies","forEach","dependency","deserializeIdAllowEmptyName","find","failedTask","exitOnFirstFailedTask","failedTaskId","consoleWarning","Error","previousTasksResults","exports"],"sources":["build-pipe.ts"],"sourcesContent":["import { EnvDefinition } from '@teambit/envs';\nimport { ComponentMap, ComponentID } from '@teambit/component';\nimport { Logger, LongProcessLogger } from '@teambit/logger';\nimport mapSeries from 'p-map-series';\nimport prettyTime from 'pretty-time';\nimport { capitalize } from '@teambit/toolbox.string.capitalize';\nimport chalk from 'chalk';\nimport { ArtifactFactory, ArtifactList, FsArtifact } from './artifact';\nimport { BuildContext, BuildTask, BuildTaskHelper, BuiltTaskResult } from './build-task';\nimport { ComponentResult } from './types';\nimport { TasksQueue } from './tasks-queue';\nimport { EnvsBuildContext } from './builder.service';\nimport { TaskResultsList } from './task-results-list';\n\nexport type TaskResults = {\n /**\n * task itself. useful for getting its id/description later on.\n */\n task: BuildTask;\n\n /**\n * environment were the task was running\n */\n env: EnvDefinition;\n\n /**\n * component build results.\n */\n componentsResults: ComponentResult[];\n\n /**\n * artifacts generated by the build pipeline.\n * in case the task finished with errors, this prop is undefined.\n */\n artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n\n /**\n * timestamp of start initiation.\n */\n startTime: number;\n\n /**\n * timestamp of task completion.\n */\n endTime: number;\n};\n\ntype PipeOptions = {\n exitOnFirstFailedTask?: boolean; // by default it skips only when a dependent failed.\n showEnvNameInOutput?: boolean;\n showEnvVersionInOutput?: boolean; // in case it shows the env-name, whether should show also the version\n};\n\nexport class BuildPipe {\n private failedTasks: BuildTask[] = [];\n private failedDependencyTask: BuildTask | undefined;\n private longProcessLogger: LongProcessLogger;\n private taskResults: TaskResults[] = [];\n constructor(\n /**\n * array of services to apply on the components.\n */\n readonly tasksQueue: TasksQueue,\n readonly envsBuildContext: EnvsBuildContext,\n readonly logger: Logger,\n readonly artifactFactory: ArtifactFactory,\n private previousTaskResults?: TaskResults[],\n private options?: PipeOptions\n ) {}\n\n get allTasksResults(): TaskResults[] {\n return [...(this.previousTaskResults || []), ...(this.taskResults || [])];\n }\n\n /**\n * execute a pipeline of build tasks.\n */\n async execute(): Promise<TaskResultsList> {\n await this.executePreBuild();\n this.longProcessLogger = this.logger.createLongProcessLogger('running tasks', this.tasksQueue.length);\n await mapSeries(this.tasksQueue, async ({ task, env }) => this.executeTask(task, env));\n this.longProcessLogger.end();\n const capsuleRootDir = Object.values(this.envsBuildContext)[0]?.capsuleNetwork.capsulesRootDir;\n const tasksResultsList = new TaskResultsList(this.tasksQueue, this.taskResults, capsuleRootDir);\n await this.executePostBuild(tasksResultsList);\n\n return tasksResultsList;\n }\n\n private async executePreBuild() {\n this.logger.setStatusLine('executing pre-build for all tasks');\n const longProcessLogger = this.logger.createLongProcessLogger('running pre-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.preBuild) return;\n await task.preBuild(this.getBuildContext(env.id));\n });\n longProcessLogger.end();\n }\n\n private async executeTask(task: BuildTask, env: EnvDefinition): Promise<void> {\n const taskId = BuildTaskHelper.serializeId(task);\n const envName = this.options?.showEnvNameInOutput ? `(${this.getPrettyEnvName(env.id)}) ` : '';\n const buildContext = this.getBuildContext(env.id);\n const hasOriginalSeeders = Boolean(buildContext.capsuleNetwork._originalSeeders?.length);\n const dependencyStr = hasOriginalSeeders ? '' : `[dependency] `;\n const taskLogPrefix = `${dependencyStr}${envName}[${this.getPrettyAspectName(task.aspectId)}: ${task.name}]`;\n this.longProcessLogger.logProgress(`${taskLogPrefix}${task.description ? ` ${task.description}` : ''}`, false);\n this.updateFailedDependencyTask(task);\n if (this.shouldSkipTask(taskId, env.id)) {\n return;\n }\n const startTask = process.hrtime();\n const taskStartTime = Date.now();\n let buildTaskResult: BuiltTaskResult;\n try {\n buildTaskResult = await task.execute(buildContext);\n } catch (err) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" threw an error`);\n throw err;\n }\n\n const endTime = Date.now();\n const compsWithErrors = buildTaskResult.componentsResults.filter((c) => c.errors?.length);\n let artifacts: ComponentMap<ArtifactList<FsArtifact>> | undefined;\n const duration = prettyTime(process.hrtime(startTask));\n if (compsWithErrors.length) {\n this.logger.consoleFailure(`env: ${env.id}, task \"${taskId}\" has failed`);\n this.logger.consoleFailure(\n chalk.red(`${this.longProcessLogger.getProgress()} env: ${env.id}, task \"${taskId}\" has failed in ${duration}`)\n );\n this.failedTasks.push(task);\n } else {\n const color = hasOriginalSeeders ? chalk.green : chalk.green.dim;\n this.logger.consoleSuccess(\n color(`${this.longProcessLogger.getProgress()} ${taskLogPrefix} Completed successfully in ${duration}`)\n );\n const defs = buildTaskResult.artifacts || [];\n artifacts = this.artifactFactory.generate(buildContext, defs, task);\n }\n\n const taskResults: TaskResults = {\n task,\n env,\n componentsResults: buildTaskResult.componentsResults,\n artifacts,\n startTime: taskStartTime,\n endTime,\n };\n\n this.taskResults.push(taskResults);\n }\n\n private getPrettyAspectName(aspectId: string): string {\n const resolvedId = ComponentID.fromString(aspectId);\n const tokens = resolvedId.name.split('-').map((token) => capitalize(token));\n return tokens.join(' ');\n }\n\n private getPrettyEnvName(envId: string) {\n const resolvedId = ComponentID.fromString(envId);\n const ver = this.options?.showEnvVersionInOutput ? `@${resolvedId.version}` : '';\n return `${resolvedId.fullName}${ver}`;\n }\n\n private async executePostBuild(tasksResults: TaskResultsList) {\n const longProcessLogger = this.logger.createLongProcessLogger('running post-build for all tasks');\n this.logger.setStatusLine('executing post-build for all tasks');\n await mapSeries(this.tasksQueue, async ({ task, env }) => {\n if (!task.postBuild) return;\n await task.postBuild(this.getBuildContext(env.id), tasksResults);\n });\n longProcessLogger.end();\n }\n\n private updateFailedDependencyTask(task: BuildTask) {\n if (!this.failedDependencyTask && this.failedTasks.length && task.dependencies) {\n task.dependencies.forEach((dependency) => {\n const { aspectId, name } = BuildTaskHelper.deserializeIdAllowEmptyName(dependency);\n this.failedDependencyTask = this.failedTasks.find((failedTask) => {\n if (name && name !== failedTask.name) return false;\n return aspectId === failedTask.aspectId;\n });\n });\n }\n }\n\n private shouldSkipTask(taskId: string, envId: string): boolean {\n if (this.options?.exitOnFirstFailedTask && this.failedTasks.length) {\n const failedTaskId = BuildTaskHelper.serializeId(this.failedTasks[0]);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n if (!this.failedDependencyTask) return false;\n const failedTaskId = BuildTaskHelper.serializeId(this.failedDependencyTask);\n this.logger.consoleWarning(`env: ${envId}, task \"${taskId}\" has skipped due to \"${failedTaskId}\" failure`);\n return true;\n }\n\n private getBuildContext(envId: string): BuildContext {\n const buildContext = this.envsBuildContext[envId];\n if (!buildContext) throw new Error(`unable to find buildContext for ${envId}`);\n buildContext.previousTasksResults = this.allTasksResults;\n return buildContext;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,YAAA;E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CAACsE,oBAAoB,GAAG,IAAI,CAACnG,eAAe;IACxD,OAAO6B,YAAY;EACrB;AACF;AAACuE,OAAA,CAAA5G,SAAA,GAAAA,SAAA","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ import { EnvDefinition } from '@teambit/envs';
2
+ import type { TaskSlot } from './builder.main.runtime';
3
+ import { TasksQueue } from './tasks-queue';
4
+ import { PipeFunctionNames } from './builder.service';
5
+ /**
6
+ * there are two ways how to add tasks to build pipeline.
7
+ * 1. `getBuildPipe()` method of the env.
8
+ * 2. registering to the `builder.registerBuildTask()`.
9
+ *
10
+ * in the option #1, it's possible to determine the order. e.g. `getBuildPipe() { return [taskA, taskB, taskC]; }`
11
+ * in the option #2, the register happens once the extension is loaded, so there is no way to put
12
+ * one task before/after another task.
13
+ *
14
+ * To be able to determine the order, you can do the following
15
+ * 1. "task.location", it has two options "start" and "end". the rest are "middle".
16
+ * 2. "task.dependencies", the dependencies must be completed for all envs before this task starts.
17
+ * the dependencies are applicable inside a location and not across locations. see getLocation()
18
+ * or/and continue reading for more info about this.
19
+ *
20
+ * to determine the final order of the tasks, the following is done:
21
+ * 1. split all tasks to three groups: start, middle and end.
22
+ * 2. for each group define a dependencies graph for the tasks with "dependencies" prop and the pipeline.
23
+ * 3. start with the first group "start", toposort the dependencies graph and push the found tasks
24
+ * to a queue. once completed, iterate the pipeline and add all tasks to the queue.
25
+ * 4. do the same for the "middle" and "end" groups.
26
+ *
27
+ * the reason for splitting the tasks to the three groups and not using the "dependencies" field
28
+ * alone to determine the order is that the "start" and "end" groups are mostly core and "middle"
29
+ * is mostly the user entering tasks to the pipeline and we as the core don't know about the users
30
+ * tasks. For example, a core task "PublishComponent" must happen after the compiler, however, a
31
+ * user might have an env without a compiler. if we determine the order only by the dependencies
32
+ * field, the "PublishComponent" would have a dependency "compiler" and because in this case there
33
+ * is no compiler task, it would throw an error about missing dependencies.
34
+ */
35
+ export declare function calculatePipelineOrder(taskSlot: TaskSlot, envs: EnvDefinition[], pipeNameOnEnv: PipeFunctionNames, tasks?: string[], skipTests?: boolean, skipTasks?: string[]): TasksQueue;
@@ -0,0 +1,34 @@
1
+ import { ComponentID, Component } from '@teambit/component';
2
+ import type { ArtifactObject } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';
3
+ import { TaskResults } from './build-pipe';
4
+ import { TaskMetadata } from './types';
5
+ export type PipelineReport = {
6
+ taskId: string;
7
+ taskName: string;
8
+ taskDescription?: string;
9
+ startTime?: number;
10
+ endTime?: number;
11
+ errors?: Array<Error | string>;
12
+ warnings?: string[];
13
+ };
14
+ export type AspectData = {
15
+ aspectId: string;
16
+ data: TaskMetadata;
17
+ };
18
+ /**
19
+ * Helper to get the data and artifacts from the TasksResultsList before saving during the tag
20
+ */
21
+ export declare class BuildPipelineResultList {
22
+ private tasksResults;
23
+ private components;
24
+ private artifactListsMap;
25
+ constructor(tasksResults: TaskResults[], components: Component[]);
26
+ private getFlattenedArtifactListsMapFromAllTasks;
27
+ getMetadataFromTaskResults(componentId: ComponentID): {
28
+ [taskId: string]: TaskMetadata;
29
+ };
30
+ getPipelineReportOfComponent(componentId: ComponentID): PipelineReport[];
31
+ getDataOfComponent(componentId: ComponentID): AspectData[];
32
+ getArtifactsDataOfComponent(componentId: ComponentID): ArtifactObject[] | undefined;
33
+ private mergeDataIfPossible;
34
+ }