miaoda-react-devkit 0.1.1-beta.21 → 0.1.1-beta.24

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.
@@ -1,14 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- /**
4
- * Vite 插件:在 `vite dev` 期间将 @sentry/react 重定向到 stub。
5
- *
6
- * - apply: 'serve' → 仅在开发服务器模式下生效
7
- * - 生产构建时 @sentry/react 正常解析,使用真实 DSN 上报
8
- */
9
-
10
- declare function withSentryStub(): Plugin;
11
-
12
3
  /**
13
4
  * 生产构建使用的 Sentry 替换插件。
14
5
  *
@@ -64,4 +55,4 @@ declare function hmrTogglePlugin(): Plugin;
64
55
  */
65
56
  declare const extractRouterPlugin: () => Plugin;
66
57
 
67
- export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild, withSentryStub };
58
+ export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild };
@@ -1,14 +1,5 @@
1
1
  import { Plugin } from 'vite';
2
2
 
3
- /**
4
- * Vite 插件:在 `vite dev` 期间将 @sentry/react 重定向到 stub。
5
- *
6
- * - apply: 'serve' → 仅在开发服务器模式下生效
7
- * - 生产构建时 @sentry/react 正常解析,使用真实 DSN 上报
8
- */
9
-
10
- declare function withSentryStub(): Plugin;
11
-
12
3
  /**
13
4
  * 生产构建使用的 Sentry 替换插件。
14
5
  *
@@ -64,4 +55,4 @@ declare function hmrTogglePlugin(): Plugin;
64
55
  */
65
56
  declare const extractRouterPlugin: () => Plugin;
66
57
 
67
- export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild, withSentryStub };
58
+ export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild };
@@ -1,37 +1,16 @@
1
- // src/vite/withSentryStub.ts
1
+ // src/vite/withSentryBuild.ts
2
2
  import path from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  var SENTRY_MODULE = "@sentry/react";
5
5
  var _dirname = path.dirname(fileURLToPath(import.meta.url));
