@luxkit/cli 1.1.2 โ 1.1.3
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/README.md +65 -19
- package/README_Zh.md +189 -0
- package/dist/index.js +121 -37
- package/dist/skills/lux/references/custom-preset-setting.md +101 -43
- package/dist/skills/lux/skill.md +7 -4
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -16,15 +16,21 @@
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
### What is lux?
|
|
19
|
+
### ๐ What is lux?
|
|
20
20
|
|
|
21
|
-
`lux` is a CLI tool that sets up project lint configs and VSCode workspace settings with a single command
|
|
21
|
+
`lux` is a CLI tool for modern development & the **AI era** that sets up project lint configs and VSCode workspace settings with a single command.
|
|
22
|
+
|
|
23
|
+
- ๐**One-click setup**: ESLint, Prettier, CSpell, Stylelint, EditorConfig, and VSCode workspace โ all in one command.
|
|
24
|
+
- ๐ค**AI Agent companion**: Built for Claude, Opencode and more! Use natural language (e.g. _"/lux configure a react lint template for my team"_) to let AI build and adjust custom presets for you.
|
|
25
|
+
- ๐ฆ**Framework presets**: Built-in presets for `web-vue`, `web-react`, `node`, and more.
|
|
26
|
+
- ๐จ**Ultimate Freedom for Customization**: Tired of rigid one-size-fits-all encapsulated configurations? lux allows you to extract and fine-tune built-in presets, and also supports **fully custom private presets**. It perfectly balances out-of-the-box usability with the strong customization demands of team collaboration.
|
|
27
|
+
- ๐ง **Safe project integration**: Smart conflict resolution and merge, auto-detects `bun`, `pnpm`, `npm`, `yarn` dependency trees.
|
|
22
28
|
|
|
23
29
|
<div align="center">
|
|
24
30
|
<img src="https://github.com/TTT1231/lux/blob/main/demo.gif?raw=true" alt="lux demo" width="640" />
|
|
25
31
|
</div>
|
|
26
32
|
|
|
27
|
-
### Quick Start
|
|
33
|
+
### โกQuick Start
|
|
28
34
|
|
|
29
35
|
```bash
|
|
30
36
|
# Install globally (pick your package manager)
|
|
@@ -45,21 +51,42 @@ lux vscode web-vue # Generate .vscode/settings.json + extensions.json (per
|
|
|
45
51
|
# List available presets
|
|
46
52
|
lux fmt list
|
|
47
53
|
lux vscode list
|
|
54
|
+
|
|
55
|
+
# Next: customize your own lint preset (optional)
|
|
48
56
|
```
|
|
49
57
|
|
|
50
58
|
<br />
|
|
51
59
|
|
|
52
|
-
###
|
|
60
|
+
### ๐จCustomize Built-in Presets
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Check if skill and presets are initialized (skip if already done)
|
|
64
|
+
lux init && lux init --preset
|
|
65
|
+
|
|
66
|
+
# Use an AI agent to customize a built-in preset (recommended)
|
|
67
|
+
# In an AI agent like Claude, just run:
|
|
68
|
+
/lux configure built-in preset web-react template to fit my development project style
|
|
69
|
+
|
|
70
|
+
# Or manually edit files under ~/.lux/preset/
|
|
71
|
+
# e.g. add a cspell script to web-react:
|
|
72
|
+
# "cspell":"cspell \"src/**/*\"" to ~/.lux/preset/fmt/web-react/package.json
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### ๐งฉFully Custom Presets
|
|
53
76
|
|
|
54
77
|
```bash
|
|
55
78
|
# Check if skill and presets are initialized (skip if already done)
|
|
56
79
|
lux init && lux init --preset
|
|
57
80
|
|
|
58
|
-
# Use an agent to
|
|
59
|
-
|
|
81
|
+
# Use an AI agent to create a fully custom preset (recommended)
|
|
82
|
+
# In an AI agent like Claude, just run:
|
|
83
|
+
/lux configure my formatting template <your-custom-fmt-preset-name> to fit my development project style
|
|
84
|
+
|
|
85
|
+
# Verify the preset is registered
|
|
86
|
+
lux fmt list
|
|
60
87
|
```
|
|
61
88
|
|
|
62
|
-
### CLI Commands
|
|
89
|
+
### ๐CLI Commands
|
|
63
90
|
|
|
64
91
|
| Command | Description |
|
|
65
92
|
| :-------------------------- | :---------------------------------------------------------------- |
|
|
@@ -80,7 +107,7 @@ lux init && lux init --preset
|
|
|
80
107
|
|
|
81
108
|
<br />
|
|
82
109
|
|
|
83
|
-
### Options
|
|
110
|
+
### โ๏ธOptions
|
|
84
111
|
|
|
85
112
|
```bash
|
|
86
113
|
lux fmt <preset> [options]
|
|
@@ -91,34 +118,49 @@ lux fmt <preset> [options]
|
|
|
91
118
|
--stylelint Include Stylelint config generation (opt-in)
|
|
92
119
|
--editorconfig Include EditorConfig config generation (opt-in)
|
|
93
120
|
--reset Reset local preset and re-create from built-in defaults
|
|
121
|
+
|
|
122
|
+
lux vscode <preset> [options]
|
|
123
|
+
|
|
124
|
+
--force Force overwrite existing files
|
|
125
|
+
--dry-run Preview without writing files
|
|
126
|
+
--stylelint Include Stylelint settings and extension (opt-in)
|
|
127
|
+
--reset Reset local preset and re-create from built-in defaults
|
|
94
128
|
```
|
|
95
129
|
|
|
96
130
|
<br />
|
|
97
131
|
|
|
98
|
-
|
|
132
|
+
###๐ง How It Works
|
|
99
133
|
|
|
100
134
|
```
|
|
101
|
-
lux fmt
|
|
135
|
+
lux fmt <preset> [options]
|
|
102
136
|
โ
|
|
103
137
|
โผ
|
|
104
|
-
Parse CLI args
|
|
138
|
+
Parse CLI args, validate project package.json
|
|
105
139
|
โ
|
|
106
140
|
โผ
|
|
107
|
-
|
|
141
|
+
Resolve preset type
|
|
108
142
|
โ
|
|
109
|
-
โโโ
|
|
110
|
-
|
|
143
|
+
โโโ Built-in preset โโโบ --reset? โโโบ Reset local copy
|
|
144
|
+
โ โ
|
|
145
|
+
โ โโโ Local copy exists (~/.lux/preset/)? โโโบ Apply from local
|
|
146
|
+
โ โโโ Not found โโโบ Generate from built-in โโโบ Save to ~/.lux/preset/ โโโบ Apply
|
|
147
|
+
โ
|
|
148
|
+
โโโ Custom preset (~/.lux/preset/fmt/<name>/) โโโบ Apply from local directory
|
|
149
|
+
โ
|
|
150
|
+
โโโ Not found โโโบ Fuzzy match against all presets (built-in + custom), show error
|
|
151
|
+
โ
|
|
152
|
+
โผ
|
|
153
|
+
--stylelint / --editorconfig filtering (warns if custom preset lacks matching config)
|
|
111
154
|
โ
|
|
112
155
|
โผ
|
|
113
156
|
For each config file:
|
|
114
157
|
โ
|
|
115
158
|
โโโ File not found? โโโบ Create
|
|
116
|
-
โโโ
|
|
117
|
-
|
|
118
|
-
โโโ Exists + --force? โโโบ Overwrite / Skip
|
|
159
|
+
โโโ Exists + --force? โโโบ Overwrite
|
|
160
|
+
โโโ Exists? โโโบ Skip
|
|
119
161
|
โ
|
|
120
162
|
โผ
|
|
121
|
-
Inject scripts into package.json (
|
|
163
|
+
Inject scripts into package.json (auto-detect bun / pnpm / npm / yarn)
|
|
122
164
|
โ
|
|
123
165
|
โผ
|
|
124
166
|
Auto-install devDependencies (detects lockfile)
|
|
@@ -128,7 +170,11 @@ lux fmt web-vue
|
|
|
128
170
|
|
|
129
171
|
### ๐ค Support
|
|
130
172
|
|
|
131
|
-
|
|
173
|
+
Found a bug, have a feature idea, or want to improve the code? Contributions are welcome!
|
|
174
|
+
|
|
175
|
+
- **Report bugs or request features**: [Open an issue](https://github.com/TTT1231/lux/issues) on GitHub.
|
|
176
|
+
- **Submit code**: [Pull Requests](https://github.com/TTT1231/lux/pulls) are very welcome!
|
|
177
|
+
- **Star us**: If this tool saved you even 5 minutes of config time, please give us a [โญ๏ธStar](https://github.com/TTT1231/lux)!
|
|
132
178
|
|
|
133
179
|
<br />
|
|
134
180
|
|
package/README_Zh.md
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# lux
|
|
4
|
+
|
|
5
|
+
**ไธ้ฎ้กน็ฎๆ ผๅผๅ & VSCode ้
็ฝฎ CLI**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@luxkit/cli)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://opensource.org/licenses/ISC)
|
|
10
|
+
[](https://www.typescriptlang.org/)
|
|
11
|
+
[](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>
|
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ import { program } from "commander";
|
|
|
6
6
|
// src/commands/fmt.ts
|
|
7
7
|
import fs3 from "fs";
|
|
8
8
|
import path5 from "path";
|
|
9
|
+
import chalk2 from "chalk";
|
|
9
10
|
|
|
10
11
|
// src/presets/fmt/electron-vue.ts
|
|
11
12
|
var electronVueFmt = {
|
|
@@ -668,7 +669,6 @@ var logger = {
|
|
|
668
669
|
};
|
|
669
670
|
|
|
670
671
|
// src/utils/errors.ts
|
|
671
|
-
import chalk2 from "chalk";
|
|
672
672
|
var CliError = class extends Error {
|
|
673
673
|
code;
|
|
674
674
|
suggestion;
|
|
@@ -714,14 +714,6 @@ function levenshtein(a, b) {
|
|
|
714
714
|
}
|
|
715
715
|
function resolvePreset(presets, name) {
|
|
716
716
|
const found = presets.find((p) => p.name === name);
|
|
717
|
-
if (!found) {
|
|
718
|
-
const err = new PresetNotFoundError(
|
|
719
|
-
name,
|
|
720
|
-
presets.map((p) => p.name)
|
|
721
|
-
);
|
|
722
|
-
console.error(chalk2.red(err.message));
|
|
723
|
-
process.exit(1);
|
|
724
|
-
}
|
|
725
717
|
return found;
|
|
726
718
|
}
|
|
727
719
|
|
|
@@ -1031,6 +1023,28 @@ function getLocalPresetDir(type, presetName) {
|
|
|
1031
1023
|
function isValidPresetName(name) {
|
|
1032
1024
|
return name.length > 0 && !name.includes("/") && !name.includes("\\") && !name.includes("..");
|
|
1033
1025
|
}
|
|
1026
|
+
function listCustomPresets() {
|
|
1027
|
+
const fmtDir = path4.join(getLuxDir(), "preset", "fmt");
|
|
1028
|
+
if (!fs2.existsSync(fmtDir)) return [];
|
|
1029
|
+
const entries = fs2.readdirSync(fmtDir, { withFileTypes: true });
|
|
1030
|
+
const result = [];
|
|
1031
|
+
for (const entry of entries) {
|
|
1032
|
+
if (!entry.isDirectory()) continue;
|
|
1033
|
+
if (!isValidPresetName(entry.name)) continue;
|
|
1034
|
+
const pkgPath = path4.join(fmtDir, entry.name, "package.json");
|
|
1035
|
+
if (fs2.existsSync(pkgPath)) {
|
|
1036
|
+
result.push(entry.name);
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
1041
|
+
function isValidCustomPreset(name) {
|
|
1042
|
+
if (!isValidPresetName(name)) return false;
|
|
1043
|
+
const presetDir = path4.join(getLuxDir(), "preset", "fmt", name);
|
|
1044
|
+
if (!fs2.existsSync(presetDir)) return false;
|
|
1045
|
+
const pkgPath = path4.join(presetDir, "package.json");
|
|
1046
|
+
return fs2.existsSync(pkgPath);
|
|
1047
|
+
}
|
|
1034
1048
|
function localPresetExists(type, presetName) {
|
|
1035
1049
|
const dir = getLocalPresetDir(type, presetName);
|
|
1036
1050
|
return fs2.existsSync(dir);
|
|
@@ -1244,11 +1258,13 @@ function mergeTemplateIntoProject(templatePkg, projectPkg, pm, opts, result) {
|
|
|
1244
1258
|
if (templatePkg.scripts) {
|
|
1245
1259
|
const existingScripts = merged.scripts ?? {};
|
|
1246
1260
|
const newScripts = { ...existingScripts };
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1261
|
+
const filteredScripts = filterScripts(
|
|
1262
|
+
templatePkg.scripts,
|
|
1263
|
+
opts.noStylelint,
|
|
1264
|
+
opts.noEditorconfig
|
|
1265
|
+
);
|
|
1266
|
+
for (const [key, value] of Object.entries(filteredScripts)) {
|
|
1267
|
+
const resolved = value.replace(/<pm>/g, prefix);
|
|
1252
1268
|
if (existingScripts[key] !== void 0 && !opts.force) {
|
|
1253
1269
|
result.scriptsSkipped++;
|
|
1254
1270
|
if (opts.dryRun) {
|
|
@@ -1283,6 +1299,42 @@ function filterStylelintSettings(settings) {
|
|
|
1283
1299
|
}
|
|
1284
1300
|
return filtered;
|
|
1285
1301
|
}
|
|
1302
|
+
function filterScripts(scripts, noStylelint, noEditorconfig) {
|
|
1303
|
+
const filtered = {};
|
|
1304
|
+
for (const [key, value] of Object.entries(scripts)) {
|
|
1305
|
+
if (noStylelint && key.includes("stylelint")) continue;
|
|
1306
|
+
if (noEditorconfig && key.includes("editorconfig")) continue;
|
|
1307
|
+
let resolved = value;
|
|
1308
|
+
if (noStylelint) {
|
|
1309
|
+
resolved = resolved.replace(/\s*&&\s*stylelint\s+"[^"]*".*/g, "");
|
|
1310
|
+
}
|
|
1311
|
+
filtered[key] = resolved;
|
|
1312
|
+
}
|
|
1313
|
+
return filtered;
|
|
1314
|
+
}
|
|
1315
|
+
function detectPresetCapabilities(presetName) {
|
|
1316
|
+
const presetDir = path4.join(getLuxDir(), "preset", "fmt", presetName);
|
|
1317
|
+
const entries = fs2.readdirSync(presetDir);
|
|
1318
|
+
const hasStylelintFile = entries.some((f) => STYLELINT_FILES.has(f));
|
|
1319
|
+
const pkg = readJson(
|
|
1320
|
+
path4.join(presetDir, "package.json")
|
|
1321
|
+
);
|
|
1322
|
+
const hasStylelintDep = pkg?.devDependencies ? Object.keys(pkg.devDependencies).some((d) => isNotStylelintDep(d) === false) : false;
|
|
1323
|
+
const hasEditorconfigFile = entries.includes(EDITORCONFIG_FILE);
|
|
1324
|
+
const hasEditorconfigDep = pkg?.devDependencies ? Object.keys(pkg.devDependencies).some((d) => !isNotEditorconfigDep(d)) : false;
|
|
1325
|
+
return {
|
|
1326
|
+
hasStylelint: hasStylelintFile || hasStylelintDep,
|
|
1327
|
+
hasEditorconfig: hasEditorconfigFile || hasEditorconfigDep
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
function isNotStylelintDep(dep) {
|
|
1331
|
+
if (dep.includes("stylelint")) return false;
|
|
1332
|
+
if (dep === "postcss-html" || dep === "postcss-scss") return false;
|
|
1333
|
+
return true;
|
|
1334
|
+
}
|
|
1335
|
+
function isNotEditorconfigDep(dep) {
|
|
1336
|
+
return !dep.includes("editorconfig");
|
|
1337
|
+
}
|
|
1286
1338
|
function resolveLocalDeps(deps) {
|
|
1287
1339
|
const packages = [];
|
|
1288
1340
|
for (const [name, version] of Object.entries(deps)) {
|
|
@@ -1296,27 +1348,24 @@ function resolveLocalDeps(deps) {
|
|
|
1296
1348
|
}
|
|
1297
1349
|
|
|
1298
1350
|
// src/commands/fmt.ts
|
|
1299
|
-
function
|
|
1300
|
-
const filtered = {};
|
|
1301
|
-
for (const [key, value] of Object.entries(scripts)) {
|
|
1302
|
-
filtered[key] = value.replace(/\s*&&\s*stylelint\s+"[^"]*".*/g, "");
|
|
1303
|
-
}
|
|
1304
|
-
return filtered;
|
|
1305
|
-
}
|
|
1306
|
-
function isNotStylelintDep(dep) {
|
|
1351
|
+
function isNotStylelintDep2(dep) {
|
|
1307
1352
|
if (dep.includes("stylelint")) return false;
|
|
1308
1353
|
if (dep === "postcss-html" || dep === "postcss-scss") return false;
|
|
1309
1354
|
return true;
|
|
1310
1355
|
}
|
|
1311
|
-
function
|
|
1356
|
+
function isNotEditorconfigDep2(dep) {
|
|
1312
1357
|
return !dep.includes("editorconfig");
|
|
1313
1358
|
}
|
|
1314
1359
|
function registerFmtCommand(program2) {
|
|
1315
1360
|
const fmt = program2.command("fmt").description("Initialize formatting config with preset");
|
|
1316
1361
|
fmt.argument("<preset>").option("-F, --force", "Force overwrite existing files").option("--no-install", "Skip dependency installation").option("--dry-run", "Preview without writing files").option("--stylelint", "Include Stylelint config generation").option("--editorconfig", "Include EditorConfig config generation").option("--reset", "Reset local preset and re-materialize from built-in").action(
|
|
1317
1362
|
async (presetName, options) => {
|
|
1318
|
-
const
|
|
1319
|
-
|
|
1363
|
+
const builtinPreset = FMT_PRESETS.find((p) => p.name === presetName);
|
|
1364
|
+
const isBuiltin = builtinPreset !== void 0;
|
|
1365
|
+
if (options.reset && !isBuiltin) {
|
|
1366
|
+
logger.warn(`"${presetName}" is a custom preset, --reset has no builtin to restore`);
|
|
1367
|
+
return;
|
|
1368
|
+
}
|
|
1320
1369
|
const cwd = process.cwd();
|
|
1321
1370
|
const pkgPath = path5.join(cwd, "package.json");
|
|
1322
1371
|
if (fileExists(pkgPath)) {
|
|
@@ -1329,25 +1378,52 @@ function registerFmtCommand(program2) {
|
|
|
1329
1378
|
return;
|
|
1330
1379
|
}
|
|
1331
1380
|
}
|
|
1332
|
-
if (
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1381
|
+
if (isBuiltin) {
|
|
1382
|
+
if (options.reset) {
|
|
1383
|
+
resetLocalPreset("fmt", presetName);
|
|
1384
|
+
}
|
|
1385
|
+
const useLocal = localPresetExists("fmt", presetName);
|
|
1386
|
+
if (useLocal) {
|
|
1387
|
+
await executeLocalPath(cwd, presetName, options);
|
|
1388
|
+
} else {
|
|
1389
|
+
await executeBuiltinPath(cwd, presetName, builtinPreset, options);
|
|
1390
|
+
}
|
|
1391
|
+
} else if (isValidCustomPreset(presetName)) {
|
|
1337
1392
|
await executeLocalPath(cwd, presetName, options);
|
|
1338
1393
|
} else {
|
|
1339
|
-
|
|
1394
|
+
const builtinNames = new Set(FMT_PRESETS.map((p) => p.name));
|
|
1395
|
+
const customNames = listCustomPresets().filter((n) => !builtinNames.has(n));
|
|
1396
|
+
const allNames = [...builtinNames, ...customNames];
|
|
1397
|
+
const err = new PresetNotFoundError(presetName, allNames);
|
|
1398
|
+
logger.error(err.message);
|
|
1399
|
+
process.exitCode = 1;
|
|
1340
1400
|
}
|
|
1341
1401
|
}
|
|
1342
1402
|
);
|
|
1343
1403
|
fmt.command("list").description("List available fmt presets").action(() => {
|
|
1404
|
+
const builtinNames = new Set(FMT_PRESETS.map((p) => p.name));
|
|
1344
1405
|
for (const p of FMT_PRESETS) {
|
|
1345
1406
|
console.log(`${p.name.padEnd(12)} ${p.description}`);
|
|
1346
1407
|
}
|
|
1408
|
+
const customs = listCustomPresets().filter((name) => !builtinNames.has(name));
|
|
1409
|
+
for (const name of customs) {
|
|
1410
|
+
console.log(`${name.padEnd(12)} ${chalk2.yellow("(custom)")}`);
|
|
1411
|
+
}
|
|
1347
1412
|
});
|
|
1348
1413
|
}
|
|
1349
1414
|
async function executeLocalPath(cwd, presetName, options) {
|
|
1350
1415
|
logger.log("Using local custom preset");
|
|
1416
|
+
const caps = detectPresetCapabilities(presetName);
|
|
1417
|
+
if (options.stylelint && !caps.hasStylelint) {
|
|
1418
|
+
logger.warn(
|
|
1419
|
+
"--stylelint has no effect: this custom preset has no stylelint config or dependencies"
|
|
1420
|
+
);
|
|
1421
|
+
}
|
|
1422
|
+
if (options.editorconfig && !caps.hasEditorconfig) {
|
|
1423
|
+
logger.warn(
|
|
1424
|
+
"--editorconfig has no effect: this custom preset has no editorconfig config or dependencies"
|
|
1425
|
+
);
|
|
1426
|
+
}
|
|
1351
1427
|
const opts = {
|
|
1352
1428
|
cwd,
|
|
1353
1429
|
force: options.force ?? false,
|
|
@@ -1452,13 +1528,13 @@ async function executeBuiltinPath(cwd, presetName, preset, options) {
|
|
|
1452
1528
|
warnMissingPackageJson(preset, options.install !== false);
|
|
1453
1529
|
return;
|
|
1454
1530
|
}
|
|
1455
|
-
const scripts =
|
|
1531
|
+
const scripts = preset.scripts ? filterScripts(preset.scripts, opts.noStylelint, opts.noEditorconfig) : void 0;
|
|
1456
1532
|
if (scripts) {
|
|
1457
1533
|
await injectScripts(scripts, opts, pm);
|
|
1458
1534
|
}
|
|
1459
1535
|
if (!preset.dependencies?.dev) return;
|
|
1460
|
-
const devDeps = opts.noStylelint ? preset.dependencies.dev.filter(
|
|
1461
|
-
const finalDeps = opts.noEditorconfig ? devDeps.filter(
|
|
1536
|
+
const devDeps = opts.noStylelint ? preset.dependencies.dev.filter(isNotStylelintDep2) : preset.dependencies.dev;
|
|
1537
|
+
const finalDeps = opts.noEditorconfig ? devDeps.filter(isNotEditorconfigDep2) : devDeps;
|
|
1462
1538
|
if (opts.dryRun) {
|
|
1463
1539
|
logger.log(`[dry-run] Would add to package.json: ${finalDeps.join(", ")}`);
|
|
1464
1540
|
return;
|
|
@@ -1488,8 +1564,8 @@ async function executeBuiltinPath(cwd, presetName, preset, options) {
|
|
|
1488
1564
|
}
|
|
1489
1565
|
function filterDeps(deps, noStylelint, noEditorconfig) {
|
|
1490
1566
|
let filtered = deps;
|
|
1491
|
-
if (noStylelint) filtered = filtered.filter(
|
|
1492
|
-
if (noEditorconfig) filtered = filtered.filter(
|
|
1567
|
+
if (noStylelint) filtered = filtered.filter(isNotStylelintDep2);
|
|
1568
|
+
if (noEditorconfig) filtered = filtered.filter(isNotEditorconfigDep2);
|
|
1493
1569
|
return filtered;
|
|
1494
1570
|
}
|
|
1495
1571
|
function logGenerationResult(result, dryRun) {
|
|
@@ -2676,7 +2752,15 @@ function registerVscodeCommand(program2) {
|
|
|
2676
2752
|
vscode.argument("<preset>").option("-F, --force", "Force overwrite existing files").option("--dry-run", "Preview without writing files").option("--stylelint", "Include Stylelint settings and extension").option("--reset", "Reset local preset and re-materialize from built-in").action(
|
|
2677
2753
|
async (presetName, options) => {
|
|
2678
2754
|
const preset = resolvePreset(VSCODE_PRESETS, presetName);
|
|
2679
|
-
if (!preset)
|
|
2755
|
+
if (!preset) {
|
|
2756
|
+
const err = new PresetNotFoundError(
|
|
2757
|
+
presetName,
|
|
2758
|
+
VSCODE_PRESETS.map((p) => p.name)
|
|
2759
|
+
);
|
|
2760
|
+
logger.error(err.message);
|
|
2761
|
+
process.exitCode = 1;
|
|
2762
|
+
return;
|
|
2763
|
+
}
|
|
2680
2764
|
const cwd = process.cwd();
|
|
2681
2765
|
if (options.reset) {
|
|
2682
2766
|
resetLocalPreset("vscode", presetName);
|
|
@@ -1,20 +1,6 @@
|
|
|
1
1
|
# Custom Preset Configuration
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Quick Start
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
lux init --preset # materialize all built-in presets to ~/.lux/preset/
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
After materialization, edit files under `~/.lux/preset/<type>/<preset-name>/` to customize. Changes take effect on the next `lux fmt` / `lux vscode` run.
|
|
12
|
-
|
|
13
|
-
`lux init --preset` can be run repeatedly โ each run overwrites with built-in defaults. To reset a single preset, use `lux fmt <name> --reset` or `lux vscode <name> --reset` (deletes local preset dir only; re-generated from built-in on next run).
|
|
14
|
-
|
|
15
|
-
## Storage Location
|
|
16
|
-
|
|
17
|
-
`~/.lux/preset/` (i.e. `os.homedir()/.lux/preset/`). Override with `LUX_HOME` env var.
|
|
3
|
+
lux ้ข่ฎพๅญๅจๅจ`~/.lux/preset/` (i.e. `os.homedir()/.lux/preset/`). Override with `LUX_HOME` env varใ
|
|
18
4
|
|
|
19
5
|
```
|
|
20
6
|
~/.lux/preset/
|
|
@@ -22,46 +8,118 @@ After materialization, edit files under `~/.lux/preset/<type>/<preset-name>/` to
|
|
|
22
8
|
โโโ vscode/ # vscode presets (same + go)
|
|
23
9
|
```
|
|
24
10
|
|
|
25
|
-
|
|
11
|
+
> โ ๏ธ **Always use `lux init --preset` to initialize all built-in presets.**ใ
|
|
12
|
+
|
|
13
|
+
## Built-in presets File Reference
|
|
26
14
|
|
|
27
15
|
### fmt preset
|
|
28
16
|
|
|
29
|
-
| File | Description
|
|
30
|
-
| :--------------------- |
|
|
31
|
-
| `eslint.config.mjs` | ESLint flat config
|
|
32
|
-
| `.prettierrc` | Prettier JSON config
|
|
33
|
-
| `.prettierignore` | Prettier ignore rules
|
|
34
|
-
| `stylelint.config.mjs` | Stylelint config
|
|
35
|
-
| `.stylelintignore` | Stylelint ignore rules
|
|
36
|
-
| `cspell.json` | CSpell dictionary config
|
|
37
|
-
| `.editorconfig` | EditorConfig config
|
|
38
|
-
| `package.json` | Template with `devDependencies` and `scripts`
|
|
17
|
+
| File | Description |
|
|
18
|
+
| :--------------------- | :-------------------------------------------- |
|
|
19
|
+
| `eslint.config.mjs` | ESLint flat config |
|
|
20
|
+
| `.prettierrc` | Prettier JSON config |
|
|
21
|
+
| `.prettierignore` | Prettier ignore rules |
|
|
22
|
+
| `stylelint.config.mjs` | Stylelint config |
|
|
23
|
+
| `.stylelintignore` | Stylelint ignore rules |
|
|
24
|
+
| `cspell.json` | CSpell dictionary config |
|
|
25
|
+
| `.editorconfig` | EditorConfig config |
|
|
26
|
+
| `package.json` | Template with `devDependencies` and `scripts` |
|
|
39
27
|
|
|
40
28
|
### vscode preset
|
|
41
29
|
|
|
42
|
-
| File | Description
|
|
43
|
-
| :---------------- |
|
|
44
|
-
| `settings.json` | VSCode workspace settings
|
|
30
|
+
| File | Description |
|
|
31
|
+
| :---------------- | :------------------------------- |
|
|
32
|
+
| `settings.json` | VSCode workspace settings |
|
|
45
33
|
| `extensions.json` | VSCode extension recommendations |
|
|
46
34
|
|
|
47
|
-
##
|
|
35
|
+
## Customize built-in presets
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
lux init --preset # init all built-in presets
|
|
39
|
+
```
|
|
40
|
+
|
|
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
|
+
|
|
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).
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
| :---------- | :------------ |
|
|
51
|
-
| `<pm>` | Package manager prefix (`bun run` / `pnpm run` / `npm run`) |
|
|
52
|
-
| `<lockfile>` | Project lockfile name (`bun.lock` / `pnpm-lock.yaml` etc.) |
|
|
53
|
-
| `"<latest>"` | Resolved to latest version at install time, or pin like `"3.3.0"` |
|
|
45
|
+
## Customize your own presets
|
|
54
46
|
|
|
55
|
-
|
|
47
|
+
### fmt
|
|
56
48
|
|
|
49
|
+
Create a directory under `~/.lux/preset/fmt/<your-fmt-preset-name>/` with config files and a `package.json`:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# 1. Create the preset directory
|
|
53
|
+
mkdir -p ~/.lux/preset/fmt/[your-custom-fmt-preset-name]
|
|
54
|
+
|
|
55
|
+
# 2. Add config files (pick what you need)
|
|
56
|
+
# 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....
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Minimum `package.json` example:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
{
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"eslint": "<latest>",
|
|
68
|
+
"prettier": "<latest>"
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"lint": "<pm> eslint .",
|
|
72
|
+
"lint:fix": "<pm> eslint . --fix --cache --cache-location node_modules/.cache/.eslintcache",
|
|
73
|
+
"cspell": "<pm> cspell \"**\""
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then ๆง่ก`lux fmt list`ๆฃๆฅๆฏๅฆ็ๆโโ่ฟไธช`<your-fmt-preset-name>` ๆฏๅฆๅบ็ฐๅจๅ
ถไธญใ
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
lux fmt <your-fmt-preset-name> # applies your custom preset
|
|
82
|
+
lux fmt <your-fmt-preset-name> --force # overwrite existing config files
|
|
83
|
+
lux fmt <your-fmt-preset-name> --dry-run # preview without writing
|
|
84
|
+
lux fmt <your-fmt-preset-name> --stylelint # applies your custom preset (includes stylelint config)
|
|
57
85
|
```
|
|
58
|
-
lux init --preset
|
|
59
|
-
โ materialize all built-in presets to ~/.lux/preset/ (no cwd writes)
|
|
60
86
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
87
|
+
Notes:
|
|
88
|
+
|
|
89
|
+
- `lux fmt list` shows custom presets after built-in ones, marked with `(custom)`
|
|
90
|
+
- `lux fmt <name> --reset` warns and aborts for custom presets โ there is no built-in source to restore
|
|
91
|
+
- Unknown preset names fuzzy-match against all available presets (builtin + custom combined)
|
|
92
|
+
- `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)
|
|
94
|
+
|
|
95
|
+
### vscode
|
|
96
|
+
|
|
97
|
+
Custom vscode presets are not yet supported. To customize VSCode settings, use the built-in preset customization flow:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
lux init --preset # materialize built-in presets
|
|
101
|
+
# Edit files under ~/.lux/preset/vscode/<preset-name>/
|
|
102
|
+
# - settings.json (VSCode workspace settings)
|
|
103
|
+
# - extensions.json (extension recommendations)
|
|
104
|
+
lux vscode web-vue # applies your customized preset
|
|
105
|
+
```
|
|
64
106
|
|
|
65
|
-
|
|
66
|
-
|
|
107
|
+
## Fmt presets ยท package.json rules
|
|
108
|
+
|
|
109
|
+
`devDependencies` ๅ `dependencies` ๆๆฐ็ๆฌๅ ไฝไฝฟ็จ`<latest>`๏ผ็นๅฎ็ๆฌ้คๅคใ่ฟๆ่ฟไธช`scripts`ๅฆๆไธ็กฎๅฎๅ
็ฎก็ๅจๅฐฑ็จๅ ไฝ็ฌฆ`<pm>`่ฎฉ lux ่ชๅจๆฃๆตใ
|
|
110
|
+
|
|
111
|
+
```jsonc
|
|
112
|
+
{
|
|
113
|
+
"devDependencies": {
|
|
114
|
+
// ๆๆฐ็ๆฌ
|
|
115
|
+
"prettier": "<latest>",
|
|
116
|
+
// ๅบๅฎ็ๆฌ
|
|
117
|
+
"cspell": "10.0.0",
|
|
118
|
+
},
|
|
119
|
+
"scripts": {
|
|
120
|
+
"lint": "<pm> eslint .",
|
|
121
|
+
"lint:fix": "<pm> eslint . --fix --cache --cache-location node_modules/.cache/.eslintcache",
|
|
122
|
+
"cspell": "<pm> cspell \"**\"",
|
|
123
|
+
},
|
|
124
|
+
}
|
|
67
125
|
```
|
package/dist/skills/lux/skill.md
CHANGED
|
@@ -15,25 +15,28 @@ lux fmt list
|
|
|
15
15
|
- `--no-install` โ write deps to package.json but skip install
|
|
16
16
|
- `--reset` โ reset local preset, re-materialize from built-in defaults
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
`lux fmt list` Built-in presets first, custom presets last, marked with **custom**.
|
|
19
|
+
|
|
20
|
+
built-in presets: `web-vue` `web-react` `electron-vue` `uniapp` `node` `nest`
|
|
19
21
|
|
|
20
22
|
## vscode โ generate editor settings
|
|
21
23
|
|
|
22
24
|
```bash
|
|
23
|
-
lux vscode <preset> [--dry-run]
|
|
25
|
+
lux vscode <preset> [--dry-run] [--stylelint]
|
|
24
26
|
lux vscode list
|
|
25
27
|
```
|
|
26
28
|
|
|
27
29
|
- `--force` โ overwrite existing settings (default: skip)
|
|
28
30
|
- `--dry-run` โ preview what would be generated, write nothing
|
|
31
|
+
- `--stylelint` โ Include Stylelint settings and extension
|
|
29
32
|
- `--reset` โ reset local preset, re-materialize from built-in defaults
|
|
30
33
|
|
|
31
|
-
|
|
34
|
+
built-in presets: `web-vue` `web-react` `electron-vue` `uniapp` `node` `nest` `go`
|
|
32
35
|
|
|
33
36
|
## init โ initialize skills or presets
|
|
34
37
|
|
|
35
38
|
```bash
|
|
36
|
-
lux init # interactively select AI tool, copy skill files to
|
|
39
|
+
lux init # interactively select AI tool, copy skill files to AI Agent
|
|
37
40
|
lux init --preset # materialize all built-in presets to ~/.lux/preset/ (no cwd writes, no package.json required)
|
|
38
41
|
```
|
|
39
42
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxkit/cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"description": "One-click project formatting & VSCode config CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lux": "dist/index.js"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
|
-
"dist"
|
|
10
|
+
"dist",
|
|
11
|
+
"README_Zh.md"
|
|
11
12
|
],
|
|
12
13
|
"publishConfig": {
|
|
13
14
|
"access": "public"
|
|
@@ -21,7 +22,8 @@
|
|
|
21
22
|
"prepublishOnly": "cross-env NODE_ENV=production bun run build",
|
|
22
23
|
"test": "vitest run",
|
|
23
24
|
"test:watch": "vitest",
|
|
24
|
-
"test:coverage": "vitest run --coverage"
|
|
25
|
+
"test:coverage": "vitest run --coverage",
|
|
26
|
+
"code:check": "bun run lint && bun run format:check"
|
|
25
27
|
},
|
|
26
28
|
"keywords": [
|
|
27
29
|
"cli",
|