@shuiyangsuan/cli 0.0.6 → 0.0.9
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 +32 -32
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/config-D5i9xsXl.js +2753 -0
- package/dist/config-D5i9xsXl.js.map +1 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.js +1 -1
- package/package.json +10 -10
- package/dist/config-ezvKVSXt.js +0 -5902
- package/dist/config-ezvKVSXt.js.map +0 -1
package/README.md
CHANGED
|
@@ -112,102 +112,102 @@ npm install @shuiyangsuan/cli
|
|
|
112
112
|
### 基础用法
|
|
113
113
|
|
|
114
114
|
```typescript
|
|
115
|
-
import { executeDelete, readConfig } from '@shuiyangsuan/cli'
|
|
115
|
+
import { executeDelete, readConfig } from '@shuiyangsuan/cli'
|
|
116
116
|
|
|
117
117
|
// 读取配置
|
|
118
|
-
const config = await readConfig()
|
|
118
|
+
const config = await readConfig()
|
|
119
119
|
|
|
120
120
|
// 执行删除
|
|
121
121
|
const result = await executeDelete(['node_modules', 'dist'], config, {
|
|
122
122
|
force: true, // 强制删除,不提示确认
|
|
123
123
|
verbose: true, // 详细输出
|
|
124
|
-
})
|
|
124
|
+
})
|
|
125
125
|
|
|
126
|
-
console.log(`成功删除 ${result.deletedCount} 个文件`)
|
|
127
|
-
console.log('删除的文件:', result.deletedFiles)
|
|
126
|
+
console.log(`成功删除 ${result.deletedCount} 个文件`)
|
|
127
|
+
console.log('删除的文件:', result.deletedFiles)
|
|
128
128
|
```
|
|
129
129
|
|
|
130
130
|
### 预览模式
|
|
131
131
|
|
|
132
132
|
```typescript
|
|
133
|
-
import { executeDelete, readConfig } from '@shuiyangsuan/cli'
|
|
133
|
+
import { executeDelete, readConfig } from '@shuiyangsuan/cli'
|
|
134
134
|
|
|
135
|
-
const config = await readConfig()
|
|
135
|
+
const config = await readConfig()
|
|
136
136
|
|
|
137
137
|
// 预览将要删除的内容,不实际删除
|
|
138
138
|
const result = await executeDelete(['**/*.log', 'dist'], config, {
|
|
139
139
|
dryRun: true,
|
|
140
140
|
verbose: true,
|
|
141
|
-
})
|
|
141
|
+
})
|
|
142
142
|
|
|
143
|
-
console.log('将要删除的文件:', result.deletedFiles)
|
|
143
|
+
console.log('将要删除的文件:', result.deletedFiles)
|
|
144
144
|
```
|
|
145
145
|
|
|
146
146
|
### 仅收集文件列表
|
|
147
147
|
|
|
148
148
|
```typescript
|
|
149
|
-
import { collectFilesToDelete } from '@shuiyangsuan/cli'
|
|
149
|
+
import { collectFilesToDelete } from '@shuiyangsuan/cli'
|
|
150
150
|
|
|
151
151
|
// 仅收集匹配的文件列表,不执行删除
|
|
152
|
-
const files = await collectFilesToDelete(['**/*.ts', '**/*.js'], {})
|
|
152
|
+
const files = await collectFilesToDelete(['**/*.ts', '**/*.js'], {})
|
|
153
153
|
|
|
154
|
-
console.log('匹配的文件:')
|
|
155
|
-
files.forEach((file) => console.log(` - ${file}`))
|
|
154
|
+
console.log('匹配的文件:')
|
|
155
|
+
files.forEach((file) => console.log(` - ${file}`))
|
|
156
156
|
```
|
|
157
157
|
|
|
158
158
|
### 在构建脚本中使用
|
|
159
159
|
|
|
160
160
|
```typescript
|
|
161
161
|
// build.ts
|
|
162
|
-
import { executeDelete, readConfig } from '@shuiyangsuan/cli'
|
|
163
|
-
import { execSync } from 'child_process'
|
|
162
|
+
import { executeDelete, readConfig } from '@shuiyangsuan/cli'
|
|
163
|
+
import { execSync } from 'child_process'
|
|
164
164
|
|
|
165
165
|
async function build() {
|
|
166
|
-
const config = await readConfig()
|
|
166
|
+
const config = await readConfig()
|
|
167
167
|
|
|
168
168
|
// 清理旧的构建产物
|
|
169
169
|
await executeDelete(['dist', 'build'], config, {
|
|
170
170
|
force: true,
|
|
171
171
|
verbose: true,
|
|
172
|
-
})
|
|
172
|
+
})
|
|
173
173
|
|
|
174
174
|
// 执行构建
|
|
175
|
-
execSync('tsc', { stdio: 'inherit' })
|
|
175
|
+
execSync('tsc', { stdio: 'inherit' })
|
|
176
176
|
|
|
177
|
-
console.log('构建完成!')
|
|
177
|
+
console.log('构建完成!')
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
build().catch(console.error)
|
|
180
|
+
build().catch(console.error)
|
|
181
181
|
```
|
|
182
182
|
|
|
183
183
|
### 完整示例 - 带错误处理
|
|
184
184
|
|
|
185
185
|
```typescript
|
|
186
|
-
import { executeDelete, readConfig, type DeleteResult } from '@shuiyangsuan/cli'
|
|
186
|
+
import { executeDelete, readConfig, type DeleteResult } from '@shuiyangsuan/cli'
|
|
187
187
|
|
|
188
188
|
async function cleanup() {
|
|
189
189
|
try {
|
|
190
|
-
const config = await readConfig()
|
|
190
|
+
const config = await readConfig()
|
|
191
191
|
|
|
192
192
|
const result: DeleteResult = await executeDelete(['node_modules', 'dist', '**/*.log'], config, {
|
|
193
193
|
force: false, // 需要确认
|
|
194
194
|
verbose: true, // 详细输出
|
|
195
|
-
})
|
|
195
|
+
})
|
|
196
196
|
|
|
197
|
-
console.log('✅ 清理完成!')
|
|
198
|
-
console.log(`成功:${result.deletedCount}, 失败:${result.failedCount}`)
|
|
197
|
+
console.log('✅ 清理完成!')
|
|
198
|
+
console.log(`成功:${result.deletedCount}, 失败:${result.failedCount}`)
|
|
199
199
|
|
|
200
200
|
if (result.errors.length > 0) {
|
|
201
|
-
console.error('错误信息:')
|
|
202
|
-
result.errors.forEach((err) => console.error(` - ${err}`))
|
|
201
|
+
console.error('错误信息:')
|
|
202
|
+
result.errors.forEach((err) => console.error(` - ${err}`))
|
|
203
203
|
}
|
|
204
204
|
} catch (error) {
|
|
205
|
-
console.error('清理失败:', (error as Error).message)
|
|
206
|
-
process.exit(1)
|
|
205
|
+
console.error('清理失败:', (error as Error).message)
|
|
206
|
+
process.exit(1)
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
cleanup()
|
|
210
|
+
cleanup()
|
|
211
211
|
```
|
|
212
212
|
|
|
213
213
|
### API 文档
|
|
@@ -264,7 +264,7 @@ import type {
|
|
|
264
264
|
DeleteOptions, // 删除选项
|
|
265
265
|
DeleteResult, // 删除结果
|
|
266
266
|
CliConfig, // 配置类型
|
|
267
|
-
} from '@shuiyangsuan/cli'
|
|
267
|
+
} from '@shuiyangsuan/cli'
|
|
268
268
|
```
|
|
269
269
|
|
|
270
270
|
## 📝 配置文件
|
|
@@ -414,7 +414,7 @@ yangguodong
|
|
|
414
414
|
|
|
415
415
|
- **TypeScript** - 类型安全的 JavaScript 超集
|
|
416
416
|
- **commander** - CLI 框架
|
|
417
|
-
- **
|
|
417
|
+
- **tinyglobby** - 快速的 glob 模式匹配
|
|
418
418
|
- **Rolldown** - 构建工具
|
|
419
419
|
- **Bun Test** - 测试框架
|
|
420
420
|
- **oxlint** - 代码检查
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as __commonJSMin, o as __require, r as deleteCommand, s as __toESM, t as readConfig } from "./config-
|
|
1
|
+
import { a as __commonJSMin, o as __require, r as deleteCommand, s as __toESM, t as readConfig } from "./config-D5i9xsXl.js";
|
|
2
2
|
|
|
3
3
|
//#region node_modules/.pnpm/commander@14.0.3/node_modules/commander/lib/error.js
|
|
4
4
|
var require_error = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -3026,7 +3026,7 @@ const { program: program$1, createCommand, createArgument, createOption, Command
|
|
|
3026
3026
|
|
|
3027
3027
|
//#endregion
|
|
3028
3028
|
//#region package.json
|
|
3029
|
-
var version = "0.0.
|
|
3029
|
+
var version = "0.0.8";
|
|
3030
3030
|
|
|
3031
3031
|
//#endregion
|
|
3032
3032
|
//#region src/cli.ts
|