create-wenuts-cli 2.1.1 → 2.2.0
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/package.json
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
"version": "0.1.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"dev": "next dev",
|
|
6
|
+
"dev": "concurrently \"yarn run icons:watch\" \"next dev\"",
|
|
7
7
|
"build": "next build",
|
|
8
8
|
"start": "next start",
|
|
9
9
|
"lint": "next lint",
|
|
10
|
-
"prepare": "husky"
|
|
10
|
+
"prepare": "husky",
|
|
11
|
+
"icons": "node scripts/generate-icons.mjs",
|
|
12
|
+
"icons:watch": "chokidar \"src/assets/icons/**/*.svg\" -c \"yarn run icons\""
|
|
11
13
|
},
|
|
12
14
|
"dependencies": {
|
|
13
15
|
"@mantine/core": "^8.1.2",
|
|
@@ -26,10 +28,13 @@
|
|
|
26
28
|
},
|
|
27
29
|
"devDependencies": {
|
|
28
30
|
"@eslint/eslintrc": "^3",
|
|
31
|
+
"@svgr/cli": "^8.1.0",
|
|
29
32
|
"@tailwindcss/postcss": "^4",
|
|
30
33
|
"@types/node": "^20",
|
|
31
34
|
"@types/react": "^19",
|
|
32
35
|
"@types/react-dom": "^19",
|
|
36
|
+
"chokidar-cli": "^3.0.0",
|
|
37
|
+
"concurrently": "^9.2.1",
|
|
33
38
|
"eslint": "^9",
|
|
34
39
|
"eslint-config-next": "16.1.1",
|
|
35
40
|
"husky": "^9.0.11",
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// scripts/generate-icons.mjs
|
|
2
|
+
import { execSync } from 'child_process';
|
|
3
|
+
|
|
4
|
+
// 配置路径
|
|
5
|
+
const SVG_DIR = 'src/assets/icons'; // 存放原始 .svg 的地方
|
|
6
|
+
const OUT_DIR = 'src/components/icons'; // 生成组件的地方
|
|
7
|
+
|
|
8
|
+
console.log('🚀 正在将 SVG 转换为 React 组件...');
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
// 执行 SVGR 命令
|
|
12
|
+
// --typescript: 生成 tsx
|
|
13
|
+
// --icon: 自动处理 width/height 为 1em
|
|
14
|
+
// --no-prettier: 禁用 prettier 插件以避免 ESM 冲突
|
|
15
|
+
// --out-dir: 输出目录
|
|
16
|
+
execSync(`npx @svgr/cli --out-dir ${OUT_DIR} --typescript --icon --no-prettier ${SVG_DIR}`, {
|
|
17
|
+
stdio: 'inherit',
|
|
18
|
+
});
|
|
19
|
+
// 使用项目的 Prettier 配置重新格式化生成的文件
|
|
20
|
+
execSync(`npx prettier --write "${OUT_DIR}/**/*.{ts,tsx}"`, {
|
|
21
|
+
stdio: 'inherit',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
console.log('✅ 转换完成!');
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error('❌ 转换失败:', error.message);
|
|
27
|
+
}
|