birc-generator 0.9.1 → 1.0.0

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.
Files changed (58) hide show
  1. package/PROJECT.md +23 -4
  2. package/README.md +13 -11
  3. package/bin/birc.js +10 -4
  4. package/bin/cli-util.js +30 -2
  5. package/lib/create.js +150 -0
  6. package/lib/features.js +558 -0
  7. package/lib/make.js +658 -0
  8. package/lib/project.js +234 -0
  9. package/package.json +5 -3
  10. package/plopfile.js +60 -1340
  11. package/project-docs/PROJECT.md.hbs +13 -0
  12. package/templates/aop/OperationLogAspect.hbs +10 -3
  13. package/templates/auth/AuthController.hbs +73 -0
  14. package/templates/auth/AuthFlowTest.hbs +112 -0
  15. package/templates/auth/AuthSecurityCustomizer.hbs +38 -0
  16. package/templates/auth/AuthUser.hbs +54 -0
  17. package/templates/auth/AuthUserDAO.hbs +9 -0
  18. package/templates/auth/JpaUserDetailsService.hbs +47 -0
  19. package/templates/auth/JwtAuthenticationFilter.hbs +50 -0
  20. package/templates/auth/JwtProperties.hbs +35 -0
  21. package/templates/auth/JwtSecretEnvTest.hbs +68 -0
  22. package/templates/auth/JwtSecretEnvironmentPostProcessor.hbs +102 -0
  23. package/templates/auth/JwtService.hbs +60 -0
  24. package/templates/auth/LoginFailedException.hbs +27 -0
  25. package/templates/auth/LoginRequest.hbs +16 -0
  26. package/templates/auth/V1__create_auth_users_table.sql.hbs +13 -0
  27. package/templates/auth/application-yml-block.hbs +7 -0
  28. package/templates/auth/build-gradle-dep.hbs +4 -0
  29. package/templates/auth/spring.factories.hbs +1 -0
  30. package/templates/base/CorsTest.java.hbs +93 -0
  31. package/templates/base/README.md.hbs +6 -0
  32. package/templates/base/application-test.yml.hbs +3 -0
  33. package/templates/base/application.yml.hbs +12 -0
  34. package/templates/clockin/ClockInApiException.hbs +37 -0
  35. package/templates/clockin/ClockInApiResponse.hbs +14 -0
  36. package/templates/clockin/ClockInClient.hbs +251 -0
  37. package/templates/clockin/ClockInClientConfig.hbs +41 -0
  38. package/templates/clockin/ClockInController.hbs +77 -0
  39. package/templates/clockin/ClockInPage.hbs +11 -0
  40. package/templates/clockin/ClockInProperties.hbs +34 -0
  41. package/templates/clockin/ClockInRecord.hbs +20 -0
  42. package/templates/clockin/MemberImage.hbs +7 -0
  43. package/templates/clockin/OnDutyWeek.hbs +26 -0
  44. package/templates/clockin/UnclockedMember.hbs +7 -0
  45. package/templates/clockin/UserPermission.hbs +11 -0
  46. package/templates/clockin/application-yml-block.hbs +10 -0
  47. package/templates/docker/docker-compose.prod.yml.hbs +5 -0
  48. package/templates/docker/docker-compose.yml.hbs +7 -1
  49. package/templates/docker/env.example.hbs +15 -0
  50. package/templates/file-upload/FileExtensionUtils.hbs +45 -0
  51. package/templates/file-upload/FileExtensionUtilsTest.hbs +48 -0
  52. package/templates/file-upload/FileStorageServiceImpl.hbs +6 -0
  53. package/templates/multi-module/config/SecurityConfig.java.hbs +123 -8
  54. package/templates/multi-module/config/SecurityCustomizer.java.hbs +24 -0
  55. package/templates/openapi/ApiDocsAccessTest.hbs +60 -0
  56. package/templates/openapi/application-yml-block.hbs +8 -0
  57. package/test.md +6 -3
  58. package/versions.js +1 -0
package/test.md CHANGED
@@ -10,10 +10,10 @@
10
10
 
11
11
  覆蓋率與變異測試是這份 repo 的硬門檻,不是某一張票順便加的:
12
12
 
