{"id":23270407,"url":"https://github.com/kusstar/gdl","last_synced_at":"2026-04-30T14:37:35.920Z","repository":{"id":57245581,"uuid":"424629950","full_name":"KusStar/gdl","owner":"KusStar","description":"Download any folder from GitHub Repo url","archived":false,"fork":false,"pushed_at":"2022-12-08T10:03:30.000Z","size":367,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-30T08:32:37.474Z","etag":null,"topics":["github"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/KusStar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-11-04T14:42:27.000Z","updated_at":"2023-04-11T12:35:21.000Z","dependencies_parsed_at":"2023-01-25T06:30:48.736Z","dependency_job_id":null,"html_url":"https://github.com/KusStar/gdl","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KusStar%2Fgdl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KusStar%2Fgdl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KusStar%2Fgdl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KusStar%2Fgdl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KusStar","download_url":"https://codeload.github.com/KusStar/gdl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247463808,"owners_count":20942940,"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","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":["github"],"created_at":"2024-12-19T18:51:30.237Z","updated_at":"2026-04-30T14:37:35.887Z","avatar_url":"https://github.com/KusStar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GDL - GitHub Download\n\n\u003e Download any folder from GitHub Repo url.\n\n[![asciicast](https://asciinema.org/a/7Ca0oKLDj5S9uhwVMOItTEcTl.svg)](https://asciinema.org/a/7Ca0oKLDj5S9uhwVMOItTEcTl)\n\n## Usage\n\n- Just use `npx` to execute\n\n```sh\nnpx gdl https://github.com/KusStar/gdl ./gdl\n```\n\n- Or use it in your project, see [Install](#install)\n\n## Install\n\n```sh\nnpm i gdl\n# or yarn add gdl\n```\n\n### Commonjs\n\n```js\nconst { download, downloadWithCheck } = require('gdl')\n\ndownloadWithCheck('https://github.com/KusStar/gkd', './gdl')\n```\n\n### ES6\n\n```js\nimport { download, downloadWithCheck } from 'gdl'\n\ndownloadWithCheck('https://github.com/KusStar/gdl', './gdl')\n```\n\n## Interfaces\n  \n```ts\n// index.d.ts\nimport { Options } from 'got';\n\n/**\n * basically from next.js/packages/create-next-app/helpers/examples\n * The MIT License (MIT), Copyright (c), 2021 Vercel Inc.\n *\n * Modified by KusStar\n * @reference https://github.com/vercel/next.js/blob/e8e4210f9fe416534c36ceb9d3ad82dd02906cc6/packages/create-next-app/helpers/examples.ts\n */\n\ndeclare type RepoInfo = {\n    username: string;\n    name: string;\n    branch: string;\n    filePath: string;\n};\ndeclare function isUrlOk(url: string): Promise\u003cboolean\u003e;\ndeclare function getRepoInfo(url: URL, gotOptions?: Options): Promise\u003cRepoInfo | undefined\u003e;\ndeclare function hasRepo({ username, name, branch, filePath }: RepoInfo): Promise\u003cboolean\u003e;\ndeclare function downloadAndExtractRepo(root: string, { username, name, branch, filePath }: RepoInfo, caching?: boolean): Promise\u003cunknown\u003e;\ninterface Links {\n    self: string;\n    git: string;\n    html: string;\n}\ninterface ContentItem {\n    name: string;\n    path: string;\n    sha: string;\n    size: number;\n    url: string;\n    html_url: string;\n    git_url: string;\n    download_url?: any;\n    type: string;\n    _links: Links;\n}\ndeclare function getRepoContents(url: string): Promise\u003cContentItem[]\u003e;\n\n/**\n * Directly download any valid GitHub tree url.\n * Example: https://github.com/KusStar/gdl/tree/master/{...}\n * @param url\n * @param targetDir\n */\ndeclare function download(url: string, targetDir?: string): Promise\u003cunknown\u003e;\ndeclare type Callback = (dir: string) =\u003e void | Promise\u003cvoid\u003e;\n/**\n * The same as download above, but with two checking callbacks.\n * Will check if targetDir is exists,\n * if exists and not empty, will try to call existsCallback,\n *  defaults to remove targetDir and mkdir targetDir.\n * if not exists, will try to call notExistsCallback,\n *  defaults to mkdir targetDir.\n * @param url\n * @param targetDir\n * @param ifExistsCallback\n * @param ifNotExistsCallback\n */\ndeclare function downloadWithCheck(url: string, targetDir?: string, ifExistsCallback?: Callback, notExistsCallback?: Callback): Promise\u003cvoid\u003e;\n\nexport { Callback, ContentItem, Links, RepoInfo, download, downloadAndExtractRepo, downloadWithCheck, getRepoContents, getRepoInfo, hasRepo, isUrlOk };\n```\n\n## Thanks\n\n- [create-next-app](https://github.com/vercel/next.js/tree/e8e4210f9fe416534c36ceb9d3ad82dd02906cc6/packages/create-next-app)\n  basically, the logic of download and extract GitHub repo is copied from it.\n\n- [packages.json - devDependencies](./package.json)\n\n## License\n\n- [MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkusstar%2Fgdl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkusstar%2Fgdl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkusstar%2Fgdl/lists"}