{"_id":"@awam/gittar","_rev":"1-8babcecc04ef3f07d88680c6e64bef66","name":"@awam/gittar","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.2":{"name":"@awam/gittar","version":"0.1.2","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":"3ee1249846d689dbe404cc155cc3a434071aa988","bugs":{"url":"https://github.com/lukeed/gittar/issues"},"homepage":"https://github.com/lukeed/gittar#readme","_id":"@awam/gittar@0.1.2","_npmVersion":"6.0.0","_nodeVersion":"8.11.1","_npmUser":{"name":"awam","email":"ewanharris93@gmail.com"},"dist":{"integrity":"sha512-kPBf3nONmi6vADVHijvPDyUwqIf42pBZpqRH6p8YfxV7SqBXi4W3jnxgoxb4nFKWCrkxqFyToPTDWiebGceZ8g==","shasum":"ed75dac2110bad45d181f7e9ce0fd24563d501d4","tarball":"https://registry.npmjs.org/@awam/gittar/-/gittar-0.1.2.tgz","fileCount":4,"unpackedSize":10884,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa8tB7CRA9TVsSAnZWagAAQB0P/1v9fnb2t19uo3z/QGft\nyEAOCwsBOHFjdlBgdtE5b6wfdaGUDZs/XsoA/fPjChXN+wxRKEebMw6q5A5d\nrXeUc2aRTNvijtBPsDhJb1yjjAniagk79/lj/df3E4gYkm+ZsPuX+ITeN8Og\nl9I1zBS68ClXUVDZMbHDbpncWsd4nBsbvz0oBObwLiGkbNQo7Jcz/t2ncnl1\n7nfsZIr8fUIIRFi7I6gB3Nr9k5BHkryx88d2Lw/DPRD7DLRd7Da5O5X+IVzD\nyjHZk8SmCBSUohoD7FM5xYh2ozcKVVUL7ZO+B61Uu4w1kMmXmbX5MzeYVoxi\n4RP9HzSKxf0TvH29ym6rs7Q5ki1MDGXqxZzAsWOtjcuYlwo4+sAmpryzDQbe\nUUMHXqOznhCc1IPCD7te0TEb+piC9mms6qaTQaTic89pfZk011CKIglXVwOG\nlWeJMNooe99QFE9lPb2C22Be5C5kXBjJZNozDfGoHzNOgBtvqchOYF/hoh4L\nSMAlohNurQDzQKAvOAFQuV/9rspdjcFQjxZVhAvgNo8hNwvhEho3X2ox0GkF\nmFasj7vGFjXNW9mMIossyUjfibLCcxbsXbVpqqPoO3KZ/VjbvRXS6kislKam\nMXV7cSyokU5f5NYOfnQpSQp8APXuqVHB4yXjpabtmq0YwM85MqLwxObV0gfA\nFxot\r\n=6xIU\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEfVKNV/WSkN9eXJHF5/A16VFcg17j2rS0S3tBYpLp5JAiAjrZJ9bwmc2VktKig/O9nJT/nm7xeSVmkCD7+mWjXu3A=="}]},"maintainers":[{"name":"awam","email":"ewanharris93@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/gittar_0.1.2_1525862521959_0.6566140915147987"},"_hasShrinkwrap":false}},"time":{"created":"2018-05-09T10:42:01.903Z","0.1.2":"2018-05-09T10:42:02.015Z","modified":"2022-04-04T16:49:19.864Z"},"maintainers":[{"name":"awam","email":"ewanharris93@gmail.com"}],"description":":guitar: Download and/or Extract git repositories (GitHub, GitLab, BitBucket). Cross-platform and Offline-first!","homepage":"https://github.com/lukeed/gittar#readme","keywords":["archive","bitbucket","download","extract","git","github","gitlab","offline","offline-first","repo","repository","scaffold","tarball"],"repository":{"type":"git","url":"git+https://github.com/lukeed/gittar.git"},"author":{"name":"Luke Edwards","email":"luke.edwards05@gmail.com","url":"lukeed.com"},"bugs":{"url":"https://github.com/lukeed/gittar/issues"},"license":"MIT","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","readmeFilename":"readme.md"}