From f480da7d35c38a789f408ccf1d8437662974fbcf Mon Sep 17 00:00:00 2001 From: Shreeyash Shrestha Date: Tue, 19 Nov 2024 14:43:23 +0545 Subject: [PATCH] Add ts files in "generated" on knip --- .../{workflows => }/pull_request_template.md | 0 docker-compose-with-backend.yml | 2 +- knip.json | 11 ++++---- package.json | 27 +++++++------------ pnpm-lock.yaml | 6 ++--- type.template.tsx | 16 ----------- 6 files changed, 20 insertions(+), 42 deletions(-) rename .github/{workflows => }/pull_request_template.md (100%) delete mode 100644 type.template.tsx diff --git a/.github/workflows/pull_request_template.md b/.github/pull_request_template.md similarity index 100% rename from .github/workflows/pull_request_template.md rename to .github/pull_request_template.md diff --git a/docker-compose-with-backend.yml b/docker-compose-with-backend.yml index 492af476..d936724f 100644 --- a/docker-compose-with-backend.yml +++ b/docker-compose-with-backend.yml @@ -7,7 +7,7 @@ services: environment: APP_TITLE: ${APP_TITLE:-CMS} APP_GRAPHQL_ENDPOINT: ${APP_GRAPHQL_ENDPOINT:-http://localhost:8001/graphql/} - APP_GRAPHQL_CODEGEN_ENDPOINT: ${APP_GRAPHQL_CODEGEN_ENDPOINT:-http://web:8001/graphql/} + APP_GRAPHQL_CODEGEN_ENDPOINT: ${APP_GRAPHQL_CODEGEN_ENDPOINT:-./backend/schema.graphql} volumes: - ../:/code ports: diff --git a/knip.json b/knip.json index 208c1997..810ee50e 100644 --- a/knip.json +++ b/knip.json @@ -1,16 +1,17 @@ { "$schema": "https://unpkg.com/knip@5/schema.json", - "ignoreBinaries": ["awk", "ip"], + "ignore": ["generated/**/*.ts"], "entry": [ + "src/index.tsx!", "src/**/*.test.ts", - "src/**/*.test.tsx", - "src/index.tsx!" + "src/**/*.test.tsx" ], "project": [ + "src/**/*.tsx!", + "src/**/*.ts!", "src/**/*.d.ts", "src/**/*.test.ts", "src/**/*.test.tsx", - "src/**/*.tsx!", - "src/**/*.ts!" + "generated/**/*.ts" ] } diff --git a/package.json b/package.json index 922920ab..c044abc3 100644 --- a/package.json +++ b/package.json @@ -4,35 +4,29 @@ "version": "0.0.0", "type": "module", "scripts": { + "generate:type": "graphql-codegen --require dotenv/config --config codegen.ts", + "prestart": "pnpm generate:type", "start": "vite", - "dev": "vite", - "preview": "vite preview", - "test": "vitest", - "coverage": "vitest run --coverage", - "prestart": "pnpm initialize", - "get-hostname": "ip route | awk '/default/ { print $3 }'", - "replace-localhost": "awk \"{sub(/localhost/, \\\"$(pnpm -s get-hostname)\\\")}1\"", - "generate:type": "APP_GRAPHQL_CODEGEN_ENDPOINT=$(echo $APP_GRAPHQL_CODEGEN_ENDPOINT | pnpm -s replace-localhost) graphql-codegen --require dotenv/config --config codegen.ts", - "initialize": "pnpm generate:type", - "prebuild": "pnpm initialize", + "prebuild": "pnpm generate:type", "build": "vite build", - "pretypecheck": "pnpm initialize", + "pretypecheck": "pnpm generate:type", "typecheck": "tsc", - "prelint:js": "pnpm initialize", + "prelint:unused": "pnpm generate:type", + "lint:unused": "knip --no-gitignore --tags=-knipignore", + "prelint:js": "pnpm generate:type", "lint:js": "eslint src", - "prelint:css": "pnpm initialize", "lint:css": "stylelint \"./src/**/*.css\"", - "prelint": "pnpm initialize", "lint": "pnpm lint:js && pnpm lint:css", "lint:fix": "pnpm lint:js --fix && pnpm lint:css --fix", - "prelint:unused": "pnpm initialize", - "lint:unused": "knip --tags=-knipignore", + "test": "vitest", + "test:coverage": "vitest run --coverage", "postinstall": "patch-package" }, "dependencies": { "@apollo/client": "^3.11.8", "@togglecorp/fujs": "^2.0.0", "@julr/vite-plugin-validate-env": "^1.1.1", + "@graphql-typed-document-node/core": "^3.2.0", "graphql": "^16.9.0", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -41,7 +35,6 @@ "devDependencies": { "@graphql-codegen/cli": "^5.0.2", "@graphql-codegen/client-preset": "^4.3.3", - "@graphql-typed-document-node/core": "^3.2.0", "@types/node": "^20.1.3", "@types/react": "^18.0.28", "@types/react-dom": "^18.0.11", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 135726bc..96ce0149 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@apollo/client': specifier: ^3.11.8 version: 3.11.8(@types/react@18.0.28)(graphql-ws@5.16.0(graphql@16.9.0))(graphql@16.9.0)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) + '@graphql-typed-document-node/core': + specifier: ^3.2.0 + version: 3.2.0(graphql@16.9.0) '@julr/vite-plugin-validate-env': specifier: ^1.1.1 version: 1.1.1(vite@5.1.5(@types/node@20.1.3))(zod@3.23.8) @@ -36,9 +39,6 @@ importers: '@graphql-codegen/client-preset': specifier: ^4.3.3 version: 4.4.0(graphql@16.9.0) - '@graphql-typed-document-node/core': - specifier: ^3.2.0 - version: 3.2.0(graphql@16.9.0) '@types/node': specifier: ^20.1.3 version: 20.1.3 diff --git a/type.template.tsx b/type.template.tsx deleted file mode 100644 index a4450ea4..00000000 --- a/type.template.tsx +++ /dev/null @@ -1,16 +0,0 @@ -/* - Both lint and build steps fail if `generated/type.tsx` is missing - We generally genereate this file using graphql-codegen but graphql-codegen - cannot always be used. - In such cases, just copy this mock type.tsx to ensure that lint and build - steps pass. - NOTE: typecheck step still fails. -*/ - -export type Query = { - __typename?: 'Query'; -}; - -export type Mutation = { - __typename?: 'Mutation'; -};