Skip to content

Commit abb1191

Browse files
committed
Add English documentation and Claude Code guidance
1 parent 3f6a78a commit abb1191

File tree

4 files changed

+416
-80
lines changed

4 files changed

+416
-80
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
All notable changes to this project will be documented in this file.
44

5+
## [1.0.1] - 2025.07.15
6+
7+
### Added
8+
- English README.md with comprehensive documentation
9+
- Chinese documentation preserved in README.zh-CN.md
10+
- CLAUDE.md file for Claude Code integration guidance
11+
- Bilingual documentation support with cross-references
12+
13+
### Changed
14+
- Converted main README from Chinese to English
15+
- Improved documentation structure and examples
16+
- Enhanced development and contribution guidelines
17+
518
## [1.0.0] - 2025.07.09
619

720
### Added

CLAUDE.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
This is a TypeScript CLI tool that generates directory tree structures with various output formats (text, JSON, markdown). The tool is built as a Node.js package using commander.js for CLI parsing and includes formatting capabilities with colored output.
8+
9+
## Commands
10+
11+
### Development Commands
12+
- `npm run dev` - Run CLI tool in development mode with ts-node
13+
- `npm run build` - Compile TypeScript to JavaScript (outputs to dist/)
14+
- `npm run test` - Run Jest tests with coverage
15+
- `npm run format` - Format code with Prettier
16+
- `npm run format:check` - Check code formatting (also used as lint)
17+
- `npm run clean` - Remove dist/ directory
18+
19+
### CLI Usage (After Build)
20+
- `tree-cli [path]` - Basic tree generation
21+
- `tree-cli quick [path]` - Quick view excluding common build dirs
22+
- `tree-cli dev [path]` - Development view excluding more directories
23+
24+
## Architecture
25+
26+
### Core Components
27+
28+
1. **src/cli.ts** - CLI entry point using commander.js, handles argument parsing and command routing
29+
2. **src/index.ts** - Main API export, provides `generateTree()` function for programmatic use
30+
3. **src/tree-builder.ts** - Core tree building logic, handles file system traversal and filtering
31+
4. **src/formatters.ts** - Output formatters (TextFormatter, JsonFormatter, MarkdownFormatter)
32+
5. **src/types.ts** - TypeScript type definitions
33+
34+
### Key Design Patterns
35+
36+
- **Factory Pattern**: `createFormatter()` function creates appropriate formatter based on options
37+
- **Builder Pattern**: `TreeBuilder` class constructs file tree with various filtering options
38+
- **Strategy Pattern**: Different formatters implement common interface for output generation
39+
40+
### File Structure
41+
- Source code in `src/`
42+
- Tests in `src/__tests__/`
43+
- Built output in `dist/` (created by TypeScript compiler)
44+
- Coverage reports in `coverage/`
45+
46+
## Testing
47+
48+
Uses Jest with TypeScript support via ts-jest. Test files use `.test.ts` extension and are located in `src/__tests__/`.
49+
50+
## Publishing
51+
52+
The package uses npm scripts for publishing workflow:
53+
- `prepublishOnly` runs clean, build, and test before publishing
54+
- Package exports both CLI binary (`dist/cli.js`) and library (`dist/index.js`)

README.md

