fix: update hwlab v02 web asset probe for React Vite
This commit is contained in:
+37
-18
@@ -895,17 +895,30 @@ function v02WebAssetsProbeScript(): string {
|
||||
"html=$(fetch_url \"$base/\" 2>/dev/null)",
|
||||
"html_code=$?",
|
||||
"printf 'htmlOk\\t%s\\n' \"$html_code\"",
|
||||
"css_path=$(printf '%s' \"$html\" | sed -n 's/.*href=\"\\([^\"]*\\.css\\)\".*/\\1/p' | head -1)",
|
||||
"printf 'cssPath\\t%s\\n' \"$css_path\"",
|
||||
"case \"$css_path\" in",
|
||||
" http://*|https://*) css_url=\"$css_path\" ;;",
|
||||
" /*) css_url=\"$base$css_path\" ;;",
|
||||
" \"\") css_url=\"\" ;;",
|
||||
" *) css_url=\"$base/$css_path\" ;;",
|
||||
"esac",
|
||||
"printf 'htmlAppScript\\t%s\\n' \"$(printf '%s' \"$html\" | grep -Eq 'src=\"/app\\.js\"|src=\"app\\.js\"'; printf '%s' \"$?\")\"",
|
||||
"printf 'htmlCssLink\\t%s\\n' \"$(test -n \"$css_path\"; printf '%s' \"$?\")\"",
|
||||
"printf 'readonlyNote\\t%s\\n' \"$(printf '%s' \"$html\" | grep -Eiq 'readonly-rpc|复核入口'; printf '%s' \"$?\")\"",
|
||||
"css=$(fetch_url \"$base/styles.css\" 2>/dev/null)",
|
||||
"if [ -n \"$css_url\" ]; then css=$(fetch_url \"$css_url\" 2>/dev/null); else css=\"\"; false; fi",
|
||||
"css_code=$?",
|
||||
"printf 'cssOk\\t%s\\n' \"$css_code\"",
|
||||
"printf 'cssBytes\\t%s\\n' \"$(printf '%s' \"$css\" | wc -c | tr -d ' ')\"",
|
||||
"app_js=$(fetch_url \"$base/app.js\" 2>/dev/null)",
|
||||
"app_js_code=$?",
|
||||
"printf 'appJsOk\\t%s\\n' \"$app_js_code\"",
|
||||
"printf 'appJsBytes\\t%s\\n' \"$(printf '%s' \"$app_js\" | wc -c | tr -d ' ')\"",
|
||||
"printf 'sidebarFitCss\\t%s\\n' \"$(printf '%s' \"$css\" | grep -Eq 'grid-template-rows:[[:space:]]*auto[[:space:]]+auto[[:space:]]+auto[[:space:]]+auto[[:space:]]+minmax\\(0,[[:space:]]*1fr\\)'; printf '%s' \"$?\")\"",
|
||||
"printf 'workspaceFitCss\\t%s\\n' \"$(printf '%s' \"$css\" | grep -Eq 'grid-template-rows:[[:space:]]*auto[[:space:]]+minmax\\(0,[[:space:]]*1fr\\)'; printf '%s' \"$?\")\"",
|
||||
"printf 'eventPanelFitCss\\t%s\\n' \"$(printf '%s' \"$css\" | grep -Eq 'grid-template-rows:[[:space:]]*auto[[:space:]]+minmax\\(132px,[[:space:]]*1fr\\)'; printf '%s' \"$?\")\"",
|
||||
"fetch_url \"$base/styles.css\" >/dev/null 2>&1",
|
||||
"legacy_styles_code=$?",
|
||||
"if [ \"$legacy_styles_code\" = \"0\" ]; then legacy_styles_absent=1; else legacy_styles_absent=0; fi",
|
||||
"printf 'legacyStylesAbsent\\t%s\\n' \"$legacy_styles_absent\"",
|
||||
"printf 'reactWorkbenchCss\\t%s\\n' \"$(printf '%s' \"$css\" | grep -Eq 'workbench-shell|activity-rail|session-sidebar|conversation-panel'; printf '%s' \"$?\")\"",
|
||||
"health=$(fetch_url \"$api/health/live\" 2>/dev/null)",
|
||||
"health_code=$?",
|
||||
"printf 'apiHealthOk\\t%s\\n' \"$health_code\"",
|
||||
@@ -1026,53 +1039,59 @@ function v02WebAssetsFromText(
|
||||
if (key.length > 0) fields[key] = rest.join("\t");
|
||||
}
|
||||
const htmlOk = fields.htmlOk === "0";
|
||||
const htmlAppScript = fields.htmlAppScript === "0";
|
||||
const htmlCssLink = fields.htmlCssLink === "0";
|
||||
const cssOk = fields.cssOk === "0";
|
||||
const appJsOk = fields.appJsOk === "0";
|
||||
const apiHealthOk = fields.apiHealthOk === "0";
|
||||
const readonlyNoteAbsent = fields.readonlyNote === "1";
|
||||
const sidebarFitCss = fields.sidebarFitCss === "0";
|
||||
const workspaceFitCss = fields.workspaceFitCss === "0";
|
||||
const eventPanelFitCss = fields.eventPanelFitCss === "0";
|
||||
const legacyStylesAbsent = fields.legacyStylesAbsent === "0";
|
||||
const reactWorkbenchCss = fields.reactWorkbenchCss === "0";
|
||||
const apiRevision = fields.apiRevision || null;
|
||||
const webChecksPass = htmlOk && cssOk && appJsOk && readonlyNoteAbsent && sidebarFitCss && workspaceFitCss && eventPanelFitCss && apiHealthOk;
|
||||
const webChecksPass = htmlOk && htmlAppScript && htmlCssLink && cssOk && appJsOk && readonlyNoteAbsent && legacyStylesAbsent && reactWorkbenchCss && apiHealthOk;
|
||||
const failedChecks = Object.entries({
|
||||
htmlOk,
|
||||
htmlAppScript,
|
||||
htmlCssLink,
|
||||
cssOk,
|
||||
appJsOk,
|
||||
readonlyNoteAbsent,
|
||||
sidebarFitCss,
|
||||
workspaceFitCss,
|
||||
eventPanelFitCss,
|
||||
legacyStylesAbsent,
|
||||
reactWorkbenchCss,
|
||||
apiHealthOk,
|
||||
}).filter(([, ok]) => !ok).map(([name]) => name);
|
||||
return {
|
||||
ok: commandOk && webChecksPass,
|
||||
summary: commandOk && webChecksPass ? "19666/19667 probes passed" : `19666/19667 probe issues: ${failedChecks.join(", ") || "command failed"}`,
|
||||
summary: commandOk && webChecksPass ? "19666/19667 React/Vite asset probes passed" : `19666/19667 probe issues: ${failedChecks.join(", ") || "command failed"}`,
|
||||
baseUrl: fields.baseUrl || V02_CLOUD_WEB_URL,
|
||||
apiUrl: fields.apiUrl || V02_CLOUD_API_URL,
|
||||
sourceCommit,
|
||||
argoSyncRevision: argoSyncRevision || null,
|
||||
cssPath: fields.cssPath || null,
|
||||
checks: {
|
||||
htmlOk,
|
||||
htmlAppScript,
|
||||
htmlCssLink,
|
||||
cssOk,
|
||||
appJsOk,
|
||||
readonlyNoteAbsent,
|
||||
sidebarFitCss,
|
||||
workspaceFitCss,
|
||||
eventPanelFitCss,
|
||||
legacyStylesAbsent,
|
||||
reactWorkbenchCss,
|
||||
apiHealthOk,
|
||||
},
|
||||
probeExitCodes: {
|
||||
html: numericField(fields.htmlOk),
|
||||
htmlAppScript: numericField(fields.htmlAppScript),
|
||||
htmlCssLink: numericField(fields.htmlCssLink),
|
||||
css: numericField(fields.cssOk),
|
||||
appJs: numericField(fields.appJsOk),
|
||||
readonlyNoteGrep: numericField(fields.readonlyNote),
|
||||
sidebarFitCssGrep: numericField(fields.sidebarFitCss),
|
||||
workspaceFitCssGrep: numericField(fields.workspaceFitCss),
|
||||
eventPanelFitCssGrep: numericField(fields.eventPanelFitCss),
|
||||
legacyStylesAbsent,
|
||||
reactWorkbenchCssGrep: numericField(fields.reactWorkbenchCss),
|
||||
apiHealth: numericField(fields.apiHealthOk),
|
||||
},
|
||||
assetBytes: {
|
||||
css: numericField(fields.cssBytes),
|
||||
appJs: numericField(fields.appJsBytes),
|
||||
},
|
||||
apiRevision,
|
||||
|
||||
Reference in New Issue
Block a user