This commit fixes an issue seen on certain Windows environments (Windows 10 22H2 and 11 23H2 Pro Azure VMs) where scripts were being deleted during execution due to temporary directory usage. To resolve this, scripts are now stored in a persistent directory, enhancing reliability for long-running scripts and improving auditability along with troubleshooting. Key changes: - Move script execution logic to the `main` process from `preloader` to utilize Electron's `app.getPath`. - Improve runtime environment detection for non-browser environments to allow its usage in Electron main process. - Introduce a secure module to expose IPC channels from the main process to the renderer via the preloader process. Supporting refactorings include: - Simplify `CodeRunner` interface by removing the `tempScriptFolderName` parameter. - Rename `NodeSystemOperations` to `NodeElectronSystemOperations` as it now wraps electron APIs too, and convert it to class for simplicity. - Rename `TemporaryFileCodeRunner` to `ScriptFileCodeRunner` to reflect its new functinoality. - Rename `SystemOperations` folder to `System` for simplicity. - Rename `HostRuntimeEnvironment` to `BrowserRuntimeEnvironment` for clarity. - Refactor main Electron process configuration to align with latest Electron documentation/recommendations. - Refactor unit tests `BrowserRuntimeEnvironment` to simplify singleton workaround. - Use alias imports like `electron/main` and `electron/common` for better clarity.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import type {
|
|
CommandOps,
|
|
FileSystemOps,
|
|
OperatingSystemOps,
|
|
LocationOps,
|
|
SystemOperations,
|
|
} from '@/infrastructure/CodeRunner/System/SystemOperations';
|
|
import { CommandOpsStub } from './CommandOpsStub';
|
|
import { FileSystemOpsStub } from './FileSystemOpsStub';
|
|
import { LocationOpsStub } from './LocationOpsStub';
|
|
import { OperatingSystemOpsStub } from './OperatingSystemOpsStub';
|
|
|
|
export class SystemOperationsStub implements SystemOperations {
|
|
public operatingSystem: OperatingSystemOps = new OperatingSystemOpsStub();
|
|
|
|
public location: LocationOps = new LocationOpsStub();
|
|
|
|
public fileSystem: FileSystemOps = new FileSystemOpsStub();
|
|
|
|
public command: CommandOps = new CommandOpsStub();
|
|
|
|
public withOperatingSystem(operatingSystemOps: OperatingSystemOps): this {
|
|
this.operatingSystem = operatingSystemOps;
|
|
return this;
|
|
}
|
|
|
|
public withLocation(location: LocationOps): this {
|
|
this.location = location;
|
|
return this;
|
|
}
|
|
|
|
public withFileSystem(fileSystem: FileSystemOps): this {
|
|
this.fileSystem = fileSystem;
|
|
return this;
|
|
}
|
|
|
|
public withCommand(command: CommandOps): this {
|
|
this.command = command;
|
|
return this;
|
|
}
|
|
}
|