Summary:
Sets a default key binding of `ctrl+l` to clear the screen within built-in Flipper plugins which display a log view.
Motivation: A small quality of life improvement for developers used to the default "clear screen" binding. This makes our log-rendering plugins consistent with other native apps such as terminals, Chrome DevTools, and many others.
Reviewed By: mweststrate
Differential Revision: D37782638
fbshipit-source-id: 0a85b930faaa0e9468d5391f15092aad7b6057ee
Summary:
I've decided to migrate [a desktop plugin](https://github.com/bamlab/react-native-performance) to Sandy.
When doing so, I decided to rise to the challenge from the [Flipper docs](https://fbflipper.com/docs/tutorial/js-custom#testing-plugin-logic): `we are going to pretend that we always write unit tests first` 😅
However, I've realized that when creating a plugin with `npx flipper-pkg init`, running `yarn jest` directly after creation actually fails.
There are 3 issues solved in the different commits:
1. an absolute import seem to not be resolved, since all the other imports were relative in the file, I changed it as well
2. some dependencies are missing.
They used to be included in the `flipper` dependency but when migrating to use `flipper-plugin` instead, they're not present anymore.
I don't think this is an ideal fix, I would believe a dependency like a `flipper-dev-environment` including all of those would be more appropriate. So I'm open to suggestions to fix/remove of course
3. jest.config needs to be fixed to run in jsdom environment and ensure we can test the react component
## Changelog
Fix: ensure desktop plugin template tests run
Pull Request resolved: https://github.com/facebook/flipper/pull/3039
Test Plan:
I've cloned the repo and run:
```
cd flipper/desktop/pkg
yarn
cd ../../..
./flipper/desktop/pkg/bin/run init
```
I run the tests on the newly package created, but it actually still failed because of the first issue (since it still installed `flipper-plugin` from npm`)
However, by adding this patch, it now runs!
```patch
diff --git a/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js b/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
index 2e07ff5..ff3181d 100644
--- a/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
+++ b/node_modules/flipper-plugin/lib/ui/data-table/DataTable.js
@@ -39,7 +39,7 @@ const useAssertStableRef_1 = require("../../utils/useAssertStableRef");
const PluginContext_1 = require("../../plugin/PluginContext");
const lodash_1 = require("lodash");
const useInUnitTest_1 = require("../../utils/useInUnitTest");
-const createDataSource_1 = require("flipper-plugin/src/state/createDataSource");
+const createDataSource_1 = require("../../state/createDataSource");
function DataTable(props) {
var _a, _b;
const { onRowStyle, onSelect, onCopyRows, onContextMenu } = props;
```
Reviewed By: aigoncharov
Differential Revision: D32358207
Pulled By: mweststrate
fbshipit-source-id: 7761b4150c24dd5379a24c3c1deeb78bf3dda4ee
Summary:
`flipper-pkg init` would always introduce `flipper-plugin` peer with version `latest`. Since that can never be checked against the current flipper version, it always generated a warning. Updated the init process to take the version the plugin was generated with as base version instead.
Note that in the test the version will always display as 0.0.0, will double check after release that the proper version will show up when running from npx, but don't see a reason why not (famous last words)
Reviewed By: nikoant, priteshrnandgaonkar
Differential Revision: D28992531
fbshipit-source-id: c32aad1650f575f790c2e04d089104b7a616d26f
Summary:
Added option to bootstrap device plugin in "flipper-pkg".
Changelog: "flipper-pkg init" can now be used to bootstrap device plugins
Reviewed By: mweststrate
Differential Revision: D26389429
fbshipit-source-id: 90773011bd50289004cd747111e1787402840922
Summary: This updates the docs of Flipper to use Sandy, rather than `FlipperPlugin` class. Restructured the docs a bit as a result.
Reviewed By: passy
Differential Revision: D24991285
fbshipit-source-id: 66d5760c25cf9cf3983515433dfd64348d51db3d
Summary:
This diff updates plugin scaffolding by using Sandy and closely following the internal Scarf templates (see D24949452, D24949452)
By using `flipper-plugin`, it is now also possible to write unit tests for a plugin, and the default infra for that is generated (babel / jest)
For now there is still a dependency on `flipper` to support fancy components not yet available in Sandy, this will be updated in the future: T79632585
Changelog: `flipper-pkg init` now uses the new Sandy plugin infrastructure ant Ant.design component system
Reviewed By: nikoant
Differential Revision: D24950080
fbshipit-source-id: afc5e7ac728b20cb84fdbbdcb76cd45968736c01
Summary:
Created a test that snapshots the generated files, so that we can capture accidental regressions when generating files.
Also made the package id to package name a bit more robust
Reviewed By: jknoxville
Differential Revision: D21619633
fbshipit-source-id: 88ffb127e050d840df9ccd4b15ba29a71f341975
Summary:
Added a watch mode to the bundle command of flipper plugins. This makes it easy to test develop plugins locally, even when you are using a production build of flipper, which lowers the barrier of developing / fixing plugins.
opted for `fs.watch` over watchman to avoid some overengineering:
1. pkg / pkg-lib don't have the watchman utilities that would be needed for this. I wasn't sure if I could move those over from `static` without breaking the bootstrapping process
2. watchman is often a nuisance on non FB machines that aren't set up for it. fs.watch in contrast doesn't have any further dependencies or setup requirements, and is much more likely to work ootb.
3. since we watch only the `src` folder we don't really need the watchman optimizations. (so for a package.json change people would have to restart, but I don't think that is much of a problem).
Reviewed By: jknoxville
Differential Revision: D21523814
fbshipit-source-id: b1de72b7d01c6fc50cb8ce5709f54f8019eb89e4
Summary: See previous diff, should have merged those two diffs
Reviewed By: jknoxville
Differential Revision: D21523815
fbshipit-source-id: 3db91d06d845f0764e28f0dbf3020e77812cde53
Summary: When opening a freshly generated plugin in VScode the IDE would be full of errors, even though it can bundle correctly thanks to the defaults used by bundle. This is fixed by diff by correctly setting up a tsconfig.
Reviewed By: jknoxville
Differential Revision: D21523817
fbshipit-source-id: 8f6b58fbfb704460ddb5b845ddfb137b28d37187
Summary: By adding a build command the flipper plugin can be picked up, even when using a production build of Flipper, as we don't require Flipper's own infrastructure anymore to compile plugins.
Reviewed By: jknoxville
Differential Revision: D21523819
fbshipit-source-id: eed935ee95a7e3bff2ace629836b4b2450b5d1ad
Summary:
As soon as any data was send to a freshly generated plugin, the plugin would crash as React doesn't support directly rendering data. Replaced it with a poor mans rendering that simply dumps all the data we received.
Also made sure the view is scrollable now which wasn't the case before.
Reviewed By: jknoxville
Differential Revision: D21523816
fbshipit-source-id: 3e04799facdf8b66ce9d66217a47fc7826d58d43
Summary:
This stack contains a bunch of improvements I made to smoothen the demo of plugin creating in the Flipper + React Native talk.
With 98% likelihood people will manage the source code of their Flipper plugins in git. This will make sure the `.gitignore` is configured properly ootb
Reviewed By: nikoant
Differential Revision: D21523818
fbshipit-source-id: b2ed769edc8fb9fd320464b05686e817e438f21e