Skip to content

Commit

Permalink
Update to new API endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverdunk committed Jan 4, 2024
1 parent 9ed0d21 commit 0bdf4a1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
24 changes: 9 additions & 15 deletions tools/lib/chrome-versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const tagPrefix = 'refs/tags/';
const repoUrl = 'https://chromium.googlesource.com/chromium/src.git';


const omahaProxyUrl = 'https://omahaproxy.appspot.com/all.json';
const versionHistoryUrl = 'https://versionhistory.googleapis.com/v1/chrome/platforms/all/channels/stable/versions/';


/**
Expand Down Expand Up @@ -136,24 +136,18 @@ export async function chromeVersions() {


/**
* Fetches and finds the current stable version of Chrome via omahaproxy.
* Fetches and finds the current stable version of Chrome.
*
* @return {Promise<number>}
*/
export async function chromePublishedStable() {
const r = await fetch(omahaProxyUrl);
const data = /** @type {chromeTypes.OmahaProxyData} */ (await r.json());

for (const row of data) {
for (const version of row.versions) {
if (version.channel !== 'stable') {
continue;
}

const numericRelease = +version.version.split('.')[0];
if (numericRelease) {
return numericRelease;
}
const r = await fetch(versionHistoryUrl);
const data = /** @type {chromeTypes.VersionHistoryData} */ (await r.json());

for (const version of data.versions) {
const numericRelease = +version.version.split('.')[0];
if (numericRelease) {
return numericRelease;
}
}

Expand Down
9 changes: 3 additions & 6 deletions types/chrome.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,12 @@ export type SpecCallback = (spec: TypeSpec, id: string) => void;
export type Tag = { name: string, value?: string };


export type OmahaProxyData = {
os: string,
export type VersionHistoryData = {
versions: {
channel: Channel,
name: string,
version: string,
current_reldate: string,
branch_commit: string,
}[],
}[];
};


/**
Expand Down

0 comments on commit 0bdf4a1

Please sign in to comment.