mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-02 13:33:11 +00:00
fixes relative path requirement for datadir path. wip.
This commit is contained in:
parent
3ee6425200
commit
5f0e410530
@ -48,3 +48,7 @@ export const mockCodexGlobals = {
|
||||
getPublicIp: vi.fn(),
|
||||
getTestnetSPRs: vi.fn(),
|
||||
};
|
||||
|
||||
export const mockCodexApp = {
|
||||
openCodexApp: vi.fn(),
|
||||
};
|
||||
|
||||
@ -20,7 +20,6 @@ import {
|
||||
import { runCodex, checkNodeStatus } from "./handlers/nodeHandlers.js";
|
||||
import { showInfoMessage } from "./utils/messages.js";
|
||||
import { ConfigService } from "./services/configService.js";
|
||||
import { openCodexApp } from "./services/codexApp.js";
|
||||
|
||||
import { UiService } from "./services/uiService.js";
|
||||
import { FsService } from "./services/fsService.js";
|
||||
@ -36,6 +35,7 @@ import { ShellService } from "./services/shellService.js";
|
||||
import { OsService } from "./services/osService.js";
|
||||
import { ProcessControl } from "./handlers/processControl.js";
|
||||
import { CodexGlobals } from "./services/codexGlobals.js";
|
||||
import { CodexApp } from "./services/codexApp.js";
|
||||
|
||||
async function showNavigationMenu() {
|
||||
console.log("\n");
|
||||
@ -104,6 +104,7 @@ export async function main() {
|
||||
const uiService = new UiService();
|
||||
const fsService = new FsService();
|
||||
const configService = new ConfigService(fsService);
|
||||
const codexApp = new CodexApp(configService);
|
||||
const pathSelector = new PathSelector(uiService, new MenuLoop(), fsService);
|
||||
const numberSelector = new NumberSelector(uiService);
|
||||
const shellService = new ShellService();
|
||||
@ -142,6 +143,7 @@ export async function main() {
|
||||
configMenu,
|
||||
installer,
|
||||
processControl,
|
||||
codexApp,
|
||||
);
|
||||
|
||||
await mainMenu.show();
|
||||
|
||||
@ -1,17 +1,22 @@
|
||||
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
|
||||
export class CodexApp {
|
||||
constructor(configService) {
|
||||
this.configService = configService;
|
||||
}
|
||||
|
||||
const segments = [
|
||||
"https://releases-v0-0-14.codex-marketplace-ui.pages.dev/",
|
||||
"?",
|
||||
`api-port=${config.ports.apiPort}`,
|
||||
];
|
||||
openCodexApp = async () => {
|
||||
// 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 url = segments.join("");
|
||||
const segments = [
|
||||
"https://releases-v0-0-14.codex-marketplace-ui.pages.dev/",
|
||||
"?",
|
||||
`api-port=${this.configService.get().ports.apiPort}`,
|
||||
];
|
||||
|
||||
open(url);
|
||||
const url = segments.join("");
|
||||
open(url);
|
||||
};
|
||||
}
|
||||
|
||||
@ -6,6 +6,8 @@ import {
|
||||
getCodexLogsDefaultPath,
|
||||
} from "../utils/appData.js";
|
||||
|
||||
import path from "path";
|
||||
|
||||
const defaultConfig = {
|
||||
codexExe: "",
|
||||
// User-selected config options:
|
||||
@ -99,7 +101,7 @@ export class ConfigService {
|
||||
|
||||
this.fs.writeFile(
|
||||
this.config.codexConfigFilePath,
|
||||
`data-dir="${this.format(this.config.dataDir)}"${nl}` +
|
||||
`data-dir="${this.format(this.toRelative(this.config.dataDir))}"${nl}` +
|
||||
`log-level="DEBUG"${nl}` +
|
||||
`log-file="${this.format(this.getLogFilePath())}"${nl}` +
|
||||
`storage-quota=${this.config.storageQuota}${nl}` +
|
||||
@ -115,4 +117,9 @@ export class ConfigService {
|
||||
format = (str) => {
|
||||
return str.replaceAll("\\", "/");
|
||||
};
|
||||
|
||||
toRelative = (str) => {
|
||||
throw new Error("This code does not belong in this file. Move it.");
|
||||
return path.relative(this.config.codexInstallPath, str);
|
||||
};
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ export class MainMenu {
|
||||
configMenu,
|
||||
installer,
|
||||
processControl,
|
||||
codexApp,
|
||||
) {
|
||||
this.ui = uiService;
|
||||
this.loop = menuLoop;
|
||||
@ -13,6 +14,7 @@ export class MainMenu {
|
||||
this.configMenu = configMenu;
|
||||
this.installer = installer;
|
||||
this.processControl = processControl;
|
||||
this.codexApp = codexApp;
|
||||
|
||||
this.loop.initialize(this.promptMainMenu);
|
||||
}
|
||||
@ -54,7 +56,7 @@ export class MainMenu {
|
||||
await this.ui.askMultipleChoice("Codex is running", [
|
||||
{
|
||||
label: "Open Codex app",
|
||||
action: this.openCodexApp,
|
||||
action: this.codexApp.openCodexApp,
|
||||
},
|
||||
{
|
||||
label: "Stop Codex",
|
||||
@ -67,10 +69,6 @@ export class MainMenu {
|
||||
]);
|
||||
};
|
||||
|
||||
openCodexApp = async () => {
|
||||
console.log("todo!");
|
||||
};
|
||||
|
||||
showNotRunningMenu = async () => {
|
||||
await this.ui.askMultipleChoice("Codex is not running", [
|
||||
{
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { describe, beforeEach, it, expect, vi } from "vitest";
|
||||
import { MainMenu } from "./mainMenu.js";
|
||||
import { mockUiService } from "../__mocks__/service.mocks.js";
|
||||
import { mockUiService, mockCodexApp } from "../__mocks__/service.mocks.js";
|
||||
import { mockInstallMenu, mockConfigMenu } from "../__mocks__/ui.mocks.js";
|
||||
import {
|
||||
mockInstaller,
|
||||
@ -21,6 +21,7 @@ describe("mainmenu", () => {
|
||||
mockConfigMenu,
|
||||
mockInstaller,
|
||||
mockProcessControl,
|
||||
mockCodexApp,
|
||||
);
|
||||
});
|
||||
|
||||
@ -113,7 +114,7 @@ describe("mainmenu", () => {
|
||||
expect(mockUiService.askMultipleChoice).toHaveBeenCalledWith(
|
||||
"Codex is running",
|
||||
[
|
||||
{ label: "Open Codex app", action: mainmenu.openCodexApp },
|
||||
{ label: "Open Codex app", action: mockCodexApp.openCodexApp },
|
||||
{ label: "Stop Codex", action: mockProcessControl.stopCodexProcess },
|
||||
{ label: "Exit", action: mockMenuLoop.stopLoop },
|
||||
],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user