@luxkit/cli 1.1.3 → 1.1.4

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.
@@ -1,6 +1,6 @@
1
1
  # Custom Preset Configuration
2
2
 
3
- lux 预设存储在`~/.lux/preset/` (i.e. `os.homedir()/.lux/preset/`). Override with `LUX_HOME` env var
3
+ Presets are stored at `~/.lux/preset/` (i.e. `os.homedir()/.lux/preset/`). Override with `LUX_HOME` env var.
4
4
 
5
5
  ```
6
6
  ~/.lux/preset/
@@ -8,7 +8,7 @@ lux 预设存储在`~/.lux/preset/` (i.e. `os.homedir()/.lux/preset/`). Override
8
8
  └── vscode/ # vscode presets (same + go)
9
9
  ```
10
10
 
11
- > ⚠️ **Always use `lux init --preset` to initialize all built-in presets.**。
11
+ > ⚠️ **Always use `lux init --preset` to initialize all built-in presets.**
12
12
 
13
13
  ## Built-in presets File Reference
14
14
 
@@ -23,6 +23,7 @@ lux 预设存储在`~/.lux/preset/` (i.e. `os.homedir()/.lux/preset/`). Override
23
23
  | `.stylelintignore` | Stylelint ignore rules |
24
24
  | `cspell.json` | CSpell dictionary config |
25
25
  | `.editorconfig` | EditorConfig config |
26
+ | `.lintstagedrc.json` | lint-staged config (enables `--lint-staged`) |
26
27
  | `package.json` | Template with `devDependencies` and `scripts` |
27
28
 
28
29
  ### vscode preset
@@ -38,9 +39,9 @@ lux 预设存储在`~/.lux/preset/` (i.e. `os.homedir()/.lux/preset/`). Override
38
39
  lux init --preset # init all built-in presets
39
40
  ```
40
41
 
41
- After init, edit files under `~/.lux/preset/<type>/<preset-name>/` to customize,例如`package.json`、`eslint.config.mjs`等等,也可以增加你自己的 lint 文件例如`your-file-lint-config`. Changes take effect on the next `lux fmt` / `lux vscode` run.
42
+ After init, edit files under `~/.lux/preset/<type>/<preset-name>/` to customize — e.g. `package.json`, `eslint.config.mjs`, etc. You can also add your own lint files like `your-file-lint-config`. Changes take effect on the next `lux fmt` / `lux vscode` run.
42
43
 
43
- 如果你自定义内置预设想重置的时候,可以重新执行`lux init --preset`去覆盖,或者使用`lux fmt <name> --reset` 、`lux vscode <name> --reset` (deletes local preset dir only; re-generated from built-in on next run).
44
+ To reset a customized built-in preset, re-run `lux init --preset` to overwrite, or use `lux fmt <name> --reset` / `lux vscode <name> --reset` (deletes local preset dir only; re-generated from built-in on next run).
44
45
 
45
46
  ## Customize your own presets
46
47
 
@@ -52,11 +53,16 @@ Create a directory under `~/.lux/preset/fmt/<your-fmt-preset-name>/` with config
52
53
  # 1. Create the preset directory
53
54
  mkdir -p ~/.lux/preset/fmt/[your-custom-fmt-preset-name]
54
55
 
55
- # 2. Add config files (pick what you need)
56
+ # 2. Add config files
56
57
  # Required: package.json (with devDependencies/dependencies and/or scripts)
57
- # Optional: eslint.config.mjs, .prettierrc, .prettierignore,
58
- # stylelint.config.mjs, .stylelintignore,
59
- # cspell.json, .editorconfig , etc....
58
+ # Recommended: include ALL tool configs so --stylelint / --cspell / --editorconfig flags can take effect
59
+ # Config files: eslint.config.mjs, .prettierrc, .prettierignore,
60
+ # stylelint.config.mjs, .stylelintignore,
61
+ # Config files: eslint.config.mjs, .prettierrc, .prettierignore,
62
+ # stylelint.config.mjs, .stylelintignore,
63
+ # cspell.json, .editorconfig, .lintstagedrc.json, etc.
64
+ #
65
+ # ⚠️ Only configs present in the preset can be controlled by flags. See "Flag-based filtering" below.
60
66
  ```
