Skip to content

Commit 04daa01

Browse files
more feedback
1 parent 3276a27 commit 04daa01

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dev:prisma:migrate:dev": "yarn with-env yarn workspace @sourcebot/db prisma:migrate:dev",
1717
"dev:prisma:studio": "yarn with-env yarn workspace @sourcebot/db prisma:studio",
1818
"dev:prisma:migrate:reset": "yarn with-env yarn workspace @sourcebot/db prisma:migrate:reset",
19-
"build:deps": "yarn workspaces foreach -R --from '{@sourcebot/schemas,@sourcebot/error,@sourcebot/crypto,@sourcebot/db}' run build"
19+
"build:deps": "yarn workspaces foreach -R --from '{@sourcebot/schemas,@sourcebot/error,@sourcebot/crypto,@sourcebot/db,@sourcebot/shared}' run build"
2020
},
2121
"devDependencies": {
2222
"cross-env": "^7.0.3",

packages/shared/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
This package contains shared code between the backend & webapp packages.
2+
3+
### Why two index files?
4+
5+
This package contains two index files: `index.server.ts` and `index.client.ts`. There is some code in this package that will only work in a Node.JS runtime (e.g., because it depends on the `fs` pacakge. Entitlements are a good example of this), and other code that is runtime agnostic (e.g., `constants.ts`). To deal with this, we these two index files export server code and client code, respectively.
6+
7+
For package consumers, the usage would look like the following:
8+
- Server: `import { ... } from @sourcebot/shared`
9+
- Client: `import { ... } from @sourcebot/shared/client`

packages/shared/src/env.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,21 @@ export const env = createEnv({
66
server: {
77
SOURCEBOT_EE_LICENSE_KEY: z.string().optional(),
88
SOURCEBOT_PUBLIC_KEY_PATH: z.string(),
9+
},
10+
// @NOTE: Please make sure of the following:
11+
// - Make sure you destructure all client variables in
12+
// the `runtimeEnv` block below.
13+
// - Update the Dockerfile to pass these variables as build-args.
14+
client: {
915
NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT: z.enum(SOURCEBOT_CLOUD_ENVIRONMENT).optional(),
1016
},
11-
runtimeEnv: process.env,
17+
clientPrefix: "NEXT_PUBLIC_",
18+
runtimeEnv: {
19+
...process.env,
20+
21+
// For Next.js >= 13.4.4, you need to manually destructure client variables:
22+
NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT: process.env.NEXT_PUBLIC_SOURCEBOT_CLOUD_ENVIRONMENT,
23+
},
1224
emptyStringAsUndefined: true,
1325
skipValidation: process.env.SKIP_ENV_VALIDATION === "1",
1426
});

0 commit comments

Comments
 (0)