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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ When pull requests with changesets land on `main`, the release job in [`ci.yml`]

Examples are runtime-isolated demos. Each one installs the packed `@variablelab/env` tarball, as an outside consumer would, with its own lockfile and outside the pnpm workspace. To add one:

1. Create the directory under `examples/<name>/` with the source for the demo.
1. Create the directory under `examples/<name>/` with the source for the demo, and give it ports no other example uses (see [Ports](../examples/README.md#ports)).
2. Add a `package.json` that consumes `@variablelab/env` from the local tarball:
```jsonc
"@variablelab/env": "file:../../package/.local/variablelab-env.tgz"
Expand Down
19 changes: 19 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,22 @@ mise run //examples/backend-node:start
## Why isolated?

`@variablelab/env` advertises itself as runtime-agnostic. Examples that secretly resolve through a shared pnpm workspace don't actually prove that promise. With per-example `mise.toml`, lockfiles, and a packed tarball, each example is a real consumer — it works exactly as it would for someone running `pnpm add @variablelab/env` in a fresh project.

## Ports

Each example uses its own ports, so `mise run test:e2e` can run all the suites in parallel.

| Example | Ports |
| -------------------- | ------------------------------------------ |
| `backend-node` | 3001 |
| `backend-bun` | 3002 |
| `backend-deno` | 3003 |
| `backend-node-cjs` | 3011 |
| `backend-bun-cjs` | 3012 |
| `backend-deno-cjs` | 3013 |
| `worker-cloudflare` | 8787 |
| `edge-nextjs` | 3004 |
| `spa-vite-plugin` | 5173 `dev` and E2E, 4173 `preview` |
| `spa-vite-dynamic` | 5174 `dev`, 4174 `preview` (E2E uses both) |
| `ssr-react-router` | 5175 `dev`, 3005 `start` and E2E |
| `ssr-tanstack-start` | 3006 |
2 changes: 1 addition & 1 deletion examples/backend-bun-cjs/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "@playwright/test";

const PORT = 3002;
const PORT = 3012;
const BASE_URL = `http://127.0.0.1:${PORT}`;

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/backend-bun-cjs/src/config/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type { EnvConfig } from "../env/schema.ts";

export default {
log: { LEVEL: "debug" },
server: { PORT: 3002, HOST: "127.0.0.1" },
server: { PORT: 3012, HOST: "127.0.0.1" },
db: { URL: "postgres://localhost/dev", LOGGING: true },
} satisfies EnvConfig;
2 changes: 1 addition & 1 deletion examples/backend-bun-cjs/src/config/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type { EnvConfig } from "../env/schema.ts";

export default {
log: { LEVEL: "info" },
server: { PORT: 3002, HOST: "0.0.0.0" },
server: { PORT: 3012, HOST: "0.0.0.0" },
db: { LOGGING: false },
} satisfies EnvConfig;
2 changes: 1 addition & 1 deletion examples/backend-bun-cjs/test/e2e/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test("loads development config via auto-discovery", async ({ request }) => {
IS_PROD: false,
IS_TEST: false,
log: { LEVEL: "debug" },
server: { PORT: 3002, HOST: "127.0.0.1" },
server: { PORT: 3012, HOST: "127.0.0.1" },
db: { URL: "postgres://localhost/dev", LOGGING: true },
},
});
Expand Down
2 changes: 1 addition & 1 deletion examples/backend-deno-cjs/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "@playwright/test";

const PORT = 3003;
const PORT = 3013;
const BASE_URL = `http://127.0.0.1:${PORT}`;

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/backend-deno-cjs/src/config/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type { EnvConfig } from "../env/schema.ts";

export default {
log: { LEVEL: "debug" },
server: { PORT: 3003, HOST: "127.0.0.1" },
server: { PORT: 3013, HOST: "127.0.0.1" },
db: { URL: "postgres://localhost/dev", LOGGING: true },
} satisfies EnvConfig;
2 changes: 1 addition & 1 deletion examples/backend-deno-cjs/src/config/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type { EnvConfig } from "../env/schema.ts";

export default {
log: { LEVEL: "info" },
server: { PORT: 3003, HOST: "0.0.0.0" },
server: { PORT: 3013, HOST: "0.0.0.0" },
db: { LOGGING: false },
} satisfies EnvConfig;
2 changes: 1 addition & 1 deletion examples/backend-deno-cjs/test/e2e/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test("loads development config via auto-discovery", async ({ request }) => {
IS_PROD: false,
IS_TEST: false,
log: { LEVEL: "debug" },
server: { PORT: 3003, HOST: "127.0.0.1" },
server: { PORT: 3013, HOST: "127.0.0.1" },
db: { URL: "postgres://localhost/dev", LOGGING: true },
},
});
Expand Down
2 changes: 1 addition & 1 deletion examples/backend-node-cjs/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "@playwright/test";

