Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/ide/gha-update-image/lib/jb-helper/jb-releases.ts
2501 views
1
import { z } from "zod";
2
import axios from "axios";
3
4
export const productReleaseZod = z.record(
5
z.string(),
6
z.array(
7
z.object({
8
date: z.string(),
9
type: z.string(),
10
downloads: z.object({
11
linux: z
12
.object({
13
link: z.string(),
14
})
15
.optional(),
16
}),
17
notesLink: z.string().nullish(),
18
whatsnew: z.string().nullish(),
19
majorVersion: z.string(), // 2024.2
20
build: z.string(), // 242.20224.159
21
version: z.string(), // 2024.2.1
22
}),
23
),
24
);
25
26
export type ReleaseItem = z.infer<typeof productReleaseZod>[string][number];
27
28
export const releaseItemStr = (release: ReleaseItem) => {
29
return `${release.version}(${release.type},${release.build})`;
30
};
31
32
export async function fetchProductReleases(info: { productCode: string; productType: string }) {
33
const { productCode, productType } = info;
34
// https://data.services.jetbrains.com/products/releases?code=GW&type=eap,rc,release&platform=linux
35
const url = `https://data.services.jetbrains.com/products/releases?code=${productCode}&type=${productType}&platform=linux`;
36
console.log(`Fetching product releases on ${url}`);
37
const response = await axios.get(url);
38
const data = productReleaseZod.parse(response.data);
39
if (!data[productCode] || data[productCode].length <= 0) {
40
throw new Error(`No data found for ${productCode} in ${url}`);
41
}
42
return data[productCode];
43
}
44
45