@shuiyangsuan/cli 0.0.1 → 0.0.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 +5 -0
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/package.json +59 -60
package/README.md
CHANGED
|
@@ -103,20 +103,24 @@ by delete "dist" "build" ".next" --dry-run
|
|
|
103
103
|
删除文件和文件夹,支持 glob 模式匹配。
|
|
104
104
|
|
|
105
105
|
**语法:**
|
|
106
|
+
|
|
106
107
|
```bash
|
|
107
108
|
by delete <patterns...> [options]
|
|
108
109
|
```
|
|
109
110
|
|
|
110
111
|
**参数:**
|
|
112
|
+
|
|
111
113
|
- `<patterns...>` - 要删除的文件或文件夹路径/模式(支持多个)
|
|
112
114
|
|
|
113
115
|
**选项:**
|
|
116
|
+
|
|
114
117
|
- `-f, --force` - 强制删除,不提示确认
|
|
115
118
|
- `-n, --dry-run` - 预览模式,仅显示将要删除的内容
|
|
116
119
|
- `-v, --verbose` - 详细输出模式
|
|
117
120
|
- `-d, --use-defaults` - 使用配置文件中的默认模式
|
|
118
121
|
|
|
119
122
|
**退出码:**
|
|
123
|
+
|
|
120
124
|
- `0` - 成功
|
|
121
125
|
- `1` - 失败或有错误发生
|
|
122
126
|
|
|
@@ -192,6 +196,7 @@ bun test --coverage
|
|
|
192
196
|
```
|
|
193
197
|
|
|
194
198
|
测试覆盖以下场景:
|
|
199
|
+
|
|
195
200
|
- ✅ 基础删除功能(单文件、多文件、文件夹)
|
|
196
201
|
- ✅ 预览模式(dry-run)
|
|
197
202
|
- ✅ 强制删除模式
|
package/dist/index.js
CHANGED
|
@@ -8840,7 +8840,12 @@ async function collectFilesToDelete(patterns, _options) {
|
|
|
8840
8840
|
|
|
8841
8841
|
//#endregion
|
|
8842
8842
|
//#region src/config/index.ts
|
|
8843
|
-
const CONFIG_FILES = [
|
|
8843
|
+
const CONFIG_FILES = [
|
|
8844
|
+
".clirc.json",
|
|
8845
|
+
"cli.config.js",
|
|
8846
|
+
"cli.config.ts",
|
|
8847
|
+
".cli.config.mts"
|
|
8848
|
+
];
|
|
8844
8849
|
/**
|
|
8845
8850
|
* 读取配置文件
|
|
8846
8851
|
* @returns 配置对象
|
|
@@ -8849,9 +8854,17 @@ async function readConfig() {
|
|
|
8849
8854
|
const cwd = process.cwd();
|
|
8850
8855
|
for (const configFile of CONFIG_FILES) {
|
|
8851
8856
|
const configPath = join(cwd, configFile);
|
|
8852
|
-
if (existsSync(configPath))
|
|
8853
|
-
|
|
8854
|
-
|
|
8857
|
+
if (!existsSync(configPath)) continue;
|
|
8858
|
+
try {
|
|
8859
|
+
let config;
|
|
8860
|
+
if (configFile.endsWith(".json")) {
|
|
8861
|
+
const content = readFileSync(configPath, "utf-8");
|
|
8862
|
+
config = JSON.parse(content);
|
|
8863
|
+
} else {
|
|
8864
|
+
const module = await import(configPath);
|
|
8865
|
+
config = module.default || module;
|
|
8866
|
+
}
|
|
8867
|
+
return config;
|
|
8855
8868
|
} catch (err) {
|
|
8856
8869
|
console.warn(`读取配置文件失败 (${configFile}): ${err.message}`);
|
|
8857
8870
|
}
|