{"_id":"gittar","_rev":"2887246","name":"gittar","description":":guitar: Download and/or Extract git repositories (GitHub, GitLab, BitBucket). Cross-platform and Offline-first!","dist-tags":{"latest":"0.1.1"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"time":{"modified":"2022-11-04T06:13:59.000Z","created":"2017-08-02T05:05:41.910Z","0.1.1":"2018-04-09T18:21:01.320Z","0.1.0":"2017-08-04T21:47:25.544Z","0.0.0":"2017-08-02T05:05:41.910Z"},"users":{},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"repository":{"type":"git","url":"git+https://github.com/lukeed/gittar.git"},"versions":{"0.1.1":{"name":"gittar","version":"0.1.1","repository":{"type":"git","url":"git+https://github.com/lukeed/gittar.git"},"description":":guitar: Download and/or Extract git repositories (GitHub, GitLab, BitBucket). Cross-platform and Offline-first!","main":"lib/index.js","license":"MIT","files":["lib"],"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"test":"tape test/*.js | tap-spec"},"keywords":["archive","bitbucket","download","extract","git","github","gitlab","offline","offline-first","repo","repository","scaffold","tarball"],"dependencies":{"mkdirp":"^0.5.1","tar":"^4.4.1"},"devDependencies":{"rimraf":"^2.6.1","tap-spec":"^4.1.1","tape":"^4.8.0"},"gitHead":"6574458550954e49643524b568e7c3a68be4bf29","bugs":{"url":"https://github.com/lukeed/gittar/issues"},"homepage":"https://github.com/lukeed/gittar#readme","_id":"gittar@0.1.1","_shasum":"d6993ea6160a86c8b7f3de722a61f73bc99e14b4","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"d6993ea6160a86c8b7f3de722a61f73bc99e14b4","size":4465,"noattachment":false,"key":"/gittar/-/gittar-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/gittar/download/gittar-0.1.1.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gittar_0.1.1_1523298061245_0.8223405801977739"},"_hasShrinkwrap":false,"publish_time":1523298061320,"_cnpm_publish_time":1523298061320,"_cnpmcore_publish_time":"2021-12-18T05:37:03.345Z"},"0.1.0":{"name":"gittar","version":"0.1.0","repository":{"type":"git","url":"git+https://github.com/lukeed/gittar.git"},"description":":guitar: Download and/or Extract git repositories (GitHub, GitLab, BitBucket). Cross-platform and Offline-first!","main":"lib/index.js","license":"MIT","files":["lib"],"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"test":"tape test/*.js | tap-spec"},"keywords":["archive","bitbucket","download","extract","git","github","gitlab","offline","offline-first","repo","repository","scaffold","tarball"],"dependencies":{"mkdirp":"^0.5.1","tar":"^3.1.9"},"devDependencies":{"rimraf":"^2.6.1","tap-spec":"^4.1.1","tape":"^4.8.0"},"gitHead":"bec839e24376dc41074d28c2d0520b772f094e76","bugs":{"url":"https://github.com/lukeed/gittar/issues"},"homepage":"https://github.com/lukeed/gittar#readme","_id":"gittar@0.1.0","_shasum":"49313ad1223e474b04c36b2cb06354bc5ab6b9b0","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"49313ad1223e474b04c36b2cb06354bc5ab6b9b0","size":4464,"noattachment":false,"key":"/gittar/-/gittar-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/gittar/download/gittar-0.1.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gittar-0.1.0.tgz_1501883245435_0.7844978524371982"},"directories":{},"publish_time":1501883245544,"_hasShrinkwrap":false,"_cnpm_publish_time":1501883245544,"_cnpmcore_publish_time":"2021-12-18T05:37:03.636Z"},"0.0.0":{"name":"gittar","version":"0.0.0","repository":{"type":"git","url":"git+https://github.com/lukeed/gittar.git"},"description":"WIP :guitar:","main":"lib/index.js","license":"MIT","files":["lib"],"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"engines":{"node":">=4"},"scripts":{"test":"tape test/*.js | tap-spec"},"keywords":[],"devDependencies":{},"gitHead":"b1337cb63828e9cd7baa7cff70cba81c8561bbba","bugs":{"url":"https://github.com/lukeed/gittar/issues"},"homepage":"https://github.com/lukeed/gittar#readme","_id":"gittar@0.0.0","_shasum":"caec6f75572fbf88be34ef5ffac1de73c9bfed2a","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.11.1","_npmUser":{"name":"lukeed","email":"luke@lukeed.com"},"dist":{"shasum":"caec6f75572fbf88be34ef5ffac1de73c9bfed2a","size":1257,"noattachment":false,"key":"/gittar/-/gittar-0.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/gittar/download/gittar-0.0.0.tgz"},"maintainers":[{"name":"lukeed","email":"luke@lukeed.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gittar-0.0.0.tgz_1501650341813_0.30095559172332287"},"directories":{},"publish_time":1501650341910,"_hasShrinkwrap":false,"_cnpm_publish_time":1501650341910,"_cnpmcore_publish_time":"2021-12-18T05:37:03.860Z"}},"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> :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#=> github/lukeed/mri/v1.1.0.tar.gz\n#=> gitlab/Rich-Harris/buble/v0.15.2.tar.gz\n#=> 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> **Important:** Please see [`gittar.fetch`](#gittarfetchrepo-options) for exceptions & 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//=> ~/.gittar/github/lukeed/gittar/master.tar.gz\n\ngittar.fetch('lukeed/tinydate#v1.0.0').then(console.log);\n//=> ~/.gittar/github/lukeed/tinydate/v1.0.0.tar.gz\n\ngittar.fetch('https://github.com/lukeed/mri').then(console.log);\n//=> ~/.gittar/github/lukeed/mri/master.tar.gz\n\ngittar.fetch('gitlab:Rich-Harris/buble#v0.15.2').then(console.log);\n//=> ~/.gittar/gitlab/Rich-Harris/buble/v0.15.2.tar.gz\n\ngittar.fetch('Rich-Harris/buble', { host:'gitlab' }).then(console.log);\n//=> ~/.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 => pkg += x).on('end', _ => {\n        const devDeps = JSON.parse(pkg).devDependencies || {};\n        console.log('~> 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`<br>\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//=> ~/.gittar/github/user/repo/master.tar.gz\n//=> https://github.com/user/repo/archive/master.tar.gz\n\nparse('user/repo#v1.0.0');\n//=> ~/.gittar/github/user/repo/v1.0.0.tar.gz\n//=> https://github.com/user/repo/archive/v1.0.0.tar.gz\n\nparse('user/repo#production');\n//=> ~/.gittar/github/user/repo/production.tar.gz\n//=> https://github.com/user/repo/archive/production.tar.gz\n\nparse('bitbucket:user/repo');\n//=> ~/.gittar/bitbucket/user/repo/master.tar.gz\n//=> https://bitbucket.org/user/repo/get/master.tar.gz\n\nparse('https://gitlab.com/user/repo');\n//=> ~/.gittar/gitlab/user/repo/master.tar.gz\n//=> https://gitlab.com/user/repo/repository/archive.tar.gz?ref=master\n```\n\n> **Note:** The `parse` function does not exist -- it's only demonstrating the _parsed_ values of the varying patterns.\n\n#### options.host\nType: `String`<br>\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//=> ~/.gittar/gitlab/user/repo/master.tar.gz\n//=> https://gitlab.com/user/repo/repository/archive.tar.gz?ref=master\n```\n\n#### options.force\nType: `Boolean`<br>\nDefault: `false`\n\nForce a HTTPS download. If there is an error with the network request, a local/cache lookup will follow.\n\n> **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`<br>\nDefault: `false`\n\nOnly attempt to use an existing, cached file. No network requests will be dispatched.\n\n> **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> **Important:** A `repo` pattern will be parsed (internally) as a filepath. No network requests will be dispatched.\n\n#### target\nType: `String`<br>\nDefault: `process.cwd()`\n\nThe target directory to place the archive's contents.\n\n> **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`<br>\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> **Note:** The `cwd` and `file` options are set for you and _cannot_ be changed!\n\n#### options.strip\nType: `Integer`<br>\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//=> contents: foo/**\n\n// strip:0 (retain tarball name)\ngittar.extract(file, 'foo', { strip:0 });\n//=> contents: foo/mri-master/**\n```\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","_attachments":{},"homepage":"https://github.com/lukeed/gittar#readme","bugs":{"url":"https://github.com/lukeed/gittar/issues"},"license":"MIT"}