@dimples/apa 0.1.0-dev.10 → 0.1.0-dev.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import { spawn } from "node:child_process";
|
|
3
3
|
import { Command } from "commander";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
5
6
|
import { fileURLToPath } from "node:url";
|
|
6
7
|
import { serve } from "@hono/node-server";
|
|
7
8
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
8
9
|
import { Hono } from "hono";
|
|
9
|
-
import { existsSync } from "node:fs";
|
|
10
10
|
//#region ../../packages/shared/dist/index.mjs
|
|
11
11
|
const mockProjects = [
|
|
12
12
|
{
|
|
@@ -236,6 +236,75 @@ function startServer(opts) {
|
|
|
236
236
|
app.get("/api/actors", (c) => c.json(actors));
|
|
237
237
|
app.get("/api/scenes", (c) => c.json(scenes));
|
|
238
238
|
app.get("/api/costumes", (c) => c.json(costumes));
|
|
239
|
+
const seq = (prefix, existing) => {
|
|
240
|
+
const max = existing.reduce((acc, x) => {
|
|
241
|
+
const n = Number.parseInt(x.id.replace(prefix, ""), 10);
|
|
242
|
+
return Number.isNaN(n) ? acc : Math.max(acc, n);
|
|
243
|
+
}, 0);
|
|
244
|
+
return `${prefix}${String(max + 1).padStart(3, "0")}`;
|
|
245
|
+
};
|
|
246
|
+
app.post("/api/projects", async (c) => {
|
|
247
|
+
const b = await c.req.json();
|
|
248
|
+
if (!b.name?.trim()) return c.json({ error: "name 必填" }, 400);
|
|
249
|
+
const project = {
|
|
250
|
+
id: seq("p-", projects),
|
|
251
|
+
cover: b.cover || void 0,
|
|
252
|
+
name: b.name.trim(),
|
|
253
|
+
logline: b.logline?.trim() || "",
|
|
254
|
+
genre: b.genre?.trim() || "未分类",
|
|
255
|
+
status: b.status ?? "planning",
|
|
256
|
+
progress: 0,
|
|
257
|
+
members: b.members ?? [],
|
|
258
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
259
|
+
};
|
|
260
|
+
projects.push(project);
|
|
261
|
+
return c.json(project, 201);
|
|
262
|
+
});
|
|
263
|
+
app.post("/api/actors", async (c) => {
|
|
264
|
+
const b = await c.req.json();
|
|
265
|
+
if (!b.name?.trim()) return c.json({ error: "name 必填" }, 400);
|
|
266
|
+
const actor = {
|
|
267
|
+
id: seq("a-", actors),
|
|
268
|
+
avatar: b.avatar || void 0,
|
|
269
|
+
name: b.name.trim(),
|
|
270
|
+
persona: b.persona?.trim() || "",
|
|
271
|
+
accent: b.accent || "indigo",
|
|
272
|
+
tags: b.tags ?? [],
|
|
273
|
+
projectCount: 0,
|
|
274
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
275
|
+
};
|
|
276
|
+
actors.push(actor);
|
|
277
|
+
return c.json(actor, 201);
|
|
278
|
+
});
|
|
279
|
+
app.post("/api/scenes", async (c) => {
|
|
280
|
+
const b = await c.req.json();
|
|
281
|
+
if (!b.name?.trim()) return c.json({ error: "name 必填" }, 400);
|
|
282
|
+
const scene = {
|
|
283
|
+
id: seq("s-", scenes),
|
|
284
|
+
name: b.name.trim(),
|
|
285
|
+
description: b.description?.trim() || "",
|
|
286
|
+
timeOfDay: b.timeOfDay?.trim() || "日",
|
|
287
|
+
tags: b.tags ?? [],
|
|
288
|
+
projectName: b.projectName?.trim() || "未关联",
|
|
289
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
290
|
+
};
|
|
291
|
+
scenes.push(scene);
|
|
292
|
+
return c.json(scene, 201);
|
|
293
|
+
});
|
|
294
|
+
app.post("/api/costumes", async (c) => {
|
|
295
|
+
const b = await c.req.json();
|
|
296
|
+
if (!b.name?.trim()) return c.json({ error: "name 必填" }, 400);
|
|
297
|
+
const costume = {
|
|
298
|
+
id: seq("c-", costumes),
|
|
299
|
+
name: b.name.trim(),
|
|
300
|
+
description: b.description?.trim() || "",
|
|
301
|
+
era: b.era?.trim() || "当代",
|
|
302
|
+
tags: b.tags ?? [],
|
|
303
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
304
|
+
};
|
|
305
|
+
costumes.push(costume);
|
|
306
|
+
return c.json(costume, 201);
|
|
307
|
+
});
|
|
239
308
|
app.use("*", async (c, next) => {
|
|
240
309
|
await next();
|
|
241
310
|
if (!c.req.path.startsWith("/api")) c.header("Cache-Control", "public, max-age=604800");
|