Skip to content

Commit

Permalink
chore: Angular 18 support (#993)
Browse files Browse the repository at this point in the history
* chore: Angular 18 support
  • Loading branch information
lukaVarga authored Jul 10, 2024
1 parent 3acf99b commit 60314f4
Show file tree
Hide file tree
Showing 26 changed files with 3,164 additions and 2,431 deletions.
4 changes: 2 additions & 2 deletions downstream_projects.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packageDir": "./dist",
"projects": {
"sample-app-angular": "https://github.com/ui-router/sample-app-angular.git",
"angular17": "./test-angular-versions/v17",
"typescript52": "./test-typescript-versions/typescript5.2"
"angular18": "./test-angular-versions/v18",
"typescript54": "./test-typescript-versions/typescript5.4"
}
}
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@uirouter/angular",
"description": "State-based routing for Angular",
"version": "13.0.0",
"version": "14.0.0",
"scripts": {
"clean": "shx rm -rf lib lib-esm _bundles _doc dist",
"compile": "npm run clean && ngc",
Expand Down Expand Up @@ -43,20 +43,20 @@
"license": "MIT",
"distDir": "dist",
"peerDependencies": {
"@angular/common": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/common": "^18.0.0",
"@angular/core": "^18.0.0",
"@uirouter/core": "^6.0.8",
"@uirouter/rx": "^1.0.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.0",
"@angular/animations": "^17.0.0",
"@angular/common": "^17.0.0",
"@angular/compiler": "^17.0.0",
"@angular/compiler-cli": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/platform-browser": "^17.0.0",
"@angular/platform-browser-dynamic": "^17.0.0",
"@angular-devkit/build-angular": "^18.0.0",
"@angular/animations": "^18.0.0",
"@angular/common": "^18.0.0",
"@angular/compiler": "^18.0.0",
"@angular/compiler-cli": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@types/jest": "^27.0.3",
"@types/jquery": "^3.5.9",
"@types/node": "^20.11.4",
Expand All @@ -65,8 +65,8 @@
"@uirouter/rx": "^1.0.0",
"husky": "^7.0.4",
"jest": "^29.0.0",
"jest-preset-angular": "^14.0.0",
"ng-packagr": "^17.0.0",
"jest-preset-angular": "^14.1.1",
"ng-packagr": "^18.0.0",
"postcss": "^8.0.0",
"prettier": "^2.5.0",
"pretty-quick": "^3.1.2",
Expand All @@ -76,7 +76,7 @@
"ts-node": "10.4.0",
"tslib": "^2.3.0",
"tslint": "^6.1.0",
"typescript": "~5.2.2",
"typescript": "~5.4.5",
"zone.js": "~0.14.0"
},
"jest": {
Expand Down
27 changes: 27 additions & 0 deletions test-angular-versions/v18/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# V18

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.0.7.

## Development server

Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.

## Code scaffolding

Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.

## Build

Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.

## Running unit tests

Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Running end-to-end tests

Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
124 changes: 124 additions & 0 deletions test-angular-versions/v18/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"packageManager": "yarn"
},
"newProjectRoot": "projects",
"projects": {
"v18": {
"projectType": "application",
"schematics": {
"@schematics/angular:class": {
"skipTests": true
},
"@schematics/angular:component": {
"skipTests": true
},
"@schematics/angular:directive": {
"skipTests": true
},
"@schematics/angular:guard": {
"skipTests": true
},
"@schematics/angular:interceptor": {
"skipTests": true
},
"@schematics/angular:pipe": {
"skipTests": true
},
"@schematics/angular:resolver": {
"skipTests": true
},
"@schematics/angular:service": {
"skipTests": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/v18",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "2kB",
"maximumError": "4kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "v18:build:production"
},
"development": {
"buildTarget": "v18:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": [
"src/styles.css"
],
"scripts": []
}
}
}
}
}
}
10 changes: 10 additions & 0 deletions test-angular-versions/v18/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from 'cypress';

