Add revision information in the exported file
Summary: Adds revision information which is used to build the flipper app. for more context follow the [discussion](https://fb.workplace.com/groups/1489943347777350/permalink/2046366362135043/) Reviewed By: danielbuechele Differential Revision: D14458169 fbshipit-source-id: 71860f1e78c042f76d0e220dd3be96f2adaf609e
This commit is contained in:
committed by
Facebook Github Bot
parent
e184af7f2a
commit
51139500f4
@@ -151,11 +151,11 @@ test('test generateNotifications helper function', () => {
|
||||
|
||||
test('test processStore function for empty state', () => {
|
||||
const json = processStore([], null, {}, [], new Map(), 'salt');
|
||||
expect(json).toBeNull();
|
||||
expect(json).resolves.toBeNull();
|
||||
});
|
||||
|
||||
test('test processStore function for an iOS device connected', () => {
|
||||
const json = processStore(
|
||||
test('test processStore function for an iOS device connected', async () => {
|
||||
const json = await processStore(
|
||||
[],
|
||||
new ArchivedDevice('serial', 'emulator', 'TestiPhone', 'iOS', []),
|
||||
{},
|
||||
@@ -168,19 +168,17 @@ test('test processStore function for an iOS device connected', () => {
|
||||
const {device, clients} = json;
|
||||
expect(device).toBeDefined();
|
||||
expect(clients).toEqual([]);
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {serial, deviceType, title, os} = device;
|
||||
expect(serial).toEqual('salt-serial');
|
||||
expect(deviceType).toEqual('archivedEmulator');
|
||||
expect(title).toEqual('TestiPhone');
|
||||
expect(os).toEqual('iOS');
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {pluginStates, activeNotifications} = json.store;
|
||||
expect(pluginStates).toEqual({});
|
||||
expect(activeNotifications).toEqual([]);
|
||||
});
|
||||
|
||||
test('test processStore function for an iOS device connected with client plugin data', () => {
|
||||
test('test processStore function for an iOS device connected with client plugin data', async () => {
|
||||
const device = new ArchivedDevice(
|
||||
'serial',
|
||||
'emulator',
|
||||
@@ -189,7 +187,7 @@ test('test processStore function for an iOS device connected with client plugin
|
||||
[],
|
||||
);
|
||||
const clientIdentifier = generateClientIdentifier(device, 'testapp');
|
||||
const json = processStore(
|
||||
const json = await processStore(
|
||||
[],
|
||||
device,
|
||||
{[clientIdentifier]: {msg: 'Test plugin'}},
|
||||
@@ -208,7 +206,7 @@ test('test processStore function for an iOS device connected with client plugin
|
||||
expect(pluginStates).toEqual(expectedPluginState);
|
||||
});
|
||||
|
||||
test('test processStore function to have only the client for the selected device', () => {
|
||||
test('test processStore function to have only the client for the selected device', async () => {
|
||||
const selectedDevice = new ArchivedDevice(
|
||||
'serial',
|
||||
'emulator',
|
||||
@@ -237,7 +235,7 @@ test('test processStore function to have only the client for the selected device
|
||||
'testapp',
|
||||
);
|
||||
|
||||
const json = processStore(
|
||||
const json = await processStore(
|
||||
[],
|
||||
selectedDevice,
|
||||
{
|
||||
@@ -273,7 +271,7 @@ test('test processStore function to have only the client for the selected device
|
||||
expect(pluginStates).toEqual(expectedPluginState);
|
||||
});
|
||||
|
||||
test('test processStore function to have multiple clients for the selected device', () => {
|
||||
test('test processStore function to have multiple clients for the selected device', async () => {
|
||||
const selectedDevice = new ArchivedDevice(
|
||||
'serial',
|
||||
'emulator',
|
||||
@@ -294,7 +292,7 @@ test('test processStore function to have multiple clients for the selected devic
|
||||
const client1 = generateClientFromDevice(selectedDevice, 'testapp1');
|
||||
const client2 = generateClientFromDevice(selectedDevice, 'testapp2');
|
||||
|
||||
const json = processStore(
|
||||
const json = await processStore(
|
||||
[],
|
||||
selectedDevice,
|
||||
{
|
||||
@@ -315,7 +313,6 @@ test('test processStore function to have multiple clients for the selected devic
|
||||
expect(json).toBeDefined();
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already added
|
||||
const {clients} = json;
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already added
|
||||
const {pluginStates} = json.store;
|
||||
let expectedPluginState = {
|
||||
[generateClientIdentifierWithSalt(clientIdentifierApp1, 'salt') +
|
||||
@@ -334,7 +331,7 @@ test('test processStore function to have multiple clients for the selected devic
|
||||
expect(pluginStates).toEqual(expectedPluginState);
|
||||
});
|
||||
|
||||
test('test processStore function for device plugin state and no clients', () => {
|
||||
test('test processStore function for device plugin state and no clients', async () => {
|
||||
// Test case to verify that device plugin data is exported even if there are no clients
|
||||
const selectedDevice = new ArchivedDevice(
|
||||
'serial',
|
||||
@@ -343,7 +340,7 @@ test('test processStore function for device plugin state and no clients', () =>
|
||||
'iOS',
|
||||
[],
|
||||
);
|
||||
const json = processStore(
|
||||
const json = await processStore(
|
||||
[],
|
||||
selectedDevice,
|
||||
{
|
||||
@@ -358,7 +355,6 @@ test('test processStore function for device plugin state and no clients', () =>
|
||||
expect(json).toBeDefined();
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {pluginStates} = json.store;
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {clients} = json;
|
||||
let expectedPluginState = {
|
||||
'salt-serial#TestDevicePlugin': {msg: 'Test Device plugin'},
|
||||
@@ -367,7 +363,7 @@ test('test processStore function for device plugin state and no clients', () =>
|
||||
expect(clients).toEqual([]);
|
||||
});
|
||||
|
||||
test('test processStore function for unselected device plugin state and no clients', () => {
|
||||
test('test processStore function for unselected device plugin state and no clients', async () => {
|
||||
// Test case to verify that device plugin data is exported even if there are no clients
|
||||
const selectedDevice = new ArchivedDevice(
|
||||
'serial',
|
||||
@@ -376,7 +372,7 @@ test('test processStore function for unselected device plugin state and no clien
|
||||
'iOS',
|
||||
[],
|
||||
);
|
||||
const json = processStore(
|
||||
const json = await processStore(
|
||||
[],
|
||||
selectedDevice,
|
||||
{
|
||||
@@ -391,13 +387,12 @@ test('test processStore function for unselected device plugin state and no clien
|
||||
expect(json).toBeDefined();
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {pluginStates} = json.store;
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {clients} = json;
|
||||
expect(pluginStates).toEqual({});
|
||||
expect(clients).toEqual([]);
|
||||
});
|
||||
|
||||
test('test processStore function for notifications for selected device', () => {
|
||||
test('test processStore function for notifications for selected device', async () => {
|
||||
// Test case to verify that device plugin data is exported even if there are no clients
|
||||
const selectedDevice = new ArchivedDevice(
|
||||
'serial',
|
||||
@@ -419,7 +414,7 @@ test('test processStore function for notifications for selected device', () => {
|
||||
client: client.id,
|
||||
};
|
||||
|
||||
const json = processStore(
|
||||
const json = await processStore(
|
||||
[activeNotification],
|
||||
selectedDevice,
|
||||
{},
|
||||
@@ -431,11 +426,9 @@ test('test processStore function for notifications for selected device', () => {
|
||||
expect(json).toBeDefined();
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {pluginStates} = json.store;
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {clients} = json;
|
||||
expect(pluginStates).toEqual({});
|
||||
expect(clients).toEqual([generateClientFromClientWithSalt(client, 'salt')]);
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {activeNotifications} = json.store;
|
||||
const expectedActiveNotification = {
|
||||
pluginId: 'TestNotification',
|
||||
@@ -445,7 +438,7 @@ test('test processStore function for notifications for selected device', () => {
|
||||
expect(activeNotifications).toEqual([expectedActiveNotification]);
|
||||
});
|
||||
|
||||
test('test processStore function for notifications for unselected device', () => {
|
||||
test('test processStore function for notifications for unselected device', async () => {
|
||||
// Test case to verify that device plugin data is exported even if there are no clients
|
||||
const selectedDevice = new ArchivedDevice(
|
||||
'serial',
|
||||
@@ -478,7 +471,7 @@ test('test processStore function for notifications for unselected device', () =>
|
||||
notification,
|
||||
client: unselectedclient.id,
|
||||
};
|
||||
const json = processStore(
|
||||
const json = await processStore(
|
||||
[activeNotification],
|
||||
selectedDevice,
|
||||
{},
|
||||
@@ -489,11 +482,9 @@ test('test processStore function for notifications for unselected device', () =>
|
||||
expect(json).toBeDefined();
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {pluginStates} = json.store;
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {clients} = json;
|
||||
expect(pluginStates).toEqual({});
|
||||
expect(clients).toEqual([generateClientFromClientWithSalt(client, 'salt')]);
|
||||
//$FlowFixMe Flow doesn't that its a test and the assertion for null is already done
|
||||
const {activeNotifications} = json.store;
|
||||
expect(activeNotifications).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -21,12 +21,13 @@ import fs from 'fs';
|
||||
import uuid from 'uuid';
|
||||
import {remote} from 'electron';
|
||||
import {serialize, deserialize} from './serialization';
|
||||
|
||||
import {readCurrentRevision} from './packageMetadata.js';
|
||||
export const IMPORT_FLIPPER_TRACE_EVENT = 'import-flipper-trace';
|
||||
export const EXPORT_FLIPPER_TRACE_EVENT = 'export-flipper-trace';
|
||||
|
||||
export type ExportType = {|
|
||||
fileVersion: string,
|
||||
flipperReleaseRevision: ?string,
|
||||
clients: Array<ClientExport>,
|
||||
device: ?DeviceExport,
|
||||
store: {
|
||||
@@ -85,13 +86,13 @@ export function processNotificationStates(
|
||||
return activeNotifications;
|
||||
}
|
||||
|
||||
const addSaltToDeviceSerial = (
|
||||
const addSaltToDeviceSerial = async (
|
||||
salt: string,
|
||||
device: BaseDevice,
|
||||
clients: Array<ClientExport>,
|
||||
pluginStates: PluginStatesState,
|
||||
pluginNotification: Array<PluginNotification>,
|
||||
): ExportType => {
|
||||
): Promise<ExportType> => {
|
||||
const {serial} = device;
|
||||
const newSerial = salt + '-' + serial;
|
||||
const newDevice = new ArchivedDevice(
|
||||
@@ -131,8 +132,10 @@ const addSaltToDeviceSerial = (
|
||||
}
|
||||
return {...notif, client: notif.client.replace(serial, newSerial)};
|
||||
});
|
||||
const revision: ?string = await readCurrentRevision();
|
||||
return {
|
||||
fileVersion: remote.app.getVersion(),
|
||||
flipperReleaseRevision: revision,
|
||||
clients: updatedClients,
|
||||
device: newDevice.toJSON(),
|
||||
store: {
|
||||
@@ -142,14 +145,14 @@ const addSaltToDeviceSerial = (
|
||||
};
|
||||
};
|
||||
|
||||
export const processStore = (
|
||||
export const processStore = async (
|
||||
activeNotifications: Array<PluginNotification>,
|
||||
device: ?BaseDevice,
|
||||
pluginStates: PluginStatesState,
|
||||
clients: Array<ClientExport>,
|
||||
devicePlugins: Map<string, Class<FlipperDevicePlugin<>>>,
|
||||
salt: string,
|
||||
): ?ExportType => {
|
||||
): Promise<?ExportType> => {
|
||||
if (device) {
|
||||
const {serial} = device;
|
||||
const processedClients = processClients(clients, serial);
|
||||
@@ -166,7 +169,7 @@ export const processStore = (
|
||||
devicePlugins,
|
||||
);
|
||||
// Adding salt to the device id, so that the device_id in the device list is unique.
|
||||
const exportFlipperData = addSaltToDeviceSerial(
|
||||
const exportFlipperData = await addSaltToDeviceSerial(
|
||||
salt,
|
||||
device,
|
||||
processedClients,
|
||||
|
||||
Reference in New Issue
Block a user