Skip to content

Commit 4a4e47a

Browse files
committed
feat: add support for Angular v11
1 parent c4e5275 commit 4a4e47a

File tree

4 files changed

+2767
-2941
lines changed

4 files changed

+2767
-2941
lines changed

src/interfaces.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,16 @@ export interface GHPages {
22
publish(dir: string, options: any, callback: (error: any) => void);
33
clean?(): void;
44
}
5+
6+
export interface WorkspaceProject {
7+
projectType?: string;
8+
architect?: Record<
9+
string,
10+
{ builder: string; options?: Record<string, any> }
11+
>;
12+
}
13+
14+
export interface Workspace {
15+
defaultProject?: string;
16+
projects: Record<string, WorkspaceProject>;
17+
}

src/ng-add.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,31 @@
1-
import { experimental, JsonParseMode, parseJson } from '@angular-devkit/core';
1+
import { JsonParseMode, parseJson } from '@angular-devkit/core';
22
import {
33
SchematicContext,
44
SchematicsException,
5-
Tree
5+
Tree,
66
} from '@angular-devkit/schematics';
7+
import { Workspace } from './interfaces';
78

8-
function getWorkspace(
9-
host: Tree
10-
): { path: string; workspace: experimental.workspace.WorkspaceSchema } {
9+
function getWorkspace(host: Tree): { path: string; workspace: Workspace } {
1110
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];
1312

1413
const configBuffer = host.read(path);
1514
if (configBuffer === null) {
1615
throw new SchematicsException(`Could not find angular.json`);
1716
}
1817
const content = configBuffer.toString();
1918

20-
let workspace: experimental.workspace.WorkspaceSchema;
19+
let workspace: Workspace;
2120
try {
22-
workspace = (parseJson(
23-
content,
24-
JsonParseMode.Loose
25-
) as {}) as experimental.workspace.WorkspaceSchema;
21+
workspace = (parseJson(content, JsonParseMode.Loose) as {}) as Workspace;
2622
} catch (e) {
2723
throw new SchematicsException(`Could not parse angular.json: ` + e.message);
2824
}
2925

3026
return {
3127
path,
32-
workspace
28+
workspace,
3329
};
3430
}
3531
interface NgAddOptions {
@@ -78,7 +74,7 @@ export const ngAdd = (options: NgAddOptions) => (
7874

7975
project.architect['deploy'] = {
8076
builder: 'angular-cli-ghpages:deploy',
81-
options: {}
77+
options: {},
8278
};
8379

8480
tree.overwrite(workspacePath, JSON.stringify(workspace, null, 2));

0 commit comments

Comments
 (0)