(int: IntegrationWithSource)
| 91 | |
| 92 | // Build injection patterns from integrations (for source files) |
| 93 | function integrationInjections(int: IntegrationWithSource): Array<Injection> { |
| 94 | const source = { sourceId: int._sourceId, sourceName: int._sourceName } |
| 95 | const injections: Array<Injection> = [] |
| 96 | |
| 97 | const appliesTo = (path: string) => { |
| 98 | if (int.type === 'vite-plugin') return path.includes('vite.config') |
| 99 | if ( |
| 100 | int.type === 'provider' || |
| 101 | int.type === 'root-provider' || |
| 102 | int.type === 'devtools' |
| 103 | ) { |
| 104 | return path.includes('__root') || path.includes('root.tsx') |
| 105 | } |
| 106 | return false |
| 107 | } |
| 108 | |
| 109 | if (int.import) { |
| 110 | const prefix = int.import.split(' from ')[0] |
| 111 | injections.push({ |
| 112 | matches: (line) => line.includes(prefix), |
| 113 | appliesTo, |
| 114 | source, |
| 115 | }) |
| 116 | } |
| 117 | |
| 118 | const code = int.code || int.jsName |
| 119 | if (code) { |
| 120 | injections.push({ |
| 121 | matches: (line) => line.includes(code), |
| 122 | appliesTo, |
| 123 | source, |
| 124 | }) |
| 125 | } |
| 126 | |
| 127 | return injections |
| 128 | } |
| 129 | |
| 130 | // Build injection pattern from a dependency (for package.json) |
| 131 | function dependencyInjection(dep: DependencyAttribution): Injection { |
nothing calls this directly
no outgoing calls
no test coverage detected