Skip to content

Commit b6c3428

Browse files
authored
Merge pull request #967 from devlinjunker/angular-v14
Update Dependencies to Angular v14
2 parents 3c97b47 + dbb534a commit b6c3428

33 files changed

+6174
-2648
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,6 @@ If you make changes in `@uirouter/core`, run these scripts before rebuilding or
9292

9393
- `npm run build`: Compiles `@uirouter/core` code
9494
- `npm run watch`: Continuously builds the `@uirouter/core` code when sources change.
95+
96+
## Updating Angular Versions
97+
See notes in [add_support_for_new_angular_version.txt](./add_support_for_new_angular_version.txt) for steps to update the angular dependency version

downstream_projects.json

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
{
22
"packageDir": "./dist",
33
"projects": {
4-
"angular12": "./test-angular-versions/v12",
5-
"angular13": "./test-angular-versions/v13",
6-
"typescript37": "./test-typescript-versions/typescript3.7",
7-
"typescript38": "./test-typescript-versions/typescript3.8",
8-
"typescript39": "./test-typescript-versions/typescript3.9",
9-
"typescript40": "./test-typescript-versions/typescript4.0",
10-
"typescript41": "./test-typescript-versions/typescript4.1",
11-
"typescript42": "./test-typescript-versions/typescript4.2",
12-
"typescript43": "./test-typescript-versions/typescript4.3",
4+
"angular14": "./test-angular-versions/v14",
5+
"typescript46": "./test-typescript-versions/typescript4.6",
136
"sample-app-angular": "https://github.com/ui-router/sample-app-angular.git"
147
}
15-
}
8+
}

ng-package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
3+
"lib": {
4+
"entryFile": "src/index.ts"
5+
}
6+
}

