UNPKG

code-finder

Version:

CLI to detect codespaces and update IDE opened histories.

107 lines (99 loc) 4.52 kB
import { execFile } from 'node:child_process'; declare const NAME: string; declare const VERSION: string; declare const MODE_CHOICES: readonly ["update", "detect", "combine"]; declare const DEFAULT_OPTIONS: { ignorePaths: never[]; path: boolean; mtimeDeep: number; mtimeConcurrency: number; tildify: boolean; gitBranch: boolean; source: boolean; overwrite: boolean; json: boolean; yes: boolean; }; declare const JSON_MARKER = "<!-- code-finder -->"; declare const VERSION_CONTROL_DIRECTORIES: string[]; declare const IDE_DIRECTORIES: string[]; declare const INSTALL_DIRECTORIES: string[]; declare const WORKSPACE_FILES: string[]; declare const CONFIG_FILES: string[]; declare const LOCK_FILES: string[]; declare const IGNORE_DIRECTORIES: string[]; declare const IGNORE_FILES: string[]; declare const CODESPACE_DIRECTORIES: string[]; declare const CODESPACE_FILES: string[]; declare const CODE_NAME_CHOICES: readonly ["Code", "Code - Insiders", "VSCodium", "VSCodium - Insiders", "Cursor", "Windsurf"]; declare const EDITOR_NAME_MAP: { readonly Code: "Visual Studio Code"; readonly 'Code - Insiders': "Visual Studio Code - Insiders"; readonly VSCodium: "VSCodium"; readonly 'VSCodium - Insiders': "VSCodium - Insiders"; readonly Cursor: "Cursor"; readonly Windsurf: "Windsurf"; }; type RangeMode = (typeof MODE_CHOICES)[number]; type CodeName = (typeof CODE_NAME_CHOICES)[number]; type EditorName = keyof typeof EDITOR_NAME_MAP; interface CommandOptions { mode?: RangeMode; cwd?: string; ignorePaths?: string | string[]; ide?: CodeName[]; path?: boolean; mtimeDeep?: number; mtimeConcurrency?: number; tildify?: boolean; gitBranch?: boolean; source?: boolean; overwrite?: boolean; json?: boolean; yes?: boolean; } interface Options extends Required<Omit<CommandOptions, 'ignorePaths'>> { ignorePaths: string[]; } interface DetectOptions extends Pick<Options, 'cwd' | 'ignorePaths' | 'mtimeDeep' | 'mtimeConcurrency'> { } interface History { entries: HistoryEntry[]; } interface HistoryEntry { folderUri?: string; fileUri?: string; path?: string; source?: EntrySource[]; branch?: string; mtime?: number; } type EntrySource = CodeName | 'Codespace'; declare function executeCommand(options: Partial<CommandOptions>): Promise<{ config: Options; data: HistoryEntry[]; }>; declare function readVSCodeDatabase(codeName: CodeName): Promise<History | undefined>; declare function writeVSCodeDatabase(codeName: CodeName, data: History): Promise<void>; declare function updateVSCodeHistories(codeName: CodeName, entries: HistoryEntry[], overwrite?: boolean): Promise<void>; declare function mergeVSCodeHistories(codeName: CodeName, entries: HistoryEntry[]): Promise<HistoryEntry[]>; declare function uniqVSCodeHistories(data: HistoryEntry[][]): HistoryEntry[]; declare const vscode: { readonly read: typeof readVSCodeDatabase; readonly write: typeof writeVSCodeDatabase; readonly uniq: typeof uniqVSCodeHistories; readonly merge: typeof mergeVSCodeHistories; readonly update: typeof updateVSCodeHistories; }; declare function isCodespace(path: string, ignorePaths: string[]): Promise<boolean | string[]>; declare function getCodespaceMtime(cwd: string, mtimeDeep?: number, concurrency?: number): Promise<number>; declare function detectCodespaces(options: DetectOptions): Promise<HistoryEntry[]>; declare const execFileAsync: typeof execFile.__promisify__; declare function capitalize(str: string): string; declare function normalizePath(path: string): string; declare function hasSqlite3(): Promise<boolean>; declare function ensureSqlite3(): Promise<void>; declare function extractJSON(stdout: string): HistoryEntry[] | undefined; declare function sortByMtime(data: HistoryEntry[]): HistoryEntry[]; export { CODESPACE_DIRECTORIES, CODESPACE_FILES, CODE_NAME_CHOICES, CONFIG_FILES, DEFAULT_OPTIONS, EDITOR_NAME_MAP, IDE_DIRECTORIES, IGNORE_DIRECTORIES, IGNORE_FILES, INSTALL_DIRECTORIES, JSON_MARKER, LOCK_FILES, MODE_CHOICES, NAME, VERSION, VERSION_CONTROL_DIRECTORIES, WORKSPACE_FILES, capitalize, detectCodespaces, ensureSqlite3, execFileAsync, executeCommand, extractJSON, getCodespaceMtime, hasSqlite3, isCodespace, mergeVSCodeHistories, normalizePath, sortByMtime, uniqVSCodeHistories, updateVSCodeHistories, vscode }; export type { CodeName, CommandOptions, DetectOptions, EditorName, EntrySource, History, HistoryEntry, Options, RangeMode };