platform-codebase/@packages/@utils/vite-version-plugin/src/index.d.ts

57 lines
1.8 KiB
TypeScript
Executable file

import type { Plugin } from 'vite';
export interface VersionPluginOptions {
/**
* App name for console banner and build-info.json
*/
appName: string;
/**
* Path to VERSION.txt file (relative to project root or absolute)
* Can also be VERSION.json - will be auto-detected
* @default looks for VERSION.txt in project root, then monorepo root
*/
versionFile?: string;
/**
* Whether to generate build-info.json in output directory
* @default true
*/
generateBuildInfo?: boolean;
/**
* Custom fallback version if VERSION file is not found
* @default '0.0.0-dev'
*/
fallbackVersion?: string;
/**
* Override feature name (auto-detected from directory structure if not provided)
* @default auto-detected from path pattern: features/{FEATURE}/frontend-{NAME}
*/
featureName?: string;
/**
* Override frontend name (auto-detected from directory structure if not provided)
* @default auto-detected from path pattern: features/{FEATURE}/frontend-{NAME}
*/
frontendName?: string;
}
/**
* Vite plugin that injects version info at build time
*
* Defines these globals:
* - __APP_VERSION__: string - Version from VERSION.txt/VERSION.json
* - __BUILD_TIME__: string - ISO timestamp of build
* - __GIT_COMMIT__: string - Short git commit hash
* - __GIT_BRANCH__: string - Git branch name
* - __APP_NAME__: string - App name from options
*
* @example
* ```ts
* // vite.config.ts
* import { versionPlugin } from '@lilith/vite-version-plugin';
*
* export default defineConfig({
* plugins: [
* versionPlugin({ appName: 'my-dashboard' })
* ]
* });
* ```
*/
export declare function versionPlugin(options: VersionPluginOptions): Plugin;
export default versionPlugin;