Skip to content

Commit 25b318e

Browse files
committed
fix(@schematics/angular): fix module discovery
When creating schematics with names that are paths, the path option is the path to create the schematic into. we need to app root to discover the module.
1 parent af3a0d3 commit 25b318e

File tree

19 files changed

+39
-1
lines changed

19 files changed

+39
-1
lines changed

packages/schematics/angular/class/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
export interface Schema {
1010
name: string;
11+
appRoot?: string;
1112
path?: string;
1213
sourceDir?: string;
1314
/**

packages/schematics/angular/class/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"name": {
88
"type": "string"
99
},
10+
"appRoot": {
11+
"type": "string"
12+
},
1013
"path": {
1114
"type": "string",
1215
"default": "app"

packages/schematics/angular/component/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
export interface Schema {
1010
path?: string;
11+
appRoot?: string;
1112
sourceDir?: string;
1213
name: string;
1314
/**

packages/schematics/angular/component/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
"type": "string",
99
"default": "app"
1010
},
11+
"appRoot": {
12+
"type": "string"
13+
},
1114
"sourceDir": {
1215
"type": "string",
1316
"default": "src",

packages/schematics/angular/directive/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
export interface Schema {
1010
name: string;
1111
path?: string;
12+
appRoot?: string;
1213
/**
1314
* The prefix to apply to generated selectors.
1415
*/

packages/schematics/angular/directive/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"type": "string",
1212
"default": "app"
1313
},
14+
"appRoot": {
15+
"type": "string"
16+
},
1417
"prefix": {
1518
"type": "string",
1619
"description": "The prefix to apply to generated selectors.",

packages/schematics/angular/enum/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
export interface Schema {
1010
name: string;
1111
path?: string;
12+
appRoot?: string;
1213
sourceDir?: string;
1314
}

packages/schematics/angular/enum/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"type": "string",
1212
"default": "app"
1313
},
14+
"appRoot": {
15+
"type": "string"
16+
},
1417
"sourceDir": {
1518
"type": "string",
1619
"default": "src"

packages/schematics/angular/guard/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ export interface Schema {
1515
*/
1616
module?: string;
1717
path?: string;
18+
appRoot?: string;
1819
sourceDir?: string;
1920
}

packages/schematics/angular/guard/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
"type": "string",
2626
"default": "app"
2727
},
28+
"appRoot": {
29+
"type": "string"
30+
},
2831
"sourceDir": {
2932
"type": "string",
3033
"default": "src"

packages/schematics/angular/interface/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
export interface Schema {
1010
name: string;
1111
path?: string;
12+
appRoot?: string;
1213
sourceDir?: string;
1314
/**
1415
* Specifies the prefix to use.

packages/schematics/angular/interface/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"type": "string",
1212
"default": "app"
1313
},
14+
"appRoot": {
15+
"type": "string"
16+
},
1417
"sourceDir": {
1518
"type": "string",
1619
"default": "src"

packages/schematics/angular/module/schema.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
export interface Schema {
1010
name: string;
1111
path?: string;
12+
appRoot?: string;
1213
sourceDir?: string;
1314
routing?: boolean;
15+
routingScope?: ('Child' | 'Root');
1416
spec?: boolean;
1517
flat?: boolean;
1618
commonModule?: boolean;

packages/schematics/angular/module/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"type": "string",
1212
"default": "app"
1313
},
14+
"appRoot": {
15+
"type": "string"
16+
},
1417
"sourceDir": {
1518
"type": "string",
1619
"default": "src"

packages/schematics/angular/pipe/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
export interface Schema {
1010
name: string;
1111
path?: string;
12+
appRoot?: string;
1213
sourceDir?: string;
1314
/**
1415
* Flag to indicate if a dir is created.

packages/schematics/angular/pipe/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"type": "string",
1212
"default": "app"
1313
},
14+
"appRoot": {
15+
"type": "string"
16+
},
1417
"sourceDir": {
1518
"type": "string",
1619
"default": "src"

packages/schematics/angular/service/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
export interface Schema {
1010
name: string;
1111
path?: string;
12+
appRoot?: string;
1213
sourceDir?: string;
1314
/**
1415
* Flag to indicate if a dir is created.

packages/schematics/angular/service/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
"type": "string",
1212
"default": "app"
1313
},
14+
"appRoot": {
15+
"type": "string"
16+
},
1417
"sourceDir": {
1518
"type": "string",
1619
"default": "src"

packages/schematics/angular/utility/find-module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface ModuleOptions {
1616
sourceDir?: string;
1717
path?: string;
1818
skipImport?: boolean;
19+
appRoot?: string;
1920
}
2021

2122

@@ -35,7 +36,7 @@ export function findModuleFromOptions(host: Tree,
3536
return normalizePath(findModule(host, pathToCheck));
3637
} else {
3738
const modulePath = normalizePath(
38-
options.sourceDir + '/' + options.path + '/' + options.module);
39+
options.sourceDir + '/' + (options.appRoot || options.path) + '/' + options.module);
3940
const moduleBaseName = normalizePath(modulePath).split('/').pop();
4041

4142
if (host.exists(modulePath)) {

0 commit comments

Comments
 (0)