@teambit/builder 1.0.228 → 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.
- package/artifacts/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_pipelines_builder-preview.js +1 -1
- package/artifacts/schema.json +706 -180
- package/dist/artifact/artifact-definition.d.ts +65 -0
- package/dist/artifact/artifact-extractor.d.ts +35 -0
- package/dist/artifact/artifact-factory.d.ts +20 -0
- package/dist/artifact/artifact-list.d.ts +52 -0
- package/dist/artifact/artifact.d.ts +59 -0
- package/dist/artifact/artifacts.cmd.d.ts +26 -0
- package/dist/artifact/extension-artifact.d.ts +10 -0
- package/dist/artifact/fs-artifact.d.ts +18 -0
- package/dist/artifact/index.d.ts +6 -0
- package/dist/build-pipe.d.ts +75 -0
- package/dist/build-pipeline-order.d.ts +35 -0
- package/dist/build-pipeline-result-list.d.ts +34 -0
- package/dist/build-task.d.ts +128 -0
- package/dist/build.cmd.d.ts +39 -0
- package/dist/builder-env-type.d.ts +15 -0
- package/dist/builder.aspect.d.ts +2 -0
- package/dist/builder.composition.d.ts +1 -0
- package/dist/builder.graphql.d.ts +102 -0
- package/dist/builder.main.runtime.d.ts +153 -0
- package/dist/builder.route.d.ts +20 -0
- package/dist/builder.service.d.ts +105 -0
- package/dist/exceptions/artifact-definition-no-glob.d.ts +3 -0
- package/dist/exceptions/artifact-storage-error.d.ts +7 -0
- package/dist/exceptions/capsule-not-found.d.ts +5 -0
- package/dist/exceptions/index.d.ts +3 -0
- package/dist/exceptions/invalid-task.d.ts +5 -0
- package/dist/index.d.ts +19 -0
- package/dist/pipeline/index.d.ts +1 -0
- package/dist/pipeline/pipeline-results.d.ts +2 -0
- package/dist/pipeline.d.ts +43 -0
- package/dist/{preview-1712805335812.js → preview-1712822929999.js} +2 -2
- package/dist/storage/default-resolver.d.ts +7 -0
- package/dist/storage/index.d.ts +2 -0
- package/dist/storage/s3-resolver.d.ts +0 -0
- package/dist/storage/storage-resolver.d.ts +26 -0
- package/dist/task-results-list.d.ts +22 -0
- package/dist/task.d.ts +44 -0
- package/dist/tasks-queue.d.ts +16 -0
- package/dist/templates/build-task/files/index-file.d.ts +2 -0
- package/dist/templates/build-task/files/task-file.d.ts +2 -0
- package/dist/templates/build-task/index.d.ts +2 -0
- package/dist/types.d.ts +32 -0
- package/package.json +18 -18
- 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 {};
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { Component } from '@teambit/component';
|
|
2
|
+
import { LaneId } from '@teambit/lane-id';
|
|
3
|
+
import { ExecutionContext } from '@teambit/envs';
|
|
4
|
+
import type { Network } from '@teambit/isolator';
|
|
5
|
+
import type { ComponentResult } from './types';
|
|
6
|
+
import type { ArtifactDefinition } from './artifact';
|
|
7
|
+
import { TaskResultsList } from './task-results-list';
|
|
8
|
+
import { TaskResults } from './build-pipe';
|
|
9
|
+
import { PipeName } from './builder.service';
|
|
10
|
+
export type TaskLocation = 'start' | 'end';
|
|
11
|
+
/**
|
|
12
|
+
* delimiter between task.aspectId and task.name
|
|
13
|
+
*/
|
|
14
|
+
export declare const TaskIdDelimiter = ":";
|
|
15
|
+
/**
|
|
16
|
+
* A folder to write artifacts generated during a build task
|
|
17
|
+
* This folder is used in the core envs and excluded by default from the package tar file (the core envs is writing this into the npmignore file)
|
|
18
|
+
*/
|
|
19
|
+
export declare const CAPSULE_ARTIFACTS_DIR = "artifacts";
|
|
20
|
+
export interface BuildContext extends ExecutionContext {
|
|
21
|
+
/**
|
|
22
|
+
* all components about to be built/tagged.
|
|
23
|
+
*/
|
|
24
|
+
components: Component[];
|
|
25
|
+
/**
|
|
26
|
+
* network of capsules ready to be built.
|
|
27
|
+
*/
|
|
28
|
+
capsuleNetwork: Network;
|
|
29
|
+
/**
|
|
30
|
+
* data generated by tasks that were running before this task
|
|
31
|
+
*/
|
|
32
|
+
previousTasksResults: TaskResults[];
|
|
33
|
+
/**
|
|
34
|
+
* Run the build pipeline in dev mode
|
|
35
|
+
*/
|
|
36
|
+
dev?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* pipe name such as "build", "tas", "snap".
|
|
39
|
+
* an example usage is "deploy" task which is running in snap and tag pipeline and has different needs in each one.
|
|
40
|
+
*/
|
|
41
|
+
pipeName: PipeName;
|
|
42
|
+
/**
|
|
43
|
+
* current lane-id if exists. empty when on main.
|
|
44
|
+
*/
|
|
45
|
+
laneId?: LaneId;
|
|
46
|
+
}
|
|
47
|
+
export interface TaskDescriptor {
|
|
48
|
+
aspectId: string;
|
|
49
|
+
name?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface BuildTask {
|
|
53
|
+
/**
|
|
54
|
+
* aspect id serialized of the creator of the task.
|
|
55
|
+
* todo: automate this so then it won't be needed to pass manually.
|
|
56
|
+
*/
|
|
57
|
+
aspectId: string;
|
|
58
|
+
/**
|
|
59
|
+
* name of the task. function as an identifier among other tasks of the same aspectId.
|
|
60
|
+
* spaces and special characters are not allowed. as a convention, use UpperCamelCase style.
|
|
61
|
+
* (e.g. TypescriptCompiler).
|
|
62
|
+
*/
|
|
63
|
+
name: string;
|
|
64
|
+
/**
|
|
65
|
+
* description of what the task does.
|
|
66
|
+
* if available, the logger will log it show it in the status-line.
|
|
67
|
+
*/
|
|
68
|
+
description?: string;
|
|
69
|
+
/**
|
|
70
|
+
* where to put the task, before the env pipeline or after
|
|
71
|
+
*/
|
|
72
|
+
location?: TaskLocation;
|
|
73
|
+
/**
|
|
74
|
+
* execute a task in a build context
|
|
75
|
+
*/
|
|
76
|
+
execute(context: BuildContext): Promise<BuiltTaskResult>;
|
|
77
|
+
/**
|
|
78
|
+
* run before the build pipeline has started. this is useful when some preparation are needed to
|
|
79
|
+
* be done on all envs before the build starts.
|
|
80
|
+
* e.g. typescript compiler needs to write the tsconfig file. doing it during the task, will
|
|
81
|
+
* cause dependencies from other envs to get this tsconfig written.
|
|
82
|
+
*/
|
|
83
|
+
preBuild?(context: BuildContext): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* run after the build pipeline completed for all envs. useful for doing some cleanup on the
|
|
86
|
+
* capsules before the deployment starts.
|
|
87
|
+
*/
|
|
88
|
+
postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* needed if you want the task to be running only after the dependencies were completed
|
|
91
|
+
* for *all* envs.
|
|
92
|
+
* normally this is not needed because the build-pipeline runs the tasks in the same order
|
|
93
|
+
* they're located in the `getBuildPipe()` array and according to the task.location.
|
|
94
|
+
* the case where this is useful is when a task not only needs to be after another task, but also
|
|
95
|
+
* after all environments were running that task.
|
|
96
|
+
* a dependency is task.aspectId. if an aspect has multiple tasks, to be more specific, use
|
|
97
|
+
* "aspectId:name", e.g. "teambit.compilation/compiler:TypescriptCompiler".
|
|
98
|
+
*/
|
|
99
|
+
dependencies?: string[];
|
|
100
|
+
}
|
|
101
|
+
export interface BuiltTaskResult {
|
|
102
|
+
/**
|
|
103
|
+
* build results for each of the components in the build context.
|
|
104
|
+
*/
|
|
105
|
+
componentsResults: ComponentResult[];
|
|
106
|
+
/**
|
|
107
|
+
* array of artifact definitions to generate after a successful build.
|
|
108
|
+
*/
|
|
109
|
+
artifacts?: ArtifactDefinition[];
|
|
110
|
+
}
|
|
111
|
+
export declare class BuildTaskHelper {
|
|
112
|
+
static serializeId({ aspectId, name }: {
|
|
113
|
+
aspectId: string;
|
|
114
|
+
name: string;
|
|
115
|
+
}): string;
|
|
116
|
+
static deserializeId(id: string): {
|
|
117
|
+
aspectId: string;
|
|
118
|
+
name: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* don't throw an error when the id includes only the aspect-id without the task name.
|
|
122
|
+
* useful for task dependencies, when it's allowed to specify the aspect-id only.
|
|
123
|
+
*/
|
|
124
|
+
static deserializeIdAllowEmptyName(id: string): {
|
|
125
|
+
aspectId: string;
|
|
126
|
+
name?: string;
|
|
127
|
+
};
|
|
128
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Command, CommandOptions } from '@teambit/cli';
|
|
2
|
+
import { Logger } from '@teambit/logger';
|
|
3
|
+
import { Workspace } from '@teambit/workspace';
|
|
4
|
+
import { BuilderMain } from './builder.main.runtime';
|
|
5
|
+
type BuildOpts = {
|
|
6
|
+
all: boolean;
|
|
7
|
+
unmodified?: boolean;
|
|
8
|
+
dev: boolean;
|
|
9
|
+
rebuild: boolean;
|
|
10
|
+
install: boolean;
|
|
11
|
+
cachePackagesOnCapsulesRoot: boolean;
|
|
12
|
+
reuseCapsules: boolean;
|
|
13
|
+
tasks: string;
|
|
14
|
+
listTasks?: string;
|
|
15
|
+
skipTests?: boolean;
|
|
16
|
+
failFast?: boolean;
|
|
17
|
+
includeSnap?: boolean;
|
|
18
|
+
includeTag?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class BuilderCmd implements Command {
|
|
21
|
+
private builder;
|
|
22
|
+
private workspace;
|
|
23
|
+
private logger;
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
extendedDescription: string;
|
|
27
|
+
arguments: {
|
|
28
|
+
name: string;
|
|
29
|
+
description: string;
|
|
30
|
+
}[];
|
|
31
|
+
helpUrl: string;
|
|
32
|
+
alias: string;
|
|
33
|
+
group: string;
|
|
34
|
+
options: CommandOptions;
|
|
35
|
+
constructor(builder: BuilderMain, workspace: Workspace, logger: Logger);
|
|
36
|
+
report([pattern]: [string], { all, unmodified, dev, install, cachePackagesOnCapsulesRoot, reuseCapsules, tasks, listTasks, skipTests, failFast, includeSnap, includeTag, }: BuildOpts): Promise<string>;
|
|
37
|
+
private getListTasks;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Pipeline } from './pipeline';
|
|
2
|
+
export interface BuilderEnv {
|
|
3
|
+
/**
|
|
4
|
+
* return a build pipeline instance.
|
|
5
|
+
*/
|
|
6
|
+
build(): Pipeline;
|
|
7
|
+
/**
|
|
8
|
+
* return a snap pipeline instance.
|
|
9
|
+
*/
|
|
10
|
+
snap(): Pipeline;
|
|
11
|
+
/**
|
|
12
|
+
* return a tag pipeline instance.
|
|
13
|
+
*/
|
|
14
|
+
tag(): Pipeline;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Logo: () => import("react/jsx-runtime").JSX.Element;
|