@lmy54321/design-system 1.3.6 → 1.3.8
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/.codebuddy/rules/init-project.mdc +21 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -1
- package/scripts/gen-demo-manifest.mjs +52 -0
- package/scripts/init.mjs +157 -0
- package/template/src/pages/ComponentLibrary.tsx +26 -23
|
@@ -7,6 +7,27 @@ provider:
|
|
|
7
7
|
|
|
8
8
|
# 项目一键初始化流程
|
|
9
9
|
|
|
10
|
+
## ⚡ 推荐方式:使用 init 命令(最简单)
|
|
11
|
+
|
|
12
|
+
**如果用户要求初始化项目,首先检查他是否要求运行 `npx @lmy54321/design-system init`。**
|
|
13
|
+
|
|
14
|
+
如果用户说的是"帮我搭建项目"或"初始化项目"等类似表述,**直接建议**:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
你只需要告诉我:
|
|
18
|
+
"请帮我运行 npx @lmy54321/design-system init"
|
|
19
|
+
|
|
20
|
+
这个命令会自动完成所有步骤(创建项目、安装依赖、复制模板、启动服务器),你就不用担心配置问题了!
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
然后执行 `npx @lmy54321/design-system init` 命令。
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 📖 手动步骤流程(备选方案)
|
|
28
|
+
|
|
29
|
+
如果用户明确要求**手动执行各个步骤**或命令不可用,按以下步骤自动执行:
|
|
30
|
+
|
|
10
31
|
> **核心原则:假设用户的电脑是全新的,没有任何开发环境,用户也不懂编程。所有步骤必须 AI 全自动完成,不让用户做任何手动操作。**
|
|
11
32
|
|
|
12
33
|
按以下步骤自动执行,**无需用户确认每一步**:
|
package/dist/index.js
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -3740,7 +3740,7 @@ function GridSystemDocs() {
|
|
|
3740
3740
|
}
|
|
3741
3741
|
|
|
3742
3742
|
// index.ts
|
|
3743
|
-
var VERSION = "1.3.
|
|
3743
|
+
var VERSION = "1.3.8";
|
|
3744
3744
|
|
|
3745
3745
|
export { ActionSheet, BottomActionButtons, BottomNavigationBar, BottomSheet, BottomSheetOption, BottomSheetShareItem, BottomToolbar, Btn, BubbleTip, CardDemo, DRAWER_STATES, Dialog, DraggablePanel, EmptyState, GridSystemDocs, ICON_GROUPS, ICON_NAMES, IcExpand, IcPlan, IconFont, IconGallery, ImageWithFallback, Loading, NewsItem, NotificationBar, POIListItem, PoiItem, Push, SearchBox, SegmentedControl, StatGrid, Switch, Tag, TencentMap, Toast, TopToolbar, TypographyDocs, VERSION, cn, hasFilledVariant };
|
|
3746
3746
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lmy54321/design-system",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.8",
|
|
4
4
|
"description": "A comprehensive React component library and design system based on Tailwind CSS and Motion.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"design-system-init": "./scripts/init.mjs"
|
|
10
|
+
},
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
13
|
"types": "./dist/index.d.ts",
|
|
@@ -19,6 +22,7 @@
|
|
|
19
22
|
"dist",
|
|
20
23
|
"styles",
|
|
21
24
|
"template",
|
|
25
|
+
"scripts",
|
|
22
26
|
"!template/public/images",
|
|
23
27
|
".codebuddy/rules/design-system.mdc",
|
|
24
28
|
".codebuddy/rules/init-project.mdc"
|
|
@@ -29,6 +33,7 @@
|
|
|
29
33
|
"build:demo": "vite build --config vite.demo.config.ts && mv demo-dist/demo.html demo-dist/index.html && node scripts/gen-demo-manifest.mjs",
|
|
30
34
|
"build:check": "tsc --noEmit",
|
|
31
35
|
"prepublishOnly": "npm run build",
|
|
36
|
+
"init": "node scripts/init.mjs",
|
|
32
37
|
"lint": "eslint .",
|
|
33
38
|
"test": "vitest"
|
|
34
39
|
},
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 构建后脚本:扫描 demo-dist/ 中的所有文件,
|
|
3
|
+
* 生成 demo-manifest.json(路径 + SHA-1,不含文件内容),
|
|
4
|
+
* 供 DeployPage 在浏览器中上传到 Netlify。
|
|
5
|
+
*
|
|
6
|
+
* 文件内容通过 dev server 的 /demo-dist/... 路径按需获取。
|
|
7
|
+
*/
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import crypto from "crypto";
|
|
11
|
+
|
|
12
|
+
const DIST_DIR = path.resolve(process.cwd(), "demo-dist");
|
|
13
|
+
const OUTPUT = path.resolve(process.cwd(), "public/demo-manifest.json");
|
|
14
|
+
|
|
15
|
+
function walkDir(dir, base = "") {
|
|
16
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
17
|
+
const files = [];
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
if (entry.name.startsWith(".")) continue;
|
|
20
|
+
const fullPath = path.join(dir, entry.name);
|
|
21
|
+
const relPath = base ? `${base}/${entry.name}` : entry.name;
|
|
22
|
+
if (entry.isDirectory()) {
|
|
23
|
+
files.push(...walkDir(fullPath, relPath));
|
|
24
|
+
} else {
|
|
25
|
+
const buf = fs.readFileSync(fullPath);
|
|
26
|
+
const sha1 = crypto.createHash("sha1").update(buf).digest("hex");
|
|
27
|
+
files.push({
|
|
28
|
+
path: "/" + relPath,
|
|
29
|
+
sha1,
|
|
30
|
+
size: buf.length,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return files;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
console.log("Scanning demo-dist/...");
|
|
38
|
+
const files = walkDir(DIST_DIR);
|
|
39
|
+
const manifest = {
|
|
40
|
+
buildTime: new Date().toISOString(),
|
|
41
|
+
fileCount: files.length,
|
|
42
|
+
totalSize: files.reduce((s, f) => s + f.size, 0),
|
|
43
|
+
files,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
fs.writeFileSync(OUTPUT, JSON.stringify(manifest));
|
|
47
|
+
const manifestSize = Buffer.byteLength(JSON.stringify(manifest));
|
|
48
|
+
console.log(
|
|
49
|
+
`Generated demo-manifest.json: ${files.length} files, ` +
|
|
50
|
+
`total ${(manifest.totalSize / 1024 / 1024).toFixed(1)} MB, ` +
|
|
51
|
+
`manifest ${(manifestSize / 1024).toFixed(1)} KB`
|
|
52
|
+
);
|
package/scripts/init.mjs
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import { existsSync, mkdirSync, copyFileSync, cpSync } from 'fs';
|
|
5
|
+
import { resolve, dirname } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
|
|
11
|
+
// 获取脚本所在目录(npm 包目录)
|
|
12
|
+
const packageDir = resolve(__dirname, '..');
|
|
13
|
+
const cwd = process.cwd();
|
|
14
|
+
|
|
15
|
+
console.log('\n🚀 @lmy54321/design-system 项目初始化\n');
|
|
16
|
+
console.log(`📂 初始化位置: ${cwd}\n`);
|
|
17
|
+
|
|
18
|
+
// ============================================================
|
|
19
|
+
// 步骤 1: 创建 Vite 项目
|
|
20
|
+
// ============================================================
|
|
21
|
+
|
|
22
|
+
console.log('📦 步骤 1/5: 创建 Vite 项目...');
|
|
23
|
+
try {
|
|
24
|
+
execSync('npm create vite@latest . -- --template react-ts --yes', {
|
|
25
|
+
cwd,
|
|
26
|
+
stdio: 'inherit'
|
|
27
|
+
});
|
|
28
|
+
console.log('✅ Vite 项目已创建\n');
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('❌ 创建 Vite 项目失败');
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ============================================================
|
|
35
|
+
// 步骤 2: 安装依赖(包括设计系统)
|
|
36
|
+
// ============================================================
|
|
37
|
+
|
|
38
|
+
console.log('📦 步骤 2/5: 安装依赖...');
|
|
39
|
+
try {
|
|
40
|
+
execSync('npm install && npm install @lmy54321/design-system tailwindcss @tailwindcss/vite react-router-dom motion', {
|
|
41
|
+
cwd,
|
|
42
|
+
stdio: 'inherit'
|
|
43
|
+
});
|
|
44
|
+
console.log('✅ 依赖安装完成\n');
|
|
45
|
+
} catch (error) {
|
|
46
|
+
console.error('❌ 依赖安装失败');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ============================================================
|
|
51
|
+
// 步骤 3: 复制模板文件(关键!)
|
|
52
|
+
// ============================================================
|
|
53
|
+
|
|
54
|
+
console.log('📂 步骤 3/5: 复制完整模板...');
|
|
55
|
+
try {
|
|
56
|
+
const templateDir = resolve(cwd, 'node_modules/@lmy54321/design-system/template');
|
|
57
|
+
|
|
58
|
+
// 检查模板是否存在
|
|
59
|
+
if (!existsSync(templateDir)) {
|
|
60
|
+
throw new Error(`模板目录不存在: ${templateDir}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 复制 src 目录
|
|
64
|
+
const srcDir = resolve(cwd, 'src');
|
|
65
|
+
const templateSrcDir = resolve(templateDir, 'src');
|
|
66
|
+
if (existsSync(srcDir)) {
|
|
67
|
+
execSync(`rm -rf ${srcDir}`, { shell: true });
|
|
68
|
+
}
|
|
69
|
+
cpSync(templateSrcDir, srcDir, { recursive: true });
|
|
70
|
+
|
|
71
|
+
// 复制配置文件
|
|
72
|
+
const filesToCopy = [
|
|
73
|
+
'index.html',
|
|
74
|
+
'vite.config.ts',
|
|
75
|
+
'tsconfig.json'
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
for (const file of filesToCopy) {
|
|
79
|
+
const src = resolve(templateDir, file);
|
|
80
|
+
const dest = resolve(cwd, file);
|
|
81
|
+
if (existsSync(src)) {
|
|
82
|
+
copyFileSync(src, dest);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// 清理 Vite 自动生成的无关文件
|
|
87
|
+
const filesToRemove = [
|
|
88
|
+
'src/App.css',
|
|
89
|
+
'src/assets/react.svg',
|
|
90
|
+
'public/vite.svg',
|
|
91
|
+
'vite.config.js'
|
|
92
|
+
];
|
|
93
|
+
|
|
94
|
+
for (const file of filesToRemove) {
|
|
95
|
+
const filePath = resolve(cwd, file);
|
|
96
|
+
if (existsSync(filePath)) {
|
|
97
|
+
execSync(`rm -f ${filePath}`, { shell: true });
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
console.log('✅ 模板文件已复制\n');
|
|
102
|
+
} catch (error) {
|
|
103
|
+
console.error('❌ 复制模板失败:', error.message);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ============================================================
|
|
108
|
+
// 步骤 4: 同步规则文件到 .codebuddy/rules
|
|
109
|
+
// ============================================================
|
|
110
|
+
|
|
111
|
+
console.log('📋 步骤 4/5: 同步规则文件...');
|
|
112
|
+
try {
|
|
113
|
+
const rulesDir = resolve(cwd, '.codebuddy/rules');
|
|
114
|
+
const packageRulesDir = resolve(cwd, 'node_modules/@lmy54321/design-system/.codebuddy/rules');
|
|
115
|
+
|
|
116
|
+
// 创建 .codebuddy/rules 目录
|
|
117
|
+
mkdirSync(rulesDir, { recursive: true });
|
|
118
|
+
|
|
119
|
+
// 复制规则文件
|
|
120
|
+
const rulesToCopy = [
|
|
121
|
+
'init-project.mdc',
|
|
122
|
+
'design-system.mdc'
|
|
123
|
+
];
|
|
124
|
+
|
|
125
|
+
for (const rule of rulesToCopy) {
|
|
126
|
+
const src = resolve(packageRulesDir, rule);
|
|
127
|
+
const dest = resolve(rulesDir, rule);
|
|
128
|
+
if (existsSync(src)) {
|
|
129
|
+
copyFileSync(src, dest);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
console.log('✅ 规则文件已同步\n');
|
|
134
|
+
} catch (error) {
|
|
135
|
+
console.error('❌ 规则同步失败:', error.message);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ============================================================
|
|
140
|
+
// 步骤 5: 启动开发服务器
|
|
141
|
+
// ============================================================
|
|
142
|
+
|
|
143
|
+
console.log('🎉 步骤 5/5: 启动开发服务器...\n');
|
|
144
|
+
try {
|
|
145
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━');
|
|
146
|
+
console.log('✨ 项目初始化完成!');
|
|
147
|
+
console.log('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n');
|
|
148
|
+
console.log('🚀 启动开发服务器中...\n');
|
|
149
|
+
|
|
150
|
+
execSync('npm run dev', {
|
|
151
|
+
cwd,
|
|
152
|
+
stdio: 'inherit'
|
|
153
|
+
});
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error('❌ 启动开发服务器失败');
|
|
156
|
+
process.exit(1);
|
|
157
|
+
}
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
2
|
+
import {
|
|
3
|
+
cn,
|
|
4
|
+
Btn,
|
|
5
|
+
Switch,
|
|
6
|
+
Tag,
|
|
7
|
+
Loading,
|
|
8
|
+
SegmentedControl,
|
|
9
|
+
SearchBox,
|
|
10
|
+
Dialog,
|
|
11
|
+
Toast,
|
|
12
|
+
NotificationBar,
|
|
13
|
+
ActionSheet,
|
|
14
|
+
TopToolbar,
|
|
15
|
+
BottomNavigationBar,
|
|
16
|
+
BottomActionButtons,
|
|
17
|
+
DraggablePanel,
|
|
18
|
+
DRAWER_STATES,
|
|
19
|
+
TypographyDocs,
|
|
20
|
+
GridSystemDocs,
|
|
21
|
+
BubbleTip,
|
|
22
|
+
Push,
|
|
23
|
+
EmptyState,
|
|
24
|
+
StatGrid,
|
|
25
|
+
IconGallery,
|
|
26
|
+
CardDemo,
|
|
27
|
+
} from "@lmy54321/design-system";
|
|
25
28
|
|
|
26
29
|
// ============ Color System Data ============
|
|
27
30
|
type ColorToken = {
|