Lines changed: 82 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -5,132 +5,134 @@
55
[![codecov](https://codecov.io/gh/oyal/tree-cli-tool/branch/main/graph/badge.svg)](https://codecov.io/gh/oyal/tree-cli-tool)
66
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
77

8-
一个功能强大的命令行工具,用于显示目录树状结构,支持多种配置选项和输出格式。
8+
A powerful command-line tool to display directory tree structure with various configuration options and output formats.
99

10-
## 安装
10+
**[中文文档](README.zh-CN.md)**
11+
12+
## Installation
1113

1214
```bash
1315
npm install -g tree-cli-tool
1416
```
1517

16-
## 基本用法
18+
## Basic Usage
1719

1820
```bash
19-
# 显示当前目录的树状结构
21+
# Display tree structure of current directory
2022
tree-cli
2123

22-
# 显示指定目录的树状结构
24+
# Display tree structure of specified directory
2325
tree-cli /path/to/directory
2426

25-
# 限制遍历深度
27+
# Limit traversal depth
2628
tree-cli -d 3
2729

28-
# 显示文件大小
30+
# Show file sizes
2931
tree-cli -s
3032

31-
# 输出为 JSON 格式
33+
# Output as JSON format
3234
tree-cli -f json
3335

34-
# 排除特定文件/目录
36+
# Exclude specific files/directories
3537
tree-cli -e "node_modules" "*.log" ".git"
3638
```
3739

38-
## 命令选项
40+
## Command Options
3941

40-
### 基本选项
42+
### Basic Options
4143

42-
- `[path]` - 目标目录路径(默认:当前目录)
43-
- `-d, --max-depth <number>` - 最大遍历深度,-1 表示无限制(默认:-1)
44-
- `-f, --format <type>` - 输出格式:text|json|markdown(默认:text
44+
- `[path]` - Target directory path (default: current directory)
45+
- `-d, --max-depth <number>` - Maximum traversal depth, -1 for unlimited (default: -1)
46+
- `-f, --format <type>` - Output format: text|json|markdown (default: text)
4547

46-
### 过滤选项
48+
### Filter Options
4749

48-
- `-e, --exclude <patterns...>` - 排除模式(支持 glob 风格)
49-
- `--include-types <types...>` - 只包含指定文件类型(扩展名)
50-
- `--exclude-types <types...>` - 排除指定文件类型(扩展名)
51-
- `-i, --ignore-pattern <regex>` - 正则表达式忽略模式
50+
- `-e, --exclude <patterns...>` - Exclude patterns (supports glob style)
51+
- `--include-types <types...>` - Include only specified file types (extensions)
52+
- `--exclude-types <types...>` - Exclude specified file types (extensions)
53+
- `-i, --ignore-pattern <regex>` - Regular expression ignore pattern
5254

53-
### 显示选项
55+
### Display Options
5456

55-
- `-a, --show-hidden` - 显示隐藏文件和目录
56-
- `-s, --show-size` - 显示文件大小
57-
- `--show-date` - 显示修改时间
58-
- `-D, --dirs-only` - 只显示目录
59-
- `--no-color` - 禁用彩色输出
57+
- `-a, --show-hidden` - Show hidden files and directories
58+
- `-s, --show-size` - Show file sizes
59+
- `--show-date` - Show modification times
60+
- `-D, --dirs-only` - Show directories only
61+
- `--no-color` - Disable colored output
6062

61-
### 输出选项
63+
### Output Options
6264

63-
- `-o, --output <file>` - 输出到文件而不是标准输出
65+
- `-o, --output <file>` - Output to file instead of stdout
6466

65-
## 预设命令
67+
## Preset Commands
6668

67-
### quick 命令
69+
### quick Command
6870

69-
快速查看目录结构,自动排除常见的构建目录:
71+
Quick directory structure view, automatically excludes common build directories:
7072

7173
```bash
7274
tree-cli quick [path] [-d depth]
7375
```
7476

75-
自动排除:`node_modules`, `.git`, `dist`, `build`, `.next`, `.nuxt`
77+
Automatically excludes: `node_modules`, `.git`, `dist`, `build`, `.next`, `.nuxt`
7678

77-
### dev 命令
79+
### dev Command
7880

79-
开发者友好的视图,排除更多构建和缓存目录:
81+
Developer-friendly view, excludes more build and cache directories:
8082

8183
```bash
8284
tree-cli dev [path] [-d depth]
8385
```
8486

85-
自动排除:`node_modules`, `.git`, `dist`, `build`, `.next`, `.nuxt`, `coverage`, `.nyc_output`, `.cache`, `tmp`, `temp`, `*.log`, `.DS_Store`, `Thumbs.db`
87+
Automatically excludes: `node_modules`, `.git`, `dist`, `build`, `.next`, `.nuxt`, `coverage`, `.nyc_output`, `.cache`, `tmp`, `temp`, `*.log`, `.DS_Store`, `Thumbs.db`
8688

87-
## 使用示例
89+
## Usage Examples
8890

89-
### 1. 基本目录树
91+
### 1. Basic Directory Tree
9092

9193
```bash
9294
tree-cli
9395
```
9496

95-
### 2. 限制深度并显示文件大小
97+
### 2. Limit Depth and Show File Sizes
9698

9799
```bash
98100
tree-cli -d 2 -s
99101
```
100102

101-
### 3. 只显示 JavaScript TypeScript 文件
103+
### 3. Show Only JavaScript and TypeScript Files
102104

103105
```bash
104106
tree-cli --include-types js ts jsx tsx
105107
```
106108

107-
### 4. 排除特定目录和文件类型
109+
### 4. Exclude Specific Directories and File Types
108110

109111
```bash
110112
tree-cli -e "node_modules" "dist" --exclude-types log tmp
111113
```
112114

113-
### 5. 输出为 JSON 格式
115+
### 5. Output as JSON Format
114116

115117
```bash
116118
tree-cli -f json -o tree.json
117119
```
118120

119-
### 6. 使用正则表达式排除文件
121+
### 6. Use Regular Expression to Exclude Files
120122

121123
```bash
122124
tree-cli -i "test.*\\.js$"
123125
```
124126

125-
### 7. 开发者模式查看项目结构
127+
### 7. Developer Mode View Project Structure
126128

127129
```bash
128130
tree-cli dev -d 3
129131
```
130132

131-
## 输出格式
133+
## Output Formats
132134

133-
### Text 格式(默认)
135+
### Text Format (Default)
134136

135137
```
136138
project/
@@ -144,7 +146,7 @@ project/
144146
2 directories, 3 files
145147
```
146148

147-
### JSON 格式
149+
### JSON Format
148150

149151
```json
150152
{
@@ -162,7 +164,7 @@ project/
162164
}
163165
```
164166

165-
### Markdown 格式
167+
### Markdown Format
166168

167169
```markdown
168170
# Directory Tree: project
@@ -181,7 +183,7 @@ project/
181183
- **Files**: 3
182184
```
183185

184-
## 作为 Node.js 模块使用
186+
## Use as Node.js Module
185187

186188
```javascript
187189
import { generateTree } from 'tree-cli-tool';
@@ -198,70 +200,70 @@ console.log(result.formatted);
198200
console.log('Stats:', result.stats);
199201
```
200202

201-
## 开发
203+
## Development
202204

203-
### 本地开发
205+
### Local Development
204206

205207
```bash
206-
# 克隆仓库
208+
# Clone repository
207209
git clone https://github.com/oyal/tree-cli-tool.git
208210
cd tree-cli-tool
209211

210-
# 安装依赖
212+
# Install dependencies
211213
npm install
212214

213-
# 开发模式运行
215+
# Run in development mode
214216
npm run dev
215217

216-
# 构建项目
218+
# Build project
217219
npm run build
218220

219-
# 运行测试
221+
# Run tests
220222
npm test
221223

222-
# 代码格式化
224+
# Format code
223225
npm run format
224226

225-
# 检查代码格式
227+
# Check code formatting
226228
npm run format:check
227229
```
228230

229-
### 代码质量保证
231+
### Code Quality Assurance
230232

231-
项目配置了以下代码质量工具:
233+
The project is configured with the following code quality tools:
232234

233-
- **Prettier**: 代码格式化
234-
- **GitHub Actions**: 自动化 CI/CD 流程
235+
- **Prettier**: Code formatting
236+
- **GitHub Actions**: Automated CI/CD pipeline
235237

236-
**代码质量检查** 在以下时机自动运行:
238+
**Code quality checks** run automatically at:
237239

238-
1. GitHub Actions CI 流程中
239-
2. 发布前自动检查(prepublishOnly
240+
1. GitHub Actions CI pipeline
241+
2. Pre-publish checks (prepublishOnly)
240242

241-
### 发布流程
243+
### Publishing Process
242244

243-
本项目使用 GitHub Actions 自动化发布流程:
245+
This project uses GitHub Actions for automated publishing:
244246

245-
1. **自动发布** (推荐):
246-
- 进入 GitHub Actions 页面
247-
- 选择 "Publish" 工作流
248-
- 选择版本类型 (patch/minor/major)
249-
- 点击运行
247+
1. **Automated Publishing** (Recommended):
248+
- Go to GitHub Actions page
249+
- Select "Publish" workflow
250+
- Choose version type (patch/minor/major)
251+
- Click run
250252

251-
2. **手动发布**
253+
2. **Manual Publishing**:
252254
```bash
253-
npm version patch # minor, major
255+
npm version patch # or minor, major
254256
git push origin main --tags
255257
```
256258

257-
### 贡献指南
259+
### Contributing
258260

259-
1. Fork 本仓库
260-
2. 创建功能分支 (`git checkout -b feature/amazing-feature`)
261-
3. 提交更改 (`git commit -m 'Add some amazing feature'`)
262-
4. 推送到分支 (`git push origin feature/amazing-feature`)
263-
5. 创建 Pull Request
261+
1. Fork this repository
262+
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
263+
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
264+
4. Push to the branch (`git push origin feature/amazing-feature`)
265+
5. Create a Pull Request
264266

265-
## 许可证
267+
## License
266268

267-
MIT
269+
MIT

0 commit comments

Comments
 (0)