Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion apps/desktop/BUILDING.md
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
when building for release, make sure node-pty is built for the correct architecture with `bun install:deps` and then run `bun release`
# Development

Run the dev server without env validation or auth:

```bash
SKIP_ENV_VALIDATION=1 bun run dev
```

This skips environment variable validation and the sign-in screen, useful for local development without credentials.

# Release

When building for release, make sure node-pty is built for the correct architecture with `bun install:deps` and then run `bun release`
1 change: 1 addition & 0 deletions apps/desktop/bunfig.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ preload = ["./test-setup.ts"]

[test.env]
NODE_ENV = "test"
SKIP_ENV_VALIDATION = "1"
9 changes: 9 additions & 0 deletions apps/desktop/electron.vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export default defineConfig({
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV || "production",
),
"process.env.SKIP_ENV_VALIDATION": JSON.stringify(
process.env.SKIP_ENV_VALIDATION || "",
),
// API URLs - baked in at build time for main process
"process.env.NEXT_PUBLIC_API_URL": JSON.stringify(
process.env.NEXT_PUBLIC_API_URL || "https://api.superset.sh",
Expand Down Expand Up @@ -104,6 +107,9 @@ export default defineConfig({
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV || "production",
),
"process.env.SKIP_ENV_VALIDATION": JSON.stringify(
process.env.SKIP_ENV_VALIDATION || "",
),
},

build: {
Expand All @@ -120,6 +126,9 @@ export default defineConfig({
define: {
// Core env vars - Vite replaces these at build time
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
"process.env.SKIP_ENV_VALIDATION": JSON.stringify(
process.env.SKIP_ENV_VALIDATION || "",
),
"process.platform": JSON.stringify(process.platform),
// API URLs - available in renderer if needed
"process.env.NEXT_PUBLIC_API_URL": JSON.stringify(
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src/main/env.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const env = createEnv({
GH_CLIENT_ID: process.env.GH_CLIENT_ID,
},
emptyStringAsUndefined: true,
skipValidation: !!process.env.SKIP_ENV_VALIDATION,

// Main process runs in trusted Node.js environment
isServer: true,
Expand Down
4 changes: 3 additions & 1 deletion apps/desktop/src/renderer/env.renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ const rawEnv = {
| undefined,
};

export const env = envSchema.parse(rawEnv);
export const env = process.env.SKIP_ENV_VALIDATION
? (rawEnv as z.infer<typeof envSchema>)
: envSchema.parse(rawEnv);
5 changes: 3 additions & 2 deletions apps/desktop/src/renderer/screens/main/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ function LoadingSpinner() {
export function MainScreen() {
const utils = trpc.useUtils();
const { data: authState } = trpc.auth.getState.useQuery();
const isSignedIn = authState?.isSignedIn ?? false;
const isAuthLoading = !authState;
const isSignedIn =
!!process.env.SKIP_ENV_VALIDATION || (authState?.isSignedIn ?? false);
const isAuthLoading = !process.env.SKIP_ENV_VALIDATION && !authState;

// Subscribe to auth state changes
trpc.auth.onStateChange.useSubscription(undefined, {
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/test-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { tmpdir } from "node:os";
import { join } from "node:path";

process.env.NODE_ENV = "test";
process.env.SKIP_ENV_VALIDATION = "1";
process.env.GOOGLE_CLIENT_ID = "test-google-client-id";
process.env.GH_CLIENT_ID = "test-github-client-id";

Expand Down
1 change: 1 addition & 0 deletions packages/trpc/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export const env = createEnv({
client: {},
runtimeEnv: process.env,
emptyStringAsUndefined: true,
skipValidation: !!process.env.SKIP_ENV_VALIDATION,
});