From e068427f217cdc1fb3e156dc297407a735ffcbe2 Mon Sep 17 00:00:00 2001 From: Mihovil Ilakovac Date: Fri, 29 Nov 2024 11:37:39 +0100 Subject: [PATCH] e2e tests Signed-off-by: Mihovil Ilakovac --- .../waspBuild-golden/files.manifest | 9 +++++++ .../waspBuild/.wasp/build/.waspchecksums | 24 +++++++++++++++---- .../.wasp/build/sdk/wasp/client/env.ts | 11 +-------- .../.wasp/build/sdk/wasp/client/env/schema.ts | 11 +++++++++ .../.wasp/build/sdk/wasp/dist/client/env.js | 9 +------ .../build/sdk/wasp/dist/client/env.js.map | 2 +- .../sdk/wasp/dist/client/env/schema.d.ts | 8 +++++++ .../build/sdk/wasp/dist/client/env/schema.js | 11 +++++++++ .../sdk/wasp/dist/client/env/schema.js.map | 1 + .../.wasp/build/sdk/wasp/dist/env/index.js | 1 + .../build/sdk/wasp/dist/env/index.js.map | 2 +- .../.wasp/build/sdk/wasp/env/index.ts | 1 + .../.wasp/build/sdk/wasp/package.json | 2 ++ .../build/web-app/plugins/validateEnv.ts | 14 +++++++++++ .../.wasp/build/web-app/tsconfig.node.json | 2 +- .../.wasp/build/web-app/vite.config.ts | 7 +++++- .../.wasp/out/sdk/wasp/client/env.ts | 11 +-------- .../.wasp/out/sdk/wasp/client/env/schema.ts | 11 +++++++++ .../.wasp/out/sdk/wasp/dist/client/env.js | 9 +------ .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../out/sdk/wasp/dist/client/env/schema.d.ts | 8 +++++++ .../out/sdk/wasp/dist/client/env/schema.js | 11 +++++++++ .../sdk/wasp/dist/client/env/schema.js.map | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../waspBuild/.wasp/out/sdk/wasp/env/index.ts | 1 + .../waspBuild/.wasp/out/sdk/wasp/package.json | 2 ++ .../waspCompile-golden/files.manifest | 5 ++++ .../waspCompile/.wasp/out/.waspchecksums | 24 +++++++++++++++---- .../.wasp/out/sdk/wasp/client/env.ts | 11 +-------- .../.wasp/out/sdk/wasp/client/env/schema.ts | 11 +++++++++ .../.wasp/out/sdk/wasp/dist/client/env.js | 9 +------ .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../out/sdk/wasp/dist/client/env/schema.d.ts | 8 +++++++ .../out/sdk/wasp/dist/client/env/schema.js | 11 +++++++++ .../sdk/wasp/dist/client/env/schema.js.map | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../.wasp/out/sdk/wasp/env/index.ts | 1 + .../.wasp/out/sdk/wasp/package.json | 2 ++ .../.wasp/out/web-app/plugins/validateEnv.ts | 14 +++++++++++ .../.wasp/out/web-app/tsconfig.node.json | 2 +- .../.wasp/out/web-app/vite.config.ts | 7 +++++- .../waspComplexTest-golden/files.manifest | 5 ++++ .../waspComplexTest/.wasp/out/.waspchecksums | 24 +++++++++++++++---- .../.wasp/out/sdk/wasp/client/env.ts | 11 +-------- .../.wasp/out/sdk/wasp/client/env/schema.ts | 11 +++++++++ .../.wasp/out/sdk/wasp/dist/client/env.js | 9 +------ .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../out/sdk/wasp/dist/client/env/schema.d.ts | 8 +++++++ .../out/sdk/wasp/dist/client/env/schema.js | 11 +++++++++ .../sdk/wasp/dist/client/env/schema.js.map | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../.wasp/out/sdk/wasp/env/index.ts | 1 + .../.wasp/out/sdk/wasp/package.json | 2 ++ .../.wasp/out/web-app/plugins/validateEnv.ts | 14 +++++++++++ .../.wasp/out/web-app/tsconfig.node.json | 2 +- .../.wasp/out/web-app/vite.config.ts | 7 +++++- .../waspJob-golden/files.manifest | 5 ++++ .../waspJob/.wasp/out/.waspchecksums | 24 +++++++++++++++---- .../waspJob/.wasp/out/sdk/wasp/client/env.ts | 11 +-------- .../.wasp/out/sdk/wasp/client/env/schema.ts | 11 +++++++++ .../.wasp/out/sdk/wasp/dist/client/env.js | 9 +------ .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../out/sdk/wasp/dist/client/env/schema.d.ts | 8 +++++++ .../out/sdk/wasp/dist/client/env/schema.js | 11 +++++++++ .../sdk/wasp/dist/client/env/schema.js.map | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../waspJob/.wasp/out/sdk/wasp/env/index.ts | 1 + .../waspJob/.wasp/out/sdk/wasp/package.json | 2 ++ .../.wasp/out/web-app/plugins/validateEnv.ts | 14 +++++++++++ .../.wasp/out/web-app/tsconfig.node.json | 2 +- .../waspJob/.wasp/out/web-app/vite.config.ts | 7 +++++- .../waspMigrate-golden/files.manifest | 5 ++++ .../waspMigrate/.wasp/out/.waspchecksums | 24 +++++++++++++++---- .../.wasp/out/sdk/wasp/client/env.ts | 11 +-------- .../.wasp/out/sdk/wasp/client/env/schema.ts | 11 +++++++++ .../.wasp/out/sdk/wasp/dist/client/env.js | 9 +------ .../.wasp/out/sdk/wasp/dist/client/env.js.map | 2 +- .../out/sdk/wasp/dist/client/env/schema.d.ts | 8 +++++++ .../out/sdk/wasp/dist/client/env/schema.js | 11 +++++++++ .../sdk/wasp/dist/client/env/schema.js.map | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js | 1 + .../.wasp/out/sdk/wasp/dist/env/index.js.map | 2 +- .../.wasp/out/sdk/wasp/env/index.ts | 1 + .../.wasp/out/sdk/wasp/package.json | 2 ++ .../.wasp/out/web-app/plugins/validateEnv.ts | 14 +++++++++++ .../.wasp/out/web-app/tsconfig.node.json | 2 +- .../.wasp/out/web-app/vite.config.ts | 7 +++++- 91 files changed, 463 insertions(+), 155 deletions(-) create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env/schema.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js.map create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/plugins/validateEnv.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env/schema.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js create mode 100644 waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js.map create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env/schema.ts create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js.map create mode 100644 waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/plugins/validateEnv.ts create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env/schema.ts create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js.map create mode 100644 waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/plugins/validateEnv.ts create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env/schema.ts create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js.map create mode 100644 waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/plugins/validateEnv.ts create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env/schema.ts create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js.map create mode 100644 waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/plugins/validateEnv.ts diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest b/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest index 81e64e5f2d..ae43282d69 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/files.manifest @@ -8,6 +8,7 @@ waspBuild/.wasp/build/sdk/wasp/api/events.ts waspBuild/.wasp/build/sdk/wasp/api/index.ts waspBuild/.wasp/build/sdk/wasp/client/config.ts waspBuild/.wasp/build/sdk/wasp/client/env.ts +waspBuild/.wasp/build/sdk/wasp/client/env/schema.ts waspBuild/.wasp/build/sdk/wasp/client/index.ts waspBuild/.wasp/build/sdk/wasp/client/operations/actions/core.ts waspBuild/.wasp/build/sdk/wasp/client/operations/actions/index.ts @@ -40,6 +41,9 @@ waspBuild/.wasp/build/sdk/wasp/dist/client/config.js.map waspBuild/.wasp/build/sdk/wasp/dist/client/env.d.ts waspBuild/.wasp/build/sdk/wasp/dist/client/env.js waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map +waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.d.ts +waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js +waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js.map waspBuild/.wasp/build/sdk/wasp/dist/client/index.d.ts waspBuild/.wasp/build/sdk/wasp/dist/client/index.js waspBuild/.wasp/build/sdk/wasp/dist/client/index.js.map @@ -230,6 +234,7 @@ waspBuild/.wasp/build/web-app/README.md waspBuild/.wasp/build/web-app/index.html waspBuild/.wasp/build/web-app/netlify.toml waspBuild/.wasp/build/web-app/package.json +waspBuild/.wasp/build/web-app/plugins/validateEnv.ts waspBuild/.wasp/build/web-app/public/.gitkeep waspBuild/.wasp/build/web-app/public/favicon.ico waspBuild/.wasp/build/web-app/public/manifest.json @@ -251,6 +256,7 @@ waspBuild/.wasp/out/sdk/wasp/api/events.ts waspBuild/.wasp/out/sdk/wasp/api/index.ts waspBuild/.wasp/out/sdk/wasp/client/config.ts waspBuild/.wasp/out/sdk/wasp/client/env.ts +waspBuild/.wasp/out/sdk/wasp/client/env/schema.ts waspBuild/.wasp/out/sdk/wasp/client/index.ts waspBuild/.wasp/out/sdk/wasp/client/operations/actions/core.ts waspBuild/.wasp/out/sdk/wasp/client/operations/actions/index.ts @@ -283,6 +289,9 @@ waspBuild/.wasp/out/sdk/wasp/dist/client/config.js.map waspBuild/.wasp/out/sdk/wasp/dist/client/env.d.ts waspBuild/.wasp/out/sdk/wasp/dist/client/env.js waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map +waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts +waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js +waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js.map waspBuild/.wasp/out/sdk/wasp/dist/client/index.d.ts waspBuild/.wasp/out/sdk/wasp/dist/client/index.js waspBuild/.wasp/out/sdk/wasp/dist/client/index.js.map diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums index cb8a54f96c..620364ff6b 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/.waspchecksums @@ -25,7 +25,14 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "cff5bac505653ea7c09e0a981582fd7d894549594b00cb07b86509074df0268f" + "1b6b65c500f28977a14163878d73b53d900e0dfe44abc1ff663bc46f81dfc33e" + ], + [ + [ + "file", + "../out/sdk/wasp/client/env/schema.ts" + ], + "02448805f48d0f750f82594a702b2a83d57a127173eab8c58f8fa925cbf74ca1" ], [ [ @@ -179,7 +186,7 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "70b04edbb7f6c4a3617de54badaea6e4cb9f431fe8e6df26ab4e4690edebcbfd" + "936d4774b243ae7f1fc42866f450f35909031bc7bb8067fff7b7d5fe14815b95" ], [ [ @@ -214,7 +221,7 @@ "file", "../out/sdk/wasp/package.json" ], - "9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56" + "8c99121b7e9e68b1edca56f8c9247038bf65b0f8203ed9a6bbbcad725f81e039" ], [ [ @@ -559,6 +566,13 @@ ], "6eaf4967aa33a30abe5779f11067ceec7666c1e6060fb306ee1dc432fa7784dd" ], + [ + [ + "file", + "web-app/plugins/validateEnv.ts" + ], + "32a2187cfa251fcf5292996247d702b757d5213d9466a9f5a5fb528cd5256da7" + ], [ [ "file", @@ -669,13 +683,13 @@ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "16dc8bf734e2d166de87eed707410124eff01a54e52782808776e64806d96bc0" ], [ [ "file", "web-app/vite.config.ts" ], - "64256d93d81f6192f419e836ed4484f0e8c1e28f018bfb3213851608200594ac" + "07e935f0ee6a82371f33d91e59ffc07437837a5c055822ef065b3352ecf611b7" ] ] \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts index c716a6d227..b4b476fd15 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env.ts @@ -1,14 +1,5 @@ -import * as z from 'zod' - import { ensureEnvSchema } from '../env/index.js' - -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}) +import { clientEnvSchema } from './env/schema.js' // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env/schema.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env/schema.ts new file mode 100644 index 0000000000..19ed1e7764 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/client/env/schema.ts @@ -0,0 +1,11 @@ +import * as z from 'zod' + +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js index 2fdbb13d5e..a7a3b2e326 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js @@ -1,12 +1,5 @@ -import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}); +import { clientEnvSchema } from './env/schema.js'; // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map index 8cfab0b96e..d60054a003 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.d.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.d.ts new file mode 100644 index 0000000000..3f716d9baf --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.d.ts @@ -0,0 +1,8 @@ +import * as z from 'zod'; +export declare const clientEnvSchema: z.ZodObject<{ + REACT_APP_API_URL: z.ZodDefault; +}, "strip", z.ZodTypeAny, { + REACT_APP_API_URL: string; +}, { + REACT_APP_API_URL?: string | undefined; +}>; diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js new file mode 100644 index 0000000000..21c7f02366 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js @@ -0,0 +1,11 @@ +import * as z from 'zod'; +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}); +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js.map new file mode 100644 index 0000000000..700daa57fb --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/client/env/schema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../client/env/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,iCAAiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,CAAC;QACH,OAAO,EAAE,uCAAuC;KACjD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js index 69c147a159..23178d5364 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js @@ -1,5 +1,6 @@ import * as z from 'zod'; const redColor = '\x1b[31m'; +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema(data, schema) { try { return schema.parse(data); diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map index cfcaa99839..bb9bbd4aaa 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts index 9d81bd80bf..92402b11dd 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/env/index.ts @@ -2,6 +2,7 @@ import * as z from 'zod' const redColor = '\x1b[31m' +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema( data: unknown, schema: Schema diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json index 10a54b5d6e..aa03bb45eb 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/sdk/wasp/package.json @@ -39,6 +39,7 @@ "./client/api": "./dist/api/index.js", "./client/auth": "./dist/client/auth/index.js", "./client/crud": "./dist/client/crud/index.js", + "./client/env/schema": "./dist/client/env/schema.js", "./client/operations": "./dist/client/operations/index.js", "./client/operations/rpc": "./dist/client/operations/rpc.js", "./client/router": "./dist/client/router/index.js", @@ -51,6 +52,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/plugins/validateEnv.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/plugins/validateEnv.ts new file mode 100644 index 0000000000..6c13d96c48 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/plugins/validateEnv.ts @@ -0,0 +1,14 @@ +import { type Plugin, loadEnv } from "vite"; + +import { ensureEnvSchema } from 'wasp/env' +import { clientEnvSchema } from 'wasp/client/env/schema' + +export function validateEnv(): Plugin { + return { + name: 'wasp-validate-env', + config: (config) => { + const env = loadEnv(config.mode, process.cwd(), config.envPrefix) + ensureEnvSchema(env, clientEnvSchema) + }, + }; +} diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json index d90bb30d80..3b1dd9cea2 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/tsconfig.node.json @@ -6,5 +6,5 @@ "moduleResolution": "bundler", "allowSyntheticDefaultImports": true }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] + "include": ["vite.config.ts", "./src/ext-src/vite.config.ts", "./plugins/"] } diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/vite.config.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/vite.config.ts index ed2d3dd5f0..4cf7a4cd47 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/vite.config.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/build/web-app/vite.config.ts @@ -3,6 +3,8 @@ import { mergeConfig } from "vite"; import react from "@vitejs/plugin-react"; import { defaultExclude } from "vitest/config" +import { validateEnv } from "./plugins/validateEnv.js"; + // Ignoring the TS error because we are importing a file outside of TS root dir. // @ts-ignore import customViteConfig from '../../../vite.config' @@ -10,7 +12,10 @@ const _waspUserProvidedConfig = customViteConfig const defaultViteConfig = { base: "/", - plugins: [react()], + plugins: [ + validateEnv(), + react(), + ], optimizeDeps: { exclude: ['wasp'] }, diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts index c716a6d227..b4b476fd15 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env.ts @@ -1,14 +1,5 @@ -import * as z from 'zod' - import { ensureEnvSchema } from '../env/index.js' - -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}) +import { clientEnvSchema } from './env/schema.js' // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env/schema.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env/schema.ts new file mode 100644 index 0000000000..19ed1e7764 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/client/env/schema.ts @@ -0,0 +1,11 @@ +import * as z from 'zod' + +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}) diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js index 2fdbb13d5e..a7a3b2e326 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,12 +1,5 @@ -import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}); +import { clientEnvSchema } from './env/schema.js'; // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map index 8cfab0b96e..d60054a003 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts new file mode 100644 index 0000000000..3f716d9baf --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts @@ -0,0 +1,8 @@ +import * as z from 'zod'; +export declare const clientEnvSchema: z.ZodObject<{ + REACT_APP_API_URL: z.ZodDefault; +}, "strip", z.ZodTypeAny, { + REACT_APP_API_URL: string; +}, { + REACT_APP_API_URL?: string | undefined; +}>; diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js new file mode 100644 index 0000000000..21c7f02366 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js @@ -0,0 +1,11 @@ +import * as z from 'zod'; +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}); +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js.map new file mode 100644 index 0000000000..700daa57fb --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/client/env/schema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../client/env/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,iCAAiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,CAAC;QACH,OAAO,EAAE,uCAAuC;KACjD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js index 69c147a159..23178d5364 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,5 +1,6 @@ import * as z from 'zod'; const redColor = '\x1b[31m'; +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema(data, schema) { try { return schema.parse(data); diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map index cfcaa99839..bb9bbd4aaa 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts index 9d81bd80bf..92402b11dd 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/env/index.ts @@ -2,6 +2,7 @@ import * as z from 'zod' const redColor = '\x1b[31m' +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema( data: unknown, schema: Schema diff --git a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json index 10a54b5d6e..aa03bb45eb 100644 --- a/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspBuild-golden/waspBuild/.wasp/out/sdk/wasp/package.json @@ -39,6 +39,7 @@ "./client/api": "./dist/api/index.js", "./client/auth": "./dist/client/auth/index.js", "./client/crud": "./dist/client/crud/index.js", + "./client/env/schema": "./dist/client/env/schema.js", "./client/operations": "./dist/client/operations/index.js", "./client/operations/rpc": "./dist/client/operations/rpc.js", "./client/router": "./dist/client/router/index.js", @@ -51,6 +52,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest b/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest index d019538d60..9d1831e3b5 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/files.manifest @@ -7,6 +7,7 @@ waspCompile/.wasp/out/sdk/wasp/api/events.ts waspCompile/.wasp/out/sdk/wasp/api/index.ts waspCompile/.wasp/out/sdk/wasp/client/config.ts waspCompile/.wasp/out/sdk/wasp/client/env.ts +waspCompile/.wasp/out/sdk/wasp/client/env/schema.ts waspCompile/.wasp/out/sdk/wasp/client/index.ts waspCompile/.wasp/out/sdk/wasp/client/operations/actions/core.ts waspCompile/.wasp/out/sdk/wasp/client/operations/actions/index.ts @@ -39,6 +40,9 @@ waspCompile/.wasp/out/sdk/wasp/dist/client/config.js.map waspCompile/.wasp/out/sdk/wasp/dist/client/env.d.ts waspCompile/.wasp/out/sdk/wasp/dist/client/env.js waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map +waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts +waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js +waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js.map waspCompile/.wasp/out/sdk/wasp/dist/client/index.d.ts waspCompile/.wasp/out/sdk/wasp/dist/client/index.js waspCompile/.wasp/out/sdk/wasp/dist/client/index.js.map @@ -227,6 +231,7 @@ waspCompile/.wasp/out/web-app/README.md waspCompile/.wasp/out/web-app/index.html waspCompile/.wasp/out/web-app/netlify.toml waspCompile/.wasp/out/web-app/package.json +waspCompile/.wasp/out/web-app/plugins/validateEnv.ts waspCompile/.wasp/out/web-app/public/.gitkeep waspCompile/.wasp/out/web-app/public/favicon.ico waspCompile/.wasp/out/web-app/public/manifest.json diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums index 7441538322..fa032cbb93 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/.waspchecksums @@ -25,7 +25,14 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "cff5bac505653ea7c09e0a981582fd7d894549594b00cb07b86509074df0268f" + "1b6b65c500f28977a14163878d73b53d900e0dfe44abc1ff663bc46f81dfc33e" + ], + [ + [ + "file", + "../out/sdk/wasp/client/env/schema.ts" + ], + "02448805f48d0f750f82594a702b2a83d57a127173eab8c58f8fa925cbf74ca1" ], [ [ @@ -179,7 +186,7 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "70b04edbb7f6c4a3617de54badaea6e4cb9f431fe8e6df26ab4e4690edebcbfd" + "936d4774b243ae7f1fc42866f450f35909031bc7bb8067fff7b7d5fe14815b95" ], [ [ @@ -214,7 +221,7 @@ "file", "../out/sdk/wasp/package.json" ], - "9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56" + "8c99121b7e9e68b1edca56f8c9247038bf65b0f8203ed9a6bbbcad725f81e039" ], [ [ @@ -573,6 +580,13 @@ ], "5ee6b826939622573e7ea7ae363d168ba86a62612098a62f282bb7d2d737cfa0" ], + [ + [ + "file", + "web-app/plugins/validateEnv.ts" + ], + "32a2187cfa251fcf5292996247d702b757d5213d9466a9f5a5fb528cd5256da7" + ], [ [ "file", @@ -683,13 +697,13 @@ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "16dc8bf734e2d166de87eed707410124eff01a54e52782808776e64806d96bc0" ], [ [ "file", "web-app/vite.config.ts" ], - "64256d93d81f6192f419e836ed4484f0e8c1e28f018bfb3213851608200594ac" + "07e935f0ee6a82371f33d91e59ffc07437837a5c055822ef065b3352ecf611b7" ] ] \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts index c716a6d227..b4b476fd15 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env.ts @@ -1,14 +1,5 @@ -import * as z from 'zod' - import { ensureEnvSchema } from '../env/index.js' - -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}) +import { clientEnvSchema } from './env/schema.js' // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env/schema.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env/schema.ts new file mode 100644 index 0000000000..19ed1e7764 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/client/env/schema.ts @@ -0,0 +1,11 @@ +import * as z from 'zod' + +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}) diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js index 2fdbb13d5e..a7a3b2e326 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,12 +1,5 @@ -import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}); +import { clientEnvSchema } from './env/schema.js'; // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map index 8cfab0b96e..d60054a003 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts new file mode 100644 index 0000000000..3f716d9baf --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts @@ -0,0 +1,8 @@ +import * as z from 'zod'; +export declare const clientEnvSchema: z.ZodObject<{ + REACT_APP_API_URL: z.ZodDefault; +}, "strip", z.ZodTypeAny, { + REACT_APP_API_URL: string; +}, { + REACT_APP_API_URL?: string | undefined; +}>; diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js new file mode 100644 index 0000000000..21c7f02366 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js @@ -0,0 +1,11 @@ +import * as z from 'zod'; +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}); +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js.map b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js.map new file mode 100644 index 0000000000..700daa57fb --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/client/env/schema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../client/env/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,iCAAiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,CAAC;QACH,OAAO,EAAE,uCAAuC;KACjD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js index 69c147a159..23178d5364 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,5 +1,6 @@ import * as z from 'zod'; const redColor = '\x1b[31m'; +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema(data, schema) { try { return schema.parse(data); diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map index cfcaa99839..bb9bbd4aaa 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts index 9d81bd80bf..92402b11dd 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/env/index.ts @@ -2,6 +2,7 @@ import * as z from 'zod' const redColor = '\x1b[31m' +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema( data: unknown, schema: Schema diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json index 10a54b5d6e..aa03bb45eb 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/sdk/wasp/package.json @@ -39,6 +39,7 @@ "./client/api": "./dist/api/index.js", "./client/auth": "./dist/client/auth/index.js", "./client/crud": "./dist/client/crud/index.js", + "./client/env/schema": "./dist/client/env/schema.js", "./client/operations": "./dist/client/operations/index.js", "./client/operations/rpc": "./dist/client/operations/rpc.js", "./client/router": "./dist/client/router/index.js", @@ -51,6 +52,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/plugins/validateEnv.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/plugins/validateEnv.ts new file mode 100644 index 0000000000..6c13d96c48 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/plugins/validateEnv.ts @@ -0,0 +1,14 @@ +import { type Plugin, loadEnv } from "vite"; + +import { ensureEnvSchema } from 'wasp/env' +import { clientEnvSchema } from 'wasp/client/env/schema' + +export function validateEnv(): Plugin { + return { + name: 'wasp-validate-env', + config: (config) => { + const env = loadEnv(config.mode, process.cwd(), config.envPrefix) + ensureEnvSchema(env, clientEnvSchema) + }, + }; +} diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..3b1dd9cea2 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/tsconfig.node.json @@ -6,5 +6,5 @@ "moduleResolution": "bundler", "allowSyntheticDefaultImports": true }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] + "include": ["vite.config.ts", "./src/ext-src/vite.config.ts", "./plugins/"] } diff --git a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/vite.config.ts b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/vite.config.ts index ed2d3dd5f0..4cf7a4cd47 100644 --- a/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/vite.config.ts +++ b/waspc/e2e-test/test-outputs/waspCompile-golden/waspCompile/.wasp/out/web-app/vite.config.ts @@ -3,6 +3,8 @@ import { mergeConfig } from "vite"; import react from "@vitejs/plugin-react"; import { defaultExclude } from "vitest/config" +import { validateEnv } from "./plugins/validateEnv.js"; + // Ignoring the TS error because we are importing a file outside of TS root dir. // @ts-ignore import customViteConfig from '../../../vite.config' @@ -10,7 +12,10 @@ const _waspUserProvidedConfig = customViteConfig const defaultViteConfig = { base: "/", - plugins: [react()], + plugins: [ + validateEnv(), + react(), + ], optimizeDeps: { exclude: ['wasp'] }, diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest b/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest index 1eb72927bb..fde25bd8e1 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/files.manifest @@ -38,6 +38,7 @@ waspComplexTest/.wasp/out/sdk/wasp/client/crud/index.ts waspComplexTest/.wasp/out/sdk/wasp/client/crud/operationsHelpers.ts waspComplexTest/.wasp/out/sdk/wasp/client/crud/tasks.ts waspComplexTest/.wasp/out/sdk/wasp/client/env.ts +waspComplexTest/.wasp/out/sdk/wasp/client/env/schema.ts waspComplexTest/.wasp/out/sdk/wasp/client/index.ts waspComplexTest/.wasp/out/sdk/wasp/client/operations/actions/core.ts waspComplexTest/.wasp/out/sdk/wasp/client/operations/actions/index.ts @@ -159,6 +160,9 @@ waspComplexTest/.wasp/out/sdk/wasp/dist/client/crud/tasks.js.map waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.d.ts waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map +waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts +waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js +waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js.map waspComplexTest/.wasp/out/sdk/wasp/dist/client/index.d.ts waspComplexTest/.wasp/out/sdk/wasp/dist/client/index.js waspComplexTest/.wasp/out/sdk/wasp/dist/client/index.js.map @@ -513,6 +517,7 @@ waspComplexTest/.wasp/out/web-app/README.md waspComplexTest/.wasp/out/web-app/index.html waspComplexTest/.wasp/out/web-app/netlify.toml waspComplexTest/.wasp/out/web-app/package.json +waspComplexTest/.wasp/out/web-app/plugins/validateEnv.ts waspComplexTest/.wasp/out/web-app/public/.gitkeep waspComplexTest/.wasp/out/web-app/public/favicon.ico waspComplexTest/.wasp/out/web-app/public/manifest.json diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums index 0fffdc979e..317e5dbda4 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/.waspchecksums @@ -228,7 +228,14 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "cff5bac505653ea7c09e0a981582fd7d894549594b00cb07b86509074df0268f" + "1b6b65c500f28977a14163878d73b53d900e0dfe44abc1ff663bc46f81dfc33e" + ], + [ + [ + "file", + "../out/sdk/wasp/client/env/schema.ts" + ], + "02448805f48d0f750f82594a702b2a83d57a127173eab8c58f8fa925cbf74ca1" ], [ [ @@ -396,7 +403,7 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "70b04edbb7f6c4a3617de54badaea6e4cb9f431fe8e6df26ab4e4690edebcbfd" + "936d4774b243ae7f1fc42866f450f35909031bc7bb8067fff7b7d5fe14815b95" ], [ [ @@ -501,7 +508,7 @@ "file", "../out/sdk/wasp/package.json" ], - "e9daaa0fd911e4211651d99935e3191bbc17f33d1c5f8e5e9960fef5a2b0497f" + "f3762fd39c7211dcf2eb6267a8a2a4047647b161baf99b2b07a6d966c4bb5d16" ], [ [ @@ -1196,6 +1203,13 @@ ], "e5e90969045aa6566c4e98f6571653c8056c5dedc923a934feacb3a7698d4f09" ], + [ + [ + "file", + "web-app/plugins/validateEnv.ts" + ], + "32a2187cfa251fcf5292996247d702b757d5213d9466a9f5a5fb528cd5256da7" + ], [ [ "file", @@ -1320,13 +1334,13 @@ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "16dc8bf734e2d166de87eed707410124eff01a54e52782808776e64806d96bc0" ], [ [ "file", "web-app/vite.config.ts" ], - "64256d93d81f6192f419e836ed4484f0e8c1e28f018bfb3213851608200594ac" + "07e935f0ee6a82371f33d91e59ffc07437837a5c055822ef065b3352ecf611b7" ] ] \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts index c716a6d227..b4b476fd15 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env.ts @@ -1,14 +1,5 @@ -import * as z from 'zod' - import { ensureEnvSchema } from '../env/index.js' - -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}) +import { clientEnvSchema } from './env/schema.js' // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env/schema.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env/schema.ts new file mode 100644 index 0000000000..19ed1e7764 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/client/env/schema.ts @@ -0,0 +1,11 @@ +import * as z from 'zod' + +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}) diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js index 2fdbb13d5e..a7a3b2e326 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,12 +1,5 @@ -import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}); +import { clientEnvSchema } from './env/schema.js'; // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map index 8cfab0b96e..d60054a003 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts new file mode 100644 index 0000000000..3f716d9baf --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts @@ -0,0 +1,8 @@ +import * as z from 'zod'; +export declare const clientEnvSchema: z.ZodObject<{ + REACT_APP_API_URL: z.ZodDefault; +}, "strip", z.ZodTypeAny, { + REACT_APP_API_URL: string; +}, { + REACT_APP_API_URL?: string | undefined; +}>; diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js new file mode 100644 index 0000000000..21c7f02366 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js @@ -0,0 +1,11 @@ +import * as z from 'zod'; +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}); +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js.map new file mode 100644 index 0000000000..700daa57fb --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/client/env/schema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../client/env/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,iCAAiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,CAAC;QACH,OAAO,EAAE,uCAAuC;KACjD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js index 69c147a159..23178d5364 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,5 +1,6 @@ import * as z from 'zod'; const redColor = '\x1b[31m'; +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema(data, schema) { try { return schema.parse(data); diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map index cfcaa99839..bb9bbd4aaa 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts index 9d81bd80bf..92402b11dd 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/env/index.ts @@ -2,6 +2,7 @@ import * as z from 'zod' const redColor = '\x1b[31m' +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema( data: unknown, schema: Schema diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json index 22e2c2d0e6..56d513771b 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/sdk/wasp/package.json @@ -47,6 +47,7 @@ "./client/api": "./dist/api/index.js", "./client/auth": "./dist/client/auth/index.js", "./client/crud": "./dist/client/crud/index.js", + "./client/env/schema": "./dist/client/env/schema.js", "./client/operations": "./dist/client/operations/index.js", "./client/operations/rpc": "./dist/client/operations/rpc.js", "./client/router": "./dist/client/router/index.js", @@ -59,6 +60,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/plugins/validateEnv.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/plugins/validateEnv.ts new file mode 100644 index 0000000000..6c13d96c48 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/plugins/validateEnv.ts @@ -0,0 +1,14 @@ +import { type Plugin, loadEnv } from "vite"; + +import { ensureEnvSchema } from 'wasp/env' +import { clientEnvSchema } from 'wasp/client/env/schema' + +export function validateEnv(): Plugin { + return { + name: 'wasp-validate-env', + config: (config) => { + const env = loadEnv(config.mode, process.cwd(), config.envPrefix) + ensureEnvSchema(env, clientEnvSchema) + }, + }; +} diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..3b1dd9cea2 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/tsconfig.node.json @@ -6,5 +6,5 @@ "moduleResolution": "bundler", "allowSyntheticDefaultImports": true }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] + "include": ["vite.config.ts", "./src/ext-src/vite.config.ts", "./plugins/"] } diff --git a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/vite.config.ts b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/vite.config.ts index ed2d3dd5f0..4cf7a4cd47 100644 --- a/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/vite.config.ts +++ b/waspc/e2e-test/test-outputs/waspComplexTest-golden/waspComplexTest/.wasp/out/web-app/vite.config.ts @@ -3,6 +3,8 @@ import { mergeConfig } from "vite"; import react from "@vitejs/plugin-react"; import { defaultExclude } from "vitest/config" +import { validateEnv } from "./plugins/validateEnv.js"; + // Ignoring the TS error because we are importing a file outside of TS root dir. // @ts-ignore import customViteConfig from '../../../vite.config' @@ -10,7 +12,10 @@ const _waspUserProvidedConfig = customViteConfig const defaultViteConfig = { base: "/", - plugins: [react()], + plugins: [ + validateEnv(), + react(), + ], optimizeDeps: { exclude: ['wasp'] }, diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest b/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest index 195ef2d3c4..bdd8988e8b 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspJob-golden/files.manifest @@ -8,6 +8,7 @@ waspJob/.wasp/out/sdk/wasp/api/events.ts waspJob/.wasp/out/sdk/wasp/api/index.ts waspJob/.wasp/out/sdk/wasp/client/config.ts waspJob/.wasp/out/sdk/wasp/client/env.ts +waspJob/.wasp/out/sdk/wasp/client/env/schema.ts waspJob/.wasp/out/sdk/wasp/client/index.ts waspJob/.wasp/out/sdk/wasp/client/operations/actions/core.ts waspJob/.wasp/out/sdk/wasp/client/operations/actions/index.ts @@ -40,6 +41,9 @@ waspJob/.wasp/out/sdk/wasp/dist/client/config.js.map waspJob/.wasp/out/sdk/wasp/dist/client/env.d.ts waspJob/.wasp/out/sdk/wasp/dist/client/env.js waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map +waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts +waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js +waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js.map waspJob/.wasp/out/sdk/wasp/dist/client/index.d.ts waspJob/.wasp/out/sdk/wasp/dist/client/index.js waspJob/.wasp/out/sdk/wasp/dist/client/index.js.map @@ -272,6 +276,7 @@ waspJob/.wasp/out/web-app/README.md waspJob/.wasp/out/web-app/index.html waspJob/.wasp/out/web-app/netlify.toml waspJob/.wasp/out/web-app/package.json +waspJob/.wasp/out/web-app/plugins/validateEnv.ts waspJob/.wasp/out/web-app/public/.gitkeep waspJob/.wasp/out/web-app/public/favicon.ico waspJob/.wasp/out/web-app/public/manifest.json diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums index 0729ccc5d1..3b0dbe507a 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/.waspchecksums @@ -25,7 +25,14 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "cff5bac505653ea7c09e0a981582fd7d894549594b00cb07b86509074df0268f" + "1b6b65c500f28977a14163878d73b53d900e0dfe44abc1ff663bc46f81dfc33e" + ], + [ + [ + "file", + "../out/sdk/wasp/client/env/schema.ts" + ], + "02448805f48d0f750f82594a702b2a83d57a127173eab8c58f8fa925cbf74ca1" ], [ [ @@ -179,7 +186,7 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "70b04edbb7f6c4a3617de54badaea6e4cb9f431fe8e6df26ab4e4690edebcbfd" + "936d4774b243ae7f1fc42866f450f35909031bc7bb8067fff7b7d5fe14815b95" ], [ [ @@ -221,7 +228,7 @@ "file", "../out/sdk/wasp/package.json" ], - "f045068da4d6b321ff13c7fe91eb01a10f98e7bf477edee21ab1621e95166bf7" + "fb03703124b389a1a3f8b09063a51309774e703ee69de82a61541141e809e2de" ], [ [ @@ -671,6 +678,13 @@ ], "d4cca5f4ac642f394ba89e9abfa195614be65d9ab7f36b5abc11590c178f8cdd" ], + [ + [ + "file", + "web-app/plugins/validateEnv.ts" + ], + "32a2187cfa251fcf5292996247d702b757d5213d9466a9f5a5fb528cd5256da7" + ], [ [ "file", @@ -781,13 +795,13 @@ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "16dc8bf734e2d166de87eed707410124eff01a54e52782808776e64806d96bc0" ], [ [ "file", "web-app/vite.config.ts" ], - "64256d93d81f6192f419e836ed4484f0e8c1e28f018bfb3213851608200594ac" + "07e935f0ee6a82371f33d91e59ffc07437837a5c055822ef065b3352ecf611b7" ] ] \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts index c716a6d227..b4b476fd15 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env.ts @@ -1,14 +1,5 @@ -import * as z from 'zod' - import { ensureEnvSchema } from '../env/index.js' - -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}) +import { clientEnvSchema } from './env/schema.js' // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env/schema.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env/schema.ts new file mode 100644 index 0000000000..19ed1e7764 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/client/env/schema.ts @@ -0,0 +1,11 @@ +import * as z from 'zod' + +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}) diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js index 2fdbb13d5e..a7a3b2e326 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,12 +1,5 @@ -import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}); +import { clientEnvSchema } from './env/schema.js'; // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map index 8cfab0b96e..d60054a003 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts new file mode 100644 index 0000000000..3f716d9baf --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts @@ -0,0 +1,8 @@ +import * as z from 'zod'; +export declare const clientEnvSchema: z.ZodObject<{ + REACT_APP_API_URL: z.ZodDefault; +}, "strip", z.ZodTypeAny, { + REACT_APP_API_URL: string; +}, { + REACT_APP_API_URL?: string | undefined; +}>; diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js new file mode 100644 index 0000000000..21c7f02366 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js @@ -0,0 +1,11 @@ +import * as z from 'zod'; +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}); +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js.map new file mode 100644 index 0000000000..700daa57fb --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/client/env/schema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../client/env/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,iCAAiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,CAAC;QACH,OAAO,EAAE,uCAAuC;KACjD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js index 69c147a159..23178d5364 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,5 +1,6 @@ import * as z from 'zod'; const redColor = '\x1b[31m'; +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema(data, schema) { try { return schema.parse(data); diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map index cfcaa99839..bb9bbd4aaa 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts index 9d81bd80bf..92402b11dd 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/env/index.ts @@ -2,6 +2,7 @@ import * as z from 'zod' const redColor = '\x1b[31m' +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema( data: unknown, schema: Schema diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json index 096de35ddb..cacc245459 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/sdk/wasp/package.json @@ -40,6 +40,7 @@ "./client/api": "./dist/api/index.js", "./client/auth": "./dist/client/auth/index.js", "./client/crud": "./dist/client/crud/index.js", + "./client/env/schema": "./dist/client/env/schema.js", "./client/operations": "./dist/client/operations/index.js", "./client/operations/rpc": "./dist/client/operations/rpc.js", "./client/router": "./dist/client/router/index.js", @@ -52,6 +53,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/plugins/validateEnv.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/plugins/validateEnv.ts new file mode 100644 index 0000000000..6c13d96c48 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/plugins/validateEnv.ts @@ -0,0 +1,14 @@ +import { type Plugin, loadEnv } from "vite"; + +import { ensureEnvSchema } from 'wasp/env' +import { clientEnvSchema } from 'wasp/client/env/schema' + +export function validateEnv(): Plugin { + return { + name: 'wasp-validate-env', + config: (config) => { + const env = loadEnv(config.mode, process.cwd(), config.envPrefix) + ensureEnvSchema(env, clientEnvSchema) + }, + }; +} diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..3b1dd9cea2 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/tsconfig.node.json @@ -6,5 +6,5 @@ "moduleResolution": "bundler", "allowSyntheticDefaultImports": true }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] + "include": ["vite.config.ts", "./src/ext-src/vite.config.ts", "./plugins/"] } diff --git a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/vite.config.ts b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/vite.config.ts index ed2d3dd5f0..4cf7a4cd47 100644 --- a/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/vite.config.ts +++ b/waspc/e2e-test/test-outputs/waspJob-golden/waspJob/.wasp/out/web-app/vite.config.ts @@ -3,6 +3,8 @@ import { mergeConfig } from "vite"; import react from "@vitejs/plugin-react"; import { defaultExclude } from "vitest/config" +import { validateEnv } from "./plugins/validateEnv.js"; + // Ignoring the TS error because we are importing a file outside of TS root dir. // @ts-ignore import customViteConfig from '../../../vite.config' @@ -10,7 +12,10 @@ const _waspUserProvidedConfig = customViteConfig const defaultViteConfig = { base: "/", - plugins: [react()], + plugins: [ + validateEnv(), + react(), + ], optimizeDeps: { exclude: ['wasp'] }, diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest b/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest index 3558fafbf7..c25c8ed603 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/files.manifest @@ -11,6 +11,7 @@ waspMigrate/.wasp/out/sdk/wasp/api/events.ts waspMigrate/.wasp/out/sdk/wasp/api/index.ts waspMigrate/.wasp/out/sdk/wasp/client/config.ts waspMigrate/.wasp/out/sdk/wasp/client/env.ts +waspMigrate/.wasp/out/sdk/wasp/client/env/schema.ts waspMigrate/.wasp/out/sdk/wasp/client/index.ts waspMigrate/.wasp/out/sdk/wasp/client/operations/actions/core.ts waspMigrate/.wasp/out/sdk/wasp/client/operations/actions/index.ts @@ -43,6 +44,9 @@ waspMigrate/.wasp/out/sdk/wasp/dist/client/config.js.map waspMigrate/.wasp/out/sdk/wasp/dist/client/env.d.ts waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map +waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts +waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js +waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js.map waspMigrate/.wasp/out/sdk/wasp/dist/client/index.d.ts waspMigrate/.wasp/out/sdk/wasp/dist/client/index.js waspMigrate/.wasp/out/sdk/wasp/dist/client/index.js.map @@ -231,6 +235,7 @@ waspMigrate/.wasp/out/web-app/README.md waspMigrate/.wasp/out/web-app/index.html waspMigrate/.wasp/out/web-app/netlify.toml waspMigrate/.wasp/out/web-app/package.json +waspMigrate/.wasp/out/web-app/plugins/validateEnv.ts waspMigrate/.wasp/out/web-app/public/.gitkeep waspMigrate/.wasp/out/web-app/public/favicon.ico waspMigrate/.wasp/out/web-app/public/manifest.json diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums index 62cee85013..db13b63d53 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/.waspchecksums @@ -25,7 +25,14 @@ "file", "../out/sdk/wasp/client/env.ts" ], - "cff5bac505653ea7c09e0a981582fd7d894549594b00cb07b86509074df0268f" + "1b6b65c500f28977a14163878d73b53d900e0dfe44abc1ff663bc46f81dfc33e" + ], + [ + [ + "file", + "../out/sdk/wasp/client/env/schema.ts" + ], + "02448805f48d0f750f82594a702b2a83d57a127173eab8c58f8fa925cbf74ca1" ], [ [ @@ -179,7 +186,7 @@ "file", "../out/sdk/wasp/env/index.ts" ], - "70b04edbb7f6c4a3617de54badaea6e4cb9f431fe8e6df26ab4e4690edebcbfd" + "936d4774b243ae7f1fc42866f450f35909031bc7bb8067fff7b7d5fe14815b95" ], [ [ @@ -214,7 +221,7 @@ "file", "../out/sdk/wasp/package.json" ], - "9f8844eca690b66c914179693b7f7beedef8b7c8fe2016d9d7353d474cea3d56" + "8c99121b7e9e68b1edca56f8c9247038bf65b0f8203ed9a6bbbcad725f81e039" ], [ [ @@ -573,6 +580,13 @@ ], "3ed48d6333377934dc8dc7e98afcb81ab93f866daaebc0de5d608cfbd7b97e1a" ], + [ + [ + "file", + "web-app/plugins/validateEnv.ts" + ], + "32a2187cfa251fcf5292996247d702b757d5213d9466a9f5a5fb528cd5256da7" + ], [ [ "file", @@ -683,13 +697,13 @@ "file", "web-app/tsconfig.node.json" ], - "30fed1f6aa4710deb690d1ae47628066f34afda7b633f0c696fafcda9e2dbc1e" + "16dc8bf734e2d166de87eed707410124eff01a54e52782808776e64806d96bc0" ], [ [ "file", "web-app/vite.config.ts" ], - "64256d93d81f6192f419e836ed4484f0e8c1e28f018bfb3213851608200594ac" + "07e935f0ee6a82371f33d91e59ffc07437837a5c055822ef065b3352ecf611b7" ] ] \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts index c716a6d227..b4b476fd15 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env.ts @@ -1,14 +1,5 @@ -import * as z from 'zod' - import { ensureEnvSchema } from '../env/index.js' - -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}) +import { clientEnvSchema } from './env/schema.js' // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema) diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env/schema.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env/schema.ts new file mode 100644 index 0000000000..19ed1e7764 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/client/env/schema.ts @@ -0,0 +1,11 @@ +import * as z from 'zod' + +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}) diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js index 2fdbb13d5e..a7a3b2e326 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js @@ -1,12 +1,5 @@ -import * as z from 'zod'; import { ensureEnvSchema } from '../env/index.js'; -const clientEnvSchema = z.object({ - REACT_APP_API_URL: z - .string({ - required_error: 'REACT_APP_API_URL is required', - }) - .default('http://localhost:3001') -}); +import { clientEnvSchema } from './env/schema.js'; // PUBLIC API export const env = ensureEnvSchema(import.meta.env, clientEnvSchema); //# sourceMappingURL=env.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map index 8cfab0b96e..d60054a003 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env.js.map @@ -1 +1 @@ -{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,iBAAiB,EAAE,CAAC;SACjB,MAAM,CAAC;QACN,cAAc,EAAE,+BAA+B;KAChD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA;AAEF,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"env.js","sourceRoot":"","sources":["../../client/env.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEjD,aAAa;AACb,MAAM,CAAC,MAAM,GAAG,GAAG,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts new file mode 100644 index 0000000000..3f716d9baf --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.d.ts @@ -0,0 +1,8 @@ +import * as z from 'zod'; +export declare const clientEnvSchema: z.ZodObject<{ + REACT_APP_API_URL: z.ZodDefault; +}, "strip", z.ZodTypeAny, { + REACT_APP_API_URL: string; +}, { + REACT_APP_API_URL?: string | undefined; +}>; diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js new file mode 100644 index 0000000000..21c7f02366 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js @@ -0,0 +1,11 @@ +import * as z from 'zod'; +// PRIVATE API (sdk, Vite config) +export const clientEnvSchema = z.object({ + REACT_APP_API_URL: z + .string() + .url({ + message: 'REACT_APP_API_URL must be a valid URL', + }) + .default('http://localhost:3001'), +}); +//# sourceMappingURL=schema.js.map \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js.map b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js.map new file mode 100644 index 0000000000..700daa57fb --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/client/env/schema.js.map @@ -0,0 +1 @@ +{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../client/env/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,iCAAiC;AACjC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,iBAAiB,EAAE,CAAC;SACjB,MAAM,EAAE;SACR,GAAG,CAAC;QACH,OAAO,EAAE,uCAAuC;KACjD,CAAC;SACD,OAAO,CAAC,uBAAuB,CAAC;CACpC,CAAC,CAAA"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js index 69c147a159..23178d5364 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js @@ -1,5 +1,6 @@ import * as z from 'zod'; const redColor = '\x1b[31m'; +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema(data, schema) { try { return schema.parse(data); diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map index cfcaa99839..bb9bbd4aaa 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/dist/env/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file +{"version":3,"file":"index.js","sourceRoot":"","sources":["../../env/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAA;AAE3B,iCAAiC;AACjC,MAAM,UAAU,eAAe,CAC7B,IAAa,EACb,MAAc;IAEd,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,EAAE,CAAC;YAC5B,MAAM,WAAW,GAAG;gBAClB,EAAE;gBACF,iCAAiC;gBACjC,iCAAiC;gBACjC,iCAAiC;gBACjC,EAAE;aACH,CAAA;YACD,KAAK,MAAM,KAAK,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC;gBAC5B,WAAW,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;YACzC,CAAC;YACD,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;YACpB,WAAW,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YACnD,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAA;YAC/C,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,CAAA;QACT,CAAC;IACH,CAAC;AACH,CAAC"} \ No newline at end of file diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts index 9d81bd80bf..92402b11dd 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/env/index.ts @@ -2,6 +2,7 @@ import * as z from 'zod' const redColor = '\x1b[31m' +// PRIVATE API (SDK, Vite config) export function ensureEnvSchema( data: unknown, schema: Schema diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json index 10a54b5d6e..aa03bb45eb 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/sdk/wasp/package.json @@ -39,6 +39,7 @@ "./client/api": "./dist/api/index.js", "./client/auth": "./dist/client/auth/index.js", "./client/crud": "./dist/client/crud/index.js", + "./client/env/schema": "./dist/client/env/schema.js", "./client/operations": "./dist/client/operations/index.js", "./client/operations/rpc": "./dist/client/operations/rpc.js", "./client/router": "./dist/client/router/index.js", @@ -51,6 +52,7 @@ "./core/storage": "./dist/core/storage.js", "./dev": "./dist/dev/index.js", "./entities": "./dist/entities/index.js", + "./env": "./dist/env/index.js", "./ext-src/*": "./dist/ext-src/*.js", "./operations": "./dist/operations/index.js", "./operations/*": "./dist/operations/*", diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/plugins/validateEnv.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/plugins/validateEnv.ts new file mode 100644 index 0000000000..6c13d96c48 --- /dev/null +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/plugins/validateEnv.ts @@ -0,0 +1,14 @@ +import { type Plugin, loadEnv } from "vite"; + +import { ensureEnvSchema } from 'wasp/env' +import { clientEnvSchema } from 'wasp/client/env/schema' + +export function validateEnv(): Plugin { + return { + name: 'wasp-validate-env', + config: (config) => { + const env = loadEnv(config.mode, process.cwd(), config.envPrefix) + ensureEnvSchema(env, clientEnvSchema) + }, + }; +} diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json index d90bb30d80..3b1dd9cea2 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/tsconfig.node.json @@ -6,5 +6,5 @@ "moduleResolution": "bundler", "allowSyntheticDefaultImports": true }, - "include": ["vite.config.ts", "./src/ext-src/vite.config.ts"] + "include": ["vite.config.ts", "./src/ext-src/vite.config.ts", "./plugins/"] } diff --git a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/vite.config.ts b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/vite.config.ts index ed2d3dd5f0..4cf7a4cd47 100644 --- a/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/vite.config.ts +++ b/waspc/e2e-test/test-outputs/waspMigrate-golden/waspMigrate/.wasp/out/web-app/vite.config.ts @@ -3,6 +3,8 @@ import { mergeConfig } from "vite"; import react from "@vitejs/plugin-react"; import { defaultExclude } from "vitest/config" +import { validateEnv } from "./plugins/validateEnv.js"; + // Ignoring the TS error because we are importing a file outside of TS root dir. // @ts-ignore import customViteConfig from '../../../vite.config' @@ -10,7 +12,10 @@ const _waspUserProvidedConfig = customViteConfig const defaultViteConfig = { base: "/", - plugins: [react()], + plugins: [ + validateEnv(), + react(), + ], optimizeDeps: { exclude: ['wasp'] },