igir
Version:
🕹 A zero-setup ROM collection manager that sorts, filters, extracts or archives, patches, and reports on collections of any size on any OS.
467 lines (466 loc) • 16.4 kB
TypeScript
import 'reflect-metadata';
import { LogLevelValue } from '../console/logLevel.js';
import { FsWalkCallback } from '../polyfill/fsPoly.js';
import ROM from './dats/rom.js';
import File from './files/file.js';
import { ChecksumBitmaskValue } from './files/fileChecksums.js';
export declare const InputChecksumArchivesMode: {
readonly NEVER: 1;
readonly AUTO: 2;
readonly ALWAYS: 3;
};
export type InputChecksumArchivesModeKey = keyof typeof InputChecksumArchivesMode;
export type InputChecksumArchivesModeValue = (typeof InputChecksumArchivesMode)[InputChecksumArchivesModeKey];
export declare const InputChecksumArchivesModeInverted: Record<InputChecksumArchivesModeValue, InputChecksumArchivesModeKey>;
export declare const MergeMode: {
readonly FULLNONMERGED: 1;
readonly NONMERGED: 2;
readonly SPLIT: 3;
readonly MERGED: 4;
};
export type MergeModeKey = keyof typeof MergeMode;
export type MergeModeValue = (typeof MergeMode)[MergeModeKey];
export declare const MergeModeInverted: Record<MergeModeValue, MergeModeKey>;
export declare const GameSubdirMode: {
readonly NEVER: 1;
readonly MULTIPLE: 2;
readonly ALWAYS: 3;
};
export type GameSubdirModeKey = keyof typeof GameSubdirMode;
export type GameSubdirModeValue = (typeof GameSubdirMode)[GameSubdirModeKey];
export declare const GameSubdirModeInverted: Record<GameSubdirModeValue, GameSubdirModeKey>;
export declare const FixExtension: {
readonly NEVER: 1;
readonly AUTO: 2;
readonly ALWAYS: 3;
};
export type FixExtensionKey = keyof typeof FixExtension;
export type FixExtensionValue = (typeof FixExtension)[FixExtensionKey];
export declare const FixExtensionInverted: Record<FixExtensionValue, FixExtensionKey>;
export declare const PreferRevision: {
readonly OLDER: 1;
readonly NEWER: 2;
};
export type PreferRevisionKey = keyof typeof PreferRevision;
export type PreferRevisionValue = (typeof PreferRevision)[PreferRevisionKey];
export declare const PreferRevisionInverted: Record<PreferRevisionValue, PreferRevisionKey>;
export interface OptionsProps {
readonly commands?: string[];
readonly input?: string[];
readonly inputExclude?: string[];
readonly inputChecksumQuick?: boolean;
readonly inputChecksumMin?: string;
readonly inputChecksumMax?: string;
readonly inputChecksumArchives?: string;
readonly dat?: string[];
readonly datExclude?: string[];
readonly datNameRegex?: string;
readonly datNameRegexExclude?: string;
readonly datDescriptionRegex?: string;
readonly datDescriptionRegexExclude?: string;
readonly datCombine?: boolean;
readonly datIgnoreParentClone?: boolean;
readonly patch?: string[];
readonly patchExclude?: string[];
readonly output?: string;
readonly dirMirror?: boolean;
readonly dirDatName?: boolean;
readonly dirDatDescription?: boolean;
readonly dirLetter?: boolean;
readonly dirLetterCount?: number;
readonly dirLetterLimit?: number;
readonly dirLetterGroup?: boolean;
readonly dirGameSubdir?: string;
readonly fixExtension?: string;
readonly overwrite?: boolean;
readonly overwriteInvalid?: boolean;
readonly cleanExclude?: string[];
readonly cleanBackup?: string;
readonly cleanDryRun?: boolean;
readonly zipExclude?: string;
readonly zipDatName?: boolean;
readonly symlink?: boolean;
readonly symlinkRelative?: boolean;
readonly header?: string;
readonly removeHeaders?: string[];
readonly mergeRoms?: string;
readonly mergeDiscs?: boolean;
readonly excludeDisks?: boolean;
readonly allowExcessSets?: boolean;
readonly allowIncompleteSets?: boolean;
readonly filterRegex?: string;
readonly filterRegexExclude?: string;
readonly filterLanguage?: string[];
readonly filterRegion?: string[];
readonly filterCategoryRegex?: string;
readonly noBios?: boolean;
readonly onlyBios?: boolean;
readonly noDevice?: boolean;
readonly onlyDevice?: boolean;
readonly noUnlicensed?: boolean;
readonly onlyUnlicensed?: boolean;
readonly onlyRetail?: boolean;
readonly noDebug?: boolean;
readonly onlyDebug?: boolean;
readonly noDemo?: boolean;
readonly onlyDemo?: boolean;
readonly noBeta?: boolean;
readonly onlyBeta?: boolean;
readonly noSample?: boolean;
readonly onlySample?: boolean;
readonly noPrototype?: boolean;
readonly onlyPrototype?: boolean;
readonly noProgram?: boolean;
readonly onlyProgram?: boolean;
readonly noAftermarket?: boolean;
readonly onlyAftermarket?: boolean;
readonly noHomebrew?: boolean;
readonly onlyHomebrew?: boolean;
readonly noUnverified?: boolean;
readonly onlyUnverified?: boolean;
readonly noBad?: boolean;
readonly onlyBad?: boolean;
readonly single?: boolean;
readonly preferGameRegex?: string;
readonly preferRomRegex?: string;
readonly preferVerified?: boolean;
readonly preferGood?: boolean;
readonly preferLanguage?: string[];
readonly preferRegion?: string[];
readonly preferRevision?: string;
readonly preferRetail?: boolean;
readonly preferParent?: boolean;
readonly playlistExtensions?: string[];
readonly dir2datOutput?: string;
readonly fixdatOutput?: string;
readonly reportOutput?: string;
readonly datThreads?: number;
readonly readerThreads?: number;
readonly writerThreads?: number;
readonly writeRetry?: number;
readonly tempDir?: string;
readonly disableCache?: boolean;
readonly cachePath?: string;
readonly verbose?: number;
readonly help?: boolean;
}
/**
* A collection of all options for a single invocation of the application.
*/
export default class Options implements OptionsProps {
readonly commands: string[];
readonly input: string[];
readonly inputExclude: string[];
readonly inputChecksumQuick: boolean;
readonly inputChecksumMin?: string;
readonly inputChecksumMax?: string;
readonly inputChecksumArchives?: string;
readonly dat: string[];
readonly datExclude: string[];
readonly datNameRegex?: string;
readonly datNameRegexExclude?: string;
readonly datDescriptionRegex?: string;
readonly datDescriptionRegexExclude?: string;
readonly datCombine: boolean;
readonly datIgnoreParentClone: boolean;
readonly patch: string[];
readonly patchExclude: string[];
readonly output?: string;
readonly dirMirror: boolean;
readonly dirDatName: boolean;
readonly dirDatDescription: boolean;
readonly dirLetter: boolean;
readonly dirLetterCount: number;
readonly dirLetterLimit: number;
readonly dirLetterGroup: boolean;
readonly dirGameSubdir?: string;
readonly fixExtension?: string;
readonly overwrite: boolean;
readonly overwriteInvalid: boolean;
readonly cleanExclude: string[];
readonly cleanBackup?: string;
readonly cleanDryRun: boolean;
readonly zipExclude: string;
readonly zipDatName: boolean;
readonly symlink: boolean;
readonly symlinkRelative: boolean;
readonly header: string;
readonly removeHeaders?: string[];
readonly mergeRoms?: string;
readonly mergeDiscs: boolean;
readonly excludeDisks: boolean;
readonly allowExcessSets: boolean;
readonly allowIncompleteSets: boolean;
readonly filterRegex?: string;
readonly filterRegexExclude?: string;
readonly filterLanguage: string[];
readonly filterRegion: string[];
readonly filterCategoryRegex?: string;
readonly noBios: boolean;
readonly onlyBios: boolean;
readonly noDevice: boolean;
readonly onlyDevice: boolean;
readonly noUnlicensed: boolean;
readonly onlyUnlicensed: boolean;
readonly onlyRetail: boolean;
readonly noDebug: boolean;
readonly onlyDebug: boolean;
readonly noDemo: boolean;
readonly onlyDemo: boolean;
readonly noBeta: boolean;
readonly onlyBeta: boolean;
readonly noSample: boolean;
readonly onlySample: boolean;
readonly noPrototype: boolean;
readonly onlyPrototype: boolean;
readonly noProgram: boolean;
readonly onlyProgram: boolean;
readonly noAftermarket: boolean;
readonly onlyAftermarket: boolean;
readonly noHomebrew: boolean;
readonly onlyHomebrew: boolean;
readonly noUnverified: boolean;
readonly onlyUnverified: boolean;
readonly noBad: boolean;
readonly onlyBad: boolean;
readonly single: boolean;
readonly preferGameRegex?: string;
readonly preferRomRegex?: string;
readonly preferVerified: boolean;
readonly preferGood: boolean;
readonly preferLanguage: string[];
readonly preferRegion: string[];
readonly preferRevision?: string;
readonly preferRetail: boolean;
readonly preferParent: boolean;
readonly playlistExtensions: string[];
readonly dir2datOutput?: string;
readonly fixdatOutput?: string;
readonly reportOutput: string;
readonly datThreads: number;
readonly readerThreads: number;
readonly writerThreads: number;
readonly writeRetry: number;
readonly tempDir: string;
readonly disableCache: boolean;
readonly cachePath?: string;
readonly verbose: number;
readonly help: boolean;
constructor(options?: OptionsProps);
/**
* Construct a {@link Options} from a generic object, such as one from `yargs`.
*/
static fromObject(obj: object): Options;
/**
* Return an object of all options.
*/
toObject(): Record<string, unknown>;
/**
* Return a JSON representation of all options.
*/
toString(): string;
private static getRegex;
getCommands(): Set<string>;
/**
* Was any writing command provided?
*/
shouldWrite(): boolean;
/**
* The writing command that was specified.
*/
writeString(): string | undefined;
/**
* Was the `copy` command provided?
*/
shouldCopy(): boolean;
/**
* Was the `move` command provided?
*/
shouldMove(): boolean;
/**
* Was the `link` command provided?
*/
shouldLink(): boolean;
/**
* Was the `extract` command provided?
*/
shouldExtract(): boolean;
/**
* Should a given ROM be extracted?
*/
shouldExtractRom(rom: ROM): boolean;
/**
* Was the `zip` command provided?
*/
shouldZip(): boolean;
/**
* Should a given output file path be zipped?
*/
shouldZipRom(rom: ROM): boolean;
/**
* Was the 'playlist' command provided?
*/
shouldPlaylist(): boolean;
/**
* Was the 'dir2dat' command provided?
*/
shouldDir2Dat(): boolean;
/**
* Was the 'fixdat' command provided?
*/
shouldFixdat(): boolean;
/**
* Was the `test` command provided?
*/
shouldTest(): boolean;
/**
* Was the `clean` command provided?
*/
shouldClean(): boolean;
/**
* Was the `report` command provided?
*/
shouldReport(): boolean;
getInputPaths(): string[];
private scanInputFiles;
private scanInputExcludeFiles;
/**
* Scan for input files, and input files to exclude, and return the difference.
*/
scanInputFilesWithoutExclusions(walkCallback?: FsWalkCallback): Promise<string[]>;
private static scanPaths;
private static globPath;
/**
* Trying to use globs with directory names that resemble glob patterns (e.g. dirs that include
* parentheticals) is problematic. Most of the time globs are at the tail end of the path, so try
* to figure out what leading part of the pattern is just a path, and escape it appropriately,
* and then tack on the glob at the end.
* Example problematic paths:
* ./TOSEC - DAT Pack - Complete (3983) (TOSEC-v2023-07-10)/TOSEC-ISO/Sega*
*/
private static sanitizeGlobPattern;
getInputChecksumQuick(): boolean;
getInputChecksumMin(): ChecksumBitmaskValue | undefined;
getInputChecksumMax(): ChecksumBitmaskValue | undefined;
getInputChecksumArchives(): InputChecksumArchivesModeValue | undefined;
/**
* Were any DAT paths provided?
*/
usingDats(): boolean;
private scanDatFiles;
private scanDatExcludeFiles;
/**
* Scan for DAT files, and DAT files to exclude, and return the difference.
*/
scanDatFilesWithoutExclusions(walkCallback?: FsWalkCallback): Promise<string[]>;
getDatNameRegex(): RegExp[] | undefined;
getDatNameRegexExclude(): RegExp[] | undefined;
getDatDescriptionRegex(): RegExp[] | undefined;
getDatDescriptionRegexExclude(): RegExp[] | undefined;
getDatCombine(): boolean;
getDatIgnoreParentClone(): boolean;
getPatchFileCount(): number;
/**
* Scan for patch files, and patch files to exclude, and return the difference.
*/
scanPatchFilesWithoutExclusions(walkCallback?: FsWalkCallback): Promise<string[]>;
private scanPatchFiles;
private scanPatchExcludeFiles;
getOutput(): string;
/**
* Get the "root" sub-path of the output dir, the sub-path up until the first replaceable token.
*/
getOutputDirRoot(): string;
getDirMirror(): boolean;
getDirDatName(): boolean;
getDirDatDescription(): boolean;
getDirLetter(): boolean;
getDirLetterCount(): number;
getDirLetterLimit(): number;
getDirLetterGroup(): boolean;
getDirGameSubdir(): GameSubdirModeValue | undefined;
getFixExtension(): FixExtensionValue | undefined;
getOverwrite(): boolean;
getOverwriteInvalid(): boolean;
private scanCleanExcludeFiles;
/**
* Scan for output files, and output files to exclude from cleaning, and return the difference.
*/
scanOutputFilesWithoutCleanExclusions(outputDirs: string[], writtenFiles: File[], walkCallback?: FsWalkCallback): Promise<string[]>;
getCleanBackup(): string | undefined;
getCleanDryRun(): boolean;
private getZipExclude;
getZipDatName(): boolean;
getSymlink(): boolean;
getSymlinkRelative(): boolean;
private getHeader;
/**
* Should a file have its contents read to detect any {@link Header}?
*/
shouldReadFileForHeader(filePath: string): boolean;
/**
* Can the {@link Header} be removed for a {@link extension} during writing?
*/
canRemoveHeader(extension: string): boolean;
getMergeRoms(): MergeModeValue | undefined;
getMergeDiscs(): boolean;
getExcludeDisks(): boolean;
getAllowExcessSets(): boolean;
getAllowIncompleteSets(): boolean;
getFilterRegex(): RegExp[] | undefined;
getFilterRegexExclude(): RegExp[] | undefined;
getFilterLanguage(): Set<string>;
getFilterRegion(): Set<string>;
getFilterCategoryRegex(): RegExp[] | undefined;
getNoBios(): boolean;
getOnlyBios(): boolean;
getNoDevice(): boolean;
getOnlyDevice(): boolean;
getNoUnlicensed(): boolean;
getOnlyUnlicensed(): boolean;
getOnlyRetail(): boolean;
getNoDebug(): boolean;
getOnlyDebug(): boolean;
getNoDemo(): boolean;
getOnlyDemo(): boolean;
getNoBeta(): boolean;
getOnlyBeta(): boolean;
getNoSample(): boolean;
getOnlySample(): boolean;
getNoPrototype(): boolean;
getOnlyPrototype(): boolean;
getNoProgram(): boolean;
getOnlyProgram(): boolean;
getNoAftermarket(): boolean;
getOnlyAftermarket(): boolean;
getNoHomebrew(): boolean;
getOnlyHomebrew(): boolean;
getNoUnverified(): boolean;
getOnlyUnverified(): boolean;
getNoBad(): boolean;
getOnlyBad(): boolean;
getSingle(): boolean;
getPreferGameRegex(): RegExp[] | undefined;
getPreferRomRegex(): RegExp[] | undefined;
getPreferVerified(): boolean;
getPreferGood(): boolean;
getPreferLanguages(): string[];
getPreferRegions(): string[];
getPreferRevision(): PreferRevisionValue | undefined;
getPreferRetail(): boolean;
getPreferParent(): boolean;
getPlaylistExtensions(): string[];
getDir2DatOutput(): string;
getFixdatOutput(): string;
getReportOutput(): string;
getDatThreads(): number;
getReaderThreads(): number;
getWriterThreads(): number;
getWriteRetry(): number;
getTempDir(): string;
getDisableCache(): boolean;
getCachePath(): string | undefined;
getLogLevel(): LogLevelValue;
getHelp(): boolean;
private static filterUniqueUpper;
}