const PORT = 3001;
const PORT = 3011;
const BASE_URL = `http://127.0.0.1:${PORT}`;

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/backend-node-cjs/src/config/development.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type { EnvConfig } from "../env/schema.ts";

export default {
log: { LEVEL: "debug" },
server: { PORT: 3001, HOST: "127.0.0.1" },
server: { PORT: 3011, HOST: "127.0.0.1" },
db: { URL: "postgres://localhost/dev", LOGGING: true },
} satisfies EnvConfig;
2 changes: 1 addition & 1 deletion examples/backend-node-cjs/src/config/production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ import type { EnvConfig } from "../env/schema.ts";

export default {
log: { LEVEL: "info" },
server: { PORT: 3001, HOST: "0.0.0.0" },
server: { PORT: 3011, HOST: "0.0.0.0" },
db: { LOGGING: false },
} satisfies EnvConfig;
2 changes: 1 addition & 1 deletion examples/backend-node-cjs/test/e2e/server.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test("loads development config via auto-discovery", async ({ request }) => {
IS_PROD: false,
IS_TEST: false,
log: { LEVEL: "debug" },
server: { PORT: 3001, HOST: "127.0.0.1" },
server: { PORT: 3011, HOST: "127.0.0.1" },
db: { URL: "postgres://localhost/dev", LOGGING: true },
},
});
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-react-router/app/config/development.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ServerEnvConfig } from "../env/schema.server.ts";

export default {
server: { PORT: 3002, HOST: "127.0.0.1" },
server: { PORT: 3005, HOST: "127.0.0.1" },
public: {
API_BASE_URL: "http://localhost:3001/dev-api",
APP_NAME: "rr7-dev-app",
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-react-router/app/config/production.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ServerEnvConfig } from "../env/schema.server.ts";

export default {
server: { PORT: 3002, HOST: "0.0.0.0" },
server: { PORT: 3005, HOST: "0.0.0.0" },
public: {
API_BASE_URL: "https://api.example.com",
APP_NAME: "rr7-prod-app",
Expand Down
1 change: 1 addition & 0 deletions examples/ssr-react-router/mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ run = "react-router build"

[tasks.start]
depends = ["setup"]
env = { PORT = "3005" }
run = "react-router-serve build/server/index.js"

[tasks."test:e2e"]
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-react-router/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "@playwright/test";

const PORT = 3002;
const PORT = 3005;
const BASE_URL = `http://127.0.0.1:${PORT}`;

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-tanstack-start/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig } from "@playwright/test";

const PORT = 3003;
const PORT = 3006;
const BASE_URL = `http://127.0.0.1:${PORT}`;

export default defineConfig({
Expand Down
2 changes: 1 addition & 1 deletion examples/ssr-tanstack-start/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
import { serve } from "srvx/node";
import handler from "./dist/server/server.js";

const port = Number(process.env.PORT) || 3003;
const port = Number(process.env.PORT) || 3006;
serve({ fetch: handler.fetch, port });
console.log(`tss-prod-app listening on http://127.0.0.1:${port}`);
2 changes: 1 addition & 1 deletion examples/ssr-tanstack-start/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import { defineConfig } from "vite";

export default defineConfig({
plugins: [tanstackStart(), react(), envConfig()],
server: { port: 3003, strictPort: true },
server: { port: 3006, strictPort: true },
});
Loading