Skip to content

Commit

Permalink
feat(all)!: upgrade Angular to v18 (#3052)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Angular has been upgraded to v18
  • Loading branch information
griest024 committed Sep 17, 2024
1 parent d4df739 commit 8c58188
Show file tree
Hide file tree
Showing 58 changed files with 6,012 additions and 8,397 deletions.
83 changes: 37 additions & 46 deletions apps/daffio/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientModule } from '@angular/common/http';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import {
APP_ID,
NgModule,
Expand Down Expand Up @@ -26,49 +26,40 @@ import { DaffioSidebarHeaderComponentModule } from './core/sidebar/components/si
import { TemplateModule } from './core/template/template.module';
import { environment } from '../environments/environment';

@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,

StoreModule.forRoot({}),
EffectsModule.forRoot(),
HttpClientModule,

AppRoutingModule,
DaffioSidebarHeaderComponentModule,
DaffioSidebarFooterComponentModule,
DaffioSimpleFooterComponentModule,
DaffioMarketingFooterComponentModule,

//Make sure this loads after Router and Store
StoreRouterConnectingModule.forRoot({ serializer: FullRouterStateSerializer,
/*
They stateKey defines the name of the state used by the router-store reducer.
This matches the key defined in the map of reducers
*/
stateKey: 'router' }),
StoreDevtoolsModule.instrument({
maxAge: 25, // Retains last 25 states
logOnly: environment.production, // Restrict extension to log-only mode
connectInZone: true,
}),
TemplateModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }),
],
declarations: [
DaffioAppComponent,
],
bootstrap: [
DaffioAppComponent,
],
providers: [
DAFF_THEME_INITIALIZER,
{
provide: APP_ID,
useValue: 'serverApp',
},
provideDaffRouterActivatedRoute(),
],
})
@NgModule({ declarations: [
DaffioAppComponent,
],
bootstrap: [
DaffioAppComponent,
], imports: [BrowserModule,
BrowserAnimationsModule,
StoreModule.forRoot({}),
EffectsModule.forRoot(),
AppRoutingModule,
DaffioSidebarHeaderComponentModule,
DaffioSidebarFooterComponentModule,
DaffioSimpleFooterComponentModule,
DaffioMarketingFooterComponentModule,
//Make sure this loads after Router and Store
StoreRouterConnectingModule.forRoot({ serializer: FullRouterStateSerializer,
/*
They stateKey defines the name of the state used by the router-store reducer.
This matches the key defined in the map of reducers
*/
stateKey: 'router' }),
StoreDevtoolsModule.instrument({
maxAge: 25, // Retains last 25 states
logOnly: environment.production, // Restrict extension to log-only mode
connectInZone: true,
}),
TemplateModule,
ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production })], providers: [
DAFF_THEME_INITIALIZER,
{
provide: APP_ID,
useValue: 'serverApp',
},
provideDaffRouterActivatedRoute(),
provideHttpClient(withInterceptorsFromDi()),
] })
export class AppModule {}
16 changes: 8 additions & 8 deletions apps/daffio/src/app/core/assets/fetch/browser.service.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {
HttpClientTestingModule,
HttpTestingController,
} from '@angular/common/http/testing';
import { HttpTestingController, provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';

import { DaffioAssetFetchBrowserService } from './browser.service';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';

describe('DaffioAssetFetchBrowserService', () => {
let httpTestingController: HttpTestingController;
let service: DaffioAssetFetchBrowserService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [
imports: [],
providers: [
DaffioAssetFetchBrowserService,
],
});
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});

