Skip to content

Commit

Permalink
Angular v19 upgrades and more
Browse files Browse the repository at this point in the history
  • Loading branch information
jits committed Feb 7, 2025
1 parent 2bf23f1 commit db96be5
Show file tree
Hide file tree
Showing 29 changed files with 5,374 additions and 5,117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9
version: 10

- name: Set up Node.js
uses: actions/setup-node@v4
Expand Down
5 changes: 5 additions & 0 deletions app/.postcssrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"plugins": {
"@tailwindcss/postcss": {}
}
}
3 changes: 2 additions & 1 deletion app/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"routesFile": "prerendered-routes.txt"
},
"ssr": {
"entry": "server.ts"
"entry": "src/server.ts"
}
},
"configurations": {
Expand Down Expand Up @@ -119,6 +119,7 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"builderMode": "application",
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
Expand Down
1 change: 1 addition & 0 deletions app/ngsw-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.csr.html",
"applicationMaxAge": "30d",
"assetGroups": [
{
"name": "app",
Expand Down
91 changes: 51 additions & 40 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,69 @@
},
"engines": {
"node": "20",
"pnpm": "9"
"pnpm": "10"
},
"packageManager": "[email protected]",
"private": true,
"dependencies": {
"@angular/animations": "^18.2.12",
"@angular/cdk": "18.2.13",
"@angular/common": "^18.2.12",
"@angular/compiler": "^18.2.12",
"@angular/core": "^18.2.12",
"@angular/forms": "^18.2.12",
"@angular/material": "18.2.13",
"@angular/platform-browser": "^18.2.12",
"@angular/platform-browser-dynamic": "^18.2.12",
"@angular/platform-server": "^18.2.12",
"@angular/router": "^18.2.12",
"@angular/service-worker": "^18.2.12",
"@angular/ssr": "^18.2.12",
"@ngrx/operators": "^18.1.1",
"@ngrx/signals": "^18.1.1",
"consola": "^3.2.3",
"express": "^4.21.1",
"firebase": "^11.0.2",
"ngxtension": "^4.1.0",
"rxfire": "^6.0.6-canary.5cfad21",
"@angular/animations": "^19.1.5",
"@angular/cdk": "19.1.3",
"@angular/common": "^19.1.5",
"@angular/compiler": "^19.1.5",
"@angular/core": "^19.1.5",
"@angular/forms": "^19.1.5",
"@angular/material": "19.1.3",
"@angular/platform-browser": "^19.1.5",
"@angular/platform-browser-dynamic": "^19.1.5",
"@angular/platform-server": "^19.1.5",
"@angular/router": "^19.1.5",
"@angular/service-worker": "^19.1.5",
"@angular/ssr": "^19.1.6",
"@ngrx/operators": "^19.0.1",
"@ngrx/signals": "^19.0.1",
"consola": "^3.4.0",
"express": "^4.21.2",
"firebase": "^11.3.0",
"ngxtension": "^4.3.2",
"rxfire": "^6.1.0",
"rxjs": "~7.8.0",
"tslib": "^2.8.1",
"zone.js": "~0.14.10"
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^18.2.12",
"@angular/cli": "^18.2.12",
"@angular/compiler-cli": "^18.2.12",
"@ngrx/eslint-plugin": "^18.1.1",
"@types/express": "^4.17.17",
"@types/jasmine": "~5.1.0",
"@types/node": "^22.9.0",
"angular-eslint": "18.4.1",
"autoprefixer": "^10.4.20",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"jasmine-core": "~5.4.0",
"@angular-devkit/build-angular": "^19.1.6",
"@angular/cli": "^19.1.6",
"@angular/compiler-cli": "^19.1.5",
"@ngrx/eslint-plugin": "^19.0.1",
"@tailwindcss/postcss": "^4.0.0",
"@types/express": "^5.0.0",
"@types/jasmine": "~5.1.5",
"@types/node": "^22.13.1",
"angular-eslint": "^19.0.2",
"eslint": "^9.19.0",
"eslint-config-prettier": "^10.0.1",
"jasmine-core": "~5.5.0",
"karma": "~6.4.4",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"ng-mocks": "^14.13.1",
"ng-mocks": "^14.13.2",
"postcss": "^8.4.49",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.8",
"tailwindcss": "^3.4.15",
"typescript": "~5.5.4",
"typescript-eslint": "^8.15.0"
"prettier": "^3.4.2",
"prettier-plugin-tailwindcss": "^0.6.11",
"tailwindcss": "^4.0.0",
"typescript": "~5.7.3",
"typescript-eslint": "^8.23.0"
},
"pnpm": {
"onlyBuiltDependencies": [
"protobufjs",
"nx",
"@parcel/watcher",
"esbuild",
"msgpackr-extract",
"lmdb"
]
}
}
6,560 changes: 3,249 additions & 3,311 deletions app/pnpm-lock.yaml

Large diffs are not rendered by default.

60 changes: 0 additions & 60 deletions app/server.ts

This file was deleted.

1 change: 0 additions & 1 deletion app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const logger = createLogger('AppComponent');

@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet, MatSnackBarModule],
template: ` <router-outlet /> `,
styles: [],
Expand Down
4 changes: 2 additions & 2 deletions app/src/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApplicationConfig, isDevMode, provideZoneChangeDetection } from '@angular/core';
import { MAT_FORM_FIELD_DEFAULT_OPTIONS } from '@angular/material/form-field';
import { provideClientHydration } from '@angular/platform-browser';
import { provideClientHydration, withEventReplay } from '@angular/platform-browser';
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
import { provideRouter, withComponentInputBinding, withRouterConfig } from '@angular/router';
import { provideServiceWorker } from '@angular/service-worker';
Expand All @@ -14,7 +14,7 @@ export const appConfig: ApplicationConfig = {
withComponentInputBinding(),
withRouterConfig({ paramsInheritanceStrategy: 'always' }),
),
provideClientHydration(),
provideClientHydration(withEventReplay()),
provideAnimationsAsync(),
provideServiceWorker('ngsw-worker.js', {
enabled: !isDevMode(),
Expand Down
3 changes: 1 addition & 2 deletions app/src/app/login/feature/login-flow.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { LoginFlowStore } from './login-flow.store';

@Component({
selector: 'app-login-flow',
standalone: true,
imports: [RouterLink, MatButtonModule, MatIconModule, MatSnackBarModule, LoginFormComponent],
providers: [LoginFlowStore],
template: `
Expand All @@ -20,7 +19,7 @@ import { LoginFlowStore } from './login-flow.store';
</div>
<div class="mt-6 w-[360px]">
@if (status() === 'error') {
<div class="my-2 rounded bg-red-100 px-3 py-2 text-center text-sm text-red-700">
<div class="my-2 rounded-sm bg-red-100 px-3 py-2 text-center text-sm text-red-700">
{{ error() }}
</div>
}
Expand Down
16 changes: 8 additions & 8 deletions app/src/app/login/feature/login-flow.store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { effect, inject } from '@angular/core';
import { effect, inject, untracked } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthStore } from '@app-shared/auth/data/auth.store';
import { createLogger } from '@app-shared/logger';
Expand Down Expand Up @@ -165,14 +165,14 @@ export const LoginFlowStore = signalStore(
effect(() => logger.log('State:', getState(store)));

// Listen for changes to the user and trigger completion once we have one.
effect(
() => {
if (store.user()) {
effect(() => {
const user = store.user();
if (user) {
untracked(() => {
void store.completeLogin();
}
},
{ allowSignalWrites: true },
);
});
}
});
},
}),
);
1 change: 0 additions & 1 deletion app/src/app/login/feature/login-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { LoginFlowComponent } from './login-flow.component';

@Component({
selector: 'app-login-page',
standalone: true,
template: `
@defer {
<section class="flex justify-center py-6">
Expand Down
1 change: 0 additions & 1 deletion app/src/app/login/ui/login-form.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { MockBuilder, MockRender, ngMocks } from 'ng-mocks';
import { LoginFormComponent } from './login-form.component';

@Component({
standalone: true,
imports: [LoginFormComponent],
template: `<app-login-form [processing]="processing" />`,
changeDetection: ChangeDetectionStrategy.OnPush,
Expand Down
3 changes: 1 addition & 2 deletions app/src/app/login/ui/login-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';

@Component({
selector: 'app-login-form',
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
ReactiveFormsModule,
Expand Down Expand Up @@ -47,7 +46,7 @@ import { MatProgressBarModule } from '@angular/material/progress-bar';
</mat-card-footer>
</mat-card>
<div class="text mt-6 rounded bg-blue-100 px-3 py-2 text-center text-blue-700">
<div class="text mt-6 rounded-sm bg-blue-100 px-3 py-2 text-center text-blue-700">
We'll send you an email with a link to log in
<br />
(and automatically create a new account if needed)
Expand Down
26 changes: 9 additions & 17 deletions app/src/app/shared/auth/data/auth.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import {
withComputed,
withHooks,
withMethods,
withProps,
withState,
} from '@ngrx/signals';
import { rxMethod } from '@ngrx/signals/rxjs-interop';
import { createInjectionToken } from 'ngxtension/create-injection-token';
import { EMPTY, filter, finalize, pipe, shareReplay, switchMap, tap } from 'rxjs';
import { AuthService } from './auth.service';

Expand Down Expand Up @@ -117,6 +117,14 @@ export const AuthStore = signalStore(
),
};
}),
withProps((store) => ({
waitUntilConnected$: toObservable(store.status).pipe(
tap((status) => logger.log('waitUntilConnected$ - status =', status)),
filter((status) => status === 'connected'),
shareReplay(1),
),
user$: toObservable(store.user),
})),
withHooks({
onInit(store) {
effect(() => logger.log('State:', getState(store)));
Expand All @@ -125,19 +133,3 @@ export const AuthStore = signalStore(
},
}),
);

function helpersFactory(store: AuthStore) {
const waitUntilConnected$ = toObservable(store.status).pipe(
tap((status) => logger.log('waitUntilConnected$ - status =', status)),
filter((status) => status === 'connected'),
shareReplay(1),
);

const user$ = toObservable(store.user);

return {
waitUntilConnected$,
user$,
};
}
export const [injectAuthStoreHelpers] = createInjectionToken(helpersFactory, { deps: [AuthStore] });
5 changes: 2 additions & 3 deletions app/src/app/shared/auth/util/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CanMatchFn, Route, Router } from '@angular/router';
import { createLogger } from '@app-shared/logger';
import { RuntimeService } from '@app-shared/runtime.service';
import { map, take } from 'rxjs';
import { AuthStore, injectAuthStoreHelpers } from '../data/auth.store';
import { AuthStore } from '../data/auth.store';

const logger = createLogger('authGuard');

Expand All @@ -23,10 +23,9 @@ export function authGuard(allowOnly: 'authed' | 'not-authed'): CanMatchFn {
return false;
}

const { waitUntilConnected$ } = injectAuthStoreHelpers();
const authStore = inject(AuthStore);

return waitUntilConnected$.pipe(
return authStore.waitUntilConnected$.pipe(
map(() => {
const isAuthenticated = authStore.isAuthenticated();

Expand Down
3 changes: 1 addition & 2 deletions app/src/app/website/feature/about-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';

@Component({
selector: 'app-about-page',
standalone: true,
imports: [],
template: ` <h1 class="mat-headline-medium text-center">About</h1> `,
template: ` <h1 class="text-center">About</h1> `,
styles: ``,
changeDetection: ChangeDetectionStrategy.OnPush,
})
Expand Down
Loading

0 comments on commit db96be5

Please sign in to comment.