@alumbwe/anvil 1.0.41 → 1.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/entry.ts +5 -0
- package/src/pre-init/client-env.ts +17 -0
- package/src/utils/client-env-defaults.ts +28 -0
package/package.json
CHANGED
package/src/entry.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
|
|
3
|
+
// MUST be first: applies production defaults for NEXT_PUBLIC_* before any
|
|
4
|
+
// module in the import graph evaluates `@anvil/common/env`, which validates
|
|
5
|
+
// the client env at import time and throws on machines without an env file.
|
|
6
|
+
import './pre-init/client-env'
|
|
7
|
+
|
|
3
8
|
import {
|
|
4
9
|
isTerminalCommandBrokerInvocation,
|
|
5
10
|
serveTerminalCommandBroker,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Apply production defaults for NEXT_PUBLIC_* vars BEFORE anything that
|
|
2
|
+
// imports `@anvil/common/env`, which validates the client env at import time
|
|
3
|
+
// and throws on a machine without an env file (any global npm install).
|
|
4
|
+
//
|
|
5
|
+
// Must be imported before `./index` in `entry.ts`, mirroring the tree-sitter
|
|
6
|
+
// pre-init: both prepare runtime state the eagerly-evaluated import graph
|
|
7
|
+
// needs at module-evaluation time.
|
|
8
|
+
//
|
|
9
|
+
// Gap-filling only: real values already in process.env (from ~/.env.local,
|
|
10
|
+
// the shell, or --define flags baked into compiled binaries) always win.
|
|
11
|
+
import { CLIENT_ENV_DEFAULTS } from '../utils/client-env-defaults'
|
|
12
|
+
|
|
13
|
+
for (const [key, value] of Object.entries(CLIENT_ENV_DEFAULTS)) {
|
|
14
|
+
if (process.env[key] === undefined) {
|
|
15
|
+
process.env[key] = value
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production defaults for the NEXT_PUBLIC_* client env vars.
|
|
3
|
+
*
|
|
4
|
+
* `@anvil/common/env` validates all NEXT_PUBLIC_* vars at *import time*, so a
|
|
5
|
+
* global npm install (no .env.local anywhere on the machine) dies before any
|
|
6
|
+
* of our code runs. These defaults — all public-by-design values, the same
|
|
7
|
+
* set `cli/scripts/build-binary.ts` bakes into compiled binaries — are applied
|
|
8
|
+
* to `process.env` at pre-init so the CLI boots on any machine, cmd or
|
|
9
|
+
* PowerShell, with or without an env file.
|
|
10
|
+
*
|
|
11
|
+
* IMPORTANT: the pre-init loader (`cli/src/pre-init/client-env.ts`) imports
|
|
12
|
+
* this table, and `build-binary.ts` reads it at build time. Keep the two in
|
|
13
|
+
* sync through this module — never duplicate the values.
|
|
14
|
+
*
|
|
15
|
+
* User-set values always win: the loader only fills gaps, it never overwrites
|
|
16
|
+
* anything already in process.env (including values Bun loads from
|
|
17
|
+
* .env.local in dev, and the --define flags baked into binaries).
|
|
18
|
+
*/
|
|
19
|
+
export const CLIENT_ENV_DEFAULTS: Readonly<Record<string, string>> = {
|
|
20
|
+
NEXT_PUBLIC_CB_ENVIRONMENT: 'prod',
|
|
21
|
+
NEXT_PUBLIC_ANVIL_APP_URL: 'https://anvil.dev',
|
|
22
|
+
NEXT_PUBLIC_SUPPORT_EMAIL: 'support@anvil.dev',
|
|
23
|
+
NEXT_PUBLIC_POSTHOG_API_KEY: 'phc_placeholder',
|
|
24
|
+
NEXT_PUBLIC_POSTHOG_HOST_URL: 'https://us.i.posthog.com',
|
|
25
|
+
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY: 'pk_placeholder',
|
|
26
|
+
NEXT_PUBLIC_STRIPE_CUSTOMER_PORTAL: 'https://billing.stripe.com/portal',
|
|
27
|
+
NEXT_PUBLIC_WEB_PORT: '3000',
|
|
28
|
+
}
|