httpTestingController = TestBed.inject(HttpTestingController);
service = TestBed.inject(DaffioAssetFetchBrowserService);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import {
Component,
signal,
Expand Down Expand Up @@ -28,6 +28,7 @@ import {

import { DaffioSidebarViewportContainer } from './sidebar-viewport.component';
import { DaffioSidebarService } from '../../services/sidebar.service';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';

@Component({ template: '' })
class TestComponent {}
Expand Down Expand Up @@ -59,24 +60,23 @@ describe('DaffioSidebarViewportContainer', () => {
);

TestBed.configureTestingModule({
imports: [
RouterTestingModule,
NoopAnimationsModule,
DaffSidebarModule,
HttpClientTestingModule,
],
declarations: [
declarations: [
DaffioSidebarViewportContainer,
TestComponent,
],
providers: [
],
imports: [RouterTestingModule,
NoopAnimationsModule,
DaffSidebarModule],
providers: [
{
provide: DaffioSidebarService,
useValue: sidebarServiceSpy,
provide: DaffioSidebarService,
useValue: sidebarServiceSpy,
},
provideMockStore(),
],
})
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
})
.compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import {
waitForAsync,
ComponentFixture,
Expand All @@ -8,20 +8,19 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';

import { DaffioDocsListContainer } from './docs-list.component';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';

describe('DaffioDocsListContainer', () => {
let component: DaffioDocsListContainer;
let fixture: ComponentFixture<DaffioDocsListContainer>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
DaffioDocsListContainer,
imports: [DaffioDocsListContainer,
RouterTestingModule,
NoopAnimationsModule,
HttpClientTestingModule,
],
})
NoopAnimationsModule],
providers: [provideHttpClient(withInterceptorsFromDi()), provideHttpClientTesting()]
})
.compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import {
waitForAsync,
ComponentFixture,
Expand All @@ -11,28 +11,28 @@ import { of } from 'rxjs';

import { DaffioDocsPackageCardsContainer } from './package-cards.component';
import { DaffioDocsIndexService } from '../../../services/index.service';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';

describe('DaffioDocsPackageCardsContainer', () => {
let component: DaffioDocsPackageCardsContainer;
let fixture: ComponentFixture<DaffioDocsPackageCardsContainer>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
declarations: [
DaffioDocsPackageCardsContainer,
],
imports: [
RouterTestingModule,
NoopAnimationsModule,
HttpClientTestingModule,
],
providers: [
],
imports: [RouterTestingModule,
NoopAnimationsModule],
providers: [
{
provide: DaffioDocsIndexService,
useValue: jasmine.createSpyObj('DaffioDocsIndexService', { getList: of() }),
provide: DaffioDocsIndexService,
useValue: jasmine.createSpyObj('DaffioDocsIndexService', { getList: of() }),
},
],
})
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
})
.compileComponents();
}));

Expand Down
5 changes: 2 additions & 3 deletions apps/demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientModule } from '@angular/common/http';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Expand Down Expand Up @@ -34,8 +34,6 @@ import { environment } from '../environments/environment';
BrowserModule,
BrowserAnimationsModule,

HttpClientModule,

DemoDriverModule,

StoreModule.forRoot({}),
Expand Down Expand Up @@ -71,6 +69,7 @@ import { environment } from '../environments/environment';
},
),
provideRouterStore(),
provideHttpClient(withInterceptorsFromDi()),
],
bootstrap: [AppComponent],
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { provideHttpClientTesting } from '@angular/common/http/testing';
import { TestBed } from '@angular/core/testing';

import { DaffInMemoryBackendCartRootService } from '@daffodil/cart/driver/in-memory';
Expand All @@ -8,24 +8,24 @@ import { DaffInMemoryBackendProductService } from '@daffodil/product/driver/in-m
import { DaffProductTestingModule } from '@daffodil/product/testing';

import { DemoInMemoryBackendService } from './backend.service';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';

describe('@daffodil/demo | DemoInMemoryBackendService', () => {
let service: DemoInMemoryBackendService;

beforeEach(() => {
TestBed.configureTestingModule({
imports: [
HttpClientTestingModule,
DaffProductTestingModule,
],
providers: [
imports: [DaffProductTestingModule],
providers: [
DaffInMemoryBackendCartRootService,
DaffInMemoryBackendProductService,
DaffInMemoryBackendNavigationService,
DaffInMemoryBackendGeographyService,
DemoInMemoryBackendService,
],
});
provideHttpClient(withInterceptorsFromDi()),
provideHttpClientTesting(),
]
});

service = TestBed.inject(DemoInMemoryBackendService);
});
Expand Down
50 changes: 22 additions & 28 deletions apps/design-land/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HttpClientModule } from '@angular/common/http';
import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
Expand All @@ -18,31 +18,25 @@ import { DesignLandAppComponent } from './app.component';
import { DesignLandNavModule } from './core/nav/nav.module';
import { DesignLandTemplateModule } from './core/template/template.module';

@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
DesignLandAppRoutingModule,
HttpClientModule,
DaffSidebarModule,
DaffLinkSetModule,
DaffArticleModule,
DaffThemeSwitchButtonModule,
DaffNavbarModule,
DaffButtonModule,
FontAwesomeModule,
DesignLandNavModule,
DesignLandTemplateModule,
DaffToastModule,
],
declarations: [
DesignLandAppComponent,
],
bootstrap: [
DesignLandAppComponent,
],
providers: [
DAFF_THEME_INITIALIZER,
],
})
@NgModule({ declarations: [
DesignLandAppComponent,
],
bootstrap: [
DesignLandAppComponent,
], imports: [BrowserModule,
BrowserAnimationsModule,
DesignLandAppRoutingModule,
DaffSidebarModule,
DaffLinkSetModule,
DaffArticleModule,
DaffThemeSwitchButtonModule,
DaffNavbarModule,
DaffButtonModule,
FontAwesomeModule,
DesignLandNavModule,
DesignLandTemplateModule,
DaffToastModule], providers: [
DAFF_THEME_INITIALIZER,
provideHttpClient(withInterceptorsFromDi()),
] })
export class AppModule { }
Loading

0 comments on commit 8c58188

Please sign in to comment.