From 10e5ccfe86f2f341671c6a0c6cda1ea6a5da0e20 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 14 Oct 2025 16:33:46 -0700 Subject: [PATCH] Handle tsconfig --- .dockerignore | 4 +++- .gitignore | 1 + Dockerfile | 6 +++++ Makefile | 2 ++ package.json | 9 ++++---- tsconfig.enterprise.json | 36 ++++++++++++++++++++++++++++++ tsconfig.json => tsconfig.oss.json | 0 tsconfig.saas.json | 36 ++++++++++++++++++++++++++++++ 8 files changed, 88 insertions(+), 6 deletions(-) create mode 100644 tsconfig.enterprise.json rename tsconfig.json => tsconfig.oss.json (100%) create mode 100644 tsconfig.saas.json diff --git a/.dockerignore b/.dockerignore index 9223d5b5..ecd919cd 100644 --- a/.dockerignore +++ b/.dockerignore @@ -29,4 +29,6 @@ CONTRIBUTING.md dist .git migrations/ -config/ \ No newline at end of file +config/ +build.ts +tsconfig.json \ No newline at end of file diff --git a/.gitignore b/.gitignore index 23fdd106..2fc6b10b 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,4 @@ postgres/ dynamic/ *.mmdb scratch/ +tsconfig.json \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index bc85b0aa..1a1493a5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,6 +15,12 @@ RUN echo "export * from \"./$DATABASE\";" > server/db/index.ts RUN echo "export const build = \"$BUILD\" as any;" > server/build.ts +# Copy the appropriate TypeScript configuration based on build type +RUN if [ "$BUILD" = "oss" ]; then cp tsconfig.oss.json tsconfig.json; \ + elif [ "$BUILD" = "saas" ]; then cp tsconfig.saas.json tsconfig.json; \ + elif [ "$BUILD" = "enterprise" ]; then cp tsconfig.enterprise.json tsconfig.json; \ + fi + # if the build is oss then remove the server/private directory RUN if [ "$BUILD" = "oss" ]; then rm -rf server/private; fi diff --git a/Makefile b/Makefile index e4a709ec..ed888631 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ build-release: exit 1; \ fi docker buildx build \ + --build-arg BUILD=oss --build-arg DATABASE=sqlite \ --platform linux/arm64,linux/amd64 \ --tag fosrl/pangolin:latest \ @@ -16,6 +17,7 @@ build-release: --tag fosrl/pangolin:$(tag) \ --push . docker buildx build \ + --build-arg BUILD=oss --build-arg DATABASE=pg \ --platform linux/arm64,linux/amd64 \ --tag fosrl/pangolin:postgresql-latest \ diff --git a/package.json b/package.json index 4484ee89..862864a0 100644 --- a/package.json +++ b/package.json @@ -19,9 +19,9 @@ "db:sqlite:studio": "drizzle-kit studio --config=./drizzle.sqlite.config.ts", "db:pg:studio": "drizzle-kit studio --config=./drizzle.pg.config.ts", "db:clear-migrations": "rm -rf server/migrations", - "set:oss": "echo 'export const build = \"oss\" as any;' > server/build.ts", - "set:saas": "echo 'export const build = \"saas\" as any;' > server/build.ts", - "set:enterprise": "echo 'export const build = \"enterprise\" as any;' > server/build.ts", + "set:oss": "echo 'export const build = \"oss\" as any;' > server/build.ts && cp tsconfig.oss.json tsconfig.json", + "set:saas": "echo 'export const build = \"saas\" as any;' > server/build.ts && cp tsconfig.saas.json tsconfig.json", + "set:enterprise": "echo 'export const build = \"enterprise\" as any;' > server/build.ts && cp tsconfig.enterprise.json tsconfig.json", "set:sqlite": "echo 'export * from \"./sqlite\";' > server/db/index.ts", "set:pg": "echo 'export * from \"./pg\";' > server/db/index.ts", "next:build": "next build", @@ -29,8 +29,7 @@ "build:pg": "mkdir -p dist && next build && node esbuild.mjs -e server/index.ts -o dist/server.mjs && node esbuild.mjs -e server/setup/migrationsPg.ts -o dist/migrations.mjs", "start": "ENVIRONMENT=prod node dist/migrations.mjs && ENVIRONMENT=prod NODE_ENV=development node --enable-source-maps dist/server.mjs", "email": "email dev --dir server/emails/templates --port 3005", - "build:cli": "node esbuild.mjs -e cli/index.ts -o dist/cli.mjs", - "db:sqlite:seed-exit-node": "sqlite3 config/db/db.sqlite \"INSERT INTO exitNodes (exitNodeId, name, address, endpoint, publicKey, listenPort, reachableAt, maxConnections, online, lastPing, type, region) VALUES (null, 'test', '10.0.0.1/24', 'localhost', 'MJ44MpnWGxMZURgxW/fWXDFsejhabnEFYDo60LQwK3A=', 1234, 'http://localhost:3003', 123, 1, null, 'gerbil', null);\"" + "build:cli": "node esbuild.mjs -e cli/index.ts -o dist/cli.mjs" }, "dependencies": { "@asteasolutions/zod-to-openapi": "^7.3.4", diff --git a/tsconfig.enterprise.json b/tsconfig.enterprise.json new file mode 100644 index 00000000..0b856fe0 --- /dev/null +++ b/tsconfig.enterprise.json @@ -0,0 +1,36 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "baseUrl": "src", + "paths": { + "@server/*": ["../server/*"], + "@test/*": ["../test/*"], + "@app/*": ["*"], + "@cli/*": ["../cli/*"], + "@/*": ["./*"], + "#private/*": ["../server/private/*"], + "#open/*": ["../server/*"], + "#closed/*": ["../server/private/*"], + "#dynamic/*": ["../server/private/*"] + }, + "plugins": [ + { + "name": "next" + } + ], + "target": "ES2022" + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] +} diff --git a/tsconfig.json b/tsconfig.oss.json similarity index 100% rename from tsconfig.json rename to tsconfig.oss.json diff --git a/tsconfig.saas.json b/tsconfig.saas.json new file mode 100644 index 00000000..0b856fe0 --- /dev/null +++ b/tsconfig.saas.json @@ -0,0 +1,36 @@ +{ + "compilerOptions": { + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "baseUrl": "src", + "paths": { + "@server/*": ["../server/*"], + "@test/*": ["../test/*"], + "@app/*": ["*"], + "@cli/*": ["../cli/*"], + "@/*": ["./*"], + "#private/*": ["../server/private/*"], + "#open/*": ["../server/*"], + "#closed/*": ["../server/private/*"], + "#dynamic/*": ["../server/private/*"] + }, + "plugins": [ + { + "name": "next" + } + ], + "target": "ES2022" + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] +}