Skip to content

Commit 7aab6b9

Browse files
committed
ok
1 parent 821a2b0 commit 7aab6b9

28 files changed

Lines changed: 13328 additions & 2 deletions

.browserslistrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
last 1 Chrome version

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/renovate.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"github>fregante/.github:renovate-preset"
5+
]
6+
}

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Test
2+
on:
3+
- pull_request
4+
- push
5+
6+
jobs:
7+
test:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- run: npm ci
12+
- run: npm test

.github/workflows/deployment.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- run: npm ci
14+
- run: npm run test
15+
- run: npm run build
16+
- name: Deploy to GitHub Pages
17+
uses: crazy-max/ghaction-github-pages@v4
18+
with:
19+
target_branch: gh-pages
20+
build_dir: public
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
.cache
3+
.parcel-cache
4+
dist
5+
public

.htmlnanorc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"minifySvg": false
3+
}

.parcelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": "@parcel/config-default",
3+
"resolvers": ["parcel-resolver-ignore", "..."],
4+
"reporters": ["...", "parcel-reporter-static-files-copy"]
5+
}

README.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# DownGD <img src="logo.svg" width="50" height="50" align="left">
2+
3+
> Download directory from a GitHub repo
4+
5+
GitHub doesn’t let you download a single folder from a repo, which might be necessary when you just need a few files from a large repository.
6+
7+
This tool will handle the download of all the files in a directory, in a single click, after you entered your token.
8+
9+
> You can create a [new token here](https://github.com/settings/personal-access-tokens/new), [example](https://imgbb.com/VWBGvhHm).
10+
11+
12+
The download starts automatically when you visit pass the link to the GitHub directory as `url` parameter, like:
13+
14+
[**downgd.github.io/downgd.github.io/**`?url=https://github.com/mrdoob/three.js/tree/dev/build`](https://downgd.github.io/downgd.github.io/?url=https://github.com/mrdoob/three.js/tree/dev/build)
15+
16+
You can also specify download filename by adding `filename` parameter, like:
17+
18+
[**downgd.github.io/downgd.github.io/**`?url=https://github.com/mrdoob/three.js/tree/dev/build&filename=three-js-build`](https://downgd.github.io/downgd.github.io/?url=https://github.com/mrdoob/three.js/tree/dev/build&filename=three-js-build) to save the file as **three-js-build.zip**.
19+
20+
This is an alternative to the existing [GitZip](https://kinolien.github.io/gitzip/) and [DownGit](https://minhaskamal.github.io/DownGit/) but without the cruft.
21+
22+
## Development Guide
23+
24+
To run the project locally or contribute, follow these steps:
25+
26+
### Prerequisites
27+
28+
Make sure you have the following installed:
29+
30+
- [Node.js](https://nodejs.org/)
31+
- [Git](https://git-scm.com/)
32+
33+
### Setup
34+
35+
1. **Clone the repository:**
36+
37+
```bash
38+
git clone https://github.com/downgd/downgd.github.io
39+
cd downgd.github.io
40+
```
41+
42+
2. **Install dependencies:**
43+
44+
```bash
45+
npm install
46+
```
47+
48+
3. **Start development server:**
49+
50+
```bash
51+
npm start
52+
53+
# or
54+
55+
npm run watch:build
56+
```
57+
58+
This runs:
59+
60+
* TypeScript in watch mode
61+
* Parcel dev server at [http://localhost:1234](http://localhost:1234)
62+
* Vitest in watch mode for unit testing
63+
64+
## Related
65+
66+
- [list-github-dir-content](https://github.com/fregante/list-github-dir-content) - List all the files in a GitHub repo’s directory
67+
- [Refined GitHub](https://github.com/refined-github/refined-github) - Browser extension that adds a link to this app to GitHub (and much more)
68+
69+
## License
70+
71+
MIT © [M Ramzan Ch](http://twitter.com/rm4814691)

authenticated-fetch.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
export default async function authenticatedFetch(
2+
url: string,
3+
{signal, method}: {signal?: AbortSignal; method?: 'HEAD'} = {},
4+
): Promise<Response> {
5+
const token = globalThis.localStorage?.getItem('token');
6+
7+
const response = await fetch(url, {
8+
method,
9+
signal,
10+
...(token
11+
? {
12+
headers: {
13+
// eslint-disable-next-line @typescript-eslint/naming-convention
14+
Authorization: `Bearer ${token}`,
15+
},
16+
}
17+
: {}),
18+
});
19+
20+
switch (response.status) {
21+
case 401: {
22+
throw new Error('Invalid token');
23+
}
24+
25+
case 403:
26+
case 429: {
27+
// See https://developer.github.com/v3/#rate-limiting
28+
if (response.headers.get('X-RateLimit-Remaining') === '0') {
29+
throw new Error('Rate limit exceeded');
30+
}
31+
32+
break;
33+
}
34+
35+
default:
36+
}
37+
38+
return response;
39+
}

0 commit comments

Comments
 (0)