Get started

@hulla/gittar

Copy a repository folder into a starter project, with a separate cache and an explicit refresh policy.

On this page

@hulla/gittar downloads a repository’s files over HTTPS and extracts them into a cache. Use it in a Bun script to fetch a starter project or a collection of templates.

You get the files at one revision, without a .git directory or commit history.

Edit options for the local acme/starters template.

download.options.jsonEditable
{
  "subpath": "web",
  "update": "never",
  "outDir": "./project-1"
}

Cache: 0 simulated downloads · full web/ + api/ snapshot

Copy a starter, change its title, then use a new destination. The next copy starts from the unchanged cache.

Local filesystem model; no downloads or files written. Reusing a destination replaces that copy, as a real copy operation would.

Build a template downloader that copies a repository to a local folder, then run it again to observe the cache.

TypeScript
import gittar from '@hulla/gittar'

const snapshot = await gittar({
  url: 'hulladev/gittar',
  branch: 'master',
  outDir: './downloaded-template',
})

console.log(snapshot.files.length, snapshot.fromCache)

The full repository goes into the cache. A separate outDir receives a copy. Add a subpath when you only need one directory.

Bun is required

Extraction and copying use Bun APIs and system commands. Run these scripts with Bun in an environment with tar, cp, and mkdir. The default commit check also uses Git.

PolicyWhat a later call does
commit (default)Checks the remote branch and downloads if its commit changed.
alwaysDownloads again, even when cached files exist.
neverUses existing cached files without checking the remote. Downloads on a cache miss.

Read Caching and copying before building an updater. Use the reference to look up options, returned metadata, and error types.