From dcd909779bc5d115571063b04928f6e279814dee Mon Sep 17 00:00:00 2001 From: Anton Nikolaev Date: Fri, 26 Jun 2020 09:05:49 -0700 Subject: [PATCH] Script to list all plugins included into Flipper desktop workspaces Summary: Script to list all plugins included into Flipper desktop workspaces. Reviewed By: passy Differential Revision: D22256917 fbshipit-source-id: a3d8a0f9faea6e462a2f22be155d99eb22eb59d8 --- desktop/package.json | 1 + desktop/scripts/list-plugins.ts | 21 +++++++++++++++++++++ desktop/scripts/workspaces.ts | 12 ++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 desktop/scripts/list-plugins.ts diff --git a/desktop/package.json b/desktop/package.json index 8c6bbd8c0..07caca50d 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -251,6 +251,7 @@ "lint": "yarn lint:eslint && yarn lint:flow && yarn lint:tsc", "bump-versions": "./ts-node scripts/bump-versions.ts", "publish-packages": "./ts-node scripts/publish-packages.ts", + "list-plugins": "./ts-node scripts/list-plugins.ts", "everything": "yarn reset && yarn install && yarn lint && yarn test && yarn test-electron && yarn build --mac --mac-dmg --win --linux --linux-deb && yarn build-headless --mac --linux && yarn start" }, "optionalDependencies": { diff --git a/desktop/scripts/list-plugins.ts b/desktop/scripts/list-plugins.ts new file mode 100644 index 000000000..ac4c9df84 --- /dev/null +++ b/desktop/scripts/list-plugins.ts @@ -0,0 +1,21 @@ +/** + * 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 {getWorkspaces} from './workspaces'; + +getWorkspaces() + .then((workspaces) => { + workspaces.packages + .filter((x) => x.isPlugin) + .forEach((x) => console.log(x.dir)); + }) + .catch((err: any) => { + console.error(err); + process.exit(1); + }); diff --git a/desktop/scripts/workspaces.ts b/desktop/scripts/workspaces.ts index 61a35181c..bc51d09aa 100644 --- a/desktop/scripts/workspaces.ts +++ b/desktop/scripts/workspaces.ts @@ -20,6 +20,7 @@ const glob = promisify(globImport); export interface Package { dir: string; json: any; + isPrivate: boolean; isPlugin: boolean; } @@ -50,7 +51,11 @@ async function getWorkspacesByRoot( return { dir, json, - isPlugin: dir.startsWith(pluginsDir), + isPrivate: json.private || dir.startsWith(pluginsDir), + isPlugin: + json.keywords && + Array.isArray(json.keywords) && + json.keywords.includes('flipper-plugin'), }; }, ); @@ -58,6 +63,7 @@ async function getWorkspacesByRoot( rootPackage: { dir: rootDir, json: rootPackageJson, + isPrivate: true, isPlugin: false, }, packages, @@ -195,9 +201,7 @@ export async function publishPackages({ if (proxy) { cmd += ` --http-proxy ${proxy} --https-proxy ${proxy}`; } - const publicPackages = workspaces.packages.filter( - (pkg) => !pkg.json.private && !pkg.isPlugin, - ); + const publicPackages = workspaces.packages.filter((pkg) => !pkg.isPrivate); for (const pkg of publicPackages) { if (dryRun) { console.log(`DRYRUN: Skipping npm publishing for ${pkg.json.name}`);