xb-init 1.3.4__tar.gz

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.
Files changed (60) hide show
  1. xb_init-1.3.4/.gitignore +39 -0
  2. xb_init-1.3.4/PKG-INFO +281 -0
  3. xb_init-1.3.4/README.md +252 -0
  4. xb_init-1.3.4/pyproject.toml +62 -0
  5. xb_init-1.3.4/xb/__init__.py +10 -0
  6. xb_init-1.3.4/xb/cli.py +105 -0
  7. xb_init-1.3.4/xb/commands/__init__.py +1 -0
  8. xb_init-1.3.4/xb/commands/build.py +78 -0
  9. xb_init-1.3.4/xb/commands/dev.py +48 -0
  10. xb_init-1.3.4/xb/commands/doctor.py +91 -0
  11. xb_init-1.3.4/xb/commands/init.py +273 -0
  12. xb_init-1.3.4/xb/commands/upgrade.py +63 -0
  13. xb_init-1.3.4/xb/commands/version.py +65 -0
  14. xb_init-1.3.4/xb/templates/backend/api/__init__.py.j2 +3 -0
  15. xb_init-1.3.4/xb/templates/backend/api/config.py.j2 +371 -0
  16. xb_init-1.3.4/xb/templates/backend/api/ports.py.j2 +105 -0
  17. xb_init-1.3.4/xb/templates/backend/backend_build.py.j2 +29 -0
  18. xb_init-1.3.4/xb/templates/backend/main.py.j2 +104 -0
  19. xb_init-1.3.4/xb/templates/backend/managers/__init__.py.j2 +7 -0
  20. xb_init-1.3.4/xb/templates/backend/managers/logger_manager.py.j2 +42 -0
  21. xb_init-1.3.4/xb/templates/backend/managers/path_manager.py.j2 +178 -0
  22. xb_init-1.3.4/xb/templates/backend/managers/sudoers_manager.py.j2 +141 -0
  23. xb_init-1.3.4/xb/templates/backend/requirements.txt.j2 +4 -0
  24. xb_init-1.3.4/xb/templates/configs/global_config.yaml.j2 +4 -0
  25. xb_init-1.3.4/xb/templates/configs/secrets.yaml.example.j2 +3 -0
  26. xb_init-1.3.4/xb/templates/configs/secrets.yaml.j2 +3 -0
  27. xb_init-1.3.4/xb/templates/electron/launcher.js.j2 +153 -0
  28. xb_init-1.3.4/xb/templates/electron/main.js.j2 +139 -0
  29. xb_init-1.3.4/xb/templates/electron/package.json.j2 +65 -0
  30. xb_init-1.3.4/xb/templates/electron/port_diagnostics.js.j2 +187 -0
  31. xb_init-1.3.4/xb/templates/electron/resources/postinst.j2 +183 -0
  32. xb_init-1.3.4/xb/templates/electron/resources/postrm.j2 +115 -0
  33. xb_init-1.3.4/xb/templates/frontend/index.html.j2 +12 -0
  34. xb_init-1.3.4/xb/templates/frontend/package.json.j2 +18 -0
  35. xb_init-1.3.4/xb/templates/frontend/src/App.vue.j2 +67 -0
  36. xb_init-1.3.4/xb/templates/frontend/src/components/ConfigSetup.vue.j2 +254 -0
  37. xb_init-1.3.4/xb/templates/frontend/src/components/DashboardHome.vue.j2 +40 -0
  38. xb_init-1.3.4/xb/templates/frontend/src/components/FileManager.vue.j2 +627 -0
  39. xb_init-1.3.4/xb/templates/frontend/src/components/GitVersionBadge.vue.j2 +306 -0
  40. xb_init-1.3.4/xb/templates/frontend/src/components/RefreshButton.vue.j2 +142 -0
  41. xb_init-1.3.4/xb/templates/frontend/src/main.js.j2 +5 -0
  42. xb_init-1.3.4/xb/templates/frontend/src/style.css.j2 +404 -0
  43. xb_init-1.3.4/xb/templates/frontend/vite.config.js.j2 +49 -0
  44. xb_init-1.3.4/xb/templates/root/.gitignore.j2 +35 -0
  45. xb_init-1.3.4/xb/templates/root/AGENTS.md.j2 +424 -0
  46. xb_init-1.3.4/xb/templates/root/README.md.j2 +155 -0
  47. xb_init-1.3.4/xb/templates/root/build.sh.j2 +156 -0
  48. xb_init-1.3.4/xb/templates/root/dev.sh.j2 +346 -0
  49. xb_init-1.3.4/xb/templates/root/pyproject.toml.j2 +23 -0
  50. xb_init-1.3.4/xb/templates/scripts/example.sh.j2 +3 -0
  51. xb_init-1.3.4/xb/templates/version/hooks/pre-commit.j2 +72 -0
  52. xb_init-1.3.4/xb/templates/version/scripts/gui_version_manager.py.j2 +174 -0
  53. xb_init-1.3.4/xb/templates/version/scripts/install_hooks.sh.j2 +82 -0
  54. xb_init-1.3.4/xb/templates/version/scripts/version_manager.py.j2 +111 -0
  55. xb_init-1.3.4/xb/templates/version/scripts/web_version_manager.py.j2 +241 -0
  56. xb_init-1.3.4/xb/utils/__init__.py +1 -0
  57. xb_init-1.3.4/xb/utils/click_helpers.py +96 -0
  58. xb_init-1.3.4/xb/utils/template_engine.py +267 -0
  59. xb_init-1.3.4/xb/utils/validators.py +8 -0
  60. xb_init-1.3.4/xb/utils/version_check.py +190 -0
