Summary: Implemented a way for re-loading single plugin on auto-update. This make it possible to apply update without full Flipper restart. Reviewed By: mweststrate Differential Revision: D23729972 fbshipit-source-id: ed30f7cde5a0537945db0b5bb6969ae8fde42cb6
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
*/
|
|
|
|
import {default as algoliasearch, SearchIndex} from 'algoliasearch';
|
|
|
|
const ALGOLIA_APPLICATION_ID = 'OFCNCOG2CU';
|
|
const ALGOLIA_API_KEY = 'f54e21fa3a2a0160595bb058179bfb1e';
|
|
|
|
function provideSearchIndex(): SearchIndex {
|
|
const client = algoliasearch(ALGOLIA_APPLICATION_ID, ALGOLIA_API_KEY);
|
|
return client.initIndex('npm-search');
|
|
}
|
|
|
|
export type NpmPackageDescriptor = {
|
|
name: string;
|
|
version: string;
|
|
};
|
|
|
|
export type NpmHostedPluginsSearchArgs = {
|
|
query?: string;
|
|
};
|
|
|
|
export async function getNpmHostedPlugins(
|
|
args: NpmHostedPluginsSearchArgs = {},
|
|
): Promise<readonly NpmPackageDescriptor[]> {
|
|
const index = provideSearchIndex();
|
|
args = Object.assign(
|
|
{
|
|
query: '',
|
|
filters: 'keywords:flipper-plugin',
|
|
hitsPerPage: 50,
|
|
},
|
|
args,
|
|
);
|
|
const {hits} = await index.search<NpmPackageDescriptor>(
|
|
args.query || '',
|
|
args,
|
|
);
|
|
return hits;
|
|
}
|