mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +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">
|
<h2 class="text-2xl font-bold tracking-wide text-muted-strong">
|
||||||
seed. zap. subscribe.
|
seed. zap. subscribe.
|
||||||
</h2>
|
</h2>
|
||||||
|
<!-- VERSION_INFO -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Mobile Search FAB -->
|
<!-- Mobile Search FAB -->
|
||||||
|
|||||||
+13
-5
@@ -171,14 +171,22 @@ function injectVersionInfo() {
|
|||||||
v: ${hash.slice(0, 8)} • ${date}
|
v: ${hash.slice(0, 8)} • ${date}
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
// Fallback search if whitespace differs
|
// Robust replacement using explicit comment placeholder
|
||||||
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
|
const placeholder = '<!-- VERSION_INFO -->';
|
||||||
if (taglineRegex.test(content)) {
|
if (content.includes(placeholder)) {
|
||||||
content = content.replace(taglineRegex, '$1' + versionHtml);
|
content = content.replace(placeholder, versionHtml);
|
||||||
fs.writeFileSync(indexHtmlPath, content);
|
fs.writeFileSync(indexHtmlPath, content);
|
||||||
console.log(`Injected version: ${hash.slice(0, 8)} • ${date}`);
|
console.log(`Injected version: ${hash.slice(0, 8)} • ${date}`);
|
||||||
} else {
|
} 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) {
|
} 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
|
from playwright.sync_api import sync_playwright
|
||||||
|
import re
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
with sync_playwright() as p:
|
with sync_playwright() as p:
|
||||||
browser = p.chromium.launch()
|
browser = p.chromium.launch()
|
||||||
page = browser.new_page()
|
page = browser.new_page()
|
||||||
page.goto("http://localhost:3000")
|
try:
|
||||||
|
page.goto("http://localhost:8080")
|
||||||
|
|
||||||
# Locate the tagline
|
# Pattern for version string
|
||||||
tagline = page.get_by_text("seed. zap. subscribe.")
|
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
|
locator = page.get_by_text(pattern)
|
||||||
# The tagline is an h2 inside a div.
|
locator.wait_for()
|
||||||
container = tagline.locator("..")
|
|
||||||
|
|
||||||
# Wait for fade-in to settle or just force visibility?
|
# Scroll to element
|
||||||
# The container has "fade-in" class. It might take time.
|
locator.scroll_into_view_if_needed()
|
||||||
# I'll wait for the version text to be visible.
|
|
||||||
version_locator = container.locator("div.text-xs")
|
|
||||||
version_locator.wait_for()
|
|
||||||
|
|
||||||
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
|
content = locator.text_content()
|
||||||
container.screenshot(path="verification.png")
|
print(f"Found version string: '{content.strip()}'")
|
||||||
browser.close()
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error: {e}")
|
||||||
|
finally:
|
||||||
|
browser.close()
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
run()
|
run()
|
||||||
Reference in new issue
Block a user