mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
Allow release checkers to find bridge version in earlier releases
This commit is contained in:
110
docs/index.js
110
docs/index.js
@@ -80,15 +80,16 @@ switch (navigator.platform) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function populateAppListApp (element, fileUrl, fileName, fileSize) {
|
function populateAppListApp (element, fileUrl, fileName, fileSize, version) {
|
||||||
element.href = fileUrl;
|
element.href = fileUrl;
|
||||||
element.title = `${fileName} (${fileSize})`;
|
element.title = `${fileName} (${fileSize})`;
|
||||||
element.dataset.fileSize = fileSize;
|
element.dataset.fileSize = fileSize;
|
||||||
|
element.dataset.version = version;
|
||||||
element.removeAttribute("disabled");
|
element.removeAttribute("disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const ENDPOINT_URL = "https://api.github.com/repos/hensm/fx_cast/releases/latest";
|
const ENDPOINT_URL = "https://api.github.com/repos/hensm/fx_cast/releases";
|
||||||
|
|
||||||
fetch(ENDPOINT_URL)
|
fetch(ENDPOINT_URL)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
@@ -96,54 +97,57 @@ fetch(ENDPOINT_URL)
|
|||||||
.catch(onError);
|
.catch(onError);
|
||||||
|
|
||||||
function onResponse (res) {
|
function onResponse (res) {
|
||||||
for (const asset of res.assets) {
|
for (const release of res.reverse()) {
|
||||||
const formattedSize = formatSize(asset.size);
|
for (const asset of release.assets) {
|
||||||
|
const formattedSize = formatSize(asset.size);
|
||||||
const REGEX_EXT = /.*\.(.*)$/;
|
const { tag_name } = release;
|
||||||
const REGEX_ARCH = /.*(x(?:86|64))\..*$/;
|
|
||||||
|
const REGEX_EXT = /.*\.(.*)$/;
|
||||||
switch (asset.name.match(REGEX_EXT).pop()) {
|
const REGEX_ARCH = /.*(x(?:86|64))\..*$/;
|
||||||
case "xpi":
|
|
||||||
downloadExtBtn.href = asset.browser_download_url;
|
switch (asset.name.match(REGEX_EXT).pop()) {
|
||||||
downloadExtBtn.title = `${asset.name} (${formattedSize})`;
|
case "xpi":
|
||||||
downloadExtBtn.dataset.version = res.tag_name;
|
downloadExtBtn.href = asset.browser_download_url;
|
||||||
downloadExtBtn.removeAttribute("disabled");
|
downloadExtBtn.title = `${asset.name} (${formattedSize})`;
|
||||||
break;
|
downloadExtBtn.dataset.version = tag_name;
|
||||||
|
downloadExtBtn.removeAttribute("disabled");
|
||||||
|
break;
|
||||||
case "exe":
|
|
||||||
switch (asset.name.match(REGEX_ARCH).pop()) {
|
|
||||||
case "x86":
|
case "exe":
|
||||||
populateAppListApp(
|
switch (asset.name.match(REGEX_ARCH).pop()) {
|
||||||
appListWin32Btn, asset.browser_download_url
|
case "x86":
|
||||||
, asset.name, formattedSize);
|
populateAppListApp(
|
||||||
break;
|
appListWin32Btn, asset.browser_download_url
|
||||||
case "x64":
|
, asset.name, formattedSize, tag_name);
|
||||||
populateAppListApp(
|
break;
|
||||||
appListWin64Btn, asset.browser_download_url
|
case "x64":
|
||||||
, asset.name, formattedSize);
|
populateAppListApp(
|
||||||
break;
|
appListWin64Btn, asset.browser_download_url
|
||||||
}
|
, asset.name, formattedSize, tag_name);
|
||||||
|
break;
|
||||||
break;
|
}
|
||||||
|
|
||||||
case "pkg":
|
break;
|
||||||
populateAppListApp(
|
|
||||||
appListMacBtn, asset.browser_download_url
|
case "pkg":
|
||||||
, asset.name, formattedSize);
|
populateAppListApp(
|
||||||
break;
|
appListMacBtn, asset.browser_download_url
|
||||||
|
, asset.name, formattedSize, tag_name);
|
||||||
case "deb":
|
break;
|
||||||
populateAppListApp(
|
|
||||||
appListDebBtn, asset.browser_download_url
|
case "deb":
|
||||||
, asset.name, formattedSize);
|
populateAppListApp(
|
||||||
break;
|
appListDebBtn, asset.browser_download_url
|
||||||
|
, asset.name, formattedSize, tag_name);
|
||||||
case "rpm":
|
break;
|
||||||
populateAppListApp(
|
|
||||||
appListRpmBtn, asset.browser_download_url
|
case "rpm":
|
||||||
, asset.name, formattedSize);
|
populateAppListApp(
|
||||||
break;
|
appListRpmBtn, asset.browser_download_url
|
||||||
|
, asset.name, formattedSize, tag_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,12 +156,12 @@ function onResponse (res) {
|
|||||||
case "win":
|
case "win":
|
||||||
downloadAppBtn.href = appListWin64Btn.href;
|
downloadAppBtn.href = appListWin64Btn.href;
|
||||||
downloadAppBtn.title = appListWin64Btn.title;
|
downloadAppBtn.title = appListWin64Btn.title;
|
||||||
downloadAppBtn.dataset.version = res.tag_name;
|
downloadAppBtn.dataset.version = appListWin64Btn.dataset.version;
|
||||||
break;
|
break;
|
||||||
case "mac":
|
case "mac":
|
||||||
downloadAppBtn.href = appListMacBtn.href;
|
downloadAppBtn.href = appListMacBtn.href;
|
||||||
downloadAppBtn.title = appListMacBtn.title;
|
downloadAppBtn.title = appListMacBtn.title;
|
||||||
downloadAppBtn.dataset.version = res.tag_name;
|
downloadAppBtn.dataset.version = appListMacBtn.dataset.version;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
@@ -170,7 +174,7 @@ function onResponse (res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onError (err) {
|
function onError (err) {
|
||||||
console.error("Failed to fetch download links");
|
console.error("Failed to fetch download links", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,7 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
|||||||
}));
|
}));
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
fetch("https://api.github.com/repos/hensm/fx_cast/releases/latest")
|
fetch("https://api.github.com/repos/hensm/fx_cast/releases")
|
||||||
.then(res => {
|
.then(res => {
|
||||||
window.clearTimeout(timeout);
|
window.clearTimeout(timeout);
|
||||||
return res.json();
|
return res.json();
|
||||||
@@ -250,11 +250,30 @@ export default class Bridge extends Component<BridgeProps, BridgeState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async onCheckUpdatesResponse (res: any) {
|
private async onCheckUpdatesResponse (res: any) {
|
||||||
const isUpdateAvailable = !this.props.info ||
|
let latestBridgeRelease;
|
||||||
semver.lt(this.props.info.version, res.tag_name);
|
for (const release of res) {
|
||||||
|
if (release.assets.find((asset: any) =>
|
||||||
|
asset.content_type !== "application/x-xpinstall")) {
|
||||||
|
latestBridgeRelease = release;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!latestBridgeRelease) {
|
||||||
|
this.setState({
|
||||||
|
isCheckingUpdates: false
|
||||||
|
, wasErrorCheckingUpdates: true
|
||||||
|
, updateStatus: _("optionsBridgeUpdateStatusError")
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isUpdateAvailable = !this.props.info || semver.lt(
|
||||||
|
this.props.info.version, latestBridgeRelease.tag_name);
|
||||||
|
|
||||||
if (isUpdateAvailable) {
|
if (isUpdateAvailable) {
|
||||||
this.updateData = res;
|
this.updateData = latestBridgeRelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
|||||||
Reference in New Issue
Block a user