mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
61 lines
1.3 KiB
Lua
61 lines
1.3 KiB
Lua
---@class Blueprint
|
|
local M = {}
|
|
|
|
---@generic T
|
|
---@param value? T
|
|
---@param default_value T
|
|
---@return T
|
|
local function fallback(value, default_value)
|
|
if value == nil or value == '' then
|
|
return default_value
|
|
end
|
|
return value
|
|
end
|
|
|
|
---@class BlueprintInput
|
|
---@field project_name? string
|
|
---@field runtime? string
|
|
---@field description? string
|
|
|
|
---@class GeneratedFile
|
|
---@field path string
|
|
---@field content string
|
|
|
|
---@class BlueprintOutput
|
|
---@field name string
|
|
---@field runtime string
|
|
---@field description string
|
|
---@field files GeneratedFile[]
|
|
|
|
---@param input BlueprintInput
|
|
---@return BlueprintOutput
|
|
function M.build_blueprint(input)
|
|
local name = fallback(input.project_name, "starter-app")
|
|
local runtime = fallback(input.runtime, "web")
|
|
local description = fallback(input.description, "Generated by Codegen Studio")
|
|
|
|
local files = {
|
|
{
|
|
path = name .. "/README.md",
|
|
content = "# " .. name .. "\n\n" .. description .. "\n"
|
|
},
|
|
{
|
|
path = name .. "/package.json",
|
|
content = "{\n \"name\": \"" .. name .. "\",\n \"private\": true\n}\n"
|
|
},
|
|
{
|
|
path = name .. "/src/app/page.tsx",
|
|
content = "export default function Home() {\n return <div>" .. name .. "</div>\n}\n"
|
|
}
|
|
}
|
|
|
|
return {
|
|
name = name,
|
|
runtime = runtime,
|
|
description = description,
|
|
files = files
|
|
}
|
|
end
|
|
|
|
return M
|