Separate interfaces for installed, bundled and downloadable plugins
Summary: I've re-designed interfaces describing plugins as I found that mental overhead working with them became too expensive because of slightly flawed design. However this cascaded changes in many files so you can see how extensively these interfaces used in our codebase. Before this change we had one interface PluginDetails which described three different entities: 1) plugins installed on the disk 2) plugins bundled into Flipper 3) plugins available on Marketplace. It's hard to use this "general" PluginDetails interface because of this as you always need to think about all three use cases everywhere. After this change we have 3 separate interfaces: InstalledPluginDetails, BundledPluginDetails and DownloadablePluginDetails and things became much type-safer now. Reviewed By: mweststrate Differential Revision: D25530383 fbshipit-source-id: b93593916a980c04e36dc6ffa168797645a0ff9c
This commit is contained in:
committed by
Facebook GitHub Bot
parent
efb82e80b5
commit
5383017299
@@ -7,15 +7,12 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import PluginDetails from './PluginDetails';
|
||||
import {InstalledPluginDetails} from './PluginDetails';
|
||||
import {getInstalledPlugins} from './pluginInstaller';
|
||||
import semver from 'semver';
|
||||
import {getNpmHostedPlugins, NpmPackageDescriptor} from './getNpmHostedPlugins';
|
||||
import NpmApi from 'npm-api';
|
||||
import {
|
||||
getPluginDetails,
|
||||
getPluginDetailsFromPackageJson,
|
||||
} from './getPluginDetails';
|
||||
import {getInstalledPluginDetails, getPluginDetails} from './getPluginDetails';
|
||||
import {getPluginVersionInstallationDir} from './pluginPaths';
|
||||
import pmap from 'p-map';
|
||||
import {notNull} from './typeUtils';
|
||||
@@ -31,7 +28,7 @@ export type UpdatablePlugin = {
|
||||
updateStatus: UpdateResult;
|
||||
};
|
||||
|
||||
export type UpdatablePluginDetails = PluginDetails & UpdatablePlugin;
|
||||
export type UpdatablePluginDetails = InstalledPluginDetails & UpdatablePlugin;
|
||||
|
||||
export async function getUpdatablePlugins(
|
||||
query?: string,
|
||||
@@ -51,7 +48,7 @@ export async function getUpdatablePlugins(
|
||||
semver.lt(installedPlugin.version, npmPackageDescriptor.version)
|
||||
) {
|
||||
const pkg = await npmApi.repo(npmPackageDescriptor.name).package();
|
||||
const npmPluginDetails = await getPluginDetails(
|
||||
const npmPluginDetails = await getInstalledPluginDetails(
|
||||
getPluginVersionInstallationDir(
|
||||
npmPackageDescriptor.name,
|
||||
npmPackageDescriptor.version,
|
||||
@@ -91,7 +88,7 @@ export async function getUpdatablePlugins(
|
||||
async (notInstalledPlugin) => {
|
||||
try {
|
||||
const pkg = await npmApi.repo(notInstalledPlugin.name).package();
|
||||
const npmPluginDetails = await getPluginDetailsFromPackageJson(pkg);
|
||||
const npmPluginDetails = getPluginDetails(pkg);
|
||||
if (npmPluginDetails.specVersion === 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user