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.io/license
|
---|
7 | */
|
---|
8 | /// <reference types="node" />
|
---|
9 | import { BuilderHandlerFn, BuilderInfo, BuilderOutput } from '@angular-devkit/architect';
|
---|
10 | import { TestProjectHost } from '@angular-devkit/architect/testing';
|
---|
11 | import { json, logging } from '@angular-devkit/core';
|
---|
12 | import { Observable } from 'rxjs';
|
---|
13 | export interface BuilderHarnessExecutionResult<T extends BuilderOutput = BuilderOutput> {
|
---|
14 | result?: T;
|
---|
15 | error?: Error;
|
---|
16 | logs: readonly logging.LogEntry[];
|
---|
17 | }
|
---|
18 | export interface BuilderHarnessExecutionOptions {
|
---|
19 | configuration: string;
|
---|
20 | outputLogsOnFailure: boolean;
|
---|
21 | outputLogsOnException: boolean;
|
---|
22 | useNativeFileWatching: boolean;
|
---|
23 | }
|
---|
24 | export declare class BuilderHarness<T> {
|
---|
25 | private readonly builderHandler;
|
---|
26 | private readonly host;
|
---|
27 | private readonly builderInfo;
|
---|
28 | private schemaRegistry;
|
---|
29 | private projectName;
|
---|
30 | private projectMetadata;
|
---|
31 | private targetName?;
|
---|
32 | private options;
|
---|
33 | private builderTargets;
|
---|
34 | private watcherNotifier?;
|
---|
35 | constructor(builderHandler: BuilderHandlerFn<T & json.JsonObject>, host: TestProjectHost, builderInfo?: Partial<BuilderInfo>);
|
---|
36 | useProject(name: string, metadata?: Record<string, unknown>): this;
|
---|
37 | useTarget(name: string, baseOptions: T): this;
|
---|
38 | withConfiguration(configuration: string, options: T): this;
|
---|
39 | withBuilderTarget<O>(target: string, handler: BuilderHandlerFn<O & json.JsonObject>, options?: O, info?: Partial<BuilderInfo>): this;
|
---|
40 | execute(options?: Partial<BuilderHarnessExecutionOptions>): Observable<BuilderHarnessExecutionResult>;
|
---|
41 | executeOnce(options?: Partial<BuilderHarnessExecutionOptions>): Promise<BuilderHarnessExecutionResult>;
|
---|
42 | appendToFile(path: string, content: string): Promise<void>;
|
---|
43 | writeFile(path: string, content: string | Buffer): Promise<void>;
|
---|
44 | writeFiles(files: Record<string, string | Buffer>): Promise<void>;
|
---|
45 | removeFile(path: string): Promise<void>;
|
---|
46 | modifyFile(path: string, modifier: (content: string) => string | Promise<string>): Promise<void>;
|
---|
47 | hasFile(path: string): boolean;
|
---|
48 | hasFileMatch(directory: string, pattern: RegExp): boolean;
|
---|
49 | readFile(path: string): string;
|
---|
50 | private validateProjectName;
|
---|
51 | }
|
---|