feat(workspace-terminal): use environment shell command
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import * as webcontainer from '@tempfix/webcontainer__api';
|
||||
import type { IExecutionEnvironment, IFileEntry, IFileWatcher, IProcessHandle } from '../interfaces/IExecutionEnvironment.js';
|
||||
import type {
|
||||
IExecutionEnvironment,
|
||||
IFileEntry,
|
||||
IFileWatcher,
|
||||
IProcessHandle,
|
||||
IShellCommand,
|
||||
} from '../interfaces/IExecutionEnvironment.js';
|
||||
|
||||
/**
|
||||
* WebContainer-based execution environment.
|
||||
@@ -154,6 +160,14 @@ export class WebContainerEnvironment implements IExecutionEnvironment {
|
||||
};
|
||||
}
|
||||
|
||||
public getShellCommand(): IShellCommand {
|
||||
return {
|
||||
command: 'jsh',
|
||||
label: 'jsh',
|
||||
prompt: '~/',
|
||||
};
|
||||
}
|
||||
|
||||
// ============ WebContainer-specific methods ============
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,17 @@ export interface IProcessHandle {
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
export interface IShellCommand {
|
||||
/** Executable to start for an interactive shell session. */
|
||||
command: string;
|
||||
/** Optional command arguments. */
|
||||
args?: string[];
|
||||
/** Optional display label for terminal tabs. */
|
||||
label?: string;
|
||||
/** Optional prompt marker used for setup commands. */
|
||||
prompt?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract execution environment interface.
|
||||
* Implementations can target WebContainer (browser), Backend API (server), or Mock (testing).
|
||||
@@ -93,12 +104,18 @@ export interface IExecutionEnvironment {
|
||||
|
||||
/**
|
||||
* Spawn a new process
|
||||
* @param command - Command to run (e.g., 'jsh', 'node', 'npm')
|
||||
* @param command - Command to run (e.g., 'node', 'npm')
|
||||
* @param args - Optional arguments
|
||||
* @returns Process handle with I/O streams
|
||||
*/
|
||||
spawn(command: string, args?: string[]): Promise<IProcessHandle>;
|
||||
|
||||
/**
|
||||
* Return the environment-native interactive shell command.
|
||||
* Implementations should provide this when terminal shells need a specific executable.
|
||||
*/
|
||||
getShellCommand?(): IShellCommand | Promise<IShellCommand>;
|
||||
|
||||
// ============ Lifecycle ============
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user