61
67
 
62
68
  Minimum `package.json` example:
@@ -75,7 +81,7 @@ Minimum `package.json` example:
75
81
  }
76
82
  ```
77
83
 
78
- Then 执行`lux fmt list`检查是否生效——这个`<your-fmt-preset-name>` 是否出现在其中。
84
+ Then run `lux fmt list` to verify — check if `<your-fmt-preset-name>` appears in the list.
79
85
 
80
86
  ```bash
81
87
  lux fmt <your-fmt-preset-name> # applies your custom preset
@@ -90,7 +96,9 @@ Notes:
90
96
  - `lux fmt <name> --reset` warns and aborts for custom presets — there is no built-in source to restore
91
97
  - Unknown preset names fuzzy-match against all available presets (builtin + custom combined)
92
98
  - `lux fmt` returns exit code **1** when a preset is not found (safe for CI/CD)
93
- - `lux fmt <name> --stylelint/--editorconfig` warns when the flag has no effect (preset has no matching config or dependencies)
99
+ - `lux fmt <name> --stylelint/--editorconfig/--cspell/--husky/--lint-staged` warns when the flag has no effect (preset has no matching config or dependencies)
100
+
101
+ > For general flag behavior (`--force`, `--dry-run`, `--no-install`, `--reset`), see `skill.md`. The sections below only cover behaviors specific to custom preset interaction.
94
102
 
95
103
  ### vscode
96
104
 
@@ -106,14 +114,14 @@ lux vscode web-vue # applies your customized
106
114
 
107
115
  ## Fmt presets · package.json rules
108
116
 
109
- `devDependencies` `dependencies` 最新版本占位使用`<latest>`,特定版本除外。还有这个`scripts`如果不确定包管理器就用占位符`<pm>`让 lux 自动检测。
117
+ Use `<latest>` placeholder for `devDependencies` and `dependencies` to get the latest version, or pin a specific version. Use `<pm>` placeholder in `scripts` to let lux auto-detect the package manager.
110
118
 
111
119
  ```jsonc
112
120
  {
113
121
  "devDependencies": {
114
- // 最新版本
122
+ // latest version
115
123
  "prettier": "<latest>",
116
- // 固定版本
124
+ // pinned version
117
125
  "cspell": "10.0.0",
118
126
  },
119
127
  "scripts": {
@@ -123,3 +131,118 @@ lux vscode web-vue # applies your customized
123
131
  },
124
132
  }
125
133
  ```
