@dsivd/prestations-ng 19.0.0-beta.12 → 19.0.0-beta.13

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
@@ -25,13 +25,13 @@ mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCo
25
25
 
26
26
  #### Fixes
27
27
 
28
- Fix application.properties :
28
+ Fix `application.properties`:
29
29
 
30
30
  ```diff
31
- # Remove the following properties if it was added by the recipe
31
+ # Remove the following properties if they were added by the recipe
32
32
  spring.liquibase.password=${spring.datasource.password}
33
33
  spring.liquibase.username=${spring.datasource.username}
34
- Replace the spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS property by spring.jackson.datatype.datetime.write-dates-as-timestamps if it was not done by the recipe
34
+ Replace the `spring.jackson.serialization.WRITE_DATES_AS_TIMESTAMPS` property with `spring.jackson.datatype.datetime.write-dates-as-timestamps` if it was not already done by the recipe
35
35
  ```
36
36
 
37
37
  If the following plugin with Lombok path was added by the recipe, remove this plugin:
@@ -62,9 +62,9 @@ If the code uses `AutoConfigureMockMvc`, add:
62
62
  </dependency>
63
63
  ```
64
64
 
65
- And replace the old `AutoConfigureMockMvc` import which is not recognized anymore by the new one.
65
+ And replace the old `AutoConfigureMockMvc` import, which is not recognized anymore, with the new one.
66
66
 
67
- If we use in pom.xml Spring/Hibernate dependencies (like hibernate-jpamodelgen), check the Spring Boot 4 migration
67
+ If you use Spring/Hibernate dependencies in `pom.xml` (like `hibernate-jpamodelgen`), check the Spring Boot 4 migration
68
68
  guide to see if it has been replaced by another library: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide
69
69
 
70
70
  ### Jackson migration
@@ -183,18 +183,18 @@ Take a look at Sonar to see other things that you can improve or ignore.
183
183
 
184
184
  ## PRESTATIONS-NG
185
185
 
186
- For the commands in this guide, it is supposed that you are in the `front` folder of your project.
186
+ For the commands in this guide, it is assumed that you are in the `front` folder of your project.
187
187
 
188
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.
189
+ to `^21.2.14`, using `node 22+` to build, `npm 10+` as package manager, and `Foehn 2+ (Bootstrap 5+)` for our design system.
190
190
 
191
- A lot of breaking changes because our library has migrated to **standalone** components, **signals** and **inject function** instead of constructor injection parameters.
191
+ There are a lot of breaking changes because our library has migrated to **standalone** components, **signals**, and the **inject function** instead of constructor injection parameters.
192
192
 
193
193
  > 🚨 **Read carefully the following [PITFALLS](ANGULAR_SIGNALS.md#common_pitfalls), especially points 4, 6 & 8**
194
194
 
195
195
  ### Migrate to ESLint
196
196
 
197
- (NB : you can skip this step if you already have a `front/.eslintrc.json` file, it means it is already done.)
197
+ 💡 **NB : you can skip this step if you already have a `front/.eslintrc.json` file, it means it is already done.**
198
198
 
199
199
  Follow [our migration guide](ESLINT_MIGRATION_GUIDE.md) to migrate your project from TSLint to ESLint.
200
200
 
@@ -202,9 +202,9 @@ Follow [our migration guide](ESLINT_MIGRATION_GUIDE.md) to migrate your project
202
202
 
203
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
204
 
205
- **NB: Commit before continuing so your repository is clean.**
205
+ 💡 **NB: Commit before continuing so your repository is clean.**
206
206
 
207
- Remove your `resolutions` in `package.json` before starting : if you have `resolutions` in `package.json`, remove manually the section.
207
+ Remove your `resolutions` in `package.json` before starting: if you have `resolutions` in `package.json`, remove the section manually.
208
208
 
209
209
  In the next commands, commit before each ng update.
210
210
 
@@ -227,7 +227,7 @@ Verify your node version in your terminal by executing:
227
227
  node -v
228
228
  ```
229
229
 
