$digest) { $verify($root, $file, $digest, ($manifest['source_eol'] ?? 'exact') === 'lf' && ! in_array($file, $manifest['exact_source_files'] ?? [], true)); } $compiled = in_array('--compiled', $arguments, true) || in_array('--installed', $arguments, true); if ($compiled) { $verify($root, 'public/build/manifest.json', $manifest['frontend']['manifest_sha256']); if (isset($manifest['frontend']['fonts_manifest_sha256'])) { $verify($root, 'public/build/fonts-manifest.json', $manifest['frontend']['fonts_manifest_sha256']); } foreach ($manifest['frontend']['files'] as $file => $digest) { $verify($root.'/public/build', $file, $digest); } } if (in_array('--installed', $arguments, true)) { $settings = parse_ini_file($root.'/.env', false, INI_SCANNER_RAW); if (! is_array($settings) || ($settings['COMPRAS_RUNTIME_ENABLED'] ?? null) !== 'true') { throw new LogicException('Integrated Compras runtime is not selected.'); } foreach ($manifest['components'] as $component) { $componentRoot = realpath($settings[$component['setting']] ?? ''); if ($componentRoot === false) { throw new LogicException('Selected component unavailable.'); } $verify($componentRoot, 'manifest.json', $component['manifest_sha256']); $componentBytes = file_get_contents($componentRoot.'/manifest.json'); if (! is_string($componentBytes)) { throw new LogicException('Component manifest unreadable.'); } $componentManifest = json_decode($componentBytes, true, 512, JSON_THROW_ON_ERROR); foreach ($componentManifest['files'] as $key => $entry) { if (is_array($entry)) { $verify($componentRoot, $entry['file'], $entry['sha256']); } else { $verify($componentRoot, $key, $entry); } } } } echo json_encode(['state' => 'passed', 'product' => 'compras', 'release_id' => $manifest['release_id'], 'source_files' => count($manifest['source_files']), 'asset_files' => $compiled ? count($manifest['frontend']['files']) : 0, 'installed_components' => in_array('--installed', $arguments, true) ? count($manifest['components']) : 0], JSON_THROW_ON_ERROR).PHP_EOL; } catch (Throwable $error) { fwrite(STDERR, $error->getMessage().PHP_EOL); exit(1); }