This repository has been archived by the owner on Nov 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 959
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reviewed By: LukeDefeo Differential Revision: D50411182 fbshipit-source-id: 46c089c69aefb58f85a861c7898ee355f094e03c
- Loading branch information
1 parent
a8be443
commit aea77cc
Showing
7 changed files
with
85 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
desktop/flipper-server-core/src/utils/findInstallation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and 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 path from 'path'; | ||
import fs from 'fs-extra'; | ||
import os from 'os'; | ||
import GK from '../fb-stubs/GK'; | ||
|
||
const pwaRoot = path.join( | ||
os.homedir(), | ||
'Applications', | ||
'Chrome Apps.localized', | ||
); | ||
const appFolder = path.resolve(pwaRoot, '.flipper'); | ||
const defaultAppPath = path.join(pwaRoot, 'Flipper.app'); | ||
const movedAppPath = path.join(appFolder, 'Flipper.app'); | ||
|
||
export async function movePWA(): Promise<void> { | ||
if (os.platform() !== 'darwin') { | ||
return; | ||
} | ||
|
||
if (!GK.get('flipper_move_pwa')) { | ||
return; | ||
} | ||
|
||
// Move PWA into its own folder | ||
// Later we will make the folder hidden so Spotlight stops indexing it | ||
// Sadly, Spotlight can stop indexing only hidden folder, not hidden files | ||
// Therefore, we have to create this parent folder in the first place. | ||
if (!(await fs.pathExists(appFolder))) { | ||
await fs.mkdir(appFolder); | ||
} | ||
await fs.move(defaultAppPath, movedAppPath); | ||
} | ||
|
||
export async function findInstallation(): Promise<string | undefined> { | ||
if (os.platform() !== 'darwin') { | ||
return; | ||
} | ||
|
||
try { | ||
if (GK.get('flipper_move_pwa')) { | ||
if (await fs.pathExists(defaultAppPath)) { | ||
await movePWA(); | ||
} | ||
} | ||
} catch (e) { | ||
console.error('Failed to move PWA', e); | ||
} finally { | ||
if (GK.get('flipper_move_pwa')) { | ||
const movedAppPlistPath = path.join( | ||
movedAppPath, | ||
'Contents', | ||
'Info.plist', | ||
); | ||
if (await fs.pathExists(movedAppPlistPath)) { | ||
return movedAppPath; | ||
} | ||
// We should get here only if moving PWA failed | ||
} | ||
const dafaultAppPlistPath = path.join( | ||
defaultAppPath, | ||
'Contents', | ||
'Info.plist', | ||
); | ||
if (await fs.pathExists(dafaultAppPlistPath)) { | ||
return defaultAppPath; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters