@kohryan/moodui 0.0.13 → 0.0.15

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.d.mts CHANGED
@@ -1 +1,2 @@
1
- #!/usr/bin/env node
1
+
2
+ export { }
package/dist/cli.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- #!/usr/bin/env node
3
2
 
4
3
  // src/cli.ts
5
4
  import fs6 from "fs/promises";
@@ -1165,8 +1164,32 @@ async function runUI() {
1165
1164
  uiDir = path2.join(__dirname2, "..", "dist", "ui");
1166
1165
  }
1167
1166
  const PORT = 3e3;
1168
- console.log(`Starting MoodUI UI...`);
1167
+ const workingDir = process.cwd();
1168
+ console.log(`Starting MoodUI UI at http://localhost:${PORT}`);
1169
+ console.log(`Working directory: ${workingDir}`);
1169
1170
  const server = http.createServer(async (req, res) => {
1171
+ if (req.method === "POST" && req.url === "/api/save-file") {
1172
+ try {
1173
+ let body = "";
1174
+ for await (const chunk of req) {
1175
+ body += chunk.toString();
1176
+ }
1177
+ const { path: filePath2, code } = JSON.parse(body);
1178
+ const resolvedOut = path2.resolve(workingDir, filePath2);
1179
+ await fs6.mkdir(path2.dirname(resolvedOut), { recursive: true });
1180
+ await fs6.writeFile(resolvedOut, code, "utf8");
1181
+ res.writeHead(200, { "Content-Type": "application/json" });
1182
+ res.end(JSON.stringify({ success: true, path: resolvedOut }));
1183
+ console.log(`OK: wrote ${resolvedOut}`);
1184
+ return;
1185
+ } catch (err) {
1186
+ const errorMsg = err instanceof Error ? err.message : String(err);
1187
+ res.writeHead(500, { "Content-Type": "application/json" });
1188
+ res.end(JSON.stringify({ success: false, error: errorMsg }));
1189
+ console.error(`Error saving file: ${errorMsg}`);
1190
+ return;
1191
+ }
1192
+ }
1170
1193
  let filePath = path2.join(uiDir, req.url === "/" ? "index.html" : req.url);
1171
1194
  const extname = String(path2.extname(filePath)).toLowerCase();
1172
1195
  const mimeTypes = {