diff --git a/packages/angular/src/generators/setup-ssr/lib/add-dependencies.ts b/packages/angular/src/generators/setup-ssr/lib/add-dependencies.ts index 7d99903d905a5d..ad3736549015c8 100644 --- a/packages/angular/src/generators/setup-ssr/lib/add-dependencies.ts +++ b/packages/angular/src/generators/setup-ssr/lib/add-dependencies.ts @@ -1,6 +1,6 @@ import { addDependenciesToPackageJson, type Tree } from '@nx/devkit'; import { gte } from 'semver'; -import type { PackageCompatVersions } from '../../../utils/backward-compatible-versions'; +import type { VersionMap } from '../../../utils/backward-compatible-versions'; import { getInstalledAngularVersionInfo, getInstalledPackageVersionInfo, @@ -35,10 +35,11 @@ export function addDependencies( } else { dependencies['@nguniversal/express-engine'] = getInstalledPackageVersionInfo(tree, '@nguniversal/express-engine') - ?.version ?? (pkgVersions as PackageCompatVersions).ngUniversalVersion; + ?.version ?? + (pkgVersions as VersionMap['angularV16']).ngUniversalVersion; devDependencies['@nguniversal/builders'] = getInstalledPackageVersionInfo(tree, '@nguniversal/builders')?.version ?? - (pkgVersions as PackageCompatVersions).ngUniversalVersion; + (pkgVersions as VersionMap['angularV16']).ngUniversalVersion; } addDependenciesToPackageJson(tree, dependencies, devDependencies); diff --git a/packages/angular/src/utils/backward-compatible-versions.ts b/packages/angular/src/utils/backward-compatible-versions.ts index f67245cb24fad5..08704d9d4d57c8 100644 --- a/packages/angular/src/utils/backward-compatible-versions.ts +++ b/packages/angular/src/utils/backward-compatible-versions.ts @@ -2,22 +2,31 @@ import * as latestVersions from './versions'; type SupportedVersions = 'angularV16' | 'angularV17'; -export type LatestPackageVersionNames = Exclude< +type LatestPackageVersionNames = Exclude< keyof typeof latestVersions, 'nxVersion' >; -export type CompatPackageVersionNames = +type CompatPackageVersionNames = | LatestPackageVersionNames // Can be removed when dropping support for Angular v16 | 'ngUniversalVersion'; +export type PackageVersionNames = + | LatestPackageVersionNames + | CompatPackageVersionNames; + +export type VersionMap = { + angularV16: Record; + angularV17: Record< + Exclude, + string + >; +}; + export type PackageLatestVersions = Record; -export type PackageCompatVersions = Record; +export type PackageCompatVersions = VersionMap[SupportedVersions]; -export const backwardCompatibleVersions: Record< - SupportedVersions, - PackageCompatVersions -> = { +export const backwardCompatibleVersions: VersionMap = { angularV16: { angularVersion: '~16.2.0', angularDevkitVersion: '~16.2.0', @@ -46,29 +55,28 @@ export const backwardCompatibleVersions: Record< jsoncEslintParserVersion: '^2.1.0', }, angularV17: { - angularVersion: '~16.2.0', - angularDevkitVersion: '~16.2.0', - ngPackagrVersion: '~16.2.0', - ngrxVersion: '~16.0.0', + angularVersion: '~17.3.0', + angularDevkitVersion: '~17.3.0', + ngPackagrVersion: '~17.3.0', + ngrxVersion: '~17.0.0', rxjsVersion: '~7.8.0', - zoneJsVersion: '~0.13.0', + zoneJsVersion: '~0.14.3', angularJsVersion: '1.7.9', tsLibVersion: '^2.3.0', - ngUniversalVersion: '~16.2.0', corsVersion: '~2.8.5', typesCorsVersion: '~2.8.5', expressVersion: '~4.18.2', typesExpressVersion: '4.17.14', browserSyncVersion: '^3.0.0', moduleFederationNodeVersion: '~1.0.5', - angularEslintVersion: '~16.0.0', + angularEslintVersion: '~17.3.0', tailwindVersion: '^3.0.2', postcssVersion: '^8.4.5', postcssUrlVersion: '~10.1.3', autoprefixerVersion: '^10.4.0', tsNodeVersion: '10.9.1', - jestPresetAngularVersion: '~13.1.0', - typesNodeVersion: '16.11.7', + jestPresetAngularVersion: '~14.0.3', + typesNodeVersion: '18.16.9', jasmineMarblesVersion: '^0.9.2', jsoncEslintParserVersion: '^2.1.0', }, diff --git a/packages/angular/src/utils/version-utils.ts b/packages/angular/src/utils/version-utils.ts index da43c68647e942..469296ba582ec0 100644 --- a/packages/angular/src/utils/version-utils.ts +++ b/packages/angular/src/utils/version-utils.ts @@ -1,16 +1,15 @@ import { coerce, major } from 'semver'; import type { - CompatPackageVersionNames, - LatestPackageVersionNames, PackageCompatVersions, PackageLatestVersions, + PackageVersionNames, } from './backward-compatible-versions'; import { backwardCompatibleVersions } from './backward-compatible-versions'; import * as versions from './versions'; import { angularVersion } from './versions'; export function getPkgVersionForAngularMajorVersion( - pkgVersionName: LatestPackageVersionNames | CompatPackageVersionNames, + pkgVersionName: PackageVersionNames, angularMajorVersion: number ): string { return angularMajorVersion < major(coerce(angularVersion))