MCPcopy Create free account
hub / github.com/vercel/examples / composeStack

Function composeStack

python/vibe-coding-ide/frontend/src/templates.ts:52–94  ·  view source on GitHub ↗
(
  frontendId: string,
  backendId: string
)

Source from the content-addressed store, hash-verified

50}
51
52export function composeStack(
53 frontendId: string,
54 backendId: string
55): ProjectTemplate | undefined {
56 const frontend = getTemplateById(frontendId)
57 const backend = getTemplateById(backendId)
58 if (!frontend || !backend) return undefined
59
60 const files: Record<string, string> = {}
61 for (const [p, c] of Object.entries(frontend.files)) {
62 files[`frontend/${p}`] = c as string
63 }
64 for (const [p, c] of Object.entries(backend.files)) {
65 files[`backend/${p}`] = c as string
66 }
67
68 // No UI injection here; stack-specific frontends handle connectivity checks
69
70 const backendDefault = `backend/${backend.defaultActiveFile}`
71 const frontendDefault = `frontend/${frontend.defaultActiveFile}`
72 const defaultActiveFile =
73 backendDefault in files
74 ? backendDefault
75 : frontendDefault in files
76 ? frontendDefault
77 : Object.keys(files)[0] || 'README.md'
78
79 // For stacks, keep suggestions concise: prefer backend-only prompts
80 const suggestions = backend.suggestions
81 ? [...backend.suggestions]
82 : frontend.suggestions
83 ? [...frontend.suggestions]
84 : undefined
85
86 return {
87 id: `stack:${frontend.id}+${backend.id}`,
88 label: `${frontend.label} + ${backend.label}`,
89 description: 'Custom stack (composed frontend and backend)',
90 files,
91 defaultActiveFile,
92 suggestions,
93 }
94}
95
96export function getStackById(id: string): ProjectTemplate | undefined {
97 const parsed = parseStackId(id)

Callers 1

getStackByIdFunction · 0.85

Calls 1

getTemplateByIdFunction · 0.85

Tested by

no test coverage detected