diff --git a/apps/desktop-shell/scripts/check-config.mjs b/apps/desktop-shell/scripts/check-config.mjs index dbdef848b..e3d46e2c0 100644 --- a/apps/desktop-shell/scripts/check-config.mjs +++ b/apps/desktop-shell/scripts/check-config.mjs @@ -1005,7 +1005,7 @@ function extractStringArrayExport(source, exportName, seen = new Set()) { } const match = source.match( - new RegExp(`export const ${exportName}[^=]*= \\[([\\s\\S]*?)\\][^;]*;`), + new RegExp(`export const ${exportName}[^=]*=\\s*\\[([\\s\\S]*?)\\][^;]*;`), ); if (!match) { throw new Error(`unable to read ${exportName}`); diff --git a/apps/mobile-shell/scripts/check-config.mjs b/apps/mobile-shell/scripts/check-config.mjs index c9d812194..7e2ac1249 100644 --- a/apps/mobile-shell/scripts/check-config.mjs +++ b/apps/mobile-shell/scripts/check-config.mjs @@ -479,7 +479,7 @@ function extractStringArrayExport(source, exportName, seen = new Set()) { } const match = source.match( - new RegExp(`export const ${exportName}[^=]*= \\[([\\s\\S]*?)\\][^;]*;`), + new RegExp(`export const ${exportName}[^=]*=\\s*\\[([\\s\\S]*?)\\][^;]*;`), ); if (!match) { throw new Error(`unable to read ${exportName}`); @@ -499,6 +499,18 @@ function extractStringArrayExport(source, exportName, seen = new Set()) { return entries; } +function sourceIncludes(source, snippet) { + if (source.includes(snippet)) { + return true; + } + const compact = (value) => + value + .replace(/\s+/g, ' ') + .replace(/\s*([()[\]{}])\s*/g, '$1') + .replace(/,\)/g, ')'); + return compact(source).includes(compact(snippet)); +} + function extractStringConstExport(source, exportName) { const match = source.match( new RegExp(`export const ${exportName}\\s*=\\s*'([^']+)';`), @@ -1844,7 +1856,8 @@ for (const snippet of [ 'thirdPartyCookiesEnabled={false}', 'sharedCookiesEnabled={false}', 'webviewDebuggingEnabled={false}', - 'injectedJavaScriptBeforeContentLoaded={MOBILE_WEBVIEW_BEFORE_CONTENT_SCRIPT}', + 'injectedJavaScriptBeforeContentLoaded={', + 'MOBILE_WEBVIEW_BEFORE_CONTENT_SCRIPT', 'handleBlockedFileDownload', 'logMobileShellDownloadBlocked(event)', 'onFileDownload={handleBlockedFileDownload}', @@ -1853,7 +1866,7 @@ for (const snippet of [ 'mobile shell navigation failed for', 'external_navigation.open', ]) { - if (!shellAppSource.includes(snippet)) { + if (!sourceIncludes(shellAppSource, snippet)) { throw new Error(`mobile shell ShellApp missing ${snippet}`); } } @@ -3056,7 +3069,8 @@ if ( !hapticsSource.includes( '(request.payload as HapticsImpactPayload | undefined)?.style', ) || - !hapticsSource.includes( + !sourceIncludes( + hapticsSource, "invalidRequest('haptics impact style must be light, medium, or heavy')", ) || !hapticsSource.includes('Haptics.ImpactFeedbackStyle.Heavy') || @@ -3317,7 +3331,7 @@ for (const snippet of [ "not.toContain('app.setBadgeCount')", "expect(getMobileRuntimePlatform()).toBe('android')", ]) { - if (!hostBridgeRuntimeTestSource.includes(snippet)) { + if (!sourceIncludes(hostBridgeRuntimeTestSource, snippet)) { throw new Error(`mobile shell runtime tests missing ${snippet}`); } } @@ -3423,7 +3437,7 @@ for (const snippet of [ "not.toContain('auth.requestLogin')", "not.toContain('payment.request')", ]) { - if (!capabilitiesTestSource.includes(snippet)) { + if (!sourceIncludes(capabilitiesTestSource, snippet)) { throw new Error(`mobile shell capability profile test missing ${snippet}`); } }