Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Commit 4fa0167

Browse files
filipesilvahansl
authored andcommitted
refactor(@schematics/angular): use schema format
1 parent e7f3663 commit 4fa0167

File tree

16 files changed

+71
-31
lines changed

16 files changed

+71
-31
lines changed

packages/schematics/angular/app-shell/index_spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ describe('App Shell Schematic', () => {
2525
let appTree: Tree;
2626
const appOptions: ApplicationOptions = {
2727
directory: '',
28-
name: 'app',
29-
prefix: '',
28+
name: 'appshell-app',
3029
sourceDir: 'src',
3130
inlineStyle: false,
3231
inlineTemplate: false,

packages/schematics/angular/app-shell/schema.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,64 +22,77 @@
2222

2323
"name": {
2424
"type": "string",
25+
"format": "app-name",
2526
"description": "Name of the universal app"
2627
},
2728
"appId": {
2829
"type": "string",
30+
"format": "app-name",
2931
"description": "The appId to use withServerTransition.",
3032
"default": "serverApp"
3133
},
3234
"outDir": {
3335
"type": "string",
36+
"format": "path",
3437
"description": "The output directory for build results.",
35-
"default": "dist-server/"
38+
"default": "dist-server"
3639
},
3740
"root": {
3841
"type": "string",
42+
"format": "path",
3943
"description": "The root directory of the app.",
4044
"default": "src"
4145
},
4246
"index": {
4347
"type": "string",
48+
"format": "path",
4449
"description": "Name of the index file",
4550
"default": "index.html"
4651
},
4752
"main": {
4853
"type": "string",
54+
"format": "path",
4955
"description": "The name of the main entry-point file.",
5056
"default": "main.server.ts"
5157
},
5258
"test": {
5359
"type": "string",
60+
"format": "path",
5461
"description": "The name of the test entry-point file."
5562
},
5663
"tsconfigFileName": {
5764
"type": "string",
65+
"format": "path",
5866
"default": "tsconfig.server",
5967
"description": "The name of the TypeScript configuration file."
6068
},
6169
"testTsconfigFileName": {
6270
"type": "string",
71+
"format": "path",
6372
"description": "The name of the TypeScript configuration file for tests.",
6473
"default": "tsconfig.spec"
6574
},
6675
"appDir": {
6776
"type": "string",
77+
"format": "path",
6878
"description": "The name of the application directory.",
6979
"default": "app"
7080
},
7181
"rootModuleFileName": {
7282
"type": "string",
83+
"format": "path",
7384
"description": "The name of the root module file",
7485
"default": "app.server.module.ts"
7586
},
7687
"rootModuleClassName": {
7788
"type": "string",
89+
"format": "app-name",
7890
"description": "The name of the root module class.",
7991
"default": "AppServerModule"
8092
},
8193
"sourceDir": {
8294
"type": "string",
95+
"format": "path",
8396
"description": "The path of the source directory.",
8497
"default": "src",
8598
"alias": "sd"

packages/schematics/angular/application/index_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ describe('Application Schematic', () => {
1919
const defaultOptions: ApplicationOptions = {
2020
directory: 'foo',
2121
name: 'foo',
22-
prefix: '',
2322
sourceDir: 'src',
2423
inlineStyle: false,
2524
inlineTemplate: false,

packages/schematics/angular/application/schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,29 @@
66
"properties": {
77
"directory": {
88
"type": "string",
9+
"format": "path",
910
"description": "The directory name to create the app in.",
1011
"alias": "dir"
1112
},
1213
"path": {
1314
"type": "string",
15+
"format": "path",
1416
"description": "The path of the application.",
1517
"default": "app",
1618
"visible": false
1719
},
1820
"sourceDir": {
1921
"type": "string",
22+
"format": "path",
2023
"description": "The path of the source directory.",
2124
"default": "src",
2225
"alias": "sd",
2326
"visible": false
2427
},
2528
"name": {
2629
"description": "The name of the application.",
27-
"type": "string"
30+
"type": "string",
31+
"format": "app-name"
2832
},
2933
"inlineStyle": {
3034
"description": "Specifies if the style will be in the ts file.",
@@ -55,6 +59,7 @@
5559
},
5660
"prefix": {
5761
"type": "string",
62+
"format": "html-selector",
5863
"description": "The prefix to apply to generated selectors.",
5964
"default": "app",
6065
"alias": "p"

packages/schematics/angular/class/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
},
1111
"path": {
1212
"type": "string",
13+
"format": "path",
1314
"description": "The path to create the class.",
1415
"default": "app",
1516
"visible": false
1617
},
1718
"sourceDir": {
1819
"type": "string",
20+
"format": "path",
1921
"description": "The path of the source directory.",
2022
"default": "src",
2123
"visible": false
2224
},
2325
"appRoot": {
2426
"type": "string",
27+
"format": "path",
2528
"description": "The root of the application.",
2629
"visible": false
2730
},

packages/schematics/angular/component/index_spec.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('Component Schematic', () => {
2828
spec: true,
2929
module: undefined,
3030
export: false,
31-
prefix: undefined,
31+
prefix: 'app',
3232
};
3333

3434
let appTree: Tree;
@@ -175,18 +175,6 @@ describe('Component Schematic', () => {
175175
expect(files.indexOf(`${root}.ts`)).toBeGreaterThanOrEqual(0);
176176
});
177177

178-
it('should handle ".." in a path', () => {
179-
const options = { ...defaultOptions, path: 'app/a/../c' };
180-
181-
const tree = schematicRunner.runSchematic('component', options, appTree);
182-
const files = tree.files;
183-
const root = `/src/app/c/foo/foo.component`;
184-
expect(files.indexOf(`${root}.css`)).toBeGreaterThanOrEqual(0);
185-
expect(files.indexOf(`${root}.html`)).toBeGreaterThanOrEqual(0);
186-
expect(files.indexOf(`${root}.spec.ts`)).toBeGreaterThanOrEqual(0);
187-
expect(files.indexOf(`${root}.ts`)).toBeGreaterThanOrEqual(0);
188-
});
189-
190178
it('should use the prefix', () => {
191179
const options = { ...defaultOptions, prefix: 'pre' };
192180

@@ -196,7 +184,7 @@ describe('Component Schematic', () => {
196184
});
197185

198186
it('should not use a prefix if none is passed', () => {
199-
const options = { ...defaultOptions, prefix: '' };
187+
const options = { ...defaultOptions, prefix: undefined };
200188

201189
const tree = schematicRunner.runSchematic('component', options, appTree);
202190
const content = getFileContent(tree, '/src/app/foo/foo.component.ts');

packages/schematics/angular/component/schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@
66
"properties": {
77
"path": {
88
"type": "string",
9+
"format": "path",
910
"description": "The path to create the component.",
1011
"default": "app",
1112
"visible": false
1213
},
1314
"sourceDir": {
1415
"type": "string",
16+
"format": "path",
1517
"description": "The path of the source directory.",
1618
"default": "src",
1719
"alias": "sd",
1820
"visible": false
1921
},
2022
"appRoot": {
2123
"type": "string",
24+
"format": "path",
2225
"description": "The root of the application.",
2326
"visible": false
2427
},
@@ -53,8 +56,8 @@
5356
},
5457
"prefix": {
5558
"type": "string",
59+
"format": "html-selector",
5660
"description": "The prefix to apply to generated selectors.",
57-
"default": "app",
5861
"alias": "p"
5962
},
6063
"styleext": {
@@ -79,6 +82,7 @@
7982
},
8083
"selector": {
8184
"type": "string",
85+
"format": "html-selector",
8286
"description": "The selector to use for the component."
8387
},
8488
"module": {

packages/schematics/angular/directive/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@
1010
},
1111
"path": {
1212
"type": "string",
13+
"format": "path",
1314
"description": "The path to create the directive.",
1415
"default": "app",
1516
"visible": false
1617
},
1718
"appRoot": {
1819
"type": "string",
20+
"format": "path",
1921
"description": "The root of the application.",
2022
"visible": false
2123
},
2224
"prefix": {
2325
"type": "string",
26+
"format": "html-selector",
2427
"description": "The prefix to apply to generated selectors.",
2528
"default": "app",
2629
"alias": "p"
2730
},
2831
"sourceDir": {
2932
"type": "string",
33+
"format": "path",
3034
"description": "The path of the source directory.",
3135
"default": "src",
3236
"visible": false
@@ -43,6 +47,7 @@
4347
},
4448
"selector": {
4549
"type": "string",
50+
"format": "html-selector",
4651
"description": "The selector to use for the directive."
4752
},
4853
"flat": {

packages/schematics/angular/enum/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
},
1111
"path": {
1212
"type": "string",
13+
"format": "path",
1314
"description": "The path to create the enum.",
1415
"default": "app",
1516
"visible": false
1617
},
1718
"sourceDir": {
1819
"type": "string",
20+
"format": "path",
1921
"description": "The path of the source directory.",
2022
"default": "src",
2123
"visible": false
2224
},
2325
"appRoot": {
2426
"type": "string",
27+
"format": "path",
2528
"description": "The root of the application.",
2629
"visible": false
2730
}

packages/schematics/angular/guard/schema.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,25 @@
2121
"module": {
2222
"type": "string",
2323
"description": "Allows specification of the declaring module.",
24-
"alias": "m",
25-
"subtype": "filepath"
24+
"alias": "m"
2625
},
2726
"path": {
2827
"type": "string",
28+
"format": "path",
2929
"description": "The path to create the guard.",
3030
"default": "app",
3131
"visible": false
3232
},
3333
"sourceDir": {
3434
"type": "string",
35+
"format": "path",
3536
"description": "The path of the source directory.",
3637
"default": "src",
3738
"visible": false
3839
},
3940
"appRoot": {
4041
"type": "string",
42+
"format": "path",
4143
"description": "The root of the application.",
4244
"visible": false
4345
}

packages/schematics/angular/interface/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
},
1111
"path": {
1212
"type": "string",
13+
"format": "path",
1314
"description": "The path to create the interface.",
1415
"default": "app",
1516
"visible": false
1617
},
1718
"sourceDir": {
1819
"type": "string",
20+
"format": "path",
1921
"description": "The path of the source directory.",
2022
"default": "src",
2123
"visible": false
2224
},
2325
"appRoot": {
2426
"type": "string",
27+
"format": "path",
2528
"description": "The root of the application.",
2629
"visible": false
2730
},

packages/schematics/angular/module/schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
},
1111
"path": {
1212
"type": "string",
13+
"format": "path",
1314
"description": "The path to create the module.",
1415
"default": "app",
1516
"visible": false
1617
},
1718
"sourceDir": {
1819
"type": "string",
20+
"format": "path",
1921
"description": "The path of the source directory.",
2022
"default": "src",
2123
"visible": false
2224
},
2325
"appRoot": {
2426
"type": "string",
27+
"format": "path",
2528
"description": "The root of the application.",
2629
"visible": false
2730
},

packages/schematics/angular/pipe/schema.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,21 @@
1010
},
1111
"path": {
1212
"type": "string",
13+
"format": "path",
1314
"description": "The path to create the pipe.",
1415
"default": "app",
1516
"visible": false
1617
},
1718
"sourceDir": {
1819
"type": "string",
20+
"format": "path",
1921
"description": "The path of the source directory.",
2022
"default": "src",
2123
"visible": false
2224
},
2325
"appRoot": {
2426
"type": "string",
27+
"format": "path",
2528
"description": "The root of the application.",
2629
"visible": false
2730
},
@@ -44,8 +47,7 @@
4447
"type": "string",
4548
"default": "",
4649
"description": "Allows specification of the declaring module.",
47-
"alias": "m",
48-
"subtype": "filepath"
50+
"alias": "m"
4951
},
5052
"export": {
5153
"type": "boolean",

0 commit comments

Comments
 (0)