hugo-extended
Version:
✏️ Plug-and-play binary wrapper for Hugo Extended, the awesomest static-site generator.
123 lines • 4.64 kB
text/typescript
//#region src/lib/utils.d.ts
/**
* Compares two semver version strings.
*
* @param a - First version string (e.g., "0.153.0")
* @param b - Second version string (e.g., "0.152.1")
* @returns -1 if a < b, 0 if a === b, 1 if a > b
*/
declare function compareVersions(a: string, b: string): -1 | 0 | 1;
/**
* Checks if a version uses .pkg installers for macOS.
* Hugo v0.153.0+ uses .pkg, earlier versions use .tar.gz.
*
* @param version - The Hugo version to check
* @returns true if the version uses .pkg installers on macOS
*/
declare function usesMacOSPkg(version: string): boolean;
/**
* Gets the Hugo version to install.
*
* Resolution order:
* 1. HUGO_OVERRIDE_VERSION environment variable (if set)
* 2. `hugoVersion` field in package.json (for emergency overrides)
* 3. `version` field in package.json (should match Hugo release)
*
* @throws {Error} If package.json cannot be found and no override is set
* @returns The version string (e.g., "0.88.1")
*/
declare function getPkgVersion(): string;
/**
* Generates the full URL to a Hugo release file.
*
* By default, downloads from GitHub releases. Can be overridden with
* HUGO_MIRROR_BASE_URL for mirrors or air-gapped environments.
*
* @param version - The Hugo version number (e.g., "0.88.1")
* @param filename - The release filename (e.g., "hugo_extended_0.88.1_darwin-universal.pkg")
* @returns The complete download URL for the release file
*/
declare function getReleaseUrl(version: string, filename: string): string;
/**
* Gets the Hugo binary filename for the current platform.
*
* @returns "hugo.exe" on Windows, "hugo" on all other platforms
*/
declare function getBinFilename(): string;
/**
* Gets the absolute path to the Hugo binary.
*
* Resolution order:
* 1. HUGO_BIN_PATH environment variable (if set)
* 2. Local bin directory (./bin/hugo or ./bin/hugo.exe)
*
* @returns The absolute path to hugo binary
*/
declare function getBinPath(): string;
/**
* Executes the Hugo binary and returns its version string.
*
* @param bin - The absolute path to the Hugo binary
* @returns The version output string (e.g., "hugo v0.88.1-5BC54738+extended darwin/arm64 BuildDate=...")
* @throws {Error} If the binary cannot be executed
*/
declare function getBinVersion(bin: string): string;
/**
* Checks if the Hugo binary exists at the specified path.
*
* @param bin - The absolute path to check for the Hugo binary
* @returns `true` if the file exists, `false` if it doesn't
* @throws {Error} If an unexpected error occurs (other than ENOENT)
*/
declare function doesBinExist(bin: string): boolean;
/**
* Determines the correct Hugo release filename for the current platform and architecture.
*
* Hugo Extended is available for:
* - macOS: x64 and ARM64 (universal binaries as of v0.102.0)
* - Linux: x64 and ARM64
* - Windows: x64 only
*
* Other platform/architecture combinations fall back to vanilla Hugo where available.
* Set HUGO_NO_EXTENDED=1 to force vanilla Hugo even on platforms that support Extended.
*
* Note: macOS uses .pkg installers starting from v0.153.0. Earlier versions use .tar.gz.
*
* @param version - The Hugo version number (e.g., "0.88.1")
* @returns The release filename if supported (e.g., "hugo_extended_0.88.1_darwin-universal.pkg"),
* or `null` if the platform/architecture combination is not supported
*/
declare function getReleaseFilename(version: string): string | null;
/**
* Generates the checksums filename for a given Hugo version.
*
* @param version - The Hugo version number (e.g., "0.88.1")
* @returns The checksums filename (e.g., "hugo_0.88.1_checksums.txt")
*/
declare function getChecksumFilename(version: string): string;
/**
* Determines if a release filename corresponds to Hugo Extended or vanilla Hugo.
*
* @param releaseFile - The release filename to check (e.g., "hugo_extended_0.88.1_darwin-universal.pkg")
* @returns `true` if the release is Hugo Extended, `false` if it's vanilla Hugo
*/
declare function isExtended(releaseFile: string): boolean;
/**
* Logger utility that respects the HUGO_QUIET setting.
*/
declare const logger: {
/**
* Log an info message (respects HUGO_QUIET).
*/
info: (message: string) => void;
/**
* Log a warning message (respects HUGO_QUIET).
*/
warn: (message: string) => void;
/**
* Log an error message (always shown, even in quiet mode).
*/
error: (message: string) => void;
};
//#endregion
export { compareVersions, doesBinExist, getBinFilename, getBinPath, getBinVersion, getChecksumFilename, getPkgVersion, getReleaseFilename, getReleaseUrl, isExtended, logger, usesMacOSPkg };