Skip to content

Commit 97a7878

Browse files
feat: add Angular schematics (#220)
1 parent dcb0813 commit 97a7878

File tree

8 files changed

+50
-109
lines changed

8 files changed

+50
-109
lines changed

angular.json

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,8 @@
2020
"main": "apps/example-app/src/main.ts",
2121
"polyfills": "apps/example-app/src/polyfills.ts",
2222
"tsConfig": "apps/example-app/tsconfig.app.json",
23-
"assets": [
24-
"apps/example-app/src/favicon.ico",
25-
"apps/example-app/src/assets"
26-
],
27-
"styles": [
28-
"apps/example-app/src/styles.css"
29-
],
23+
"assets": ["apps/example-app/src/favicon.ico", "apps/example-app/src/assets"],
24+
"styles": ["apps/example-app/src/styles.css"],
3025
"scripts": [],
3126
"vendorChunk": true,
3227
"extractLicenses": false,
@@ -58,9 +53,7 @@
5853
"buildOptimizer": true
5954
}
6055
},
61-
"outputs": [
62-
"{options.outputPath}"
63-
]
56+
"outputs": ["{options.outputPath}"]
6457
},
6558
"serve": {
6659
"builder": "@angular-devkit/build-angular:dev-server",
@@ -97,9 +90,7 @@
9790
"jestConfig": "apps/example-app/jest.config.js",
9891
"setupFile": "apps/example-app/src/test-setup.ts"
9992
},
100-
"outputs": [
101-
"coverage/"
102-
]
93+
"outputs": ["coverage/"]
10394
}
10495
}
10596
},
@@ -144,6 +135,9 @@
144135
},
145136
{
146137
"command": "cpy ./README.md ./dist/@testing-library/angular"
138+
},
139+
{
140+
"command": "cpy schematics/**/*.json ../../dist/@testing-library/angular --cwd=./projects/testing-library --parents"
147141
}
148142
]
149143
}
@@ -154,9 +148,7 @@
154148
"jestConfig": "projects/testing-library/jest.config.js",
155149
"setupFile": "projects/testing-library/test-setup.ts"
156150
},
157-
"outputs": [
158-
"coverage/projects/testing-library"
159-
]
151+
"outputs": ["coverage/projects/testing-library"]
160152
}
161153
}
162154
},
@@ -208,11 +200,9 @@
208200
"jestConfig": "projects/jest-utils/jest.config.js",
209201
"setupFile": "projects/jest-utils/test-setup.ts"
210202
},
211-
"outputs": [
212-
"coverage/projects/jest-utils"
213-
]
203+
"outputs": ["coverage/projects/jest-utils"]
214204
}
215205
}
216206
}
217207
}
218-
}
208+
}

migrations.json

Lines changed: 0 additions & 89 deletions
This file was deleted.

projects/testing-library/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@
2121
"url": "https://github.com/testing-library/angular-testing-library/issues"
2222
},
2323
"homepage": "https://github.com/testing-library/angular-testing-library#readme",
24+
"schematics": "./schematics/collection.json",
25+
"ng-add": {
26+
"save": "devDependencies"
27+
},
28+
"ng-update": {
29+
"migrations": "./schematics/migrations/migration.json"
30+
},
2431
"peerDependencies": {
2532
"@angular/common": ">= 10.0.0",
2633
"@angular/platform-browser": ">= 10.0.0",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"schematics": {
3+
"ng-add": {
4+
"aliases": ["init"],
5+
"factory": "./ng-add",
6+
"schema": "./ng-add/schema.json",
7+
"description": "Add @testing-library/angular to your application"
8+
}
9+
}
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"schematics": {}
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Rule, SchematicContext, Tree } from '@angular-devkit/schematics';
2+
3+
export default function (): Rule {
4+
return (_host: Tree, context: SchematicContext) => {
5+
context.logger.info(
6+
`Correctly installed @testing-library/angular.
7+
See our docs at https://testing-library.com/docs/angular-testing-library/intro/ to get started.`,
8+
);
9+
};
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"$schema": "http://json-schema.org/schema",
3+
"$id": "SchematicsTestingLibraryAngular",
4+
"title": "testing-library-anguular",
5+
"type": "object",
6+
"properties": {},
7+
"required": []
8+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
2+
export interface Schema {}

0 commit comments

Comments
 (0)