Skip to content

Commit 0e9d54a

Browse files
committed
test(@angular/cli): create validation harness for example code
This commit introduces a pre-built, minimal, standalone Angular application that will serve as a validation harness for the code snippets in the `find_examples` tool. This harness, located in `tools/example-validation-harness`, will be used by a new CI script to programmatically compile and type-check all example code. Using a full Angular project environment ensures a high-fidelity validation that covers TypeScript, Angular-specific syntax, and HTML templates.
1 parent d3a438c commit 0e9d54a

File tree

7 files changed

+128
-0
lines changed

7 files changed

+128
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"validation-harness": {
7+
"projectType": "application",
8+
"root": "",
9+
"sourceRoot": "src",
10+
"prefix": "app",
11+
"architect": {
12+
"build": {
13+
"builder": "@angular/build:application",
14+
"options": {
15+
"outputPath": "dist/validation-harness",
16+
"index": "src/index.html",
17+
"browser": "src/main.ts",
18+
"polyfills": ["zone.js"],
19+
"tsConfig": "tsconfig.app.json",
20+
"assets": [],
21+
"styles": [],
22+
"scripts": []
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "example-validation-harness",
3+
"version": "0.0.0",
4+
"private": true,
5+
"dependencies": {
6+
"@angular/common": "^21.0.0-next",
7+
"@angular/compiler": "^21.0.0-next",
8+
"@angular/core": "^21.0.0-next",
9+
"@angular/forms": "^21.0.0-next",
10+
"@angular/platform-browser": "^21.0.0-next",
11+
"rxjs": "~7.8.0",
12+
"tslib": "^2.3.0",
13+
"zone.js": "~0.15.0"
14+
},
15+
"devDependencies": {
16+
"@angular/build": "^21.0.0-next",
17+
"@angular/cli": "^21.0.0-next",
18+
"@angular/compiler-cli": "^21.0.0-next",
19+
"typescript": "~5.9.2"
20+
}
21+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import { Component } from '@angular/core';
10+
11+
@Component({
12+
selector: 'app-root',
13+
imports: [],
14+
template: '',
15+
})
16+
export class App {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>ValidationHarness</title>
6+
<base href="/">
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="icon" type="image/x-icon" href="favicon.ico">
9+
</head>
10+
<body>
11+
<app-root></app-root>
12+
</body>
13+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
8+
9+
import { bootstrapApplication } from '@angular/platform-browser';
10+
import { App } from './app/app';
11+
12+
bootstrapApplication(App).catch((err) => console.error(err));
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./out-tsc/app",
5+
"types": []
6+
},
7+
"include": ["src/**/*.ts"],
8+
"exclude": ["src/**/*.spec.ts"]
9+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"compileOnSave": false,
3+
"compilerOptions": {
4+
"strict": true,
5+
"noImplicitOverride": true,
6+
"noPropertyAccessFromIndexSignature": true,
7+
"noImplicitReturns": true,
8+
"noFallthroughCasesInSwitch": true,
9+
"skipLibCheck": true,
10+
"isolatedModules": true,
11+
"experimentalDecorators": true,
12+
"importHelpers": true,
13+
"target": "ES2022",
14+
"module": "preserve"
15+
},
16+
"angularCompilerOptions": {
17+
"enableI18nLegacyMessageIdFormat": false,
18+
"strictInjectionParameters": true,
19+
"strictInputAccessModifiers": true,
20+
"typeCheckHostBindings": true,
21+
"strictTemplates": true
22+
},
23+
"files": [],
24+
"references": [
25+
{
26+
"path": "./tsconfig.app.json"
27+
}
28+
]
29+
}

0 commit comments

Comments
 (0)