Implements launching codex app from installer

This commit is contained in:
Ben 2025-02-24 11:14:54 +01:00
parent 8fa5705817
commit fea6a7e5cb
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
3 changed files with 38 additions and 15 deletions

View File

@ -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"
}
}

View File

@ -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;
}

17
src/services/codexapp.js Normal file
View File

@ -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);
}