Skip to content

Commit

Permalink
Add ts files in "generated" on knip
Browse files Browse the repository at this point in the history
  • Loading branch information
shreeyash07 committed Nov 20, 2024
1 parent 2bfbe59 commit 0437d6a
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 73 deletions.
File renamed without changes.
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ FROM node:18-bullseye

RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
git bash g++ make iproute2 \
&& rm -rf /var/lib/apt/lists/*

git bash g++ make \
RUN npm install -g pnpm

WORKDIR /code
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-with-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
COMPOSE_FILE=

APP_TITLE=
APP_GRAPHQL_CODEGEN_ENDPOINT=
APP_GRAPHQL_ENDPOINT=
22 changes: 14 additions & 8 deletions env.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import {
defineConfig,
Schema,
} from '@julr/vite-plugin-validate-env';
import { Schema } from '@julr/vite-plugin-validate-env';

export default defineConfig({
COMPOSE_FILE: Schema.string.optional(),
APP_TITLE: Schema.string.optional(),
});
const envConfig = {
validator: 'builtin',
debug: true,
schema: {
// NOTE: We need to replace with URL
APP_GRAPHQL_ENDPOINT: Schema.string(),

// NOTE: It is not used for now
APP_TITLE: Schema.string.optional(),
},
};

export default envConfig;
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
<title>
%APP_TITLE%
</title>
<link href="https://fonts.googleapis.com/css2?family=Manrope:[email protected]&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Assistant:[email protected]&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;600;700&family=Manrope:wght@300;400;600;700&display=swap" rel="stylesheet">
<style>
html, body {
margin: 0;
Expand Down
16 changes: 0 additions & 16 deletions knip.json

This file was deleted.

18 changes: 18 additions & 0 deletions knip.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
/* NOTE: It is ignored because some of the files and types inside the generated will not be used but needed. */
"ignore": ["generated/**/*.ts"],
"entry": [
"src/index.tsx!",
"src/**/*.test.ts",
"src/**/*.test.tsx"
],
"project": [
"src/**/*.tsx!",
"src/**/*.ts!",
"src/**/*.d.ts",
"src/**/*.test.ts",
"src/**/*.test.tsx",
"generated/**/*.ts"
]
}
27 changes: 10 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ import { unwrappedRoutes } from './routes';
const ME_QUERY = gql`
query Me {
public {
id
me {
displayName
email
firstName
id
firstName
lastName
email
displayName
}
}
}
Expand All @@ -52,10 +51,9 @@ function App() {
);

useEffect(() => {
if (loading) {
return;
if (!loading) {
setUserAuth(meResult?.public.me ?? undefined);
}
setUserAuth(meResult?.public.me ?? undefined);
}, [meResult, loading]);

const removeUserAuth = useCallback(
Expand All @@ -74,6 +72,10 @@ function App() {
[userAuth, removeUserAuth],
);

if (loading) {
return null;
}

return (
<UserContext.Provider value={userContextValue}>
<RouterProvider router={router} />
Expand Down
16 changes: 0 additions & 16 deletions type.template.tsx

This file was deleted.

0 comments on commit 0437d6a

Please sign in to comment.