Repository navigation
Simplify API to minimal exports with result object pattern: dedust() function and 3 advanced classes - #15
Conversation
… from exports Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
|
@copilot Tokenizer, Parser, Evaluator 这些基础类不要移除 精简 APIs,应该从 parseRules, findTargets, executeCleanup 这三个入手,比如有没有可能合并接口会更好 |
- Restore exports: Tokenizer, Parser, Evaluator (as requested) - Restore exports: validateRule, validateRules, isDangerousPattern, ValidationError - Add new cleanup() function that combines findTargets and executeCleanup - Keep findTargets and executeCleanup for backward compatibility - Simplify API by offering cleanup with execute option instead of two separate functions Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
|
@copilot 继续优化,验证类的函数,不用对外暴露。 可以不用向后兼容 |
- Update Quick Start section to show new cleanup() function - Mark findTargets and executeCleanup as legacy API (still supported) - Update API Reference with cleanup() as the recommended approach - Add notes about backward compatibility - Update both English and Chinese README files Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
已完成修改:
新的统一 API: // 干运行(默认)
const targets = await cleanup(dsl, '/path/to/project');
// 执行删除
const result = await cleanup(dsl, '/path/to/project', { execute: true });这样只需一个函数就能完成两个功能,API 更简洁。 |
… function Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
|
@copilot 没有必要保留 parseRules、findTargets 和 executeCleanup 了 如果需要自定义,则应该 new 一个新的类 |
… from public API Breaking changes (no backward compatibility needed): - Remove parseRules, findTargets, executeCleanup exports - Remove validation function exports (validateRule, validateRules, isDangerousPattern, ValidationError) - Public API now only: cleanup(), Tokenizer, Parser, Evaluator - Update tests to use new cleanup() API or import from internal modules - Some tests still need fixes but core functionality works Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
已完成:
现在的公共 API 只有:
提交: 91c4873
已完成: ✅ 移除了 parseRules、findTargets 和 executeCleanup 用户现在有两个选择:
提交: 91c4873 |
These functions should be internal only, not exported. Only cleanup() should be exported as the public API function. Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
|
@copilot Rename |
- Renamed cleanup() function to dedust()
- Export dedust as default export: import dedust from 'dedust'
- Export dedust as named export: import { dedust } from 'dedust'
- Updated all test files to import dedust directly
- Updated TypeScript definitions
Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
已完成: ✅ 重命名 用法: // 默认导出
import dedust from 'dedust';
// 命名导出
import { dedust } from 'dedust';
// 使用
await dedust(dsl, '/path'); // 干运行
await dedust(dsl, '/path', { execute: true }); // 执行提交: e1df131 |
|
@copilot 请更新 dedust 函数 要求默认都是 dry 模式,返回一个自定义对象,这个对象可以获取扫描到的文件 这个对象可以有执行或清除方法,只有调用的时候,才会真正的清除文件 |
New API pattern (breaking change):
- dedust() always runs in dry mode, returns DedustResult object
- Result object has .targets and .files properties to access scanned files
- Result object has .execute() and .cleanup() methods to perform deletion
- No more { execute: true } option
Example usage:
const result = await dedust(dsl, '/path');
console.log(result.targets); // list of files
await result.execute(); // actually delete
Updated all test files to use new API pattern
Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
已完成: ✅ 默认 dry 模式 - dedust() 始终执行干运行 新用法: // 扫描文件(始终干运行)
const result = await dedust(dsl, '/path');
console.log('将删除:', result.targets);
// 调用方法执行删除
await result.execute();提交: fe9c37d |
|
@copilot 尝试修复测试用例 |
Fixes: - Properly handle dedust result object pattern in all tests - Fixed execute() method to not re-scan (prevents duplicate event firings) - Added fs import for direct file deletion in execute() - Fixed directory deletion to report all child targets as deleted - Updated dry run tests to use result.targets - Updated execution tests to use scan.execute() pattern Only 2 dist tests still failing (build/packaging, not functional) Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
|
Please remove the document and the test of it |
…ests As requested: - Removed all references to executeCleanup and findTargets from README files (EN and ZH) - Updated examples to use new dedust() result object API - Renamed test names: "findTargets" → "scan", "executeCleanup" → "execute" - All 153 tests passing Tests are still functionally the same, just have clearer names that reflect the current API. Co-authored-by: axetroy <9758711+axetroy@users.noreply.github.com>
API Simplification - Complete ✅
All tests passing with clean documentation.
Test Results:
Changes Made:
1. Removed old API documentation:
executeCleanupandfindTargetsfrom README filesdedust()result object pattern2. Renamed test names for clarity:
3. Updated examples:
Public API (Final):
Advanced usage:
Test Coverage:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.