File tree Expand file tree Collapse file tree 5 files changed +15
-5
lines changed
etc/api/angular_devkit/schematics/tools
angular_devkit/schematics/tools Expand file tree Collapse file tree 5 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ export declare class InvalidCollectionJsonException extends BaseException {
105
105
}
106
106
107
107
export declare class NodeModulesEngineHost extends FileSystemEngineHostBase {
108
- constructor ( ) ;
108
+ constructor ( paths ?: string [ ] | undefined ) ;
109
109
protected _resolveCollectionPath ( name : string ) : string ;
110
110
protected _resolveReferenceString ( refString : string , parentPath : string ) : {
111
111
ref : RuleFactory < { } > ;
@@ -136,6 +136,7 @@ export declare class NodeWorkflow extends workflow.BaseWorkflow {
136
136
root ?: Path ;
137
137
packageManager ?: string ;
138
138
registry ?: schema . CoreSchemaRegistry ;
139
+ resolvePaths ?: string [ ] ;
139
140
} ) ;
140
141
}
141
142
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ export class UpdateCommand extends Command<UpdateCommandSchema> {
50
50
{
51
51
packageManager : this . packageManager ,
52
52
root : normalize ( this . workspace . root ) ,
53
+ // __dirname -> favor @schematics/update from this package
54
+ // Otherwise, use packages from the active workspace (migrations)
55
+ resolvePaths : [ __dirname , this . workspace . root ] ,
53
56
} ,
54
57
) ;
55
58
this . workflow . engineHost . registerOptionsTransform (
Original file line number Diff line number Diff line change @@ -253,6 +253,11 @@ export abstract class SchematicCommand<
253
253
packageManager : await getPackageManager ( this . workspace . root ) ,
254
254
root : normalize ( this . workspace . root ) ,
255
255
registry : new schema . CoreSchemaRegistry ( formats . standardFormats ) ,
256
+ resolvePaths : ! ! this . workspace . configFile
257
+ // Workspace
258
+ ? [ process . cwd ( ) , this . workspace . root ]
259
+ // Global
260
+ : [ __dirname , process . cwd ( ) ] ,
256
261
} ) ;
257
262
workflow . engineHost . registerContextTransform ( context => {
258
263
// This is run by ALL schematics, so if someone uses `externalSchematics(...)` which
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ export class NodePackageDoesNotSupportSchematics extends BaseException {
37
37
* A simple EngineHost that uses NodeModules to resolve collections.
38
38
*/
39
39
export class NodeModulesEngineHost extends FileSystemEngineHostBase {
40
- constructor ( ) { super ( ) ; }
40
+ constructor ( private readonly paths ?: string [ ] ) { super ( ) ; }
41
41
42
42
protected _resolveCollectionPath ( name : string ) : string {
43
43
let collectionPath : string | undefined = undefined ;
@@ -47,9 +47,9 @@ export class NodeModulesEngineHost extends FileSystemEngineHostBase {
47
47
48
48
if ( extname ( name ) ) {
49
49
// When having an extension let's just resolve the provided path.
50
- collectionPath = require . resolve ( name ) ;
50
+ collectionPath = require . resolve ( name , { paths : this . paths } ) ;
51
51
} else {
52
- const packageJsonPath = require . resolve ( join ( name , 'package.json' ) ) ;
52
+ const packageJsonPath = require . resolve ( join ( name , 'package.json' ) , { paths : this . paths } ) ;
53
53
const { schematics } = require ( packageJsonPath ) ;
54
54
55
55
if ( ! schematics || typeof schematics !== 'string' ) {
Original file line number Diff line number Diff line change @@ -25,9 +25,10 @@ export class NodeWorkflow extends workflow.BaseWorkflow {
25
25
root ?: Path ;
26
26
packageManager ?: string ;
27
27
registry ?: schema . CoreSchemaRegistry ;
28
+ resolvePaths ?: string [ ] ,
28
29
} ,
29
30
) {
30
- const engineHost = new NodeModulesEngineHost ( ) ;
31
+ const engineHost = new NodeModulesEngineHost ( options . resolvePaths ) ;
31
32
super ( {
32
33
host,
33
34
engineHost,
You can’t perform that action at this time.
0 commit comments