Created
July 7, 2025 16:12
-
-
Save JosXa/a10cb48e0b460e95e588a35579d2b754 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "@johnlindquist/kit" | |
import { startSpinner } from "@josxa/kit-utils" | |
metadata = { | |
name: "Update Script Kit", | |
description: "Download and install latest Script Kit release", | |
author: "JosXa", | |
} | |
/** | |
* Interface defining the structure of a release asset from the GitHub API. | |
*/ | |
interface ReleaseAsset { | |
name: string | |
browser_download_url: string | |
} | |
/** | |
* Interface defining the structure of a release from the GitHub API. | |
*/ | |
interface Release { | |
assets: ReleaseAsset[] | |
tag_name: string | |
} | |
const repo = "script-kit/app" | |
const url = `https://api.github.com/repos/${repo}/releases` | |
// Fetch the latest release information from GitHub API | |
const response = await get(url) | |
const release: Release = response.data[0] | |
const version = release.tag_name | |
// Find the Windows x64 executable asset | |
const asset = release.assets.find((asset) => asset.name.match(/Script-Kit-.*-x64\.exe$/)) | |
if (!asset) { | |
throw new Error("No matching asset found for Windows x64.") | |
} | |
const downloadUrl = asset.browser_download_url | |
const downloadPath = home("Downloads", asset.name) | |
const spinner = startSpinner("dots") | |
spinner.message = `Downloading ${asset.name}...` | |
// Download the executable to the Downloads directory | |
await download(downloadUrl, home("Downloads"), { filename: asset.name }) | |
// Execute the downloaded installer | |
debugger | |
await exec(downloadPath) | |
spinner.stop() | |
spinner?.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment