Change Flipper version retrieving
Summary: Changed retrieving of Flipper version. Now it will be always retrieved from package.json. Before this change we used "remote.app.getVersion()" API which instead returned electron version for dev builds, e.g. "11.2.3". This is not convenient, because we now use Flipper version to check plugin compatibility and unrelated Electron version here makes things more complicated. After this change, if version is not properly bumped then "0.0.0" will be used: 1) when running using "yarn start", 2) when local building with "yarn build --mac" without setting new version, 3) when running tests "yarn test". In addition to that I added a new command-line argument and env var which allow overriding version number for Flipper. This is useful for testing plugin updates, because compatibility between plugins and Flipper is checked by comparing Flipper version with the min version set in the plugin metadata. Reviewed By: passy Differential Revision: D28287354 fbshipit-source-id: 2f9482080e3612b95a24300050d98150c6db6cb7
This commit is contained in:
committed by
Facebook GitHub Bot
parent
21ce694fd5
commit
2b41fba704
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import {remote} from 'electron';
|
import {isTest} from './isProduction';
|
||||||
|
|
||||||
export type Info = {
|
export type Info = {
|
||||||
arch: string;
|
arch: string;
|
||||||
@@ -36,15 +36,12 @@ export function getInfo(): Info {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
let APP_VERSION: string | undefined = undefined;
|
let APP_VERSION: string | undefined;
|
||||||
// Prefer using this function over manually calling `remote.app.getVersion()`
|
export function getAppVersion(): string {
|
||||||
// as calls to the remote object go over IPC and can be slow.
|
return (APP_VERSION =
|
||||||
export function getAppVersion(): string | undefined {
|
APP_VERSION ??
|
||||||
if (APP_VERSION === undefined && remote) {
|
process.env.FLIPPER_FORCE_VERSION ??
|
||||||
APP_VERSION = remote.app.getVersion();
|
(isTest() ? '0.0.0' : require('../../package.json').version ?? '0.0.0'));
|
||||||
}
|
|
||||||
|
|
||||||
return APP_VERSION;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stringifyInfo(info: Info): string {
|
export function stringifyInfo(info: Info): string {
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ const argv = yargs
|
|||||||
'[FB-internal only] Will force using public sources only, to be able to iterate quickly on the public version. If sources are checked out from GitHub this is already the default. Setting env var "FLIPPER_FORCE_PUBLIC_BUILD" is equivalent.',
|
'[FB-internal only] Will force using public sources only, to be able to iterate quickly on the public version. If sources are checked out from GitHub this is already the default. Setting env var "FLIPPER_FORCE_PUBLIC_BUILD" is equivalent.',
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
},
|
},
|
||||||
|
'force-version': {
|
||||||
|
describe:
|
||||||
|
'Will force using the given value as Flipper version, to be able to test logic which is version-dependent. Setting env var "FLIPPER_FORCE_VERSION" is equivalent.',
|
||||||
|
type: 'string',
|
||||||
|
},
|
||||||
})
|
})
|
||||||
.version('DEV')
|
.version('DEV')
|
||||||
.help()
|
.help()
|
||||||
@@ -152,6 +157,10 @@ if (argv.channel !== undefined) {
|
|||||||
process.env.FLIPPER_RELEASE_CHANNEL = argv.channel;
|
process.env.FLIPPER_RELEASE_CHANNEL = argv.channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argv['force-version']) {
|
||||||
|
process.env.FLIPPER_FORCE_VERSION = argv['force-version'];
|
||||||
|
}
|
||||||
|
|
||||||
function looksLikeDevServer(): boolean {
|
function looksLikeDevServer(): boolean {
|
||||||
const hn = hostname();
|
const hn = hostname();
|
||||||
if (/^devvm.*\.facebook\.com$/.test(hn)) {
|
if (/^devvm.*\.facebook\.com$/.test(hn)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user