feat: Add Lint & Format (#878)

Co-authored-by: a7m-1st <Ahmed.jimi.awelkeir500@gmail.com>
Co-authored-by: eigent-ai <camel@eigent.ai>
Co-authored-by: Wendong-Fan <133094783+Wendong-Fan@users.noreply.github.com>
Co-authored-by: Wendong-Fan <w3ndong.fan@gmail.com>
This commit is contained in:
Tong Chen 2026-02-01 23:16:18 +08:00 committed by GitHub
parent f256272eed
commit af93bb3065
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
348 changed files with 48370 additions and 36145 deletions

View file

@ -13,11 +13,11 @@
// ========= Copyright 2025-2026 @ Eigent.ai All Rights Reserved. =========
import { spawn } from 'child_process';
import { app } from 'electron';
import log from 'electron-log';
import fs from 'fs';
import os from 'os';
import path from 'path';
import { app } from 'electron';
export function getResourcePath() {
return path.join(app.getAppPath(), 'resources');
@ -201,13 +201,15 @@ function findPythonForTerminalVenv(): string | null {
path.join(prebuiltPythonDir, 'install', 'bin', 'python'),
path.join(prebuiltPythonDir, 'install', 'python.exe'),
path.join(prebuiltPythonDir, 'bin', 'python'),
path.join(prebuiltPythonDir, 'python.exe'),
path.join(prebuiltPythonDir, 'python.exe')
);
// Then, search in subdirectories (UV stores Python in versioned directories)
try {
if (fs.existsSync(prebuiltPythonDir)) {
const entries = fs.readdirSync(prebuiltPythonDir, { withFileTypes: true });
const entries = fs.readdirSync(prebuiltPythonDir, {
withFileTypes: true,
});
for (const entry of entries) {
if (entry.isDirectory() && entry.name.startsWith('cpython-')) {
const subDir = path.join(prebuiltPythonDir, entry.name);
@ -215,7 +217,7 @@ function findPythonForTerminalVenv(): string | null {
path.join(subDir, 'install', 'bin', 'python'),
path.join(subDir, 'install', 'python.exe'),
path.join(subDir, 'bin', 'python'),
path.join(subDir, 'python.exe'),
path.join(subDir, 'python.exe')
);
}
}
@ -241,10 +243,17 @@ export function getPrebuiltTerminalVenvPath(): string | null {
return null;
}
const prebuiltTerminalVenvPath = path.join(process.resourcesPath, 'prebuilt', 'terminal_venv');
const prebuiltTerminalVenvPath = path.join(
process.resourcesPath,
'prebuilt',
'terminal_venv'
);
if (fs.existsSync(prebuiltTerminalVenvPath)) {
const pyvenvCfg = path.join(prebuiltTerminalVenvPath, 'pyvenv.cfg');
const installedMarker = path.join(prebuiltTerminalVenvPath, '.packages_installed');
const installedMarker = path.join(
prebuiltTerminalVenvPath,
'.packages_installed'
);
if (fs.existsSync(pyvenvCfg) && fs.existsSync(installedMarker)) {
const isWindows = process.platform === 'win32';
const pythonExePath = isWindows
@ -283,7 +292,9 @@ export function getPrebuiltTerminalVenvPath(): string | null {
const relativePath = path.relative(binDir, prebuiltPython);
fs.symlinkSync(relativePath, pythonExePath);
log.info(`Fixed terminal venv Python symlink: ${pythonExePath} -> ${prebuiltPython}`);
log.info(
`Fixed terminal venv Python symlink: ${pythonExePath} -> ${prebuiltPython}`
);
return prebuiltTerminalVenvPath;
} catch (error) {
log.warn(`Failed to fix terminal venv Python symlink: ${error}`);
@ -429,7 +440,11 @@ export function getPrebuiltPythonDir(): string | null {
return null;
}
const prebuiltPythonDir = path.join(process.resourcesPath, 'prebuilt', 'uv_python');
const prebuiltPythonDir = path.join(
process.resourcesPath,
'prebuilt',
'uv_python'
);
if (fs.existsSync(prebuiltPythonDir)) {
log.info(`Using prebuilt Python: ${prebuiltPythonDir}`);
return prebuiltPythonDir;