@@ -0,0 +1,39 @@
1
+ # Python
2
+ __pycache__/
3
+ *.pyc
4
+ *.pyo
5
+ *.pyd
6
+ .Python
7
+ *.so
8
+ *.egg
9
+ *.egg-info/
10
+ dist/
11
+ build/
12
+ .eggs/
13
+
14
+ # Virtual environments
15
+ .venv/
16
+ venv/
17
+ ENV/
18
+ env/
19
+
20
+ # uv
21
+ .uv/
22
+ uv.lock
23
+
24
+ # IDE
25
+ .vscode/
26
+ .idea/
27
+ *.swp
28
+ *.swo
29
+ .DS_Store
30
+
31
+ # Testing
32
+ .pytest_cache/
33
+ .coverage
34
+ htmlcov/
35
+
36
+ # Local dev
37
+ *.log
38
+ .env
39
+ .env.local
xb_init-1.3.4/PKG-INFO ADDED
@@ -0,0 +1,281 @@
1
+ Metadata-Version: 2.4
2
+ Name: xb-init
3
+ Version: 1.3.4
4
+ Summary: Project management tool for UV + FastAPI + Vue3 + Electron desktop applications
5
+ Project-URL: Homepage, https://github.com/yourusername/xb
6
+ Project-URL: Documentation, https://github.com/yourusername/xb#readme
7
+ Project-URL: Repository, https://github.com/yourusername/xb.git
8
+ Project-URL: Issues, https://github.com/yourusername/xb/issues
9
+ Author-email: XB Team <xb@example.com>
10
+ License: MIT
11
+ Keywords: cli,electron,fastapi,project-management,vue3
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Build Tools
18
+ Requires-Python: >=3.12
19
+ Requires-Dist: click>=8.1.0
20
+ Requires-Dist: jinja2>=3.1.0
21
+ Requires-Dist: pillow>=10.0.0
22
+ Requires-Dist: pyyaml>=6.0
23
+ Requires-Dist: rich>=13.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: black>=23.0; extra == 'dev'
26
+ Requires-Dist: pytest>=7.0; extra == 'dev'
27
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # xb - 前后端打包构建工具
31
+
32
+ **xb**(PyPI: `xb-init`)是一个基于 `uv` 又类似 `uv` 的项目管理工具,专为快速初始化 **UV + FastAPI + Vue3 + Electron** 桌面应用而生。一条命令拉起完整工程脚手架,开发、构建、版本管理一站式搞定。
33
+
34
+ ## 核心特性
35
+
36
+ - 一键初始化完整项目结构(`xb init myapp`)
37
+ - UV + FastAPI + Vue3 + Electron 开箱即用
38
+ - 自动 `git init` 并提交首个 commit
39
+ - 自动生成 `AGENTS.md`(AI 编码助手协作约定)
40
+ - 可选 sudo 免密配置(`--sudoers`)
41
+ - 可选自定义应用图标(`--icon`)
42
+ - 内置开发、构建、版本管理命令
43
+ - 自动版本检查与一键升级(`xb upgrade`)
44
+ - 环境诊断(`xb doctor`)
45
+ - DEB 安装钩子(postinst / postrm)
46
+
47
+ ## 安装
48
+
49
+ ```bash
50
+ # 安装 uv(若已有可跳过)
51
+ curl -LsSf https://astral.sh/uv/install.sh | sh
52
+
53
+ # 方式一:从 PyPI 安装(推荐)
54
+ uv tool install xb-init
55
+
56
+ # 方式二:从源码安装
57
+ cd xb
58
+ uv sync
59
+ uv tool install .
60
+
61
+ # 验证
62
+ xb --help
63
+ ```
64
+
65
+ ## 快速开始
66
+
67
+ ```bash
68
+ # 创建项目(自动 git init + 首次 commit)
69
+ xb init myapp
70
+
71
+ # 带 sudo 免密配置
72
+ xb init myapp --sudoers
73
+
74
+ # 带自定义图标
75
+ xb init myapp --icon ~/icons/app.png
76
+
77
+ cd myapp
78
+
79
+ # 启动开发环境
80
+ xb dev
81
+ # 或显式指定动作
82
+ xb dev start
83
+
84
+ # 查看状态
85
+ xb dev status
86
+
87
+ # 停止
88
+ xb dev stop
89
+ ```
90
+
91
+ > **`xb init` 自动行为**:
92
+ > - 在目标目录执行 `git init` 并以 `chore: xb init 初始化 <package> 项目` 提交首个 commit
93
+ > - 若检测到 PyPI 有新版 xb,会询问是否先升级再创建项目
94
+ > - 若系统未安装 git 或未配置 `user.name/user.email`,会打印警告但不阻塞项目创建
95
+
96
+ ## 命令一览
97
+
98
+ | 命令 | 说明 |
99
+ |------|------|
100
+ | `xb doctor` | 检查开发环境(Python、uv、Node.js、npm、git、端口) |
101
+ | `xb init <name> [--sudoers] [--icon PATH]` | 初始化项目 |
102
+ | `xb dev [start\|stop\|status]` | 启动/停止/查看开发环境 |
103
+ | `xb build [all\|frontend\|backend\|electron]` | 构建项目 |
104
+ | `xb build -f / -b / -e / -a` | 构建快捷 flag |
105
+ | `xb version [patch\|minor\|major]` | 读取或更新版本号 |
106
+ | `xb --upgrade` | 升级 xb 到 PyPI 最新版本 |
107
+
108
+ ## 构建
109
+
110
+ ```bash
111
+ # 构建所有
112
+ xb build
113
+ xb build all
114
+ xb build -a
115
+
116
+ # 单独构建
117
+ xb build frontend # 或 xb build -f
118
+ xb build backend # 或 xb build -b
119
+ xb build electron # 或 xb build -e
120
+ ```
121
+
122
+ ## 生成的项目结构
123
+
124
+ ```
125
+ myapp/
126
+ ├── pyproject.toml # Python 依赖(uv 管理)
127
+ ├── AGENTS.md # AI 编码助手协作约定
128
+ ├── README.md # 项目说明
129
+ ├── .gitignore
130
+ ├── backend/ # FastAPI 后端
131
+ │ ├── main.py # FastAPI 入口(lifespan / CORS / SPA 兜底)
132
+ │ ├── backend_build.py # PyInstaller 打包脚本
133
+ │ ├── api/
134
+ │ │ ├── __init__.py
135
+ │ │ ├── config.py # /api/config 路由(配置读写)
136
+ │ │ └── ports.py # 端口管理 API
137
+ │ └── managers/
138
+ │ ├── logger_manager.py # 基于 loguru 的统一日志
139
+ │ ├── path_manager.py # 开发/打包态路径切换
140
+ │ └── sudoers_manager.py # 可选,sudo 免密管理
141
+ ├── frontend/ # Vue 3 前端
142
+ │ ├── package.json
143
+ │ ├── vite.config.js
144
+ │ ├── index.html
145
+ │ ├── public/ # 静态资源(含 app-icon.png)
146
+ │ └── src/
147
+ │ ├── main.js
148
+ │ ├── App.vue
149
+ │ ├── style.css
150
+ │ └── components/
151
+ ├── electron/ # Electron 主进程
152
+ │ ├── package.json # electron-builder 配置
153
+ │ ├── main.js # 主进程入口
154
+ │ ├── launcher.js # 后端启动器
155
+ │ ├── port_diagnostics.js # 端口诊断
156
+ │ └── resources/ # icon.png + postinst/postrm 安装钩子
157
+ ├── version/ # 版本管理
158
+ │ ├── hooks/
159
+ │ │ └── pre-commit
160
+ │ └── scripts/
161
+ │ ├── install_hooks.sh
162
+ │ ├── version_manager.py
163
+ │ ├── gui_version_manager.py
164
+ │ └── web_version_manager.py
165
+ ├── configs/ # 配置文件
166
+ │ ├── global_config.yaml
167
+ │ └── secrets.yaml.example
168
+ ├── scripts/ # 可执行脚本
169
+ ├── datas/ # 运行时数据(gitignore)
170
+ │ ├── logs/
171
+ │ ├── pids/
172
+ │ └── reports/
173
+ ├── dev.sh # 开发脚本
174
+ ├── build.sh # 打包脚本
175
+ ├── .git/ # 自动 git init + 首个 commit
176
+ └── .venv # Python 虚拟环境
177
+ ```
178
+
179
+ ## xb 工具自身结构
180
+
181
+ ```
182
+ xb/
183
+ ├── cli.py # CLI 入口(Click + Rich 美化)
184
+ ├── __init__.py # 版本号(从 importlib.metadata 读取)
185
+ ├── commands/ # 子命令实现
186
+ │ ├── init.py # 初始化(含升级检查、图标处理、git init)
187
+ │ ├── dev.py # 开发环境管理
188
+ │ ├── build.py # 构建
189
+ │ ├── version.py # 版本管理
190
+ │ ├── doctor.py # 环境诊断
191
+ │ └── upgrade.py # 升级 xb
192
+ ├── templates/ # Jinja2 项目模板
193
+ │ ├── backend/
194
+ │ ├── frontend/
195
+ │ ├── electron/
196
+ │ ├── configs/
197
+ │ ├── scripts/
198
+ │ ├── version/
199
+ │ └── root/
200
+ └── utils/
201
+ ├── template_engine.py # 模板渲染引擎
202
+ ├── validators.py # 包名校验
203
+ ├── click_helpers.py # 中文化 Help 输出
204
+ └── version_check.py # PyPI 版本检查(24h 缓存 + 异步更新)
205
+ ```
206
+
207
+ ## 版本管理
208
+
209
+ ```bash
210
+ # 查看当前版本
211
+ xb version
212
+
213
+ # 升级版本号
214
+ xb version patch # x.y.z+1
215
+ xb version minor # x.y+1.0
216
+ xb version major # x+1.0.0
217
+ ```
218
+
219
+ ## 配置
220
+
221
+ ### Sudo 免密
222
+
223
+ ```bash
224
+ # 初始化时启用
225
+ xb init myapp --sudoers
226
+
227
+ # 密码存储在 configs/secrets.yaml(自动 gitignore)
228
+ # 建议设置文件权限: chmod 600 configs/secrets.yaml
229
+ ```
230
+
231
+ ### 应用图标
232
+
233
+ ```bash
234
+ # 显式指定图标
235
+ xb init myapp --icon ./my-icon.png
236
+
237
+ # 不指定时自动查找以下约定路径:
238
+ # ./app-icon.png, ./icon.png, ./<package>.png,
239
+ # ./assets/app-icon.png, ./assets/icon.png, ./resources/icon.png
240
+ ```
241
+
242
+ ## 技术栈
243
+
244
+ | 组件 | 技术 | 说明 |
245
+ |------|------|------|
246
+ | 后端 | FastAPI + Uvicorn | 异步高性能 API 框架 |
247
+ | 前端 | Vue 3 + Vite | 现代化响应式框架 |
248
+ | 桌面 | Electron | 跨平台桌面容器 |
249
+ | 构建 | PyInstaller + electron-builder | 后端可执行 + DEB 安装包 |
250
+ | 依赖 | uv | 极速 Python 包管理器 |
251
+ | CLI | Click + Rich | 彩色命令行体验 |
252
+
253
+ ## 环境要求
254
+
255
+ - **Python**: 3.12+
256
+ - **Node.js**: 16+
257
+ - **npm**: 8+
258
+ - **uv**: 已安装
259
+ - **OS**: Linux(仅支持 Ubuntu 及其他基于 Debian 的发行版)
260
+
261
+ 使用 `xb doctor` 可一键检查所有环境依赖。
262
+
263
+ ## 许可证
264
+
265
+ MIT
266
+
267
+ ## 故障排查
268
+
269
+ ```bash
270
+ # 一键环境检查
271
+ xb doctor
272
+
273
+ # 后端启动失败
274
+ cat datas/logs/backend.log
275
+ lsof -i:8000
276
+ .venv/bin/python backend/main.py
277
+
278
+ # 前端启动失败
279
+ cat datas/logs/frontend.log
280
+ cd frontend && rm -rf node_modules && npm install
281
+ ```
@@ -0,0 +1,252 @@
1
+ # xb - 前后端打包构建工具
2
+
3
+ **xb**(PyPI: `xb-init`)是一个基于 `uv` 又类似 `uv` 的项目管理工具,专为快速初始化 **UV + FastAPI + Vue3 + Electron** 桌面应用而生。一条命令拉起完整工程脚手架,开发、构建、版本管理一站式搞定。
4
+
5
+ ## 核心特性
6
+
7
+ - 一键初始化完整项目结构(`xb init myapp`)
8
+ - UV + FastAPI + Vue3 + Electron 开箱即用
9
+ - 自动 `git init` 并提交首个 commit
10
+ - 自动生成 `AGENTS.md`(AI 编码助手协作约定)
11
+ - 可选 sudo 免密配置(`--sudoers`)
12
+ - 可选自定义应用图标(`--icon`)
13
+ - 内置开发、构建、版本管理命令
14
+ - 自动版本检查与一键升级(`xb upgrade`)
15
+ - 环境诊断(`xb doctor`)
16
+ - DEB 安装钩子(postinst / postrm)
17
+
18
+ ## 安装
19
+
20
+ ```bash
21
+ # 安装 uv(若已有可跳过)
22
+ curl -LsSf https://astral.sh/uv/install.sh | sh
23
+
24
+ # 方式一:从 PyPI 安装(推荐)
25
+ uv tool install xb-init
26
+
27
+ # 方式二:从源码安装
28
+ cd xb
29
+ uv sync
30
+ uv tool install .
31
+
32
+ # 验证
33
+ xb --help
34
+ ```
35
+
36
+ ## 快速开始
37
+
38
+ ```bash
39
+ # 创建项目(自动 git init + 首次 commit)
40
+ xb init myapp
41
+
42
+ # 带 sudo 免密配置
43
+ xb init myapp --sudoers
44
+
45
+ # 带自定义图标
46
+ xb init myapp --icon ~/icons/app.png
47
+
48
+ cd myapp
49
+
50
+ # 启动开发环境
51
+ xb dev
52
+ # 或显式指定动作
53
+ xb dev start
54
+
55
+ # 查看状态
56
+ xb dev status
57
+
58
+ # 停止
59
+ xb dev stop
60
+ ```
61
+
62
+ > **`xb init` 自动行为**:
63
+ > - 在目标目录执行 `git init` 并以 `chore: xb init 初始化 <package> 项目` 提交首个 commit
64
+ > - 若检测到 PyPI 有新版 xb,会询问是否先升级再创建项目
65
+ > - 若系统未安装 git 或未配置 `user.name/user.email`,会打印警告但不阻塞项目创建
66
+
67
+ ## 命令一览
68
+
69
+ | 命令 | 说明 |
70
+ |------|------|
71
+ | `xb doctor` | 检查开发环境(Python、uv、Node.js、npm、git、端口) |
72
+ | `xb init <name> [--sudoers] [--icon PATH]` | 初始化项目 |
73
+ | `xb dev [start\|stop\|status]` | 启动/停止/查看开发环境 |
74
+ | `xb build [all\|frontend\|backend\|electron]` | 构建项目 |
75
+ | `xb build -f / -b / -e / -a` | 构建快捷 flag |
76
+ | `xb version [patch\|minor\|major]` | 读取或更新版本号 |
77
+ | `xb --upgrade` | 升级 xb 到 PyPI 最新版本 |
78
+
79
+ ## 构建
80
+
81
+ ```bash
82
+ # 构建所有
83
+ xb build
84
+ xb build all
85
+ xb build -a
86
+
87
+ # 单独构建
88
+ xb build frontend # 或 xb build -f
89
+ xb build backend # 或 xb build -b
90
+ xb build electron # 或 xb build -e
91
+ ```
92
+
93
+ ## 生成的项目结构
94
+
95
+ ```
96
+ myapp/
97
+ ├── pyproject.toml # Python 依赖(uv 管理)
98
+ ├── AGENTS.md # AI 编码助手协作约定
99
+ ├── README.md # 项目说明
100
+ ├── .gitignore
101
+ ├── backend/ # FastAPI 后端
102
+ │ ├── main.py # FastAPI 入口(lifespan / CORS / SPA 兜底)
103
+ │ ├── backend_build.py # PyInstaller 打包脚本
104
+ │ ├── api/
105
+ │ │ ├── __init__.py
106
+ │ │ ├── config.py # /api/config 路由(配置读写)
107
+ │ │ └── ports.py # 端口管理 API
108
+ │ └── managers/
109
+ │ ├── logger_manager.py # 基于 loguru 的统一日志
110
+ │ ├── path_manager.py # 开发/打包态路径切换
111
+ │ └── sudoers_manager.py # 可选,sudo 免密管理
112
+ ├── frontend/ # Vue 3 前端
113
+ │ ├── package.json
114
+ │ ├── vite.config.js
115
+ │ ├── index.html
116
+ │ ├── public/ # 静态资源(含 app-icon.png)
117
+ │ └── src/
118
+ │ ├── main.js
119
+ │ ├── App.vue
120
+ │ ├── style.css
121
+ │ └── components/
122
+ ├── electron/ # Electron 主进程
123
+ │ ├── package.json # electron-builder 配置
124
+ │ ├── main.js # 主进程入口
125
+ │ ├── launcher.js # 后端启动器
126
+ │ ├── port_diagnostics.js # 端口诊断
127
+ │ └── resources/ # icon.png + postinst/postrm 安装钩子
128
+ ├── version/ # 版本管理
129
+ │ ├── hooks/
130
+ │ │ └── pre-commit
131
+ │ └── scripts/
132
+ │ ├── install_hooks.sh
133
+ │ ├── version_manager.py
134
+ │ ├── gui_version_manager.py
135
+ │ └── web_version_manager.py
136
+ ├── configs/ # 配置文件
137
+ │ ├── global_config.yaml
138
+ │ └── secrets.yaml.example
139
+ ├── scripts/ # 可执行脚本
140
+ ├── datas/ # 运行时数据(gitignore)
141
+ │ ├── logs/
142
+ │ ├── pids/
143
+ │ └── reports/
144
+ ├── dev.sh # 开发脚本
145
+ ├── build.sh # 打包脚本
146
+ ├── .git/ # 自动 git init + 首个 commit
147
+ └── .venv # Python 虚拟环境
148
+ ```
149
+
150
+ ## xb 工具自身结构
151
+
152
+ ```
153
+ xb/
154
+ ├── cli.py # CLI 入口(Click + Rich 美化)
155
+ ├── __init__.py # 版本号(从 importlib.metadata 读取)
156
+ ├── commands/ # 子命令实现
157
+ │ ├── init.py # 初始化(含升级检查、图标处理、git init)
158
+ │ ├── dev.py # 开发环境管理
159
+ │ ├── build.py # 构建
160
+ │ ├── version.py # 版本管理
161
+ │ ├── doctor.py # 环境诊断
162
+ │ └── upgrade.py # 升级 xb
163
+ ├── templates/ # Jinja2 项目模板
164
+ │ ├── backend/
165
+ │ ├── frontend/
166
+ │ ├── electron/
167
+ │ ├── configs/
168
+ │ ├── scripts/
169
+ │ ├── version/
170
+ │ └── root/
171
+ └── utils/
172
+ ├── template_engine.py # 模板渲染引擎
173
+ ├── validators.py # 包名校验
174
+ ├── click_helpers.py # 中文化 Help 输出
175
+ └── version_check.py # PyPI 版本检查(24h 缓存 + 异步更新)
176
+ ```
177
+
178
+ ## 版本管理
179
+
180
+ ```bash
181
+ # 查看当前版本
182
+ xb version
183
+
184
+ # 升级版本号
185
+ xb version patch # x.y.z+1
186
+ xb version minor # x.y+1.0
187
+ xb version major # x+1.0.0
188
+ ```
189
+
190
+ ## 配置
191
+
192
+ ### Sudo 免密
193
+
194
+ ```bash
195
+ # 初始化时启用
196
+ xb init myapp --sudoers
197
+
198
+ # 密码存储在 configs/secrets.yaml(自动 gitignore)
199
+ # 建议设置文件权限: chmod 600 configs/secrets.yaml
200
+ ```
201
+
202
+ ### 应用图标
203
+
204
+ ```bash
205
+ # 显式指定图标
206
+ xb init myapp --icon ./my-icon.png
207
+
208
+ # 不指定时自动查找以下约定路径:
209
+ # ./app-icon.png, ./icon.png, ./<package>.png,
210
+ # ./assets/app-icon.png, ./assets/icon.png, ./resources/icon.png
211
+ ```
212
+
213
+ ## 技术栈
214
+
215
+ | 组件 | 技术 | 说明 |
216
+ |------|------|------|
217
+ | 后端 | FastAPI + Uvicorn | 异步高性能 API 框架 |
218
+ | 前端 | Vue 3 + Vite | 现代化响应式框架 |
219
+ | 桌面 | Electron | 跨平台桌面容器 |
220
+ | 构建 | PyInstaller + electron-builder | 后端可执行 + DEB 安装包 |
221
+ | 依赖 | uv | 极速 Python 包管理器 |
222
+ | CLI | Click + Rich | 彩色命令行体验 |
223
+
224
+ ## 环境要求
225
+
226
+ - **Python**: 3.12+
227
+ - **Node.js**: 16+
228
+ - **npm**: 8+
229
+ - **uv**: 已安装
230
+ - **OS**: Linux(仅支持 Ubuntu 及其他基于 Debian 的发行版)
231
+
232
+ 使用 `xb doctor` 可一键检查所有环境依赖。
233
+
234
+ ## 许可证
235
+
236
+ MIT
237
+
238
+ ## 故障排查
239
+
240
+ ```bash
241
+ # 一键环境检查
242
+ xb doctor
243
+
244
+ # 后端启动失败
245
+ cat datas/logs/backend.log
246
+ lsof -i:8000
247
+ .venv/bin/python backend/main.py
248
+
249
+ # 前端启动失败
250
+ cat datas/logs/frontend.log
251
+ cd frontend && rm -rf node_modules && npm install
252
+ ```
@@ -0,0 +1,62 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "xb-init"
7
+ version = "1.3.4"
8
+ description = "Project management tool for UV + FastAPI + Vue3 + Electron desktop applications"
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = {text = "MIT"}
12
+ authors = [
13
+ {name = "XB Team", email = "xb@example.com"}
14
+ ]
15
+ keywords = ["electron", "fastapi", "vue3", "project-management", "cli"]
16
+ classifiers = [
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Topic :: Software Development :: Build Tools",
23
+ ]
24
+
25
+ dependencies = [
26
+ "click>=8.1.0",
27
+ "jinja2>=3.1.0",
28
+ "pillow>=10.0.0",
29
+ "pyyaml>=6.0",
30
+ "rich>=13.0.0",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ dev = [
35
+ "pytest>=7.0",
36
+ "black>=23.0",
37
+ "ruff>=0.1.0",
38
+ ]
39
+
40
+ [project.scripts]
41
+ xb = "xb.cli:main"
42
+
43
+ [project.urls]
44
+ Homepage = "https://github.com/yourusername/xb"
45
+ Documentation = "https://github.com/yourusername/xb#readme"
46
+ Repository = "https://github.com/yourusername/xb.git"
47
+ Issues = "https://github.com/yourusername/xb/issues"
48
+
49
+ [tool.hatch.build.targets.wheel]
50
+ packages = ["xb"]
51
+
52
+ [tool.black]
53
+ line-length = 100
54
+ target-version = ['py310']
55
+
56
+ [tool.ruff]
57
+ line-length = 100
58
+ target-version = "py310"
59
+
60
+ [tool.ruff.lint]
61
+ select = ["E", "F", "I", "N", "W", "B"]
62
+ ignore = ["E501"]
@@ -0,0 +1,10 @@
1
+ """
2
+ xb - Project management tool for UV + FastAPI + Vue3 + Electron desktop applications
3
+ """
4
+
5
+ from importlib.metadata import PackageNotFoundError, version as _get_version
6
+
7
+ try:
8
+ __version__ = _get_version("xb-init")
9
+ except PackageNotFoundError:
10
+ __version__ = "0.0.0+unknown"