UNPKG

stackpress

Version:

Incept is a content management framework.

25 lines (24 loc) 884 B
import path from 'node:path'; import { action } from '@stackpress/ingest/Server'; import generate from '../../scripts/generate.js'; export default action(async function GenerateScript(req, res, ctx) { if (!ctx.config.has('client')) return; const cli = ctx.plugin('cli'); const tsconfig = ctx.config.path('client.tsconfig'); if (!tsconfig) { cli?.verbose && cli.control.error('Missing tsconfig path'); res.setError('Missing tsconfig path'); return; } const idea = getIdeaPath(ctx, req); await generate(ctx, idea, tsconfig, cli); res.setStatus(200); }); export function getIdeaPath(server, req) { const defaultPath = path.join(server.loader.cwd, 'schema.idea'); const config = server.config.path('cli.idea', defaultPath); const input = req.data.path('input', config); return req.data.path('i', input); } ;