230
- **NB: If version is still v20+ by default, type `node22` in your terminal to switch to node v22+**
230
+ 💡 **NB: If the version is still v20+ by default, type `node22` in your terminal to switch to node v22+**
231
231
 
232
232
  ```bash
233
233
  node22
@@ -243,7 +243,7 @@ node -v
243
243
 
244
244
  ##### IntelliJ node version
245
245
 
246
- Change IntelliJ node version to 22+ by going to `File > Settings > Languages & Frameworks > TypeScript` and selecting a node version 22+ in `Node runtime`.
246
+ Change the IntelliJ Node.js version to 22+ by going to `File > Settings > Languages & Frameworks > TypeScript` and selecting a node version 22+ in `Node runtime`.
247
247
 
248
248
  #### Continue with Angular 20 migration
249
249
 
@@ -261,10 +261,10 @@ ng update @angular/core@20 @angular/cli@20
261
261
  - accept **"router-current-navigation"** by hitting "Space" key
262
262
  - hit "Enter" key
263
263
 
264
- **IMPORTANT: Search for every `@for` in your project and check that `track` statement is present and has a unique identifier.
264
+ 🚨 **IMPORTANT: Search for every `@for` in your project and check that `track` statement is present and has a unique identifier.
265
265
  When a unique identifier is not possible, use `track $index`.**
266
266
 
267
- **NB: When using `@angular/cdk` in your project**
267
+ 💡 **NB: When using `@angular/cdk` in your project**
268
268
 
269
269
  ```bash
270
270
  ng update @angular/cdk@20