134
+
135
+ ## Flag-based filtering (`--stylelint`, `--cspell`, `--editorconfig`, `--husky`, `--lint-staged`)
136
+
137
+ The `--stylelint`/`--cspell`/`--editorconfig`/`--husky`/`--lint-staged` flags control **strip/inject** behavior. For these flags to work with your custom preset, you must include **all** relevant config files and dependencies in the preset directory — lux can only strip what already exists; it cannot inject what is missing.
138
+
139
+ ### Three-layer filtering
140
+
141
+ When a flag is **not** passed (default), lux skips the corresponding files, deps, and scripts. When a flag **is** passed, those items are preserved.
142
+
143
+ | Layer | Matching rule | Examples |
144
+ | :------------ | :----------------------------------------------------------------------------------------------------------------------------- | :----------------------------------------------------------- |
145
+ | **Files** | Exact filename match | `stylelint.config.mjs`, `.stylelintignore`, `cspell.json`, `.editorconfig`, `.lintstagedrc.json` |
146
+ | **Deps** | stylelint: predefined set match; editorconfig: `includes('editorconfig')`; cspell: `dep === 'cspell'`; husky: `dep === 'husky'`; lint-staged: `dep === 'lint-staged'` | `stylelint`, `postcss-html`, `cspell`, `editorconfig-checker`, `husky`, `lint-staged` |
147
+ | **Script keys** | **Case-sensitive** `key.includes(keyword)` match + inline command segment stripping | See detailed rules below |
148
+
149
+ ### Script naming convention (important)
150
+
151
+ lux checks whether a script **key** contains a specific keyword to decide if it should be filtered:
152
+
153
+ | Script key example | Filtered by `--stylelint`? | Reason |
154
+ | :------------------------------ | :------------------------- | :-------------------------------------------- |
155
+ | `stylelint:check` | ✅ Yes | key contains `stylelint` (all lowercase) |
156
+ | `stylelint` | ✅ Yes | key contains `stylelint` |
157
+ | `Stylelint:check` | ❌ No | uppercase `S`, case-sensitive mismatch |
158
+ | `style:check` | ❌ No | key does not contain the full word `stylelint` |
159
+ | `lintX:check` | ❌ No | key does not contain any known keyword |
160
+
161
+ The same rules apply to `cspell` and `editorconfig`:
162
+
163
+ | Keyword | Matching key examples | Non-matching key examples |
164
+ | :-------------- | :---------------------------- | :------------------------------ |
165
+ | `stylelint` | `stylelint:check`, `stylelint` | `Stylelint:*`, `style:*` |
166
+ | `cspell` | `cspell`, `cspell:check` | `Cspell:*`, `spell:*` |
167
+ | `editorconfig` | `editorconfig:check` | `Editorconfig:*`, `editor:*` |
168
+ | `lint-staged` | `lint-staged`, `lint-staged:check` | `Lint-staged:*` (case-sensitive) |
169
+
170
+ **Non-matching script keys are copied as-is** to the target project — lux does not process them.
171
+
172
+ ### Inline command segment stripping
173
+
174
+ lux also strips inline tool invocation segments from **composite scripts**:
175
+
176
+ ```jsonc
177
+ {
178
+ "scripts": {
179
+ // Original: composite script with stylelint and cspell
180
+ "lint": "<pm> eslint . && stylelint \"src/**/*.{css,scss,vue}\" && cspell --gitignore \"src/**/*\"",
181
+
182
+ // When --stylelint and --cspell are NOT passed, both segments are stripped
183
+ // Result: "lint": "<pm> eslint ."
184
+ }
185
+ }
186
+ ```
187
+
188
+ Inline stripping matches `&& stylelint "..."` and `&& cspell ...` patterns in command text.
189
+
190
+ ### Full custom preset example (all flags supported)
191
+
192
+ To make `--stylelint`, `--cspell`, `--editorconfig`, `--husky`, and `--lint-staged` all functional, your custom preset should include configs for **every tool**:
193
+
194
+ ```
195
+ ~/.lux/preset/fmt/my-full-preset/
196
+ ├── eslint.config.mjs # ESLint config
197
+ ├── .prettierrc # Prettier config
198
+ ├── .prettierignore # Prettier ignore rules
199
+ ├── stylelint.config.mjs # ← enables --stylelint
200
+ ├── .stylelintignore # ← enables --stylelint
201
+ ├── cspell.json # ← enables --cspell
202
+ ├── .editorconfig # ← enables --editorconfig
203
+ ├── .lintstagedrc.json # ← enables --lint-staged
204
+ └── package.json # with all devDependencies and scripts
205
+ ```
206
+
207
+ The `package.json` should include corresponding deps and scripts:
208
+
209
+ ```jsonc
210
+ {
211
+ "devDependencies": {
212
+ "eslint": "<latest>",
213
+ "prettier": "<latest>",
214
+ // ← enables --stylelint
215
+ "stylelint": "<latest>",
216
+ "stylelint-config-standard-scss": "<latest>",
217
+ "stylelint-order": "<latest>",
218
+ "postcss-html": "<latest>",
219
+ // ← enables --cspell
220
+ "cspell": "<latest>",
221
+ // ← enables --husky
222
+ "husky": "<latest>",
223
+ // ← enables --lint-staged
224
+ "lint-staged": "<latest>"
225
+ },
226
+ "scripts": {
227
+ "lint": "<pm> eslint .",
228
+ "lint:fix": "<pm> eslint . --fix --cache --cache-location node_modules/.cache/.eslintcache",
229
+ // ← key contains "stylelint", controllable by --stylelint
230
+ "stylelint:check": "<pm> stylelint \"src/**/*.{css,scss,vue}\"",
231
+ // ← key contains "cspell", controllable by --cspell
232
+ "cspell": "<pm> cspell \"**\"",
233
+ // ← key contains "lint-staged", controllable by --lint-staged
234
+ "lint-staged": "lint-staged"
235
+ }
236
+ }
237
+ ```
238
+
239
+ Usage:
240
+
241
+ ```bash
242
+ lux fmt my-full-preset # ESLint + Prettier only
243
+ lux fmt my-full-preset --stylelint # + Stylelint
244
+ lux fmt my-full-preset --stylelint --cspell # + Stylelint + CSpell
245
+ lux fmt my-full-preset --stylelint --cspell --editorconfig # + Stylelint + CSpell + EditorConfig
246
+ lux fmt my-full-preset --lint-staged # + lint-staged + husky
247
+ lux fmt my-full-preset --stylelint --cspell --lint-staged # all tools
248
+ ```
@@ -6,33 +6,54 @@ description: Use when setting up ESLint, Prettier, CSpell, Stylelint, EditorConf
6
6
  ## fmt — generate lint/format configs
