Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
### 🎉 New features

- Add support for launching Expo updates. ([#134](https://github.com/expo/orbit/pull/134), [#137](https://github.com/expo/orbit/pull/137), [#138](https://github.com/expo/orbit/pull/138), [#144](https://github.com/expo/orbit/pull/144), [#148](https://github.com/expo/orbit/pull/148) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Add experimental support for Windows and Linux. ([#152](https://github.com/expo/orbit/pull/152), [#157](https://github.com/expo/orbit/pull/157), [#158](https://github.com/expo/orbit/pull/158), [#160](https://github.com/expo/orbit/pull/160), [#161](https://github.com/expo/orbit/pull/161), [#165](https://github.com/expo/orbit/pull/165), [#170](https://github.com/expo/orbit/pull/170), [#171](https://github.com/expo/orbit/pull/171), [#172](https://github.com/expo/orbit/pull/172), [#173](https://github.com/expo/orbit/pull/173), [#174](https://github.com/expo/orbit/pull/174), [#175](https://github.com/expo/orbit/pull/175), [#177](https://github.com/expo/orbit/pull/177), [#178](https://github.com/expo/orbit/pull/178) by [@gabrieldonadel](https://github.com/gabrieldonadel))
- Add experimental support for Windows and Linux. ([#152](https://github.com/expo/orbit/pull/152), [#157](https://github.com/expo/orbit/pull/157), [#158](https://github.com/expo/orbit/pull/158), [#160](https://github.com/expo/orbit/pull/160), [#161](https://github.com/expo/orbit/pull/161), [#165](https://github.com/expo/orbit/pull/165), [#170](https://github.com/expo/orbit/pull/170), [#171](https://github.com/expo/orbit/pull/171), [#172](https://github.com/expo/orbit/pull/172), [#173](https://github.com/expo/orbit/pull/173), [#174](https://github.com/expo/orbit/pull/174), [#175](https://github.com/expo/orbit/pull/175), [#177](https://github.com/expo/orbit/pull/177), [#178](https://github.com/expo/orbit/pull/178), [#180](https://github.com/expo/orbit/pull/180) by [@gabrieldonadel](https://github.com/gabrieldonadel))

### 🐛 Bug fixes

Expand Down
2 changes: 2 additions & 0 deletions apps/menu-bar/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"typescript": "~4.9.4"
},
"dependencies": {
"@expo/json-file": "^8.2.37",
"common-types": "1.0.0",
"electron-squirrel-startup": "^1.0.0",
"express": "^4.18.2",
"react-native-electron-modules": "1.0.0"
Expand Down
8 changes: 8 additions & 0 deletions apps/menu-bar/electron/vite.main.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ export default defineConfig({
browserField: false,
mainFields: ['module', 'jsnext:main', 'jsnext'],
},
optimizeDeps: {
include: ['common-types'],
},
build: {
commonjsOptions: {
include: [/common-types/, /node_modules/],
},
},
Comment on lines +10 to +17
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://vitejs.dev/guide/dep-pre-bundling.html#monorepos-and-linked-dependencies

In a monorepo setup, a dependency may be a linked package from the same repo. Vite automatically detects dependencies that are not resolved from node_modules and treats the linked dep as source code. It will not attempt to bundle the linked dep, and will analyze the linked dep's dependency list instead.
However, this requires the linked dep to be exported as ESM. If not, you can add the dependency to optimizeDeps.include and build.commonjsOptions.include in your config.

});
4 changes: 4 additions & 0 deletions apps/menu-bar/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ body {
background-color: var(--orbit-window-background);
}

input {
color: var(--text-color);
}

:not(input):not(textarea),
:not(input):not(textarea)::after,
:not(input):not(textarea)::before {
Expand Down
18 changes: 17 additions & 1 deletion apps/menu-bar/modules/menu-bar/electron/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,25 @@
import JsonFile from '@expo/json-file';
import { StorageUtils } from 'common-types';
import { app, dialog } from 'electron';
import os from 'os';
import path from 'path';

import spawnCliAsync from './spawnCliAsync';
import { NativeMenuBarModule } from '../src/types';

function getUserSettingsJsonFile() {
return new JsonFile<StorageUtils.UserSettingsData>(StorageUtils.userSettingsFile(os.homedir()), {
jsonParseErrorDefault: {},
cantReadFileDefault: {},
});
}

const runCli = async (command: string, args: string[], listenerId: number) => {
const cliPath = path.join(__dirname, '../../../../cli/build/index.js');

const commandOutput = await spawnCliAsync(cliPath, command, args, listenerId);
const userSettingsJsonFile = getUserSettingsJsonFile();
const { envVars } = await userSettingsJsonFile.readAsync();
const commandOutput = await spawnCliAsync(cliPath, command, args, listenerId, envVars);
return commandOutput;
};

Expand All @@ -33,6 +45,10 @@ const MenuBarModule: Partial<NativeMenuBarModule> & { name: string } = {

return response;
},
setEnvVars(envVars) {
const userSettingsJsonFile = getUserSettingsJsonFile();
userSettingsJsonFile.setAsync('envVars', envVars);
},
};

export default MenuBarModule;
10 changes: 8 additions & 2 deletions apps/menu-bar/modules/menu-bar/electron/spawnCliAsync.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { fork, ChildProcess } from 'child_process';

function spawnCliAsync(cliPath: string, command: string, args: string[] = [], listenerId: number) {
function spawnCliAsync(
cliPath: string,
command: string,
args: string[] = [],
listenerId: number,
envVars: Record<string, string> = {}
) {
let child: ChildProcess;
let hasReachedReturnOutput = false;
let hasReachedError = false;
let returnOutput = '';

const promise = new Promise<string>((resolve, reject) => {
child = fork(cliPath, [command, ...args], {
env: { ...process.env, EXPO_MENU_BAR: true } as any,
env: { ...process.env, EXPO_MENU_BAR: true, ...envVars } as any,
stdio: 'pipe',
});

Expand Down
5 changes: 5 additions & 0 deletions packages/common-types/src/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@ export function getExpoOrbitDirectory(homedir: string) {
export function userSettingsFile(homedir: string): string {
return `${getExpoOrbitDirectory(homedir)}/${AUTH_FILE_NAME}`;
}

export type UserSettingsData = {
sessionSecret?: string;
envVars?: Record<string, string>;
};