fetch-github-folder
TypeScript icon, indicating that this package has built-in type declarations

0.1.20 • Public • Published

fetch-github-folder 🦎

Open in VS Code NPM package version NPM downloads NPM Last Update package.json Dependencies count package.json Dependents count JSR package version JSR package Score JSR package owner GitHub commits per month GitHub Total commits Count NPM License Coveralls Coverage Percentage CodeFactor Code quality Grade Code Climate Technical Debt Code Climate Issues GitHub Tests Workflow status GitHub Release Workflow status Sonar Quality Gate Status Sonar Bugs Count Sonar Code Smells Count Sonar Duplicated Lines (%) Sonar Lines of Code Count Sonar Reliability Grade Sonar Security Grade Sonar Technical Debt Count Sonar Maintainability Grade Sonar Vulnerabilities Count OSS Lifecycle status

(Don't judge me for my obsession with badges)

[!CAUTION]

This project currently is not stable, but I'm actively working on writing tests and handling edge cases, such as support for Git-LFS and other. Check out the dev branch to see the latest updates! 😉 (except that I currently don't care and just push to main)

What This Project Does

This project allows you to download any folder inside a repo on github.

Requirements

You need to have installed latest node, git, npm

Installation

npm i fetch-github-folder

From JSR

Unfortunately JSR doesn't support publishing executables yet, so you can install only script library with functions that will allow you to fetch github folder from other scripts.

npx jsr add @nikelborm/fetch-github-folder
  1. Generate Personal access token (classic) with read:packages scope

  2. Save the token

  3. Login to Github's NPM registry (yes you need to do it, even if the package is public):

    npm login --scope=@nikelborm --auth-type=legacy --registry=https://npm.pkg.github.com

    You can also read more about --auth-type=legacy here

  4. Enter your username when asked

  5. Paste the token as password value

  6. Then install the package by executing:

    npm i @nikelborm/fetch-github-folder

For local development

# Clone this repo:
git clone -b main https://github.com/nikelborm/fetch-github-folder.git
# cd to it:
cd fetch-github-folder
# Install dependencies:
npm install
# Create .env file:
cp template.env .env
# Ask for token
read -sp 'Enter github access token: ' gh_token; echo;
# And immediately put it into .env
sed -i "s/\(GITHUB_ACCESS_TOKEN\)='.*'/\1='$gh_token'/" .env

Environment Variables

  • GITHUB_ACCESS_TOKEN: This is your personal access token from GitHub. It is used to authenticate your requests to the GitHub API. You can generate one here.
  • REPO_OWNER: This is the username of the owner of the repository you are trying to download from. For example, if the repository's URL is https://github.com/apache/superset, the owner is apache.
  • REPO_NAME: This is the name of the repository you are trying to download from. In the example above, the repository name is superset.
  • PATH_TO_ENTITY_IN_REPO: This is the path to the directory you want to download. It can be directory that lies inside root of repo like docker or it can be some nested directory like docker/nginx.
  • GIT_REF: This is the commit SHA hash, branch name, or tag name you want to download from. If you don't specify it, the default branch in the repository will be used.
  • DESTINATION_PATH: If entity at PATH_TO_ENTITY_IN_REPO is a file, then destination path is a path to downloaded file. If it's a directory, then all files and directories from target directory of remote repository at PATH_TO_ENTITY_IN_REPO will be put into a directory with path from DESTINATION_PATH. If the directory doesn't exist, it will be automatically created.

How to use

  1. Set env variables in .env file
  2. Run npm start

Package Sidebar

Install

npm i fetch-github-folder

Weekly Downloads

4

Version

0.1.20

License

MIT

Unpacked Size

127 kB

Total Files

93

Last publish

Collaborators

  • nikelborm