@xec-sh/cli
Version:
Xec: The Universal Shell for TypeScript
58 lines (57 loc) • 2.02 kB
TypeScript
import type { Command } from 'commander';
import type { ResolvedTarget } from '../config/types.js';
export interface ScriptContext {
args?: string[];
argv?: string[];
__filename?: string;
__dirname?: string;
}
export interface TargetInfo {
type: 'local' | 'ssh' | 'docker' | 'k8s';
name?: string;
host?: string;
container?: string;
pod?: string;
namespace?: string;
config: any;
}
export interface LoaderOptions {
verbose?: boolean;
cache?: boolean;
preferredCDN?: 'esm.sh' | 'jsr.io' | 'unpkg' | 'skypack' | 'jsdelivr';
quiet?: boolean;
typescript?: boolean;
}
export interface ExecutionOptions extends LoaderOptions {
target?: ResolvedTarget;
targetEngine?: any;
context?: ScriptContext;
watch?: boolean;
}
export interface ScriptExecutionResult {
success: boolean;
error?: Error;
output?: string;
}
export declare class ScriptLoader {
private moduleLoader;
private options;
constructor(options?: LoaderOptions);
executeScript(scriptPath: string, options?: ExecutionOptions): Promise<ScriptExecutionResult>;
private executeScriptInternal;
private executeWithWatch;
evaluateCode(code: string, options?: ExecutionOptions): Promise<ScriptExecutionResult>;
startRepl(options?: ExecutionOptions): Promise<void>;
loadDynamicCommand(filePath: string, program: Command, commandName: string): Promise<{
success: boolean;
error?: string;
}>;
private createTargetInfo;
private findTempDirectory;
private addReplCommands;
static isScript(filepath: string): boolean;
}
export declare function getUnifiedScriptLoader(options?: LoaderOptions): ScriptLoader;
export declare function executeScript(scriptPath: string, options?: ExecutionOptions): Promise<ScriptExecutionResult>;
export declare function evaluateCode(code: string, options?: ExecutionOptions): Promise<ScriptExecutionResult>;
export declare function startRepl(options?: ExecutionOptions): Promise<void>;