Skip to content

Commit

Permalink
chore(demo, components-angular): Upgrade to Angular 16 (#1920)
Browse files Browse the repository at this point in the history
```[tasklist]
### Tasks
- [x] Follow [angular update guide](https://update.angular.io/?v=15.0-16.0)
- [x] Check [changelog from ng-packagr](https://github.com/ng-packagr/ng-packagr/blob/HEAD/CHANGELOG.md#1600-2023-05-03)
- [x] Check [changelog from ng-bootstrap](https://github.com/ng-bootstrap/ng-bootstrap/blob/HEAD/CHANGELOG.md#1500-2023-05-25)
- [x] Check [changelog from ngx-highlightjs](https://togithub.com/murhafsousli/ngx-highlightjs/blob/HEAD/CHANGELOG.md#900)
``` 

# components-angular (no changes)


![image](https://github.com/swisspost/design-system/assets/12294151/98bbae67-65ee-4e7d-bd3f-c756c4a8f0da)

# PRs

close #1914
close #1913 
close #1912
close #1911
close #1901

---------

Co-authored-by: Alizé Debray <[email protected]>
Co-authored-by: Alizé Debray <[email protected]>
Co-authored-by: Philipp Gfeller <[email protected]>
  • Loading branch information
4 people authored Sep 12, 2023
1 parent 4c519b3 commit 54eb63a
Show file tree
Hide file tree
Showing 7 changed files with 2,131 additions and 2,153 deletions.
7 changes: 7 additions & 0 deletions .changeset/cyan-seahorses-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@swisspost/design-system-components-angular': major
'@swisspost/design-system-intranet-header': major
'@swisspost/design-system-demo': major
---

Upgraded major version of Angular from v15 to v16.
3 changes: 3 additions & 0 deletions packages/components-angular/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,8 @@
"@angular-eslint/schematics:library": {
"setParserOptionsProject": true
}
},
"cli": {
"analytics": false
}
}
40 changes: 20 additions & 20 deletions packages/components-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
"lint": "ng lint"
},
"dependencies": {
"@angular/animations": "15.2.9",
"@angular/common": "15.2.9",
"@angular/compiler": "15.2.9",
"@angular/core": "15.2.9",
"@angular/forms": "15.2.9",
"@angular/localize": "15.2.9",
"@angular/platform-browser": "15.2.9",
"@angular/platform-browser-dynamic": "15.2.9",
"@angular/router": "15.2.9",
"@ng-bootstrap/ng-bootstrap": "14.2.0",
"@angular/animations": "16.2.3",
"@angular/common": "16.2.3",
"@angular/compiler": "16.2.3",
"@angular/core": "16.2.3",
"@angular/forms": "16.2.3",
"@angular/localize": "16.2.3",
"@angular/platform-browser": "16.2.3",
"@angular/platform-browser-dynamic": "16.2.3",
"@angular/router": "16.2.3",
"@ng-bootstrap/ng-bootstrap": "15.1.1",
"@popperjs/core": "2.11.8",
"@swisspost/design-system-styles": "workspace:6.4.0",
"rxjs": "7.8.1",
Expand All @@ -28,26 +28,26 @@
"zone.js": "0.13.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "15.2.9",
"@angular-eslint/builder": "15.2.1",
"@angular-eslint/eslint-plugin": "15.2.1",
"@angular-eslint/eslint-plugin-template": "15.2.1",
"@angular-eslint/schematics": "15.2.1",
"@angular-eslint/template-parser": "15.2.1",
"@angular/cli": "15.2.9",
"@angular/compiler-cli": "15.2.9",
"@angular-devkit/build-angular": "16.2.1",
"@angular-eslint/builder": "16.1.1",
"@angular-eslint/eslint-plugin": "16.1.1",
"@angular-eslint/eslint-plugin-template": "16.1.1",
"@angular-eslint/schematics": "16.1.1",
"@angular-eslint/template-parser": "16.1.1",
"@angular/cli": "16.2.1",
"@angular/compiler-cli": "16.2.3",
"@types/jasmine": "4.3.5",
"@types/node": "18.17.14",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.48.0",
"jasmine-core": "4.6.0",
"jasmine-core": "5.1.1",
"karma": "6.4.2",
"karma-chrome-launcher": "3.2.0",
"karma-coverage": "2.2.1",
"karma-jasmine": "5.1.0",
"karma-jasmine-html-reporter": "2.1.0",
"ng-packagr": "15.2.2",
"ng-packagr": "16.2.2",
"rimraf": "5.0.1",
"typescript": "4.9.5"
}
Expand Down
48 changes: 24 additions & 24 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,51 @@
"lint": "ng lint"
},
"dependencies": {
"@angular/animations": "15.2.9",
"@angular/cdk": "15.2.9",
"@angular/common": "15.2.9",
"@angular/compiler": "15.2.9",
"@angular/core": "15.2.9",
"@angular/forms": "15.2.9",
"@angular/localize": "15.2.9",
"@angular/platform-browser": "15.2.9",
"@angular/platform-browser-dynamic": "15.2.9",
"@angular/router": "15.2.9",
"@ng-bootstrap/ng-bootstrap": "14.2.0",
"@angular/animations": "16.2.3",
"@angular/cdk": "16.2.2",
"@angular/common": "16.2.3",
"@angular/compiler": "16.2.3",
"@angular/core": "16.2.3",
"@angular/forms": "16.2.3",
"@angular/localize": "16.2.3",
"@angular/platform-browser": "16.2.3",
"@angular/platform-browser-dynamic": "16.2.3",
"@angular/router": "16.2.3",
"@ng-bootstrap/ng-bootstrap": "15.1.1",
"@popperjs/core": "2.11.8",
"@swimlane/ngx-datatable": "20.1.0",
"@swisspost/design-system-intranet-header": "workspace:4.0.10",
"@swisspost/design-system-styles": "workspace:6.4.0",
"bootstrap": "5.3.1",
"core-js": "3.32.1",
"highlight.js": "11.8.0",
"ngx-highlightjs": "8.0.0",
"ngx-toastr": "16.2.0",
"ngx-highlightjs": "10.0.0",
"ngx-toastr": "17.0.2",
"prettier": "2.8.8",
"rxjs": "7.8.1",
"tslib": "2.6.2",
"zone.js": "0.13.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "15.2.9",
"@angular-devkit/build-angular": "16.2.1",
"@angular-devkit/build-optimizer": "0.1202.18",
"@angular-eslint/builder": "15.2.1",
"@angular-eslint/eslint-plugin": "15.2.1",
"@angular-eslint/eslint-plugin-template": "15.2.1",
"@angular-eslint/schematics": "15.2.1",
"@angular-eslint/template-parser": "15.2.1",
"@angular/cli": "15.2.9",
"@angular/compiler-cli": "15.2.9",
"@angular/elements": "15.2.9",
"@angular/language-service": "15.2.9",
"@angular-eslint/builder": "16.1.1",
"@angular-eslint/eslint-plugin": "16.1.1",
"@angular-eslint/eslint-plugin-template": "16.1.1",
"@angular-eslint/schematics": "16.1.1",
"@angular-eslint/template-parser": "16.1.1",
"@angular/cli": "16.2.1",
"@angular/compiler-cli": "16.2.3",
"@angular/elements": "16.2.3",
"@angular/language-service": "16.2.3",
"@types/highlight.js": "9.12.4",
"@types/jasmine": "4.3.5",
"@types/jasminewd2": "2.0.10",
"@types/node": "18.17.14",
"@typescript-eslint/eslint-plugin": "5.62.0",
"@typescript-eslint/parser": "5.62.0",
"eslint": "8.48.0",
"jasmine-core": "4.6.0",
"jasmine-core": "5.1.1",
"jasmine-marbles": "0.9.2",
"jasmine-spec-reporter": "7.0.0",
"karma": "6.4.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

import { Component, Input, OnDestroy } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Subscription } from 'rxjs';
import { combineLatest, from, Subscription, switchMap } from 'rxjs';
import { VersionService } from '../version.service';
import { HttpClient } from '@angular/common/http';
import { map } from 'rxjs/operators';
import { Observable } from 'rxjs/internal/Observable';

