1 | /**
|
2 | * @license
|
3 | * Copyright Google LLC All Rights Reserved.
|
4 | *
|
5 | * Use of this source code is governed by an MIT-style license that can be
|
6 | * found in the LICENSE file at https://angular.dev/license
|
7 | */
|
8 | import { json } from '@angular-devkit/core';
|
9 | import { BuilderInfo, BuilderInput, BuilderOutput, Target } from './api';
|
10 | import { JobDescription, JobHandler } from './jobs';
|
11 | /**
|
12 | * BuilderSymbol used for knowing if a function was created using createBuilder(). This is a
|
13 | * property set on the function that should be `true`.
|
14 | * Using Symbol.for() as it's a global registry that's the same for all installations of
|
15 | * Architect (if some libraries depends directly on architect instead of sharing the files).
|
16 | */
|
17 | export declare const BuilderSymbol: unique symbol;
|
18 | /**
|
19 | * BuilderVersionSymbol used for knowing which version of the library createBuilder() came from.
|
20 | * This is to make sure we don't try to use an incompatible builder.
|
21 | * Using Symbol.for() as it's a global registry that's the same for all installations of
|
22 | * Architect (if some libraries depends directly on architect instead of sharing the files).
|
23 | */
|
24 | export declare const BuilderVersionSymbol: unique symbol;
|
25 | /**
|
26 | * A Specialization of the JobHandler type. This exposes BuilderDescription as the job description
|
27 | * type.
|
28 | */
|
29 | export type BuilderJobHandler<A extends json.JsonObject = json.JsonObject, I extends BuilderInput = BuilderInput, O extends BuilderOutput = BuilderOutput> = JobHandler<A, I, O> & {
|
30 | jobDescription: BuilderDescription;
|
31 | };
|
32 | /**
|
33 | * A Builder description, which is used internally. Adds the builder info which is the
|
34 | * metadata attached to a builder in Architect.
|
35 | */
|
36 | export interface BuilderDescription extends JobDescription {
|
37 | info: BuilderInfo;
|
38 | }
|
39 | /**
|
40 | * A Builder instance. Use createBuilder() to create one of these.
|
41 | */
|
42 | export interface Builder<OptionT extends json.JsonObject = json.JsonObject> {
|
43 | handler: JobHandler<json.JsonObject, BuilderInput, BuilderOutput>;
|
44 | [BuilderSymbol]: true;
|
45 | [BuilderVersionSymbol]: string;
|
46 | __OptionT: OptionT;
|
47 | }
|
48 | export interface ArchitectHost<BuilderInfoT extends BuilderInfo = BuilderInfo> {
|
49 | /**
|
50 | * Get the builder name for a target.
|
51 | * @param target The target to inspect.
|
52 | */
|
53 | getBuilderNameForTarget(target: Target): Promise<string | null>;
|
54 | /**
|
55 | * Resolve a builder. This needs to return a string which will be used in a dynamic `import()`
|
56 | * clause. This should throw if no builder can be found. The dynamic import will throw if
|
57 | * it is unsupported.
|
58 | * @param builderName The name of the builder to be used.
|
59 | * @returns All the info needed for the builder itself.
|
60 | */
|
61 | resolveBuilder(builderName: string): Promise<BuilderInfoT | null>;
|
62 | loadBuilder(info: BuilderInfoT): Promise<Builder | null>;
|
63 | getCurrentDirectory(): Promise<string>;
|
64 | getWorkspaceRoot(): Promise<string>;
|
65 | getOptionsForTarget(target: Target): Promise<json.JsonObject | null>;
|
66 | getProjectMetadata(projectName: string): Promise<json.JsonObject | null>;
|
67 | getProjectMetadata(target: Target): Promise<json.JsonObject | null>;
|
68 | }
|