Skip to content

Commit 341b18d

Browse files
alan-agius4vikerman
authored andcommitted
refactor(@angular-devkit/schematics): remove several deprecated APIs
BREAKING CHANGE: Removed several deprecated APIs: - EngineHost `listSchematics` has been removed in favour of `listSchematicNames`. - `FileSystemSink` - Use the new virtualFs.Host classes from `@angular-devkit/core`. - `optimize` function has been remove as trees are automaticlly optimized. - `DryRunSink` deprecated constructor that allowed to provide a directory path has been removed. Provide a `virtualFs.Host` instead.
1 parent 1404e50 commit 341b18d

12 files changed

Lines changed: 10 additions & 70 deletions

File tree

etc/api/angular_devkit/schematics/src/_golden-api.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ export declare class DryRunSink extends HostSink {
176176
protected _fileDoesNotExistExceptionSet: Set<string>;
177177
protected _subject: Subject<DryRunEvent>;
178178
readonly reporter: Observable<DryRunEvent>;
179-
constructor(dir: string, force?: boolean);
180179
constructor(host: virtualFs.Host, force?: boolean);
181180
_done(): Observable<void>;
182181
protected _fileAlreadyExistException(path: string): void;
@@ -215,7 +214,6 @@ export interface EngineHost<CollectionMetadataT extends object, SchematicMetadat
215214
getSchematicRuleFactory<OptionT extends object>(schematic: SchematicDescription<CollectionMetadataT, SchematicMetadataT>, collection: CollectionDescription<CollectionMetadataT>): RuleFactory<OptionT>;
216215
hasTaskExecutor(name: string): boolean;
217216
listSchematicNames(collection: CollectionDescription<CollectionMetadataT>): string[];
218-
listSchematics(collection: Collection<CollectionMetadataT, SchematicMetadataT>): string[];
219217
transformContext(context: TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>): TypedSchematicContext<CollectionMetadataT, SchematicMetadataT> | void;
220218
transformOptions<OptionT extends object, ResultT extends object>(schematic: SchematicDescription<CollectionMetadataT, SchematicMetadataT>, options: OptionT, context?: TypedSchematicContext<CollectionMetadataT, SchematicMetadataT>): Observable<ResultT>;
221219
}
@@ -246,10 +244,6 @@ export interface FilePredicate<T> {
246244
(path: Path, entry?: Readonly<FileEntry> | null): T;
247245
}
248246

249-
export declare class FileSystemSink extends HostSink {
250-
constructor(dir: string, force?: boolean);
251-
}
252-
253247
export declare type FileVisitor = FilePredicate<void>;
254248

255249
export declare const FileVisitorCancelToken: symbol;

etc/api/angular_devkit/schematics/tools/index.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export declare abstract class FileSystemEngineHostBase implements FileSystemEngi
6767
getSchematicRuleFactory<OptionT extends object>(schematic: FileSystemSchematicDesc, _collection: FileSystemCollectionDesc): RuleFactory<OptionT>;
6868
hasTaskExecutor(name: string): boolean;
6969
listSchematicNames(collection: FileSystemCollectionDesc): string[];
70-
listSchematics(collection: FileSystemCollection): string[];
7170
registerContextTransform(t: ContextTransform): void;
7271
registerOptionsTransform<T extends object, R extends object>(t: OptionTransform<T, R>): void;
7372
registerTaskExecutor<T>(factory: TaskExecutorFactory<T>, options?: T): void;

