Commit Graph

22 Commits

Author SHA1 Message Date
Anton Nikolaev
a08bed86b7 Fix changelog.md generation
Summary: Currently Flipper shows empty Changelog with only "pre-history" entry. This is because of path in generation script is wrong now. Flipper shows Changelog.md from desktop/static, so generated entries should be added there rather than to Changelog.md in the root.

Reviewed By: passy

Differential Revision: D21016884

fbshipit-source-id: 8709a2556374ec70bc665eaf0729bb85fd0d913f
2020-04-14 09:21:58 -07:00
Anton Nikolaev
a54aad57a7 Fast refresh
Summary:
This diff enables optional [Fast Refresh](https://reactnative.dev/docs/fast-refresh) for Flipper in dev mode. It can be opted-in using additional argument "--fast-refresh": `yarn start --fast-refresh`. I've copy-pasted the most part of implementation from React Native with some minor changes.

I made this optional for now as it works not ideally. In most cases which I checked it works fine, however for some files it falls back to full refresh (e.g. when `desktop/plugins/network/index.tsx` changed) and sometimes doesn't refresh content even after change detected and re-compiled (e.g. when `src/ui/components/searchable/Searchable.tsx` is changed, Network plugin which is dependent on it is not refreshed automatically).

State from redux is restored after fast refresh, but local state in class-based components is cleared. For function-based components local state is also stored, so it's an additional point to make plugins components functional :)

Also, for now there is no UI for Fast Refresh (loading indicator etc), information is just logged to console.

Changelog: Experimental support for Fast Refresh in dev mode can be enabled by `yarn start --fast-refresh`.

Reviewed By: jknoxville

Differential Revision: D20993073

fbshipit-source-id: 65632788df105a85fac0b924b7808120900b349e
2020-04-14 07:20:40 -07:00
Anton Nikolaev
553c54b63e Include default plugins into app bundle (#998)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/998

After this diff all the default plugins (which are distributed with Flipper) will be included into the main app bundle instead of bundling each of them separately and then loading from file system. This is done by auto-generating plugins index in build-time and importing it from Flipper app bundle, so Metro can follow these imports and bundle all the plugins to the app bundle.
This provides several benefits:
1) reduced Flipper bundle size (~10% reduction of zipped Flipper archive), because Metro bundles each of re-used dependencies only once instead of bundling them for each plugin where such dependency used.
2) Faster Flipper startup because of reduced bundle and the fact that we don't need to load each plugin bundle from disk - just need to load the single bundle where everything is already included.
3) Metro dev server for plugins works in the same way as for Flipper app itself, e.g. simple refresh automatically recompiles bundled plugins too if there are changes. This also potentially should allow us to enable "fast refresh" for quicker iterations while developing plugins.
4) Faster build ("yarn build --mac" is 2 times faster on my machine after this change)

Potential downsides:
1) Currently all the plugins are identically loaded from disk. After this change some of plugins will be bundled, and some of them (third-party) will be loaded from disk.
2) In future when it will be possible to publish new versions of default plugins separately, installing new version of such plugin (e.g. with some urgent fix) will mean the "default" pre-built version will still be bundled (we cannot "unbundle" it :)), but we'll skip it and instead load new version from disk.

Changelog: Internals: include default plugins into the main bundle instead producing separate bundles for them.

Reviewed By: passy

Differential Revision: D20864002

fbshipit-source-id: 2968f3b786cdd1767d6223996090143d03894b92
2020-04-14 07:20:39 -07:00
Anton Nikolaev
cc96fc984c Refactor plugins compilation script
Summary:
Refactored plugins compilation script by splitting it into 3 scripts: 1) search plugins 2) compile plugins 3) watch plugins.

No functional changes in this review, it's just preparation for further changes.

Reviewed By: passy

Differential Revision: D20860443

fbshipit-source-id: 02900430199875574b992e597d09b82d0d7f32ef
2020-04-14 07:20:39 -07:00
Anton Nikolaev
452c52c291 Add internal plugins as workspaces to single package.json
Summary: We cannot just add internal plugins as workspaces to the root package.json in "sonar/desktop" as they are not open-sourced, so public build will break. Instead, I have created root package.json for internal plugins and added all internal plugins as workspaces there. This means all these plugins will use the single root yarn.lock and installation of their dependencies will be faster. This also means that plugins can declare dependencies to other local packages included into workspaces and they will be symlinked automatically.

Reviewed By: mweststrate

Differential Revision: D20806237

