UNPKG

2.73 kBTypeScriptView Raw
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 */
8import { WorkspaceDefinition } from './definitions';
9import { WorkspaceHost } from './host';
10/**
11 * Supported workspace formats
12 */
13export declare enum WorkspaceFormat {
14 JSON = 0
15}
16/**
17 * @private
18 */
19export declare function _test_addWorkspaceFile(name: string, format: WorkspaceFormat): void;
20/**
21 * @private
22 */
23export declare function _test_removeWorkspaceFile(name: string): void;
24/**
25 * Reads and constructs a `WorkspaceDefinition`. If the function is provided with a path to a
26 * directory instead of a file, a search of the directory's files will commence to attempt to
27 * locate a known workspace file. Currently the following are considered known workspace files:
28 * - `angular.json`
29 * - `.angular.json`
30 *
31 * @param path The path to either a workspace file or a directory containing a workspace file.
32 * @param host The `WorkspaceHost` to use to access the file and directory data.
33 * @param format An optional `WorkspaceFormat` value. Used if the path specifies a non-standard
34 * file name that would prevent automatically discovering the format.
35 *
36 *
37 * @return An `Promise` of the read result object with the `WorkspaceDefinition` contained within
38 * the `workspace` property.
39 */
40export declare function readWorkspace(path: string, host: WorkspaceHost, format?: WorkspaceFormat): Promise<{
41 workspace: WorkspaceDefinition;
42}>;
43/**
44 * Writes a `WorkspaceDefinition` to the underlying storage via the provided `WorkspaceHost`.
45 * If the `WorkspaceDefinition` was created via the `readWorkspace` function, metadata will be
46 * used to determine the path and format of the Workspace. In all other cases, the `path` and
47 * `format` options must be specified as they would be otherwise unknown.
48 *
49 * @param workspace The `WorkspaceDefinition` that will be written.
50 * @param host The `WorkspaceHost` to use to access/write the file and directory data.
51 * @param path The path to a file location for the output. Required if `readWorkspace` was not
52 * used to create the `WorkspaceDefinition`. Optional otherwise; will override the
53 * `WorkspaceDefinition` metadata if provided.
54 * @param format The `WorkspaceFormat` to use for output. Required if `readWorkspace` was not
55 * used to create the `WorkspaceDefinition`. Optional otherwise; will override the
56 * `WorkspaceDefinition` metadata if provided.
57 *
58 *
59 * @return An `Promise` of type `void`.
60 */
61export declare function writeWorkspace(workspace: WorkspaceDefinition, host: WorkspaceHost, path?: string, format?: WorkspaceFormat): Promise<void>;