Skip to content

Commit 1fcba1a

Browse files
authored
feat(angular): support angular v16.1 (nrwl#17155)
1 parent 09e5b03 commit 1fcba1a

File tree

25 files changed

+3736
-1309
lines changed

25 files changed

+3736
-1309
lines changed

e2e/angular-extensions/src/cypress-component-tests.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import {
1414
import { names } from '@nx/devkit';
1515
import { join } from 'path';
1616

17-
describe('Angular Cypress Component Tests', () => {
17+
// TODO(leo): enable when https://github.com/cypress-io/cypress/pull/27030 is merged and released
18+
describe.skip('Angular Cypress Component Tests', () => {
1819
let projectName: string;
1920
const appName = uniq('cy-angular-app');
2021
const usedInAppLibName = uniq('cy-angular-lib');

e2e/cypress/src/cypress.test.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ describe('env vars', () => {
178178
'should allow CT and e2e in the same project',
179179
async () => {
180180
await testCtAndE2eInProject('next');
181-
await testCtAndE2eInProject('angular');
181+
// TODO(leo): uncomment when https://github.com/cypress-io/cypress/pull/27030 is merged and released
182+
// await testCtAndE2eInProject('angular');
182183
await testCtAndE2eInProject('react');
183184
},
184185
TEN_MINS_MS

package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@
2828
},
2929
"devDependencies": {
3030
"@actions/core": "^1.10.0",
31-
"@angular-devkit/architect": "~0.1600.0",
32-
"@angular-devkit/build-angular": "~16.0.0",
33-
"@angular-devkit/core": "~16.0.0",
34-
"@angular-devkit/schematics": "~16.0.0",
31+
"@angular-devkit/architect": "~0.1601.0",
32+
"@angular-devkit/build-angular": "~16.1.0",
33+
"@angular-devkit/core": "~16.1.0",
34+
"@angular-devkit/schematics": "~16.1.0",
3535
"@angular-eslint/eslint-plugin": "~16.0.0",
3636
"@angular-eslint/eslint-plugin-template": "~16.0.0",
3737
"@angular-eslint/template-parser": "~16.0.0",
38-
"@angular/cli": "~16.0.0",
39-
"@angular/common": "~16.0.0",
40-
"@angular/compiler": "~16.0.0",
41-
"@angular/compiler-cli": "~16.0.0",
42-
"@angular/core": "~16.0.0",
43-
"@angular/router": "~16.0.0",
38+
"@angular/cli": "~16.1.0",
39+
"@angular/common": "~16.1.0",
40+
"@angular/compiler": "~16.1.0",
41+
"@angular/compiler-cli": "~16.1.0",
42+
"@angular/core": "~16.1.0",
43+
"@angular/router": "~16.1.0",
4444
"@babel/core": "^7.15.0",
4545
"@babel/helper-create-regexp-features-plugin": "^7.14.5",
4646
"@babel/plugin-transform-runtime": "^7.15.0",
@@ -63,7 +63,7 @@
6363
"@ngrx/effects": "~16.0.0",
6464
"@ngrx/router-store": "~16.0.0",
6565
"@ngrx/store": "~16.0.0",
66-
"@nguniversal/builders": "~16.0.0",
66+
"@nguniversal/builders": "~16.1.0",
6767
"@nx/cypress": "16.4.0-beta.9",
6868
"@nx/devkit": "16.4.0-beta.9",
6969
"@nx/eslint-plugin": "16.4.0-beta.9",
@@ -86,7 +86,7 @@
8686
"@rollup/plugin-json": "^4.1.0",
8787
"@rollup/plugin-node-resolve": "^13.0.4",
8888
"@rollup/plugin-url": "^7.0.0",
89-
"@schematics/angular": "~16.0.0",
89+
"@schematics/angular": "~16.1.0",
9090
"@storybook/addon-essentials": "^7.0.9",
9191
"@storybook/core-server": "^7.0.9",
9292
"@storybook/react": "^7.0.9",
@@ -208,7 +208,7 @@
208208
"mini-css-extract-plugin": "~2.4.7",
209209
"minimatch": "3.0.5",
210210
"next-sitemap": "^3.1.10",
211-
"ng-packagr": "~16.0.0",
211+
"ng-packagr": "~16.1.0",
212212
"node-fetch": "^2.6.7",
213213
"nx": "16.4.0-beta.9",
214214
"nx-cloud": "16.0.5",
@@ -259,9 +259,9 @@
259259
"tsconfig-paths": "^4.1.2",
260260
"tsconfig-paths-webpack-plugin": "4.0.0",
261261
"tslint-to-eslint-config": "^2.13.0",
262-
"typedoc": "0.23.28",
263-
"typedoc-plugin-markdown": "3.14.0",
264-
"typescript": "~5.0.2",
262+
"typedoc": "0.24.8",
263+
"typedoc-plugin-markdown": "3.15.3",
264+
"typescript": "~5.1.3",
265265
"unzipper": "^0.10.11",
266266
"url-loader": "^4.1.1",
267267
"use-sync-external-store": "^1.2.0",

packages/angular/migrations.json

+70
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@
254254
},
255255
"description": "Remove the 'accessibility-' prefix from '@angular-eslint/eslint-plugin-template' rules.",
256256
"factory": "./src/migrations/update-16-4-0/rename-angular-eslint-accesibility-rules"
257+
},
258+
"update-angular-cli-version-16-1-0": {
259+
"cli": "nx",
260+
"version": "16.4.0-beta.11",
261+
"requires": {
262+
"@angular/core": ">=16.1.0"
263+
},
264+
"description": "Update the @angular/cli package version to ~16.1.0.",
265+
"factory": "./src/migrations/update-16-4-0/update-angular-cli"
257266
}
258267
},
259268
"packageJsonUpdates": {
@@ -1159,6 +1168,67 @@
11591168
"alwaysAddToPackageJson": false
11601169
}
11611170
}
1171+
},
1172+
"16.4.0": {
1173+
"version": "16.4.0-beta.11",
1174+
"x-prompt": "Do you want to update the Angular version to v16.1?",
1175+
"requires": {
1176+
"@angular/core": ">=16.0.0 <16.1.0"
1177+
},
1178+
"packages": {
1179+
"@angular-devkit/architect": {
1180+
"version": "~0.1601.0",
1181+
"alwaysAddToPackageJson": false
1182+
},
1183+
"@angular-devkit/build-angular": {
1184+
"version": "~16.1.0",
1185+
"alwaysAddToPackageJson": false
1186+
},
1187+
"@angular-devkit/build-webpack": {
1188+
"version": "~0.1601.0",
1189+
"alwaysAddToPackageJson": false
1190+
},
1191+
"@angular-devkit/core": {
1192+
"version": "~16.1.0",
1193+
"alwaysAddToPackageJson": false
1194+
},
1195+
"@angular-devkit/schematics": {
1196+
"version": "~16.1.0",
1197+
"alwaysAddToPackageJson": false
1198+
},
1199+
"@angular/core": {
1200+
"version": "~16.1.0",
1201+
"alwaysAddToPackageJson": true
1202+
},
1203+
"@angular/material": {
1204+
"version": "~16.1.0",
1205+
"alwaysAddToPackageJson": false
1206+
},
1207+
"@angular/cdk": {
1208+
"version": "~16.1.0",
1209+
"alwaysAddToPackageJson": false
1210+
},
1211+
"@nguniversal/builders": {
1212+
"version": "~16.1.0",
1213+
"alwaysAddToPackageJson": false
1214+
},
1215+
"@nguniversal/common": {
1216+
"version": "~16.1.0",
1217+
"alwaysAddToPackageJson": false
1218+
},
1219+
"@nguniversal/express-engine": {
1220+
"version": "~16.1.0",
1221+
"alwaysAddToPackageJson": false
1222+
},
1223+
"@schematics/angular": {
1224+
"version": "~16.1.0",
1225+
"alwaysAddToPackageJson": false
1226+
},
1227+
"ng-packagr": {
1228+
"version": "~16.1.0",
1229+
"alwaysAddToPackageJson": false
1230+
}
1231+
}
11621232
}
11631233
}
11641234
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { readJson, Tree, writeJson } from '@nx/devkit';
2+
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
3+
import updateAngularCli, { angularCliVersion } from './update-angular-cli';
4+
5+
describe('update-angular-cli migration', () => {
6+
let tree: Tree;
7+
8+
beforeEach(() => {
9+
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
10+
});
11+
12+
it('should update @angular/cli version when defined as a dev dependency', async () => {
13+
writeJson(tree, 'package.json', {
14+
devDependencies: { '@angular/cli': '~13.3.0' },
15+
});
16+
17+
await updateAngularCli(tree);
18+
19+
const { devDependencies } = readJson(tree, 'package.json');
20+
expect(devDependencies['@angular/cli']).toBe(angularCliVersion);
21+
});
22+
23+
it('should update @angular/cli version when defined as a dependency', async () => {
24+
writeJson(tree, 'package.json', {
25+
dependencies: { '@angular/cli': '~13.3.0' },
26+
});
27+
28+
await updateAngularCli(tree);
29+
30+
const { dependencies } = readJson(tree, 'package.json');
31+
expect(dependencies['@angular/cli']).toBe(angularCliVersion);
32+
});
33+
34+
it('should not add @angular/cli to package.json when it is not set', async () => {
35+
const initialPackageJson = readJson(tree, 'package.json');
36+
37+
await updateAngularCli(tree);
38+
39+
const packageJson = readJson(tree, 'package.json');
40+
expect(packageJson).toStrictEqual(initialPackageJson);
41+
});
42+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { formatFiles, Tree, updateJson } from '@nx/devkit';
2+
3+
export const angularCliVersion = '~16.1.0';
4+
5+
export default async function (tree: Tree) {
6+
let shouldFormat = false;
7+
8+
updateJson(tree, 'package.json', (json) => {
9+
if (json.devDependencies?.['@angular/cli']) {
10+
json.devDependencies['@angular/cli'] = angularCliVersion;
11+
shouldFormat = true;
12+
} else if (json.dependencies?.['@angular/cli']) {
13+
json.dependencies['@angular/cli'] = angularCliVersion;
14+
shouldFormat = true;
15+
}
16+
17+
return json;
18+
});
19+
20+
if (shouldFormat) {
21+
await formatFiles(tree);
22+
}
23+
}

packages/angular/src/utils/versions.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export const nxVersion = require('../../package.json').version;
22

3-
export const angularVersion = '~16.0.0';
4-
export const angularDevkitVersion = '~16.0.0';
5-
export const ngPackagrVersion = '~16.0.0';
3+
export const angularVersion = '~16.1.0';
4+
export const angularDevkitVersion = '~16.1.0';
5+
export const ngPackagrVersion = '~16.1.0';
66
export const ngrxVersion = '~16.0.0';
77
export const rxjsVersion = '~7.8.0';
88
export const zoneJsVersion = '~0.13.0';
99
export const angularJsVersion = '1.7.9';
1010
export const tsLibVersion = '^2.3.0';
1111

12-
export const ngUniversalVersion = '~16.0.0';
12+
export const ngUniversalVersion = '~16.1.0';
1313
export const corsVersion = '~2.8.5';
1414
export const typesCorsVersion = '~2.8.5';
1515
export const expressVersion = '~4.18.2';

packages/cypress/migrations.json

+6
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@
5959
"version": "16.4.0-beta.10",
6060
"description": "Remove tsconfig.e2e.json and add settings to project tsconfig.json. tsConfigs executor option is now deprecated. The project level tsconfig.json file should be used instead.",
6161
"implementation": "./src/migrations/update-16-4-0/tsconfig-sourcemaps"
62+
},
63+
"update-16-4-0-warn-incompatible-angular-cypress": {
64+
"cli": "nx",
65+
"version": "16.4.0-beta.11",
66+
"description": "Cypress Component Testing is broken with Angular 16.1.0. Warn about it if the workspace has Angular >= 16.1.0 and Angular projects using Component Testing.",
67+
"implementation": "./src/migrations/update-16-4-0/warn-incompatible-angular-cypress"
6268
}
6369
},
6470
"packageJsonUpdates": {

0 commit comments

Comments
 (0)