Commit Graph

93 Commits

Author SHA1 Message Date
Lorenzo Blasa
c347fae7c1 Use getAuthToken utility function instead
Summary: ^

Reviewed By: mweststrate

Differential Revision: D46557801

fbshipit-source-id: 2a83613afd9482ff4ed0abe5aaaf9675ef73bc49
2023-06-08 07:17:12 -07:00
Lorenzo Blasa
132a20d5a7 Token read from invalid path
Summary:
^

Token is no longer in the static directory. Also, we can now use a shared utility.

Reviewed By: aigoncharov

Differential Revision: D46516296

fbshipit-source-id: c38d024061653ac8b3fb587c8e3ad83dba0b151d
2023-06-07 07:39:56 -07:00
Lorenzo Blasa
bb9793019c Expand PATH with /usr/local/bin
Summary:
^

There is an issue whereas when Flipper Server is launched NOT from the terminal, it doesn't inherit the user's terminal `$PATH` variable.

This causes a few different issues.

This change tries to address that.

Reviewed By: passy

Differential Revision: D46392435

fbshipit-source-id: 6201a1749134db8c50eca8751af149737dce57d7
2023-06-02 08:01:51 -07:00
Lorenzo Blasa
6430403da0 Jest update v26.6.3 -> v29.5.1
Summary:
^

Basically, update Jest and fix any raised issues. Mainly:
- Update necessary dependencies
- Update snapshots
- `useFakeTimers` caused a few issues which meant that the way we hook into the performance object had to be tweaked. The main code change is: `//fbsource/xplat/sonar/desktop/scripts/jest-setup-after.tsx`
- `mocked` -> `jest.mocked`

Changelog: Update Jest to v29.5.1

Reviewed By: antonk52

Differential Revision: D46319818

fbshipit-source-id: d218ca8f7e43abac6b00844953ddeb7f4e1010a2
2023-05-31 14:19:29 -07:00
Lorenzo Blasa
76fbaf245c Replace existing running instance, if any
Summary:
Replace an existing running instance, if any.

This is useful for:
- Applying updates
- Ensuring freshness of server

Reviewed By: passy

Differential Revision: D46146814

fbshipit-source-id: bfb760f3ab26b7632510773609f1c6ca3a97c4ec
2023-05-25 06:32:18 -07:00
Lorenzo Blasa
4704c177ec Check if server is already listening
Summary:
Right now, this simply avoids trying to create a server instance if one appears to be already running.

In a future change, we may decide to kill the existing instance and replace it with a new one.

But, in this case, running this as is will be useful as it will provide the connection URL with the auth token.

Also remove flipper server dependency from finding installation. In this case, we don't need it and can use `os.getPlatform()` instead.

Reviewed By: antonk52

Differential Revision: D46144843

fbshipit-source-id: 2922843b916d37e0126e43ae65a622f87a6920ec
2023-05-24 06:50:05 -07:00
Lorenzo Blasa
c6d5eb3334 Flipper as PWA
Summary:
^

Reference: https://docs.google.com/document/d/1flQJUzTe4AuQz3QCpvbloQycenHsu7ZxbKScov7K7ao

Reviewed By: passy

Differential Revision: D45693382

fbshipit-source-id: 5a2e6c213a7e7e2cf9cd5f3033cff3e5291a2a92
2023-05-16 04:32:47 -07:00
Lorenzo Blasa
a96caacb2b EnvironmentInfo as argument to start server
Summary:
Clean initialisation by passing down the environment info to start server.

