{"id":13526971,"url":"https://github.com/lukeed/gittar","last_synced_at":"2025-07-21T23:33:47.040Z","repository":{"id":23575824,"uuid":"99074174","full_name":"lukeed/gittar","owner":"lukeed","description":":guitar: Download and/or Extract git repositories (GitHub, GitLab, BitBucket). Cross-platform and Offline-first!","archived":false,"fork":false,"pushed_at":"2019-06-29T20:42:01.000Z","size":23,"stargazers_count":122,"open_issues_count":7,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-02T23:40:05.668Z","etag":null,"topics":["archive","bitbucket","download","extract","git","github","gitlab","offline","offline-first","repo","repository","scaffold","tarball"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lukeed.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-02T05:06:00.000Z","updated_at":"2025-01-15T23:59:27.000Z","dependencies_parsed_at":"2022-07-27T04:02:26.200Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/gittar","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lukeed/gittar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fgittar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fgittar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fgittar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fgittar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/gittar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Fgittar/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266403123,"owners_count":23923404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archive","bitbucket","download","extract","git","github","gitlab","offline","offline-first","repo","repository","scaffold","tarball"],"created_at":"2024-08-01T06:01:38.630Z","updated_at":"2025-07-21T23:33:47.015Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":[],"categories":["Repository","JavaScript"],"sub_categories":["Git"],"readme":"# gittar [![TravisCI Status](https://travis-ci.org/lukeed/gittar.svg?branch=master)](https://travis-ci.org/lukeed/gittar) [![AppVeyor Status](https://ci.appveyor.com/api/projects/status/4xj1vr9pyieaoibf?svg=true)](https://ci.appveyor.com/project/lukeed/gittar)\n\n\u003e :guitar: Download and/or Extract git repositories (GitHub, GitLab, BitBucket). Cross-platform and Offline-first!\n\nGittar is a Promise-based API that downloads `*.tar.gz` files from GitHub, GitLab, and BitBucket.\n\nAll archives are saved to the `$HOME/.gittar` directory with the following structure:\n\n```sh\n{HOSTNAME}/{USER}/{REPO}/{BRANCH-TAG}.tar.gz\n#=\u003e github/lukeed/mri/v1.1.0.tar.gz\n#=\u003e gitlab/Rich-Harris/buble/v0.15.2.tar.gz\n#=\u003e github/vuejs-templates/pwa/master.tar.gz\n```\n\nBy default, new `gittar.fetch` requests will check the local filesystem for a matching tarball _before_ intiating a new remote download!\n\n\u003e **Important:** Please see [`gittar.fetch`](#gittarfetchrepo-options) for exceptions \u0026 behaviors!\n\n\n## Install\n\n```\n$ npm install --save gittar\n```\n\n\n## Usage\n\n```js\nconst gittar = require('gittar');\n\ngittar.fetch('lukeed/gittar').then(console.log);\n//=\u003e ~/.gittar/github/lukeed/gittar/master.tar.gz\n\ngittar.fetch('lukeed/tinydate#v1.0.0').then(console.log);\n//=\u003e ~/.gittar/github/lukeed/tinydate/v1.0.0.tar.gz\n\ngittar.fetch('https://github.com/lukeed/mri').then(console.log);\n//=\u003e ~/.gittar/github/lukeed/mri/master.tar.gz\n\ngittar.fetch('gitlab:Rich-Harris/buble#v0.15.2').then(console.log);\n//=\u003e ~/.gittar/gitlab/Rich-Harris/buble/v0.15.2.tar.gz\n\ngittar.fetch('Rich-Harris/buble', { host:'gitlab' }).then(console.log);\n//=\u003e ~/.gittar/gitlab/Rich-Harris/buble/master.tar.gz\n\nconst src = '...local file or repo pattern...';\nconst dest = '/path/to/foobar';\n\ngittar.extract(src, dest, {\n  filter(path, entry) {\n    if (path.includes('package.json')) {\n      let pkg = '';\n      entry.on('data', x =\u003e pkg += x).on('end', _ =\u003e {\n        const devDeps = JSON.parse(pkg).devDependencies || {};\n        console.log('~\u003e new devDependencies:', Object.keys(devDeps));\n      });\n    }\n\n    if (path.includes('.babelrc')) {\n      return false; // ignore this file!\n    }\n\n    return true; // keep all other files\n  }\n});\n```\n\n\n## API\n\n### gittar.fetch(repo, options)\n\nType: `Promise`\u003cbr\u003e\nReturns: `String`\n\n***Behavior***\n\nParses the `repo` name, then looks for matching tarball on filesystem. Otherwise, a HTTPS request is dispatched and then, if successful, the archive is saved to `~/.gittar` at the appropriate path.\n\n***Exceptions***\n\n- If Gittar detects that your machine is not connected to the internet, or if [`useCache`](#optionsusecache) is `true`, then it will _only_ attempt a local fetch.\n- If `repo` is (or is assumed to be) a `master` branch, or if [`force`](#optionsforce) is `true`, then the archive will be downloaded over HTTPS _before_ checking local cache.\n\n#### repo\nType: `String`\n\nThe name, link, or pattern for a git repository.\n\nOptionally provide a tag or branch name, otherwise `master` is assumed.\n\n```js\nparse('user/repo');\n//=\u003e ~/.gittar/github/user/repo/master.tar.gz\n//=\u003e https://github.com/user/repo/archive/master.tar.gz\n\nparse('user/repo#v1.0.0');\n//=\u003e ~/.gittar/github/user/repo/v1.0.0.tar.gz\n//=\u003e https://github.com/user/repo/archive/v1.0.0.tar.gz\n\nparse('user/repo#production');\n//=\u003e ~/.gittar/github/user/repo/production.tar.gz\n//=\u003e https://github.com/user/repo/archive/production.tar.gz\n\nparse('bitbucket:user/repo');\n//=\u003e ~/.gittar/bitbucket/user/repo/master.tar.gz\n//=\u003e https://bitbucket.org/user/repo/get/master.tar.gz\n\nparse('https://gitlab.com/user/repo');\n//=\u003e ~/.gittar/gitlab/user/repo/master.tar.gz\n//=\u003e https://gitlab.com/user/repo/repository/archive.tar.gz?ref=master\n```\n\n\u003e **Note:** The `parse` function does not exist -- it's only demonstrating the _parsed_ values of the varying patterns.\n\n#### options.host\nType: `String`\u003cbr\u003e\nDefault: `github`\n\nThe hostname for the repository.\n\nSpecifying a \"hint\" in the [`repo`](#repo) will take precedence over this value.\n\n```js\nfetch('gitlab:user/repo', { host:'bitbucket' });\n//=\u003e ~/.gittar/gitlab/user/repo/master.tar.gz\n//=\u003e https://gitlab.com/user/repo/repository/archive.tar.gz?ref=master\n```\n\n#### options.force\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nForce a HTTPS download. If there is an error with the network request, a local/cache lookup will follow.\n\n\u003e **Note:** A network request is also forced if the `repo` is (or is assumed to be) a `master` branch!\n\n#### options.useCache\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nOnly attempt to use an existing, cached file. No network requests will be dispatched.\n\n\u003e **Note:** Gittar enacts this option if it detects that there is no internet connectivity.\n\n\n### gittar.extract(file, target, options)\n\n#### file\nType: `String`\n\nA filepath to extract. Also accepts a [`repo`](#repo) pattern!\n\n\u003e **Important:** A `repo` pattern will be parsed (internally) as a filepath. No network requests will be dispatched.\n\n#### target\nType: `String`\u003cbr\u003e\nDefault: `process.cwd()`\n\nThe target directory to place the archive's contents.\n\n\u003e **Note:** Value will be resolved (see [`path.resolve`](https://nodejs.org/api/path.html#path_path_resolve_paths)) if not already an absolute path.\n\n#### options\nType: `Object`\u003cbr\u003e\nDefault: `{ strip:1 }`\n\nAll options are passed directly to [`tar.extract`](https://github.com/npm/node-tar#tarxoptions-filelist-callback-alias-tarextract).\n\n\u003e **Note:** The `cwd` and `file` options are set for you and _cannot_ be changed!\n\n#### options.strip\nType: `Integer`\u003cbr\u003e\nDefault: `1`\n\nBy default, `gittar` will strip the name of tarball from the extracted filepath.\n\n```js\nconst file = 'lukeed/mri#master';\n\n// strip:1 (default)\ngittar.extract(file, 'foo');\n//=\u003e contents: foo/**\n\n// strip:0 (retain tarball name)\ngittar.extract(file, 'foo', { strip:0 });\n//=\u003e contents: foo/mri-master/**\n```\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fgittar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Fgittar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Fgittar/lists"}