UNPKG

peezy-cli

Version:

Production-ready CLI for scaffolding modern applications with curated full-stack templates, intelligent migrations, and enterprise security.

64 lines 1.89 kB
import fs from "node:fs"; import path from "node:path"; import { pathToFileURL } from "node:url"; export async function loadPeezyConfig(cwd = process.cwd()) { const candidates = [ "peezy.config.mjs", "peezy.config.js", "peezy.config.cjs", "peezy.config.json", ]; for (const file of candidates) { const full = path.join(cwd, file); if (!fs.existsSync(full)) continue; try { const mod = await import(pathToFileURL(full).href); const cfg = (mod.default ?? mod); const plugins = []; for (const p of cfg.plugins ?? []) { if (typeof p === "string") { try { const loaded = await import(p); const inst = (loaded.default ?? loaded); if (inst && inst.name) plugins.push(inst); } catch { // ignore missing plugin } } else if (p && typeof p === "object" && p.name) { plugins.push(p); } } return plugins; } catch { return []; } } return []; } export function applyExtendPrompts(plugins, base) { return plugins.reduce((acc, p) => { try { return p.extendPrompts ? p.extendPrompts(acc) ?? acc : acc; } catch { return acc; } }, base); } export async function runAfterScaffold(plugins, ctx) { for (const p of plugins) { try { if (p.onAfterScaffold) await p.onAfterScaffold(ctx); } catch { // ignore plugin errors to not break core flow } } } //# sourceMappingURL=plugin.js.map