@dsivd/prestations-ng 19.0.0-beta.1 → 19.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/UPGRADING_V19.md CHANGED
@@ -81,7 +81,7 @@ Replace `com.fasterxml.jackson.databind.ObjectMapper` with `tools.jackson.databi
81
81
 
82
82
  ### BO : Brave Tracer
83
83
 
84
- If you are using Brave Tracer (search `brace.Tracer` in the code, usually in backoffices), you need to replace it with
84
+ If you are using Brave Tracer (search `brave.Tracer` in the code, usually in backoffices), you need to replace it with
85
85
  OpenTelemetry by adding the following dependencies (already included by `ch.vd.cyber:starter-bo-jdbc-jms` and `ch.vd.cyber:starter-prestation`):
86
86
 
87
87
  ```xml
@@ -102,7 +102,8 @@ And replace `brave.Tracer` imports by `io.micrometer.tracing.Tracer`;
102
102
 
103
103
  This base class has been moved from `ch.vd.cyber.sdk:cyberadmin-be` to `ch.vd.cyber.sdk:backoffice-be`
104
104
  and renamed `EsbMessageListenerWithTracingPropagation`.
105
- the constructor has also been updated :
105
+
106
+ The constructor has also been updated :
106
107
 
107
108
  ```java
108
109
  import ch.vd.cyberadminbe.jms.EsbMessageListenerWithSleuthIntegration;
@@ -132,7 +133,7 @@ public class MyListener extends EsbMessageListenerWithTracingPropagation {
132
133
  }
133
134
  ```
134
135
 
135
- finally, if you have mock issues with you integration tests, you can use `ch.vd.cyber.backofficebe.jms.JmsTestUtils.mockTracingPropagation(final Tracer tracerMock, final Propagator propagatorMock)`
136
+ finally, if you have mock issues with your integration tests, you can use `ch.vd.cyber.backofficebe.jms.JmsTestUtils.mockTracingPropagation(final Tracer tracerMock, final Propagator propagatorMock)`
136
137
 
137
138
  ### BO : ESB Integration
138
139
 
@@ -153,6 +154,13 @@ Run your application with this dependency :
153
154
 
154
155
  Look for logs that indicate property you should migrate (watch for WARN logs of class PropertiesMigrationListener), update them and remove the dependency
155
156
 
157
+ ### BO using jpa repositories
158
+
159
+ As we also have jdbc in the classpath, to avoid having dozens of log like "Spring Data JDBC - Could not safely
160
+ identify store assignment for repository candidate interface", add the property in your application.properties :
161
+
162
+ spring.data.jdbc.repositories.enabled=false
163
+
156
164
  ### Debugging tips
157
165
 
158
166
  Spring boot 4 doesn't support calling a controller with a trailing slash, fix the url called (/api/ping != /api/ping**/**)
