From 9d7d64a87a6ec68b553e7b42a15184e7d6375cb7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C3=ABl=20Bitard?= <bitard.michael@gmail.com>
Date: Wed, 29 May 2024 09:31:03 +0200
Subject: [PATCH] =?UTF-8?q?chore(infra):=20acc=C3=A8l=C3=A9re=20la=20tsc?=
 =?UTF-8?q?=20en=20activant=20l'incremental=20build=20(#1195)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitignore                   |  1 +
 knip.ts                      | 49 ++++++++++++++++--------------------
 package.json                 |  2 +-
 packages/api/package.json    |  2 +-
 packages/common/package.json |  2 +-
 packages/ui/package.json     |  2 +-
 6 files changed, 26 insertions(+), 32 deletions(-)

diff --git a/.gitignore b/.gitignore
index ded9a3207..c194cdc0a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
 node_modules
+**/tsconfig.tsbuildinfo
 .idea
 .zed
 .eslintcache
diff --git a/knip.ts b/knip.ts
index 13449d39b..8f82ecd63 100644
--- a/knip.ts
+++ b/knip.ts
@@ -1,30 +1,7 @@
 const config = {
-  ignore: [
-    ".history/**",
-    "packages/api/knexfile.ts",
-    "**/knex/migrations/*",
-    "packages/api/src/knex/migration-stub.ts",
-    "packages/common/src/**/*.test.ts",
-    "packages/api/src/tools/phases/tests-creation.ts",
-    "packages/api/src/**/*.queries.types.ts",
-  ],
-  ignoreBinaries: [
-    "eslint",
-    "prettier",
-    "createdb",
-    "dropdb",
-    "npm-check-updates",
-    "pg_dump",
-    "pg_restore",
-    "pgtyped-config.ci.json",
-    "pgtyped-config.json",
-    "scp",
-    "ssh",
-    "tar",
-  ],
-
   workspaces: {
     ".": {
+      ignoreBinaries: ["eslint", "prettier"],
       ignoreDependencies: [
         // TODO 2023-12-28 knip voit pas les override dependencies
         "vue",
@@ -35,8 +12,25 @@ const config = {
       ],
     },
     "packages/api": {
-      entry: ["src/index.ts", "src/scripts/*"],
-      project: "**/*.ts",
+      ignoreBinaries: [
+        "createdb",
+        "dropdb",
+        "npm-check-updates",
+        "pg_dump",
+        "pg_restore",
+        "pgtyped-config.ci.json",
+        "pgtyped-config.json",
+        "scp",
+        "tar",
+      ],
+      ignore: ["knexfile.ts", "src/**/*.queries.types.ts"],
+      entry: [
+        "src/index.ts",
+        "src/scripts/*",
+        "src/tools/phases/tests-creation.ts",
+        "src/knex/migration-stub.ts",
+        "src/knex/migrations/*",
+      ],
       ignoreDependencies: [
         // TODO 2023-12-28 ces dépendances semblent être "shadow" par les définitions bourrines .d.ts qu'on a mise
         "graphql-scalars",
@@ -53,8 +47,7 @@ const config = {
       ],
     },
     "packages/ui": {
-      entry: "src/index.ts",
-      project: ["src/**/*.tsx", "src/**/*.ts", "src/**/*.js"],
+      ignoreBinaries: ["npm-check-updates"],
       ignoreDependencies: [
         "@vitest/coverage-v8",
         "@babel/eslint-parser",
diff --git a/package.json b/package.json
index 007877a0c..7b92aa373 100644
--- a/package.json
+++ b/package.json
@@ -21,7 +21,7 @@
     "prepare": "husky install",
     "test": "npm run test --workspaces",
     "lint": "npm run lint --workspaces",
-    "knip": "npx --yes knip@5.15.1"
+    "knip": "npx --yes knip@5.17.3"
   },
   "lint-staged": {
     "packages/ui/src/**/*.{js,ts,tsx}": [
diff --git a/packages/api/package.json b/packages/api/package.json
index a4451f2da..17d9a9a67 100644
--- a/packages/api/package.json
+++ b/packages/api/package.json
@@ -6,7 +6,7 @@
   "main": "./src/index.js",
   "type": "module",
   "scripts": {
-    "build": "tsc",
+    "build": "tsc --incremental",
     "daily": "node --loader ts-node/esm/transpile-only ./src/scripts/daily.ts",
     "monthly": "node --loader ts-node/esm/transpile-only ./src/scripts/monthly.ts",
     "db:dump": "rm -rf ./backups/* && pg_dump --host=localhost --username=postgres --clean --if-exists --format=d --no-owner --no-privileges --dbname=camino --file=./backups/",
diff --git a/packages/common/package.json b/packages/common/package.json
index 68396783d..8cebcc174 100644
--- a/packages/common/package.json
+++ b/packages/common/package.json
@@ -6,7 +6,7 @@
   "type": "module",
   "scripts": {
     "test": "vitest --environment node --root src/",
-    "build": "tsc",
+    "build": "tsc --incremental",
     "format": "prettier --write src && eslint --fix src",
     "lint": "prettier --check src && eslint src"
   },
diff --git a/packages/ui/package.json b/packages/ui/package.json
index e43cb8d8e..aebb77fee 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -5,7 +5,7 @@
   "private": true,
   "type": "module",
   "scripts": {
-    "build": "tsc --noEmit && vite build --emptyOutDir",
+    "build": "tsc --noEmit --incremental && vite build --emptyOutDir",
     "dev": "vite --host",
     "dev:update": "npm-check-updates && npm install && npm audit fix",
     "start": "node ./index.js",
-- 
GitLab