mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +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)
|
// @public (undocumented)
|
||||||
export interface FileSystemCollectionDescription {
|
export interface FileSystemCollectionDescription {
|
||||||
|
// (undocumented)
|
||||||
|
readonly encapsulation?: boolean;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
@ -121,7 +123,7 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost_2
|
|||||||
// (undocumented)
|
// (undocumented)
|
||||||
protected abstract _resolveCollectionPath(name: string, requester?: string): string;
|
protected abstract _resolveCollectionPath(name: string, requester?: string): string;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
protected abstract _resolveReferenceString(name: string, parentPath: string): {
|
protected abstract _resolveReferenceString(name: string, parentPath: string, collectionDescription: FileSystemCollectionDesc): {
|
||||||
ref: RuleFactory<{}>;
|
ref: RuleFactory<{}>;
|
||||||
path: string;
|
path: string;
|
||||||
} | null;
|
} | null;
|
||||||
@ -183,7 +185,7 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
|
|||||||
// (undocumented)
|
// (undocumented)
|
||||||
protected _resolveCollectionPath(name: string, requester?: string): string;
|
protected _resolveCollectionPath(name: string, requester?: string): string;
|
||||||
// (undocumented)
|
// (undocumented)
|
||||||
protected _resolveReferenceString(refString: string, parentPath: string): {
|
protected _resolveReferenceString(refString: string, parentPath: string, collectionDescription?: FileSystemCollectionDesc): {
|
||||||
ref: RuleFactory<{}>;
|
ref: RuleFactory<{}>;
|
||||||
path: string;
|
path: string;
|
||||||
} | null;
|
} | null;
|
||||||
|
@ -23,6 +23,7 @@ export interface FileSystemCollectionDescription {
|
|||||||
readonly path: string;
|
readonly path: string;
|
||||||
readonly version?: string;
|
readonly version?: string;
|
||||||
readonly schematics: { [name: string]: FileSystemSchematicDesc };
|
readonly schematics: { [name: string]: FileSystemSchematicDesc };
|
||||||
|
readonly encapsulation?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FileSystemSchematicJsonDescription {
|
export interface FileSystemSchematicJsonDescription {
|
||||||
@ -63,7 +64,8 @@ export declare type FileSystemSchematic = Schematic<
|
|||||||
FileSystemCollectionDescription,
|
FileSystemCollectionDescription,
|
||||||
FileSystemSchematicDescription
|
FileSystemSchematicDescription
|
||||||
>;
|
>;
|
||||||
export declare type FileSystemCollectionDesc = CollectionDescription<FileSystemCollectionDescription>;
|
export declare type FileSystemCollectionDesc =
|
||||||
|
CollectionDescription<FileSystemCollectionDescription>;
|
||||||
export declare type FileSystemSchematicDesc = SchematicDescription<
|
export declare type FileSystemSchematicDesc = SchematicDescription<
|
||||||
FileSystemCollectionDescription,
|
FileSystemCollectionDescription,
|
||||||
FileSystemSchematicDescription
|
FileSystemSchematicDescription
|
||||||
|
@ -102,6 +102,7 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
|
|||||||
protected abstract _resolveReferenceString(
|
protected abstract _resolveReferenceString(
|
||||||
name: string,
|
name: string,
|
||||||
parentPath: string,
|
parentPath: string,
|
||||||
|
collectionDescription: FileSystemCollectionDesc,
|
||||||
): { ref: RuleFactory<{}>; path: string } | null;
|
): { ref: RuleFactory<{}>; path: string } | null;
|
||||||
protected abstract _transformCollectionDescription(
|
protected abstract _transformCollectionDescription(
|
||||||
name: string,
|
name: string,
|
||||||
@ -234,7 +235,11 @@ export abstract class FileSystemEngineHostBase implements FileSystemEngineHost {
|
|||||||
if (!partialDesc.factory) {
|
if (!partialDesc.factory) {
|
||||||
throw new SchematicMissingFactoryException(name);
|
throw new SchematicMissingFactoryException(name);
|
||||||
}
|
}
|
||||||
const resolvedRef = this._resolveReferenceString(partialDesc.factory, collectionPath);
|
const resolvedRef = this._resolveReferenceString(
|
||||||
|
partialDesc.factory,
|
||||||
|
collectionPath,
|
||||||
|
collection,
|
||||||
|
);
|
||||||
if (!resolvedRef) {
|
if (!resolvedRef) {
|
||||||
throw new FactoryCannotBeResolvedException(name);
|
throw new FactoryCannotBeResolvedException(name);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,11 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
|
|||||||
return collectionPath;
|
return collectionPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected _resolveReferenceString(refString: string, parentPath: string) {
|
protected _resolveReferenceString(
|
||||||
|
refString: string,
|
||||||
|
parentPath: string,
|
||||||
|
collectionDescription?: FileSystemCollectionDesc,
|
||||||
|
) {
|
||||||
const ref = new ExportStringRef<RuleFactory<{}>>(refString, parentPath);
|
const ref = new ExportStringRef<RuleFactory<{}>>(refString, parentPath);
|
||||||
if (!ref.ref) {
|
if (!ref.ref) {
|
||||||
return null;
|
return null;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user