@mico_fe/ftc-plugin 0.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/install.sh ADDED
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ # 颜色输出
6
+ RED='\033[0;31m'
7
+ GREEN='\033[0;32m'
8
+ YELLOW='\033[1;33m'
9
+ BLUE='\033[0;34m'
10
+ NC='\033[0m' # No Color
11
+
12
+ # 配置
13
+ PACKAGE_NAME="@mico_fe/ftc-plugin"
14
+ INSTALL_DIR="$HOME/figma-to-code-plugin"
15
+ TMP_DIR="/tmp/figma-to-code-plugin-install"
16
+ FORCE_INSTALL=false
17
+
18
+ # 打印带颜色的消息
19
+ print_message() {
20
+ local color=$1
21
+ local message=$2
22
+ echo -e "${color}${message}${NC}"
23
+ }
24
+
25
+ # 检查命令是否存在
26
+ command_exists() {
27
+ command -v "$1" >/dev/null 2>&1
28
+ }
29
+
30
+ # 清理临时文件
31
+ cleanup() {
32
+ if [ -d "$TMP_DIR" ]; then
33
+ print_message "$BLUE" "🧹 清理临时文件..."
34
+ rm -rf "$TMP_DIR"
35
+ fi
36
+ }
37
+
38
+ # 错误处理
39
+ error_exit() {
40
+ print_message "$RED" "❌ 错误: $1"
41
+ cleanup
42
+ exit 1
43
+ }
44
+
45
+ # 主安装函数
46
+ main() {
47
+ # 解析命令行参数
48
+ while [[ $# -gt 0 ]]; do
49
+ case $1 in
50
+ -y|--yes|--force)
51
+ FORCE_INSTALL=true
52
+ shift
53
+ ;;
54
+ -h|--help)
55
+ print_message "$BLUE" "使用方法: $0 [选项]"
56
+ print_message "$BLUE" "选项:"
57
+ print_message "$BLUE" " -y, --yes, --force 跳过确认,强制覆盖安装"
58
+ print_message "$BLUE" " -h, --help 显示此帮助信息"
59
+ exit 0
60
+ ;;
61
+ *)
62
+ print_message "$YELLOW" "未知选项: $1"
63
+ shift
64
+ ;;
65
+ esac
66
+ done
67
+
68
+ print_message "$GREEN" "╔══════════════════════════════════════════════════╗"
69
+ print_message "$GREEN" "║ Figma to Code Plugin 安装脚本 ║"
70
+ print_message "$GREEN" "╚══════════════════════════════════════════════════╝"
71
+ echo ""
72
+
73
+ # 检查必要的命令
74
+ print_message "$BLUE" "🔍 检查系统依赖..."
75
+ if ! command_exists curl && ! command_exists wget; then
76
+ error_exit "需要 curl 或 wget 命令"
77
+ fi
78
+
79
+ if ! command_exists tar; then
80
+ error_exit "需要 tar 命令"
81
+ fi
82
+
83
+ # 创建临时目录
84
+ print_message "$BLUE" "📁 创建临时目录..."
85
+ mkdir -p "$TMP_DIR"
86
+
87
+ # 获取最新版本信息
88
+ print_message "$BLUE" "🔎 获取最新版本信息..."
89
+ local registry_url="https://registry.npmjs.org/${PACKAGE_NAME}"
90
+
91
+ if command_exists curl; then
92
+ PACKAGE_INFO=$(curl -sL "$registry_url")
93
+ else
94
+ PACKAGE_INFO=$(wget -qO- "$registry_url")
95
+ fi
96
+
97
+ if [ -z "$PACKAGE_INFO" ]; then
98
+ error_exit "无法获取包信息"
99
+ fi
100
+
101
+ # 解析最新版本号和下载地址
102
+ LATEST_VERSION=$(echo "$PACKAGE_INFO" | grep -o '"latest":"[^"]*"' | sed 's/"latest":"\(.*\)"/\1/')
103
+ TARBALL_URL="https://registry.npmjs.org/@mico_fe/ftc-plugin/-/ftc-plugin-${LATEST_VERSION}.tgz"
104
+
105
+ if [ -z "$TARBALL_URL" ]; then
106
+ error_exit "无法获取下载地址"
107
+ fi
108
+
109
+ print_message "$GREEN" "📦 最新版本: $LATEST_VERSION"
110
+ print_message "$BLUE" "⬇️ 下载包文件..."
111
+
112
+ # 下载包
113
+ local tarball_file="$TMP_DIR/package.tgz"
114
+ if command_exists curl; then
115
+ curl -L "$TARBALL_URL" -o "$tarball_file" --progress-bar || error_exit "下载失败"
116
+ else
117
+ wget --show-progress -O "$tarball_file" "$TARBALL_URL" || error_exit "下载失败"
118
+ fi
119
+
120
+ # 检查安装目录
121
+ if [ -d "$INSTALL_DIR" ]; then
122
+ print_message "$YELLOW" "⚠️ 检测到已存在的安装目录: $INSTALL_DIR"
123
+
124
+ if [ "$FORCE_INSTALL" = true ]; then
125
+ print_message "$BLUE" "💪 强制覆盖安装模式"
126
+ rm -rf "$INSTALL_DIR"
127
+ else
128
+ # 使用 /dev/tty 来确保即使通过管道执行也能读取用户输入
129
+ if [ -t 0 ]; then
130
+ # 标准输入是终端
131
+ read -p "是否覆盖安装? (y/N): " -n 1 -r
132
+ echo
133
+ else
134
+ # 标准输入不是终端(通过管道),从 /dev/tty 读取
135
+ read -p "是否覆盖安装? (y/N): " -n 1 -r < /dev/tty
136
+ echo
137
+ fi
138
+
139
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
140
+ print_message "$YELLOW" "取消安装"
141
+ cleanup
142
+ exit 0
143
+ fi
144
+ rm -rf "$INSTALL_DIR"
145
+ fi
146
+ fi
147
+
148
+ # 创建安装目录
149
+ print_message "$BLUE" "📂 创建安装目录..."
150
+ mkdir -p "$INSTALL_DIR"
151
+
152
+ # 解压包
153
+ print_message "$BLUE" "📦 解压文件到 $INSTALL_DIR..."
154
+ tar -xzf "$tarball_file" -C "$TMP_DIR" || error_exit "解压失败"
155
+
156
+ # 移动文件到安装目录(npm包解压后在package子目录)
157
+ if [ -d "$TMP_DIR/package" ]; then
158
+ cp -r "$TMP_DIR/package/"* "$INSTALL_DIR/" || error_exit "移动文件失败"
159
+ else
160
+ cp -r "$TMP_DIR/"* "$INSTALL_DIR/" || error_exit "移动文件失败"
161
+ fi
162
+
163
+ # 清理临时文件
164
+ cleanup
165
+
166
+ # 安装成功
167
+ echo ""
168
+ print_message "$GREEN" "✅ 安装成功!"
169
+ print_message "$GREEN" "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
170
+ print_message "$BLUE" "📍 安装位置: $INSTALL_DIR"
171
+ print_message "$BLUE" "📌 版本: $LATEST_VERSION"
172
+ echo ""
173
+ print_message "$YELLOW" "📝 使用说明:"
174
+ print_message "$YELLOW" " 1. 打开 Figma 桌面应用"
175
+ print_message "$YELLOW" " 2. 进入 Plugins > Development > Import plugin from manifest"
176
+ print_message "$YELLOW" " 3. 选择文件: $INSTALL_DIR/manifest.json"
177
+ }
178
+
179
+ # 捕获退出信号,确保清理
180
+ trap cleanup EXIT
181
+
182
+ # 执行主函数
183
+ main "$@"
184
+
package/manifest.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "MFTC",
3
+ "id": "942138313887142055324",
4
+ "api": "1.0.0",
5
+ "main": "dist/code.js",
6
+ "ui": "dist/index.html",
7
+ "editorType": ["figma", "dev"],
8
+ "capabilities": ["inspect", "vscode"],
9
+ "permissions": [],
10
+ "documentAccess": "dynamic-page",
11
+ "networkAccess": {
12
+ "allowedDomains": [
13
+ "http://localhost:17482",
14
+ "http://localhost:17483",
15
+ "http://localhost:17484",
16
+ "http://localhost:17485",
17
+ "http://localhost:17486"
18
+ ],
19
+ "reasoning": "Connects to user's local Bridge service for design-to-code workflow."
20
+ }
21
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@mico_fe/ftc-plugin",
3
+ "version": "0.2.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "files": [
8
+ "dist",
9
+ "manifest.json",
10
+ "README.md",
11
+ "install.sh",
12
+ "uninstall.sh"
13
+ ],
14
+ "scripts": {
15
+ "prepublishOnly": "npm run build",
16
+ "build": "npm run build:ui:prod && npm run build:main:prod --minify --tree-shaking=true",
17
+ "build:main:prod": "esbuild plugin-src/code.ts --bundle --target=ES6 --outfile=dist/code.js",
18
+ "build:ui:prod": "vite build --minify esbuild --emptyOutDir=false --mode production",
19
+ "build:watch": "concurrently -n pluginMain,ui \"npm run build:main:prod --watch\" \"npm run build:ui:prod --watch\"",
20
+ "lint": "eslint plugin-src ui-src",
21
+ "lint:fix": "eslint plugin-src ui-src --fix"
22
+ },
23
+ "dependencies": {
24
+ "@mico/figma-to-code-plugin-main": "workspace:*",
25
+ "@mico/figma-to-code-plugin-ui": "workspace:*",
26
+ "@mico/figma-to-code-types": "workspace:*",
27
+ "@figma/plugin-typings": "^1.114.0",
28
+ "antd": "^6.0.0",
29
+ "clsx": "^2.1.1",
30
+ "copy-to-clipboard": "^3.3.3",
31
+ "lucide-react": "^0.483.0",
32
+ "motion": "^12.19.1",
33
+ "nanoid": "^5.1.5",
34
+ "react": "19.1.0",
35
+ "react-dom": "19.1.0",
36
+ "tailwind-merge": "^3.3.1"
37
+ },
38
+ "devDependencies": {
39
+ "@mico/eslint-config": "^0.0.1",
40
+ "@mico/tsconfig": "^0.0.1",
41
+ "@tailwindcss/postcss": "^4.1.11",
42
+ "@types/node": "^24.0.0",
43
+ "@types/react": "^19.1.8",
44
+ "@types/react-dom": "^19.1.6",
45
+ "@vitejs/plugin-react": "^4.6.0",
46
+ "@vitejs/plugin-react-swc": "^3.10.2",
47
+ "concurrently": "^9.2.0",
48
+ "esbuild": "^0.25.5",
49
+ "eslint": "^10.2.1",
50
+ "eslint-plugin-react-hooks": "^5.2.0",
51
+ "eslint-plugin-react-refresh": "^0.4.20",
52
+ "postcss": "^8.5.6",
53
+ "tailwindcss": "4.0.14",
54
+ "typescript": "^6.0.0",
55
+ "vite": "^5.4.19",
56
+ "vite-plugin-singlefile": "^2.2.0"
57
+ }
58
+ }
package/uninstall.sh ADDED
@@ -0,0 +1,114 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ # 颜色输出
6
+ RED='\033[0;31m'
7
+ GREEN='\033[0;32m'
8
+ YELLOW='\033[1;33m'
9
+ BLUE='\033[0;34m'
10
+ NC='\033[0m' # No Color
11
+
12
+ # 配置
13
+ INSTALL_DIR="$HOME/figma-to-code-plugin"
14
+ FORCE_UNINSTALL=false
15
+
16
+ # 打印带颜色的消息
17
+ print_message() {
18
+ local color=$1
19
+ local message=$2
20
+ echo -e "${color}${message}${NC}"
21
+ }
22
+
23
+ # 主卸载函数
24
+ main() {
25
+ # 解析命令行参数
26
+ while [[ $# -gt 0 ]]; do
27
+ case $1 in
28
+ -y|--yes|--force)
29
+ FORCE_UNINSTALL=true
30
+ shift
31
+ ;;
32
+ -h|--help)
33
+ print_message "$BLUE" "使用方法: $0 [选项]"
34
+ print_message "$BLUE" "选项:"
35
+ print_message "$BLUE" " -y, --yes, --force 跳过确认,强制卸载"
36
+ print_message "$BLUE" " -h, --help 显示此帮助信息"
37
+ exit 0
38
+ ;;
39
+ *)
40
+ print_message "$YELLOW" "未知选项: $1"
41
+ shift
42
+ ;;
43
+ esac
44
+ done
45
+
46
+ print_message "$BLUE" "╔══════════════════════════════════════════════════╗"
47
+ print_message "$BLUE" "║ Figma to Code Plugin 卸载脚本 ║"
48
+ print_message "$BLUE" "╚══════════════════════════════════════════════════╝"
49
+ echo ""
50
+
51
+ # 检查安装目录是否存在
52
+ if [ ! -d "$INSTALL_DIR" ]; then
53
+ print_message "$YELLOW" "⚠️ 未找到安装目录: $INSTALL_DIR"
54
+ print_message "$YELLOW" "插件可能已经被卸载或未安装。"
55
+ exit 0
56
+ fi
57
+
58
+ # 显示将要删除的内容
59
+ print_message "$YELLOW" "📍 安装目录: $INSTALL_DIR"
60
+ echo ""
61
+ print_message "$YELLOW" "将要删除以下内容:"
62
+ ls -lh "$INSTALL_DIR" 2>/dev/null | tail -n +2 | while read line; do
63
+ echo " $line"
64
+ done
65
+ echo ""
66
+
67
+ # 确认卸载
68
+ if [ "$FORCE_UNINSTALL" = true ]; then
69
+ print_message "$BLUE" "💪 强制卸载模式"
70
+ else
71
+ # 使用 /dev/tty 来确保即使通过管道执行也能读取用户输入
72
+ if [ -t 0 ]; then
73
+ # 标准输入是终端
74
+ read -p "$(echo -e ${RED}确认卸载 Figma to Code Plugin? \(y/N\): ${NC})" -n 1 -r
75
+ echo
76
+ else
77
+ # 标准输入不是终端(通过管道),从 /dev/tty 读取
78
+ read -p "$(echo -e ${RED}确认卸载 Figma to Code Plugin? \(y/N\): ${NC})" -n 1 -r < /dev/tty
79
+ echo
80
+ fi
81
+
82
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
83
+ print_message "$BLUE" "取消卸载"
84
+ exit 0
85
+ fi
86
+ fi
87
+
88
+ # 删除安装目录
89
+ print_message "$BLUE" "🗑️ 删除安装目录..."
90
+ rm -rf "$INSTALL_DIR"
91
+
92
+ # 验证删除
93
+ if [ -d "$INSTALL_DIR" ]; then
94
+ print_message "$RED" "❌ 卸载失败: 无法删除目录 $INSTALL_DIR"
95
+ exit 1
96
+ fi
97
+
98
+ # 卸载成功
99
+ echo ""
100
+ print_message "$GREEN" "✅ 卸载成功!"
101
+ print_message "$GREEN" "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
102
+ echo ""
103
+ print_message "$YELLOW" "📝 提示:"
104
+ print_message "$YELLOW" " 请在 Figma 中手动移除插件:"
105
+ print_message "$YELLOW" " Plugins > Development > Remove plugin"
106
+ echo ""
107
+ print_message "$GREEN" "如需重新安装,请运行:"
108
+ print_message "$BLUE" " curl -fsSL https://unpkg.com/@mico_fe/ftc-plugin@latest/install.sh | bash"
109
+ echo ""
110
+ }
111
+
112
+ # 执行主函数
113
+ main "$@"
114
+