generated from KubrickCode/Template-Repository
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Document
Stan edited this page Oct 10, 2025
·
6 revisions
A CLI tool and npm library for selectively downloading specific files or folders from Git repositories.
Project Name: baedal (배달 - Korean word for "deliver")
Overcome limitations of existing tools (degit, giget, github-files-fetcher) by supporting:
- ✅ Single file download
- ✅ Folder download
- ✅ Automatic default branch detection
- ✅ Short URL syntax (
user/repo/path) - ✅ Private repository access
- TypeScript (Core implementation)
- Node.js (Runtime)
{
"dependencies": {
"commander": "^12.0.0",
"ofetch": "^1.3.0",
"tar-fs": "^3.0.0",
"picocolors": "^1.0.0",
"globby": "^14.0.0"
},
"devDependencies": {
"typescript": "^5.3.0",
"tsup": "^8.0.0",
"vitest": "^1.0.0",
"@types/node": "^20.0.0",
"@types/tar-fs": "^2.0.0"
}
}-
tsup - Zero-config TypeScript bundler
- ESM + CJS dual output
- Type declarations auto-generation
- Fast builds
- GitHub
- GitLab
- Bitbucket
Support various URL formats:
user/repo/path/file.md # Short form (GitHub default)
user/repo#branch/path/file.md # With branch
gh:user/repo/path # GitHub explicit
gitlab:user/repo/path # GitLab
bitbucket:user/repo/path # Bitbucket
https://github.com/user/repo/blob/main/file.md # Full URLAuto-detect default branch via platform APIs when branch is omitted:
- GitHub API:
/repos/{owner}/{repo}→default_branch - GitLab API:
/api/v4/projects/{id}→default_branch - Bitbucket API:
/2.0/repositories/{owner}/{repo}→mainbranch
- File: Direct download via raw URL
- Folder: Download as tarball, extract specific path
- Exclude specific files/folders (glob patterns)
-
.gitignorestyle pattern support
Platform-specific authentication:
-
GitHub: Personal Access Token (
Authorization: token {token}) -
GitLab: Private Token (
PRIVATE-TOKEN: {token}) - Bitbucket: Basic Auth
Authentication methods:
- CLI option (
--auth) - Environment variables (
BAEDAL_AUTH,GITHUB_TOKEN, etc.) - Config file (
~/.baedalrc)
# Download file
baedal user/repo/path/file.md
# Download folder
baedal user/repo/path/folder
# Specify branch
baedal user/repo#dev/path/file.md
# Specify output directory
baedal user/repo/file.md -o ./output
# Private repository
baedal user/repo/file.md --auth YOUR_TOKEN
# GitLab/Bitbucket
baedal gitlab:user/repo/file.md
baedal bitbucket:user/repo/folder-o, --out <PATH> Output directory
--auth <TOKEN> Authentication token
--exclude <PATTERN> File pattern to exclude
--branch <BRANCH> Branch name (instead of auto-detect)
--force Overwrite existing files
--dry-run Simulate without actual download
import { fetchFile, fetchFolder } from 'baedal';
// Download file
await fetchFile('user/repo/path/file.md', {
out: './output',
auth: process.env.GITHUB_TOKEN
});
// Download folder
await fetchFolder('user/repo/path/folder', {
out: './output',
exclude: ['**/*.test.js', 'node_modules/**']
});- Project setup (TypeScript + tsup)
- URL parsing implementation
- GitHub provider implementation
- File/folder download basic functionality
- CLI basic interface
- npm package structure
- npm publish
- GitLab provider implementation
- Bitbucket provider implementation
- Private repository support
- File filtering
- Test coverage
- Documentation
- Performance optimization
- Unified file + folder support (unique)
- Automatic branch detection (missing in github-files-fetcher)
- Short URL syntax (missing in github-files-fetcher)
- 3 major platform support
- TypeScript native (type-safe, great DX)
- Modern maintenance (most existing tools are outdated)
- giget - Architecture, Provider pattern
- degit - URL parsing logic
- github-files-fetcher - File download approach