Skip to content

Commit c2bda5a

Browse files
committed
script
1 parent 403410b commit c2bda5a

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

bin/fetch-warp-releases.js

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,17 @@ import fs from "fs";
22
import YAML from "yaml";
33
import { marked } from "marked";
44

5-
const BASE_URL = "https://downloads.cloudflareclient.com/v1/update/json";
6-
7-
const platforms = [
8-
"windows",
9-
"macos",
10-
"noble-intel",
11-
"noble-arm",
12-
"jammy-intel",
13-
"jammy-arm",
14-
"focal-intel",
15-
"focal-arm",
16-
"buster-intel",
17-
"buster-arm",
18-
"bullseye-intel",
19-
"bullseye-arm",
20-
"bookworm-intel",
21-
"bookworm-arm",
22-
"centos8-intel",
23-
"centos8-arm",
24-
"fedora34-intel",
25-
"fedora34-arm",
26-
"fedora35-intel",
27-
"fedora35-arm",
28-
];
5+
const BASE_URL = "https://downloads.cloudflareclient.com/v1";
6+
7+
const platforms = await fetch(`${BASE_URL}/platforms`)
8+
.then((res) => res.json())
9+
.then((data) => data.result);
10+
11+
fs.writeFileSync(
12+
"./src/util/warp-platforms.json",
13+
JSON.stringify(platforms, null, "\t"),
14+
"utf-8",
15+
);
2916

3017
const linesToRemove = [
3118
"For related Cloudflare for Teams documentation please see: https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp",
@@ -34,11 +21,11 @@ const linesToRemove = [
3421
"For Consumer documentation please see: <https://developers.cloudflare.com/warp-client/>",
3522
];
3623

37-
for (const platform of platforms) {
24+
for (const { platform } of platforms) {
3825
const isLinux = platform !== "windows" && platform !== "macos";
3926

4027
for (const track of ["ga", "beta"]) {
41-
fetch(`${BASE_URL}/${platform}/${track}`)
28+
fetch(`${BASE_URL}/update/json/${platform}/${track}`)
4229
.then((res) => res.json())
4330
.then((data) => {
4431
if (!data.items) {
@@ -68,14 +55,14 @@ for (const platform of platforms) {
6855
if (isLinux) {
6956
const existingFile = YAML.parse(fs.readFileSync(path, "utf-8"));
7057

71-
existingFile.linuxPlatforms ??= [];
58+
existingFile.linuxPlatforms ??= {};
7259

73-
if (!existingFile.linuxPlatforms.includes(platform)) {
60+
if (!existingFile.linuxPlatforms[platform]) {
7461
console.log(
7562
`Adding ${platform} to Linux ${track} ${item.version}.`,
7663
);
7764

78-
existingFile.linuxPlatforms.push(platform);
65+
existingFile.linuxPlatforms[platform] = item.packageSize;
7966
}
8067

8168
fs.writeFileSync(path, YAML.stringify(existingFile), "utf-8");
@@ -120,7 +107,9 @@ for (const platform of platforms) {
120107
...item,
121108
releaseNotes,
122109
platformName,
123-
linuxPlatforms: isLinux ? [platform] : undefined,
110+
linuxPlatforms: isLinux
111+
? { [platform]: item.packageSize }
112+
: undefined,
124113
}),
125114
"utf-8",
126115
);

0 commit comments

Comments
 (0)