private static function discoverPackages(string $vendorPath, string $manifestPath): void
    {
        $installedPackages = [];
        if (file_exists($path = $vendorPath . '/composer/installed.json')) {
            $installedPackages = json_decode(file_get_contents($path), true);
        }

        $discoverPackages = [];
        foreach ($installedPackages as $package) {
            if (! empty($package['extra']['chiron'])) {
                $packageInfo = $package['extra']['chiron'];
                $discoverPackages[$package['name']] = $packageInfo;
            }
        }

        if (! is_writable(dirname($manifestPath))) {
            throw new \RuntimeException('The directory "' . dirname($manifestPath) . '" must be present and writable.');
        }

        file_put_contents($manifestPath, '<?php return ' . var_export($discoverPackages, true) . ';');
    }