@ashishkumar472/cf-git
v1.0.5
Published
A Cloudflare Workers-native fork of isomorphic-git
Downloads
9,563
Maintainers
Readme
@ashishkumar472/cf-git
A Cloudflare Workers-native fork of isomorphic-git, ported to work with the Cloudflare Workers runtime.
Key Differences from Upstream
1. Native Cloudflare Workers APIs
- SHA-1 Hashing: Uses
crypto.subtle.digestSync()(Workers-specific synchronous crypto API) - No CommonJS Dependencies: Removed
sha.js,async-lock, andpath-browserify - Pure ESM: All modules are ES modules with no CommonJS fallbacks
2. Modified Components
src/utils/shasum.js
- Replaced
sha.jswith nativecrypto.subtle.digestSync() - Falls back to async
crypto.subtle.digest()if needed - Workers-only: No Node.js crypto support
src/utils/join.js
- Replaced
path-browserifywith simple string-based path joining - Sufficient for git operations which always use forward slashes
src/utils/AsyncLock.js
- Replaced
async-lockwith queue-based implementation
3. Testing
Tests run in actual Cloudflare Workers runtime using @cloudflare/vitest-pool-workers:
# Run Workers-specific tests
npm run test:workers
# Watch mode
npm run test:workers:watchWhy This Fork?
The original isomorphic-git uses CommonJS modules (require()) which don't work in Cloudflare Workers' ESM-only environment. Instead of using polyfills, we modified the source to use native Workers APIs directly, resulting in:
- Faster performance - Native crypto is faster than polyfills
- Smaller bundle - Fewer dependencies
- No build issues - No CommonJS transformation needed
- Type-safe - Proper Workers types
- Tested - Tests run in actual Workers runtime
Development
# Install dependencies
npm install --legacy-peer-deps
# Build
npm run build
# Test in Workers environment
npm run test:workers
# Format code
npm run formatInstallation
npm install @ashishkumar472/cf-git
# or
bun add @ashishkumar472/cf-gitUsage
import git from '@ashishkumar472/cf-git'
import http from '@ashishkumar472/cf-git/http/web'
// All isomorphic-git APIs work the same way
await git.clone({
fs,
http,
dir: '/repo',
url: 'https://github.com/owner/repo',
})Compatibility
Works with:
- Cloudflare Workers
- Cloudflare Pages Functions
- Miniflare (local development)
- Vitest with Workers pool
Does NOT work with:
- Node.js (use original isomorphic-git)
- Browser (no digestSync support)
- Other edge runtimes without Workers APIs
License
MIT (same as original isomorphic-git)
Credits
Based on isomorphic-git by William Hilton and contributors.