packages/angular_devkit/schematics/src/engine/interface.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ export type SchematicDescription<CollectionMetadataT extends object,
7777
*/
7878
export interface EngineHost<CollectionMetadataT extends object, SchematicMetadataT extends object> {
7979
createCollectionDescription(name: string): CollectionDescription<CollectionMetadataT>;
80-
/**
81-
* @deprecated Use `listSchematicNames`.
82-
*/
83-
listSchematics(collection: Collection<CollectionMetadataT, SchematicMetadataT>): string[];
8480
listSchematicNames(collection: CollectionDescription<CollectionMetadataT>): string[];
8581

8682
createSchematicDescription(

packages/angular_devkit/schematics/src/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88
import { FilePredicate, MergeStrategy, Tree as TreeInterface } from './tree/interface';
9-
import { branch, empty, merge, optimize, partition } from './tree/static';
9+
import { branch, empty, merge, partition } from './tree/static';
1010

1111

1212
export { SchematicsException } from './exception/exception';
@@ -28,7 +28,6 @@ export * from './tree/host-tree';
2828
export { UpdateRecorder } from './tree/interface';
2929
export * from './engine/schematic';
3030
export * from './sink/dryrun';
31-
export * from './sink/filesystem';
3231
export * from './sink/host';
3332
export * from './sink/sink';
3433

@@ -58,5 +57,5 @@ export const Tree: TreeConstructor = {
5857
partition(tree: TreeInterface, predicate: FilePredicate<boolean>) {
5958
return partition(tree, predicate);
6059
},
61-
optimize(tree: TreeInterface) { return optimize(tree); },
60+
optimize(tree: TreeInterface) { return tree; },
6261
};

packages/angular_devkit/schematics/src/sink/dryrun.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ export class DryRunSink extends HostSink {
5050

5151
readonly reporter: Observable<DryRunEvent> = this._subject.asObservable();
5252

53-
/**
54-
* @deprecated Use the virtualFs.Host constructor instead.
55-
*/
56-
constructor(dir: string, force?: boolean);
57-
5853
/**
5954
* @param {host} dir The host to use to output. This should be scoped.
6055
* @param {boolean} force Whether to force overwriting files that already exist.

packages/angular_devkit/schematics/src/sink/dryrun_spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import { Path, normalize, virtualFs } from '@angular-devkit/core';
1010
import { toArray } from 'rxjs/operators';
1111
import { HostCreateTree, HostTree } from '../tree/host-tree';
12-
import { optimize } from '../tree/static';
1312
import { DryRunSink } from './dryrun';
1413

1514

@@ -47,7 +46,7 @@ describe('DryRunSink', () => {
4746
})
4847
.then(done, done.fail);
4948

50-
sink.commit(optimize(tree))
49+
sink.commit(tree)
5150
.toPromise().then(done, done.fail);
5251
});
5352

@@ -78,7 +77,7 @@ describe('DryRunSink', () => {
7877
})
7978
.then(done, done.fail);
8079

81-
sink.commit(optimize(tree))
80+
sink.commit(tree)
8281
.toPromise().then(done, done.fail);
8382
});
8483
});

packages/angular_devkit/schematics/src/sink/filesystem.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

packages/angular_devkit/schematics/src/sink/host_spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import { normalize, virtualFs } from '@angular-devkit/core';
1010
import { HostSink } from '@angular-devkit/schematics';
1111
import { HostCreateTree, HostTree } from '../tree/host-tree';
12-
import { optimize } from '../tree/static';
1312

1413

1514
describe('FileSystemSink', () => {
@@ -34,7 +33,7 @@ describe('FileSystemSink', () => {
3433

3534
const outputHost = new virtualFs.test.TestHost();
3635
const sink = new HostSink(outputHost);
37-
sink.commit(optimize(tree))
36+
sink.commit(tree)
3837
.toPromise()
3938
.then(() => {
4039
const tmpFiles = outputHost.files.sort();
@@ -57,7 +56,7 @@ describe('FileSystemSink', () => {
5756

5857
const outputHost = new virtualFs.test.TestHost();
5958
const sink = new HostSink(outputHost);
60-
sink.commit(optimize(tree))
59+
sink.commit(tree)
6160
.toPromise()
6261
.then(done, done.fail);
6362
});
@@ -70,7 +69,7 @@ describe('FileSystemSink', () => {
7069
tree.rename('/file0', '/file1');
7170

7271
const sink = new HostSink(host);
73-
sink.commit(optimize(tree))
72+
sink.commit(tree)
7473
.toPromise()
7574
.then(() => {
7675
expect(host.sync.exists(normalize('/file0'))).toBe(false);
@@ -88,7 +87,7 @@ describe('FileSystemSink', () => {
8887
tree.rename('/sub/directory/file2', '/another-directory/file2');
8988

9089
const sink = new HostSink(host);
91-
sink.commit(optimize(tree))
90+
sink.commit(tree)
9291
.toPromise()
9392
.then(() => {
9493
expect(host.sync.exists(normalize('/sub/directory/file2'))).toBe(false);
@@ -106,7 +105,7 @@ describe('FileSystemSink', () => {
106105
tree.create('/file0', 'hello');
107106

108107
const sink = new HostSink(host);
109-
sink.commit(optimize(tree))
108+
sink.commit(tree)
110109
.toPromise()
111110
.then(() => {
112111
expect(host.sync.read(normalize('/file0')).toString()).toBe('hello');
@@ -128,7 +127,7 @@ describe('FileSystemSink', () => {
128127
expect(tree.exists('/file0')).toBeTruthy();
129128

130129
const sink = new HostSink(host);
131-
sink.commit(optimize(tree))
130+
sink.commit(tree)
132131
.toPromise()
133132
.then(() => {
134133
expect(host.sync.read(normalize('/file0')).toString()).toBe('hello');

packages/angular_devkit/schematics/src/tree/static.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,3 @@ export function partition(tree: Tree, predicate: FilePredicate<boolean>): [Tree,
3434
throw new SchematicsException('Tree type is not supported.');
3535
}
3636
}
37-
38-
/** @deprecated Tree's are automically optimized */
39-
export function optimize(tree: Tree) {
40-
return tree;
41-
}

packages/angular_devkit/schematics/src/workflow/base.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { HostSink } from '../sink/host';
1616
import { Sink } from '../sink/sink';
1717
import { HostTree } from '../tree/host-tree';
1818
import { Tree } from '../tree/interface';
19-
import { optimize } from '../tree/static';
2019
import {
2120
LifeCycleEvent,
2221
RequiredWorkflowExecutionContext,
@@ -165,7 +164,6 @@ export abstract class BaseWorkflow implements Workflow {
165164
of(new HostTree(this._host)),
166165
{ logger: context.logger },
167166
).pipe(
168-
map(tree => optimize(tree)),
169167
concatMap((tree: Tree) => {
170168
// Process all sinks.
171169
return concat(

0 commit comments

Comments
 (0)