diff --git a/scripts/check-native-shells.mjs b/scripts/check-native-shells.mjs index 4e40a4f20..3830782d4 100644 --- a/scripts/check-native-shells.mjs +++ b/scripts/check-native-shells.mjs @@ -14,13 +14,11 @@ const developmentWorkflowDocPath = 'docs/project-memory/shared-memory/development-workflow.md'; const decisionLogDocPath = 'docs/project-memory/shared-memory/decision-log.md'; const rootPackageJson = JSON.parse(fs.readFileSync('package.json', 'utf8')); -const mobileShellConfigCheckSource = fs.readFileSync( - 'apps/mobile-shell/scripts/check-config.mjs', - 'utf8', +const mobileShellConfigCheckSource = normalizeSourceForGuardrail( + fs.readFileSync('apps/mobile-shell/scripts/check-config.mjs', 'utf8'), ); -const desktopShellConfigCheckSource = fs.readFileSync( - 'apps/desktop-shell/scripts/check-config.mjs', - 'utf8', +const desktopShellConfigCheckSource = normalizeSourceForGuardrail( + fs.readFileSync('apps/desktop-shell/scripts/check-config.mjs', 'utf8'), ); const aiGameCreatorShellAppSource = fs.readFileSync( 'apps/ai-game-creator-shell/src/App.tsx', @@ -152,6 +150,14 @@ function readSourceTree(entryPath, extension) { return fs.readFileSync(entryPath, 'utf8'); } +function normalizeSourceForGuardrail(source) { + return source + .replace(/\s+/g, ' ') + .replace(/\s*([(),])\s*/g, '$1') + .replace(/,\s*\)/g, ')') + .trim(); +} + function assertRootNativeShellCheckScripts() { if ( rootPackageJson.scripts?.['check:native-shells'] !== @@ -187,7 +193,11 @@ function assertNativeShellDependencyVersionGuardrails() { "'eas-cli': '^20.3.0'", "assertPackageLockVersion('apps/mobile-shell', 'eas-cli', '20.3.0')", ]) { - if (!mobileShellConfigCheckSource.includes(snippet)) { + if ( + !mobileShellConfigCheckSource.includes( + normalizeSourceForGuardrail(snippet), + ) + ) { throw new Error( `mobile shell dependency guardrail drifted: missing ${snippet}`, ); @@ -211,7 +221,11 @@ function assertNativeShellDependencyVersionGuardrails() { "['tauri', '2.11.2']", 'tauri-plugin-single-instance = { version = "2.4.2", features = ["deep-link"] }', ]) { - if (!desktopShellConfigCheckSource.includes(snippet)) { + if ( + !desktopShellConfigCheckSource.includes( + normalizeSourceForGuardrail(snippet), + ) + ) { throw new Error( `desktop shell dependency guardrail drifted: missing ${snippet}`, );