Check for most recent Flipper version in internal builds as well
Reviewed By: passy Differential Revision: D25945643 fbshipit-source-id: 4a831fa8d69c38004c8660597659ebd7007a3230
This commit is contained in:
committed by
Facebook GitHub Bot
parent
84c05d441d
commit
69c8413c57
@@ -16,12 +16,13 @@ import {Logger} from '../fb-interfaces/Logger';
|
|||||||
import isSandyEnabled from '../utils/isSandyEnabled';
|
import isSandyEnabled from '../utils/isSandyEnabled';
|
||||||
import {SandyApp} from '../sandy-chrome/SandyApp';
|
import {SandyApp} from '../sandy-chrome/SandyApp';
|
||||||
import {notification} from 'antd';
|
import {notification} from 'antd';
|
||||||
|
import isProduction from '../utils/isProduction';
|
||||||
|
|
||||||
type Props = {logger: Logger};
|
type Props = {logger: Logger};
|
||||||
|
|
||||||
export default function App(props: Props) {
|
export default function App(props: Props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (fbConfig.warnFBEmployees) {
|
if (fbConfig.warnFBEmployees && isProduction()) {
|
||||||
isFBEmployee().then(() => {
|
isFBEmployee().then(() => {
|
||||||
notification.warning({
|
notification.warning({
|
||||||
placement: 'bottomLeft',
|
placement: 'bottomLeft',
|
||||||
|
|||||||
@@ -9,19 +9,29 @@
|
|||||||
|
|
||||||
import {notification, Typography} from 'antd';
|
import {notification, Typography} from 'antd';
|
||||||
import isProduction from '../utils/isProduction';
|
import isProduction from '../utils/isProduction';
|
||||||
import {
|
|
||||||
checkForUpdate,
|
|
||||||
VersionCheckResult,
|
|
||||||
} from '../utils/publicVersionChecker';
|
|
||||||
import {reportPlatformFailures} from '../utils/metrics';
|
import {reportPlatformFailures} from '../utils/metrics';
|
||||||
import React, {useEffect, useState} from 'react';
|
import React, {useEffect, useState} from 'react';
|
||||||
import config from '../utils/processConfig';
|
|
||||||
import fbConfig from '../fb-stubs/config';
|
import fbConfig from '../fb-stubs/config';
|
||||||
import {useStore} from '../utils/useStore';
|
import {useStore} from '../utils/useStore';
|
||||||
import {remote} from 'electron';
|
import {remote} from 'electron';
|
||||||
|
import {checkForUpdate} from '../fb-stubs/checkForUpdate';
|
||||||
|
|
||||||
const version = remote.app.getVersion();
|
const version = remote.app.getVersion();
|
||||||
|
|
||||||
|
export type VersionCheckResult =
|
||||||
|
| {
|
||||||
|
kind: 'update-available';
|
||||||
|
url: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
kind: 'up-to-date';
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
kind: 'error';
|
||||||
|
msg: string;
|
||||||
|
};
|
||||||
|
|
||||||
export default function UpdateIndicator() {
|
export default function UpdateIndicator() {
|
||||||
const [versionCheckResult, setVersionCheckResult] = useState<
|
const [versionCheckResult, setVersionCheckResult] = useState<
|
||||||
VersionCheckResult
|
VersionCheckResult
|
||||||
@@ -93,10 +103,7 @@ export default function UpdateIndicator() {
|
|||||||
duration: null,
|
duration: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (
|
} else if (isProduction()) {
|
||||||
isProduction() &&
|
|
||||||
(config().launcherEnabled || !fbConfig.isFBBuild)
|
|
||||||
) {
|
|
||||||
reportPlatformFailures(
|
reportPlatformFailures(
|
||||||
checkForUpdate(version).then((res) => {
|
checkForUpdate(version).then((res) => {
|
||||||
if (res.kind === 'error') {
|
if (res.kind === 'error') {
|
||||||
|
|||||||
@@ -8,7 +8,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import config from '../fb-stubs/config';
|
import {VersionCheckResult} from '../chrome/UpdateIndicator';
|
||||||
|
|
||||||
|
const updateServer = 'https://www.facebook.com/fbflipper/public/latest.json';
|
||||||
|
|
||||||
const getPlatformSpecifier = (): string => {
|
const getPlatformSpecifier = (): string => {
|
||||||
switch (os.platform()) {
|
switch (os.platform()) {
|
||||||
@@ -47,24 +49,10 @@ const parseResponse = (resp: any): VersionCheckResult => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export type VersionCheckResult =
|
|
||||||
| {
|
|
||||||
kind: 'update-available';
|
|
||||||
url: string;
|
|
||||||
version: string;
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
kind: 'up-to-date';
|
|
||||||
}
|
|
||||||
| {
|
|
||||||
kind: 'error';
|
|
||||||
msg: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function checkForUpdate(
|
export async function checkForUpdate(
|
||||||
currentVersion: string,
|
currentVersion: string,
|
||||||
): Promise<VersionCheckResult> {
|
): Promise<VersionCheckResult> {
|
||||||
return fetch(`${config.updateServer}?version=${currentVersion}`).then(
|
return fetch(`${updateServer}?version=${currentVersion}`).then(
|
||||||
(res: Response) => {
|
(res: Response) => {
|
||||||
switch (res.status) {
|
switch (res.status) {
|
||||||
case 204:
|
case 204:
|
||||||
@@ -79,9 +67,11 @@ export async function checkForUpdate(
|
|||||||
}
|
}
|
||||||
return res.json().then(parseResponse);
|
return res.json().then(parseResponse);
|
||||||
default:
|
default:
|
||||||
|
const msg = `Server responded with ${res.statusText}.`;
|
||||||
|
console.warn('Version check failure: ', msg);
|
||||||
return {
|
return {
|
||||||
kind: 'error',
|
kind: 'error',
|
||||||
msg: `Server responded with ${res.statusText}.`,
|
msg,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Reference in New Issue
Block a user