Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/khrj/get-release-url

Deno package + CLI for fetching GitHub/BitBucket/Custom provider release + asset links with pattern matching
https://github.com/khrj/get-release-url

asset cli deno fetch github module pattern-matching release url

Last synced: 3 months ago
JSON representation

Deno package + CLI for fetching GitHub/BitBucket/Custom provider release + asset links with pattern matching

Awesome Lists containing this project

README

        


cloud download to man holding cup illustration

Get Release URL



Get the latest release URL from any hosting provider. Supports pattern matching



build status
language
code size
issues
license
version



View on deno.land








## Table of Contents

- [Usage](#usage)
- [Custom Provider Methods](#custom-provider-methods)
- [API](#api)
- [CLI](#cli)
- [Quickstart](#quickstart)
- [Installation](#installation)
- [Running](#running)

## Usage

```ts
import getReleaseURL from "https://deno.land/x/[email protected]/mod.ts"

const urls = await getReleaseURL({
provider: "github",
user: "phhusson",
repo: "treble_experimentations",
part: "arm64-ab-gapps",
})

for (const url of urls) {
console.log(url)
}
```

### Custom provider methods

Default supported providers are [GitHub](https://github.com) and [BitBucket](https://bitbucket.org). You can add custom provider functions using `addProviderMethod` (PRs for more defaults are welcome!)

```ts
import getReleaseURL, {
addProviderMethod,
} from "https://deno.land/x/[email protected]/mod.ts"

const customGithubProvider = async (
{ user, repo, part = "" }: { user: string; repo: string; part?: string },
) => {
const response = await fetch(
`https://api.github.com/repos/${user}/${repo}/releases/latest`,
)
const json = await response.json()

if (json.message === "Not Found") throw new Error("Invalid repository")
if (!("assets" in json)) throw new Error("Rate limit exceeded")

let browser_download_urls: string[] = json.assets.map((
asset: { browser_download_url: string },
) => asset.browser_download_url)
return browser_download_urls.filter((url) => url.includes(part))
}

addProviderMethod("github", customGithubProvider)

await getReleaseURL({
provider: "github",
user: "phhusson",
repo: "treble_experimentations",
part: "arm64-ab-gapps",
}) // Uses custom method
```

### API

See [generated documentation](https://doc.deno.land/https/deno.land/x/[email protected]/mod.ts)

## CLI

### Quickstart

```bash
deno run --allow-net https://deno.land/x/[email protected]/get-release-url.ts github phhusson treble_experimentations arm64-aonly
```

### Installation

```bash
deno install --allow-net https://deno.land/x/[email protected]/get-release-url.ts
```

### Running

```bash
get-release github phhusson treble_experimentations arm64-aonly
```

### Usage

```
Usage: get-release (github|bitbucket) user repo [partofreleasefile]
Ex: get-release github phhusson treble_experimentations
get-release github phhusson treble_experimentations arm64-ab-gapps
get-release bitbucket JesusFreke smali
get-release bitbucket JesusFreke smali baksmali
```

## Supporters

[![Stargazers repo roster for @khrj/get-release-url](https://reporoster.com/stars/khrj/get-release-url)](https://github.com/khrj/get-release-url/stargazers)

[![Forkers repo roster for @khrj/get-release-url](https://reporoster.com/forks/khrj/get-release-url)](https://github.com/khrj/get-release-url/network/members)

## Related

- [Deno modules](https://github.com/khrj/deno-modules)