Skip to content

Commit d18f89d

Browse files
clydinhansl
authored andcommitted
refactor(@angular-devkit/schematics): remove unused VirtualTree classes
1 parent 926b569 commit d18f89d

File tree

11 files changed

+4
-1208
lines changed

11 files changed

+4
-1208
lines changed

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

-79
Original file line numberDiff line numberDiff line change
@@ -244,35 +244,10 @@ export interface FilePredicate<T> {
244244
(path: Path, entry?: Readonly<FileEntry> | null): T;
245245
}
246246

247-
export declare class FileSystemCreateTree extends FileSystemTree {
248-
constructor(host: virtualFs.Host);
249-
}
250-
251-
export declare class FileSystemDirEntry extends VirtualDirEntry {
252-
protected _host: virtualFs.SyncDelegateHost<{}>;
253-
readonly parent: DirEntry | null;
254-
readonly subdirs: PathFragment[];
255-
readonly subfiles: PathFragment[];
256-
constructor(_host: virtualFs.SyncDelegateHost<{}>, tree: FileSystemTree, path?: Path);
257-
protected _createDir(name: PathFragment): DirEntry;
258-
file(name: PathFragment): FileEntry | null;
259-
}
260-
261247
export declare class FileSystemSink extends HostSink {
262248
constructor(dir: string, force?: boolean);
263249
}
264250

265-
export declare class FileSystemTree extends VirtualTree {
266-
protected _host: virtualFs.SyncDelegateHost<{}>;
267-
protected _initialized: boolean;
268-
readonly tree: Map<Path, FileEntry>;
269-
constructor(host: virtualFs.Host);
270-
protected _copyTo<T extends VirtualTree>(tree: T): void;
271-
protected _recursiveFileList(): Path[];
272-
branch(): Tree;
273-
get(path: string): FileEntry | null;
274-
}
275-
276251
export declare type FileVisitor = FilePredicate<void>;
277252