@@ -303,7 +303,7 @@ buildAppPipelinePodmanUT([
303
303
 
304
304
  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)
305
305
 
306
- **NB: Commit before continuing so your repository is clean.**
306
+ 💡 **NB: Commit before continuing so your repository is clean.**
307
307
 
308
308
  ```bash
309
309
  npm install @angular/cli@21 -g
@@ -326,13 +326,13 @@ ng update @angular/cli@21
326
326
  npm install @types/node@22 ts-node@10
327
327
  ```
328
328
 
329
- **NB: When using `@angular/cdk` in your project**
329
+ 💡 **NB: When using `@angular/cdk` in your project**
330
330
 
331
331
  ```bash
332
332
  ng update @angular/cdk@21
333
333
  ```
334
334
 
335
- **NB: When using `ngx-matomo-client` in your project**
335
+ 💡 **NB: When using `ngx-matomo-client` in your project**
336
336
 
337
337
  ```bash
338
338
  ng update ngx-matomo-client@9
@@ -356,12 +356,12 @@ ng update ngx-matomo-client@9
356
356
 
357
357
  ### Now fix your project before continuing
358
358
 
359
- **IMPORTANT: Fix your project because our new prestations-ng v19+ is standalone, uses signals instead of observables and inject function instead of constructor injection parameters.**
359
+ 🚨 **IMPORTANT: Fix your project because our new prestations-ng v19+ is standalone, uses signals instead of observables, and uses the inject function instead of constructor injection parameters.**
360
360
 
361
- - Only keep `modules` relative to your application such as `AppRoutingModule`.
362
- - Remove all other imports of **modules** and make sure you are using the new **standalone components** by adding them directly from your HTML file "alt+enter".
363
- - Add `providePrestationsNgCore(),` in `providers` array of your `app.modules.ts` file.
364
- - Check every `constructor` in your project, and remove useless `constructor` parameters that are not used anymore (like `ActivatedRoute` in components extending `AbstractPageComponent`).
361
+ - Only keep `modules` related to your application, such as `AppRoutingModule`.
362
+ - Remove all other imports of **modules** and make sure you are using the new **standalone components** by adding them directly from your template (Alt+Enter).
363
+ - Add `providePrestationsNgCore(),` to the `providers` array of your `app.module.ts` file.
364
+ - Check every `constructor` in your project and remove unused `constructor` parameters (like `ActivatedRoute` in components extending `AbstractPageComponent`).
365
365
 
366
366
  Run the following command until you have no more errors.
367
367
 
@@ -369,7 +369,7 @@ Run the following command until you have no more errors.
369
369
  npm run build
370
370
  ```
371
371
 
372
- **TIP: If your IntelliJ is still showing you errors on `@if` or `@for`, close it and re-open it to fix.**
372
+ 💡 **TIP: If your IntelliJ is still showing you errors on `@if` or `@for`, close it and re-open it to fix.**
373
373
 
374
374
  ### Migrate to inject function
375
375
 
@@ -421,7 +421,7 @@ Most of the time, you can remove `activatedRoute` because it was used as a const
421
421
 
422
422
  ### Migrate to self-closing tags
423
423
 
424
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
424
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
425
425
 
426
426
  ```bash
427
427
  npm run build
@@ -437,9 +437,9 @@ ng generate @angular/core:self-closing-tag
437
437
 
438
438
  ### Migrate to standalone
439
439
 
440
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
440
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
441
441
 
442
- **TIP: Check [Migrating from NgModules](COMPONENTS.md#migrating_from_ngmodules) for more information before running following commands.**
442
+ 💡 **TIP: Check [Migrating from NgModules](COMPONENTS.md#migrating_from_ngmodules) for more information before running the following commands.**
443
443
 
444
444
  ```bash
445
445
  npm run build
@@ -538,11 +538,11 @@ bootstrapApplication(AppComponent, appConfig).catch((err) =>
538
538
  );
539
539
  ```
540
540
 
541
- Clean up your project by removing `app-routing.module.ts` and `app.module.ts` files if it has not already been done.
541
+ Clean up your project by removing `app-routing.module.ts` and `app.module.ts` files if they have not already been removed.
542
542
 
543
543
  #### Migration to lazy-loaded routes when working with large applications
544
544
 
545
- You may have some other modules that are maybe lazy-loaded. Just be sure that all your components are standalone before continuing.
545
+ You may have some other modules that are lazy-loaded. Just be sure that all your components are standalone before continuing.
546
546
 
547
547
  > 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.
548
548
 
@@ -603,7 +603,7 @@ export const demandes_routes: Routes = [
603
603
 
604
604
  ### Migrate from NgClass to class bindings
605
605
 
606
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
606
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
607
607
 
608
608
  ```bash
609
609
  npm run build
@@ -670,7 +670,7 @@ After:
670
670
 
671
671
  ### Migrate from NgStyle to style bindings
672
672
 
673
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
673
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
674
674
 
675
675
  ```bash
676
676
  npm run build
@@ -691,7 +691,7 @@ ng generate @angular/core:ngstyle-to-style
691
691
 
692
692
  ### Convert CommonModule usage to standalone imports
693
693
 
694
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
694
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
695
695
 
696
696
  ```bash
697
697
  npm run build
@@ -748,7 +748,7 @@ export class NumberCurrencyFormatterDirective implements OnInit {
748
748
 
749
749
  ### Migrate to signal queries
750
750
 
751
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
751
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
752
752
 
753
753
  ```bash
754
754
  npm run build
@@ -770,7 +770,7 @@ ng generate @angular/core:signal-queries-migration --insert-todos
770
770
 
771
771
  ### Migrate to output functions
772
772
 
773
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
773
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
774
774
 
775
775
  ```bash
776
776
  npm run build
@@ -792,7 +792,7 @@ When needing to subscribe to an output, you can use `outputToObservable` from `@
792
792
 
793
793
  Check our [Angular signals guide](ANGULAR_SIGNALS.md) for more information about signals and input signals.
794
794
 
795
- **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
795
+ 🚨 **WARNING: The following command will work only when your application compiles without errors. If you have errors, fix them before continuing.**
796
796
 
797
797
  ```bash
798
798
  npm run build
@@ -974,6 +974,28 @@ describe('AppComponent', () => {
974
974
  });
975
975
  ```
976
976
 
977
+ #### Running fakeAsync tests using spyOnProperty with Vitest
978
+
979
+ Example of transformation:
980
+
981
+ ```diff
982
+ beforeEach(() => {
983
+ - spyOnProperty(sessionInfo, 'data').and.returnValue(of(sessionInfoData));
984
+ + vi.spyOn(sessionInfo, 'data', 'get').mockReturnValue(of(sessionInfoData));
985
+ });
986
+
987
+ - it('should properly map the initial data', fakeAsync(() => {
988
+ + it('should properly map the initial data', async () => {
989
+ const form = new MenuOrderForm();
990
+ - service.enrichWithSessionInfoData(form);
991
+ - tick(200);
992
+ + await firstValueFrom(service.enrichWithSessionInfoData(form));
993
+
994
+ // expect(...) here
995
+ - }));
996
+ + });
997
+ ```
998
+
977
999
  ### Migrate to eslint flat configuration
978
1000
 
979
1001
  ```bash
@@ -1274,6 +1296,8 @@ In `front/src/`, remove the file `typings.d.ts` if it is still there.
1274
1296
 
1275
1297
  ### Husky pre-commit hook
1276
1298
 
1299
+ 💡 **Tip: For multi-projects, see section below `Husky pre-commit hook for multi-project repository`**
1300
+
1277
1301
  ```bash
1278
1302
  npm install --save-dev husky lint-staged
1279
1303
  npx husky init
@@ -1301,7 +1325,17 @@ You should see in your project root folder `.husky` a new folder `_`.
1301
1325
 
1302
1326
  #### Husky pre-commit hook for multi-project repository
1303
1327
 
1304
- - when having a multi-project repository, modify `.husky/pre-commit` file with following content to make sure husky is running in the right folder:
1328
+ 💡 **Tip: Skip this part if you have already followed section `Husky pre-commit hook`**
1329
+
1330
+ ```bash
1331
+ npm install --save-dev husky lint-staged
1332
+ npx husky init
1333
+ chmod +x .husky/pre-commit
1334
+ mv ./.husky ../../.husky
1335
+ git add -A
1336
+ ```
1337
+
1338
+ Replace `.husky/pre-commit` content with the following:
1305
1339
 
1306
1340
  ```bash
1307
1341
  projects=$(git diff --cached --name-only --diff-filter=ACMR | awk -F'/' '{print $1}' | sort -u)
@@ -1314,13 +1348,37 @@ for project in $projects; do
1314
1348
  done
1315
1349
  ```
1316
1350
 
1317
- and move it to the root folder of your repository. Then change your `package.json` by modifying `prepare` script to run husky from the parent folder:
1351
+ - In your `package.json`, modify `prepare` script to run husky from the parent folder:
1318
1352
 
1319
1353
  ```diff
1320
1354
  - "prepare": "husky"
1321
1355
  + "prepare": "cd ../.. && husky"
1322
1356
  ```
1323
1357
 
1358
+ Then run:
1359
+
1360
+ ```bash
1361
+ npm install
1362
+ ```
1363
+
1364
+ You should see in your project root folder `.husky` a new folder `_`.
1365
+
1366
+ #### lint-staged
1367
+
1368
+ In your `package.json` file, check for existing `lint-staged` section and add/modify with the following content. If it does not exist, create it:
1369
+
1370
+ ```json
1371
+ "lint-staged": {
1372
+ "*.ts": [
1373
+ "eslint --fix",
1374
+ "prettier --config ./.prettierrc --write"
1375
+ ],
1376
+ "*.{js,jsx,json,css,scss,md,html}": [
1377
+ "prettier --config ./.prettierrc --write"
1378
+ ]
1379
+ },
1380
+ ```
1381
+
1324
1382
  #### Manually run formatting commands
1325
1383
 
1326
1384
  ```bash
@@ -1405,7 +1463,7 @@ npm install
1405
1463
 
1406
1464
  #### Build and launch your application
1407
1465
 
1408
- **NB: You will most probably need to fix some compilation errors such as adding `override` when needed**
1466
+ 💡 **NB: You will most probably need to fix some compilation errors such as adding `override` when needed**
1409
1467
 
1410
1468
  ```bash
1411
1469
  npm run build