@Component({
selector: 'app-dependency-link',
Expand All @@ -19,14 +22,25 @@ export class DependencyLinkComponent implements OnDestroy {
documentationBaseUrl: string;
urlChangeSubscription: Subscription;

constructor(private route: ActivatedRoute, private versionService: VersionService) {
this.urlChangeSubscription = this.route.url.subscribe(() => {
constructor(
private route: ActivatedRoute,
private versionService: VersionService,
private http: HttpClient,
) {
this.urlChangeSubscription = combineLatest([
this.getLatestVersion('@ng-bootstrap/ng-bootstrap'),
this.route.url,
]).subscribe(([ngBootStrapLatestVersion, _]) => {
const { dependencies } = this.versionService.localVersion;
const ngBootStrapLatestMajorVersion = ngBootStrapLatestVersion.split('.')[0];

if (route.parent.snapshot.url[0].path === 'ng-bootstrap-samples') {
this.dependency = 'ng-bootstrap';
this.dependencyVersion = dependencies.get('@ng-bootstrap/ng-bootstrap').format('x');
this.documentationBaseUrl = `https://ng-bootstrap.github.io${
this.dependencyVersion === '14' ? '' : `/releases/${this.dependencyVersion}.x`
this.dependencyVersion === ngBootStrapLatestMajorVersion
? ''
: `/releases/${this.dependencyVersion}.x`
}/#/`;
} else {
this.dependency = 'Bootstrap';
Expand All @@ -40,6 +54,25 @@ export class DependencyLinkComponent implements OnDestroy {
});
}

private getLatestVersion(packageName: string): Observable<string> {
const url = `https://registry.npmjs.org/${packageName}/latest`;

const cachedResponse = caches
.match(url)
.catch(() => fetch(url))
.then(response => {
caches.open('npm').then(cache => {
void cache.put(url, response);
});
return response.clone();
});

return from(cachedResponse).pipe(
switchMap(response => response.json()),
map(packageConfig => packageConfig.version),
);
}

ngOnDestroy() {
this.urlChangeSubscription.unsubscribe();
}
Expand Down
Loading

0 comments on commit 54eb63a

Please sign in to comment.