nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1#!/usr/bin/env nix
2/*
3#!nix shell --ignore-environment .#cacert .#nodejs --command node
4*/
5// @ts-check
6import assert from "node:assert/strict";
7import * as fs from "node:fs";
8import * as path from "node:path";
9/**
10 * @typedef {object} UpdateInfo
11 * @property {number} timestamp Unix timestamp in seconds, example: 1763468493
12 * @property {string} productVersion VSCode OSS version, example: "1.104.0"
13 * @property {string} sha256hash SHA256 hash of the download file, example: "8eb01462dc4f26aba45be4992bda0b145d1ec210c63a6272578af27e59f23bef"
14 * @property {string} url Download URL, example: "https://edgedl.me.gvt1.com/edgedl/release2/j0qc3/antigravity/stable/1.11.2-6251250307170304/linux-arm/Antigravity.tar.gz", "https://edgedl.me.gvt1.com/edgedl/release2/j0qc3/antigravity/stable/1.11.2-6251250307170304/darwin-x64/Antigravity.zip"
15 */
16/** @typedef {"x86_64-linux" | "aarch64-linux" | "x86_64-darwin" | "aarch64-darwin"} Platform */
17/** @typedef {{ version: string; vscodeVersion: string; sources: Record<Platform, { url: string; sha256: string; }> }} Information */
18
19let version = "";
20let vscodeVersion = "";
21async function getLatestInformation(/** @type {"linux-x64" | "linux-arm64" | "darwin-arm64" | "darwin"} */ targetSystem) {
22 /** @type {UpdateInfo} */
23 const latestInfo = await (await fetch(`https://antigravity-auto-updater-974169037036.us-central1.run.app/api/update/${targetSystem}/stable/latest`)).json();
24 const newVersion = /\/antigravity\/stable\/([\d.]+)-[\d]+/.exec(latestInfo.url)?.[1] ?? ""; // Current API lack version field now, we need to parse it from the URL temporarily.
25 assert(version === '' || version === newVersion, `Version mismatch: ${version}(linux-x64) != ${newVersion}(${targetSystem})`);
26 version = newVersion;
27 assert(vscodeVersion === '' || vscodeVersion === latestInfo.productVersion, `VSCode version mismatch: ${vscodeVersion}(linux-x64) != ${latestInfo.productVersion}(${targetSystem})`);
28 vscodeVersion = latestInfo.productVersion;
29 return {
30 url: latestInfo.url,
31 sha256: latestInfo.sha256hash,
32 };
33}
34/** @type {Information['sources']} */
35const sources = {
36 "x86_64-linux": await getLatestInformation("linux-x64"),
37 "aarch64-linux": await getLatestInformation("linux-arm64"),
38 "x86_64-darwin": await getLatestInformation("darwin"),
39 "aarch64-darwin": await getLatestInformation("darwin-arm64"),
40};
41/** @type {Information} */
42const information = { version, vscodeVersion, sources };
43fs.writeFileSync(path.join(import.meta.dirname, "./information.json"), JSON.stringify(information, null, 2) + "\n", "utf-8");
44console.log(`[update] Updating Antigravity complete, version: ${version}, vscodeVersion: ${vscodeVersion}`);