@luxkit/cli 1.0.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.
Files changed (3) hide show
  1. package/README.md +323 -0
  2. package/dist/index.js +2011 -0
  3. package/package.json +56 -0
package/README.md ADDED
@@ -0,0 +1,323 @@
1
+ <div align="center">
2
+
3
+ # lux
4
+
5
+ **One-click project formatting & VSCode config CLI**
6
+
7
+ [![npm version](https://img.shields.io/badge/version-1.0.0-blue.svg)](https://github.com/TTT1231/lux)
8
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18-green.svg)](https://nodejs.org/)
9
+ [![License: ISC](https://img.shields.io/badge/license-ISC-purple.svg)](https://opensource.org/licenses/ISC)
10
+ [![TypeScript](https://img.shields.io/badge/TypeScript-6.0-3178C6.svg)](https://www.typescriptlang.org/)
11
+ [![ESM Only](https://img.shields.io/badge/ESM-only-F7DF1E.svg)](https://nodejs.org/api/esm.html)
12
+
13
+ <br />
14
+
15
+ <a href="#-english">English</a> | <a href="#-中文">中文</a>
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ <br />
22
+
23
+ ## 🇬🇧 English
24
+
25
+ <br />
26
+
27
+ ### What is lux?
28
+
29
+ `lux` is a CLI tool that initializes project formatting configs and VSCode workspace settings with a single command. It generates ESLint, Prettier, Stylelint, CSpell, EditorConfig files and VSCode settings from battle-tested presets — with smart merge and conflict resolution.
30
+
31
+ <br />
32
+
33
+ ### ✨ Key Highlights
34
+
35
+ | Feature | Description |
36
+ |:--------|:------------|
37
+ | 🎯 **One Command Setup** | `lux fmt init web` generates all linting & formatting configs instantly |
38
+ | 🔧 **5 Fmt Presets** | `web` · `electron` · `uniapp` · `node` · `nest` — each with curated rules |
39
+ | 🖥️ **6 VSCode Presets** | `web` · `electron` · `uniapp` · `node` · `nest` · `go` — settings + extensions |
40
+ | 🔀 **Smart Merge** | Preset wins for linting keys; user wins for personal preferences |
41
+ | 🛡️ **Conflict Resolution** | `neverOverwrite` / `forceOverwrite` lists + `--force` flag |
42
+ | 📦 **Auto Install** | Detects bun / pnpm / yarn / npm and installs devDependencies |
43
+ | 🔍 **Fuzzy Matching** | Typo a preset name? Levenshtein distance finds the closest match |
44
+ | 🧪 **Dry Run** | Preview all changes with `--dry-run` before writing anything |
45
+ | 🔗 **Script Injection** | Auto-injects `<pm> lint` / `<pm> format` scripts into package.json |
46
+
47
+ <br />
48
+
49
+ ### Quick Start
50
+
51
+ ```bash
52
+ # Install globally (pick your package manager)
53
+ npm install -g lux
54
+ # or
55
+ bun add -g lux
56
+
57
+ # Initialize formatting configs
58
+ lux fmt init web # Generate ESLint, Prettier, Stylelint, CSpell, EditorConfig
59
+
60
+ # Initialize VSCode settings
61
+ lux vscode init web # Generate .vscode/settings.json + extensions.json
62
+
63
+ # List available presets
64
+ lux fmt list
65
+ lux vscode list
66
+ ```
67
+
68
+ <br />
69
+
70
+ ### CLI Commands
71
+
72
+ | Command | Description |
73
+ |:--------|:------------|
74
+ | `lux fmt init <preset>` | Initialize formatting config files |
75
+ | `lux fmt list` | List available fmt presets |
76
+ | `lux vscode init <preset>` | Initialize VSCode workspace settings |
77
+ | `lux vscode list` | List available VSCode presets |
78
+ | `lux vpn cmd` | Copy CMD proxy env-vars to clipboard |
79
+ | `lux vpn pw` | Copy PowerShell proxy env-vars to clipboard |
80
+
81
+ <br />
82
+
83
+ ### Available Presets
84
+
85
+ | Preset | Fmt | VSCode | Stack |
86
+ |:-------|:---:|:------:|:------|
87
+ | `web` | ✅ | ✅ | Vue / React / TS / CSS |
88
+ | `electron` | ✅ | ✅ | Electron + Web stack |
89
+ | `uniapp` | ✅ | ✅ | UniApp / WeChat Mini Program |
90
+ | `node` | ✅ | ✅ | Node.js backend |
91
+ | `nest` | ✅ | ✅ | NestJS backend |
92
+ | `go` | — | ✅ | Go backend |
93
+
94
+ <br />
95
+
96
+ ### Options
97
+
98
+ ```bash
99
+ lux fmt init <preset> [options]
100
+
101
+ --force Force overwrite existing files
102
+ --no-install Skip dependency installation
103
+ --dry-run Preview without writing files
104
+ ```
105
+
106
+ <br />
107
+
108
+ ### How It Works
109
+
110
+ ```
111
+ lux fmt init web
112
+
113
+
114
+ Parse CLI args ──► Resolve preset (fuzzy match on typo)
115
+
116
+
117
+ For each config file:
118
+
119
+ ├── File not found? ──► Create
120
+ ├── In neverOverwrite? ──► Skip
121
+ ├── In forceOverwrite? ──► Overwrite
122
+ └── Exists + --force? ──► Overwrite / Skip
123
+
124
+
125
+ Inject scripts into package.json (<pm> → bun run / pnpm run / ...)
126
+
127
+
128
+ Auto-install devDependencies (detects lockfile)
129
+ ```
130
+
131
+ <br />
132
+
133
+ ### Tech Stack
134
+
135
+ | Category | Technology |
136
+ |:---------|:-----------|
137
+ | Language | TypeScript 6.0 (ESM-only) |
138
+ | Runtime | Node.js 18+ |
139
+ | Build | tsup |
140
+ | Test | Vitest (unit + acceptance) |
141
+ | CLI | Commander.js |
142
+ | Output | Chalk |
143
+ | Bundle | Zero runtime deps (chalk + commander only) |
144
+
145
+ <br />
146
+
147
+ ### Development
148
+
149
+ ```bash
150
+ git clone git@github.com:TTT1231/lux.git
151
+ cd lux
152
+ bun install
153
+
154
+ bun link # Register `lux` globally for testing
155
+ lux fmt init web # Test it on any project
156
+
157
+ bun test # Run tests
158
+ bun build # Build to dist/
159
+ bun code:check:all # lint + format + spell check
160
+ ```
161
+
162
+ <br />
163
+
164
+ ### 📄 License
165
+
166
+ [ISC](https://opensource.org/licenses/ISC) — Free to use, modify, and distribute.
167
+
168
+ <br />
169
+
170
+ <p align="right"><a href="#-中文">切换到中文 →</a></p>
171
+
172
+ ---
173
+
174
+ <br />
175
+
176
+ ## 🇨🇳 中文
177
+
178
+ <br />
179
+
180
+ ### lux 是什么?
181
+
182
+ `lux` 是一个 CLI 工具,只需一条命令即可初始化项目格式化配置和 VSCode 工作区设置。它从经过实战检验的预设中生成 ESLint、Prettier、Stylelint、CSpell、EditorConfig 配置文件以及 VSCode 设置 —— 并带有智能合并和冲突解决机制。
183
+
184
+ <br />
185
+
186
+ ### ✨ 核心亮点
187
+
188
+ | 特性 | 说明 |
189
+ |:-----|:-----|
190
+ | 🎯 **一键配置** | `lux fmt init web` 即可生成所有 lint 与格式化配置 |
191
+ | 🔧 **5 种格式化预设** | `web` · `electron` · `uniapp` · `node` · `nest` — 各配备精选规则 |
192
+ | 🖥️ **6 种 VSCode 预设** | `web` · `electron` · `uniapp` · `node` · `nest` · `go` — 设置 + 扩展推荐 |
193
+ | 🔀 **智能合并** | 预设优先覆盖 linting 相关键;用户配置优先保留个人偏好 |
194
+ | 🛡️ **冲突解决** | `neverOverwrite` / `forceOverwrite` 列表 + `--force` 标志 |
195
+ | 📦 **自动安装** | 自动检测 bun / pnpm / yarn / npm 并安装 devDependencies |
196
+ | 🔍 **模糊匹配** | 预设名拼错了?Levenshtein 距离帮你找到最接近的匹配 |
197
+ | 🧪 **Dry Run** | 使用 `--dry-run` 预览所有变更,不写入任何文件 |
198
+ | 🔗 **脚本注入** | 自动将 `<pm> lint` / `<pm> format` 脚本注入 package.json |
199
+
200
+ <br />
201
+
202
+ ### 快速开始
203
+
204
+ ```bash
205
+ # 全局安装(选择你的包管理器)
206
+ npm install -g lux
207
+ # 或
208
+ bun add -g lux
209
+
210
+ # 初始化格式化配置
211
+ lux fmt init web # 生成 ESLint、Prettier、Stylelint、CSpell、EditorConfig
212
+
213
+ # 初始化 VSCode 设置
214
+ lux vscode init web # 生成 .vscode/settings.json + extensions.json
215
+
216
+ # 查看可用预设
217
+ lux fmt list
218
+ lux vscode list
219
+ ```
220
+
221
+ <br />
222
+
223
+ ### CLI 命令
224
+
225
+ | 命令 | 说明 |
226
+ |:-----|:-----|
227
+ | `lux fmt init <preset>` | 初始化格式化配置文件 |
228
+ | `lux fmt list` | 列出可用的格式化预设 |
229
+ | `lux vscode init <preset>` | 初始化 VSCode 工作区设置 |
230
+ | `lux vscode list` | 列出可用的 VSCode 预设 |
231
+ | `lux vpn cmd` | 复制 CMD 代理环境变量到剪贴板 |
232
+ | `lux vpn pw` | 复制 PowerShell 代理环境变量到剪贴板 |
233
+
234
+ <br />
235
+
236
+ ### 可用预设
237
+
238
+ | 预设 | 格式化 | VSCode | 技术栈 |
239
+ |:-----|:------:|:------:|:-------|
240
+ | `web` | ✅ | ✅ | Vue / React / TS / CSS |
241
+ | `electron` | ✅ | ✅ | Electron + Web 技术栈 |
242
+ | `uniapp` | ✅ | ✅ | UniApp / 微信小程序 |
243
+ | `node` | ✅ | ✅ | Node.js 后端 |
244
+ | `nest` | ✅ | ✅ | NestJS 后端 |
245
+ | `go` | — | ✅ | Go 后端 |
246
+
247
+ <br />
248
+
249
+ ### 命令选项
250
+
251
+ ```bash
252
+ lux fmt init <preset> [options]
253
+
254
+ --force 强制覆盖已有文件
255
+ --no-install 跳过依赖安装
256
+ --dry-run 预览模式,不写入文件
257
+ ```
258
+
259
+ <br />
260
+
261
+ ### 工作原理
262
+
263
+ ```
264
+ lux fmt init web
265
+
266
+
267
+ 解析 CLI 参数 ──► 解析预设(拼写错误时自动模糊匹配)
268
+
269
+
270
+ 遍历每个配置文件:
271
+
272
+ ├── 文件不存在? ──► 创建
273
+ ├── 在 neverOverwrite 中? ──► 跳过
274
+ ├── 在 forceOverwrite 中? ──► 覆盖
275
+ └── 已存在 + --force? ──► 覆盖 / 跳过
276
+
277
+
278
+ 注入脚本到 package.json(<pm> → bun run / pnpm run / ...)
279
+
280
+
281
+ 自动安装 devDependencies(检测 lockfile 判断包管理器)
282
+ ```
283
+
284
+ <br />
285
+
286
+ ### 技术栈
287
+
288
+ | 分类 | 技术 |
289
+ |:-----|:-----|
290
+ | 语言 | TypeScript 6.0(纯 ESM) |
291
+ | 运行时 | Node.js 18+ |
292
+ | 构建 | tsup |
293
+ | 测试 | Vitest(单元测试 + 验收测试) |
294
+ | CLI | Commander.js |
295
+ | 输出 | Chalk |
296
+ | 依赖 | 零运行时依赖(仅 chalk + commander) |
297
+
298
+ <br />
299
+
300
+ ### 开发
301
+
302
+ ```bash
303
+ git clone git@github.com:TTT1231/lux.git
304
+ cd lux
305
+ bun install
306
+
307
+ bun link # 全局注册 `lux` 用于测试
308
+ lux fmt init web # 在任意项目上测试
309
+
310
+ bun test # 运行测试
311
+ bun build # 构建到 dist/
312
+ bun code:check:all # lint + 格式化 + 拼写检查
313
+ ```
314
+
315
+ <br />
316
+
317
+ ### 📄 许可证
318
+
319
+ [ISC](https://opensource.org/licenses/ISC) — 可自由使用、修改和分发。
320
+
321
+ <br />
322
+
323
+ <p align="right"><a href="#-english">← Switch to English</a></p>