Skip to content

Commit 0055214

Browse files
lmiller1990leosvelperezjordanpowell88
authored
feat: support Angular 16.1 (#27106)
* feat: support Angular 16.1 * feat: support Angular 16.1 * chore: update changelog * chore: update naming --------- Co-authored-by: Leosvel Pérez Espinosa <[email protected]> Co-authored-by: jordanpowell88 <[email protected]>
1 parent d76d4e1 commit 0055214

File tree

9 files changed

+6229
-9
lines changed

9 files changed

+6229
-9
lines changed

cli/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
<!-- See the ../guides/writing-the-cypress-changelog.md for details on writing the changelog. -->
2+
## 12.15.1
3+
4+
_Released 07/05/2023 (PENDING)_
5+
6+
**Bugfixes:**
7+
8+
- Fixed an issue where some internal file locations consumed by the Cypress Angular Handler moved as a result of [this commit](https://github.com/angular/angular-cli/commit/466d86dc8d3398695055f9eced7402804848a381) from Angular. Addressed in [#27030](https://github.com/cypress-io/cypress/pull/27030).
9+
210
## 12.15.0
311

412
_Released 06/20/2023_

npm/webpack-dev-server/cypress/e2e/angular.cy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/// <reference path="../support/e2e.ts" />
33
import type { ProjectFixtureDir } from '@tooling/system-tests/lib/fixtureDirs'
44

5-
const WEBPACK_ANGULAR: ProjectFixtureDir[] = ['angular-13', 'angular-14', 'angular-15', 'angular-16']
5+
const WEBPACK_ANGULAR: ProjectFixtureDir[] = ['angular-13', 'angular-14', 'angular-15', 'angular-16', 'angular-16.1']
66

77
// Add to this list to focus on a particular permutation
88
const ONLY_PROJECTS: ProjectFixtureDir[] = []

npm/webpack-dev-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"html-webpack-plugin-4": "npm:html-webpack-plugin@^4",
2424
"html-webpack-plugin-5": "npm:html-webpack-plugin@^5",
2525
"local-pkg": "0.4.1",
26+
"semver": "^7.3.2",
2627
"speed-measure-webpack-plugin": "1.4.2",
2728
"tslib": "^2.3.1",
2829
"webpack-dev-server": "^4.7.4",

npm/webpack-dev-server/src/helpers/angularHandler.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as fs from 'fs-extra'
22
import { tmpdir } from 'os'
33
import * as path from 'path'
4+
import { gte } from 'semver'
45
import type { Configuration, RuleSetRule } from 'webpack'
56
import type { PresetHandlerResult, WebpackDevServerConfig } from '../devServer'
67
import { dynamicAbsoluteImport, dynamicImport } from '../dynamic-import'
@@ -165,10 +166,22 @@ export async function getTempDir (): Promise<string> {
165166
}
166167

167168
export async function getAngularCliModules (projectRoot: string) {
169+
let angularVersion: string
170+
171+
try {
172+
angularVersion = await getInstalledPackageVersion('@angular-devkit/core', projectRoot)
173+
} catch {
174+
throw new Error(`Could not resolve "@angular-devkit/core". Do you have it installed?`)
175+
}
176+
168177
const angularCLiModules = [
169178
'@angular-devkit/build-angular/src/utils/webpack-browser-config.js',
170-
'@angular-devkit/build-angular/src/webpack/configs/common.js',
171-
'@angular-devkit/build-angular/src/webpack/configs/styles.js',
179+
// in Angular 16.1 the locations of these files below were changed
180+
...(
181+
gte(angularVersion, '16.1.0')
182+
? ['@angular-devkit/build-angular/src/tools/webpack/configs/common.js', '@angular-devkit/build-angular/src/tools/webpack/configs/styles.js']
183+
: ['@angular-devkit/build-angular/src/webpack/configs/common.js', '@angular-devkit/build-angular/src/webpack/configs/styles.js']
184+
),
172185
'@angular-devkit/core/src/index.js',
173186
] as const
174187

@@ -195,6 +208,15 @@ export async function getAngularCliModules (projectRoot: string) {
195208
}
196209
}
197210

211+
async function getInstalledPackageVersion (pkgName: string, projectRoot: string): Promise<string> {
212+
const packageJsonPath = require.resolve(`${pkgName}/package.json`, { paths: [projectRoot] })
213+
const { version } = JSON.parse(
214+
await fs.readFile(packageJsonPath, { encoding: 'utf-8' }),
215+
)
216+
217+
return version
218+
}
219+
198220
export async function getAngularJson (projectRoot: string): Promise<AngularJson> {
199221
const { findUp } = await dynamicImport<typeof import('find-up')>('find-up')
200222

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "angular-16.1",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"ng": "ng",
7+
"start": "ng serve",
8+
"build": "ng build",
9+
"watch": "ng build --watch --configuration development",
10+
"test": "ng test"
11+
},
12+
"dependencies": {
13+
"@angular/animations": "^16.1.0",
14+
"@angular/common": "^16.1.0",
15+
"@angular/compiler": "^16.1.0",
16+
"@angular/core": "^16.1.0",
17+
"@angular/forms": "^16.1.0",
18+
"@angular/platform-browser": "^16.1.0",
19+
"@angular/platform-browser-dynamic": "^16.1.0",
20+
"@angular/router": "^16.1.0",
21+
"rxjs": "~7.8.0",
22+
"tslib": "^2.3.0",
23+
"zone.js": "~0.13.0"
24+
},
25+
"devDependencies": {
26+
"@angular-devkit/build-angular": "^16.1.0",
27+
"@angular/cli": "~16.1.0",
28+
"@angular/compiler-cli": "^16.1.0",
29+
"@types/jasmine": "~4.3.0",
30+
"jasmine-core": "~4.5.0",
31+
"karma": "~6.4.0",
32+
"karma-chrome-launcher": "~3.1.0",
33+
"karma-coverage": "~2.2.0",
34+
"karma-jasmine": "~5.1.0",
35+
"karma-jasmine-html-reporter": "~2.0.0",
36+
"typescript": "~4.9.4"
37+
},
38+
"projectFixtureDirectory": "angular"
39+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { SignalsComponent } from './signals.component'
2+
3+
describe('SignalsComponent', () => {
4+
it('can mount a signals component', () => {
5+
cy.mount(SignalsComponent)
6+
})
7+
8+
it('can increment the count using a signal', () => {
9+
cy.mount(SignalsComponent)
10+
cy.get('span').contains(0)
11+
cy.get('button').click()
12+
cy.get('span').contains(1)
13+
})
14+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { Component, signal } from '@angular/core'
2+
3+
@Component({
4+
standalone: true,
5+
selector: 'app-signals',
6+
template: `<span>{{ count() }}</span> <button (click)="increment()">+</button>`,
7+
})
8+
export class SignalsComponent {
9+
count = signal(0)
10+
11+
increment (): void {
12+
this.count.update((_count: number) => _count + 1)
13+
}
14+
}

0 commit comments

Comments
 (0)