278253
export declare const FileVisitorCancelToken: symbol;
@@ -634,60 +609,6 @@ export interface UpdateRecorder {
634609

635610
export declare function url(urlString: string): Source;
636611

637-
export declare class VirtualDirEntry implements DirEntry {
638-
protected _path: Path;
639-
protected _subdirs: Map<PathFragment, DirEntry>;
640-
protected _tree: VirtualTree;
641-
readonly parent: DirEntry | null;
642-
readonly path: Path;
643-
readonly subdirs: PathFragment[];
644-
readonly subfiles: PathFragment[];
645-
constructor(_tree: VirtualTree, _path?: Path);
646-
protected _createDir(name: PathFragment): DirEntry;
647-
dir(name: PathFragment): DirEntry;
648-
file(name: PathFragment): FileEntry | null;
649-
visit(visitor: FileVisitor): void;
650-
}
651-
652-
export declare class VirtualTree implements Tree {
653-
protected _actions: ActionList;
654-
protected _cacheMap: Map<Path, FileEntry>;
655-
protected _root: VirtualDirEntry;
656-
protected _tree: Map<Path, FileEntry>;
657-
readonly actions: Action[];
658-
readonly files: Path[];
659-
readonly root: DirEntry;
660-
readonly staging: ReadonlyMap<Path, FileEntry>;
661-
protected readonly tree: ReadonlyMap<Path, FileEntry>;
662-
protected _copyTo<T extends VirtualTree>(tree: T): void;
663-
protected _create(path: Path, content: Buffer, action?: Action): void;
664-
protected _delete(path: Path, action?: Action): void;
665-
protected _normalizePath(path: string): Path;
666-
protected _overwrite(path: Path, content: Buffer, action?: Action): void;
667-
protected _rename(path: Path, to: Path, action?: Action, force?: boolean): void;
668-
apply(action: Action, strategy: MergeStrategy): void;
669-
beginUpdate(path: string): UpdateRecorder;
670-
branch(): Tree;
671-
commitUpdate(record: UpdateRecorder): void;
672-
create(path: string, content: Buffer | string): void;
673-
delete(path: string): void;
674-
exists(path: string): boolean;
675-
get(path: string): FileEntry | null;
676-
getDir(path: string): DirEntry;
677-
has(path: string): boolean;
678-
merge(other: Tree, strategy?: MergeStrategy): void;
679-
optimize(): void;
680-
overwrite(path: string, content: Buffer | string): void;
681-
read(path: string): Buffer | null;
682-
rename(path: string, to: string): void;
683-
set(entry: FileEntry): Map<Path, FileEntry>;
684-
visit(visitor: FileVisitor): void;
685-
static branch(tree: Tree): Tree;
686-
static isVirtualTree(tree: Tree): tree is VirtualTree;
687-
static merge(tree: Tree, other: Tree, strategy?: MergeStrategy): Tree;
688-
static optimize(tree: Tree): VirtualTree;
689-
}
690-
691612
export declare function when(predicate: FilePredicate<boolean>, operator: FileOperator): FileOperator;
692613

693614
export interface Workflow {

packages/angular_devkit/schematics/src/index.ts

-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export * from './rules/url';
2525
export * from './tree/delegate';
2626
export * from './tree/empty';
2727
export * from './tree/host-tree';
28-
export * from './tree/filesystem';
29-
export * from './tree/virtual';
3028
export {UpdateRecorder} from './tree/interface';
3129
export * from './engine/schematic';
3230
export * from './sink/dryrun';

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

+2-25
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@ import { Observable, of as observableOf } from 'rxjs';
99
import { concatMap, last, map } from 'rxjs/operators';
1010
import { FileOperator, Rule, SchematicContext, Source } from '../engine/interface';
1111
import { SchematicsException } from '../exception/exception';
12-
import { FilteredTree } from '../tree/filtered';
1312
import { FilterHostTree, HostTree } from '../tree/host-tree';
1413
import { FileEntry, FilePredicate, MergeStrategy, Tree } from '../tree/interface';
1514
import { ScopedTree } from '../tree/scoped';
1615
import {
1716
branch,
1817
empty as staticEmpty,
1918
merge as staticMerge,
20-
optimize as staticOptimize,
2119
partition as staticPartition,
2220
} from '../tree/static';
23-
import { VirtualTree } from '../tree/virtual';
2421
import { callRule, callSource } from './call';
2522

2623

@@ -56,24 +53,7 @@ export function chain(rules: Rule[]): Rule {
5653
* Apply multiple rules to a source, and returns the source transformed.
5754
*/
5855
export function apply(source: Source, rules: Rule[]): Source {
59-
return (context: SchematicContext) => {
60-
return callRule(chain([
61-
...rules,
62-
// Optimize the tree. Since this is a source tree, there's not much harm here and this might
63-
// avoid further issues.
64-
tree => {
65-
if (tree instanceof VirtualTree) {
66-
tree.optimize();
67-
68-
return tree;
69-
} else if (tree.actions.length != 0) {
70-
return staticOptimize(tree);
71-
} else {
72-
return tree;
73-
}
74-
},
75-
]), callSource(source, context), context);
76-
};
56+
return context => callRule(chain(rules), callSource(source, context), context);
7757
}
7858

7959

@@ -96,10 +76,7 @@ export function noop(): Rule {
9676

9777
export function filter(predicate: FilePredicate<boolean>): Rule {
9878
return ((tree: Tree) => {
99-
// TODO: Remove VirtualTree usage in 7.0
100-
if (VirtualTree.isVirtualTree(tree)) {
101-
return new FilteredTree(tree, predicate);
102-
} else if (HostTree.isHostTree(tree)) {
79+
if (HostTree.isHostTree(tree)) {
10380
return new FilterHostTree(tree, predicate);
10481
} else {
10582
throw new SchematicsException('Tree type is not supported.');

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

-185
This file was deleted.

0 commit comments

Comments
 (0)