Skip to content

Commit

Permalink
feat(angular): support angular v16.1
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Jun 2, 2023
1 parent 63f85a1 commit 750ea32
Show file tree
Hide file tree
Showing 10 changed files with 2,610 additions and 658 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
},
"devDependencies": {
"@actions/core": "^1.10.0",
"@angular-devkit/architect": "~0.1600.0",
"@angular-devkit/build-angular": "~16.0.0",
"@angular-devkit/core": "~16.0.0",
"@angular-devkit/schematics": "~16.0.0",
"@angular-devkit/architect": "~0.1601.0-next.2",
"@angular-devkit/build-angular": "~16.1.0-next.2",
"@angular-devkit/core": "~16.1.0-next.2",
"@angular-devkit/schematics": "~16.1.0-next.2",
"@angular-eslint/eslint-plugin": "~16.0.0",
"@angular-eslint/eslint-plugin-template": "~16.0.0",
"@angular-eslint/template-parser": "~16.0.0",
"@angular/cli": "~16.0.0",
"@angular/common": "~16.0.0",
"@angular/compiler": "~16.0.0",
"@angular/compiler-cli": "~16.0.0",
"@angular/core": "~16.0.0",
"@angular/router": "~16.0.0",
"@angular/cli": "~16.1.0-next.2",
"@angular/common": "~16.1.0-next.3",
"@angular/compiler": "~16.1.0-next.3",
"@angular/compiler-cli": "~16.1.0-next.3",
"@angular/core": "~16.1.0-next.3",
"@angular/router": "~16.1.0-next.3",
"@babel/core": "^7.15.0",
"@babel/helper-create-regexp-features-plugin": "^7.14.5",
"@babel/plugin-transform-runtime": "^7.15.0",
Expand All @@ -65,7 +65,7 @@
"@ngrx/effects": "~16.0.0",
"@ngrx/router-store": "~16.0.0",
"@ngrx/store": "~16.0.0",
"@nguniversal/builders": "~16.0.0",
"@nguniversal/builders": "~16.1.0-next.0",
"@nx/cypress": "16.4.0-beta.0",
"@nx/devkit": "16.4.0-beta.0",
"@nx/eslint-plugin": "16.4.0-beta.0",
Expand All @@ -88,7 +88,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.4",
"@rollup/plugin-url": "^7.0.0",
"@schematics/angular": "~16.0.0",
"@schematics/angular": "~16.1.0-next.2",
"@storybook/addon-essentials": "^7.0.9",
"@storybook/core-server": "^7.0.9",
"@storybook/react": "^7.0.9",
Expand Down Expand Up @@ -210,7 +210,7 @@
"mini-css-extract-plugin": "~2.4.7",
"minimatch": "3.0.5",
"next-sitemap": "^3.1.10",
"ng-packagr": "~16.0.0",
"ng-packagr": "~16.1.0-next.0",
"node-fetch": "^2.6.7",
"nx": "16.4.0-beta.0",
"nx-cloud": "16.0.5",
Expand Down
70 changes: 70 additions & 0 deletions packages/angular/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,15 @@
},
"description": "Switch the data persistence operator imports to '@ngrx/router-store/data-persistence'.",
"factory": "./src/migrations/update-16-2-0/switch-data-persistence-operators-imports-to-ngrx-router-store"
},
"update-angular-cli-version-16-1-0-next-2": {
"cli": "nx",
"version": "16.5.0-beta.0",
"requires": {
"@angular/core": ">=16.1.0-next.3"
},
"description": "Update the @angular/cli package version to ~16.1.0-next.2.",
"factory": "./src/migrations/update-16-5-0/update-angular-cli"
}
},
"packageJsonUpdates": {
Expand Down Expand Up @@ -1143,6 +1152,67 @@
"alwaysAddToPackageJson": false
}
}
},
"16.5.0": {
"version": "16.5.0-beta.0",
"x-prompt": "Do you want to update the Angular version to v16.1?",
"requires": {
"@angular/core": ">=16.0.0 <16.1.0-next.3"
},
"packages": {
"@angular-devkit/architect": {
"version": "~0.1601.0-next.2",
"alwaysAddToPackageJson": false
},
"@angular-devkit/build-angular": {
"version": "~16.1.0-next.2",
"alwaysAddToPackageJson": false
},
"@angular-devkit/build-webpack": {
"version": "~0.1601.0-next.2",
"alwaysAddToPackageJson": false
},
"@angular-devkit/core": {
"version": "~16.1.0-next.2",
"alwaysAddToPackageJson": false
},
"@angular-devkit/schematics": {
"version": "~16.1.0-next.2",
"alwaysAddToPackageJson": false
},
"@angular/core": {
"version": "~16.1.0-next.3",
"alwaysAddToPackageJson": true
},
"@angular/material": {
"version": "~16.1.0-next.2",
"alwaysAddToPackageJson": false
},
"@angular/cdk": {
"version": "~16.1.0-next.2",
"alwaysAddToPackageJson": false
},
"@nguniversal/builders": {
"version": "~16.1.0-next.0",
"alwaysAddToPackageJson": false
},
"@nguniversal/common": {
"version": "~16.1.0-next.0",
"alwaysAddToPackageJson": false
},
"@nguniversal/express-engine": {
"version": "~16.1.0-next.0",
"alwaysAddToPackageJson": false
},
"@schematics/angular": {
"version": "~16.1.0-next.2",
"alwaysAddToPackageJson": false
},
"ng-packagr": {
"version": "~16.1.0-next.0",
"alwaysAddToPackageJson": false
}
}
}
}
}
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 = '~16.1.0-next.2';

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);
}
}
8 changes: 4 additions & 4 deletions packages/angular/src/utils/versions.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export const nxVersion = require('../../package.json').version;

export const angularVersion = '~16.0.0';
export const angularDevkitVersion = '~16.0.0';
export const ngPackagrVersion = '~16.0.0';
export const angularVersion = '~16.1.0-next.3';
export const angularDevkitVersion = '~16.1.0-next.2';
export const ngPackagrVersion = '~16.1.0-next.0';
export const ngrxVersion = '~16.0.0';
export const rxjsVersion = '~7.8.0';
export const zoneJsVersion = '~0.13.0';
export const angularJsVersion = '1.7.9';
export const tsLibVersion = '^2.3.0';

export const ngUniversalVersion = '~16.0.0';
export const ngUniversalVersion = '~16.1.0-next.0';
export const corsVersion = '~2.8.5';
export const typesCorsVersion = '~2.8.5';
export const expressVersion = '~4.18.2';
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 @@ -7,5 +7,5 @@ export const eslintConfigPrettierVersion = '8.1.0';

// TODO: remove when preset generation is reworked and
// deps are not installed from workspace
export const angularCliVersion = '~16.0.0';
export const angularCliVersion = '~16.1.0-next.2';
export const prettierVersion = '^2.6.2';
Loading

0 comments on commit 750ea32

Please sign in to comment.