7
7
 
8
8
  ```bash
9
- lux fmt <preset> [--stylelint] [--editorconfig]
9
+ lux fmt <preset> [--stylelint] [--editorconfig] [--cspell] [--husky] [--lint-staged]
10
10
  lux fmt list
11
11
  ```
12
12
 
13
- - `--force` overwrite existing config files (default: skip)
14
- - `--dry-run` — preview what would be generated, write nothing
15
- - `--no-install` — write deps to package.json but skip install
16
- - `--reset` — reset local preset, re-materialize from built-in defaults
13
+ built-in presets: `web-vue` `web-react` `electron-vue` `uniapp` `node` `nest`
17
14
 
18
- `lux fmt list` Built-in presets first, custom presets last, marked with **custom**.
15
+ ### Opt-in flags
19
16
 
20
- built-in presets: `web-vue` `web-react` `electron-vue` `uniapp` `node` `nest`
17
+ Only ESLint + Prettier are generated by default. Add flags to include additional tools:
18
+
19
+ - `--stylelint` — generate stylelint config + deps + scripts
20
+ - `--editorconfig` — generate .editorconfig + deps
21
+ - `--cspell` — generate cspell.json + deps + scripts
22
+ - `--husky` — initialize husky for Git hooks (creates `.husky/pre-commit`, injects init script, executes once)
23
+ - `--lint-staged` — generate `.lintstagedrc.json` + deps + scripts (implies `--husky`)
24
+
25
+ Each flag controls three layers of filtering — **files** (exact filename), **deps** (set/exact match), **script keys** (`key.includes(keyword)`, case-sensitive). See `references/custom-preset-setting.md` for details.
26
+
27
+ ### Control flags
28
+
29
+ - `--force` — overwrite existing config files **and** scripts. Default behavior skips existing files and package.json scripts. `--force` does not affect deps — deps are always additive (missing only, no version overwrite).
30
+ - `--dry-run` — preview mode, write nothing. Outputs `[dry-run]` prefixed messages showing what would happen.
31
+ - `--no-install` — write deps to package.json but **skip** `bun/npm install`. Useful for CI or manual install control.
32
+ - `--reset` — reset local preset. For built-in presets: deletes `~/.lux/preset/fmt/<name>/` and re-materializes from built-in template. For custom presets: **aborts immediately** with a warning (no built-in source to restore).
33
+
34
+ ### list
35
+
36
+ `lux fmt list` — Built-in presets first, custom presets last, marked with **(custom)**.
21
37
 
