-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automatic port detection, assignment, ci and more (#324)
- Loading branch information
1 parent
339f5f4
commit 1711b5e
Showing
10 changed files
with
2,732 additions
and
1,753 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Desktop App | ||
|
||
on: | ||
push: | ||
branches: | ||
- v1.0 | ||
pull_request: | ||
branches: | ||
- v1.0 | ||
|
||
jobs: | ||
build: | ||
runs-on: macos-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 'lts/*' | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
working-directory: ui/desktop | ||
|
||
- name: Package application | ||
run: npm run package | ||
working-directory: ui/desktop | ||
|
||
- name: Run E2E tests | ||
run: npm run test-e2e | ||
working-directory: ui/desktop |
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
Large diffs are not rendered by default.
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
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,15 +1,7 @@ | ||
// Default host for the Goose API | ||
const DEFAULT_HOST = 'http://127.0.0.1:3000'; | ||
|
||
// Get the host from environment variable or use default | ||
export const GOOSE_API_HOST = import.meta.env.VITE_GOOSE_HOST || DEFAULT_HOST; | ||
|
||
// Control whether to start the embedded server (defaults to yes if not set) | ||
export const START_EMBEDDED_SERVER = (import.meta.env.VITE_START_EMBEDDED_SERVER || 'yes').toLowerCase() === 'yes'; | ||
|
||
// Helper to construct API endpoints | ||
export const getApiUrl = (endpoint: string): string => { | ||
const baseUrl = GOOSE_API_HOST.endsWith('/') ? GOOSE_API_HOST.slice(0, -1) : GOOSE_API_HOST; | ||
export const getApiUrl = (endpoint: string): string => { | ||
const baseUrl = window.appConfig.get('GOOSE_API_HOST') + ':' + window.appConfig.get('GOOSE_SERVER__PORT'); | ||
const cleanEndpoint = endpoint.startsWith('/') ? endpoint : `/${endpoint}`; | ||
return `${baseUrl}${cleanEndpoint}`; | ||
}; |
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,7 +1,15 @@ | ||
const { contextBridge, ipcRenderer } = require('electron') | ||
|
||
const config = JSON.parse(process.argv.find((arg) => arg.startsWith('{')) || '{}'); | ||
|
||
contextBridge.exposeInMainWorld('appConfig', { | ||
get: (key) => config[key], | ||
getAll: () => config, | ||
}); | ||
|
||
contextBridge.exposeInMainWorld('electron', { | ||
hideWindow: () => ipcRenderer.send('hide-window'), | ||
createChatWindow: (query) => ipcRenderer.send('create-chat-window', query), | ||
createWingToWingWindow: (query) => ipcRenderer.send('create-wing-to-wing-window', query), | ||
}) | ||
logInfo: (txt) => ipcRenderer.send('logInfo', txt), | ||
}) |
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,34 @@ | ||
import { createServer } from 'net'; | ||
import log from './logger'; | ||
|
||
export const findAvailablePort = (): Promise<number> => { | ||
return new Promise((resolve, reject) => { | ||
const server = createServer(); | ||
|
||
|
||
server.listen(0, '127.0.0.1', () => { | ||
const { port } = server.address() as { port: number }; | ||
server.close(() => { | ||
log.info(`Found available port: ${port}`); | ||
resolve(port); | ||
}); | ||
}); | ||
}); | ||
}; | ||
|
||
// Cache the port once found to ensure consistency | ||
let cachedPort: number | null = null; | ||
|
||
export const getPort = async (): Promise<number> => { | ||
if (cachedPort !== null) { | ||
return cachedPort; | ||
} | ||
|
||
try { | ||
cachedPort = await findAvailablePort(); | ||
return cachedPort; | ||
} catch (error) { | ||
log.error('Error finding available port:', error); | ||
throw error; | ||
} | ||
}; |