@@ -172,3 +180,1217 @@ mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.activeRecipes=or
172
180
  ```
173
181
 
174
182
  Take a look at Sonar to see other things that you can improve or ignore.
183
+
184
+ ## PRESTATIONS-NG
185
+
186
+ For the commands in this guide, it is supposed that you are in the `front` folder of your project.
187
+
188
+ The main feature in `prestations-ng` v19 is the update of the `@angular/*` peer dependencies
189
+ to `^21.2.14`, using `node 22+` to build, `npm 10+` for package manager and `Foehn 2+ (Bootstrap 5+)` for our design system.
190
+
191
+ A lot of breaking because our library has migrated to **standalone** components, **signals** and **inject function** instead of constructor injection parameters.
192
+
193
+ > 🚨 **Read carefully following [PITFALLS](ANGULAR_SIGNALS.md#common_pitfalls), especially points 4, 6 & 8**
194
+
195
+ ### Migrate to ESLint
196
+
197
+ (NB : you can skip this step if you already have a `front/.eslintrc.json` file, it means it is already done.)
198
+
199
+ Follow [our migration guide](ESLINT_MIGRATION_GUIDE.md) to migrate your project from TSLint to ESLint.
200
+
201
+ ### Upgrade to Angular 20
202
+
203
+ Just FYI if you are curious about the details, you can find the Angular update guide at this address [https://angular.dev/update-guide?v=19.0-20.0&l=1](https://angular.dev/update-guide?v=19.0-20.0&l=1)
204
+
205
+ **NB: Commit before continuing so your repository is clean.**
206
+
207
+ Remove your `resolutions` in `package.json` before starting : if you have `resolutions` in `package.json`, remove manually the section.
208
+
209
+ In the next commands, commit before each ng update.
210
+
211
+ ```bash
212
+ npm install
213
+ npm install @angular/cli@19 -g
214
+ ng update @angular/core@19 @angular/cli@19
215
+ ng update @dsivd/prestations-ng@18
216
+ ```
217
+
218
+ #### Switch to node 22+
219
+
220
+ ##### If you are using our `slave-apps`
221
+
222
+ Be sure to update your `slave-apps` git repository and source your `.bashrc` (or whatever file you're using).
223
+
224
+ Verify your node version in your terminal by executing:
225
+
226
+ ```bash
227
+ node -v
228
+ ```
229
+
230
+ **NB: If version is still v20+ by default, type `node22` in your terminal to switch to node v22+**
231
+
232
+ ```bash
233
+ node22
234
+ ```
235
+
236
+ ##### If you are NOT using our `slave-apps`
237
+
238
+ Be sure to use a node version 22+ in your terminal:
239
+
240
+ ```bash
241
+ node -v
242
+ ```
243
+
244
+ #### Continue with Angular 20 migration
245
+
246
+ ```bash
247
+ npm install @angular/cli@20 -g
248
+ ng update @angular/core@20 @angular/cli@20
249
+ ```
250
+
251
+ - When asked "Select the migrations that you'd like to run",
252
+ - accept **"use-application-builder"** by hitting "Space" key
253
+ - hit "Enter" key
254
+ - When asked "Select the migrations that you'd like to run",
255
+ - accept **"control-flow-migration"** by hitting "Space" key
256
+ - hit "Down arrow" key
257
+ - accept **"router-current-navigation"** by hitting "Space" key
258
+ - hit "Enter" key
259
+
260
+ **IMPORTANT: Search for every `@for` in your project and check that `track` statement is present and has a unique identifier.
261
+ When a unique identifier is not possible, use `track $index`.**
262
+
263
+ **NB: When using `@angular/cdk` in your project**
264
+
265
+ ```bash
266
+ ng update @angular/cdk@20
267
+ ```
268
+
269
+ ### Running with node 22+
270
+
271
+ #### In your project
272
+
273
+ Update your `package.json` file to specify the node engine:
274
+
275
+ ```json
276
+ {
277
+ "engines": {
278
+ "node": ">=22.18.0"
279
+ }
280
+ }
281
+ ```
282
+
283
+ #### Update your jenkins files
284
+
285
+ - Change `nodeVersion: 20` to use node 22
286
+
287
+ ##### UT folder
288
+
289
+ ```diff
290
+ buildAppPipelinePodmanUT([
291
+ - node: 20,
292
+ + node: 22,
293
+ ])
294
+ ```
295
+
296
+ ### Upgrade to Angular 21
297
+
298
+ `prestations-ng` **v19+** now supports **Angular v21**.
299
+
300
+ Just FYI if you are curious about the details, you can find the Angular update guide at this address [https://angular.dev/update-guide?v=20.0-21.0&l=1](https://angular.dev/update-guide?v=20.0-21.0&l=1)
301
+
302
+ **NB: Commit before continuing so your repository is clean.**
303
+
304
+ ```bash
305
+ npm install @angular/cli@21 -g
306
+ ng update @dsivd/prestations-ng@latest
307
+ ```
308
+
309
+ - When asked again "Select the migrations that you'd like to run"
310
+ - accept **"router-current-navigation"** by hitting "Space" key
311
+ - hit "Enter" key
312
+
313
+ ```bash
314
+ ng update @angular/cli@21
315
+ ```
316
+
317
+ - When asked "Select the migrations that you'd like to run"
318
+ - accept **"use-application-builder"** by hitting "Space" key
319
+ - hit "Enter" key
320
+
321
+ ```bash
322
+ npm install @types/node@22 ts-node@10
323
+ ```
324
+
325
+ **NB: When using `@angular/cdk` in your project**
326
+
327
+ ```bash
328
+ ng update @angular/cdk@21
329
+ ```
330
+
331
+ **NB: When using `ngx-matomo-client` in your project**
332
+
333
+ ```bash
334
+ ng update ngx-matomo-client@9
335
+ ```
336
+
337
+ ### Quick fix
338
+
339
+ - In all custom components extending `FoehnInputComponent`, in `providers` providing `FoehnInputComponent` remove `multi: true,`.
340
+
341
+ ```diff
342
+ {
343
+ provide: FoehnInputComponent,
344
+ useExisting: forwardRef(() => ItemListComponent),
345
+ - multi: true,
346
+ }
347
+ ```
348
+
349
+ - In your `.eslintrc.json`, remove `"/src/main.ts",` from `ignorePatterns`.
350
+ - In `main.ts`, replace `platformBrowserDynamic` by `platformBrowser`.
351
+ - When using `<foehn-list-summary` component, replace `list` by `model`.
352
+
353
+ ### Now fix your project before continuing
354
+
355
+ **IMPORTANT: Fix your project because our new prestations-ng v19+ is standalone, uses signals instead of observables and inject function instead of constructor injection parameter.**
356
+
357
+ - Remove all your `@dsivd/prestations-ng` imports of modules and make sure you are using the new standalone components instead by adding them directly from your html file "alt+enter".
358
+ - Check every `constructor` in your project, and remove useless `constructor` parameters that are not used anymore (like `ActivatedRoute` in components extending `AbstractPageComponent`).
359
+
360
+ Run the following command until you have no more errors.
361
+
362
+ ```bash
363
+ npm run build
364
+ ```
365
+
366
+ **TIP: If your IntelliJ is still showing you errors on `@if` or `@for`, close it and re-open it to fix.**
367
+
368
+ ### Migrate to inject function
369
+
370
+ ```bash
371
+ ng generate @angular/core:inject
372
+ ```
373
+
374
+ ✔ Which directory do you want to migrate? **./**
375
+
376
+ ✔ Do you want to migrate abstract classes? Abstract classes are not migrated by default, because their parameters aren't guaranteed to be injectable. **Yes**
377
+
378
+ ✔ Do you want to clean up all constructors or keep them backwards compatible? Enabling this option will include an additional signature of `constructor(...args:
379
+ unknown[]);` that will avoid errors for sub-classes, but will increase the amount of generated code by the migration. **No**
380
+
381
+ ✔ Do you want optional inject calls to be non-nullable? Enable this option if you want the return type to be identical to @Optional(), at the expense of worse
382
+ type safety. **Yes**
383
+
384
+ Then:
385
+
386
+ - Go through every file that has changed and fix what is broken.
387
+ - Reorder public / private and remove unused imports so ESLINT is happy again.
388
+
389
+ Little example of cleaning when extending `AbstractPageComponent`:
390
+
391
+ Before:
392
+
393
+ ```ts
394
+ sessionInfoData: SessionInfoWithApplicationService;
395
+
396
+ constructor(
397
+ protected override activatedRoute: ActivatedRoute,
398
+ private readonly dictionaryService: SdkDictionaryService,
399
+ sessionInfoData: SessionInfoWithApplicationService
400
+ ) {
401
+ super(activatedRoute);
402
+ this.sessionInfoData = sessionInfoData;
403
+ }
404
+ ```
405
+
406
+ After:
407
+
408
+ ```ts
409
+ sessionInfoData = inject(SessionInfoWithApplicationService);
410
+
411
+ private readonly dictionaryService = inject(SdkDictionaryService);
412
+ ```
413
+
414
+ Most of the time, you can remove `activatedRoute` because it was used as a constructor parameter for `AbstractPageComponent`.
415
+
416
+ ### Migrate to self-closing tags
417
+
418
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
419
+
420
+ ```bash
421
+ npm run build
422
+ ```
423
+
424
+ Fix remaining errors and warnings, then run the following command:
425
+
426
+ ```bash
427
+ ng generate @angular/core:self-closing-tag
428
+ ```
429
+
430
+ ✔ Which directory do you want to migrate? **./**
431
+
432
+ ### Migrate to standalone
433
+
434
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
435
+
436
+ **TIP: Check [Migrating from NgModules](COMPONENTS.md#migrating_from_ngmodules) for more information before running following commands.**
437
+
438
+ ```bash
439
+ npm run build
440
+ ```
441
+
442
+ Fix remaining errors and warnings, then run the following command:
443
+
444
+ ```bash
445
+ ng generate @angular/core:standalone
446
+ ```
447
+
448
+ Choose **"Convert all components, directives and pipes to standalone"** then
449
+
450
+ ✔ Which directory do you want to migrate? **./**
451
+
452
+ ```bash
453
+ npm run build
454
+ ```
455
+
456
+ ```bash
457
+ ng generate @angular/core:standalone
458
+ ```
459
+
460
+ Choose **"Remove unnecessary NgModule classes"** then
461
+
462
+ ✔ Which directory do you want to migrate? **./**
463
+
464
+ ```bash
465
+ npm run build
466
+ ```
467
+
468
+ ```bash
469
+ ng generate @angular/core:standalone
470
+ ```
471
+
472
+ Choose **"Bootstrap the application using standalone APIs"** then
473
+
474
+ ✔ Which directory do you want to migrate? **./**
475
+
476
+ #### Now check and fix manually the migration of your `app.component.ts` to standalone
477
+
478
+ It should look like that:
479
+
480
+ ```diff
481
+ @Component({
482
+ selector: 'app-root',
483
+ templateUrl: './app.component.html',
484
+ - // eslint-disable-next-line @angular-eslint/prefer-standalone
485
+ - standalone: false
486
+ + imports: [
487
+ + RouterOutlet,
488
+ + NgHttpLoaderComponent,
489
+ + RedirectComponent,
490
+ + ]
491
+ })
492
+ ```
493
+
494
+ Create a file under `src/app` called `app.routes.ts` with the following content:
495
+
496
+ ```ts
497
+ export const routes: Routes = [
498
+ // Your routes found in app-routing.module.ts go here
499
+ ];
500
+ ```
501
+
502
+ Create a file under `src/app` called `app.config.ts` with the following content:
503
+
504
+ ```ts
505
+ export const appConfig: ApplicationConfig = {
506
+ providers: [
507
+ provideZoneChangeDetection(),
508
+ providePrestationsNgCore(),
509
+ provideRouter(routes),
510
+ META_SERVICE_PROVIDER,
511
+ provideHttpClient(
512
+ withInterceptors([pendingRequestsInterceptor$]),
513
+ withXsrfConfiguration({
514
+ cookieName: 'XSRF-TOKEN',
515
+ headerName: 'X-XSRF-TOKEN',
516
+ }),
517
+ ),
518
+ ],
519
+ };
520
+ ```
521
+
522
+ Now replace the content of `main.ts` with the following content:
523
+
524
+ ```ts
525
+ import { bootstrapApplication } from '@angular/platform-browser';
526
+
527
+ import { AppComponent } from './app/app.component';
528
+ import { appConfig } from './app/app.config';
529
+
530
+ bootstrapApplication(AppComponent, appConfig).catch((err) =>
531
+ console.error(err),
532
+ );
533
+ ```
534
+
535
+ Clean up your project by removing `app-routing.module.ts` and `app.module.ts` files if it has not already been done.
536
+
537
+ #### Migration to lazy-loaded routes when working with large applications
538
+
539
+ You may have some other modules that are maybe lazy-loaded. Just be sure that all your components are standalone before continuing.
540
+
541
+ > You can run the following command to convert eagerly loaded component routes to lazy loaded routes. This allows the build process to split the production bundle into smaller chunks, to avoid a big JS bundle that includes all routes, which negatively affects initial page load of an application.
542
+
543
+ > This migration will also collect information about all the components declared in NgModules and output the list of routes that use them (including corresponding location of the file). Consider making those components standalone.
544
+
545
+ ```bash
546
+ ng generate @angular/core:route-lazy-loading
547
+ ```
548
+
549
+ Here is an example when doing it manually because schematic above does not work as intended:
550
+
551
+ Your `app.routing.ts` file should look something like this:
552
+
553
+ ```ts
554
+ const routes: Routes = [
555
+ {
556
+ path: '',
557
+ component: PageWrapperComponent,
558
+ data: { root: true },
559
+ children: [
560
+ {
561
+ path: 'demandes',
562
+ loadChildren: () =>
563
+ import('./modules/demandes/demandes.module').then(
564
+ (m) => m.DemandesModule,
565
+ ),
566
+ },
567
+ { path: '404', component: FoehnNotfoundComponent },
568
+ { path: '', redirectTo: 'demandes', pathMatch: 'full' },
569
+ { path: '**', redirectTo: '/404', pathMatch: 'full' },
570
+ ],
571
+ },
572
+ ];
573
+ ```
574
+
575
+ Now, navigate to `DemandesModule`, at the same file level as `demandes.module.ts`, you create a `demandes.routes.ts` file with the following content:
576
+
577
+ ```ts
578
+ export const demandes_routes: Routes = [
579
+ // Your routes found in demandes.module.ts go here
580
+ ];
581
+ ```
582
+
583
+ Then replace `loadChildren: () => import('./modules/demandes/demandes.module').then(m => m.DemandesModule)` by `loadChildren: () => import('./modules/demandes/demandes.routes').then(m => m.demandes_routes)`.
584
+
585
+ Now you can safely delete `demandes.module.ts` as all components are `standalone` now.
586
+
587
+ ---
588
+
589
+ You can `lazy-load` components as well, for example:
590
+
591
+ ```diff
592
+ export const demandes_routes: Routes = [
593
+ - { path: 'list', component: DemandeListPageComponent },
594
+ + { path: 'list', loadComponent: () => import('./demande-list-page/demande-list-page.component').then(m => m.DemandeListPageComponent) },
595
+ ];
596
+ ```
597
+
598
+ ### Migrate from NgClass to class bindings
599
+
600
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
601
+
602
+ ```bash
603
+ npm run build
604
+ ```
605
+
606
+ Fix remaining errors and warnings, then run the following command:
607
+
608
+ ```bash
609
+ ng generate @angular/core:ngclass-to-class
610
+ ```
611
+
612
+ ✔ Which directory do you want to migrate? **./**
613
+
614
+ ✔ Should the migration also migrate space-separated keys? **Yes**
615
+
616
+ - Check every file that has changed and fix what is broken.
617
+ - Check remaining `ngClass` usage in your project and replace it with class bindings.
618
+
619
+ **Be aware that `[class]` replaces all element classes. When you have static classes, concatenate them with dynamic ones.**
620
+
621
+ Replacement example:
622
+
623
+ Before:
624
+
625
+ ```html
626
+ [ngClass]="isLabelSrOnly ? 'visually-hidden' : 'vd-p'"
627
+ ```
628
+
629
+ After:
630
+
631
+ ```html
632
+ [class.visually-hidden]="isLabelSrOnly()" [class.vd-p]="!isLabelSrOnly()"
633
+ ```
634
+
635
+ ---
636
+
637
+ Before:
638
+
639
+ ```html
640
+ class="modal" [ngClass]="modalSize"
641
+ ```
642
+
643
+ After:
644
+
645
+ ```html
646
+ [class]="'modal ' + modalSize()"
647
+ ```
648
+
649
+ ---
650
+
651
+ Before:
652
+
653
+ ```html
654
+ class="form-label" [ngClass]="isLabelSrOnly() ? 'visually-hidden' :
655
+ labelStyleModifier()"
656
+ ```
657
+
658
+ After:
659
+
660
+ ```html
661
+ [class]="'form-label ' + (isLabelSrOnly() ? 'visually-hidden' :
662
+ (labelStyleModifier() ?? ''))"
663
+ ```
664
+
665
+ ### Migrate from NgStyle to style bindings
666
+
667
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
668
+
669
+ ```bash
670
+ npm run build
671
+ ```
672
+
673
+ Fix remaining errors and warnings, then run the following command:
674
+
675
+ ```bash
676
+ ng generate @angular/core:ngstyle-to-style
677
+ ```
678
+
679
+ ✔ Which directory do you want to migrate? **./**
680
+
681
+ ✔ Should the migration also migrate object references? **No**
682
+
683
+ - Check every file that has changed and fix what is broken.
684
+ - Check remaining `ngStyle` usage in your project and replace it with style bindings.
685
+
686
+ ### Convert CommonModule usage to standalone imports
687
+
688
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
689
+
690
+ ```bash
691
+ npm run build
692
+ ```
693
+
694
+ Fix remaining errors and warnings, then run the following command:
695
+
696
+ ```bash
697
+ ng generate @angular/core:common-to-standalone
698
+ ```
699
+
700
+ ✔ Which directory do you want to migrate? **./**
701
+
702
+ - Check every file that has changed and fix what is broken.
703
+
704
+ ### Migrate @HostListener
705
+
706
+ Search for `@HostListener` in your project and replace it with the `host` object in the `@Component` or `@Directive` decorator.
707
+
708
+ For example, when using `@HostListener` in a directive:
709
+
710
+ Before:
711
+
712
+ ```ts
713
+ @Directive({
714
+ selector: '[numberCurrencyFormatter]',
715
+ })
716
+ export class NumberCurrencyFormatterDirective implements OnInit {
717
+ @HostListener('blur', ['$event.target.value'])
718
+ onBlur(value: string): void {
719
+ this.hasFocus = false;
720
+ this.setFormatting(value);
721
+ }
722
+ }
723
+ ```
724
+
725
+ After:
726
+
727
+ ```ts
728
+ @Directive({
729
+ selector: '[numberCurrencyFormatter]',
730
+ host: {
731
+ '(blur)': 'onBlur($event)',
732
+ },
733
+ })
734
+ export class NumberCurrencyFormatterDirective implements OnInit {
735
+ onBlur(event: FocusEvent): void {
736
+ this.hasFocus = false;
737
+ const value = (event.target as HTMLInputElement).value;
738
+ this.setFormatting(value);
739
+ }
740
+ }
741
+ ```
742
+
743
+ ### Migrate to signal queries
744
+
745
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
746
+
747
+ ```bash
748
+ npm run build
749
+ ```
750
+
751
+ Fix remaining errors and warnings, then run the following command:
752
+
753
+ ```bash
754
+ ng generate @angular/core:signal-queries-migration --insert-todos
755
+ ```
756
+
757
+ ✔ Which directory do you want to migrate? **./**
758
+
759
+ ✔ Do you want to migrate as much as possible, even if it may break your build? **No**
760
+
761
+ - Check every file that has changed and fix what is broken.
762
+ - Check every remaining `@ViewChild`, `@ViewChildren`, `@ContentChild`, and `@ContentChildren` usage in your project and replace them with signal queries.
763
+ - Check every **TODO** comment added by the migration and fix them.
764
+
765
+ ### Migrate to output functions
766
+
767
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
768
+
769
+ ```bash
770
+ npm run build
771
+ ```
772
+
773
+ Fix remaining errors and warnings, then run the following command:
774
+
775
+ ```bash
776
+ ng generate @angular/core:output-migration
777
+ ```
778
+
779
+ ✔ Which directory do you want to migrate? **./**
780
+
781
+ Check every remaining `@Output` usage in your project and replace them with output function.
782
+
783
+ When needing to subscribe to an output, you can use `outputToObservable` from `@angular/core/rxjs-interop`.
784
+
785
+ ### Migrate to input signals
786
+
787
+ Check our [Angular signals guide](ANGULAR_SIGNALS.md) for more information about signals and input signals.
788
+
789
+ **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
790
+
791
+ ```bash
792
+ npm run build
793
+ ```
794
+
795
+ Fix remaining errors and warnings, then run the following command:
796
+
797
+ ```bash
798
+ ng generate @angular/core:signal-input-migration --insert-todos
799
+ ```
800
+
801
+ ✔ Which directory do you want to migrate? **./**
802
+
803
+ ✔ Do you want to migrate as much as possible, even if it may break your build? **No**
804
+
805
+ - Check every file that has changed and fix what is broken.
806
+ - Check every remaining `@Input` usage in your project and replace them with input signals.
807
+ - Check every **TODO** comment added by the migration and fix them.
808
+
809
+ ### Migrate to vitest
810
+
811
+ [Angular migration guide: migrating to Vitest](https://angular.dev/guide/testing/migrating-to-vitest)
812
+
813
+ ```bash
814
+ npm install --save-dev vitest jsdom
815
+ ```
816
+
817
+ In your `angular.json` file, remove `"zone.js/dist/zone-error"` from `"allowedCommonJsDependencies"`
818
+
819
+ then find the `test` target for your project and change the `builder` to `@angular/build:unit-test` and add following options:
820
+
821
+ ```json
822
+ {
823
+ "projects": {
824
+ "your-project-name": {
825
+ "architect": {
826
+ "test": {
827
+ "builder": "@angular/build:unit-test",
828
+ "options": {
829
+ "buildTarget": "your-project-name:build"
830
+ }
831
+ }
832
+ }
833
+ }
834
+ }
835
+ }
836
+ ```
837
+
838
+ In your package.json file, add the following scripts:
839
+
840
+ ```diff
841
+ {
842
+ "scripts": {
843
+ - "test": "ng test",
844
+ + "test": "ng test --watch=false",
845
+ }
846
+ }
847
+ ```
848
+
849
+ In your `tsconfig.spec.json` file, remove from `types` `jasmine` and `node` and add `vitest/globals`:
850
+
851
+ ```diff
852
+ {
853
+ "compilerOptions": {
854
+ "types": [
855
+ - "jasmine",
856
+ - "node"
857
+ + "vitest/globals"
858
+ ]
859
+ }
860
+ }
861
+ ```
862
+
863
+ In your `.gitignore` file, add the following line to ignore the `screenshot` folder:
864
+
865
+ ```
866
+ __screenshots__
867
+ ```
868
+
869
+ Now remove karma and jasmine dependencies
870
+
871
+ ```bash
872
+ npm uninstall jasmine jasmine-core jasmine-spec-reporter
873
+ npm uninstall karma karma-chrome-launcher karma-coverage karma-jasmine karma-jasmine-html-reporter
874
+ npm uninstall puppeteer
875
+ npm uninstall @types/jasmine @types/jasminewd2
876
+ rm karma.conf.js
877
+ ```
878
+
879
+ - search for `karma.conf.js` in your project and remove all references to it.
880
+ - search for `protractor.conf.js` in your project and remove them if they still exist.
881
+
882
+ Then run following command to migrate from jasmine to vitest:
883
+
884
+ ```bash
885
+ ng g @schematics/angular:refactor-jasmine-vitest
886
+ ```
887
+
888
+ Now you can run your tests with `npm test` and check that everything is up and running.
889
+
890
+ In your tests, replace `waitForAsync(() => ...)` by `async(...)` and add `await` before `TestBed.configureTestingModule`.
891
+ For example, replace this:
892
+
893
+ Before:
894
+
895
+ ```ts
896
+ import {
897
+ provideHttpClient,
898
+ withInterceptorsFromDi,
899
+ } from '@angular/common/http';
900
+ import { provideHttpClientTesting } from '@angular/common/http/testing';
901
+ import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
902
+ import { RouterModule } from '@angular/router';
903
+
904
+ import { AppComponent } from './app.component';
905
+ import { AppModule } from './app.module';
906
+
907
+ describe('AppComponent', () => {
908
+ let component: AppComponent;
909
+ let fixture: ComponentFixture<AppComponent>;
910
+
911
+ beforeEach(waitForAsync(() => {
912
+ TestBed.configureTestingModule({
913
+ imports: [AppModule, RouterModule.forRoot([])],
914
+ providers: [
915
+ provideHttpClient(withInterceptorsFromDi()),
916
+ provideHttpClientTesting(),
917
+ ],
918
+ }).compileComponents();
919
+ }));
920
+
921
+ beforeEach(() => {
922
+ fixture = TestBed.createComponent(AppComponent);
923
+ component = fixture.componentInstance;
924
+ fixture.detectChanges();
925
+ });
926
+
927
+ it('should create', () => {
928
+ expect(component).toBeTruthy();
929
+ });
930
+ });
931
+ ```
932
+
933
+ After:
934
+
935
+ ```ts
936
+ import {
937
+ provideHttpClient,
938
+ withInterceptorsFromDi,
939
+ } from '@angular/common/http';
940
+ import { provideHttpClientTesting } from '@angular/common/http/testing';
941
+ import { ComponentFixture, TestBed } from '@angular/core/testing';
942
+ import { provideRouter } from '@angular/router';
943
+
944
+ import { AppComponent } from './app.component';
945
+
946
+ describe('AppComponent', () => {
947
+ let component: AppComponent;
948
+ let fixture: ComponentFixture<AppComponent>;
949
+
950
+ beforeEach(async () => {
951
+ await TestBed.configureTestingModule({
952
+ imports: [AppComponent],
953
+ providers: [
954
+ provideHttpClient(withInterceptorsFromDi()),
955
+ provideHttpClientTesting(),
956
+ provideRouter([]),
957
+ ],
958
+ }).compileComponents();
959
+
960
+ fixture = TestBed.createComponent(AppComponent);
961
+ component = fixture.componentInstance;
962
+ await fixture.whenStable();
963
+ });
964
+
965
+ it('should create', () => {
966
+ expect(component).toBeTruthy();
967
+ });
968
+ });
969
+ ```
970
+
971
+ ### Migrate to eslint flat configuration
972
+
973
+ ```bash
974
+ npm uninstall @angular-eslint/builder @angular-eslint/eslint-plugin @angular-eslint/eslint-plugin-template @angular-eslint/template-parser
975
+ npm uninstall @typescript-eslint/eslint-plugin @typescript-eslint/parser @typescript-eslint/types @typescript-eslint/utils
976
+ npm uninstall eslint-import-resolver-typescript eslint-plugin-cypress eslint-plugin-import eslint-plugin-jasmine eslint-plugin-rxjs eslint-plugin-rxjs-angular eslint-plugin-simple-npm eslint-plugin-simple-import-sort
977
+ npm uninstall eslint
978
+
979
+ npm install --save-dev eslint@^9 angular-eslint@21 typescript-eslint@^8
980
+ npm install --save-dev @typescript-eslint/parser@8 @smarttools/eslint-plugin-rxjs@1
981
+ npm install --save-dev eslint-plugin-simple-import-sort@13
982
+ npm install --save-dev eslint-config-prettier@10
983
+ npm install --save-dev eslint-plugin-import-x@4
984
+ npm install --save-dev prettier
985
+ ```
986
+
987
+ In your `front` folder, add a `.prettierrc` file with the following content:
988
+
989
+ ```json
990
+ {
991
+ "printWidth": 100,
992
+ "singleQuote": true,
993
+ "arrowParens": "always",
994
+ "trailingComma": "all",
995
+ "htmlWhitespaceSensitivity": "css",
996
+ "overrides": [
997
+ {
998
+ "files": ["*.html"],
999
+ "options": {
1000
+ "parser": "angular"
1001
+ }
1002
+ }
1003
+ ]
1004
+ }
1005
+ ```
1006
+
1007
+ Add a `.prettierignore` file with the following content:
1008
+
1009
+ ```text
1010
+ node_modules
1011
+ .git
1012
+ target
1013
+ package.json
1014
+ package-lock.json
1015
+ dist
1016
+ coverage
1017
+ .angular
1018
+ ```
1019
+
1020
+ Remove your old `.eslintrc.json` file in your `front` folder:
1021
+
1022
+ ```bash
1023
+ rm .eslintrc.json
1024
+ ```
1025
+
1026
+ - search for `.eslintrc.json` in your project and remove them.
1027
+ - add a new `eslint.config.mjs` file with the following content:
1028
+
1029
+ ```ts
1030
+ // @ts-check
1031
+ import eslint from '@eslint/js';
1032
+ import tseslint from 'typescript-eslint';
1033
+ import angular from 'angular-eslint';
1034
+ import rxjs from '@smarttools/eslint-plugin-rxjs';
1035
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
1036
+ import prettier from 'eslint-config-prettier';
1037
+ import importX from 'eslint-plugin-import-x';
1038
+
1039
+ export default tseslint.config(
1040
+ {
1041
+ ignores: ['**/coverage/**', '**/dist/**'],
1042
+ },
1043
+
1044
+ // ─── TypeScript ────────────────────────────────────────────────────────────
1045
+ {
1046
+ files: ['**/*.ts'],
1047
+ extends: [
1048
+ eslint.configs.recommended,
1049
+ ...tseslint.configs.recommended, // covers: no-explicit-any, ban-ts-comment,
1050
+ // no-unused-expressions, no-var, no-unused-vars…
1051
+ ...tseslint.configs.stylistic, // covers: array-type, consistent-type-assertions,
1052
+ // dot-notation, no-inferrable-types (default options),
1053
+ // no-empty-function (error), prefer-for-of,
1054
+ // prefer-function-type…
1055
+ ...angular.configs.tsRecommended, // covers: prefer-inject, no-empty-lifecycle-method,
1056
+ // use-lifecycle-interface…
1057
+ ],
1058
+ languageOptions: {
1059
+ parserOptions: {
1060
+ projectService: true,
1061
+ tsconfigRootDir: import.meta.dirname,
1062
+ },
1063
+ },
1064
+ plugins: {
1065
+ rxjs,
1066
+ 'simple-import-sort': simpleImportSort,
1067
+ 'import-x': importX,
1068
+ },
1069
+ processor: angular.processInlineTemplates,
1070
+ rules: {
1071
+ // ── @angular-eslint ──────────────────────────────────────────────
1072
+ '@angular-eslint/component-selector': [
1073
+ 'error',
1074
+ {
1075
+ type: 'element',
1076
+ prefix: 'app',
1077
+ style: 'kebab-case',
1078
+ },
1079
+ ],
1080
+ '@angular-eslint/directive-selector': [
1081
+ 'error',
1082
+ {
1083
+ type: 'attribute',
1084
+ prefix: 'app',
1085
+ style: 'camelCase',
1086
+ },
1087
+ ],
1088
+
1089
+ // ── @typescript-eslint ───────────────────────────────────────────
1090
+ '@typescript-eslint/explicit-function-return-type': [
1091
+ 'error',
1092
+ {
1093
+ allowExpressions: true,
1094
+ allowTypedFunctionExpressions: true,
1095
+ allowHigherOrderFunctions: true,
1096
+ allowDirectConstAssertionInArrowFunctions: true,
1097
+ },
1098
+ ],
1099
+ '@typescript-eslint/explicit-member-accessibility': [
1100
+ 'error',
1101
+ { accessibility: 'no-public' },
1102
+ ],
1103
+ '@typescript-eslint/member-delimiter-style': 'error',
1104
+ '@typescript-eslint/member-ordering': 'error',
1105
+ '@typescript-eslint/no-base-to-string': 'warn',
1106
+ // stylistic enables no-inferrable-types with default options (ignoreParameters: false);
1107
+ // override here to allow typed parameters explicitly
1108
+ '@typescript-eslint/no-inferrable-types': [
1109
+ 'error',
1110
+ { ignoreParameters: true },
1111
+ ],
1112
+ // stylistic sets no-empty-function to error; downgrade to warn
1113
+ '@typescript-eslint/no-empty-function': 'warn',
1114
+ '@typescript-eslint/prefer-includes': 'warn',
1115
+ '@typescript-eslint/return-await': ['error', 'never'],
1116
+ '@typescript-eslint/typedef': ['error', { parameter: true }],
1117
+ '@typescript-eslint/unified-signatures': 'error',
1118
+ // off here — @typescript-eslint/no-shadow handles it correctly for TS
1119
+ 'no-shadow': 'off',
1120
+ '@typescript-eslint/no-shadow': ['error', { hoist: 'all' }],
1121
+ '@typescript-eslint/no-unused-vars': [
1122
+ 'error',
1123
+ {
1124
+ varsIgnorePattern: '^_',
1125
+ argsIgnorePattern: '^_',
1126
+ caughtErrorsIgnorePattern: '^_',
1127
+ },
1128
+ ],
1129
+
1130
+ // ── eslint core ──────────────────────────────────────────────────
1131
+ 'arrow-body-style': 'error',
1132
+ 'arrow-parens': ['error', 'as-needed'],
1133
+ curly: 'error',
1134
+ eqeqeq: ['error', 'always'],
1135
+ 'guard-for-in': 'error',
1136
+ 'no-bitwise': 'error',
1137
+ 'no-caller': 'error',
1138
+ 'no-console': ['error', { allow: ['log', 'warn', 'error'] }],
1139
+ 'no-eval': 'error',
1140
+ 'no-extra-boolean-cast': 'off',
1141
+ 'no-multiple-empty-lines': 'error',
1142
+ 'no-new-wrappers': 'error',
1143
+ 'no-restricted-imports': [
1144
+ 'error',
1145
+ { paths: ['rxjs/Rx', 'primeng/primeng', 'primeng'] },
1146
+ ],
1147
+ 'no-return-assign': 'error',
1148
+ 'no-throw-literal': 'error',
1149
+ 'no-undef-init': 'error',
1150
+ 'no-useless-concat': 'error',
1151
+ 'object-shorthand': ['error', 'always', { avoidQuotes: true }],
1152
+ 'one-var': ['error', 'never'],
1153
+ 'prefer-arrow-callback': 'error',
1154
+ 'prefer-template': 'error',
1155
+ radix: 'error',
1156
+
1157
+ // ── rxjs ─────────────────────────────────────────────────────────
1158
+ 'rxjs/no-implicit-any-catch': ['error', { allowExplicitAny: true }],
1159
+ 'rxjs/no-sharereplay': 'off',
1160
+
1161
+ // ── import-x ─────────────────────────────────────────────────────
1162
+ 'import-x/no-cycle': [
1163
+ 'warn',
1164
+ { maxDepth: 3, ignoreExternal: true },
1165
+ ],
1166
+ 'import-x/no-deprecated': 'warn',
1167
+ 'import-x/first': 'error',
1168
+ 'import-x/newline-after-import': 'error',
1169
+ 'import-x/no-duplicates': 'error',
1170
+
1171
+ // ── simple-import-sort ───────────────────────────────────────────
1172
+ 'simple-import-sort/imports': 'error',
1173
+ 'simple-import-sort/exports': 'error',
1174
+ },
1175
+ },
1176
+
1177
+ // ─── HTML templates ────────────────────────────────────────────────────────
1178
+ {
1179
+ files: ['**/*.html'],
1180
+ extends: [
1181
+ ...angular.configs.templateRecommended,
1182
+ ...angular.configs.templateAccessibility,
1183
+ ],
1184
+ rules: {
1185
+ '@angular-eslint/template/no-negated-async': 'off',
1186
+ '@angular-eslint/template/button-has-type': 'error',
1187
+ },
1188
+ },
1189
+
1190
+ // ─── Prettier (must be last — disables formatting rules) ───────────────────
1191
+ prettier,
1192
+ );
1193
+ ```
1194
+
1195
+ #### Delete `typings.d.ts`
1196
+
1197
+ In `front/src/`, remove the file `typings.d.ts` if it is still there.
1198
+
1199
+ #### Update your tsconfig\*.json files
1200
+
1201
+ - Replace your `tsconfig.json` content with:
1202
+
1203
+ ```json
1204
+ {
1205
+ "compileOnSave": false,
1206
+ "compilerOptions": {
1207
+ "outDir": "./dist/out-tsc",
1208
+ "noImplicitOverride": true,
1209
+ "noImplicitReturns": true,
1210
+ "noFallthroughCasesInSwitch": true,
1211
+ "skipLibCheck": true,
1212
+ "esModuleInterop": true,
1213
+ "sourceMap": true,
1214
+ "declaration": false,
1215
+ "experimentalDecorators": true,
1216
+ "useDefineForClassFields": false,
1217
+ "moduleResolution": "bundler",
1218
+ "importHelpers": true,
1219
+ "isolatedModules": true,
1220
+ "target": "ES2022",
1221
+ "module": "ES2022",
1222
+ "paths": {
1223
+ "@dsivd/prestations-ng": ["./node_modules/@dsivd/prestations-ng"]
1224
+ }
1225
+ },
1226
+ "angularCompilerOptions": {
1227
+ "enableI18nLegacyMessageIdFormat": false,
1228
+ "strictInjectionParameters": true,
1229
+ "strictInputAccessModifiers": true,
1230
+ "strictTemplates": true,
1231
+ "strictStandalone": true
1232
+ },
1233
+ "files": [],
1234
+ "references": [
1235
+ {
1236
+ "path": "./tsconfig.app.json"
1237
+ },
1238
+ {
1239
+ "path": "./tsconfig.spec.json"
1240
+ }
1241
+ ]
1242
+ }
1243
+ ```
1244
+
1245
+ - Replace your `tsconfig.app.json` content with:
1246
+
1247
+ ```json
1248
+ {
1249
+ "extends": "./tsconfig.json",
1250
+ "compilerOptions": {
1251
+ "outDir": "../out-tsc/app",
1252
+ "types": []
1253
+ },
1254
+ "include": ["src/**/*.ts"],
1255
+ "exclude": ["src/**/*.spec.ts"]
1256
+ }
1257
+ ```
1258
+
1259
+ - Update your package.json, add the following script to run eslint:
1260
+
1261
+ ```diff
1262
+ "scripts": {
1263
+ - "lint": "ng lint",
1264
+ + "lint": "ng lint --fix=true",
1265
+ + "format:prettier": "prettier --config ./.prettierrc --write \"{,!(.scannerwork|target|coverage|node_modules|.angular)/**/}*{.ts,.js,.jsx,.json,.css,.scss,.md,.html}\"",
1266
+ }
1267
+ ```
1268
+
1269
+ ### Husky pre-commit hook
1270
+
1271
+ ```bash
1272
+ npm install --save-dev husky lint-staged
1273
+ npx husky init
1274
+ echo "cd front" > .husky/pre-commit
1275
+ echo "npx lint-staged" >> .husky/pre-commit
1276
+ chmod +x .husky/pre-commit
1277
+ mv ./.husky ../.husky
1278
+ git add -A
1279
+ ```
1280
+
1281
+ - You can manually run formatting commands as well:
1282
+
1283
+ ```bash
1284
+ npm run format:prettier
1285
+ npm run lint
1286
+ ```
1287
+
1288
+ Fix your `meta.service.ts` by replacing:
1289
+
1290
+ Before:
1291
+
1292
+ ```ts
1293
+ export const metaServiceFactory =
1294
+ (metaService: MetaService): Function =>
1295
+ () =>
1296
+ lastValueFrom(metaService.load());
1297
+
1298
+ export const META_SERVICE_PROVIDER = provideAppInitializer(() => {
1299
+ const initializerFn = metaServiceFactory(inject(MetaService));
1300
+ return initializerFn();
1301
+ });
1302
+ ```
1303
+
1304
+ After:
1305
+
1306
+ ```ts
1307
+ export const META_SERVICE_PROVIDER = provideAppInitializer(() => {
1308
+ const metaService = inject(MetaService);
1309
+ return lastValueFrom(metaService.load());
1310
+ });
1311
+ ```
1312
+
1313
+ Run again until no more errors:
1314
+
1315
+ ```bash
1316
+ npm run lint
1317
+ ```
1318
+
1319
+ Then:
1320
+
1321
+ ```bash
1322
+ npm run format:prettier
1323
+ ```
1324
+
1325
+ ### Browsers list update
1326
+
1327
+ Run update schematic:
1328
+
1329
+ ```bash
1330
+ ng g @dsivd/prestations-ng:replace-browsers-list
1331
+ ```
1332
+
1333
+ ### Remove deprecated packages
1334
+
1335
+ ```bash
1336
+ npm uninstall @angular/platform-browser-dynamic
1337
+ npm uninstall @angular/animations
1338
+ ```
1339
+
1340
+ ### Configure IntelliJ IDEA to use ESLint and Prettier on save
1341
+
1342
+ - To configure ESLint automatically in the current project, open "_File -> Settings..._" (`Ctrl+Alt+S`) and either:
1343
+ - Search for `ESLint` and check radio box "_Automatic ESLint configuration_" and check checkbox "_Run eslint --fix on save_"
1344
+ - Search for `Prettier` and check radio box "_Automatic Prettier configuration_" and check checkbox "_Run on save_"
1345
+
1346
+ ### Language deprecations
1347
+
1348
+ When using `IntelliJ`, you can run code inspection on your project to fix deprecations manually. Two ways:
1349
+
1350
+ - IntelliJ window menu, go to: `Code > Analyze code > Run inspection by name...` (or **Ctrl+Alt+Maj+i**) and type `Deprecated symbol used`.
1351
+ - Or select your project in your project panel and `right click` on it then `Analyze > Run inspection by name...` (or **Ctrl+Alt+Maj+i**) and type `Deprecated symbol used`.
1352
+
1353
+ ### Last but not least, check if your application is working!!!
1354
+
1355
+ #### Be sure your application gets a fresh start
1356
+
1357
+ ```bash
1358
+ rm -rf .angular/
1359
+ rm -rf node_modules/
1360
+ npm install
1361
+ ```
1362
+
1363
+ #### Build and launch your application
1364
+
1365
+ **NB: You will most probably need to fix some compilation errors such as adding `override` when needed**
1366
+
1367
+ ```bash
1368
+ npm run build
1369
+ npm start
1370
+ ```
1371
+
1372
+ You're good if no errors are remaining!
1373
+ Finally check if your tests run well :
1374
+
1375
+ ```bash
1376
+ npm run test
1377
+ ```
1378
+
1379
+ > 🚨 **Read carefully following [PITFALLS](ANGULAR_SIGNALS.md#common_pitfalls), especially points 4, 6 & 8 and check again your application**
1380
+
1381
+ ### Release your application using `jenkins-libs`
1382
+
1383
+ When your code has been merged/rebased onto `master`, you need to update your application in `jenkins-libs` to use node 22 instead of node 20.
1384
+
1385
+ See [getImtPortailApplications](https://dsigit.etat-de-vaud.ch/outils/git/projects/PEE/repos/jenkins-libs/browse/vars/getImtPortailApplications.groovy)
1386
+
1387
+ ```diff
1388
+ [
1389
+ 'project': 'cybersdk',
1390
+ 'name' : 'skeleton',
1391
+ 'gitUrl' : 'ssh://git@bitbucket.etat-de-vaud.ch/cybsdk/skeleton.git',
1392
+ 'jdk' : '21',
1393
+ - 'node' : '20'
1394
+ + 'node' : '22'
1395
+ ],
1396
+ ```