Added new package "flipper-plugin-lib" which contains re-usable code related to plugin installation

Summary: No functional changes, just refactoring for easier implementation of plugin updates installation

Reviewed By: passy

Differential Revision: D21902525

fbshipit-source-id: fbfa221a89b879b0d08127676b27df65ef63307d
This commit is contained in:
Anton Nikolaev
2020-06-05 06:07:54 -07:00
committed by Facebook GitHub Bot
parent 579172fa39
commit 339b786fb5
21 changed files with 111 additions and 11 deletions

View File

@@ -25,7 +25,8 @@
"pkg-lib", "pkg-lib",
"static", "static",
"plugins/*", "plugins/*",
"e2e" "e2e",
"plugin-lib"
], ],
"nohoist": [ "nohoist": [
"flipper-plugin-kaios-big-allocations/firefox-client" "flipper-plugin-kaios-big-allocations/firefox-client"
@@ -178,6 +179,7 @@
"express": "^4.15.2", "express": "^4.15.2",
"flipper-babel-transformer": "0.45.0", "flipper-babel-transformer": "0.45.0",
"flipper-pkg-lib": "0.45.0", "flipper-pkg-lib": "0.45.0",
"flipper-plugin-lib": "0.45.0",
"flow-bin": "0.124.0", "flow-bin": "0.124.0",
"fs-extra": "^9.0.0", "fs-extra": "^9.0.0",
"glob": "^7.1.2", "glob": "^7.1.2",

View File

@@ -9,5 +9,3 @@
export {default as runBuild} from './runBuild'; export {default as runBuild} from './runBuild';
export {default as getWatchFolders} from './getWatchFolders'; export {default as getWatchFolders} from './getWatchFolders';
export {default as PluginDetails} from './PluginDetails';
export {default as getPluginDetails} from './getPluginDetails';

View File

@@ -21,6 +21,7 @@
"ajv-errors": "^1.0.1", "ajv-errors": "^1.0.1",
"cli-ux": "^5.4.6", "cli-ux": "^5.4.6",
"flipper-pkg-lib": "0.45.0", "flipper-pkg-lib": "0.45.0",
"flipper-plugin-lib": "0.45.0",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"inquirer": "^7.1.0", "inquirer": "^7.1.0",
"lodash": "^4.17.15", "lodash": "^4.17.15",

View File

@@ -11,7 +11,8 @@ import {Command, flags} from '@oclif/command';
import {args} from '@oclif/parser'; import {args} from '@oclif/parser';
import fs from 'fs-extra'; import fs from 'fs-extra';
import path from 'path'; import path from 'path';
import {runBuild, getPluginDetails} from 'flipper-pkg-lib'; import {runBuild} from 'flipper-pkg-lib';
import {getPluginDetails} from 'flipper-plugin-lib';
export default class Bundle extends Command { export default class Bundle extends Command {
public static description = 'transpiles and bundles plugin'; public static description = 'transpiles and bundles plugin';

View File

@@ -15,7 +15,8 @@ import * as inquirer from 'inquirer';
import * as path from 'path'; import * as path from 'path';
import * as yarn from '../utils/yarn'; import * as yarn from '../utils/yarn';
import cli from 'cli-ux'; import cli from 'cli-ux';
import {runBuild, getPluginDetails} from 'flipper-pkg-lib'; import {runBuild} from 'flipper-pkg-lib';
import {getPluginDetails} from 'flipper-plugin-lib';
async function deriveOutputFileName(inputDirectory: string): Promise<string> { async function deriveOutputFileName(inputDirectory: string): Promise<string> {
const packageJson = await readJSON(path.join(inputDirectory, 'package.json')); const packageJson = await readJSON(path.join(inputDirectory, 'package.json'));

View File

@@ -9,7 +9,7 @@
import path from 'path'; import path from 'path';
import fs from 'fs-extra'; import fs from 'fs-extra';
import {getPluginDetails} from 'flipper-pkg-lib'; import {getPluginDetails} from 'flipper-plugin-lib';
import {kebabCase} from 'lodash'; import {kebabCase} from 'lodash';
export default async function ( export default async function (

View File

@@ -7,7 +7,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"incremental": true "incremental": true
}, },
"references": [{"path": "../pkg-lib"}], "references": [{"path": "../pkg-lib"}, {"path": "../plugin-lib"}],
"include": ["src"], "include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"] "exclude": ["node_modules", "**/__tests__/*"]
} }

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,3 @@
# flipper-plugin-lib
`flipper-plugin-lib` is a library containing common Flipper plugin installation utilities.

View File

@@ -0,0 +1,8 @@
{
"transform": {
"^.+\\.tsx?$": "ts-jest"
},
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
"testPathIgnorePatterns": ["/node_modules/", "/lib/"],
"moduleFileExtensions": ["ts", "tsx", "js", "jsx", "json", "node"]
}

View File

@@ -0,0 +1,38 @@
{
"name": "flipper-plugin-lib",
"version": "0.45.0",
"description": "Library containing common Flipper plugin installation utilities",
"repository": "facebook/flipper",
"main": "lib/index.js",
"flipperBundlerEntry": "src",
"types": "lib/index.d.ts",
"license": "MIT",
"bugs": "https://github.com/facebook/flipper/issues",
"dependencies": {
"fs-extra": "^8.1.0"
},
"devDependencies": {
"@types/fs-extra": "^8.1.0",
"@types/jest": "^25.1.0",
"@types/node": "^13.7.5",
"globby": "^10",
"jest": "^25.1.0",
"rimraf": "^3.0.2",
"ts-jest": "^26.0.0",
"ts-node": "^8",
"typescript": "^3.9.2"
},
"scripts": {
"reset": "rimraf lib *.tsbuildinfo",
"build": "tsc -b",
"prepack": "yarn reset && yarn build"
},
"files": [
"lib/**/*"
],
"homepage": "https://github.com/facebook/flipper",
"keywords": [
"Flipper"
],
"author": "Facebook, Inc"
}

View File

@@ -0,0 +1,11 @@
/**
* 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
*/
export {default as PluginDetails} from './PluginDetails';
export {default as getPluginDetails} from './getPluginDetails';

View File

@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"outDir": "lib",
"rootDir": "src",
"allowJs": true,
"esModuleInterop": true,
"composite": true,
"incremental": true
},
"include": ["src"],
"exclude": ["node_modules", "**/__tests__/*"]
}

View File

@@ -13,7 +13,8 @@ import util from 'util';
import recursiveReaddir from 'recursive-readdir'; import recursiveReaddir from 'recursive-readdir';
import pMap from 'p-map'; import pMap from 'p-map';
import {homedir} from 'os'; import {homedir} from 'os';
import {runBuild, PluginDetails} from 'flipper-pkg-lib'; import {PluginDetails} from 'flipper-plugin-lib';
import {runBuild} from 'flipper-pkg-lib';
import {getSourcePlugins, getInstalledPlugins} from './getPlugins'; import {getSourcePlugins, getInstalledPlugins} from './getPlugins';
import startWatchPlugins from './startWatchPlugins'; import startWatchPlugins from './startWatchPlugins';
import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable'; import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable';

View File

@@ -14,7 +14,7 @@ import {
getPluginsInstallationFolder, getPluginsInstallationFolder,
getPluginSourceFolders, getPluginSourceFolders,
} from './getPluginFolders'; } from './getPluginFolders';
import {PluginDetails, getPluginDetails} from 'flipper-pkg-lib'; import {PluginDetails, getPluginDetails} from 'flipper-plugin-lib';
import pmap from 'p-map'; import pmap from 'p-map';
import pfilter from 'p-filter'; import pfilter from 'p-filter';

