Skip to content

armgit / eve

Public Imported from GitHub
0

The Open Framework for Building Agents

feat(docs) enable portless for docs development (#3382)

Colton Padden4751e69788ad
diff --git a/apps/docs/lib/geistdocs/url.test.ts b/apps/docs/lib/geistdocs/url.test.ts
new file mode 100644
index 000000000..75561e864
--- /dev/null
+++ b/apps/docs/lib/geistdocs/url.test.ts
@@ -0,0 +1,26 @@
+import { afterEach, describe, expect, it, vi } from "vitest";
+import { getSiteOrigin } from "./url";
+
+const SITE_ENV = "NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL";
+
+afterEach(() => vi.unstubAllEnvs());
+
+describe("getSiteOrigin", () => {
+ it("preserves a configured HTTP origin", () => {
+ vi.stubEnv(SITE_ENV, "http://docs.eve.localhost");
+
+ expect(getSiteOrigin()).toBe("http://docs.eve.localhost");
+ });
+
+ it("adds HTTPS to a configured deployment host", () => {
+ vi.stubEnv(SITE_ENV, "eve.dev");
+
+ expect(getSiteOrigin()).toBe("https://eve.dev");
+ });
+
+ it("rejects a non-HTTP URL", () => {
+ vi.stubEnv(SITE_ENV, "file:///tmp/eve-docs");
+
+ expect(() => getSiteOrigin()).toThrow("Unsupported site URL protocol: file:");
+ });
+});
diff --git a/apps/docs/lib/geistdocs/url.ts b/apps/docs/lib/geistdocs/url.ts
index 0bdac468d..7e4546ab9 100644
--- a/apps/docs/lib/geistdocs/url.ts
+++ b/apps/docs/lib/geistdocs/url.ts
@@ -2,8 +2,16 @@ const LOCAL_SITE_HOST = "localhost:3000";
/** Returns the configured public site origin, with a non-secret local fallback. */
export const getSiteOrigin = () => {
- const host = process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ?? LOCAL_SITE_HOST;
- const protocol = host.startsWith("localhost") || host.startsWith("127.0.0.1") ? "http" : "https";
+ const site = process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ?? LOCAL_SITE_HOST;
- return `${protocol}://${host}`;
+ if (site.includes("://")) {
+ const url = new URL(site);
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
+ throw new Error(`Unsupported site URL protocol: ${url.protocol}`);
+ }
+ return url.origin;
+ }
+
+ const protocol = site.startsWith("localhost") || site.startsWith("127.0.0.1") ? "http" : "https";
+ return `${protocol}://${site}`;
};
diff --git a/apps/docs/next.config.ts b/apps/docs/next.config.ts
index 63dccf0ff..e8ec9d61f 100644
--- a/apps/docs/next.config.ts
+++ b/apps/docs/next.config.ts
@@ -13,7 +13,7 @@ const withGeistdocs = createGeistdocs();
const require = createRequire(import.meta.url);
const wgslLoader = require.resolve("@vgpu/wgsl/loader-webpack");
-const localSiteHost = "localhost:3000";
+const localSite = process.env.PORTLESS_URL ?? "localhost:3000";
const config: NextConfig = {
cacheComponents: true,
@@ -22,7 +22,7 @@ const config: NextConfig = {
env: {
NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL:
- process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ?? localSiteHost,
+ process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ?? localSite,
},
// The integrations gallery sources identity from the workspace package
diff --git a/apps/docs/package.json b/apps/docs/package.json
index 00f28c08a..4e75c171e 100644
--- a/apps/docs/package.json
+++ b/apps/docs/package.json
@@ -6,7 +6,8 @@
"type": "module",
"scripts": {
"build": "pnpm run registry:check && pnpm run templates:sync && next build",
- "dev": "pnpm run templates:sync && next dev --turbo",
+ "dev": "portless",
+ "dev:app": "pnpm run templates:sync && portless get docs.eve && next dev --turbo",
"start": "next start",
"postinstall": "fumadocs-mdx",
"translate": "npx @vercel/geistdocs translate",
@@ -95,11 +96,16 @@
"chat-adapter-sendblue": "0.2.0",
"eve": "workspace:*",
"eve-channel-blooio": "0.2.0",
+ "portless": "0.15.6",
"postcss": "8.5.15",
"shadcn": "4.16.0",
"tailwindcss": "4.3.0",
"tsx": "^4.21.0",
"typescript": "6.0.3",
"vitest": "catalog:"
+ },
+ "portless": {
+ "name": "docs.eve",
+ "script": "dev:app"
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 65f9495c0..0755925dc 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -373,6 +373,9 @@ importers:
eve-channel-blooio:
specifier: 0.2.0
version: 0.2.0([email protected]([email protected]))(eve@packages+eve)
+ portless:
+ specifier: 0.15.6
+ version: 0.15.6
postcss:
specifier: 8.5.15
version: 8.5.15
@@ -13532,6 +13535,12 @@ packages:
resolution: {integrity: sha512-25ClnWWuw7JbWZcgqY/gJ4FQWadKxGWk+3kR/7kD0tCaDtPPMj7oHu2ToLaVhfpnHrZzYby2w6tUA0eOIuUg8g==}
+ resolution: {integrity: sha512-uOAwWLF32rmyEGFASzSO0VOaqb/AQxFCCzyZbPGd82UNNOfIEvc09zy92nroNibE5HNfzV4oVB0ObKbPXgkM9A==}
+ engines: {node: '>=24'}
+ os: [darwin, linux, win32]
+ hasBin: true
+
resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==}
engines: {node: '>= 0.4'}
@@ -30332,6 +30341,8 @@ snapshots:
path-data-parser: 0.1.0
points-on-curve: 0.2.0
+