Skip to content

Commit fd8034a

Browse files
KianNHsdnts
authored andcommitted
[Docs Site] Fetch all Linux platforms for WARP releases (cloudflare#23198)
* [Docs Site] Fetch all Linux platforms for WARP releases * include the platform that creates the file * track per-release download size * script * script rerun
1 parent 1f83120 commit fd8034a

19 files changed

+504
-160
lines changed

bin/fetch-warp-releases.js

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

5-
const tracks = [
6-
"windows/ga",
7-
"windows/beta",
8-
"macos/ga",
9-
"macos/beta",
10-
"noble-intel/ga",
11-
"noble-intel/beta",
12-
];
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+
);
1316

1417
const linesToRemove = [
1518
"For related Cloudflare for Teams documentation please see: https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp",
@@ -18,72 +21,99 @@ const linesToRemove = [
1821
"For Consumer documentation please see: <https://developers.cloudflare.com/warp-client/>",
1922
];
2023

21-
for (let track of tracks) {
22-
fetch(`https://downloads.cloudflareclient.com/v1/update/json/${track}`)
23-
.then((res) => res.json())
24-
.then((data) => {
25-
if (!data.items) {
26-
console.warn(
27-
`${track} has no releases: ${JSON.stringify(data, null, 2)}`,
28-
);
29-
30-
return;
31-
}
32-
33-
data.items.forEach((item) => {
34-
if (track.startsWith("noble-intel")) {
35-
track = track.replace("noble-intel", "linux");
36-
}
24+
for (const { platform } of platforms) {
25+
const isLinux = platform !== "windows" && platform !== "macos";
3726

38-
const folder = `./src/content/warp-releases/${track}`;
39-
const path = `${folder}/${item.version}.yaml`;
27+
for (const track of ["ga", "beta"]) {
28+
fetch(`${BASE_URL}/update/json/${platform}/${track}`)
29+
.then((res) => res.json())
30+
.then((data) => {
31+
if (!data.items) {
32+
console.warn(
33+
`${track} has no releases: ${JSON.stringify(data, null, 2)}`,
34+
);
4035

41-
if (!fs.existsSync(folder)) {
42-
fs.mkdirSync(folder, { recursive: true });
43-
}
44-
45-
if (fs.existsSync(path)) {
46-
console.log(`${track} ${item.version} already exists.`);
4736
return;
4837
}
4938

50-
console.log(`Saving ${track} ${item.version}.`);
39+
data.items.forEach((item) => {
40+
let folder = `./src/content/warp-releases/`;
5141

52-
let markdown = item.releaseNotes;
42+
if (isLinux) {
43+
folder += `linux/${track}`;
44+
} else {
45+
folder += `${platform}/${track}`;
46+
}
5347

54-
markdown.replace(/\r\n/g, "\n");
48+
const path = `${folder}/${item.version}.yaml`;
5549

56-
for (const line of linesToRemove) {
57-
markdown = markdown.replace(line, "");
58-
}
50+
if (!fs.existsSync(folder)) {
51+
fs.mkdirSync(folder, { recursive: true });
52+
}
5953

60-
markdown = markdown.trim();
54+
if (fs.existsSync(path)) {
55+
if (isLinux) {
56+
const existingFile = YAML.parse(fs.readFileSync(path, "utf-8"));
6157

62-
const tokens = marked.lexer(markdown);
58+
existingFile.linuxPlatforms ??= {};
6359

64-
marked.walkTokens(tokens, (token) => {
65-
if (token.type === "heading") {
66-
token.type = "strong";
67-
token.raw = `**${token.text}**\n`;
60+
if (!existingFile.linuxPlatforms[platform]) {
61+
console.log(
62+
`Adding ${platform} to Linux ${track} ${item.version}.`,
63+
);
6864

69-
delete token.depth;
65+
existingFile.linuxPlatforms[platform] = item.packageSize;
66+
}
67+
68+
fs.writeFileSync(path, YAML.stringify(existingFile), "utf-8");
69+
} else {
70+
console.log(
71+
`${platform} ${track} ${item.version} already exists.`,
72+
);
73+
}
74+
75+
return;
7076
}
71-
});
7277

73-
const releaseNotes = tokens.reduce((s, t) => s + t.raw, "");
74-
const platformName = data.platformName.startsWith("noble-")
75-
? "Linux"
76-
: data.platformName;
77-
78-
fs.writeFileSync(
79-
`./src/content/warp-releases/${track}/${item.version}.yaml`,
80-
YAML.stringify({
81-
...item,
82-
releaseNotes,
83-
platformName,
84-
}),
85-
"utf-8",
86-
);
78+
console.log(`Saving ${track} ${item.version}.`);
79+
80+
let markdown = item.releaseNotes;
81+
82+
markdown.replace(/\r\n/g, "\n");
83+
84+
for (const line of linesToRemove) {
85+
markdown = markdown.replace(line, "");
86+
}
87+
88+
markdown = markdown.trim();
89+
90+
const tokens = marked.lexer(markdown);
91+
92+
marked.walkTokens(tokens, (token) => {
93+
if (token.type === "heading") {
94+
token.type = "strong";
95+
token.raw = `**${token.text}**\n`;
96+
97+
delete token.depth;
98+
}
99+
});
100+
101+
const releaseNotes = tokens.reduce((s, t) => s + t.raw, "");
102+
const platformName = isLinux ? "Linux" : data.platformName;
103+
104+
fs.writeFileSync(
105+
path,
106+
YAML.stringify({
107+
...item,
108+
releaseNotes,
109+
platformName,
110+
linuxPlatforms: isLinux
111+
? { [platform]: item.packageSize }
112+
: undefined,
113+
}),
114+
"utf-8",
115+
);
116+
});
87117
});
88-
});
118+
}
89119
}

src/components/WARPRelease.astro

Lines changed: 98 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { marked } from "marked";
44
import { z } from "astro:schema";
55
import prettyBytes from "pretty-bytes";
66
import { warpReleasesSchema } from "~/schemas";
7+
import platforms from "~/util/warp-platforms.json";
78
89
type Props = z.infer<typeof props>;
910
@@ -14,37 +15,108 @@ const props = z.object({
1415
});
1516
1617
const { header, open, release } = props.parse(Astro.props);
18+
19+
const getPrettyLinuxName = (platform: string) => {
20+
const platformInfo = platforms.find(p => p.platform === platform);
21+
22+
if (platformInfo) {
23+
return platformInfo.display_name;
24+
}
25+
26+
return platform;
27+
};
28+
29+
const sortedPlatforms = Object.entries(release.linuxPlatforms ?? {}).sort(
30+
(a, b) => {
31+
return getPrettyLinuxName(a[0]).localeCompare(getPrettyLinuxName(b[0]));
32+
},
33+
);
1734
---
1835

1936
<Details header={header} open={open}>
20-
<p>
21-
<div class="flex gap-2">
37+
<warp-download data-version={release.version} data-platforms={JSON.stringify(sortedPlatforms)}>
38+
<p>
39+
<div class="flex gap-2">
40+
<span>
41+
<strong>Version: </strong>
42+
{release.platformName}
43+
{release.version}
44+
</span>
45+
<span>
46+
<strong>Date: </strong>
47+
{release.releaseDate.toISOString().split("T")[0]}
48+
</span>
49+
{
50+
release.packageSize && (
51+
<span>
52+
<strong>Size: </strong>
53+
<span data-size>{prettyBytes(release.packageSize)}</span>
54+
</span>
55+
)
56+
}
57+
</div>
58+
</p>
59+
<p>
2260
<span>
23-
<strong>Version: </strong>
24-
{release.platformName}
25-
{release.version}
61+
{
62+
release.linuxPlatforms ? (
63+
<select>
64+
{sortedPlatforms.map(([platform]) => (
65+
<option value={platform}>
66+
{getPrettyLinuxName(platform)}
67+
</option>
68+
))}
69+
</select>
70+
<a
71+
class="inline-block"
72+
data-linux-download
73+
href={`https://downloads.cloudflareclient.com/v1/download/${release.linuxPlatforms[0]}/version/${release.version}`}
74+
>
75+
Download
76+
</a>
77+
) : (
78+
<a href={release.packageURL}>Download</a>
79+
)
80+
}
2681
</span>
82+
</p>
83+
<p>
2784
<span>
28-
<strong>Date: </strong>
29-
{release.releaseDate.toISOString().split("T")[0]}
85+
<h4>Release notes</h4>
3086
</span>
31-
{
32-
release.packageSize && (
33-
<span>
34-
<strong>Size: </strong>
35-
{prettyBytes(release.packageSize)}
36-
</span>
37-
)
38-
}
39-
</div>
40-
<span>
41-
<a href={release.packageURL}>Download</a>
42-
</span>
43-
</p>
44-
<p>
45-
<span>
46-
<h4>Release notes</h4>
47-
</span>
48-
<Fragment set:html={marked.parse(release.releaseNotes)} />
49-
</p>
87+
<Fragment set:html={marked.parse(release.releaseNotes)} />
88+
</p>
89+
</warp-download>
5090
</Details>
91+
92+
<script>
93+
import prettyBytes from "pretty-bytes";
94+
95+
class WarpDownload extends HTMLElement {
96+
connectedCallback() {
97+
const platforms = JSON.parse(this.dataset.platforms as string);
98+
99+
const dropdown = this.querySelector<HTMLSelectElement>("select");
100+
101+
dropdown?.addEventListener("change", () => {
102+
const platform = dropdown?.value;
103+
104+
const download = this.querySelector<HTMLAnchorElement>("a[data-linux-download]");
105+
const size = this.querySelector<HTMLSpanElement>("span[data-size]");
106+
107+
download?.setAttribute(
108+
"href",
109+
`https://downloads.cloudflareclient.com/v1/download/${platform}/version/${this.dataset.version}`,
110+
);
111+
112+
if (size) {
113+
const platformInfo = platforms.find(([p]: [string, number]) => p === platform);
114+
115+
size.textContent = prettyBytes(Number(platformInfo?.[1] ?? 0));
116+
}
117+
});
118+
}
119+
}
120+
121+
customElements.define("warp-download", WarpDownload);
122+
</script>

src/content/warp-releases/linux/beta/2025.2.459.1.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ releaseNotes: >-
44
55
**Changes and improvements**
66
7-
- Improved command line interface for Access for Infrastructure
8-
with added function for filtering and ordering.
7+
- Improved command line interface for Access for Infrastructure with added
8+
function for filtering and ordering.
99
1010
- Fixed client connectivity issues when switching between managed network
1111
profiles that use different WARP protocols.
@@ -27,3 +27,13 @@ releaseDate: 2025-03-13T17:13:33.600Z
2727
packageURL: https://downloads.cloudflareclient.com/v1/download/noble-intel/version/2025.2.459.1
2828
packageSize: 44462470
2929
platformName: Linux
30+
linuxPlatforms:
31+
noble-intel: 44462470
32+
buster-intel: 44952080
33+
focal-intel: 44913046
34+
fedora34-intel: 47124791
35+
fedora35-intel: 46859092
36+
jammy-intel: 44575658
37+
centos8-intel: 46730316
38+
bookworm-intel: 44577042
39+
bullseye-intel: 44883128
Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
releaseNotes: >-
2-
This release contains significant improvements to our captive portal / public
3-
Wi-Fi detection logic. If you have experienced captive portal issues in the past, re-test and give this version a try.
4-
1+
releaseNotes: |-
2+
This release contains significant improvements to our captive portal / public Wi-Fi detection logic. If you have experienced captive portal issues in the past, re-test and give this version a try.
53
64
**Changes and improvements**
7-
8-
- Improved [captive portal detection](/cloudflare-one/connections/connect-devices/warp/configure-warp/warp-settings/captive-portals/) to make more public networks compatible
9-
and have faster detection.
10-
11-
- WARP tunnel protocol details can now be viewed using the `warp-cli tunnel stats`
12-
command.
13-
14-
- Fixed issue with device revocation and re-registration when switching
15-
configurations.
5+
- Improved [captive portal detection](/cloudflare-one/connections/connect-devices/warp/configure-warp/warp-settings/captive-portals/) to make more public networks compatible and have faster detection.
6+
- WARP tunnel protocol details can now be viewed using the `warp-cli tunnel stats` command.
7+
- Fixed issue with device revocation and re-registration when switching configurations.
168
version: 2025.2.460.1
179
releaseDate: 2025-03-13T18:24:32.891Z
1810
packageURL: https://downloads.cloudflareclient.com/v1/download/noble-intel/version/2025.2.460.1
1911
packageSize: 44461586
2012
platformName: Linux
13+
linuxPlatforms:
14+
noble-intel: 44461586
15+
buster-intel: 44949796
16+
focal-intel: 44915238
17+
fedora34-intel: 47124281
18+
fedora35-intel: 46857904
19+
jammy-intel: 44573296
20+
centos8-intel: 46729306
21+
bookworm-intel: 44579760
22+
bullseye-intel: 44885436

0 commit comments

Comments
 (0)