Skip to content

Commit 2aa03f7

Browse files
committed
fix(www): use v1 docs URL in agent onboarding prompt during pre-release
1 parent b242bcb commit 2aa03f7

2 files changed

Lines changed: 52 additions & 20 deletions

File tree

apps/www/lib/config/release.test.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ describe("release config", () => {
7272
expect(RELEASE_CONFIG.agentPrompt).toContain(
7373
"npx arkenv@alpha init --agent",
7474
);
75-
expect(RELEASE_CONFIG.agentPrompt).toContain("/llms.txt");
75+
expect(RELEASE_CONFIG.agentPrompt).toContain(
76+
"https://arkenv-v1.vercel.app/llms.txt",
77+
);
7678
expect(RELEASE_CONFIG.agentPrompt).toContain(
7779
"suggest as a next step (do not install it yourself)",
7880
);
@@ -97,10 +99,17 @@ describe("release config", () => {
9799
});
98100

99101
it("resolves docs URL from VERCEL_PROJECT_PRODUCTION_URL next", () => {
102+
vi.stubEnv("NEXT_PUBLIC_SITE_URL", "");
103+
vi.stubEnv("VERCEL_PROJECT_PRODUCTION_URL", "prod.example");
104+
vi.stubEnv("VERCEL_URL", "preview.example");
105+
expect(getDocsUrl()).toBe("https://prod.example");
106+
});
107+
108+
it("ignores arkenv.js.org from VERCEL_PROJECT_PRODUCTION_URL during pre-release", () => {
100109
vi.stubEnv("NEXT_PUBLIC_SITE_URL", "");
101110
vi.stubEnv("VERCEL_PROJECT_PRODUCTION_URL", "arkenv.js.org");
102-
vi.stubEnv("VERCEL_URL", "arkenv-v1.vercel.app");
103-
expect(getDocsUrl()).toBe("https://arkenv.js.org");
111+
vi.stubEnv("VERCEL_URL", "preview.example");
112+
expect(getDocsUrl()).toBe("https://preview.example");
104113
});
105114

106115
it("resolves docs URL from VERCEL_URL for preview deploys", () => {
@@ -110,11 +119,17 @@ describe("release config", () => {
110119
expect(getDocsUrl()).toBe("https://arkenv-v1.vercel.app");
111120
});
112121

113-
it("falls back to arkenv.js.org when env is unset", () => {
122+
it("resolves docs URL from NEXT_PUBLIC_VERCEL_URL on client side", () => {
123+
vi.stubEnv("NEXT_PUBLIC_SITE_URL", "");
124+
vi.stubEnv("NEXT_PUBLIC_VERCEL_URL", "preview-client.example");
125+
expect(getDocsUrl()).toBe("https://preview-client.example");
126+
});
127+
128+
it("falls back to arkenv-v1.vercel.app when env is unset", () => {
114129
vi.stubEnv("NEXT_PUBLIC_SITE_URL", "");
115130
vi.stubEnv("VERCEL_PROJECT_PRODUCTION_URL", "");
116131
vi.stubEnv("VERCEL_URL", "");
117-
expect(getDocsUrl()).toBe("https://arkenv.js.org");
132+
expect(getDocsUrl()).toBe("https://arkenv-v1.vercel.app");
118133
});
119134

120135
it("embeds the resolved docs URL in the agent prompt", () => {

apps/www/lib/config/release.ts

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,29 @@ export const RELEASE_TAG = rawTag.trim();
1010

1111
export type PackageManager = "npm" | "pnpm" | "bun" | "yarn";
1212

13-
const FALLBACK_DOCS_URL = "https://arkenv.js.org";
13+
/**
14+
* Default/fallback docs origin:
15+
* During pre-release (alpha/rc), v1 docs are hosted at https://arkenv-v1.vercel.app
16+
* while https://arkenv.js.org remains the v0 docs site.
17+
* When graduating to GA (empty RELEASE_TAG), the default flips to https://arkenv.js.org.
18+
*/
19+
export const FALLBACK_DOCS_URL = RELEASE_TAG
20+
? "https://arkenv-v1.vercel.app"
21+
: "https://arkenv.js.org";
1422

1523
/**
1624
* Resolves the docs origin for the current deployment.
1725
*
1826
* Preference order:
1927
* 1. `NEXT_PUBLIC_SITE_URL` (trimmed, no trailing slash)
20-
* 2. `https://${VERCEL_PROJECT_PRODUCTION_URL}` (production domain; flips when DNS moves)
21-
* 3. `https://${VERCEL_URL}` (preview deployment host)
22-
* 4. Fallback `https://arkenv.js.org`
28+
* 2. `https://${NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ?? VERCEL_PROJECT_PRODUCTION_URL}` (production domain; flips when DNS moves in GA)
29+
* 3. `https://${NEXT_PUBLIC_VERCEL_URL ?? VERCEL_URL}` (preview deployment host)
30+
* 4. Fallback docs URL (`https://arkenv-v1.vercel.app` during pre-release, `https://arkenv.js.org` for GA)
2331
*
2432
* Setting `NEXT_PUBLIC_SITE_URL` or the Vercel production URL makes the homepage
25-
* agent prompt auto-update when the site moves off a preview host (e.g.
26-
* arkenv-v1.vercel.app → arkenv.js.org) without hardcoding the preview forever.
33+
* agent prompt auto-update when the site moves off a preview host without hardcoding.
34+
* During pre-release (e.g. alpha), arkenv.js.org serves v0 docs, so it is ignored
35+
* in favor of the v1 deployment host or the pre-release fallback.
2736
*
2837
* @param env - Env bag to read (defaults to `process.env`; injectable for tests).
2938
* @returns Absolute docs origin with no trailing slash.
@@ -36,18 +45,26 @@ export function getDocsUrl(env: NodeJS.ProcessEnv = process.env): string {
3645
: `https://${siteUrl}`;
3746
}
3847

39-
const productionHost = env.VERCEL_PROJECT_PRODUCTION_URL?.trim().replace(
40-
/\/+$/,
41-
"",
42-
);
48+
const productionHost = (
49+
env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL ??
50+
env.VERCEL_PROJECT_PRODUCTION_URL
51+
)
52+
?.trim()
53+
.replace(/\/+$/, "");
4354
if (productionHost) {
44-
return productionHost.startsWith("http://") ||
45-
productionHost.startsWith("https://")
46-
? productionHost
47-
: `https://${productionHost}`;
55+
const isV0DomainDuringPreRelease =
56+
Boolean(RELEASE_TAG) && productionHost === "arkenv.js.org";
57+
if (!isV0DomainDuringPreRelease) {
58+
return productionHost.startsWith("http://") ||
59+
productionHost.startsWith("https://")
60+
? productionHost
61+
: `https://${productionHost}`;
62+
}
4863
}
4964

50-
const previewHost = env.VERCEL_URL?.trim().replace(/\/+$/, "");
65+
const previewHost = (env.NEXT_PUBLIC_VERCEL_URL ?? env.VERCEL_URL)
66+
?.trim()
67+
.replace(/\/+$/, "");
5168
if (previewHost) {
5269
return previewHost.startsWith("http://") ||
5370
previewHost.startsWith("https://")

0 commit comments

Comments
 (0)