(Also rename dir to path as that's the name used in other places)

Reviewed By: passy

Differential Revision: D45731751

fbshipit-source-id: a60fdd49c567fc312d1f8da72db3a46a0828c140
2023-05-11 04:10:16 -07:00
Lorenzo Blasa
b94f6b6152 Set the right environment info for headless builds
Summary: The isHeadlessBuild flag was not properly set.

Reviewed By: antonk52

Differential Revision: D45728435

fbshipit-source-id: 3616c4358114d4f3d96372766dabf48b27b44333
2023-05-10 04:35:17 -07:00
Lorenzo Blasa
238f40f55d Mandate auth token to connect over TCP
Summary:
Until now, launching flipper-server with TCP would accept any incoming connection as long as it comes from the same origin (localhost) using web socket host origin verification.

This is not entirely secure as origin can be spoofed with tools like curl.

Our team created a security review and a proposal was written:
https://docs.google.com/document/d/16iXypCQibPiner061SoaQUFUY9tLVAEpkKfV_hUXI7c/

Effectively, Flipper can generate a token which is then used by the client to authenticate.

This diff contains the changes required to generate, obtain, and validate authentication tokens from clients connecting to flipper over TCP connections.

The token itself is a JWT token. JWT was chosen because it is a simple industry standard which offers three features which can immediately benefit us:

- Expiration handling. No need for Flipper to store this information anywhere.
- Payload. Payload can be used to push any data we deem relevant i.e. unix username.
- Signing. Signed and verified using the same server key pair which is already in place for certificate exchange.

Additionally, the token is stored in the Flipper static folder. This ensures that the browser and PWA clients have access to it.

Reviewed By: mweststrate

Differential Revision: D45179654

fbshipit-source-id: 6761bcb24f4ba30b67d1511cde8fe875158d78af
2023-05-05 07:52:13 -07:00
Pascal Hartig
18b6ce6f24 Dep bump
Summary: Combining a bunch of individual tasks for dep upgrades into one diff.

Reviewed By: ivanmisuno

Differential Revision: D42706074

fbshipit-source-id: 054b2545ad1295699f47f4c6eb5065b7b9a1d6a0
2023-01-25 04:35:09 -08:00
dependabot[bot]
404449d499 Bump yargs from 17.4.1 to 17.6.0 in /desktop (#4165)
Summary:
Bumps [yargs](https://github.com/yargs/yargs) from 17.4.1 to 17.6.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/yargs/yargs/blob/main/CHANGELOG.md">yargs's changelog</a>.</em></p>
<blockquote>
<h2><a href="https://github.com/yargs/yargs/compare/v17.5.1...v17.6.0">17.6.0</a> (2022-10-01)</h2>
<h3>Features</h3>
<ul>
<li><strong>lang:</strong> Czech locale (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2220">https://github.com/facebook/flipper/issues/2220</a>) (<a href="5895cf1ba1">5895cf1</a>)</li>
<li><strong>usage:</strong> add YARGS_DISABLE_WRAP env variable to disable wrap (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2210">https://github.com/facebook/flipper/issues/2210</a>) (<a href="b680ace299">b680ace</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>deno:</strong> use 'globalThis' instead of 'window' (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2186">https://github.com/facebook/flipper/issues/2186</a>) (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2215">https://github.com/facebook/flipper/issues/2215</a>) (<a href="561fc7a787">561fc7a</a>)</li>
<li><strong>deps:</strong> cliui with forced strip-ansi update (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2241">https://github.com/facebook/flipper/issues/2241</a>) (<a href="38e8df10f0">38e8df1</a>)</li>
<li>dont clobber description for multiple option calls (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2171">https://github.com/facebook/flipper/issues/2171</a>) (<a href="f91d9b334a">f91d9b3</a>)</li>
<li><strong>typescript:</strong> address warning with objectKeys (<a href="394f5f86d1">394f5f8</a>)</li>
</ul>
<h3><a href="https://github.com/yargs/yargs/compare/v17.5.0...v17.5.1">17.5.1</a> (2022-05-16)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>add missing entries to published files (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2185">https://github.com/facebook/flipper/issues/2185</a>) (<a href="5685382d18">5685382</a>)</li>
<li>address bug when strict and async middleware used together (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2164">https://github.com/facebook/flipper/issues/2164</a>) (<a href="cbc2eb726e">cbc2eb7</a>)</li>
<li><strong>completion:</strong> correct zsh installation instructions (<a href="22e9af28bb">22e9af2</a>)</li>
<li>handle multiple node_modules folders determining mainFilename for ESM (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2123">https://github.com/facebook/flipper/issues/2123</a>) (<a href="e0823dd7e6">e0823dd</a>)</li>
<li><strong>lang:</strong> add missing terms to Russian translation (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2181">https://github.com/facebook/flipper/issues/2181</a>) (<a href="1c331f22c7">1c331f2</a>)</li>
<li>prevent infinite loop with empty locale (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2179">https://github.com/facebook/flipper/issues/2179</a>) (<a href="b672e709e4">b672e70</a>)</li>
<li>veriadic arguments override array provided in config (the same as multiple dash arguments). (<a href="4dac5b8c2f">4dac5b8</a>)</li>
</ul>
<h2><a href="https://github.com/yargs/yargs/compare/v17.4.1...v17.5.0">17.5.0</a> (2022-05-11)</h2>
<h3>Features</h3>
<ul>
<li>add browser.d.ts and check for existence of Error.captureStackTrace() (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2144">https://github.com/facebook/flipper/issues/2144</a>) (<a href="6192990509">6192990</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>completion:</strong> support for default flags (<a href="db35423270">db35423</a>)</li>
<li>import yargs/yargs in esm projects (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2151">https://github.com/facebook/flipper/issues/2151</a>) (<a href="95aed1c175">95aed1c</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="6cd8e2d6a4"><code>6cd8e2d</code></a> chore(main): release 17.6.0 (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2213">https://github.com/facebook/flipper/issues/2213</a>)</li>
<li><a href="38e8df10f0"><code>38e8df1</code></a> fix(deps): cliui with forced strip-ansi update (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2241">https://github.com/facebook/flipper/issues/2241</a>)</li>
<li><a href="394f5f86d1"><code>394f5f8</code></a> fix(typescript): address warning with objectKeys</li>
<li><a href="561fc7a787"><code>561fc7a</code></a> fix(deno): use 'globalThis' instead of 'window' (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2186">https://github.com/facebook/flipper/issues/2186</a>) (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2215">https://github.com/facebook/flipper/issues/2215</a>)</li>
<li><a href="5895cf1ba1"><code>5895cf1</code></a> feat(lang): Czech locale (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2220">https://github.com/facebook/flipper/issues/2220</a>)</li>
<li><a href="f91d9b334a"><code>f91d9b3</code></a> fix: dont clobber description for multiple option calls (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2171">https://github.com/facebook/flipper/issues/2171</a>)</li>
<li><a href="b680ace299"><code>b680ace</code></a> feat(usage): add YARGS_DISABLE_WRAP env variable to disable wrap (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2210">https://github.com/facebook/flipper/issues/2210</a>)</li>
<li><a href="659dbbb4a4"><code>659dbbb</code></a> docs: update links to main branch</li>
<li><a href="02515116f8"><code>0251511</code></a> chore(main): release 17.5.1 (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2187">https://github.com/facebook/flipper/issues/2187</a>)</li>
<li><a href="22e9af28bb"><code>22e9af2</code></a> fix(completion): correct zsh installation instructions</li>
<li>Additional commits viewable in <a href="https://github.com/yargs/yargs/compare/v17.4.1...v17.6.0">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=yargs&package-manager=npm_and_yarn&previous-version=17.4.1&new-version=17.6.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

Pull Request resolved: https://github.com/facebook/flipper/pull/4165

Reviewed By: aigoncharov

Differential Revision: D40022361

Pulled By: aigoncharov

fbshipit-source-id: 5408257376334746865b27b27461ec29dea8e78a
2022-10-05 02:27:07 -07:00
Andrey Goncharov
dd7ba2d6fc Fix fb-stubs replacement for plugin bundling
Reviewed By: nikoant

Differential Revision: D39765543

fbshipit-source-id: 14cbf8a9bdf35031e636bbbde3dbc955faedb66b
2022-09-23 05:50:28 -07:00
Andrey Goncharov
fd811db12b Rebuild all plugins if a shared lib changed
Summary: Some plugins import from shared directories. These directories are not plugins themselves, therefore the current plugin root searching mechanism does nto work for them. To support plugin reloading for this scenario, we start re-building all plugins if we fail to find a plugin root.

Reviewed By: lblasa

Differential Revision: D39693820

fbshipit-source-id: 33dd7de4121bd5665a39b0ea96adce4603dc7df0
2022-09-22 04:17:24 -07:00
Andrey Goncharov
8dc5f4d3ea Remove stale build options
Summary: Now that we build all plugins at all times and it is super-fast, these options are redundant

Reviewed By: lblasa

Differential Revision: D39542723

fbshipit-source-id: 1b30ba384267ec4fd0c35b4dc14f0223ffe414c9
2022-09-15 10:02:19 -07:00
Andrey Goncharov
c69d102ca1 Track plugin changes and notify frontend
Summary: Watch source plugin folders and notify frontend that any of them changed. In subsequent diffs, we will start reloading plugins that changed.

Reviewed By: lblasa

Differential Revision: D39539443

fbshipit-source-id: 726916c0bce336a2c0179558526bcb1b74e35b93
2022-09-15 10:02:19 -07:00
Andrey Goncharov
ed93dfe978 Refine prod and dev deps
Summary: Move flipper local deps to prod deps, so yarn installs them later when we build a bundle

Reviewed By: lblasa

Differential Revision: D39475545

fbshipit-source-id: 5b61d15b45ee315c3b35d8e6836c114b90503b1a
2022-09-15 10:02:19 -07:00
Andrey Goncharov
a67a4e5d0f Remove babel transforms for flipper-server
Summary: Flipper server itself requires no babel transforms. We applied extra transforms only for the bundled plugins. However, we pack and ship all plugins in the /static folder. They are always available on the FS. Therefore we could stop bundling any plugins into flipper-server's source code.

Reviewed By: lblasa

Differential Revision: D38910251

fbshipit-source-id: b3e9fe5ae2ab69ce5579b01b6793ebf7e88baf66
2022-09-15 10:02:19 -07:00
Andrey Goncharov
97b8b8a1c4 Split flipper-plugin package
Summary:
flipper-server-companion depends on flipper-plugin. flipper-plugin includes dependencies that run only in a browser. Splitting flipper-plugin into core and browser packages helps to avoid including browser-only dependencies into flipper-server bundle.
As a result, bundle size could be cut in half. Subsequently, RSS usage drops as there is twice as less code to process for V8.

Note: it currently breaks external flipper-data-source package. It will be restored in subsequent diffs

Reviewed By: lblasa

Differential Revision: D38658285

fbshipit-source-id: 751b11fa9f3a2d938ce166687b8310ba8b059dee
2022-09-15 10:02:19 -07:00
Lorenzo Blasa
583fdd9648 Explicitly close ws in cases of a process exit
Summary:
^

There may be cases whereas the process exits but leaks the socket descriptors.

There's already a hook to close flipper-server.

Reviewed By: passy

Differential Revision: D37550940

fbshipit-source-id: 35004969834bb92bb7cf0f56bda8d7b43c11d6bf
2022-07-01 03:45:44 -07:00
Andrey Goncharov
1052384154 Add log rotating to flipper-server
Summary:
CHANGELOG: Rotate flipper-server logs

Otherwise, they re going to eat up all space eventually in a one monstrous file

Reviewed By: passy

Differential Revision: D37516868

fbshipit-source-id: 478a61c56ec007e4a3d695f7e6df2a61cb33c33a
2022-06-30 07:01:40 -07:00
Lorenzo Blasa
646b9d5a5d UDS/TCP options
Summary:
Provide an option to enable/disable TCP connections on flipper-server.

The only change at this stage is that Flipper Desktop will use UDS to connect to flipper-server.

Reviewed By: passy

Differential Revision: D37519656

fbshipit-source-id: 3d02084666fde532ec76134edf8cf6a231060a48
2022-06-29 15:01:05 -07:00
Andrey Goncharov
13535e9753 Map / route to correct HTML file
Summary: CHANGELOG: Open Flipper Server at /

Reviewed By: lawrencelomax

Differential Revision: D37517406

fbshipit-source-id: 71043c3df75d9436020da477c937795671fa15a9
2022-06-29 07:46:03 -07:00
Andrey Goncharov
dcbc7c40bb Stream server logs to browser
Summary: Makes Flipper Logs tab functional for Flipper Browser

Reviewed By: lblasa

Differential Revision: D37459924

fbshipit-source-id: 4ebf3d47fbbf90bb367e01986b12dec782b03c34
2022-06-28 06:27:43 -07:00
Lorenzo Blasa
ce9feae44f Attach handlers for process errors
Summary:
^
This is an effort to capture and log these errors as to gain visibility when failures occur.

Reviewed By: passy

Differential Revision: D37412861

fbshipit-source-id: 09687a31797aac4c377aa98944ab0701bdf45466
2022-06-24 07:56:42 -07:00
Lorenzo Blasa
335dec1a08 Adds some settings to check flipper-server state
Summary:
There's one setting: to enable or disable flipper-server.

However, I've added some current running state to it. If there's a better way of doing this, please do let me know.

Reviewed By: aigoncharov

Differential Revision: D37276670

fbshipit-source-id: f6c941cf0cfe55c267b9bcb9f799934fba1e28ef
2022-06-22 05:26:11 -07:00
Lorenzo Blasa
8c67b049ab Attach connection handler earlier
Summary:
This change attaches our event handlers as soon as the ws is created.

As a consequence, we need to wait until the server has created any necessary instances required to process incoming requests.

To achieve this, I created a type called `Lazy`.

This type wraps around a value and a promise to that value. Callers can check if the value is set. If not, callers can wait for it.

Ultimately, the value can be set outside of the promise itself.

Reviewed By: passy

Differential Revision: D37284939

fbshipit-source-id: 17dec548d7155a3d65440c9584cec07cbb826c37
2022-06-21 12:48:43 -07:00
Lorenzo Blasa
9cc8e4076f flipper-server refactor
Summary:
This changes moves most of the functionality found in flipper-server to flipper-server-core.

flipper-server will mostly be a package that wraps around flipper-server-core. Staying in flipper-server:
- Command line args
- Orchestration to start the necessary servers

Reviewed By: aigoncharov

Differential Revision: D36807087

fbshipit-source-id: f29002c7cc5d08b8c5184fdaaa02ba22562a9f45
2022-06-07 02:42:16 -07:00
Lorenzo Blasa
ee64216725 Extract logger and write to file
Summary:
This change extracts logging logic out from startFlipperServer.

Logs will also be written to disk.

Reviewed By: passy

Differential Revision: D36473768

fbshipit-source-id: b1df9df79b4aced0d3ba2e8c243aa8d44cf83703
2022-06-01 02:37:03 -07:00
Lorenzo Blasa
2fe7e73175 Refactor checks to see if socket is in use
Summary:
These are utility methods that are not specific to startServer.

They will be reused by other components needing to check if something is listening to a port.

Make socket path is also extracted.

Reviewed By: passy

Differential Revision: D36473641

fbshipit-source-id: 73ed67912052896696b59670cb757d22761eeaa1
2022-05-31 03:31:05 -07:00
Andrey Goncharov
4eca8d1088 Add isHeadlessBuild to EnvironmentInfo
Summary: Allows to attribute errors to flipper server or flipper electron

Reviewed By: passy

Differential Revision: D36698504

fbshipit-source-id: 6d07216fd05aa48b7c8cca5b53145916b64526eb
2022-05-27 02:37:53 -07:00
dependabot[bot]
8ce64bbec4 Bump yargs from 17.2.1 to 17.4.1 in /desktop (#3714)
Summary:
Bumps [yargs](https://github.com/yargs/yargs) from 17.2.1 to 17.4.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/yargs/yargs/blob/main/CHANGELOG.md">yargs's changelog</a>.</em></p>
<blockquote>
<h3><a href="https://github.com/yargs/yargs/compare/v17.4.0...v17.4.1">17.4.1</a> (2022-04-09)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>coerce pollutes argv (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2161">https://github.com/facebook/flipper/issues/2161</a>) (<a href="2d1136d303">2d1136d</a>)</li>
<li><strong>completion:</strong> don't show positional args choices with option choices (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2148">https://github.com/facebook/flipper/issues/2148</a>) (<a href="b58b5bc2cd">b58b5bc</a>)</li>
<li>hide hidden options from completion (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2143">https://github.com/facebook/flipper/issues/2143</a>) (<a href="e086dfad7f">e086dfa</a>), closes <a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2142">https://github.com/facebook/flipper/issues/2142</a></li>
<li>show message when showHelpOnFail is chained globally (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2154">https://github.com/facebook/flipper/issues/2154</a>) (<a href="ad9fcacb00">ad9fcac</a>)</li>
</ul>
<h2><a href="https://github.com/yargs/yargs/compare/v17.3.1...v17.4.0">17.4.0</a> (2022-03-19)</h2>
<h3>Features</h3>
<ul>
<li><strong>completion:</strong> choices will now work for all possible aliases of an option and not just the default long option (<a href="30edd50671">30edd50</a>)</li>
<li><strong>completion:</strong> positional arguments completion (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2090">https://github.com/facebook/flipper/issues/2090</a>) (<a href="00e4ebbe3a">00e4ebb</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li><strong>completion:</strong> changed the check for option arguments to match options that begin with '-', instead of '--', to include short options (<a href="30edd50671">30edd50</a>)</li>
<li><strong>completion:</strong> fix for completions that contain non-leading hyphens (<a href="30edd50671">30edd50</a>)</li>
<li>failed command usage string is missing arg descriptions and optional args (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2105">https://github.com/facebook/flipper/issues/2105</a>) (<a href="d6e342d8ef">d6e342d</a>)</li>
<li>wrap unknown args in quotes (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2092">https://github.com/facebook/flipper/issues/2092</a>) (<a href="6a2977867b">6a29778</a>)</li>
</ul>
<h3><a href="https://github.com/yargs/yargs/compare/v17.3.0...v17.3.1">17.3.1</a> (2021-12-23)</h3>
<h3>Bug Fixes</h3>
<ul>
<li><strong>translations:</strong> correct Korean translation (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2095">https://github.com/facebook/flipper/issues/2095</a>) (<a href="c7c2b9eb34">c7c2b9e</a>)</li>
</ul>
<h2><a href="https://github.com/yargs/yargs/compare/v17.2.1...v17.3.0">17.3.0</a> (2021-11-30)</h2>
<h3>Features</h3>
<ul>
<li>fallback to default bash completion (<a href="74c0ba5cfc">74c0ba5</a>)</li>
</ul>
<h3>Bug Fixes</h3>
<ul>
<li>avoid legacy accessors (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2013">https://github.com/facebook/flipper/issues/2013</a>) (<a href="adb0d11e02">adb0d11</a>)</li>
<li><strong>deps:</strong> update dependency yargs-parser to v21 (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2063">https://github.com/facebook/flipper/issues/2063</a>) (<a href="76c19518d7">76c1951</a>)</li>
<li>don't fail if &quot;fileURLToPath(import.meta.url)&quot; throws (<a href="3a44796c84">3a44796</a>)</li>
<li>re-add options to check callback (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2079">https://github.com/facebook/flipper/issues/2079</a>) (<a href="e75319d991">e75319d</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="be525157f3"><code>be52515</code></a> chore(main): release 17.4.1 (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2147">https://github.com/facebook/flipper/issues/2147</a>)</li>
<li><a href="2d1136d303"><code>2d1136d</code></a> fix: coerce pollutes argv (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2161">https://github.com/facebook/flipper/issues/2161</a>)</li>
<li><a href="ad9fcacb00"><code>ad9fcac</code></a> fix: show message when showHelpOnFail is chained globally (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2154">https://github.com/facebook/flipper/issues/2154</a>)</li>
<li><a href="b58b5bc2cd"><code>b58b5bc</code></a> fix(completion): don't show positional args choices with option choices (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2148">https://github.com/facebook/flipper/issues/2148</a>)</li>
<li><a href="0bb49c3d86"><code>0bb49c3</code></a> samples: event.keyCode is deprecated, use new <code>.code</code> API (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2125">https://github.com/facebook/flipper/issues/2125</a>)</li>
<li><a href="e086dfad7f"><code>e086dfa</code></a> fix: hide hidden options from completion (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2143">https://github.com/facebook/flipper/issues/2143</a>)</li>
<li><a href="bcd59f1715"><code>bcd59f1</code></a> chore(main): release 17.4.0 (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2108">https://github.com/facebook/flipper/issues/2108</a>)</li>
<li><a href="3cbc38ccbf"><code>3cbc38c</code></a> docs: fix hyphenation (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2141">https://github.com/facebook/flipper/issues/2141</a>)</li>
<li><a href="00e4ebbe3a"><code>00e4ebb</code></a> feat(completion): positional arguments completion (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2090">https://github.com/facebook/flipper/issues/2090</a>)</li>
<li><a href="c0661643fc"><code>c066164</code></a> docs: an example using inquirer prompting (<a href="https://github-redirect.dependabot.com/yargs/yargs/issues/2114">https://github.com/facebook/flipper/issues/2114</a>)</li>
<li>Additional commits viewable in <a href="https://github.com/yargs/yargs/compare/v17.2.1...v17.4.1">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=yargs&package-manager=npm_and_yarn&previous-version=17.2.1&new-version=17.4.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

 ---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `dependabot rebase` will rebase this PR
- `dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `dependabot merge` will merge this PR after your CI passes on it
- `dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `dependabot cancel merge` will cancel a previously requested merge and block automerging
- `dependabot reopen` will reopen this PR if it is closed
- `dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

Pull Request resolved: https://github.com/facebook/flipper/pull/3714

Reviewed By: timur-valiev

Differential Revision: D36371211

Pulled By: mweststrate

fbshipit-source-id: 8a67df778d5d4cb3c314eaf1463d9437fe4261bb
2022-05-23 07:29:26 -07:00
Andrey Goncharov
17b2e9d375 Connect companion events to Flipper Server
Reviewed By: passy

Differential Revision: D36517762

fbshipit-source-id: c6318b1b0705d1e6cbcf73973e2d6c9196914491
2022-05-23 03:38:23 -07:00
Lorenzo Blasa
aca1aca29c Accept connections from localhost coming from port 3000
Summary:
^

flipper-server verifies the origin of incoming connections as a way of preventing any host from connecting to flipper.

That's good.

This change expand the list of allowed origins to include localhost:3000 which is the default origin for Electron apps.

Error without this change:
```
Refused socket connection from cross domain request, origin: http://localhost:3000, host: localhost:52342. Expected origins: http://localhost:52342 or http://[::1]:52342 or http://::1:52342. Expected hosts: localhost:52342 or [::1]:52342 or ::1:52342
```

Reviewed By: passy

Differential Revision: D36440363

fbshipit-source-id: 883cadb49f245bca5d0a53a4f58c08cf45dd0189
2022-05-17 04:20:30 -07:00
Andrey Goncharov
d1ed676a48 Remove dynamic dependencies from flipper-server
Summary:
Currently, Flipper Server has a few productions dependencies (mac-ca, node-fetch) that are not bundled with the Flipper Server. It makes it harder to distribute Flipper Server, as now all potential consumers need not only to download the bundle, but also install these additional dependencies.
This diff makes it possible to bundle `mac-ca` and `node-fetch` with Flipper Server. As a result, Flipper Server becomes dependency-free in production.

Reviewed By: lblasa

Differential Revision: D36345213

fbshipit-source-id: 2cd6ba1b3301b45dc2295891964ba020fd107586
2022-05-13 03:19:47 -07:00
Lorenzo Blasa
242d26e199 Rename and documentation for start dev server (attach)
Summary:
Same as with the previous diff.

The function doesn't really start a server. Instead it attaches the routing of messages from the existing server into FlipperServer.

Reviewed By: passy

Differential Revision: D36310703

fbshipit-source-id: 7ac9a742fb36c3806597382c9aadcf96f4770484
2022-05-11 06:56:20 -07:00
Lorenzo Blasa
582966d139 Attach instead of start dev server and documentation updates
Summary:
^

Instead of 'start' use 'attach' as it seems closer to what the function actually does.

Reviewed By: passy

Differential Revision: D36310846

fbshipit-source-id: db90efc6ec3207b1a5a38139a3ba01d2f7d2aebd
2022-05-11 06:56:20 -07:00
Lorenzo Blasa
453ec4bd83 Rename base server to just server
Summary:
^

BaseServer doesn't really have any meaning. So, change it to just Server as it really creates the Express app and HTTP server attached to it.

Reviewed By: passy

Differential Revision: D36310822

fbshipit-source-id: eee5a2a395ca726679c1c4756ed58d4bc6be3cb8
2022-05-11 06:56:20 -07:00
Lorenzo Blasa
2493de75ab Remove unused import
Summary: ^

Reviewed By: passy

Differential Revision: D36310809

fbshipit-source-id: c9faa2b685fc57c8a022cf497a843f3c137716d7
2022-05-11 06:56:20 -07:00
Lorenzo Blasa
1818b87166 Rename startWebServerDev to startDevServer
Summary:
Rename 'startWebServerDev' to just 'startDevServer'.

It isn't really starting a web server though, more like installing routings and middleware to the existing created server.

Reviewed By: passy

Differential Revision: D36310765

fbshipit-source-id: 0af772012525fd7ad19e2aa6fa73cb3e7dcf2bef
2022-05-11 06:56:20 -07:00
Lorenzo Blasa
ec667bc26d Log listening port
Summary: Slight changes to the URL and port logging.

Reviewed By: passy

Differential Revision: D36310796

fbshipit-source-id: 553b9ce932792c471f8e0e2c1a0c7d79897ad59d
2022-05-11 06:56:20 -07:00
Pascal Hartig
14b83ad050 Don't tear down server on disconnect
Summary: These safeguards were added based on a discussion in D35088208 (56e94394ca) but turned out to be counter-productive. Every time a client disconnects now, we're tearing down the socket and the server, allowing for no future connections.

Reviewed By: lblasa

Differential Revision: D36252605

fbshipit-source-id: c3b6f85dea4054505a47d24a72a4aac403371c0f
2022-05-10 08:45:57 -07:00
Andrey Goncharov
b4498f070f Add flipper-server-companion to flipper-server
Summary: Start flipper-server-companion whenever a client connects to flipper-server and sets `server_companion` query parameter in a connection URL to true

Reviewed By: mweststrate

Differential Revision: D36098169

fbshipit-source-id: eb953e7d680b30aef1340f059264112387264c05
2022-05-10 05:13:24 -07:00
Andrey Goncharov
98dde53cda Add companion logging
Summary: Add top-level error logging to flipper-server. Use the top-level logging mechanism in flipper-companion.

Reviewed By: lblasa

Differential Revision: D36252218

fbshipit-source-id: 58d22b3b9bd51e597b5250478640f54d10277861
2022-05-10 05:13:24 -07:00
Pascal Hartig
d05d3f9336 Upgrade more /desktop deps
Summary: Taking care of the remaining dependabot tasks In my queue.

Reviewed By: mweststrate

Differential Revision: D36131782

fbshipit-source-id: f8a5ce18bfab7c5d50a88d64f9516d67bba4bd6d
2022-05-05 08:07:44 -07:00
Pascal Hartig
ef19d06239 Upgrade metro
Summary: Bunch of dependabot PRs showed that the signal is green, but still wanted to have all in one diff.

Reviewed By: aigoncharov

Differential Revision: D36102480

fbshipit-source-id: 88d472fdc2a910a7441a9e8164fe8af0f2d90f7b
2022-05-04 04:03:19 -07:00
Pascal Hartig
cc3aca0e8b Upgrade @types/node to one version everywhere
Summary: Caused some inconsistencies when running `tsc`. This brings them back in line.

Reviewed By: aigoncharov

Differential Revision: D36101548

fbshipit-source-id: b8f757c59f879911c9b0920fe11396246ffa37e2
2022-05-04 04:03:19 -07:00
Pascal Hartig
3032736294 Fix type errors for flipper-server and flipper-ui-browser
Summary:
Before:

```
flipper-server/src/startBaseServer.tsx(222,30): error TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'.
  Type 'undefined' is not assignable to type 'string'.
flipper-ui-browser/src/flipperServerConnection.tsx(25,9): error TS2322: Type 'Timeout' is not assignable to type 'number'.
```

Reviewed By: nikoant

Differential Revision: D36100188

fbshipit-source-id: 1913a43109a0e068394a188d362f6a9e473e7904
2022-05-03 09:55:04 -07:00
Pascal Hartig
fd23a9d626 Clean up socket on exit
Summary: Be more aggressive in cleaning up after ourselves. Using a tiny library by Sindre that handles standard exit events, SIGTERM and SIGINT.

Reviewed By: aigoncharov

Differential Revision: D35281772

fbshipit-source-id: a789f90f172b3aa3e187739cf2b7fefa75405891
2022-03-31 08:57:13 -07:00
Pascal Hartig
cfcbc75de9 Take unix domain socket max length into account
Summary: lawrencelomax helpfully pointed out that there's a legacy limit for the path length of unix domain sockets. Checking here and falling back to `/tmp` in case we're going over. This could have caused some gnarly support issues, so I'm glad we caught this before it went live.

Reviewed By: aigoncharov

Differential Revision: D35257794

fbshipit-source-id: 68a7b62d6d6863efa4b3ce84d7735b1c1a45a174
2022-03-31 06:29:21 -07:00