|
1 |
| -import { experimental, JsonParseMode, parseJson } from '@angular-devkit/core'; |
| 1 | +import { JsonParseMode, parseJson } from '@angular-devkit/core'; |
2 | 2 | import {
|
3 | 3 | SchematicContext,
|
4 | 4 | SchematicsException,
|
5 |
| - Tree |
| 5 | + Tree, |
6 | 6 | } from '@angular-devkit/schematics';
|
| 7 | +import { Workspace } from './interfaces'; |
7 | 8 |
|
8 |
| -function getWorkspace( |
9 |
| - host: Tree |
10 |
| -): { path: string; workspace: experimental.workspace.WorkspaceSchema } { |
| 9 | +function getWorkspace(host: Tree): { path: string; workspace: Workspace } { |
11 | 10 | const possibleFiles = ['/angular.json', '/.angular.json'];
|
12 |
| - const path = possibleFiles.filter(path => host.exists(path))[0]; |
| 11 | + const path = possibleFiles.filter((path) => host.exists(path))[0]; |
13 | 12 |
|
14 | 13 | const configBuffer = host.read(path);
|
15 | 14 | if (configBuffer === null) {
|
16 | 15 | throw new SchematicsException(`Could not find angular.json`);
|
17 | 16 | }
|
18 | 17 | const content = configBuffer.toString();
|
19 | 18 |
|
20 |
| - let workspace: experimental.workspace.WorkspaceSchema; |
| 19 | + let workspace: Workspace; |
21 | 20 | try {
|
22 |
| - workspace = (parseJson( |
23 |
| - content, |
24 |
| - JsonParseMode.Loose |
25 |
| - ) as {}) as experimental.workspace.WorkspaceSchema; |
| 21 | + workspace = (parseJson(content, JsonParseMode.Loose) as {}) as Workspace; |
26 | 22 | } catch (e) {
|
27 | 23 | throw new SchematicsException(`Could not parse angular.json: ` + e.message);
|
28 | 24 | }
|
29 | 25 |
|
30 | 26 | return {
|
31 | 27 | path,
|
32 |
| - workspace |
| 28 | + workspace, |
33 | 29 | };
|
34 | 30 | }
|
35 | 31 | interface NgAddOptions {
|
@@ -78,7 +74,7 @@ export const ngAdd = (options: NgAddOptions) => (
|
78 | 74 |
|
79 | 75 | project.architect['deploy'] = {
|
80 | 76 | builder: 'angular-cli-ghpages:deploy',
|
81 |
| - options: {} |
| 77 | + options: {}, |
82 | 78 | };
|
83 | 79 |
|
84 | 80 | tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));
|
|
0 commit comments