-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[menu-bar][cli] Refactor session storage to no longer use mmkv on CLI (…
…#179) * [cli] Add set-session command * Remove mmkv-node-bindings dependency * [menu-bar] Use set-session command
- Loading branch information
1 parent
2842cdb
commit cd682f8
Showing
12 changed files
with
63 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"pkg": { | ||
"assets": ["../../node_modules/mmkv-node-bindings/**/*.node"], | ||
"targets": ["node18-macos-arm64", "node18-macos-x64"] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { setSessionSecret } from '../storage'; | ||
|
||
export async function setSessionAsync(sessionSecret: string) { | ||
await setSessionSecret(sessionSecret); | ||
} |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { StorageUtils } from 'common-types'; | ||
import os from 'os'; | ||
import JsonFile from '@expo/json-file'; | ||
|
||
export function getSessionSecret(): string | undefined { | ||
const userSettings = userSettingsJsonFile().read(); | ||
return userSettings.sessionSecret; | ||
} | ||
|
||
export async function setSessionSecret(sessionSecret: string): Promise<void> { | ||
await userSettingsJsonFile().setAsync('sessionSecret', sessionSecret); | ||
} | ||
|
||
type UserData = { | ||
sessionSecret?: string; | ||
}; | ||
function userSettingsJsonFile(): JsonFile<UserData> { | ||
return new JsonFile<UserData>(StorageUtils.userSettingsFile(os.homedir()), { | ||
jsonParseErrorDefault: {}, | ||
cantReadFileDefault: {}, | ||
}); | ||
} |
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,5 @@ | ||
import MenuBarModule from '../modules/MenuBarModule'; | ||
|
||
export const setSessionAsync = async (sessionSecret: string) => { | ||
await MenuBarModule.runCli('set-session', [sessionSecret], console.log); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
export const MMKVInstanceId = 'mmkv.default'; | ||
const AUTH_FILE_NAME = 'auth.json'; | ||
|
||
export function getExpoOrbitDirectory(homedir: string) { | ||
return `${homedir}/.expo/orbit`; | ||
} | ||
|
||
export function userSettingsFile(homedir: string): string { | ||
return `${getExpoOrbitDirectory(homedir)}/${AUTH_FILE_NAME}`; | ||
} |
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