import { execFile } from 'child_process'; import { getChangedThemes } from './deploy-utils.mjs'; export async function checkStrictTypesToChangedThemes() { const changedThemes = await getChangedThemes(); let themesProcessed = 0; let hasErrors = false; console.log('Checking strict types in changed themes...'); for (let theme of changedThemes) { execFile( 'sh', ['.theme-utils/check-strict-types.sh', theme], (error, stdout) => { // Display any output from the script (missing files) if (stdout.trim()) { console.log(stdout.trim()); } // error will be non-null if the script exited with code 1 if (error) { hasErrors = true; } else { console.log(`✓ ${theme}: All PHP files have strict types declarations`); } themesProcessed++; if (themesProcessed === changedThemes.length) { if (hasErrors) { console.error('\nSome themes have files missing strict types declarations. Please fix them before deploying and try again. If you want to skip this check, add -- --skip-strict-types after your deploy command.'); console.log('\nFor more information, read: https://wp.me/PNEWy-iG6'); process.exit(1); } else { console.log('\nAll changed themes have proper strict types declarations! ✨'); } } } ); } }