diff --git a/desktop/package.json b/desktop/package.json index cf2071bbe..25b8d570c 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -25,7 +25,8 @@ "pkg-lib", "static", "plugins/*", - "e2e" + "e2e", + "plugin-lib" ], "nohoist": [ "flipper-plugin-kaios-big-allocations/firefox-client" @@ -178,6 +179,7 @@ "express": "^4.15.2", "flipper-babel-transformer": "0.45.0", "flipper-pkg-lib": "0.45.0", + "flipper-plugin-lib": "0.45.0", "flow-bin": "0.124.0", "fs-extra": "^9.0.0", "glob": "^7.1.2", diff --git a/desktop/pkg-lib/src/index.ts b/desktop/pkg-lib/src/index.ts index 87d8b505a..e5ab0987d 100644 --- a/desktop/pkg-lib/src/index.ts +++ b/desktop/pkg-lib/src/index.ts @@ -9,5 +9,3 @@ export {default as runBuild} from './runBuild'; export {default as getWatchFolders} from './getWatchFolders'; -export {default as PluginDetails} from './PluginDetails'; -export {default as getPluginDetails} from './getPluginDetails'; diff --git a/desktop/pkg/package.json b/desktop/pkg/package.json index 89e73d5ba..545021a66 100644 --- a/desktop/pkg/package.json +++ b/desktop/pkg/package.json @@ -21,6 +21,7 @@ "ajv-errors": "^1.0.1", "cli-ux": "^5.4.6", "flipper-pkg-lib": "0.45.0", + "flipper-plugin-lib": "0.45.0", "fs-extra": "^8.1.0", "inquirer": "^7.1.0", "lodash": "^4.17.15", diff --git a/desktop/pkg/src/commands/bundle.ts b/desktop/pkg/src/commands/bundle.ts index bff8e7dc0..2bb14d2d4 100644 --- a/desktop/pkg/src/commands/bundle.ts +++ b/desktop/pkg/src/commands/bundle.ts @@ -11,7 +11,8 @@ import {Command, flags} from '@oclif/command'; import {args} from '@oclif/parser'; import fs from 'fs-extra'; 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 { public static description = 'transpiles and bundles plugin'; diff --git a/desktop/pkg/src/commands/pack.ts b/desktop/pkg/src/commands/pack.ts index 77d15ff7c..d6a10663c 100644 --- a/desktop/pkg/src/commands/pack.ts +++ b/desktop/pkg/src/commands/pack.ts @@ -15,7 +15,8 @@ import * as inquirer from 'inquirer'; import * as path from 'path'; import * as yarn from '../utils/yarn'; 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 { const packageJson = await readJSON(path.join(inputDirectory, 'package.json')); diff --git a/desktop/pkg/src/utils/runMigrate.ts b/desktop/pkg/src/utils/runMigrate.ts index 419264af8..bd0624d0d 100644 --- a/desktop/pkg/src/utils/runMigrate.ts +++ b/desktop/pkg/src/utils/runMigrate.ts @@ -9,7 +9,7 @@ import path from 'path'; import fs from 'fs-extra'; -import {getPluginDetails} from 'flipper-pkg-lib'; +import {getPluginDetails} from 'flipper-plugin-lib'; import {kebabCase} from 'lodash'; export default async function ( diff --git a/desktop/pkg/tsconfig.json b/desktop/pkg/tsconfig.json index 5351f2720..6a376a67e 100644 --- a/desktop/pkg/tsconfig.json +++ b/desktop/pkg/tsconfig.json @@ -7,7 +7,7 @@ "esModuleInterop": true, "incremental": true }, - "references": [{"path": "../pkg-lib"}], + "references": [{"path": "../pkg-lib"}, {"path": "../plugin-lib"}], "include": ["src"], "exclude": ["node_modules", "**/__tests__/*"] } diff --git a/desktop/plugin-lib/LICENSE b/desktop/plugin-lib/LICENSE new file mode 100644 index 000000000..b96dcb048 --- /dev/null +++ b/desktop/plugin-lib/LICENSE @@ -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. diff --git a/desktop/plugin-lib/README.md b/desktop/plugin-lib/README.md new file mode 100644 index 000000000..545fd8250 --- /dev/null +++ b/desktop/plugin-lib/README.md @@ -0,0 +1,3 @@ +# flipper-plugin-lib + +`flipper-plugin-lib` is a library containing common Flipper plugin installation utilities. diff --git a/desktop/plugin-lib/jestconfig.json b/desktop/plugin-lib/jestconfig.json new file mode 100644 index 000000000..bab48ba29 --- /dev/null +++ b/desktop/plugin-lib/jestconfig.json @@ -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"] +} diff --git a/desktop/plugin-lib/package.json b/desktop/plugin-lib/package.json new file mode 100644 index 000000000..e6c5f4917 --- /dev/null +++ b/desktop/plugin-lib/package.json @@ -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" +} diff --git a/desktop/pkg-lib/src/PluginDetails.ts b/desktop/plugin-lib/src/PluginDetails.ts similarity index 100% rename from desktop/pkg-lib/src/PluginDetails.ts rename to desktop/plugin-lib/src/PluginDetails.ts diff --git a/desktop/pkg-lib/src/__tests__/getPluginDetails.node.ts b/desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts similarity index 100% rename from desktop/pkg-lib/src/__tests__/getPluginDetails.node.ts rename to desktop/plugin-lib/src/__tests__/getPluginDetails.node.ts diff --git a/desktop/pkg-lib/src/getPluginDetails.ts b/desktop/plugin-lib/src/getPluginDetails.ts similarity index 100% rename from desktop/pkg-lib/src/getPluginDetails.ts rename to desktop/plugin-lib/src/getPluginDetails.ts diff --git a/desktop/plugin-lib/src/index.ts b/desktop/plugin-lib/src/index.ts new file mode 100644 index 000000000..5f468a15f --- /dev/null +++ b/desktop/plugin-lib/src/index.ts @@ -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'; diff --git a/desktop/plugin-lib/tsconfig.json b/desktop/plugin-lib/tsconfig.json new file mode 100644 index 000000000..545c321c0 --- /dev/null +++ b/desktop/plugin-lib/tsconfig.json @@ -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__/*"] +} diff --git a/desktop/static/compilePlugins.ts b/desktop/static/compilePlugins.ts index 5211168fd..9810aea90 100644 --- a/desktop/static/compilePlugins.ts +++ b/desktop/static/compilePlugins.ts @@ -13,7 +13,8 @@ import util from 'util'; import recursiveReaddir from 'recursive-readdir'; import pMap from 'p-map'; 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 startWatchPlugins from './startWatchPlugins'; import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable'; diff --git a/desktop/static/getPlugins.ts b/desktop/static/getPlugins.ts index 866e77be8..1a51188bc 100644 --- a/desktop/static/getPlugins.ts +++ b/desktop/static/getPlugins.ts @@ -14,7 +14,7 @@ import { getPluginsInstallationFolder, getPluginSourceFolders, } from './getPluginFolders'; -import {PluginDetails, getPluginDetails} from 'flipper-pkg-lib'; +import {PluginDetails, getPluginDetails} from 'flipper-plugin-lib'; import pmap from 'p-map'; import pfilter from 'p-filter'; diff --git a/desktop/static/package.json b/desktop/static/package.json index edfc185ef..67d9dc18e 100644 --- a/desktop/static/package.json +++ b/desktop/static/package.json @@ -10,6 +10,7 @@ "fb-watchman": "^2.0.0", "fix-path": "^3.0.0", "flipper-pkg-lib": "0.45.0", + "flipper-plugin-lib": "0.45.0", "fs-extra": "^8.1.0", "ignore": "^5.1.4", "mem": "^6.0.0", diff --git a/desktop/static/startWatchPlugins.ts b/desktop/static/startWatchPlugins.ts index f09ffca39..f654cd472 100644 --- a/desktop/static/startWatchPlugins.ts +++ b/desktop/static/startWatchPlugins.ts @@ -9,7 +9,7 @@ import path from 'path'; import Watchman from './watchman'; -import {PluginDetails} from 'flipper-pkg-lib'; +import {PluginDetails} from 'flipper-plugin-lib'; export default async function startWatchPlugins( plugins: PluginDetails[], diff --git a/desktop/tsconfig.json b/desktop/tsconfig.json index 0cc1644ed..2e57b3aa9 100644 --- a/desktop/tsconfig.json +++ b/desktop/tsconfig.json @@ -10,7 +10,8 @@ "flipper-pkg": ["./pkg/src"], "flipper-pkg-lib": ["./pkg-lib/src"], "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"]