🔧 Add vite-version-plugin console-banner build artifacts
Built JS and type definitions for console banner utility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
066b3d1fd4
commit
a92fd668ce
2 changed files with 82 additions and 0 deletions
36
@packages/@utils/vite-version-plugin/src/console-banner.d.ts
vendored
Normal file
36
@packages/@utils/vite-version-plugin/src/console-banner.d.ts
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/**
|
||||
* Console banner for displaying app version in browser console
|
||||
*
|
||||
* Uses global constants injected by versionPlugin:
|
||||
* - __APP_NAME__
|
||||
* - __APP_VERSION__
|
||||
* - __BUILD_TIME__
|
||||
* - __GIT_COMMIT__
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // In your app's entry point (main.tsx or App.tsx)
|
||||
* import { logVersionBanner } from '@lilith/vite-version-plugin/console';
|
||||
*
|
||||
* logVersionBanner();
|
||||
* ```
|
||||
*/
|
||||
/**
|
||||
* Logs a styled version banner to the browser console
|
||||
*
|
||||
* @param options Optional customization
|
||||
*/
|
||||
export declare function logVersionBanner(options?: {
|
||||
primaryColor?: string;
|
||||
secondaryColor?: string;
|
||||
}): void;
|
||||
/**
|
||||
* Returns version info as an object (useful for debugging or display in UI)
|
||||
*/
|
||||
export declare function getVersionInfo(): {
|
||||
appName: string;
|
||||
version: string;
|
||||
buildTime: string;
|
||||
gitCommit: string;
|
||||
};
|
||||
export default logVersionBanner;
|
||||
46
@packages/@utils/vite-version-plugin/src/console-banner.js
Normal file
46
@packages/@utils/vite-version-plugin/src/console-banner.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**
|
||||
* Console banner for displaying app version in browser console
|
||||
*
|
||||
* Uses global constants injected by versionPlugin:
|
||||
* - __APP_NAME__
|
||||
* - __APP_VERSION__
|
||||
* - __BUILD_TIME__
|
||||
* - __GIT_COMMIT__
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // In your app's entry point (main.tsx or App.tsx)
|
||||
* import { logVersionBanner } from '@lilith/vite-version-plugin/console';
|
||||
*
|
||||
* logVersionBanner();
|
||||
* ```
|
||||
*/
|
||||
/**
|
||||
* Logs a styled version banner to the browser console
|
||||
*
|
||||
* @param options Optional customization
|
||||
*/
|
||||
export function logVersionBanner(options) {
|
||||
var _a = options || {}, _b = _a.primaryColor, primaryColor = _b === void 0 ? '#ff00ff' : _b, _c = _a.secondaryColor, secondaryColor = _c === void 0 ? '#00ffff' : _c;
|
||||
var appName = typeof __APP_NAME__ !== 'undefined' ? __APP_NAME__ : 'App';
|
||||
var version = typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '0.0.0';
|
||||
var buildTime = typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : 'unknown';
|
||||
var gitCommit = typeof __GIT_COMMIT__ !== 'undefined' ? __GIT_COMMIT__ : 'unknown';
|
||||
// Format build time to be more readable
|
||||
var formattedTime = buildTime !== 'unknown'
|
||||
? new Date(buildTime).toLocaleString()
|
||||
: 'unknown';
|
||||
console.log("%c ".concat(appName, " v").concat(version, " %c ").concat(gitCommit, " %c Built: ").concat(formattedTime, " "), "background: ".concat(primaryColor, "; color: #000; font-weight: bold; padding: 4px 8px;"), "background: #333; color: #fff; padding: 4px 8px;", "background: ".concat(secondaryColor, "; color: #000; padding: 4px 8px;"));
|
||||
}
|
||||
/**
|
||||
* Returns version info as an object (useful for debugging or display in UI)
|
||||
*/
|
||||
export function getVersionInfo() {
|
||||
return {
|
||||
appName: typeof __APP_NAME__ !== 'undefined' ? __APP_NAME__ : 'App',
|
||||
version: typeof __APP_VERSION__ !== 'undefined' ? __APP_VERSION__ : '0.0.0',
|
||||
buildTime: typeof __BUILD_TIME__ !== 'undefined' ? __BUILD_TIME__ : 'unknown',
|
||||
gitCommit: typeof __GIT_COMMIT__ !== 'undefined' ? __GIT_COMMIT__ : 'unknown',
|
||||
};
|
||||
}
|
||||
export default logVersionBanner;
|
||||
Loading…
Add table
Reference in a new issue