export default defineConfig({
video: false,
e2e: {
setupNodeEvents(on, config) {},
baseUrl: 'http://localhost:4000',
supportFile: false
},
})
69 changes: 69 additions & 0 deletions test-angular-versions/v18/cypress/e2e/sample_app.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
describe('Angular app', () => {
beforeEach(() => {
window.sessionStorage.clear();
});

it('loads', () => {
cy.visit('');
});

it('loads home state by default', () => {
cy.visit('');
cy.url().should('include', '/home');
});

it('renders uisref as links', () => {
cy.visit('');
cy.get('a').contains('home');
cy.get('a').contains('about');
cy.get('a').contains('lazy');
cy.get('a').contains('lazy.child');
cy.get('a').contains('lazy.child.viewtarget');
});

it('renders home', () => {
cy.visit('/home');
cy.get('a').contains('home').should('have.class', 'active');
cy.get('a').contains('about').should('not.have.class', 'active');
cy.get('#default').contains('home works');
});

it('renders about', () => {
cy.visit('/home');
cy.visit('/about');
cy.get('a').contains('home').should('not.have.class', 'active');
cy.get('a').contains('about').should('have.class', 'active');
cy.get('#default').contains('about works');
});

it('loads lazy routes', () => {
cy.visit('/home');
cy.visit('/lazy');
cy.get('a').contains('home').should('not.have.class', 'active');
cy.get('a').contains('lazy').should('have.class', 'active');
cy.get('#default').contains('lazy works');
});

it('routes to lazy routes', () => {
cy.visit('/lazy');
cy.get('a').contains('home').should('not.have.class', 'active');
cy.get('a').contains('lazy').should('have.class', 'active');
cy.get('#default').contains('lazy works');
});

it('routes to lazy child routes', () => {
cy.visit('/lazy/child');
cy.get('a').contains('home').should('not.have.class', 'active');
cy.get('a').contains('lazy.child').should('have.class', 'active');
cy.get('#default').contains('lazy.child works');
});

it('targets named views', () => {
cy.visit('/lazy/child/viewtarget');
cy.get('a').contains('home').should('not.have.class', 'active');
cy.get('a').contains('lazy.child').should('have.class', 'active');
cy.get('#default').contains('lazy.child works');
cy.get('#header').contains('lazy.child.viewtarget works');
cy.get('#footer').contains('lazy.child.viewtarget works');
});
});
50 changes: 50 additions & 0 deletions test-angular-versions/v18/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "v18",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "npm run test:dev && npm run test:prod",
"test:dev": "ng build --configuration development && cypress-runner run --path dist/v18/browser",
"test:prod": "ng build --configuration production && cypress-runner run --path dist/v18/browser"
},
"private": true,
"dependencies": {
"@angular/animations": "^18.0.0",
"@angular/common": "^18.0.0",
"@angular/compiler": "^18.0.0",
"@angular/core": "^18.0.0",
"@angular/forms": "^18.0.0",
"@angular/platform-browser": "^18.0.0",
"@angular/platform-browser-dynamic": "^18.0.0",
"@angular/router": "^18.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.14.3",
"@uirouter/angular": "*",
"@uirouter/cypress-runner": "*",
"@uirouter/core": "*",
"@uirouter/rx": "*"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.0.7",
"@angular/cli": "^18.0.7",
"@angular/compiler-cli": "^18.0.0",
"@types/jasmine": "~5.1.0",
"jasmine-core": "~5.1.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.4.5"
},
"checkPeerDependencies": {
"ignore": [
"ajv",
"terser"
]
}
}
Binary file added test-angular-versions/v18/public/favicon.ico
Binary file not shown.
8 changes: 8 additions & 0 deletions test-angular-versions/v18/src/app/about.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-about',
template: ` <p>about works!</p> `,
standalone: true,
})
export class AboutComponent {}
Empty file.
35 changes: 35 additions & 0 deletions test-angular-versions/v18/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { Component } from '@angular/core';
import { UIRouterModule } from '@uirouter/angular';

@Component({
selector: 'app-root',
template: `
<ui-view name="header" id="header"></ui-view>
<div class="app">
<img width="300" alt="Angular Logo" src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTAgMjUwIj4KICAgIDxwYXRoIGZpbGw9IiNERDAwMzEiIGQ9Ik0xMjUgMzBMMzEuOSA2My4ybDE0LjIgMTIzLjFMMTI1IDIzMGw3OC45LTQzLjcgMTQuMi0xMjMuMXoiIC8+CiAgICA8cGF0aCBmaWxsPSIjQzMwMDJGIiBkPSJNMTI1IDMwdjIyLjItLjFWMjMwbDc4LjktNDMuNyAxNC4yLTEyMy4xTDEyNSAzMHoiIC8+CiAgICA8cGF0aCAgZmlsbD0iI0ZGRkZGRiIgZD0iTTEyNSA1Mi4xTDY2LjggMTgyLjZoMjEuN2wxMS43LTI5LjJoNDkuNGwxMS43IDI5LjJIMTgzTDEyNSA1Mi4xem0xNyA4My4zaC0zNGwxNy00MC45IDE3IDQwLjl6IiAvPgogIDwvc3ZnPg==">
<div>
<a uiSref="home" uiSrefActive="active">home</a>
<a uiSref="about" uiSrefActive="active">about</a>
<a uiSref="lazy" uiSrefActiveEq="active">lazy</a>
<a uiSref="lazy.child" uiSrefActive="active">lazy.child</a>
<a uiSref="lazy.child.viewtarget" uiSrefActive="active">lazy.child.viewtarget</a>
</div>
<ui-view id="default"></ui-view>
</div>
<ui-view name="footer" id="footer"></ui-view>
`,
styles: [
`
.app {
text-align: center;
border: 1px solid;
}
.active {
font-weight: bold;
}
`,
],
standalone: true,
imports: [UIRouterModule]
})
export class AppComponent {}
Loading

0 comments on commit 60314f4

Please sign in to comment.