Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(angular): support angular 18.0.0-next.0 #22492

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
},
"devDependencies": {
"@actions/core": "^1.10.0",
"@angular-devkit/architect": "~0.1703.0",
"@angular-devkit/build-angular": "~17.3.0",
"@angular-devkit/core": "~17.3.0",
"@angular-devkit/schematics": "~17.3.0",
"@angular-devkit/architect": "~0.1800.0-next.0",
"@angular-devkit/build-angular": "~18.0.0-next.0",
"@angular-devkit/core": "~18.0.0-next.0",
"@angular-devkit/schematics": "~18.0.0-next.0",
"@angular-eslint/eslint-plugin": "~17.3.0",
"@angular-eslint/eslint-plugin-template": "~17.3.0",
"@angular-eslint/template-parser": "~17.3.0",
"@angular/cli": "~17.3.0",
"@angular/common": "~17.3.0",
"@angular/compiler": "~17.3.0",
"@angular/compiler-cli": "~17.3.0",
"@angular/core": "~17.3.0",
"@angular/router": "~17.3.0",
"@angular/cli": "~18.0.0-next.0",
"@angular/common": "~18.0.0-next.1",
"@angular/compiler": "~18.0.0-next.1",
"@angular/compiler-cli": "~18.0.0-next.1",
"@angular/core": "~18.0.0-next.1",
"@angular/router": "~18.0.0-next.1",
"@babel/core": "^7.23.2",
"@babel/helper-create-regexp-features-plugin": "^7.22.9",
"@babel/plugin-transform-runtime": "^7.23.2",
Expand Down Expand Up @@ -93,7 +93,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-url": "^7.0.0",
"@schematics/angular": "~17.3.0",
"@schematics/angular": "~18.0.0-next.0",
"@side/jest-runtime": "^1.1.0",
"@storybook/addon-essentials": "7.5.3",
"@storybook/core-server": "7.5.3",
Expand Down Expand Up @@ -228,7 +228,7 @@
"mini-css-extract-plugin": "~2.4.7",
"minimatch": "9.0.3",
"next-sitemap": "^3.1.10",
"ng-packagr": "~17.3.0",
"ng-packagr": "~18.0.0-next.1",
"node-fetch": "^2.6.7",
"npm-package-arg": "11.0.1",
"nuxt": "^3.10.0",
Expand Down
66 changes: 66 additions & 0 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,15 @@
},
"description": "Update the @angular/cli package version to ~17.3.0.",
"factory": "./src/migrations/update-18-2-0/update-angular-cli"
},
"update-angular-cli-version-18-0-0-next-0": {
"cli": "nx",
"version": "19.1.0-beta.0",
"requires": {
"@angular/core": ">=18.0.0-next.1"
},
"description": "Update the @angular/cli package version to ~18.0.0-next.0.",
"factory": "./src/migrations/update-19-1-0/update-angular-cli"
}
},
"packageJsonUpdates": {
Expand Down Expand Up @@ -1805,6 +1814,63 @@
"alwaysAddToPackageJson": false
}
}
},
"19.1.0": {
"version": "19.1.0-beta.0",
"x-prompt": "Do you want to update the Angular version to v18?",
"requires": {
"@angular/core": ">=17.3.0 <18.0.0-next.1"
},
"packages": {
"@angular-devkit/build-angular": {
"version": "~18.0.0-next.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/core": {
"version": "~18.0.0-next.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/schematics": {
"version": "~18.0.0-next.0",
"alwaysAddToPackageJson": false
},
"@angular/pwa": {
"version": "~18.0.0-next.0",
"alwaysAddToPackageJson": false
},
"@angular/ssr": {
"version": "~18.0.0-next.0",
"alwaysAddToPackageJson": false
},
"@schematics/angular": {
"version": "~18.0.0-next.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/architect": {
"version": "~0.1800.0-next.0",
"alwaysAddToPackageJson": false
},
"@angular-devkit/build-webpack": {
"version": "~0.1800.0-next.0",
"alwaysAddToPackageJson": false
},
"@angular/core": {
"version": "~18.0.0-next.1",
"alwaysAddToPackageJson": true
},
"@angular/material": {
"version": "~18.0.0-next.1",
"alwaysAddToPackageJson": false
},
"@angular/cdk": {
"version": "~18.0.0-next.1",
"alwaysAddToPackageJson": false
},
"ng-packagr": {
"version": "~18.0.0-next.1",
"alwaysAddToPackageJson": false
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import * as browserslist from 'browserslist';
import { existsSync } from 'fs';
import { EsbuildExecutor } from 'ng-packagr/lib/esbuild/esbuild-executor';
import {
generateKey,
readCacheEntry,
Expand Down Expand Up @@ -49,7 +48,8 @@ export class StylesheetProcessor {
private browserslistData: string[];
private targets: string[];
private postCssProcessor: ReturnType<typeof postcss>;
private esbuild = new EsbuildExecutor();
private esbuild =
new (require('ng-packagr/lib/esbuild/esbuild-executor').EsbuildExecutor)();
private styleIncludePaths: string[];

constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import * as browserslist from 'browserslist';
import { existsSync } from 'fs';
import { EsbuildExecutor } from 'ng-packagr/lib/esbuild/esbuild-executor';
import {
generateKey,
readCacheEntry,
Expand Down Expand Up @@ -42,7 +41,8 @@ export class StylesheetProcessor {
private browserslistData: string[];
private targets: string[];
private postCssProcessor: ReturnType<typeof postcss>;
private esbuild = new EsbuildExecutor();
private esbuild =
new (require('ng-packagr/lib/esbuild/esbuild-executor').EsbuildExecutor)();
private styleIncludePaths: string[];

constructor(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { readJson, Tree, writeJson } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import updateAngularCli, { angularCliVersion } from './update-angular-cli';

describe('update-angular-cli migration', () => {
let tree: Tree;

beforeEach(() => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
});

it('should update @angular/cli version when defined as a dev dependency', async () => {
writeJson(tree, 'package.json', {
devDependencies: { '@angular/cli': '~13.3.0' },
});

await updateAngularCli(tree);

const { devDependencies } = readJson(tree, 'package.json');
expect(devDependencies['@angular/cli']).toBe(angularCliVersion);
});

it('should update @angular/cli version when defined as a dependency', async () => {
writeJson(tree, 'package.json', {
dependencies: { '@angular/cli': '~13.3.0' },
});

await updateAngularCli(tree);

const { dependencies } = readJson(tree, 'package.json');
expect(dependencies['@angular/cli']).toBe(angularCliVersion);
});

it('should not add @angular/cli to package.json when it is not set', async () => {
const initialPackageJson = readJson(tree, 'package.json');

await updateAngularCli(tree);

const packageJson = readJson(tree, 'package.json');
expect(packageJson).toStrictEqual(initialPackageJson);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { formatFiles, Tree, updateJson } from '@nx/devkit';

export const angularCliVersion = '~18.0.0-next.0';

export default async function (tree: Tree) {
let shouldFormat = false;

updateJson(tree, 'package.json', (json) => {
if (json.devDependencies?.['@angular/cli']) {
json.devDependencies['@angular/cli'] = angularCliVersion;
shouldFormat = true;
} else if (json.dependencies?.['@angular/cli']) {
json.dependencies['@angular/cli'] = angularCliVersion;
shouldFormat = true;
}

return json;
});

if (shouldFormat) {
await formatFiles(tree);
}
}
6 changes: 3 additions & 3 deletions packages/angular/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const nxVersion = require('../../package.json').version;

export const angularVersion = '~17.3.0';
export const angularDevkitVersion = '~17.3.0';
export const ngPackagrVersion = '~17.3.0';
export const angularVersion = '~18.0.0-next.1';
export const angularDevkitVersion = '~18.0.0-next.0';
export const ngPackagrVersion = '~18.0.0-next.1';
export const ngrxVersion = '~17.0.0';
export const rxjsVersion = '~7.8.0';
export const zoneJsVersion = '~0.14.3';
Expand Down
2 changes: 1 addition & 1 deletion packages/workspace/src/utils/versions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const typescriptVersion = '~5.4.2';

// TODO: remove when preset generation is reworked and
// deps are not installed from workspace
export const angularCliVersion = '~17.3.0';
export const angularCliVersion = '~18.0.0-next.0';
Loading