import { resolve , dirname } from 'node:path' ; import prism from 'prism-media' ; /**
 * Generates a report of the dependencies used by the \@discordjs/voice module.
 * Useful for debugging.
 */ export function generateDependencyReport ( ) { const report = [ ] ; const addVersion = ( name ) => report . push ( `- ${ name }: ${ version ( name ) }` ) ; report . push ( 'Core Dependencies' ) ; addVersion ( '@discordjs/voice' ) ; addVersion ( 'prism-media' ) ; report . push ( '' ) ; report . push ( 'Opus Libraries' ) ; addVersion ( '@discordjs/opus' ) ; addVersion ( 'opusscript' ) ; report . push ( '' ) ; report . push ( 'Encryption Libraries' ) ; addVersion ( 'sodium' ) ; addVersion ( 'libsodium-wrappers' ) ; addVersion ( 'tweetnacl' ) ; report . push ( '' ) ; report . push ( 'FFmpeg' ) ; try { const info = prism . FFmpeg . getInfo ( ) ; report . push ( `- version: ${ info . version }` ) ; report . push ( `- libopus: ${ info . output . includes ( '--enable-libopus' ) ? 'yes' : 'no' }` ) ; } catch ( err ) { report . push ( '- not found' ) ; } return [ '-' . repeat ( 50 ) , ... report , '-' . repeat ( 50 ) ] . join ( '\n' ) ; } param dir param packageName param depth function findPackageJSON ( dir , packageName , depth ) { if ( depth === 0 ) return undefined ; const attemptedPath = resolve ( dir , './package.json' ) ; try { const pkg = require ( attemptedPath ) ; if ( pkg . name !== packageName ) throw new Error ( 'package.json does not match' ) ; return pkg ; } catch ( err ) { return findPackageJSON ( resolve ( dir , '..' ) , packageName , depth - 1 ) ; } } param name function version ( name ) { try { const pkg = name === '@discordjs/voice' ? require ( '../../package.json' ) : findPackageJSON ( dirname ( require . resolve ( name ) ) , name , 3 ) ; return pkg ?. version ?? 'not found' ; } catch ( err ) { return 'not found' ; } }