22
38
  ## vscode — generate editor settings
23
39
 
24
40
  ```bash
25
- lux vscode <preset> [--dry-run] [--stylelint]
41
+ lux vscode <preset> [--stylelint]
26
42
  lux vscode list
27
43
  ```
28
44
 
29
- - `--force` — overwrite existing settings (default: skip)
30
- - `--dry-run` — preview what would be generated, write nothing
31
- - `--stylelint` — Include Stylelint settings and extension
32
- - `--reset` — reset local preset, re-materialize from built-in defaults
33
-
34
45
  built-in presets: `web-vue` `web-react` `electron-vue` `uniapp` `node` `nest` `go`
35
46
 
47
+ ### Opt-in flags
48
+
49
+ - `--stylelint` — include Stylelint VSCode settings and extension recommendation
50
+
51
+ ### Control flags
52
+
53
+ - `--force` — overwrite existing .vscode/settings.json and .vscode/extensions.json (default: skip)
54
+ - `--dry-run` — preview mode
55
+ - `--reset` — reset local vscode preset (built-in presets only)
56
+
36
57
  ## init — initialize skills or presets
37
58
 
38
59
  ```bash
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxkit/cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "One-click project formatting & VSCode config CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,8 @@
23
23
  "test": "vitest run",
24
24
  "test:watch": "vitest",
25
25
  "test:coverage": "vitest run --coverage",
26
- "code:check": "bun run lint && bun run format:check"
26
+ "code:check": "bun run lint && bun run format:check",
27
+ "prepare": "husky"
27
28
  },
28
29
  "keywords": [
29
30
  "cli",
@@ -44,6 +45,12 @@
44
45
  "chalk": "5",
45
46
  "commander": "^14.0.3"
46
47
  },
48
+ "lint-staged": {
49
+ "src/**/*.{ts,js,json}": [
50
+ "eslint --fix",
51
+ "prettier --write"
52
+ ]
53
+ },
47
54
  "devDependencies": {
48
55
  "@eslint/js": "10.0.1",
49
56
  "@types/node": "^25.5.2",
@@ -53,6 +60,8 @@
53
60
  "eslint": "10.2.0",
54
61
  "eslint-config-prettier": "10.1.8",
55
62
  "eslint-plugin-prettier": "5.5.5",
63
+ "husky": "^9.1.7",
64
+ "lint-staged": "^17.0.4",
56
65
  "prettier": "3.8.1",
57
66
  "tsup": "^8.5.1",
58
67
  "typescript": "^6.0.2",
package/README_Zh.md DELETED
@@ -1,189 +0,0 @@
1
- <div align="center">
2
-
3
- # lux
4
-
5
- **一键项目格式化 & VSCode 配置 CLI**
6
-
7
- [![npm version](https://img.shields.io/npm/v/@luxkit/cli.svg)](https://www.npmjs.com/package/@luxkit/cli)
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
- [English](./README.md) | **中文**
14
-
15
- </div>
16
-
17
- ---
18
-
19
- ### 📌 为什么选择 lux?
20
-
21
- 每次新建项目都要花大量时间折腾代码规范配置?`lux` 让你彻底告别这一痛点!作为一款专为现代化开发与 **AI 时代** 打造的工程化配置工具,只需一条命令即可为您搭好绝佳的开发 lint 基建。
22
-
23
- - 🚀 **一键极速配置**:告别繁琐的手动依赖安装,一套命令自动为你搭好 ESLint、Prettier、CSpell、Stylelint、EditorConfig 以及完美的 VSCode 工作区体验。
24
- - 🤖 **AI Agent 最佳拍档**:专为 Claude、Opencode 打造生态!技能(Skill)体系,你可以直接用自然语言(如*"/lux 帮我配一套适合团队的 react 代码规范"*),让 AI 帮你全自动构建和调整自定义预设。
25
- - 📦 **框架开箱即用**:内置场景预设:`web-vue`, `web-react`, `node`等。
26
- - 🎨 **高度自由的专属定制**:厌倦了死板的“一刀切”封装配置?`lux` 支持提取和微调内置预设,更支持**完全自定义私有预设**,完美兼顾开箱即用体验与团队强定制化刚需。
27
- - 🧠 **项目安全无痛接入**:拥有智能冲突解决与合配机制,自动检测 `bun` `pnpm` `npm` `yarn` 依赖树,将配置注入到已有项目中。
28
-
29
- <div align="center">
30
- <img src="https://github.com/TTT1231/lux/blob/main/demo.gif?raw=true" alt="lux 演示" width="640" />
31
- </div>
32
-
33
- ## ⚡快速开始
34
-
35
- ```bash
36
- # 全局安装(选择你的包管理器)
37
- npm install -g @luxkit/cli
38
-
39
- # 初始化 skill 和 preset
40
- lux init && lux init --preset
41
-
42
- # lint 使用
43
- lux fmt web-vue # 配置web-vue lint,配置 ESLint、Prettier、CSpell
44
- lux fmt web-vue --stylelint # 同时包含 Stylelint
45
- lux fmt web-vue --editorconfig # 同时包含 EditorConfig
46
-
47
- # vscode配置使用(option)
48
- # 如果你全局自定义配置了,可忽视
49
- lux vscode web-vue #(项目内) 生成 .vscode/settings.json + extensions.json
50
-
51
- # 查看可用预设
52
- lux fmt list
53
- lux vscode list
54
-
55
- # 下一步:自定义你自己的lint预设(可选)
56
- ```
57
-
58
- <br />
59
-
60
- ## 🎨 自定义内置预设
61
-
62
- ```bash
63
- # 检查skill和预设是否初始化(已初始化,请忽视)
64
- lux init && lux init --preset
65
-
66
- # 使用 ai agent 进行自定义内置预设(推荐)
67
- # 在ai agent例如claude,直接执行以下即可
68
- /lux 配置内置预设 web-react 模板,符合我的开发项目风格
69
-
70
- # 如果你不想使用 ai agent 可直接编辑 `~/.lux/preset/`下的内置预设文件
71
- # 例如修改 web-react 增加cspell script
72
- # "cspell":"cspell \"src/**/*\"" 到 `~/.lux/preset/fmt/web-react/package.json` 即可
73
- ```
74
-
75
- ## 🧩 完全自定义预设
76
-
77
- 如果你想完全自定义自己的 lint,按照以下方法进行即可:
78
-
79
- ```bash
80
- # 检查skill和预设是否初始化(已初始化,请忽视)
81
- lux init && lux init --preset
82
-
83
- # 使用 ai agent 进行完全自定义预设(推荐)
84
- # 在ai agent例如claude,直接执行以下即可
85
- /lux 配置我的格式化模板<your-custom-fmt-preset-name>,符合我的开发项目风格
86
-
87
- # 检查是否配置成功
88
- lux fmt list
89
- ```
90
-
91
- ## 📖命令参考
92
-
93
- | 命令 | 说明 |
94
- | :-------------------------- | :----------------------------------------------------------- |
95
- | `lux fmt <preset>` | lint 配置 |
96
- | `lux fmt list` | 列出 lint 可用的预设 |
97
- | `lux vscode <preset>` | 配置 VSCode 设置 (项目内) |
98
- | `lux vscode list` | 列出可用的 VSCode 预设 |
99
- | `lux init` | 初始化 skill |
100
- | `lux init --preset` | 初始化所有预设 |
101
- | `lux set <key=value> [...]` | 设置代理环境变量(如 `https_proxy="http://127.0.0.1:7890"`) |
102
- | `lux unset` | 清除全部的代理配置 |
103
- | `lux show env` | 显示已配置的代理环境变量 |
104
- | `lux vpn cmd` | 复制 CMD 代理命令到剪贴板 |
105
- | `lux vpn pw` | 复制 PowerShell 代理命令到剪贴板 |
106
- | `lux vpn bash` | 复制 Bash 代理命令到剪贴板 |
107
- | `lux update` | 更新 `@luxkit/cli` 到最新版本 |
108
- | `lux update --check` | 仅检查是否有可用更新,不执行安装 |
109
-
110
- <br />
111
-
112
- ### ⚙️命令选项
113
-
114
- ```bash
115
- lux fmt <preset> [options]
116
-
117
- --force 强制覆盖已有文件
118
- --no-install 跳过依赖安装
119
- --dry-run 预览模式,不写入文件
120
- --stylelint 包含 Stylelint 配置(按需启用)
121
- --editorconfig 包含 EditorConfig 的配置(按需启用)
122
- --reset 重置本地预设,从内置默认值重新创建
123
-
124
- lux vscode <preset> [options]
125
-
126
- --force 强制覆盖已有文件
127
- --dry-run 预览模式,不写入文件
128
- --stylelint 包含 Stylelint 设置和扩展(按需启用)
129
- --reset 重置本地预设,从内置默认值重新创建
130
- ```
131
-
132
- <br />
133
-
134
- ## 🔧工作原理
135
-
136
- ```
137
- lux fmt <preset> [options]
138
-
139
-
140
- 解析 CLI 参数,校验项目 package.json
141
-
142
-
143
- 预设类型判断
144
-
145
- ├── 内置预设 ──► --reset? ──► 重置本地副本
146
- │ │
147
- │ ├── 本地副本存在 (~/.lux/preset/)? ──► 从本地副本应用
148
- │ └── 不存在 ──► 从内置生成 ──► 保存到 ~/.lux/preset/ ──► 应用
149
-
150
- ├── 自定义预设 (~/.lux/preset/fmt/<name>/) ──► 直接从本地目录应用
151
-
152
- └── 未找到 ──► 模糊匹配所有可用预设(内置 + 自定义)并报错
153
-
154
-
155
- --stylelint / --editorconfig 过滤(自定义预设无对应配置时 warning)
156
-
157
-
158
- 遍历每个配置文件:
159
-
160
- ├── 文件不存在? ──► 创建
161
- ├── 已存在 + --force? ──► 覆盖
162
- └── 已存在? ──► 跳过
163
-
164
-
165
- 注入脚本到 package.json(自动检测 bun / pnpm / npm / yarn)
166
-
167
-
168
- 自动安装 devDependencies(检测 lockfile 判断包管理器)
169
- ```
170
-
171
- <br />
172
-
173
- ## 🤝 参与贡献与支持
174
-
175
- 发现 Bug、有绝妙的新功能想法,或者想亲自下场优化代码?我们极其欢迎你的加入!
176
-
177
- - 🐛 **提交 Bug 或需求**:任何疑问或改进建议,欢迎随时在 GitHub [提交 Issue](https://github.com/TTT1231/lux/issues)。
178
- - 🛠 **提交代码 (PR)**:非常欢迎并且期待你提交 [PR](https://github.com/TTT1231/lux/pulls) 来一起完善这个项目!
179
- - ⭐️ **点赞支持**:如果这个工具帮你节省了哪怕 5 分钟的配置时间,请在 GitHub 上点亮一个 [⭐️Star](https://github.com/TTT1231/lux)!
180
-
181
- <br />
182
-
183
- ## 📄 许可证
184
-
185
- [ISC](https://opensource.org/licenses/ISC) — 可自由使用、修改和分发。
186
-
187
- <br />
188
-
189
- <p align="right"><a href="./README.md">← Switch to English</a></p>