6
- var STUB_PATH = path.resolve(_dirname, "../stubs/sentry-react-stub.js");
7
- function withSentryStub() {
8
- return {
9
- name: "miaoda-devkit:sentry-stub",
10
- enforce: "pre",
11
- apply: "serve",
12
- resolveId(id, importer) {
13
- if (importer && importer.includes("sentry-react-stub")) return null;
14
- if (id === SENTRY_MODULE) {
15
- return STUB_PATH;
16
- }
17
- return null;
18
- }
19
- };
20
- }
21
-
22
- // src/vite/withSentryBuild.ts
23
- import path2 from "path";
24
- import { fileURLToPath as fileURLToPath2 } from "url";
25
- var SENTRY_MODULE2 = "@sentry/react";
26
- var _dirname2 = path2.dirname(fileURLToPath2(import.meta.url));
27
- var STUB_PATH2 = path2.resolve(_dirname2, "../stubs/sentry-react-noop-stub.js");
6
+ var STUB_PATH = path.resolve(_dirname, "../stubs/sentry-react-noop-stub.js");
28
7
  function withSentryBuild() {
29
8
  return {
30
9
  name: "miaoda-devkit:sentry-build",
31
10
  enforce: "pre",
32
11
  apply: "build",
33
12
  resolveId(id) {
34
- if (id === SENTRY_MODULE2) return STUB_PATH2;
13
+ if (id === SENTRY_MODULE) return STUB_PATH;
35
14
  return null;
36
15
  }
37
16
  };
@@ -114,7 +93,7 @@ function hmrTogglePlugin() {
114
93
  }
115
94
 
116
95
  // src/vite/extractRouterPlugin/index.ts
117
- import path5 from "path";
96
+ import path4 from "path";
118
97
 
119
98
  // src/vite/extractRouterPlugin/babelHelpers.ts
120
99
  import _traverse from "@babel/traverse";
@@ -233,11 +212,11 @@ var flattenRouteTree = (routes) => {
233
212
  // src/vite/extractRouterPlugin/valueResolver.ts
234
213
  import * as t3 from "@babel/types";
235
214
  import fs2 from "fs";
236
- import path4 from "path";
215
+ import path3 from "path";
237
216
 
238
217
  // src/vite/extractRouterPlugin/pathUtils.ts
239
218
  import fs from "fs";
240
- import path3 from "path";
219
+ import path2 from "path";
241
220
  var joinPaths = (...paths) => {
242
221
  const parts = paths.filter(Boolean);
243
222
  const leadingSlash = parts.length > 0 && parts[0].startsWith("/");
@@ -258,7 +237,7 @@ var resolveFilePath = async (filepath, extensions = [".ts", ".tsx", ".js", ".jsx
258
237
  if (await fileExists(`${filepath}${ext}`)) return `${filepath}${ext}`;
259
238
  }
260
239
  for (const ext of extensions) {
261
- const indexPath = path3.join(filepath, `index${ext}`);
240
+ const indexPath = path2.join(filepath, `index${ext}`);
262
241
  if (await fileExists(indexPath)) return indexPath;
263
242
  }
264
243
  return null;
@@ -379,7 +358,7 @@ var resolveFromFile = async (filePath, exportName, option, context, parentPath,
379
358
  if (exportName) {
380
359
  for (const src of exportAllSources) {
381
360
  const srcPath = resolveAlias(src, option.aliasMap);
382
- const srcAbsolute = path4.resolve(path4.dirname(filePath), srcPath);
361
+ const srcAbsolute = path3.resolve(path3.dirname(filePath), srcPath);
383
362
  const srcResolved = await resolveFilePath(srcAbsolute);
384
363
  if (!srcResolved) continue;
385
364
  const value = await resolveFromFile(srcResolved, exportName, option, context, parentPath, depth + 1);
@@ -392,7 +371,7 @@ var resolveModuleBinding = async (binding, currentFilePath, option, context, par
392
371
  const importDeclaration = binding.path.parent;
393
372
  if (!t3.isImportDeclaration(importDeclaration)) return null;
394
373
  const importPath = resolveAlias(importDeclaration.source.value, option.aliasMap);
395
- const absolutePath = path4.resolve(path4.dirname(currentFilePath), importPath);
374
+ const absolutePath = path3.resolve(path3.dirname(currentFilePath), importPath);
396
375
  const resolvedPath = await resolveFilePath(absolutePath);
397
376
  if (!resolvedPath) return null;
398
377
  let exportName = null;
@@ -861,7 +840,7 @@ var extractRouterPlugin = () => {
861
840
  return acc;
862
841
  }, {});
863
842
  projectRoot = config.root || process.cwd();
864
- appPath = await resolveFilePath(path5.resolve(projectRoot, "src/App"), [".tsx", ".jsx"]) ?? "";
843
+ appPath = await resolveFilePath(path4.resolve(projectRoot, "src/App"), [".tsx", ".jsx"]) ?? "";
865
844
  },
866
845
  /** 构建开始时清空所有缓存 */
867
846
  buildStart() {
@@ -928,6 +907,5 @@ var extractRouterPlugin = () => {
928
907
  export {
929
908
  extractRouterPlugin,
930
909
  hmrTogglePlugin,
931
- withSentryBuild,
932
- withSentryStub
910
+ withSentryBuild
933
911
  };
package/lint/check.sh ADDED
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+
3
+ # 执行 Oxlint 自定义规则和 index.html 安全响应头检查。
4
+
5
+ # 默认使用 devkit 内置的 Oxlint 配置;应用根目录放置 .oxlintrc.json 可覆盖。
6
+ if [ -f "$PWD/.oxlintrc.json" ]; then
7
+ OX_CONFIG="$PWD/.oxlintrc.json"
8
+ else
9
+ OX_CONFIG="$DEVKIT_ROOT/oxlint-config.json"
10
+ fi
11
+
12
+ OX_BIN="${DEVKIT_OXLINT:-$(command -v oxlint || true)}"
13
+ if [ -z "$OX_BIN" ]; then
14
+ echo "无法找到 oxlint 可执行文件。"
15
+ OX_STATUS=1
16
+ else
17
+ "$OX_BIN" --config "$OX_CONFIG" "$PWD/src"
18
+ OX_STATUS=$?
19
+ fi
20
+
21
+ HTML_CHECKER="$DEVKIT_ROOT/dist/html/check.js"
22
+ if [ ! -f "$HTML_CHECKER" ]; then
23
+ echo "无法找到 HTML 检查器:$HTML_CHECKER"
24
+ HTML_STATUS=1
25
+ else
26
+ node "$HTML_CHECKER" "$PWD/index.html"
27
+ HTML_STATUS=$?
28
+ fi
29
+
30
+ if [ "$OX_STATUS" -ne 0 ] || [ "$HTML_STATUS" -ne 0 ]; then
31
+ exit 1
32
+ fi
33
+ exit 0
package/lint/lint.sh ADDED
@@ -0,0 +1,97 @@
1
+ #!/bin/bash
2
+ # 按原有顺序执行类型、Biome、自定义规则、Tailwind、构建和包体积检查。
3
+ # 即使某个阶段失败,仍执行后续阶段,最后汇总并输出 SUCCESS / ERROR 标记。
4
+
5
+ FAILED=""
6
+ SUMMARY=""
7
+
8
+ record() {
9
+ local name="$1" ok="$2"
10
+ if [ "$ok" -eq 0 ]; then
11
+ SUMMARY="$SUMMARY$name: OK
12
+ "
13
+ else
14
+ SUMMARY="$SUMMARY$name: FAIL
15
+ "
16
+ FAILED="$FAILED $name"
17
+ fi
18
+ }
19
+
20
+ "$DEVKIT_TSGO" -p tsconfig.check.json
21
+ record "tsgo" $?
22
+
23
+ "$DEVKIT_BIOME" lint
24
+ record "biome" $?
25
+
26
+ # check.sh 统一执行 Oxlint 与 HTML 检查器,依据退出码判断阶段结果。
27
+ bash "$DEVKIT_ROOT/lint/check.sh"
28
+ record "customRules" $?
29
+
30
+ CSS_OUTPUT=$(tailwindcss -i ./src/index.css -o /dev/null 2>&1)
31
+ CSS_STATUS=$?
32
+ CSS_ERRORS=$(printf '%s' "$CSS_OUTPUT" | grep -E '^(CssSyntaxError|Error):.*')
33
+ [ -n "$CSS_ERRORS" ] && echo "$CSS_ERRORS"
34
+ [ "$CSS_STATUS" -ne 0 ] && [ -z "$CSS_ERRORS" ] && echo "$CSS_OUTPUT"
35
+ [ -z "$CSS_ERRORS" ] && [ "$CSS_STATUS" -eq 0 ]
36
+ record "tailwind" $?
37
+
38
+ bash "$DEVKIT_ROOT/lint/testBuild.sh"
39
+ record "testBuild" $?
40
+
41
+ # 发布包体积守卫:tracked + 未忽略的 untracked 文件总大小不超过 100 MB。
42
+ PKG_LIMIT_KB=$((100 * 1024))
43
+
44
+ if stat -c %s . >/dev/null 2>&1; then
45
+ PKG_STAT=(stat -c %s) # GNU coreutils
46
+ else
47
+ PKG_STAT=(stat -f %z) # BSD/macOS
48
+ fi
49
+
50
+ if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
51
+ # 统计 git 可见的全部路径:tracked 文件加上未被 .gitignore 排除的 untracked
52
+ # 文件。按磁盘实际大小统计,未暂存的修改也会计入。
53
+ DISK_BYTES=$(git ls-files -co --exclude-standard -z 2>/dev/null \
54
+ | xargs -0 "${PKG_STAT[@]}" 2>/dev/null \
55
+ | awk '{s+=$1} END{printf "%d", s+0}')
56
+ # 已从磁盘删除但仍留在 .git 中的 tracked 文件也计入。
57
+ if [ -n "$(git ls-files -d 2>/dev/null)" ]; then
58
+ DELETED_BYTES=$(git ls-files -d -z 2>/dev/null \
59
+ | xargs -0 git ls-files -s -z -- 2>/dev/null \
60
+ | tr '\0' '\n' \
61
+ | awk 'NF {print $2}' \
62
+ | git cat-file --batch-check='%(objectsize)' 2>/dev/null \
63
+ | awk '$1 ~ /^[0-9]+$/ {s+=$1} END{printf "%d", s+0}')
64
+ else
65
+ DELETED_BYTES=0
66
+ fi
67
+ PKG_BYTES=$(( ${DISK_BYTES:-0} + ${DELETED_BYTES:-0} ))
68
+ PKG_KB=$(( (PKG_BYTES + 1023) / 1024 ))
69
+ [ "$PKG_KB" -le "$PKG_LIMIT_KB" ]
70
+ PKG_OK=$?
71
+ else
72
+ PKG_KB=0
73
+ PKG_OK=1
74
+ echo "packageSize: FAIL - not a git repository, cannot measure tracked files"
75
+ fi
76
+
77
+ echo "packageSize: tracked+untracked (non-ignored) $(awk -v k="$PKG_KB" 'BEGIN{printf "%.1f", k/1024}')MB / 100MB"
78
+ if [ "$PKG_OK" -ne 0 ]; then
79
+ echo "packageSize: FAIL - tracked + untracked (non-ignored) files exceed 100MB. Remediation (ask the user for confirmation before deleting anything):"
80
+ echo " 1. Large files under public/: upload them to a Supabase Storage bucket first, then delete the local copies and commit. Ask the user for explicit confirmation before deleting."
81
+ echo " 2. Files already deleted but still held in .git history: locate the large files and their commits with git rev-list --objects --all, then use git filter-repo to remove only those large-file paths, followed by git reflog expire --expire=now --all and git gc --prune=now. Ask the user for explicit confirmation before executing."
82
+ echo " 3. Oversized non-code files: move files needed at runtime to a Supabase Storage bucket; add files unrelated to the build/runtime environment to .gitignore."
83
+ fi
84
+ record "packageSize" "$PKG_OK"
85
+
86
+ echo ""
87
+ echo "--------- LINT SUMMARY ---------"
88
+ printf '%s' "$SUMMARY"
89
+ echo "-------------------------------"
90
+ echo ""
91
+
92
+ if [ -n "$FAILED" ]; then
93
+ echo "ERROR: lint failed ->$FAILED"
94
+ exit 1
95
+ fi
96
+
97
+ echo "SUCCESS"
@@ -0,0 +1,26 @@
1
+ #!/bin/bash
2
+
3
+ VITE_TEMP="node_modules/.vite-temp"
4
+ if [ -L "$VITE_TEMP" ]; then
5
+ rm "$VITE_TEMP"
6
+ mkdir -p "$VITE_TEMP"
7
+ elif [ ! -e "$VITE_TEMP" ]; then
8
+ mkdir -p "$VITE_TEMP"
9
+ fi
10
+
11
+ # 平台继续使用原来的 /workspace/.dist;本地检查回退到应用内的 .dist。
12
+ if [ -d /workspace ] && [ -w /workspace ]; then
13
+ BUILD_OUT_DIR="/workspace/.dist"
14
+ else
15
+ BUILD_OUT_DIR=".dist"
16
+ fi
17
+ BUILD_OUT_DIR="${DEVKIT_BUILD_OUT_DIR:-$BUILD_OUT_DIR}"
18
+
19
+ OUTPUT=$(vite build --minify false --logLevel error --outDir "$BUILD_OUT_DIR" 2>&1)
20
+ EXIT_CODE=$?
21
+
22
+ if [ $EXIT_CODE -ne 0 ]; then
23
+ echo "$OUTPUT"
24
+ fi
25
+
26
+ exit $EXIT_CODE
@@ -0,0 +1,26 @@
1
+ {
2
+ "jsPlugins": ["miaoda-react-devkit/oxlint-plugin"],
3
+ "categories": {
4
+ "correctness": "off",
5
+ "nursery": "off",
6
+ "pedantic": "off",
7
+ "perf": "off",
8
+ "restriction": "off",
9
+ "style": "off",
10
+ "suspicious": "off"
11
+ },
12
+ "rules": {
13
+ "miaoda/select-item-with-empty-value": "error",
14
+ "miaoda/button-outline-text-foreground-contrast": "warn",
15
+ "miaoda/button-default-text-primary-contrast": "warn",
16
+ "miaoda/button-outline-white-gray-contrast": "warn",
17
+ "miaoda/radix-trigger-formcontrol-nesting": "error",
18
+ "miaoda/require-button-interaction": "error",
19
+ "miaoda/use-toast-import": "error",
20
+ "miaoda/supabase-google-sso": "warn",
21
+ "miaoda/supabase-edge-function-get-with-body": "error"
22
+ },
23
+ "options": {
24
+ "denyWarnings": true
25
+ }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "miaoda-react-devkit",
3
- "version": "0.1.1-beta.21",
3
+ "version": "0.1.1-beta.24",
4
4
  "description": "React admin 应用开发工具集",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,19 +19,36 @@
19
19
  "require": "./dist/vite/index.cjs"
20
20
  },
21
21
  "./cloud/vite.config": "./cloud/vite.config.js",
22
- "./tsconfig-base": "./tsconfig-base.json"
22
+ "./tsconfig-base": "./tsconfig-base.json",
23
+ "./biome": "./biome-config.json",
24
+ "./oxlint": "./oxlint-config.json",
25
+ "./oxlint-plugin": {
26
+ "types": "./dist/oxlint/index.d.ts",
27
+ "import": "./dist/oxlint/index.js"
28
+ }
23
29
  },
24
30
  "files": [
25
31
  "dist",
26
32
  "cloud",
27
33
  "!cloud/**/*.ts",
28
34
  "tsconfig-base.json",
29
- "!dist/**/*.map"
35
+ "!dist/**/*.map",
36
+ "bin",
37
+ "lint",
38
+ "biome-config.json",
39
+ "oxlint-config.json"
30
40
  ],
31
41
  "dependencies": {
32
42
  "@babel/parser": "^7.28.0",
33
43
  "@babel/traverse": "^7.28.0",
34
- "@babel/types": "^7.28.0"
44
+ "@babel/types": "^7.28.0",
45
+ "@biomejs/biome": "2.4.5",
46
+ "@oxlint/plugins": "1.90.0",
47
+ "@typescript/native-preview": "7.0.0-dev.20260514.1",
48
+ "oxc-walker": "^1.1.1",
49
+ "oxlint": "1.90.0",
50
+ "parse5": "7.3.0",
51
+ "playwright": "1.65.0"
35
52
  },
36
53
  "peerDependencies": {
37
54
  "@sentry/core": ">=8.0.0",
@@ -56,5 +73,9 @@
56
73
  "publishConfig": {
57
74
  "registry": "https://registry.npmjs.org/",
58
75
  "access": "public"
76
+ },
77
+ "bin": {
78
+ "devkit-lint": "./bin/lint.mjs",
79
+ "devkit-smoke": "./bin/smoke.mjs"
59
80
  }
60
81
  }