Skip to content

Commit f15d558

Browse files
hanslKeen Yee Liau
authored and
Keen Yee Liau
committed
refactor(@schematics/angular): automated JSON schema generation
1 parent 8a4ce4d commit f15d558

31 files changed

+64
-752
lines changed

packages/schematics/angular/BUILD

+21-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,27 @@ licenses(["notice"]) # MIT
77

88
load("@build_bazel_rules_typescript//:defs.bzl", "ts_library")
99
load("@build_bazel_rules_nodejs//:defs.bzl", "jasmine_node_test")
10+
load("//tools:ts_json_schema.bzl", "ts_json_schema")
1011

1112
package(default_visibility = ["//visibility:public"])
1213

14+
# Create a list of Tuple("path/file.json", "path_file") to be used as rules
15+
ALL_SCHEMA_TARGETS_PAIR = [
16+
(x, x.replace("/", "_").replace("-", "_").replace(".json", ""))
17+
for x in glob(["*/schema.json"])
18+
]
19+
20+
# Create all the targets.
21+
[
22+
ts_json_schema(
23+
name = name,
24+
src = src,
25+
)
26+
for (src, name) in ALL_SCHEMA_TARGETS_PAIR
27+
]
28+
29+
ALL_SCHEMA_DEPS = [":" + name for (_, name) in ALL_SCHEMA_TARGETS_PAIR]
30+
1331
ts_library(
1432
name = "angular",
1533
srcs = glob(
@@ -25,7 +43,7 @@ ts_library(
2543
"utility/test/**/*.ts"
2644
],
2745
),
28-
deps = [
46+
deps = ALL_SCHEMA_DEPS + [
2947
"//packages/angular_devkit/core",
3048
"//packages/angular_devkit/schematics",
3149
"//packages/angular_devkit/schematics:tasks",
@@ -36,6 +54,7 @@ ts_library(
3654
],
3755
)
3856

57+
3958
ts_library(
4059
name = "angular_test_lib",
4160
srcs = glob(
@@ -52,7 +71,7 @@ ts_library(
5271
"*/other-files/**",
5372
]
5473
),
55-
deps = [
74+
deps = ALL_SCHEMA_DEPS + [
5675
":angular",
5776
"//packages/angular_devkit/core",
5877
"//packages/angular_devkit/schematics",

packages/schematics/angular/app-shell/schema.d.ts

-71
This file was deleted.

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

-55
This file was deleted.

packages/schematics/angular/application/schema.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@
6868
"description": "Do not add dependencies to package.json."
6969
}
7070
},
71-
"required": []
71+
"required": [
72+
"name"
73+
]
7274
}

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

-30
This file was deleted.

packages/schematics/angular/class/schema.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@
3636
"default": ""
3737
}
3838
},
39-
"required": []
39+
"required": [
40+
"name",
41+
"project"
42+
]
4043
}

packages/schematics/angular/component/index_spec.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/te
1010
import { Schema as ApplicationOptions } from '../application/schema';
1111
import { createAppModule } from '../utility/test';
1212
import { Schema as WorkspaceOptions } from '../workspace/schema';
13-
import { Schema as ComponentOptions } from './schema';
13+
import { ChangeDetection, Schema as ComponentOptions } from './schema';
1414

1515
// tslint:disable:max-line-length
1616
describe('Component Schematic', () => {
@@ -23,7 +23,7 @@ describe('Component Schematic', () => {
2323
// path: 'src/app',
2424
inlineStyle: false,
2525
inlineTemplate: false,
26-
changeDetection: 'Default',
26+
changeDetection: ChangeDetection.Default,
2727
styleext: 'css',
2828
spec: true,
2929
module: undefined,

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

-78
This file was deleted.

packages/schematics/angular/component/schema.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -110,5 +110,7 @@
110110
"description": "Specifies whether to apply lint fixes after generating the component."
111111
}
112112
},
113-
"required": []
113+
"required": [
114+
"name"
115+
]
114116
}

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

-54
This file was deleted.

0 commit comments

Comments
 (0)