package.json

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
{
2-
"$schema": "./node_modules/ng-packagr/package.schema.json",
32
"name": "@uirouter/angular",
43
"description": "State-based routing for Angular",
54
"version": "9.1.0",
65
"scripts": {
76
"clean": "shx rm -rf lib lib-esm _bundles _doc dist",
87
"compile": "npm run clean && ngc",
9-
"build": "ng-packagr -p package.json",
8+
"build": "ng-packagr -p ng-package.json",
109
"release": "release --deps @uirouter/core @uirouter/rx",
1110
"check-peer-dependencies": "check-peer-dependencies",
1211
"test": "jest --rootDir test",
@@ -44,49 +43,49 @@
4443
"license": "MIT",
4544
"distDir": "dist",
4645
"peerDependencies": {
47-
"@angular/common": "^12.0.0 || ^13.0.0",
48-
"@angular/core": "^12.0.0 || ^13.0.0",
46+
"@angular/common": "^14.0.0",
47+
"@angular/core": "^14.0.0",
4948
"@uirouter/core": "^6.0.8",
5049
"@uirouter/rx": "^1.0.0"
5150
},
5251
"devDependencies": {
53-
"@angular/animations": "13",
54-
"@angular/common": "13",
55-
"@angular/compiler": "13",
56-
"@angular/compiler-cli": "13",
57-
"@angular/core": "13",
58-
"@angular/platform-browser": "13",
59-
"@angular/platform-browser-dynamic": "13",
52+
"@angular-devkit/build-angular": "^14.0.0",
53+
"@angular/animations": "^14.0.0",
54+
"@angular/common": "^14.0.0",
55+
"@angular/compiler": "^14.0.0",
56+
"@angular/compiler-cli": "^14.0.0",
57+
"@angular/core": "^14.1.0",
58+
"@angular/platform-browser": "^14.0.0",
59+
"@angular/platform-browser-dynamic": "^14.0.0",
6060
"@types/jest": "^27.0.3",
6161
"@types/jquery": "^3.5.9",
6262
"@uirouter/core": "^6.0.8",
6363
"@uirouter/publish-scripts": "2.6.0",
6464
"@uirouter/rx": "^1.0.0",
6565
"husky": "^7.0.4",
66-
"jest": "27.3.1",
67-
"jest-preset-angular": "11.0.1",
68-
"ng-packagr": "13",
66+
"jest": "^28.0.0",
67+
"jest-preset-angular": "^12.2.0",
68+
"ng-packagr": "^14.0.0",
6969
"postcss": "^8.0.0",
7070
"prettier": "^2.5.0",
7171
"pretty-quick": "^3.1.2",
7272
"rxjs": "6.6.7",
7373
"rxjs-compat": "^6.5.4",
74+
"schema-utils": "^4.0.0",
7475
"ts-node": "10.4.0",
7576
"tslint": "^6.1.0",
76-
"typescript": "~4.4.2",
77+
"typescript": "~4.6.2",
7778
"zone.js": "0.11.4"
7879
},
79-
"ngPackage": {
80-
"lib": {
81-
"entryFile": "src/index.ts"
82-
}
83-
},
8480
"jest": {
8581
"preset": "jest-preset-angular",
8682
"setupFilesAfterEnv": [
8783
"./setupJest.ts"
8884
]
8985
},
86+
"checkPeerDependencies": {
87+
"ignore": ["ajv"]
88+
},
9089
"husky": {
9190
"hooks": {
9291
"pre-commit": "pretty-quick --staged"

test-angular-versions/v14/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# V14
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.1.
4+
5+
## Development server
6+
7+
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.
8+
9+
## Code scaffolding
10+
11+
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`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
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.
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"cli": {
5+
"packageManager": "yarn"
6+
},
7+
"newProjectRoot": "projects",
8+
"projects": {
9+
"v14": {
10+
"projectType": "application",
11+
"schematics": {
12+
"@schematics/angular:class": {
13+
"skipTests": true
14+
},
15+
"@schematics/angular:component": {
16+
"skipTests": true
17+
},
18+
"@schematics/angular:directive": {
19+
"skipTests": true
20+
},
21+
"@schematics/angular:guard": {
22+
"skipTests": true
23+
},
24+
"@schematics/angular:interceptor": {
25+
"skipTests": true
26+
},
27+
"@schematics/angular:pipe": {
28+
"skipTests": true
29+
},
30+
"@schematics/angular:resolver": {
31+
"skipTests": true
32+
},
33+
"@schematics/angular:service": {
34+
"skipTests": true
35+
}
36+
},
37+
"root": "",
38+
"sourceRoot": "src",
39+
"prefix": "app",
40+
"architect": {
41+
"build": {
42+
"builder": "@angular-devkit/build-angular:browser",
43+
"options": {
44+
"outputPath": "dist/v14",
45+
"index": "src/index.html",
46+
"main": "src/main.ts",
47+
"polyfills": "src/polyfills.ts",
48+
"tsConfig": "tsconfig.app.json",
49+
"assets": [
50+
"src/favicon.ico",
51+
"src/assets"
52+
],
53+
"styles": [
54+
"src/styles.css"
55+
],
56+
"scripts": []
57+
},
58+
"configurations": {
59+
"production": {
60+
"budgets": [
61+
{
62+
"type": "initial",
63+
"maximumWarning": "500kb",
64+
"maximumError": "1mb"
65+
},
66+
{
67+
"type": "anyComponentStyle",
68+
"maximumWarning": "2kb",
69+
"maximumError": "4kb"
70+
}
71+
],
72+
"fileReplacements": [
73+
{
74+
"replace": "src/environments/environment.ts",
75+
"with": "src/environments/environment.prod.ts"
76+
}
77+
],
78+
"outputHashing": "all"
79+
},
80+
"development": {
81+
"buildOptimizer": false,
82+
"optimization": false,
83+
"vendorChunk": true,
84+
"extractLicenses": false,
85+
"sourceMap": true,
86+
"namedChunks": true
87+
}
88+
},
89+
"defaultConfiguration": "production"
90+
},
91+
"serve": {
92+
"builder": "@angular-devkit/build-angular:dev-server",
93+
"configurations": {
94+
"production": {
95+
"browserTarget": "v14:build:production"
96+
},
97+
"development": {
98+
"browserTarget": "v14:build:development"
99+
}
100+
},
101+
"defaultConfiguration": "development"
102+
},
103+
"extract-i18n": {
104+
"builder": "@angular-devkit/build-angular:extract-i18n",
105+
"options": {
106+
"browserTarget": "v14:build"
107+
}
108+
},
109+
"test": {
110+
"builder": "@angular-devkit/build-angular:karma",
111+
"options": {
112+
"main": "src/test.ts",
113+
"polyfills": "src/polyfills.ts",
114+
"tsConfig": "tsconfig.spec.json",
115+
"karmaConfig": "karma.conf.js",
116+
"assets": [
117+
"src/favicon.ico",
118+
"src/assets"
119+
],
120+
"styles": [
121+
"src/styles.css"
122+
],
123+
"scripts": []
124+
}
125+
}
126+
}
127+
}
128+
}
129+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"baseUrl": "http://localhost:4000",
3+
"video": false
4+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
describe('Angular app', () => {
2+
beforeEach(() => {
3+
window.sessionStorage.clear();
4+
});
5+
6+
it('loads', () => {
7+
cy.visit('');
8+
});
9+
10+
it('loads home state by default', () => {
11+
cy.visit('');
12+
cy.url().should('include', '/home');
13+
});
14+
15+
it('renders uisref as links', () => {
16+
cy.visit('');
17+
cy.get('a').contains('home');
18+
cy.get('a').contains('about');
19+
cy.get('a').contains('lazy');
20+
cy.get('a').contains('lazy.child');
21+
cy.get('a').contains('lazy.child.viewtarget');
22+
});
23+
24+
it('renders home', () => {
25+
cy.visit('/home');
26+
cy.get('a').contains('home').should('have.class', 'active');
27+
cy.get('a').contains('about').should('not.have.class', 'active');
28+
cy.get('#default').contains('home works');
29+
});
30+
31+
it('renders about', () => {
32+
cy.visit('/home');
33+
cy.visit('/about');
34+
cy.get('a').contains('home').should('not.have.class', 'active');
35+
cy.get('a').contains('about').should('have.class', 'active');
36+
cy.get('#default').contains('about works');
37+
});
38+
39+
it('loads lazy routes', () => {
40+
cy.visit('/home');
41+
cy.visit('/lazy');
42+
cy.get('a').contains('home').should('not.have.class', 'active');
43+
cy.get('a').contains('lazy').should('have.class', 'active');
44+
cy.get('#default').contains('lazy works');
45+
});
46+
47+
it('routes to lazy routes', () => {
48+
cy.visit('/lazy');
49+
cy.get('a').contains('home').should('not.have.class', 'active');
50+
cy.get('a').contains('lazy').should('have.class', 'active');
51+
cy.get('#default').contains('lazy works');
52+
});
53+
54+
it('routes to lazy child routes', () => {
55+
cy.visit('/lazy/child');
56+
cy.get('a').contains('home').should('not.have.class', 'active');
57+
cy.get('a').contains('lazy.child').should('have.class', 'active');
58+
cy.get('#default').contains('lazy.child works');
59+
});
60+
61+
it('targets named views', () => {
62+
cy.visit('/lazy/child/viewtarget');
63+
cy.get('a').contains('home').should('not.have.class', 'active');
64+
cy.get('a').contains('lazy.child').should('have.class', 'active');
65+
cy.get('#default').contains('lazy.child works');
66+
cy.get('#header').contains('lazy.child.viewtarget works');
67+
cy.get('#footer').contains('lazy.child.viewtarget works');
68+
});
69+
});
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage'),
13+
require('@angular-devkit/build-angular/plugins/karma')
14+
],
15+
client: {
16+
jasmine: {
17+
// you can add configuration options for Jasmine here
18+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19+
// for example, you can disable the random execution with `random: false`
20+
// or set a specific seed with `seed: 4321`
21+
},
22+
clearContext: false // leave Jasmine Spec Runner output visible in browser
23+
},
24+
jasmineHtmlReporter: {
25+
suppressAll: true // removes the duplicated traces
26+
},
27+
coverageReporter: {
28+
dir: require('path').join(__dirname, './coverage/v14'),
29+
subdir: '.',
30+
reporters: [
31+
{ type: 'html' },
32+
{ type: 'text-summary' }
33+
]
34+
},
35+
reporters: ['progress', 'kjhtml'],
36+
port: 9876,
37+
colors: true,
38+
logLevel: config.LOG_INFO,
39+
autoWatch: true,
40+
browsers: ['Chrome'],
41+
singleRun: false,
42+
restartOnFileChange: true
43+
});
44+
};

0 commit comments

Comments
 (0)