A smaller and lighter degit alternative with Typescript support.
- Fast
- Caches results by default so nothing is refetched unnecessarily
- Small
- Only 24.9kB unpacked on npm (22.6kB minified, bundled and gzipped with all dependencies)
- Fault-tolerant
- Can recover from a corrupted cache file
- XDG Friendly
- Respects XDG directories
- Minimal Dependencies
- Only has a single dependency (tar) for extracting the downloaded tarballs
- Flexible Fetching
- Can fetch from different git providers. You can even provide your own fetcher!
A small CLI wrapper for @begit/core
Run npm i -g @begit/cli to install. Invoke with begit
For a comprehensive list of features, use the help command as below:
begit --helpWhich will print something like:
begit
ARGUMENTS:
<URL> - The URL to clone
[Destination] - Folder to clone into [optional]
OPTIONS:
--subdir, -s <str> - Subdirectory of repository to clone [optional]
--token, -t <str> - GitHub API Token [optional]
FLAGS:
--no-cache - Disables caching the downloaded tarball for the future
--help, -h - show helpTo clone a repository to the current working directory, simply:
begit Tommypop2/begitURLs are also accepted:
begit https://github.com/Tommypop2/begitYou can also specify the desired branch via a #:
begit Tommypop2/begit#mainUse any of the above options in conjunction with the --subdir flag.
begit Tommypop2/begit --subdir packagesOr, shortened to -s
begit Tommypop2/begit -s packagesimport { downloadRepo } from "@begit/core";
await downloadRepo({
repo: {
owner: "Tommypop2",
name: "begit",
branch: undefined,
subdir: undefined,
},
dest: "cool_project",
});The code above downloads this repository into a folder named cool_project.
Alternatively, downloadAndExtract could be used in place of downloadRepo to opt out of automatically attempting to handle errors
import { downloadRepo } from "@begit/core";
const custom_hash = "9e4e51beb1ac76e6c37be1757f14b904617a2f9b";
await downloadRepo({
repo: {
owner: "Tommypop2",
name: "begit",
branch: undefined,
subdir: undefined,
hash: custom_hash,
},
dest: "cool_project",
});import { downloadRepo } from "@begit/core";
const most_recent_hash = await getMostRecentCachedCommit("Tommypop2", "begit"); // string | undefined
await downloadRepo({
repo: {
owner: "Tommypop2",
name: "begit",
branch: undefined,
subdir: undefined,
hash: most_recent_hash,
},
dest: "cool_project",
});import { downloadRepo, matchFetcher } from "@begit/core";
const fetcher = matchFetcher("github");
await downloadRepo({
repo: {
owner: "Tommypop2",
name: "begit",
branch: undefined,
subdir: undefined,
hash: most_recent_hash,
},
dest: "cool_project",
}, fetcher);