From 6853299865338869ee8919c0cacefd892943cc1b Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 20 Sep 2025 10:44:18 +0300 Subject: [PATCH] Show application version in console banner --- assets/js/app.js | 11 ++--------- assets/js/banner.js | 12 ++++++++++++ lib/music_library/application.ex | 4 ++++ .../components/layouts/root.html.heex | 1 + 4 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 assets/js/banner.js diff --git a/assets/js/app.js b/assets/js/app.js index 456916ea..0fd5fcd7 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -27,6 +27,7 @@ import BarcodeScannerHook from "./hooks/barcode-scanner"; import FormatNumberHook from "./hooks/format-number"; import confetti from "canvas-confetti"; import { createLiveToastHook } from "live_toast"; +import banner from "./banner"; let Hooks = FluxonHooks; Hooks.BarcodeScanner = BarcodeScannerHook; @@ -145,12 +146,4 @@ window.enableLiveViewChangeObserver = () => { }); }; -console.log(`%c -███╗ ███╗██╗ ██╗███████╗██╗ ██████╗ ██╗ ██╗██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗ -████╗ ████║██║ ██║██╔════╝██║██╔════╝ ██║ ██║██╔══██╗██╔══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝ -██╔████╔██║██║ ██║███████╗██║██║ ██║ ██║██████╔╝██████╔╝███████║██████╔╝ ╚████╔╝ -██║╚██╔╝██║██║ ██║╚════██║██║██║ ██║ ██║██╔══██╗██╔══██╗██╔══██║██╔══██╗ ╚██╔╝ -██║ ╚═╝ ██║╚██████╔╝███████║██║╚██████╗ ███████╗██║██████╔╝██║ ██║██║ ██║██║ ██║ ██║ -╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ - -`, "font-family:monospace; font-size: 20px"); +banner(); diff --git a/assets/js/banner.js b/assets/js/banner.js new file mode 100644 index 00000000..c5d8a116 --- /dev/null +++ b/assets/js/banner.js @@ -0,0 +1,12 @@ +export default function banner() { + const version = document.querySelector('meta[name="version"]').content; + console.log(`%c +███╗ ███╗██╗ ██╗███████╗██╗ ██████╗ ██╗ ██╗██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗ +████╗ ████║██║ ██║██╔════╝██║██╔════╝ ██║ ██║██╔══██╗██╔══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝ +██╔████╔██║██║ ██║███████╗██║██║ ██║ ██║██████╔╝██████╔╝███████║██████╔╝ ╚████╔╝ +██║╚██╔╝██║██║ ██║╚════██║██║██║ ██║ ██║██╔══██╗██╔══██╗██╔══██║██╔══██╗ ╚██╔╝ +██║ ╚═╝ ██║╚██████╔╝███████║██║╚██████╗ ███████╗██║██████╔╝██║ ██║██║ ██║██║ ██║ ██║ +╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ +Version: ${version} +`, "font-family: IBM Plex Mono,monospace; font-size: 12px"); +} diff --git a/lib/music_library/application.ex b/lib/music_library/application.ex index 785ede11..60f949df 100644 --- a/lib/music_library/application.ex +++ b/lib/music_library/application.ex @@ -43,6 +43,10 @@ defmodule MusicLibrary.Application do :ok end + def version do + System.get_env("SOURCE_COMMIT") || "development" + end + defp skip_migrations? do # By default, sqlite migrations are run when using a release System.get_env("RELEASE_NAME") != nil diff --git a/lib/music_library_web/components/layouts/root.html.heex b/lib/music_library_web/components/layouts/root.html.heex index c07cadf2..1d24fda5 100644 --- a/lib/music_library_web/components/layouts/root.html.heex +++ b/lib/music_library_web/components/layouts/root.html.heex @@ -4,6 +4,7 @@ + <.live_title suffix=" · Music Library"> {assigns[:page_title] || assigns.conn.request_path}