mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-16 18:43:42 +08:00
refactor(@angular-devkit/schematics): provide schematic collection description to FileSystemEngineHost resolver
The `_resolveReferenceString` abstract method of the `FileSystemEngineHostBase` class now has a third parameter that provides the collection description of the schematic currently being resolved. This allows the resolver to use any fields/options present within the collection description to adjust the resolution of the schematic. The `encapsulation` optional field is also added to the `FileSystemCollectionDescription` type which will in the future allow control of the `@angular/cli` VM context wrapping on an individual schematic collection basis.
This commit is contained in:
parent
78b3537731
commit
9a5251cff9
@ -59,6 +59,8 @@ export type FileSystemCollectionDesc = CollectionDescription<FileSystemCollectio
|
||||
|
||||
// @public (undocumented)
|
||||
export interface FileSystemCollectionDescription {
|
||||
// (undocumented)
|
||||
readonly encapsulation?: boolean;
|
||||
// (undocumented)
|
||||
readonly name: string;
|
||||
// (undocumented)
|
||||
@ -121,7 +123,7 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost_2
|
||||
// (undocumented)
|
||||
protected abstract _resolveCollectionPath(name: string, requester?: string): string;
|
||||
// (undocumented)
|
||||
protected abstract _resolveReferenceString(name: string, parentPath: string): {
|
||||
protected abstract _resolveReferenceString(name: string, parentPath: string, collectionDescription: FileSystemCollectionDesc): {
|
||||
ref: RuleFactory<{}>;
|
||||
path: string;
|
||||
} | null;
|
||||
@ -183,7 +185,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
|
||||
// (undocumented)
|
||||
protected _resolveCollectionPath(name: string, requester?: string): string;
|
||||
// (undocumented)
|
||||
protected _resolveReferenceString(refString: string, parentPath: string): {
|
||||
protected _resolveReferenceString(refString: string, parentPath: string, collectionDescription?: FileSystemCollectionDesc): {
|
||||
ref: RuleFactory<{}>;
|
||||
path: string;
|
||||
} | null;
|
||||
|
@ -23,6 +23,7 @@ export interface FileSystemCollectionDescription {
|
||||
readonly path: string;
|
||||
readonly version?: string;
|
||||
readonly schematics: { [name: string]: FileSystemSchematicDesc };
|
||||
readonly encapsulation?: boolean;
|
||||
}
|
||||
|
||||
export interface FileSystemSchematicJsonDescription {
|
||||
@ -63,7 +64,8 @@ export declare type FileSystemSchematic = Schematic<
|
||||
FileSystemCollectionDescription,
|
||||
FileSystemSchematicDescription
|
||||
>;
|
||||
export declare type FileSystemCollectionDesc = CollectionDescription<FileSystemCollectionDescription>;
|
||||
export declare type FileSystemCollectionDesc =
|
||||
CollectionDescription<FileSystemCollectionDescription>;
|
||||
export declare type FileSystemSchematicDesc = SchematicDescription<
|
||||
FileSystemCollectionDescription,
|
||||
FileSystemSchematicDescription
|
||||
|
@ -102,6 +102,7 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
|
||||
protected abstract _resolveReferenceString(
|
||||
name: string,
|
||||
parentPath: string,
|
||||
collectionDescription: FileSystemCollectionDesc,
|
||||
): { ref: RuleFactory<{}>; path: string } | null;
|
||||
protected abstract _transformCollectionDescription(
|
||||
name: string,
|
||||
@ -234,7 +235,11 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
|
||||
if (!partialDesc.factory) {
|
||||
throw new SchematicMissingFactoryException(name);
|
||||
}
|
||||
const resolvedRef = this._resolveReferenceString(partialDesc.factory, collectionPath);
|
||||
const resolvedRef = this._resolveReferenceString(
|
||||
partialDesc.factory,
|
||||
collectionPath,
|
||||
collection,
|
||||
);
|
||||
if (!resolvedRef) {
|
||||
throw new FactoryCannotBeResolvedException(name);
|
||||
}
|
||||
|
@ -98,7 +98,11 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
|
||||
return collectionPath;
|
||||
}
|
||||
|
||||
protected _resolveReferenceString(refString: string, parentPath: string) {
|
||||
protected _resolveReferenceString(
|
||||
refString: string,
|
||||
parentPath: string,
|
||||
collectionDescription?: FileSystemCollectionDesc,
|
||||
) {
|
||||
const ref = new ExportStringRef<RuleFactory<{}>>(refString, parentPath);
|
||||
if (!ref.ref) {
|
||||
return null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user