roadmap-skill 0.2.3 → 0.2.4
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/index.js
CHANGED
|
@@ -287,6 +287,58 @@ var ProjectStorage = class {
|
|
|
287
287
|
}
|
|
288
288
|
return results;
|
|
289
289
|
}
|
|
290
|
+
async exportAllData() {
|
|
291
|
+
await this.ensureDirectory();
|
|
292
|
+
const fs3 = await import("fs/promises");
|
|
293
|
+
const files = await fs3.readdir(this.storageDir);
|
|
294
|
+
const jsonFiles = files.filter((f) => f.endsWith(".json"));
|
|
295
|
+
const projects = [];
|
|
296
|
+
for (const file of jsonFiles) {
|
|
297
|
+
try {
|
|
298
|
+
const filePath = path3.join(this.storageDir, file);
|
|
299
|
+
const data = await readJsonFile(filePath);
|
|
300
|
+
projects.push(data);
|
|
301
|
+
} catch {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
return {
|
|
306
|
+
version: 1,
|
|
307
|
+
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
308
|
+
projects
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
async importAllData(data) {
|
|
312
|
+
await this.ensureDirectory();
|
|
313
|
+
let imported = 0;
|
|
314
|
+
let errors = 0;
|
|
315
|
+
const errorDetails = [];
|
|
316
|
+
if (!data.projects || !Array.isArray(data.projects)) {
|
|
317
|
+
throw new Error("Invalid backup data: projects array is required");
|
|
318
|
+
}
|
|
319
|
+
for (const projectData of data.projects) {
|
|
320
|
+
try {
|
|
321
|
+
if (!projectData.project || !projectData.project.id) {
|
|
322
|
+
errors++;
|
|
323
|
+
errorDetails.push("Skipping invalid project: missing project or id");
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
const filePath = this.getFilePath(projectData.project.id);
|
|
327
|
+
await writeJsonFile(filePath, projectData);
|
|
328
|
+
imported++;
|
|
329
|
+
} catch (error) {
|
|
330
|
+
errors++;
|
|
331
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
332
|
+
errorDetails.push(`Failed to import project ${projectData.project?.id || "unknown"}: ${errorMessage}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
success: errors === 0,
|
|
337
|
+
imported,
|
|
338
|
+
errors,
|
|
339
|
+
errorDetails
|
|
340
|
+
};
|
|
341
|
+
}
|
|
290
342
|
};
|
|
291
343
|
var storage = new ProjectStorage();
|
|
292
344
|
|
|
@@ -1175,6 +1227,28 @@ function createServer(port = 7860) {
|
|
|
1175
1227
|
res.status(500).json({ error: error.message });
|
|
1176
1228
|
}
|
|
1177
1229
|
});
|
|
1230
|
+
app.get("/api/backup", async (_req, res) => {
|
|
1231
|
+
try {
|
|
1232
|
+
const backup = await storage.exportAllData();
|
|
1233
|
+
const filename = `roadmap-skill-backup-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.json`;
|
|
1234
|
+
res.setHeader("Content-Type", "application/json");
|
|
1235
|
+
res.setHeader("Content-Disposition", `attachment; filename="${filename}"`);
|
|
1236
|
+
res.json(backup);
|
|
1237
|
+
} catch (error) {
|
|
1238
|
+
res.status(500).json({ error: error.message });
|
|
1239
|
+
}
|
|
1240
|
+
});
|
|
1241
|
+
app.post("/api/backup", async (req, res) => {
|
|
1242
|
+
try {
|
|
1243
|
+
const result = await storage.importAllData(req.body);
|
|
1244
|
+
res.json(result);
|
|
1245
|
+
} catch (error) {
|
|
1246
|
+
res.status(400).json({
|
|
1247
|
+
success: false,
|
|
1248
|
+
error: error.message
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1178
1252
|
const distPath = path4.join(process.cwd(), "dist", "web", "app");
|
|
1179
1253
|
app.use(express.static(distPath));
|
|
1180
1254
|
app.get("*", (req, res) => {
|