mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
Merge pull request #2323 from PR0M3TH3AN/fix-version-injection-7871469918057559176
Robust version hash injection
This commit is contained in:
4 files changed
+33
-20
No files matched your search
@@ -359,6 +359,7 @@
|
||||
<h2 class="text-2xl font-bold tracking-wide text-muted-strong">
|
||||
seed. zap. subscribe.
|
||||
</h2>
|
||||
<!-- VERSION_INFO -->
|
||||
</div>
|
||||
|
||||
<!-- Mobile Search FAB -->
|
||||
|
||||
+13
-5
@@ -171,14 +171,22 @@ function injectVersionInfo() {
|
||||
v: ${hash.slice(0, 8)} • ${date}
|
||||
</div>`;
|
||||
|
||||
// Fallback search if whitespace differs
|
||||
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
|
||||
if (taglineRegex.test(content)) {
|
||||
content = content.replace(taglineRegex, '$1' + versionHtml);
|
||||
// Robust replacement using explicit comment placeholder
|
||||
const placeholder = '<!-- VERSION_INFO -->';
|
||||
if (content.includes(placeholder)) {
|
||||
content = content.replace(placeholder, versionHtml);
|
||||
fs.writeFileSync(indexHtmlPath, content);
|
||||
console.log(`Injected version: ${hash.slice(0, 8)} • ${date}`);
|
||||
} else {
|
||||
console.warn('Could not find tagline to inject version info.');
|
||||
// Fallback search if placeholder is missing (legacy behavior)
|
||||
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
|
||||
if (taglineRegex.test(content)) {
|
||||
content = content.replace(taglineRegex, '$1' + versionHtml);
|
||||
fs.writeFileSync(indexHtmlPath, content);
|
||||
console.log(`Injected version (via fallback regex): ${hash.slice(0, 8)} • ${date}`);
|
||||
} else {
|
||||
console.warn('Could not find placeholder or tagline to inject version info.');
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 5.8 KiB After Width: | Height: | Size: 38 KiB |
+19
-15
@@ -1,29 +1,33 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import re
|
||||
|
||||
def run():
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch()
|
||||
page = browser.new_page()
|
||||
page.goto("http://localhost:3000")
|
||||
try:
|
||||
page.goto("http://localhost:8080")
|
||||
|
||||
# Locate the tagline
|
||||
tagline = page.get_by_text("seed. zap. subscribe.")
|
||||
# Pattern for version string
|
||||
pattern = re.compile(r"v:\s+[a-f0-9]{8}\s+•\s+\d{4}-\d{2}-\d{2}")
|
||||
|
||||
# Locate the version info which should be nearby
|
||||
# The tagline is an h2 inside a div.
|
||||
container = tagline.locator("..")
|
||||
locator = page.get_by_text(pattern)
|
||||
locator.wait_for()
|
||||
|
||||
# Wait for fade-in to settle or just force visibility?
|
||||
# The container has "fade-in" class. It might take time.
|
||||
# I'll wait for the version text to be visible.
|
||||
version_locator = container.locator("div.text-xs")
|
||||
version_locator.wait_for()
|
||||
# Scroll to element
|
||||
locator.scroll_into_view_if_needed()
|
||||
|
||||
print("Version text found:", version_locator.inner_text())
|
||||
# Take a screenshot of the element specifically, plus some context
|
||||
# Or just the page after scrolling
|
||||
page.screenshot(path="verification.png")
|
||||
|
||||
# Screenshot the container
|
||||
container.screenshot(path="verification.png")
|
||||
browser.close()
|
||||
content = locator.text_content()
|
||||
print(f"Found version string: '{content.strip()}'")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
finally:
|
||||
browser.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
run()
|
||||
Reference in new issue
Block a user