View File

@@ -10,6 +10,7 @@
"fb-watchman": "^2.0.0", "fb-watchman": "^2.0.0",
"fix-path": "^3.0.0", "fix-path": "^3.0.0",
"flipper-pkg-lib": "0.45.0", "flipper-pkg-lib": "0.45.0",
"flipper-plugin-lib": "0.45.0",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"ignore": "^5.1.4", "ignore": "^5.1.4",
"mem": "^6.0.0", "mem": "^6.0.0",

View File

@@ -9,7 +9,7 @@
import path from 'path'; import path from 'path';
import Watchman from './watchman'; import Watchman from './watchman';
import {PluginDetails} from 'flipper-pkg-lib'; import {PluginDetails} from 'flipper-plugin-lib';
export default async function startWatchPlugins( export default async function startWatchPlugins(
plugins: PluginDetails[], plugins: PluginDetails[],

View File

@@ -10,7 +10,8 @@
"flipper-pkg": ["./pkg/src"], "flipper-pkg": ["./pkg/src"],
"flipper-pkg-lib": ["./pkg-lib/src"], "flipper-pkg-lib": ["./pkg-lib/src"],
"live-plugin-manager": ["./types/live-plugin-manager.d.tsx"], "live-plugin-manager": ["./types/live-plugin-manager.d.tsx"],
"flipper-babel-transformer": ["./babel-transformer/src"] "flipper-babel-transformer": ["./babel-transformer/src"],
"flipper-plugin-lib": ["./plugin-lib/src"]
} }
}, },
"exclude": ["**/node_modules/", "**/*.spec.ts"] "exclude": ["**/node_modules/", "**/*.spec.ts"]