{"id":27194792,"url":"https://github.com/openinf/openinf-gh-file-importer","last_synced_at":"2025-04-09T19:36:30.754Z","repository":{"id":39578866,"uuid":"334260742","full_name":"OpenINF/openinf-gh-file-importer","owner":"OpenINF","description":"Utility that imports arbitrary files from remote GitHub repositories","archived":false,"fork":false,"pushed_at":"2025-04-05T02:30:34.000Z","size":264,"stargazers_count":6,"open_issues_count":17,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-05T03:23:48.641Z","etag":null,"topics":["commonjs","commonjs-module","commonjs-package","download","file","github","nodejs","nodejs-module","nodejs-modules","npm","npm-package","repository","typescript","typescript-package","utility"],"latest_commit_sha":null,"homepage":"https://github.com/OpenINF/openinf-gh-file-importer#readme","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenINF.png","metadata":{"funding":{"github":[]},"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-29T20:54:28.000Z","updated_at":"2024-05-24T16:14:41.000Z","dependencies_parsed_at":"2023-07-19T03:55:35.029Z","dependency_job_id":"93805462-d2ac-43f9-8b5d-4ab6f7f758cb","html_url":"https://github.com/OpenINF/openinf-gh-file-importer","commit_stats":null,"previous_names":["openinf/gh-file-importer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-gh-file-importer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-gh-file-importer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-gh-file-importer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenINF%2Fopeninf-gh-file-importer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenINF","download_url":"https://codeload.github.com/OpenINF/openinf-gh-file-importer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248098513,"owners_count":21047455,"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":["commonjs","commonjs-module","commonjs-package","download","file","github","nodejs","nodejs-module","nodejs-modules","npm","npm-package","repository","typescript","typescript-package","utility"],"created_at":"2025-04-09T19:36:29.836Z","updated_at":"2025-04-09T19:36:30.733Z","avatar_url":"https://github.com/OpenINF.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://open.inf.is\"\u003e\n  \u003cimg\n    src=\"https://open.inf.is/assets/img/svg/logogram-color.svg\"\n    alt=\"OpenINF logo\"\n    title=\"OpenINF\"\n    align=\"right\"\n    height=\"96\"\n    width=\"96\"\n  /\u003e\n\u003c/a\u003e\n\n\u003cdiv align=\"left\"\u003e\n\n## `@openinf/gh-file-importer`\n\n\u003e Utility that imports arbitrary files from remote GitHub repositories\n\n\u003cbr /\u003e\n\n[!['View on npm'][npm-badge--shields]][npm-badge-url]\n[!['License: MIT/Apache-2.0'][license-badge--shields]][license-badge-url]\n\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\nThe high-level goal of `@openinf/gh-file-importer` is to serve as a Node.js\npackage containing a utility for **importing arbitrary files from remote GitHub\nrepos** allowing users to make use of them locally. We are constantly working to\nimprove this repository, so please feel free to [contribute](#contributing) if\nyou notice any omissions or errors.\n\nThanks!\n\n\u003cbr /\u003e\n\n\u003cdetails id=\"platform--node-js-lts\"\u003e\n\t\u003csummary\u003e\n\t\t\u003ca\n\t\t\thref=\"#platform--node-js-lts\"\n\t\t\ttitle=\"Platform: Node.js LTS\"\n\t\t\u003e\n\t\t\t\u003cimg\n\t\t\t\tsrc=\"https://img.shields.io/badge/Node.js-LTS-black?logo=Node.js\u0026logoColor=lightgreen\u0026color=2a2a2a\u0026labelColor=black\"\n\t\t\t\talt=\"Platform: Node.js LTS\"\n\t\t\t/\u003e\n\t\t\u003c/a\u003e\n\t\u003c/summary\u003e\n\t\u003cdiv align=\"left\"\u003e\u003cbr /\u003e\n\t\t\u003ca\n\t\t\ttarget=\"_blank\"\n\t\t\ttitle=\"Node.js release schedule\"\n\t\t\thref=\"https://github.com/nodejs/release#release-schedule\"\n\t\t\u003e\n\t\t\t\u003cstrong\u003eSupported Node.js Environments\u003c/strong\u003e\n\t\t\u003c/a\u003e\u003cbr /\u003e\u003cbr /\u003e\n\n- [ ] v4：Argon (Ar)\n- [ ] v6：Boron (B)\n- [ ] v8：Carbon (C)\n- [ ] v10：Dubnium (Db)\n- [ ] v12：Erbium (Er)\n- [x] v14：Fermium (Fm)\n- [x] v16：Gallium (Ga)\n- [x] v18：Hydrogen (H)\n\u003c!-- TODO\n- [x] v20: Iron (Fe) --\u003e\n\n\u003c/div\u003e\u003c/details\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n[![Code Style: Prettier][prettier-badge]][prettier-url]\n[![Commit Style: Conventional Commits][conventional-commits-badge]][conventional-commits-url]\n[![Chat on Matrix][matrix-badge--shields]][matrix-url]\n\n\u003c/div\u003e\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n### Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n- [Contributing](#contributing)\n- [License](#license)\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\n\t\u003c!-- markdownlint-disable-next-line line-length --\u003e\n\t\u003ch3 id=\"installation\" align=\"left\"\u003eInstallation \u003ca href=\"##\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/nodejs/corepack/main/icon.svg?sanitize=true\" alt=\"Corepack logo\" title=\"Corepack friendly\" align=\"right\" height=\"24\" width=\"24\" /\u003e\u003c/a\u003e\u003c/h3\u003e\n\u003c/summary\u003e\n\n\u003cbr /\u003e\n\n`@openinf/gh-file-importer` runs on\n[supported versions of Node.js](#platform--node-js-lts) and is available via\n**`npm`**, **`pnpm`**, or **`yarn`**.\n\n**Using the npm CLI**\n\n\u003csup\u003eSee the\n[official documentation for this command](https://docs.npmjs.com/cli/commands/npm-install)\nfor more information.\u003c/sup\u003e\n\n```shell\nnpm i @openinf/gh-file-importer\n```\n\n**Using the pnpm CLI**\n\n\u003csup\u003eSee the [official documentation for this command](https://pnpm.io/cli/add)\nfor more information.\u003c/sup\u003e\n\n```shell\npnpm add @openinf/gh-file-importer\n```\n\n**Using the Yarn 1 CLI (Classic)**\n\n\u003csup\u003eSee the\n[official documentation for this command](https://classic.yarnpkg.com/en/docs/cli/add)\nfor more information.\u003c/sup\u003e\n\n```shell\nyarn add @openinf/gh-file-importer\n```\n\n\u003cbr /\u003e\n\n\u003c/details\u003e\n\n### Usage\n\nImport the `GhFileImporter` constructor based on your platform.\n\n#### Node.js\n\n```ts\nimport { GhFileImporter } from '@openinf/gh-file-importer';\n```\n\n#### Options\n\nNow instantiate your API. All options are optional except for `destDir`, which is the location\nwhere your files will be stored.\n\n```ts\nimport { GhFileImporter } from '@openinf/gh-file-importer';\n\nconst DIR_TEMP = './tmp';\n\nconst ghFileImporter = new GhFileImporter({ destDir: DIR_TEMP });\n\nawait ghFileImporter.importContents('tc39', 'proposals', 'README.md');\n```\n\n**Note:** if needing to circumvent exceeding the GitHub API rate limit, be sure\nto have an environment variable called `GITHUB_TOKEN` containing a\n[GitHub person access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).\n\n#### Logging\n\nFor custom logging, pass an object with `debug`, `info`, `warn`, and `error` methods as the `log` option.\n\n```ts\nconst ghFileImporter = new GhFileImporter({\n  destDir: DIR_TEMP,\n  log: {\n    debug: () =\u003e {},\n    info: () =\u003e {},\n    warn: console.warn,\n    error: console.error\n  }\n};\n```\n\n#### Debug\n\nThe simplest way to receive debug information is to set the `log` client option to `console`.\n\n```ts\nconst ghFileImporter = new GhFileImporter({\n  destDir: DIR_TEMP,\n  log: console,\n});\n```\n\nIf you like to support a configurable log level, we recommend using the\n[`console-log-level`](https://github.com/watson/console-log-level) module.\n\n```ts\nconst ghFileImporter = new GhFileImporter({\n  destDir: DIR_TEMP,\n  log: require(\"console-log-level\")({ level: \"info\" }),\n});\n```\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n### API\n\n\u003ca name=\"GhFileImporter\"\u003e\u003c/a\u003e\n\n#### GhFileImporter\n**Kind**: global class  \n\n* [GhFileImporter](#GhFileImporter)\n    * [new GhFileImporter(options)](#new_GhFileImporter_new)\n    * [.fetchMetadata(owner, repo, path, ref)](#GhFileImporter+fetchMetadata) ⇒ \u003ccode\u003ePromise\u0026lt;any\u0026gt;\u003c/code\u003e\n    * [.fetchFileContents(owner, repo, path, ref)](#GhFileImporter+fetchFileContents) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\n    * [.fetchFileContentsFromUrl(url)](#GhFileImporter+fetchFileContentsFromUrl) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\n    * [.importContents(url)](#GhFileImporter+importContents) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\n    * [.importContentsFromUrl(url)](#GhFileImporter+importContentsFromUrl) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\n\n\u003ca name=\"new_GhFileImporter_new\"\u003e\u003c/a\u003e\n\n#### new GhFileImporter(options)\nCreates an instance of GhFileImporter.\n\n**Throws**:\n\n- \u003ccode\u003eInvalidArgTypeError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgValueError\u003c/code\u003e \n- \u003ccode\u003eInvalidPropertyValueError\u003c/code\u003e \n- \u003ccode\u003eMissingArgsError\u003c/code\u003e \n- \u003ccode\u003eMissingOptionError\u003c/code\u003e \n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| options | \u003ccode\u003eGhFileImporterOptions\u003c/code\u003e \\| \u003ccode\u003eundefined\u003c/code\u003e | The options object. |\n\n\u003ca name=\"GhFileImporter+fetchMetadata\"\u003e\u003c/a\u003e\n\n#### ghFileImporter.fetchMetadata(owner, repo, path, ref) ⇒ \u003ccode\u003ePromise\u0026lt;any\u0026gt;\u003c/code\u003e\nRetrieves a repo or path's metadata.\n\n**Kind**: instance method of [\u003ccode\u003eGhFileImporter\u003c/code\u003e](#GhFileImporter)  \n**Returns**: \u003ccode\u003ePromise\u0026lt;any\u0026gt;\u003c/code\u003e - An object containing the metadata repo or path's\n metadata.  \n**Throws**:\n\n- \u003ccode\u003eInvalidArgTypeError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgValueError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgsNumberError\u003c/code\u003e \n\n**See**: https://docs.github.com/en/rest/reference/repos#get-repository-content  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| owner | \u003ccode\u003estring\u003c/code\u003e | The username associated with the repository. |\n| repo | \u003ccode\u003estring\u003c/code\u003e | The repository name. |\n| path | \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eundefined\u003c/code\u003e | The path to the file or folder. |\n| ref | \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eundefined\u003c/code\u003e | The name of the commit/branch/tag. |\n\n\u003ca name=\"GhFileImporter+fetchFileContents\"\u003e\u003c/a\u003e\n\n#### ghFileImporter.fetchFileContents(owner, repo, path, ref) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\nRetrieves a path's contents.\n\n**Kind**: instance method of [\u003ccode\u003eGhFileImporter\u003c/code\u003e](#GhFileImporter)  \n**Returns**: \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e - The file contents.  \n**Throws**:\n\n- \u003ccode\u003eInvalidArgTypeError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgValueError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgsNumberError\u003c/code\u003e \n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| owner | \u003ccode\u003estring\u003c/code\u003e | The username associated with the repository. |\n| repo | \u003ccode\u003estring\u003c/code\u003e | The repository name. |\n| path | \u003ccode\u003estring\u003c/code\u003e | The path to the file or folder. |\n| ref | \u003ccode\u003estring\u003c/code\u003e \\| \u003ccode\u003eundefined\u003c/code\u003e | The name of the commit/branch/tag. |\n\n\u003ca name=\"GhFileImporter+fetchFileContentsFromUrl\"\u003e\u003c/a\u003e\n\n#### ghFileImporter.fetchFileContentsFromUrl(url) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\nRetrieves the file contents from the URL provided.\n\n**Kind**: instance method of [\u003ccode\u003eGhFileImporter\u003c/code\u003e](#GhFileImporter)  \n**Returns**: \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e - The file contents.  \n**Throws**:\n\n- \u003ccode\u003eInvalidArgTypeError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgValueError\u003c/code\u003e \n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| url | \u003ccode\u003estring\u003c/code\u003e | The string representation of a remote file URL. |\n\n\u003ca name=\"GhFileImporter+importContents\"\u003e\u003c/a\u003e\n\n#### ghFileImporter.importContents(url) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\nImports a file into the directory provided for the `destDir` option.\n\n**Kind**: instance method of [\u003ccode\u003eGhFileImporter\u003c/code\u003e](#GhFileImporter)  \n**Returns**: \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e - The file contents.  \n**Throws**:\n\n- \u003ccode\u003eInvalidArgTypeError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgValueError\u003c/code\u003e \n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| url | \u003ccode\u003estring\u003c/code\u003e | The string representation of a remote file URL. |\n\n\u003ca name=\"GhFileImporter+importContentsFromUrl\"\u003e\u003c/a\u003e\n\n#### ghFileImporter.importContentsFromUrl(url) ⇒ \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e\nImports a file located at the supplied URL into the directory provided for\nthe `destDir` option.\n\n**Kind**: instance method of [\u003ccode\u003eGhFileImporter\u003c/code\u003e](#GhFileImporter)  \n**Returns**: \u003ccode\u003ePromise\u0026lt;string\u0026gt;\u003c/code\u003e - The file contents.  \n**Throws**:\n\n- \u003ccode\u003eInvalidArgTypeError\u003c/code\u003e \n- \u003ccode\u003eInvalidArgValueError\u003c/code\u003e \n\n\n| Param | Type | Description |\n| --- | --- | --- |\n| url | \u003ccode\u003estring\u003c/code\u003e | The string representation of a remote file URL. |\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n### Contributing\n\nPull requests are welcome. For major changes, please open an issue first to\ndiscuss what you would like to change. If for whatever reason you spot something\nto fix but cannot patch it yourself, please [open an issue][].\n\n\u003cbr /\u003e\n\n### License\n\nThis project is licensed under either of\n\n- [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)\n- [MIT license](https://opensource.org/licenses/MIT)\n\nat your option.\n\nThe [SPDX](https://spdx.dev) license identifier for this project is\n`MIT OR Apache-2.0`.\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n---\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n\n### Show Your Support\n\n\u003cbr /\u003e\n\nIf you like the project (or want to bookmark it)\u0026nbsp;\u0026mdash;\u003cbr /\u003e\n\u0026mdash;\u0026nbsp;[give it a star ⭐️][]\u0026nbsp;\u0026mdash;\u0026nbsp;it will greatly encourage\nus.\n\n\u003cbr /\u003e\u003cbr /\u003e\n\n\u003ca title=\"The OpenINF website\" href=\"https://open.inf.is\" rel=\"author\"\u003e\n  \u003cimg alt=\"The OpenINF logo\" height=\"32px\" width=\"32px\" src=\"https://open.inf.is/assets/img/svg/logogram-color.svg\" /\u003e\n\u003c/a\u003e\n\n\u003c/div\u003e\n\n\u003c!-- BEGIN LINK DEFINITIONS --\u003e\n[conventional-commits-badge]: https://img.shields.io/badge/commit%20style-Conventional-%23fa6673?logoColor=white\u0026logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMCAzMCI+PHBhdGggc3R5bGU9ImZpbGw6ICNGRkYiIGQ9Ik0xNSwyQTEzLDEzLDAsMSwxLDIsMTUsMTMsMTMsMCwwLDEsMTUsMm0wLTJBMTUsMTUsMCwxLDAsMzAsMTUsMTUsMTUsMCwwLDAsMTUsMFoiLz48L3N2Zz4K 'Commit Style: Conventional Commits'\n[conventional-commits-url]: https://www.conventionalcommits.org 'Commit Style: Conventional Commits'\n[give it a star ⭐️]: https://github.com/OpenINF/openinf-gh-file-importer/stargazers\n[license-badge--shields]: https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg?logo=github 'License: MIT/Apache 2.0'\n[license-badge-url]: #license 'License: MIT/Apache 2.0'\n[matrix-badge--shields]: https://img.shields.io/badge/matrix-join%20chat-%2346BC99?logo=matrix 'Chat on Matrix'\n[matrix-url]: https://matrix.to/#/#openinf-space:matrix.org 'You\u0026apos;re invited to talk on Matrix'\n[npm-badge--shields]: https://img.shields.io/npm/v/@openinf/gh-file-importer/latest.svg?logo=npm\u0026color=fe7d37 'View on npm'\n[npm-badge-url]: https://www.npmjs.com/package/@openinf/gh-file-importer#top 'View on npm'\n[open an issue]: https://github.com/OpenINF/openinf-gh-file-importer/issues\n[prettier-badge]: https://img.shields.io/badge/code_style-Prettier-ff69b4.svg?logo=prettier 'Code Style: Prettier'\n[prettier-url]: https://prettier.io/playground 'Code Style: Prettier'\n[project-status-badge]: https://img.shields.io/badge/project%20status-under%20construction-orange 'Project Status: Under construction badge'\n\u003c!-- END LINK DEFINITIONS --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopeninf%2Fopeninf-gh-file-importer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopeninf%2Fopeninf-gh-file-importer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopeninf%2Fopeninf-gh-file-importer/lists"}