@ubean/devtools 0.1.7 → 0.1.9

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.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <link rel="icon" href="https://r2.soybeanjs.tech/soybeanjs/logo-ubean.svg" type="image/svg+xml" />
7
7
  <title>Ubean DevTools</title>
8
- <script type="module" crossorigin src="/_devtools/assets/index-BLUNHNMx.js"></script>
8
+ <script type="module" crossorigin src="/_devtools/assets/index-BByt7975.js"></script>
9
9
  <link rel="stylesheet" crossorigin href="/_devtools/assets/index-BlZj1Onv.css">
10
10
  </head>
11
11
 
package/dist/index.js CHANGED
@@ -713,6 +713,16 @@ function createCrudServer(options) {
713
713
  if (!scaffoldOps) throw new Error("[ubean:devtools] scaffoldOps is required for CRUD server. Make sure to pass scaffold functions via ubeanDevtoolsPlugin options.");
714
714
  const fs = scaffoldOps.createFsOps(cwd);
715
715
  /**
716
+ * Resolve a file path to an absolute path.
717
+ *
718
+ * Accepts both absolute paths (returned as-is) and project-root-relative
719
+ * paths (resolved against `cwd`). This is needed because virtual modules
720
+ * now emit portable relative `filePath` values instead of absolute paths.
721
+ */
722
+ function resolveFilePath(p) {
723
+ return isAbsolute(p) ? p : resolve(cwd, p);
724
+ }
725
+ /**
716
726
  * Determine the correct base directory for a scaffold type, taking the
717
727
  * project's `dir` config into account. Returns an absolute path.
718
728
  *
@@ -853,13 +863,14 @@ export default definePlugin({
853
863
  }
854
864
  if (type === "config") {
855
865
  if (path) {
856
- if (!await fs.exists(path)) return {
866
+ const resolved = resolveFilePath(path);
867
+ if (!await fs.exists(resolved)) return {
857
868
  success: false,
858
869
  error: `File not found: ${path}`
859
870
  };
860
871
  return {
861
872
  success: true,
862
- content: await fs.readFile(path)
873
+ content: await fs.readFile(resolved)
863
874
  };
864
875
  }
865
876
  if (getConfig) return {
@@ -876,13 +887,14 @@ export default definePlugin({
876
887
  error: "Path is required for file read"
877
888
  };
878
889
  if (SCAFFOLD_TYPE_SET.has(type) || type === "cron" || type === "plugin") {
879
- if (!await fs.exists(path)) return {
890
+ const resolved = resolveFilePath(path);
891
+ if (!await fs.exists(resolved)) return {
880
892
  success: false,
881
893
  error: `File not found: ${path}`
882
894
  };
883
895
  return {
884
896
  success: true,
885
- content: await fs.readFile(path)
897
+ content: await fs.readFile(resolved)
886
898
  };
887
899
  }
888
900
  return {
@@ -929,33 +941,38 @@ export default definePlugin({
929
941
  success: false,
930
942
  errors: ["Path is required for config file update"]
931
943
  };
932
- else if (!await fs.exists(path)) result = {
933
- success: false,
934
- errors: [`File not found: ${path}`]
935
- };
936
944
  else {
937
- await fs.writeFile(path, content || "");
938
- result = {
939
- success: true,
940
- updated: [path]
945
+ const resolved = resolveFilePath(path);
946
+ if (!await fs.exists(resolved)) result = {
947
+ success: false,
948
+ errors: [`File not found: ${path}`]
941
949
  };
950
+ else {
951
+ await fs.writeFile(resolved, content || "");
952
+ result = {
953
+ success: true,
954
+ updated: [path]
955
+ };
956
+ }
942
957
  }
943
958
  else if (!path) result = {
944
959
  success: false,
945
960
  errors: ["Path is required for file update"]
946
961
  };
947
- else if (SCAFFOLD_TYPE_SET.has(type) || type === "cron" || type === "plugin") if (!await fs.exists(path)) result = {
948
- success: false,
949
- errors: [`File not found: ${path}`]
950
- };
951
- else {
952
- await fs.writeFile(path, content || "");
953
- result = {
954
- success: true,
955
- updated: [path]
962
+ else if (SCAFFOLD_TYPE_SET.has(type) || type === "cron" || type === "plugin") {
963
+ const resolved = resolveFilePath(path);
964
+ if (!await fs.exists(resolved)) result = {
965
+ success: false,
966
+ errors: [`File not found: ${path}`]
956
967
  };
957
- }
958
- else result = {
968
+ else {
969
+ await fs.writeFile(resolved, content || "");
970
+ result = {
971
+ success: true,
972
+ updated: [path]
973
+ };
974
+ }
975
+ } else result = {
959
976
  success: false,
960
977
  errors: [`Unsupported resource type: ${type}`]
961
978
  };
@@ -1015,19 +1032,21 @@ export default definePlugin({
1015
1032
  dry: false,
1016
1033
  ...baseDir ? { baseDir } : {}
1017
1034
  }) || {});
1018
- } else if (type === "cron" || type === "plugin") if (!await fs.exists(path)) result = {
1019
- success: false,
1020
- errors: [`File not found: ${path}`]
1021
- };
1022
- else {
1023
- if (force) await fs.remove(path);
1024
- else await fs.createBackup(path, { removeOriginal: true });
1025
- result = {
1026
- success: true,
1027
- deleted: [path]
1035
+ } else if (type === "cron" || type === "plugin") {
1036
+ const resolved = resolveFilePath(path);
1037
+ if (!await fs.exists(resolved)) result = {
1038
+ success: false,
1039
+ errors: [`File not found: ${path}`]
1028
1040
  };
1029
- }
1030
- else result = {
1041
+ else {
1042
+ if (force) await fs.remove(resolved);
1043
+ else await fs.createBackup(resolved, { removeOriginal: true });
1044
+ result = {
1045
+ success: true,
1046
+ deleted: [path]
1047
+ };
1048
+ }
1049
+ } else result = {
1031
1050
  success: false,
1032
1051
  errors: [`Unsupported resource type: ${type}`]
1033
1052
  };
@@ -1047,12 +1066,13 @@ export default definePlugin({
1047
1066
  }
1048
1067
  async function restore(path) {
1049
1068
  try {
1069
+ const resolved = resolveFilePath(path);
1050
1070
  for (const type of SCAFFOLD_TYPES) {
1051
1071
  const baseDir = getBaseDirForType(type);
1052
1072
  const scaffoldRes = await scaffoldOps?.recoverScaffold({
1053
1073
  cwd,
1054
1074
  type,
1055
- path,
1075
+ path: resolved,
1056
1076
  dry: false,
1057
1077
  ...baseDir ? { baseDir } : {}
1058
1078
  });
@@ -1061,10 +1081,10 @@ export default definePlugin({
1061
1081
  return normalizeResult(scaffoldRes);
1062
1082
  }
1063
1083
  }
1064
- const backupPath = `${path}.bak`;
1084
+ const backupPath = `${resolved}.bak`;
1065
1085
  if (await fs.exists(backupPath)) {
1066
- await fs.copyFile(backupPath, path);
1067
- await fs.removeBackup(path);
1086
+ await fs.copyFile(backupPath, resolved);
1087
+ await fs.removeBackup(resolved);
1068
1088
  await notifyChange();
1069
1089
  return {
1070
1090
  success: true,
@@ -1288,7 +1308,7 @@ function createDefineWrapperWithContext() {
1288
1308
  };
1289
1309
  }
1290
1310
  //#endregion
1291
- //#region ../../node_modules/.pnpm/@vitejs+devtools-kit@0.4.8_@voidzero-dev+vite-plus-core@0.2.6_cac@7.0.0_srvx@0.11.22_typescript@6.0.3/node_modules/@vitejs/devtools-kit/dist/index.js
1311
+ //#region ../../node_modules/.pnpm/@vitejs+devtools-kit@0.4.9_@voidzero-dev+vite-plus-core@0.2.6_cac@7.0.0_srvx@0.11.22_typescript@6.0.3/node_modules/@vitejs/devtools-kit/dist/index.js
1292
1312
  const defineRpcFunction = createDefineWrapperWithContext();
1293
1313
  //#endregion
1294
1314
  //#region src/node/rpc/ai.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubean/devtools",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "DevTools for the ubean framework — server middleware, RPC, and the iframe SPA client",
5
5
  "files": [
6
6
  "dist"
@@ -16,8 +16,8 @@
16
16
  }
17
17
  },
18
18
  "dependencies": {
19
- "@ai-sdk/openai-compatible": "3.0.14",
20
- "ai": "7.0.37",
19
+ "@ai-sdk/openai-compatible": "3.0.16",
20
+ "ai": "7.0.40",
21
21
  "hookable": "^6.1.1",
22
22
  "pathe": "^2.0.3"
23
23
  },
@@ -29,18 +29,18 @@
29
29
  "@codemirror/language": "6.12.4",
30
30
  "@codemirror/state": "6.7.1",
31
31
  "@codemirror/theme-one-dark": "6.1.3",
32
- "@codemirror/view": "6.43.6",
32
+ "@codemirror/view": "6.43.7",
33
33
  "@soybeanjs/ui": "^0.29.3",
34
34
  "@soybeanjs/unocss-preset": "^0.2.0",
35
35
  "@soybeanjs/unocss-shadcn": "^0.29.3",
36
- "@types/node": "^26.1.1",
37
- "@vitejs/devtools": "^0.4.8",
38
- "@vitejs/devtools-kit": "^0.4.8",
36
+ "@types/node": "^26.1.2",
37
+ "@vitejs/devtools": "^0.4.9",
38
+ "@vitejs/devtools-kit": "^0.4.9",
39
39
  "@vitejs/plugin-vue": "^6.0.8",
40
40
  "@xterm/addon-fit": "^0.11.0",
41
41
  "@xterm/xterm": "^6.0.0",
42
42
  "hono": "4.12.32",
43
- "typescript": "6.0.3",
43
+ "typescript": "7.0.2",
44
44
  "unocss": "^66.7.5",
45
45
  "vite": "npm:@voidzero-dev/vite-plus-core@0.2.6",
46
46
  "vite-plus": "0.2.6",
@@ -49,7 +49,7 @@
49
49
  "peerDependencies": {
50
50
  "hono": "^4.0.0",
51
51
  "vue": "^3.0.0",
52
- "ubean": "0.1.7"
52
+ "ubean": "0.1.9"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "hono": {