feat(FN-3763): add cli printing press wizard plugin
Implements a new `fusion-plugin-cli-printing-press` plugin with a multi-step wizard UI for authoring CLI commands, including draft storage, route registration, and validation — plus integration wiring in the dashboard's plugin view registry. Includes TypeScript build and ESM import fixes for the plu Fusion-Task-Id: FN-3763
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/* Interim storage — replaced by FN-3766's canonical schema. Do not extend without updating that ticket. */
|
||||
import { randomUUID } from "node:crypto";
|
||||
import { mkdir, readFile, readdir, rm, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import type { ServiceDraft } from "../wizard/types.js";
|
||||
|
||||
export function createDraftStore({ rootDir }: { rootDir: string }) {
|
||||
const draftsDir = join(rootDir, ".fusion", "plugins", "cli-printing-press", "drafts");
|
||||
|
||||
async function ensureDir() { await mkdir(draftsDir, { recursive: true }); }
|
||||
|
||||
return {
|
||||
async create(input: ServiceDraft) {
|
||||
await ensureDir();
|
||||
const now = new Date().toISOString();
|
||||
const draft: ServiceDraft = { ...input, id: input.id || randomUUID(), createdAt: input.createdAt || now, updatedAt: now };
|
||||
await writeFile(join(draftsDir, `${draft.id}.json`), JSON.stringify(draft, null, 2), "utf8");
|
||||
return draft;
|
||||
},
|
||||
async list() {
|
||||
await ensureDir();
|
||||
const files = await readdir(draftsDir);
|
||||
const entries = await Promise.all(files.filter((file) => file.endsWith(".json")).map(async (file) => JSON.parse(await readFile(join(draftsDir, file), "utf8")) as ServiceDraft));
|
||||
return entries.map(({ id, name, slug, updatedAt }) => ({ id, name, slug, updatedAt }));
|
||||
},
|
||||
async get(id: string) {
|
||||
try { return JSON.parse(await readFile(join(draftsDir, `${id}.json`), "utf8")) as ServiceDraft; } catch { return null; }
|
||||
},
|
||||
async delete(id: string) {
|
||||
await rm(join(draftsDir, `${id}.json`), { force: true });
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user