-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathdeploy.config.mjs
More file actions
70 lines (62 loc) · 3.01 KB
/
Copy pathdeploy.config.mjs
File metadata and controls
70 lines (62 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Deployment matrix: which surfaces (sections) ship to which build target.
//
// The same public repo builds two deployables. A single build-time selector,
// NEXT_PUBLIC_DEPLOY_TARGET, says which one this build is; this file declares,
// per surface, which targets include it. Consumers (nav, middleware, the llms
// generator, per-section guards) all read this one table instead of their own
// flags.
//
// Selected via the build script, not hand-set env:
// npm run build -> external (default; public Vercel site)
// npm run build:internal -> internal (separate internal deployment)
//
// Authored as .mjs so both the TypeScript app and the plain-node scripts
// (scripts/llms.mjs, llms.config.mjs) can import it.
//
// The target is fixed for a given build, so a disabled surface is unreachable in
// it: middleware 404s its routes, its API guard 404s, and it is dropped from the
// nav, sitemap, and generated llms artifacts. Note this is a reachability
// guarantee, not a bundling one — the surface's client chunks may still be
// emitted (this repo is public, so that is not a disclosure concern).
/** @typedef {'external' | 'internal'} DeployTarget */
/** @type {DeployTarget} */
export const TARGET = process.env.NEXT_PUBLIC_DEPLOY_TARGET === 'internal' ? 'internal' : 'external';
// Surfaces that are NOT available everywhere. A section absent from this map
// ships to every target. `routePrefixes` are UI paths; `apiPrefixes` are the
// section's API paths (documented here and enforced by the section's API guard).
export const SURFACES = {
'internal-explorer': {
// `/tips` and `/api/tips` are legacy prefixes kept so the public build
// 404s old URLs instead of redirecting to the internal surface.
routePrefixes: ['/internal-explorer', '/tips'],
apiPrefixes: ['/api/internal-explorer', '/api/tips'],
targets: ['internal'],
},
// No apiPrefixes: the benchmark UI calls the report API straight from the
// browser (NEXT_PUBLIC_BENCHMARK_API_BASE_URL) instead of proxying through a
// route handler here, so this app serves no /api path for it.
benchmark: {
routePrefixes: ['/benchmark'],
targets: ['internal'],
},
};
/** Is a surface included in the current build target? Unknown key => yes. */
export function surfaceEnabled(key) {
const surface = SURFACES[key];
return !surface || surface.targets.includes(TARGET);
}
function disabledSurfaces() {
return Object.values(SURFACES).filter((s) => !s.targets.includes(TARGET));
}
/** UI path prefixes to 404 in this build (consumed by middleware). */
export function disabledRoutePrefixes() {
return disabledSurfaces().flatMap((s) => s.routePrefixes ?? []);
}
/** API path prefixes disabled in this build (documented; per-route guards enforce). */
export function disabledApiPrefixes() {
return disabledSurfaces().flatMap((s) => s.apiPrefixes ?? []);
}
/** Glob patterns for the llms/agents generator's `exclude` (path + subtree). */
export function disabledRouteGlobs() {
return disabledRoutePrefixes().flatMap((p) => [p, `${p}/**`]);
}