{"id":15497009,"url":"https://github.com/lencx/download-github","last_synced_at":"2025-04-22T21:32:32.988Z","repository":{"id":104825243,"uuid":"427563514","full_name":"lencx/download-github","owner":"lencx","description":"⬇️ Download directory from a GitHub repo. ","archived":false,"fork":false,"pushed_at":"2021-12-12T12:49:37.000Z","size":29,"stargazers_count":9,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T00:53:25.442Z","etag":null,"topics":["cli","clone-repo","dgh","download","download-github","file-downloader"],"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/lencx.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,"governance":null}},"created_at":"2021-11-13T03:58:08.000Z","updated_at":"2025-03-09T21:52:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"ad942b78-2797-4620-8ccd-a9e10b11ef0c","html_url":"https://github.com/lencx/download-github","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"d042d9b71c62293325050abbbb7dd648f36281fe"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Fdownload-github","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Fdownload-github/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Fdownload-github/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lencx%2Fdownload-github/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lencx","download_url":"https://codeload.github.com/lencx/download-github/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250328640,"owners_count":21412654,"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":["cli","clone-repo","dgh","download","download-github","file-downloader"],"created_at":"2024-10-02T08:29:54.692Z","updated_at":"2025-04-22T21:32:32.962Z","avatar_url":"https://github.com/lencx.png","language":"TypeScript","readme":"# download-github\n\n\u003e ⬇️ Download directory from a GitHub repo.\n\n## Usage\n\n[![asciicast](https://asciinema.org/a/453727.svg)](https://asciinema.org/a/453727)\n\n```bash\nnpm install dgh\n```\n\n```js\nimport dgh from \"dgh\";\n\ndgh({\n  owner: \"lencx\",\n  repo: \"download-github\",\n  name: \"test-dgh\",\n  ref: \"main\", // default `HEAD`\n  overwrite: true, // default `true`\n  root: \"./\", // default `process.cwd()`\n});\n```\n\n```js\n/* *** repo subdir \u0026 file overwrite *** */\n\nimport dgh from \"dgh\";\n\ndgh({\n  owner: \"lencx\",\n  repo: \"download-github\",\n  name: \"test-dgh\",\n  ref: \"HEAD\", // github branch, default 'HEAD'\n  subdir: \"src\",\n})\n  .on(\"info\", (msg) =\u003e {\n    console.log(msg);\n  })\n  .on(\"overwrite\", (files, fs) =\u003e {\n    files.forEach((file) =\u003e {\n      if (/\\/utils.ts$/.test(file)) {\n        // @see https://github.com/jprichardson/node-fs-extra\n        fs.appendFileSync(file, `\\nexport const DGH = 'DGH';\\n`);\n      }\n    });\n  })\n  .on(\"end\", () =\u003e {\n    console.log(\"dgh end\");\n  });\n```\n\n### Options\n\n| Options     | Required | Description                          |\n| ----------- | :------: | ------------------------------------ |\n| `owner`     |    Y     | github username or organization      |\n| `repo`      |    Y     | github repository                    |\n| `name`      |    Y     | app name                             |\n| `root`      |    N     | app path, default `process.cwd()`    |\n| `ref`       |    N     | github branch, default `HEAD`        |\n| `subdir`    |    N     | repository subdirectory              |\n| `overwrite` |    N     | rewrite file content, default `true` |\n\n### Event\n\n- `on('overwrite', (files, fs) =\u003e void))` - rewrite file content, the options `overwrite` must be `true`\n  - files: all file paths\n  - fs: [fs-extra](https://github.com/jprichardson/node-fs-extra) instance\n- `on('end', () =\u003e void))` - download complete callback event\n- `on('info', () =\u003e void))` - debug logs\n\n## Cli\n\n```bash\nnpx dgh \\\n  --owner=\u003cgithub_owner\u003e \\\n  --repo=\u003cgithub_repo\u003e \\\n  --name=\u003capp_name\u003e \\\n  --subdir=\u003crepo_subdir\u003e \\\n  --root=\u003capp_path\u003e\n```\n\n```bash\nnpm install -g dgh\n```\n\n## Command Args\n\n| Args             | Required | Description                       |\n| ---------------- | :------: | --------------------------------- |\n| `-h` or `--help` |          | dgh command help                  |\n| `--owner`        |    Y     | github username or organization   |\n| `--repo`         |    Y     | github repository                 |\n| `--name`         |    Y     | app name                          |\n| `--root`         |    N     | app path, default `process.cwd()` |\n| `--ref`          |    N     | github branch, default `HEAD`     |\n| `--subdir`       |    N     | repository subdirectory           |\n\n### Examples\n\n```bash\n# test command 1\nnpx dgh \\\n  --owner=lencx \\\n  --repo=\"learn-wasm\" \\\n  --name=\"dgh-test-download\" \\\n  --root=\"my/path\"\n```\n\n```bash\n# test command 2\nnpx dgh \\\n  --owner=lencx \\\n  --repo=\"learn-wasm\" \\\n  --name=\"dgh-test-download-2\" \\\n  --ref=\"gh-pages\" \\\n  --root=\"my/path\"\n```\n\n```bash\n# test command 3\nnpx dgh \\\n  --owner=lencx \\\n  --repo=\"learn-wasm\" \\\n  --name=\"dgh-test-download-3\" \\\n  --ref=\"gh-pages\" \\\n  --subdir=\"assets\" \\\n  --root=\"my/path\"\n```\n\n## Related\n\n- [create-mpl](https://github.com/lencx/create-mpl) - ⚡️ Create a project in seconds!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flencx%2Fdownload-github","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flencx%2Fdownload-github","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flencx%2Fdownload-github/lists"}