Skip to content

Latest commit

 

History

History
128 lines (98 loc) · 3.86 KB

README.md

File metadata and controls

128 lines (98 loc) · 3.86 KB
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

import getReleaseURL from "https://deno.land/x/get_release_url@1.0.0/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 and BitBucket. You can add custom provider functions using addProviderMethod (PRs for more defaults are welcome!)

import getReleaseURL, {
    addProviderMethod,
} from "https://deno.land/x/get_release_url@1.0.0/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

CLI

Quickstart

deno run --allow-net https://deno.land/x/get_release_url@1.0.0/get-release-url.ts github phhusson treble_experimentations arm64-aonly

Installation

deno install --allow-net https://deno.land/x/get_release_url@1.0.0/get-release-url.ts

Running

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

Forkers repo roster for @khrj/get-release-url

Related