From fea6a7e5cbfe8fab4535f40cec20d3d5e92686fd Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 24 Feb 2025 11:14:54 +0100 Subject: [PATCH] Implements launching codex app from installer --- package.json | 3 ++- src/main.js | 33 +++++++++++++++++++-------------- src/services/codexapp.js | 17 +++++++++++++++++ 3 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 src/services/codexapp.js diff --git a/package.json b/package.json index cec452f..54ffbd5 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "mime-types": "^2.1.35", "nanospinner": "^1.1.0", "fs-extra": "^11.3.0", - "fs-filesystem": "^2.1.2" + "fs-filesystem": "^2.1.2", + "open": "^10.1.0" } } diff --git a/src/main.js b/src/main.js index 4b35b25..b1f8b82 100644 --- a/src/main.js +++ b/src/main.js @@ -11,6 +11,7 @@ import { runCodex, checkNodeStatus } from './handlers/nodeHandlers.js'; import { showInfoMessage } from './utils/messages.js'; import { loadConfig } from './services/config.js'; import { showConfigMenu } from './configmenu.js'; +import { openCodexApp } from './services/codexapp.js'; async function showNavigationMenu() { console.log('\n') @@ -81,15 +82,16 @@ export async function main() { '1. Download and install Codex', '2. Edit Codex configuration', '3. Run Codex node', - '4. Check node status', - '5. Upload a file', - '6. Download a file', - '7. Show local data', - '8. Uninstall Codex node', - '9. Submit feedback', - '10. Exit' + '4. Open Codex App', + '5. Check node status', + '6. Upload a file', + '7. Download a file', + '8. Show local data', + '9. Uninstall Codex node', + '10. Submit feedback', + '11. Exit' ], - pageSize: 10, + pageSize: 11, loop: true } ]).catch(() => { @@ -111,28 +113,31 @@ export async function main() { await runCodex(config, showNavigationMenu); return; case '4': - await checkNodeStatus(config, showNavigationMenu); + openCodexApp(config); break; case '5': - await uploadFile(config, null, handleCommandLineOperation, showNavigationMenu); + await checkNodeStatus(config, showNavigationMenu); break; case '6': - await downloadFile(config, null, handleCommandLineOperation, showNavigationMenu); + await uploadFile(config, null, handleCommandLineOperation, showNavigationMenu); break; case '7': - await showLocalFiles(config, showNavigationMenu); + await downloadFile(config, null, handleCommandLineOperation, showNavigationMenu); break; case '8': - await uninstallCodex(config, showNavigationMenu); + await showLocalFiles(config, showNavigationMenu); break; case '9': + await uninstallCodex(config, showNavigationMenu); + break; + case '10': const { exec } = await import('child_process'); const url = 'https://docs.google.com/forms/d/1U21xp6shfDkJWzJSKHhUjwIE7fsYk94gmLUKAbxUMcw/edit'; const command = process.platform === 'win32' ? `start ${url}` : process.platform === 'darwin' ? `open ${url}` : `xdg-open ${url}`; exec(command); console.log(showInfoMessage('Opening feedback form in your browser...')); break; - case '10': + case '11': handleExit(); return; } diff --git a/src/services/codexapp.js b/src/services/codexapp.js new file mode 100644 index 0000000..b76db87 --- /dev/null +++ b/src/services/codexapp.js @@ -0,0 +1,17 @@ +import open from 'open'; + +export function openCodexApp(config) { + // TODO: Update this to the main URL when the PR for adding api-port query parameter support + // has been merged and deployed. + // See: https://github.com/codex-storage/codex-marketplace-ui/issues/92 + + const segments = [ + 'https://releases-v0-0-14.codex-marketplace-ui.pages.dev/', + '?', + `api-port=${config.ports.apiPort}` + ] + + const url = segments.join(""); + + open(url); +}