fbshipit-source-id: f8b3327166963dec7da8ac74079682aebe4527e1
2020-04-14 07:20:38 -07:00
Anton Nikolaev
bcc133026e Add public plugins to the root package.json as workspaces (#969)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/969

Added all public plugins as workspaces to the root package.json. This means all these plugins will use the single root yarn.lock and installation of their dependencies will be faster. This also means that plugins can declare dependencies to other local packages included into workspaces and they will be symlinked automatically.

Changelog: Internals: plugins added as "yarn workspaces" into the root package.json to simplify dependency management between them

Reviewed By: mweststrate

Differential Revision: D20805231

fbshipit-source-id: e85c62d3195d1ea3c5c60def6ca12318a2b53466
2020-04-14 07:20:38 -07:00
Pascal Hartig
41a911379d Set product name and executable
Summary:
This means that Linux builds have a `flipper` executable
in the directory again.

Reviewed By: cekkaewnumchai

Differential Revision: D20915156

fbshipit-source-id: 9f792bcffef41168fe5a3e43c29b59f37a4cc673
2020-04-08 06:14:13 -07:00
Anton Nikolaev
2690894ad0 Fix npm publishing
Summary:
Fixed npm packaging/publishing scripts for "flipper-doctor", "flipper-pkg" and "flipper-babel-transformer".

Also removed scripts for testing and linting, because these packages are tested and linted by root level package.json.

Reviewed By: jknoxville

Differential Revision: D20839959

fbshipit-source-id: 4d9d037d4921fc97356c849054c389dfece05652
2020-04-06 02:35:51 -07:00
Michel Weststrate
cfb77148f7 Fix changelog generation search directory
Summary:
Fix issue where not the full sonar repo was search when looking for Diffs with a changelog entry.
(note that we don't use absolute paths as that gaves problems in the past on CI where a sparse checkout happens and the hg root turned out to be different)

Reviewed By: passy

Differential Revision: D20793800

fbshipit-source-id: a77e1602e00127ba2d831a4c6392e2f1984a4fc6
2020-04-02 02:20:45 -07:00
Anton Nikolaev
bf32297ad9 Publish all packages to npm on release
Summary: Publish all the public packages (excluding those with "private=true") included as workspaces to "desktop" project.

Reviewed By: jknoxville

Differential Revision: D20765097

fbshipit-source-id: 444541e9a682a90eba02cb3da85ada9bd00d93d0
2020-03-31 06:34:39 -07:00
Anton Nikolaev
eb9a2cb5e7 Bump versions for all npm packages on release
Summary:
Automatically bump versions for all local npm packages included as workspaces and fix local dependencies correspondingly.

As a part of this I have also aligned versioning for all the packages by using the same version for all of them.

Reviewed By: jknoxville

Differential Revision: D20745632

fbshipit-source-id: 2d438c4b23ee72f7d7c068c5ce161063c7ceb9e5
2020-03-31 06:34:39 -07:00
Anton Nikolaev
da7449c20b Enable Metro caching
Summary:
Enabling Metro cache for dev mode. For release builds we reset the cache.

Cache is used for faster compilation in dev mode for both main and renderer bundles, as well as for plugins.

Currently we have few side effects based on env vars, so cache is invalidated when they are changed. Also the cache is invalidated when transformations are changed (changed code, bumped dependency etc). Also added a script to reset the cache if something is going wrong.

Reviewed By: mweststrate

Differential Revision: D20691464

fbshipit-source-id: 478947d438bd3090f052dbfa6ad5c649523ecacb
2020-03-30 09:28:35 -07:00
Anton Nikolaev
5e7a22147b Fix reload after changes in the main app bundle
Summary: Fixed automatic reloading on changes while "yarn start"

Reviewed By: mweststrate

Differential Revision: D20691166

fbshipit-source-id: 78b01a3c5e4a6da1537f2230411069e04ebbc81e
2020-03-27 03:26:52 -07:00
Anton Nikolaev
c1bb656a0d Re-use babel transformations
Summary:
SORRY FOR BIG DIFF, but it's really hard to split it as all these changes are cross-dependent and should be made at once:
1. Moved transformations to separate package "flipper-babel-transformer" and linked it using yarn workspaces to "static" and "pkg" packages where they are re-used. Removed double copies of transformations we had before int these two packages.
2. Converted transformations to typescript
3. Refactored transformations to avoid relying on file system paths for customisation (FB stubs and Electron stubs for headless build)
4. As babel transformations must be built before other builds - enabled incremental build for them and changed scripts to invoke the transformations build before other build scripts
5. As we need to deploy all the dependencies including the fresh "flipper-babel-transformer" as a part of "static" - implemented script which copies package with all the dependencies taking in account yarn workspaces (hoisting and symlinks)

Reviewed By: passy, mweststrate

Differential Revision: D20690662

fbshipit-source-id: 38a275b60d3c91e01ec21d1dbd72d03c05cfac0b
2020-03-27 03:26:51 -07:00
Pascal Hartig
fc9ed65762 prettier 2
Summary:
Quick notes:

- This looks worse than it is. It adds mandatory parentheses to single argument lambdas. Lots of outrage on Twitter about it, personally I'm {emoji:1f937_200d_2642} about it.
- Space before function, e.g. `a = function ()` is now enforced. I like this because both were fine before.
- I added `eslint-config-prettier` to the config because otherwise a ton of rules conflict with eslint itself.

Close https://github.com/facebook/flipper/pull/915

Reviewed By: jknoxville

Differential Revision: D20594929

fbshipit-source-id: ca1c65376b90e009550dd6d1f4e0831d32cbff03
2020-03-24 09:38:11 -07:00
Anton Nikolaev
3cbeaf2642 Fix Github build (#914)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/914

Fixed Github build I accidentaly broke by a previous diff

Reviewed By: mweststrate

Differential Revision: D20581935

fbshipit-source-id: c14d7e0fe83af79069f8fef432833babf04c59f8
2020-03-21 15:31:20 -07:00
Anton Nikolaev
863f89351e Yarn workspaces
Summary:
1) moved "sonar/desktop/src" to "sonar/desktop/app/src", so "app" is now a separate package containing the core Flipper app code
2) Configured yarn workspaces with the root in "sonar/desktop": app, static, pkg, doctor, headless-tests. Plugins are not included for now, I plan to do this later.

Reviewed By: jknoxville

Differential Revision: D20535782

fbshipit-source-id: 600b2301960f37c7d72166e0d04eba462bec9fc1
2020-03-20 13:37:41 -07:00
Michel Weststrate
f919a0d1a3 fixed issue where install script errors were not properly propagated
Summary:
Our post install scripts didn't propagate installation errors in CI (or locally), leading to problems only appearing later in time, causing a lot of lost time {emoji:1f605}

Also moved printing what package is installing to _before_ running the script, so that you have actual useful info in case it fails.

Compilation errors of pkg and doctor were printed in our CI, but never threw exceptions.

Fixed the cause of those compilation errors as well using `skipLibCheck` like done in the root tsconfig

Reviewed By: jknoxville

Differential Revision: D20470985

fbshipit-source-id: 1b13d4d2c096f253cc9c1f0aac06982fc4aedf55
2020-03-16 16:52:31 -07:00
Anton Nikolaev
952cb7783a Allow direct references of doctor and pkg from the main bundle
Summary: This diff allows direct referencing pkg and doctor packages from the main bundle so they can be changed and used in the main app without publishing to npm

Reviewed By: mweststrate

Differential Revision: D20390416

fbshipit-source-id: af625a8b7cead4481743a88aec198493d363ce76
2020-03-14 15:59:22 -07:00
Anton Nikolaev
10d990c32c Move plugins to "sonar/desktop/plugins"
Summary:
Plugins moved from "sonar/desktop/src/plugins" to "sonar/desktop/plugins".

Fixed all the paths after moving.

New "desktop" folder structure:
- `src` - Flipper desktop app JS code executing in Electron Renderer (Chrome) process.
- `static` - Flipper desktop app JS code executing in Electron Main (Node.js) process.
- `plugins` - Flipper desktop JS plugins.
- `pkg` - Flipper packaging lib and CLI tool.
- `doctor` - Flipper diagnostics lib and CLI tool.
- `scripts` - Build scripts for Flipper desktop app.
- `headless` - Headless version of Flipper desktop app.
- `headless-tests` - Integration tests running agains Flipper headless version.

Reviewed By: mweststrate

Differential Revision: D20344186

fbshipit-source-id: d020da970b2ea1e001f9061a8782bfeb54e31ba0
2020-03-14 14:35:18 -07:00
Anton Nikolaev
beb5c85e69 Enable eslint import checks and fixed the reported errors (#878)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/878

1) Enabled eslint error reporting for unresolved imports and fixed all the errors
2) Enabled eslint for typings (d.ts) and fixed all the errors

Reviewed By: passy

Differential Revision: D20335151

fbshipit-source-id: 7b142281a406b32df0f02a5cd0d7d05eba941acd
2020-03-14 14:35:18 -07:00
Anton Nikolaev
85c13bb1f3 Move desktop-related code to "desktop" subfolder (#872)
Summary:
Pull Request resolved: https://github.com/facebook/flipper/pull/872
Move all the JS code related to desktop app to "desktop" subfolder.

The structure of "desktop" folder:
- `src` - JS code of Flipper desktop app executing in Electron Renderer (Chrome) process. This folder also contains all the Flipper plugins in subfolder "src/plugins".
- `static` - JS code of Flipper desktop app bootstrapping executing in Electron Main (Node.js) process
- `pkg` - Flipper packaging lib and CLI tool
- `doctor` - Flipper diagnostics lib and CLI tool
- `scripts` - Build scripts for Flipper desktop app
- `headless` - Headless version of Flipper app
- `headless-tests` - Integration tests running agains Flipper headless version

Reviewed By: passy

Differential Revision: D20249304

fbshipit-source-id: 9a51c63b51b92b758a02fc8ebf7d3d116770efe9
2020-03-14 14:35:17 -07:00