UNPKG

@bobfrankston/mountsmb

Version:

Cross-platform SMB mounting solution for Windows, WSL, and Linux

158 lines (157 loc) 5.33 kB
#!/usr/bin/env node /** * mountsmb - Cross-platform secure SMB mounting via SSH tunnels * Works in both Windows (cmd/PowerShell) and WSL environments * Provides automated Samba installation and secure mounting at C:\drives\smb\ * * DEVELOPMENT WORKFLOW: * 1. During development - accumulate changes: * releaseapp.ps1 -AddCommit "Fix junction creation bug" * releaseapp.ps1 -AddCommit "Add better error handling" * * 2. When ready to release: * releaseapp.ps1 # Patch release using commit.txt * releaseapp.ps1 -Minor # Minor release using commit.txt * releaseapp.ps1 -Major -Notes # Major release with additional notes * * 3. For immediate release without commit.txt: * releaseapp.ps1 -Commit "Quick bug fix" * * The commit.txt file is automatically cleared after successful release. * Use 'releaseapp.ps1 -Help' for complete usage information. */ export declare const win32: boolean; export declare function setDbgMessages(enabled: boolean): void; export declare function getDbgMessages(): boolean; /** * Hostname mapping configuration interface */ export interface HostnameMap { /** Mapping from short name to full hostname */ [shortName: string]: string; } /** * Host resolution result with both short and full names */ export interface HostResolution { /** Short name used for mount points and display */ shortName: string; /** Full hostname used for actual connections */ fullHostname: string; } /** * Load hostname mapping from SSH config with JSON fallback * @returns Hostname mapping configuration */ export declare function loadHostnameConfig(): HostnameMap; /** * Resolve hostname bidirectionally - normalize any input to short name and full hostname * @param input - Either a short name or full hostname * @returns Object with both short name and full hostname */ export declare function resolveHostname(input: string): HostResolution; export interface ConnectionInfo { /** Username for SSH and SMB connections */ user: string; /** Full hostname for connections */ host: string; /** Short name used for mount points */ mountName: string; /** Remote path to mount */ remotePath: string; } interface MountInfo { pid: number; port: number; driveLetter: string; host: string; user: string; } /** * Mount options interface */ export interface MountOptions { /** Force Samba installation even if it appears to be running */ installSamba?: boolean; /** Enable verbose logging output */ verbose?: boolean; /** Remote path to mount (defaults to '/') */ remotePath?: string; /** Enable debug messages for troubleshooting */ debug?: boolean; } /** * Mount an SMB share from a remote host using short or full hostname * @param host - Short name (e.g., 'beta1') or full hostname (e.g., 'beta1.frankston.com') * @param options - Mount options including remotePath, verbose, and installSamba flags * @param options.remotePath - Remote path to mount (defaults to '/') * @param options.verbose - Enable verbose logging output (defaults to false for API, true for CLI) * @param options.installSamba - Force Samba installation even if already installed * @returns Promise that resolves when mount is complete * @example * ```typescript * // Mount beta1's root filesystem * await mountSMBHost('beta1'); * * // Mount specific path with options * await mountSMBHost('pi3a', { remotePath: '/var/www', installSamba: true }); * * // Mount with verbose output disabled (useful for API usage) * await mountSMBHost('beta1', { verbose: false }); * * // Mount using full hostname with custom path * await mountSMBHost('beta1.frankston.com', { remotePath: '/home/user' }); * ``` */ export declare function mountSMBHost(host: string, options?: MountOptions): Promise<void>; /** * Unmount an SMB share by hostname * @param host - Short name or full hostname to unmount */ export declare function unmountSMBHost(host: string): Promise<void>; /** * Get list of all active SMB mounts * @returns Array of mount information */ export declare function getActiveMounts(): Array<MountInfo & { mountName: string; }>; /** * Clean up dead/stale mounts * @returns Number of mounts cleaned up */ export declare function cleanupDeadMounts(): Promise<number>; /** * Get the resolved connection information for a host * @param host - Short name or full hostname * @param remotePath - Remote path (defaults to '/') * @returns Connection information with resolved hostnames */ export declare function getConnectionInfo(host: string, remotePath?: string): ConnectionInfo; /** * Get all available hostname mappings from config * @returns Current hostname mapping configuration */ export declare function getHostnameMappings(): HostnameMap; /** * Get SSH config file paths in priority order * @returns Array of SSH config file paths that exist */ export declare function getSSHConfigInfo(): Array<{ path: string; exists: boolean; primary: boolean; }>; /** * Sync hostname configurations between Windows and WSL * @returns Result of sync operation */ export declare function syncHostnameConfigs(): { success: boolean; message: string; paths?: { wsl: string; windows: string; }; }; export {};