13
- - `npm run test:coverage`:`c8` 打 `plopfile.js`、`versions.js`、`bin/cli-util.js`,行/函式/陳述 < 80% 或分支 < 65% 就失敗。安裝/更新的 tar 跳脫與自訂 URL 另有定向測試,不拿整份 `home-install.js` 湊門檻。
13
+ - `npm run test:coverage`:`c8` 打 `plopfile.js`、`lib/`、`versions.js`、`bin/cli-util.js`,行/函式/陳述 < 80% 或分支 < 65% 就失敗。安裝/更新的 tar 跳脫與自訂 URL 另有定向測試,不拿整份 `home-install.js` 湊門檻。
14
14
  - `npm run test:mutation`:Stryker 打 `bin/cli-util.js`(路徑、Gradle wrapper、create 預設),突變分數 < 70 就失敗。`plopfile.js` 的全量突變會重跑 `./gradlew test`,太慢,關鍵路徑改完仍做一次**人工突變**。
15
15
 
16
- `.gitlab-ci.yml` 跑這兩道;紅了不能合。過程中跑單一測試;完整 `npm test` 只在 implement 最後一次(裡面會 `create` / `add` / `./gradlew test`)。
16
+ `.gitlab-ci.yml` 並行跑覆蓋率(要 JDK,因為裡面有 `./gradlew test`)與變異測試(只要 Node,並先 `npm audit --omit=dev`);紅了不能合。MR 上看得出覆蓋率。過程中跑單一測試;完整 `npm test` 只在 implement 最後一次。
17
17
 
18
18
  ## 打在哪
19
19
 
@@ -31,8 +31,11 @@
31
31
  - `add` 冪等:已記在 `.bircrc.json.features` 的不再執行;舊專案漏記時既有檔與 fragment 也要跳過。
32
32
  - `add` 預檢查:要插 yml / gradle 時 dest 沒有 anchor 就失敗,且不能留下新的 Java 檔。缺 plugin-anchor 時不寫 `spotless_formatter.xml`。
33
33
  - 全 feature `create` + `make User` 之後 `./gradlew test` 與 `./gradlew spotlessCheck` 都過。
34
- - `add --force` / `sync`:覆寫已安裝 feature 的檔,yml / gradle 不重貼。
34
+ - `add --force` / `sync`:覆寫已安裝 feature 的檔,yml / gradle 不重貼。`sync` 也不換已有的 `JWT_SECRET`。
35
+ - `auth`:Entity 是 `AuthUser` / `auth_users`,不佔 `User`。JWT filter 走 `SecurityCustomizer`,不改寫 `SecurityConfig`。登入回 `X-Auth-Token`,未登入探針是 `GET /api/auth/me`。`EnvironmentPostProcessor` 登記在 `spring.factories`,介面是 `org.springframework.boot.EnvironmentPostProcessor`。
36
+ - `JWT_SECRET`:`create` / `add` 只在空白時填;沒勾 docker 也要寫出 `.env`。`.env.example` 保持空值。
35
37
  - CLI dest:檔落在呼叫者目錄,不是 generator repo。
38
+ - `make` 撞到已有 Java 只印 `Error:` 與那一個檔與 `make:migration` / `make:seeder` 提示,不印 `Aborted due to previous action failure`。
36
39
  - 產出 Java 沒有 `tw.edu.ntub.birc.starter` / `birc-spring-boot-starter`。
37
40
  - `make:entity --dto` / `--mapper` 與 `make:mapper` 同一組 Mapper + DTO;預設 `make:entity` 不生它們。
38
41
  - `make --fields --migration --seed` 寫 CREATE TABLE 與 Java `XxxSeeder`,不生 seed SQL;`make:model --migration` 的表名跟 Entity `@Table` 一致。已有 Entity 時 `make` / `make:entity --migration` / `--seed` 跳過 Java,只補 CREATE TABLE / `XxxSeeder`。
package/versions.js CHANGED
@@ -4,6 +4,7 @@ module.exports = Object.freeze({
4
4
  flywayVersion: '11.14.1',
5
5
  sentryVersion: '8.40.0',
6
6
  springdocVersion: '3.0.2',
7
+ jjwtVersion: '0.12.6',
7
8
  mapstructVersion: '1.6.3',
8
9
  lombokMapstructBindingVersion: '0.2.0',
9
10
  spotlessVersion: '6.25.0'