mirror of
https://github.com/logos-storage/logos-storage-installer.git
synced 2026-01-07 16:03:07 +00:00
Fixes uninstall on Windows
This commit is contained in:
parent
ba2aae04a9
commit
e2f4c9c85e
@ -9,7 +9,7 @@ import { runCommand } from '../utils/command.js';
|
|||||||
import { showErrorMessage, showInfoMessage, showSuccessMessage } from '../utils/messages.js';
|
import { showErrorMessage, showInfoMessage, showSuccessMessage } from '../utils/messages.js';
|
||||||
import { checkDependencies } from '../services/nodeService.js';
|
import { checkDependencies } from '../services/nodeService.js';
|
||||||
import { saveConfig } from '../services/config.js';
|
import { saveConfig } from '../services/config.js';
|
||||||
import { getCodexInstallPath, getCodexDataDirDefaultPath, getCodexLogsPath } from '../utils/appdata.js';
|
import { getCodexRootPath, getCodexBinPath, getCodexDataDirDefaultPath, getCodexLogsPath } from '../utils/appdata.js';
|
||||||
|
|
||||||
const platform = os.platform();
|
const platform = os.platform();
|
||||||
|
|
||||||
@ -96,6 +96,13 @@ async function saveCodexExePathToConfig(config, codexExePath) {
|
|||||||
saveConfig(config);
|
saveConfig(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function clearCodexExePathFromConfig(config) {
|
||||||
|
config.codexExe = "";
|
||||||
|
config.dataDir = "";
|
||||||
|
config.logsDir = "";
|
||||||
|
saveConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
export async function installCodex(config, showNavigationMenu) {
|
export async function installCodex(config, showNavigationMenu) {
|
||||||
const agreed = await showPrivacyDisclaimer();
|
const agreed = await showPrivacyDisclaimer();
|
||||||
if (!agreed) {
|
if (!agreed) {
|
||||||
@ -104,7 +111,7 @@ export async function installCodex(config, showNavigationMenu) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const installPath = getCodexInstallPath();
|
const installPath = getCodexBinPath();
|
||||||
console.log(showInfoMessage("Install location: " + installPath));
|
console.log(showInfoMessage("Install location: " + installPath));
|
||||||
|
|
||||||
const spinner = createSpinner('Installing Codex...').start();
|
const spinner = createSpinner('Installing Codex...').start();
|
||||||
@ -201,12 +208,19 @@ export async function installCodex(config, showNavigationMenu) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uninstallCodex(showNavigationMenu) {
|
function removeDir(dir) {
|
||||||
|
fs.rmSync(dir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function uninstallCodex(config, showNavigationMenu) {
|
||||||
const { confirm } = await inquirer.prompt([
|
const { confirm } = await inquirer.prompt([
|
||||||
{
|
{
|
||||||
type: 'confirm',
|
type: 'confirm',
|
||||||
name: 'confirm',
|
name: 'confirm',
|
||||||
message: chalk.yellow('⚠️ Are you sure you want to uninstall Codex? This action cannot be undone.'),
|
message: chalk.yellow(
|
||||||
|
'⚠️ Are you sure you want to uninstall Codex? This action cannot be undone. \n' +
|
||||||
|
'All data stored in the local Codex node will be deleted as well.'
|
||||||
|
),
|
||||||
default: false
|
default: false
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
@ -218,26 +232,9 @@ export async function uninstallCodex(showNavigationMenu) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (platform === 'win32') {
|
removeDir(getCodexRootPath());
|
||||||
console.log(showInfoMessage('Removing Codex from Windows...'));
|
clearCodexExePathFromConfig(config);
|
||||||
|
|
||||||
await runCommand('netsh advfirewall firewall delete rule name="Allow Codex (TCP-In)"');
|
|
||||||
await runCommand('netsh advfirewall firewall delete rule name="Allow Codex (UDP-In)"');
|
|
||||||
|
|
||||||
await runCommand('rd /s /q "%LOCALAPPDATA%\\Codex"');
|
|
||||||
|
|
||||||
console.log(showInfoMessage(
|
|
||||||
'To complete uninstallation:\n\n' +
|
|
||||||
'1. Open Control Panel → System → Advanced System settings → Environment Variables\n' +
|
|
||||||
'2. Or type "environment variables" in Windows Search\n' +
|
|
||||||
'3. Remove "%LOCALAPPDATA%\\Codex" from your Path variable'
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
const binaryPath = '/usr/local/bin/codex';
|
|
||||||
console.log(showInfoMessage(`Attempting to remove Codex binary from ${binaryPath}...`));
|
|
||||||
await runCommand(`sudo rm ${binaryPath}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(showSuccessMessage('Codex has been successfully uninstalled.'));
|
console.log(showSuccessMessage('Codex has been successfully uninstalled.'));
|
||||||
await showNavigationMenu();
|
await showNavigationMenu();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -120,7 +120,7 @@ export async function main() {
|
|||||||
await showLocalFiles(showNavigationMenu);
|
await showLocalFiles(showNavigationMenu);
|
||||||
break;
|
break;
|
||||||
case '7':
|
case '7':
|
||||||
await uninstallCodex(showNavigationMenu);
|
await uninstallCodex(config, showNavigationMenu);
|
||||||
break;
|
break;
|
||||||
case '8':
|
case '8':
|
||||||
const { exec } = await import('child_process');
|
const { exec } = await import('child_process');
|
||||||
|
|||||||
@ -5,7 +5,11 @@ export function getAppDataDir() {
|
|||||||
return ensureExists(appData("codex-cli"));
|
return ensureExists(appData("codex-cli"));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getCodexInstallPath() {
|
export function getCodexRootPath() {
|
||||||
|
return ensureExists(appData("codex"));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getCodexBinPath() {
|
||||||
return ensureExists(path.join(appData("codex"), "bin"));
|
return ensureExists(path.join(appData("codex"), "bin"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user