mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
fix: Ensure version info visibility and build robustness
- Moved `<!-- VERSION_INFO -->` out of `.fade-in` container in `index.html` to prevent visibility issues if JS fails. - Added verification in `scripts/build-dist.mjs` to ensure `dist/components` exists and is not empty. - Added logging to `scripts/build-dist.mjs` for version injection status. - Updated `scripts/verify-dist-deploy-artifact.mjs` regex to accommodate HTML structure change. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
6210b1045d
commit
6a284e0b2d
5 files changed
+10
-34
No files matched your search
@@ -359,6 +359,8 @@
|
||||
<h2 class="text-2xl font-bold tracking-wide text-muted-strong">
|
||||
seed. zap. subscribe.
|
||||
</h2>
|
||||
</div>
|
||||
<div class="text-center mb-8">
|
||||
<!-- VERSION_INFO -->
|
||||
</div>
|
||||
|
||||
|
||||
@@ -178,6 +178,7 @@ function injectVersionInfo() {
|
||||
fs.writeFileSync(indexHtmlPath, content);
|
||||
console.log(`Injected version: ${hash.slice(0, 8)} • ${date}`);
|
||||
} else {
|
||||
console.warn('Warning: <!-- VERSION_INFO --> placeholder not found. Attempting regex fallback...');
|
||||
// Fallback search if placeholder is missing (legacy behavior)
|
||||
const taglineRegex = /(seed\. zap\. subscribe\.\s*<\/h2>)/;
|
||||
if (taglineRegex.test(content)) {
|
||||
@@ -244,6 +245,12 @@ function main() {
|
||||
copyDir(dir, path.join(DIST, dir));
|
||||
}
|
||||
|
||||
// Verify components were copied (critical for client-side injection)
|
||||
const componentsDist = path.join(DIST, 'components');
|
||||
if (!fs.existsSync(componentsDist) || fs.readdirSync(componentsDist).length === 0) {
|
||||
throw new Error('Critical Error: dist/components directory is missing or empty.');
|
||||
}
|
||||
|
||||
console.log('Generating hashed asset manifest...');
|
||||
const manifest = generateHashedAssetManifest();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import path from 'node:path';
|
||||
const DIST_DIR = 'dist';
|
||||
const INDEX_PATH = path.join(DIST_DIR, 'index.html');
|
||||
const MANIFEST_PATH = path.join(DIST_DIR, 'asset-manifest.json');
|
||||
const VERSION_MARKUP_PATTERN = /seed\.\s*zap\.\s*subscribe\.\s*<\/h2>\s*<div[^>]*>\s*v:\s*[a-f0-9]{8}\s*•\s*\d{4}-\d{2}-\d{2}\s*<\/div>/i;
|
||||
const VERSION_MARKUP_PATTERN = /seed\.\s*zap\.\s*subscribe\.\s*<\/h2>[\s\S]*?v:\s*[a-f0-9]{8}\s*•\s*\d{4}-\d{2}-\d{2}/i;
|
||||
|
||||
function readUtf8(filePath) {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 20 KiB |
@@ -1,33 +0,0 @@
|
||||
from playwright.sync_api import sync_playwright
|
||||
import re
|
||||
|
||||
def run():
|
||||
with sync_playwright() as p:
|
||||
browser = p.chromium.launch()
|
||||
page = browser.new_page()
|
||||
try:
|
||||
page.goto("http://localhost:8080")
|
||||
|
||||
# Pattern for version string
|
||||
pattern = re.compile(r"v:\s+[a-f0-9]{8}\s+•\s+\d{4}-\d{2}-\d{2}")
|
||||
|
||||
locator = page.get_by_text(pattern)
|
||||
locator.wait_for()
|
||||
|
||||
# Scroll to element
|
||||
locator.scroll_into_view_if_needed()
|
||||
|
||||
# Take a screenshot of the element specifically, plus some context
|
||||
# Or just the page after scrolling
|
||||
page.screenshot(path="verification.png")
|
||||
|
||||
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