UNPKG

hugo-extended

Version:

✏️ Plug-and-play binary wrapper for Hugo Extended, the awesomest static-site generator.

66 lines 3.05 kB
//#region src/lib/install.d.ts /** * Archive types supported by the installer. */ type ArchiveType = "zip" | "tar.gz" | "pkg" | null; /** * Detects the archive type from a filename based on its extension. * * @param filename - The filename to check * @returns The detected archive type, or null if unknown */ declare function getArchiveType(filename: string): ArchiveType; /** * Parses a checksums file content into a lookup map. * * The checksums file format is: "sha256hash filename" (hash followed by whitespace and filename). * This is the standard format used by Hugo releases. * * @param content - The raw content of the checksums file * @returns A Map of filename to SHA-256 hash */ declare function parseChecksumFile(content: string): Map<string, string>; /** * Extracts a Hugo binary from a macOS .pkg file without requiring sudo. * * Uses `pkgutil --expand-full` to expand the package, then locates and copies * the Hugo binary from the payload to the destination directory. * * The Hugo .pkg structure after expansion contains: * - A "Payload" directory containing the hugo binary directly * - Or a component package directory with Payload inside * * @param pkgPath - The path to the .pkg file to extract * @param destDir - The directory where the hugo binary should be placed * @throws {Error} If extraction fails, Payload is not found, or hugo binary is missing * @see https://github.com/jmooring/hvm/commit/16eb55ae4965b5d2e414061085490a90fe7ea73e */ declare function extractPkg(pkgPath: string, destDir: string): void; /** * Downloads, verifies, and installs Hugo (Extended when available) for the current platform. * * This function handles the complete installation process: * - Determines the correct Hugo release file for the current platform and architecture * - Downloads the release file and checksums from GitHub (or custom mirror) * - Verifies the integrity of the downloaded file using SHA-256 checksums (unless HUGO_SKIP_CHECKSUM is set) * - Extracts the binary (platform-specific): * - macOS v0.153.0+: Extracts from .pkg using pkgutil (no sudo required) * - macOS pre-v0.153.0: Extracts from .tar.gz archive * - Windows: Extracts from .zip archive * - Linux/BSD: Extracts from .tar.gz archive * - Sets appropriate file permissions on Unix-like systems * - Displays the installed Hugo version * * Environment variables that affect installation: * - HUGO_OVERRIDE_VERSION: Install a different Hugo version * - HUGO_NO_EXTENDED: Force vanilla Hugo instead of Extended * - HUGO_MIRROR_BASE_URL: Custom download mirror * - HUGO_SKIP_CHECKSUM: Skip SHA-256 verification * - HUGO_QUIET: Suppress progress output * * @throws {Error} If the platform is unsupported, download fails, checksum doesn't match, or installation fails * @returns A promise that resolves with the absolute path to the installed Hugo binary */ declare function install(): Promise<string>; //#endregion export { ArchiveType, install as default, extractPkg, getArchiveType, parseChecksumFile };