coderio 1.0.0 → 1.0.1-alpha.2

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.d.ts CHANGED
@@ -801,8 +801,10 @@ declare class Workspace {
801
801
  initWorkspace(subPath: string, rootPath?: string, appName?: string): WorkspaceStructure;
802
802
  /**
803
803
  * Delete all files and directories inside the workspace
804
+ * @param workspace - The workspace structure
805
+ * @param exclude - Optional list of file/directory names to exclude from deletion
804
806
  */
805
- deleteWorkspace(workspace: WorkspaceStructure): void;
807
+ deleteWorkspace(workspace: WorkspaceStructure, exclude?: string[]): void;
806
808
  /**
807
809
  * Resolve the absolute path to the source code directory
808
810
  * @param paths - The workspace structure
package/dist/index.js CHANGED
@@ -472,7 +472,7 @@ var parseFigmaUrl = (url) => {
472
472
  if (!fileId || !nodeId) {
473
473
  throw new Error("Invalid Figma URL");
474
474
  }
475
- return { fileId, name, nodeId, projectName: `${name}_${nodeId}` };
475
+ return { fileId, name, nodeId, projectName: `${name}_${nodeId.replace(/:/g, "_")}` };
476
476
  };
477
477
 
478
478
  // src/tools/figma-tool/index.ts
@@ -636,12 +636,17 @@ var Workspace = class {
636
636
  }
637
637
  /**
638
638
  * Delete all files and directories inside the workspace
639
+ * @param workspace - The workspace structure
640
+ * @param exclude - Optional list of file/directory names to exclude from deletion
639
641
  */
640
- deleteWorkspace(workspace) {
642
+ deleteWorkspace(workspace, exclude = []) {
641
643
  try {
642
644
  if (fs2.existsSync(workspace.root)) {
643
645
  const entries = fs2.readdirSync(workspace.root);
644
646
  for (const entry of entries) {
647
+ if (exclude.includes(entry)) {
648
+ continue;
649
+ }
645
650
  const fullPath = path2.join(workspace.root, entry);
646
651
  fs2.rmSync(fullPath, { recursive: true, force: true });
647
652
  }
@@ -670,7 +675,8 @@ var Workspace = class {
670
675
  *
671
676
  */
672
677
  resolveComponentPath(aliasPath) {
673
- let relativePath = aliasPath.startsWith("@/") ? aliasPath.substring(2) : aliasPath;
678
+ const normalizedAlias = aliasPath.replace(/\\/g, "/");
679
+ let relativePath = normalizedAlias.startsWith("@/") ? normalizedAlias.substring(2) : normalizedAlias;
674
680
  if (relativePath.startsWith("src/")) {
675
681
  relativePath = relativePath.substring(4);
676
682
  }
@@ -694,7 +700,7 @@ function saveDebugLog(requestInfo, responseInfo) {
694
700
  "------------response------------",
695
701
  JSON.stringify(responseInfo, null, 2)
696
702
  ].join("\n");
697
- writeFile(workspaceManager.path?.debug ?? "", `fetch_${(/* @__PURE__ */ new Date()).toISOString()}.md`, debugContent);
703
+ writeFile(workspaceManager.path?.debug ?? "", `fetch_${(/* @__PURE__ */ new Date()).toISOString().replace(/:/g, "-")}.md`, debugContent);
698
704
  }
699
705
  async function get(url, config) {
700
706
  const response = await axios.get(url, config);
@@ -1020,7 +1026,13 @@ var createDownloadTask = async (image, imageDir) => {
1020
1026
  const filename = `${sanitizedName}-${image.id.replace(/:/g, "-")}.${ext}`;
1021
1027
  try {
1022
1028
  const localPath = await downloadImage(image.url, filename, imageDir);
1023
- const aliasPath = `@/${localPath.split("src/")?.[1] || ""}`;
1029
+ const normalizedImageDir = imageDir ? path3.normalize(imageDir) : "";
1030
+ const dirParts = normalizedImageDir.split(path3.sep).filter(Boolean);
1031
+ const srcIndex = dirParts.lastIndexOf("src");
1032
+ const srcDir = srcIndex >= 0 ? (normalizedImageDir.startsWith(path3.sep) ? path3.sep : "") + path3.join(...dirParts.slice(0, srcIndex + 1)) : "";
1033
+ const relativeFromSrc = srcDir ? path3.relative(srcDir, localPath) : "";
1034
+ const normalizedRelative = relativeFromSrc.split(path3.sep).join("/");
1035
+ const aliasPath = `@/${normalizedRelative}`;
1024
1036
  return {
1025
1037
  id: image.id,
1026
1038
  name: image.name,
@@ -1517,6 +1529,9 @@ import { ChatOpenAI } from "@langchain/openai";
1517
1529
  // src/nodes/process/structure/index.ts
1518
1530
  init_prompt();
1519
1531
 
1532
+ // src/nodes/process/structure/utils.ts
1533
+ import path4 from "path";
1534
+
1520
1535
  // src/utils/naming.ts
1521
1536
  function toPascalCase(str) {
1522
1537
  return str.replace(/[^a-zA-Z0-9]+/g, " ").trim().split(/\s+/).map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join("");
@@ -1697,7 +1712,7 @@ function postProcessStructure(structure, frames) {
1697
1712
  if (!structure) {
1698
1713
  return;
1699
1714
  }
1700
- const joinSegments = (...segments) => segments.filter((segment) => Boolean(segment && segment.length)).join("/").replace(/\/{2,}/g, "/");
1715
+ const joinSegments = (...segments) => path4.posix.join(...segments.filter((segment) => Boolean(segment && segment.length)));
1701
1716
  const nodes = Array.isArray(structure) ? structure : [structure];
1702
1717
  let rootPath = "@/components";
1703
1718
  const toKebabName = (node) => {
@@ -2152,7 +2167,7 @@ var DEFAULT_STYLING = {
2152
2167
  };
2153
2168
 
2154
2169
  // src/nodes/code/utils.ts
2155
- import path4 from "path";
2170
+ import path5 from "path";
2156
2171
 
2157
2172
  // src/utils/code-cache.ts
2158
2173
  import fs4 from "fs";
@@ -2183,8 +2198,8 @@ function saveGeneratedCode(code, filePath) {
2183
2198
  createFiles({ files, filePath });
2184
2199
  } else {
2185
2200
  const extractedCode = extractCode(code);
2186
- const folderPath = path4.dirname(filePath);
2187
- const fileName = path4.basename(filePath);
2201
+ const folderPath = path5.dirname(filePath);
2202
+ const fileName = path5.basename(filePath);
2188
2203
  writeFile(folderPath, fileName, extractedCode);
2189
2204
  }
2190
2205
  }