Skip to content

Commit dd85fd2

Browse files
authored
feat: add json schema for package.json with custom ngPackage property (#173)
See review discussions in #169
1 parent c193b68 commit dd85fd2

File tree

8 files changed

+22
-6
lines changed

8 files changed

+22
-6
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ Configuration is picked up from the cli `-p` parameter, then from the default lo
6565

6666
To configure with `package.json`, put your ng-package configuration
6767
in the `ngPackage` field:
68+
6869
```json
6970
{
71+
"$schema": "./node_modules/ng-packagr/package.schema.json",
7072
"ngPackage": {
7173
"lib": {
7274
"entryFile": "public_api.ts"
@@ -75,6 +77,8 @@ in the `ngPackage` field:
7577
}
7678
```
7779

80+
Note: the JSON `$schema` reference enables JSON editing support (autocompletion) for the custom `ngPackage` property in an IDE like [VSCode](https://github.com/Microsoft/vscode).
81+
7882
#### More Examples
7983

8084
Nikolas LeBlanc has written a story on medium.com on [Building an Angular 4 Component Library with the Angular CLI and ng-packagr](https://medium.com/@ngl817/building-an-angular-4-component-library-with-the-angular-cli-and-ng-packagr-53b2ade0701e)

integration/samples/core/ng-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../../src/lib/ng-package.schema.json",
2+
"$schema": "../../../src/ng-package.schema.json",
33
"lib": {
44
"entryFile": "public_api.ts",
55
"externals": {

integration/samples/custom/ng-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../../src/lib/ng-package.schema.json",
2+
"$schema": "../../../src/ng-package.schema.json",
33
"lib": {
44
"entryFile": "src/public_api.ts"
55
}

integration/samples/externals/ng-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../../src/lib/ng-package.schema.json",
2+
"$schema": "../../../src/ng-package.schema.json",
33
"lib": {
44
"entryFile": "public_api.ts"
55
}

integration/samples/material/ng-package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "../../../src/lib/ng-package.schema.json",
2+
"$schema": "../../../src/ng-package.schema.json",
33
"lib": {
44
"entryFile": "public_api.ts"
55
}

integration/samples/package-json/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "../../../src/package.schema.json",
23
"name": "@sample/package-json",
34
"description": "A sample library with configuration in package.json",
45
"version": "1.0.0-pre.0",
@@ -9,7 +10,6 @@
910
"@angular/common": "^4.1.2"
1011
},
1112
"ngPackage": {
12-
"$schema": "../../../src/lib/ng-package.schema.json",
1313
"lib": {
1414
"entryFile": "public_api.ts"
1515
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"$schema": "../../../src/lib/ng-package.schema.json"
2+
"$schema": "../../../src/ng-package.schema.json"
33
}

src/package.schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"allOf": [
4+
{ "$ref": "http://json.schemastore.org/package" },
5+
{
6+
"properties": {
7+
"ngPackage": { "$ref": "./ng-package.schema.json" }
8+
},
9+
"required": []
10+
}
11+
]
12+
}

0 commit comments

Comments
 (0)