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

chore: CXSPA-4724 Upgrade to Angular 16 #17941

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
cf74b84
chore: RxJs 7 (#17362)
ercultimate May 8, 2023
bbdf149
chore: fix compilation errors in libraries
ercultimate May 8, 2023
007cdf1
CXSPA-3077: Cleanup deprecated `retryWhen()` (#17385)
ercultimate May 10, 2023
f2f9366
chore: cleanup deprecated `publishReplay()` (#17387)
ercultimate May 10, 2023
f481daa
chore: Clean up deprecated `BehaviorSubject.hasError` (#17390)
ercultimate May 10, 2023
0599c86
chore: cleanup deprecated `throwError()` (#17386)
ercultimate May 10, 2023
2a7b2b5
chore: Cleanup deprecated `toPromise()` (#17383)
ercultimate May 11, 2023
c78b1fc
Merge remote-tracking branch 'origin/develop-6.1.x' into epic/CXSPA-2897
ercultimate May 11, 2023
866ca82
chore: fix sonar issues
ercultimate May 11, 2023
fa32810
Merge branch 'develop-6.5.x' into epic/CXSPA-2897
pawelfras Sep 27, 2023
fc60129
feat: CXSPA-4804 add missing logger service
pawelfras Sep 27, 2023
2f46c1b
Merge branch 'develop-6.5.x' into epic/CXSPA-2897
pawelfras Sep 27, 2023
9fb5c47
Merge branch 'develop-6.5.x' into epic/CXSPA-2897
pawelfras Oct 3, 2023
33f980c
chore: CXSPA-4841 Fix unit tests and dependencies (#17904)
pawelfras Oct 3, 2023
f538f1a
Trigger Build
pawelfras Oct 4, 2023
035189c
chore: CXSPA-4884 Tap operator handlers (#17905)
pawelfras Oct 5, 2023
a2bfa27
Merge branch 'develop-6.6.x' into epic/CXSPA-2897
pawelfras Oct 5, 2023
eb7351e
Merge branch 'develop-6.6.x' into epic/CXSPA-2897
pawelfras Oct 9, 2023
8eca6e2
chore: CXSPA-4724 Upgrade to Angular 16 - Nx and deps upgrade
pawelfras Oct 9, 2023
f4e8eab
chore: CXSPA-4724 Upgrade to Angular 16 - Nx migration process
pawelfras Oct 9, 2023
5554bdf
chore: CXSPA-4724 Upgrade to Angular 16 - Errors in libraries
pawelfras Oct 10, 2023
794e88d
chore: CXSPA-4724 Upgrade to Angular 16 - Schematics
pawelfras Oct 10, 2023
1a2ea15
chore: CXSPA-4724 Upgrade to Angular 16 - Dependencies in libraries
pawelfras Oct 12, 2023
7a9b513
chore: CXSPA-4724 Upgrade to Angular 16 - Unit tests
pawelfras Oct 19, 2023
204aa58
add ticket id to TODOs
pawelfras Oct 19, 2023
4066bfb
chore: CXSPA-4724 Upgrade to Angular 16 - Linting issues
pawelfras Oct 20, 2023
79cdfde
chore: enable pipeline steps
pawelfras Oct 20, 2023
7b35ef0
chore: enable pipeline steps
pawelfras Oct 20, 2023
eb27fd6
chore: Upgrade to Angular 16 - CI
pawelfras Oct 23, 2023
1e0e13d
chore: Upgrade to Angular 16 - SSR
pawelfras Oct 23, 2023
0f72123
Merge branch 'develop-next-major' into feature/CXSPA-4724-angular-16-…
pawelfras Oct 24, 2023
d009781
chore: restore package-lock.json
pawelfras Oct 25, 2023
1bc90a5
chore: Upgrade to Angular 16 - schematics
pawelfras Oct 25, 2023
8c67156
chore: Upgrade to Angular 16 - schematics
pawelfras Oct 25, 2023
b7f43fd
Trigger Build
pawelfras Oct 26, 2023
bf0075c
chore: Upgrade to Angular 16 - upgrade to 16.2.10
pawelfras Oct 26, 2023
5153e24
fix unit test
pawelfras Oct 26, 2023
342d94d
restore BrowserModule
pawelfras Oct 26, 2023
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
13 changes: 7 additions & 6 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
"createDefaultProgram": true
},
"extends": [
"plugin:@angular-eslint/ng-cli-compat",
"plugin:@angular-eslint/ng-cli-compat--formatting-add-on",
"plugin:@angular-eslint/template/process-inline-templates"
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"./tools/eslint-plugins/legacy-ng-cli-compat",
"./tools/eslint-plugins/legacy-ng-cli-compat--formatting-add-on"
],
"plugins": ["deprecation", "@typescript-eslint", "@nrwl/nx"],
"plugins": ["deprecation", "@typescript-eslint", "@nx"],
"rules": {
"@angular-eslint/no-host-metadata-property": "off",
"@typescript-eslint/no-empty-interface": "off",
Expand Down Expand Up @@ -69,7 +70,7 @@
"max-len": "off",
"linebreak-style": ["error", "unix"],
"no-underscore-dangle": "off",
"@nrwl/nx/enforce-module-boundaries": [
"@nx/enforce-module-boundaries": [
"error",
{
"allow": [],
Expand Down Expand Up @@ -108,7 +109,7 @@
{
"files": ["*.module.ts"],
"rules": {
"@nrwl/nx/workspace/use-default-provide-config": "error"
"@nx/workspace/use-default-provide-config": "error"
}
}
]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-merge-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- develop
- develop-*
- release/**
- epic/**
workflow_dispatch:
# empty as it is used only to manually trigger the workflow

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-pull-request-status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
- develop
- develop-*
- release/**
- epic/**
workflow_dispatch:
# empty as it is used only to manually trigger the workflow

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
- develop
- develop-*
- release/**
- epic/**
workflow_dispatch:
# empty as it is used only to manually trigger the workflow

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,5 @@ Thumbs.db

**/git-ignore


.nx/cache
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ feature-libs/smartedit/assets/webApplicationInjector.js
**/*.md
**/*.yml
coverage

/.nx/cache
2 changes: 1 addition & 1 deletion ci-scripts/validate-lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fi
validateStylesLint

echo "Validating code linting"
node --max_old_space_size=3584 ./node_modules/@nrwl/cli/bin/nx run-many --all --target=lint
node --max_old_space_size=3584 ./node_modules/nx/bin/nx run-many --all --target=lint

echo "-----"

Expand Down
1 change: 0 additions & 1 deletion core-libs/setup/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const { defaultTransformerOptions } = require('jest-preset-angular/presets');
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
module.exports = {
preset: 'jest-preset-angular',
globalSetup: 'jest-preset-angular/global-setup',
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths || {}, {
prefix: '<rootDir>/',
}),
Expand Down
6 changes: 3 additions & 3 deletions core-libs/setup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
"tslib": "^2.6.2"
},
"peerDependencies": {
"@angular/core": "^15.2.9",
"@angular/core": "^16.2.10",
"@spartacus/cart": "6.6.0-1",
"@spartacus/core": "6.6.0-1",
"@spartacus/order": "6.6.0-1",
"@spartacus/user": "6.6.0-1"
},
"optionalDependencies": {
"@angular/platform-server": "^15.2.9",
"@nguniversal/express-engine": "^15.2.0",
"@angular/platform-server": "^16.2.10",
"@nguniversal/express-engine": "^16.2.0",
"express": "^4.18.2"
},
"publishConfig": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
import * as angularCore from '@angular/core';
jest.mock('@angular/core', () => {
return {
...jest.requireActual('@angular/core'),
isDevMode: jest.fn(),
};
});

import { isDevMode } from '@angular/core';
import { Request } from 'express';
import { DefaultExpressServerLogger } from './default-express-server-logger';

Expand Down Expand Up @@ -37,7 +44,7 @@ describe('DefaultExpressServerLogger', () => {

describe('is not dev mode', () => {
beforeEach(() => {
jest.spyOn(angularCore, 'isDevMode').mockReturnValue(false);
(isDevMode as jest.Mock).mockReturnValue(false);
});

it('should log proper shape of the JSON', () => {
Expand Down Expand Up @@ -113,7 +120,7 @@ describe('DefaultExpressServerLogger', () => {

describe('is dev mode', () => {
beforeEach(() => {
jest.spyOn(angularCore, 'isDevMode').mockReturnValue(true);
(isDevMode as jest.Mock).mockReturnValue(true);
});

it('should log proper shape of the JSON', () => {
Expand Down
21 changes: 15 additions & 6 deletions core-libs/setup/ssr/providers/server-request-origin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,48 @@
*
* SPDX-License-Identifier: Apache-2.0
*/

import * as injectFn from '@angular/core';
import { serverRequestOriginFactory } from './server-request-origin';

jest.mock('@angular/core', () => {
return {
...jest.requireActual('@angular/core'),
inject: jest.fn(),
};
});

import { inject } from '@angular/core';

describe('serverRequestOriginFactory', () => {
describe('when SERVER_REQUEST_ORIGIN is present', () => {
it('should return SERVER_REQUEST_ORIGIN', () => {
const mockOrigin = 'https://express.origin.com';
jest.spyOn(injectFn, 'inject').mockReturnValue(mockOrigin);
(inject as jest.Mock).mockReturnValue(mockOrigin);

const result = serverRequestOriginFactory()();

expect(result).toEqual(mockOrigin);
});
});
describe('when SERVER_REQUEST_ORIGIN is NOT present', () => {
beforeEach(() => {
jest.spyOn(injectFn, 'inject').mockReturnValue(null);
(inject as jest.Mock).mockReturnValue(null);
});

describe('and when options.serverRequestOrigin is present', () => {
it('should return options.serverRequestOrigin', () => {
it('should return options.serverRequestOrigin', (done) => {
const optionsOrigin = 'https://express.origin.com';
const result = serverRequestOriginFactory({
serverRequestOrigin: optionsOrigin,
})();
done();
expect(result).toEqual(optionsOrigin);
});
});
describe('and when options.serverRequestOrigin is NOT present', () => {
it('should throw an error if ', () => {
expect(() => {
serverRequestOriginFactory()();
}).toThrowError();
}).toThrowError('');
});
});
});
Expand Down
13 changes: 10 additions & 3 deletions core-libs/setup/ssr/providers/server-request-url.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

import * as injectFn from '@angular/core';
jest.mock('@angular/core', () => {
return {
...jest.requireActual('@angular/core'),
inject: jest.fn(),
};
});

import { inject } from '@angular/core';
import { INITIAL_CONFIG } from '@angular/platform-server';
import { SERVER_REQUEST_ORIGIN, SERVER_REQUEST_URL } from '@spartacus/core';
import { serverRequestUrlFactory } from './server-request-url';
Expand All @@ -13,7 +20,7 @@ describe('serverRequestUrlFactory', () => {
describe('when SERVER_REQUEST_URL is present', () => {
it('should return SERVER_REQUEST_URL', () => {
const mockOrigin = 'https://express.origin.com';
jest.spyOn(injectFn, 'inject').mockImplementation((token) => {
(inject as jest.Mock).mockImplementation((token: any) => {
if (token.toString() === SERVER_REQUEST_URL.toString()) {
return mockOrigin;
}
Expand All @@ -28,7 +35,7 @@ describe('serverRequestUrlFactory', () => {
const mockOrigin = 'https://express.origin.com';
const mockUrl = '/home';

jest.spyOn(injectFn, 'inject').mockImplementation((token) => {
(inject as jest.Mock).mockImplementation((token: any) => {
if (token.toString() === SERVER_REQUEST_ORIGIN.toString()) {
return mockOrigin;
}
Expand Down
12 changes: 6 additions & 6 deletions docs/libs/creating-lib.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = function (config) {
require('karma-junit-reporter'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
clearContext: true, // close Jasmine Spec Runner output in browser to avoid ''Some of your tests did a full page reload!' error when '--no-watch' is active
},
reporters: ['progress', 'kjhtml', 'dots', 'junit'],
junitReporter: {
Expand Down Expand Up @@ -262,8 +262,8 @@ Use the following template:
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"forceConsistentCasingInFileNames": true,
"target": "es2020",
"module": "es2020",
"target": "es2022",
"module": "es2022",
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
Expand Down Expand Up @@ -292,15 +292,15 @@ Use the following template:
}
```

- `tsconfig.spec.json` - add `"target": "es2020", "module": "es2020"` in `"compilerOptions"`:
- `tsconfig.spec.json` - add `"target": "es2022", "module": "es2022"` in `"compilerOptions"`:

```json
{
/* ... */
"compilerOptions": {
/* ... */
"target": "es2020",
"module": "es2020"
"target": "es2022",
"module": "es2022"
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion feature-libs/asm/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function (config) {
require('karma-junit-reporter'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
clearContext: true, // close Jasmine Spec Runner output in browser to avoid 'Some of your tests did a full page reload!' error when '--no-watch' is active
jasmine: {
random: false,
},
Expand Down
16 changes: 8 additions & 8 deletions feature-libs/asm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
"tslib": "^2.6.2"
},
"peerDependencies": {
"@angular-devkit/schematics": "^15.2.9",
"@angular/common": "^15.2.9",
"@angular/core": "^15.2.9",
"@angular/forms": "^15.2.9",
"@angular/platform-browser": "^15.2.9",
"@ng-select/ng-select": "^10.0.3",
"@ngrx/effects": "^15.3.0",
"@ngrx/store": "^15.3.0",
"@angular-devkit/schematics": "^16.2.7",
"@angular/common": "^16.2.10",
"@angular/core": "^16.2.10",
"@angular/forms": "^16.2.10",
"@angular/platform-browser": "^16.2.10",
"@ng-select/ng-select": "^11.1.1",
"@ngrx/effects": "^16.0.1",
"@ngrx/store": "^16.0.1",
"@spartacus/cart": "6.6.0-1",
"@spartacus/core": "6.6.0-1",
"@spartacus/order": "6.6.0-1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectorRef, Pipe, PipeTransform } from '@angular/core';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { NavigationEnd, Router, RouterEvent } from '@angular/router';
import { Event, NavigationEnd, Router } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
import { I18nTestingModule } from '@spartacus/core';
import { ProgressButtonModule } from '@spartacus/storefront';
Expand All @@ -15,7 +15,7 @@ class MockUrlPipe implements PipeTransform {
transform() {}
}

let mockRouterEvents$ = new Subject<RouterEvent>();
let mockRouterEvents$ = new Subject<Event>();
class MockRouter implements Partial<Router> {
events = mockRouterEvents$;
routerState = { snapshot: { root: {} } } as any;
Expand Down
4 changes: 2 additions & 2 deletions feature-libs/cart/base/core/guards/cart-validation.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { Injectable } from '@angular/core';
import { CanActivate, Router, UrlTree } from '@angular/router';
import { Router, UrlTree } from '@angular/router';
import {
ActiveCartFacade,
CartValidationFacade,
Expand All @@ -24,7 +24,7 @@ import { CartValidationStateService } from '../services/cart-validation-state.se
@Injectable({
providedIn: 'root',
})
export class CartValidationGuard implements CanActivate {
export class CartValidationGuard {
constructor(
protected cartValidationService: CartValidationFacade,
protected semanticPathService: SemanticPathService,
Expand Down
2 changes: 1 addition & 1 deletion feature-libs/cart/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function (config) {
require('karma-junit-reporter'),
],
client: {
clearContext: false, // leave Jasmine Spec Runner output visible in browser
clearContext: true, // close Jasmine Spec Runner output in browser to avoid ''Some of your tests did a full page reload!' error when '--no-watch' is active
jasmine: {
random: false,
},
Expand Down
16 changes: 8 additions & 8 deletions feature-libs/cart/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
"tslib": "^2.6.2"
},
"peerDependencies": {
"@angular-devkit/schematics": "^15.2.9",
"@angular/common": "^15.2.9",
"@angular/core": "^15.2.9",
"@angular/forms": "^15.2.9",
"@angular/router": "^15.2.9",
"@ng-select/ng-select": "^10.0.3",
"@ngrx/effects": "^15.3.0",
"@ngrx/store": "^15.3.0",
"@angular-devkit/schematics": "^16.2.7",
"@angular/common": "^16.2.10",
"@angular/core": "^16.2.10",
"@angular/forms": "^16.2.10",
"@angular/router": "^16.2.10",
"@ng-select/ng-select": "^11.1.1",
"@ngrx/effects": "^16.0.1",
"@ngrx/store": "^16.0.1",
"@spartacus/core": "6.6.0-1",
"@spartacus/schematics": "6.6.0-1",
"@spartacus/storefront": "6.6.0-1",
Expand Down
Loading
Loading