| 157 | output: { |
| 158 | file: path.join(thirdPartyDir, 'THIRD_PARTY_NOTICES'), |
| 159 | template(dependencies) { |
| 160 | for (const dependency of dependencies) { |
| 161 | const key = `${dependency.name}:${dependency.version}`; |
| 162 | seenDependencies.set(key, dependency); |
| 163 | } |
| 164 | |
| 165 | const stringifiedDependencies = Array.from( |
| 166 | seenDependencies.values(), |
| 167 | ).map(dependency => { |
| 168 | let arr = []; |
| 169 | arr.push(`Name: ${dependency.name ?? 'N/A'}`); |
| 170 | let url = dependency.homepage ?? dependency.repository; |
| 171 | if (url !== null && typeof url !== 'string') { |
| 172 | url = url.url; |
| 173 | } |
| 174 | arr.push(`URL: ${url ?? 'N/A'}`); |
| 175 | arr.push(`Version: ${dependency.version ?? 'N/A'}`); |
| 176 | arr.push(`License: ${dependency.license ?? 'N/A'}`); |
| 177 | if (dependency.licenseText !== null) { |
| 178 | arr.push(''); |
| 179 | arr.push(dependency.licenseText.replaceAll('\r', '')); |
| 180 | } |
| 181 | return arr.join('\n'); |
| 182 | }); |
| 183 | |
| 184 | // Manual license handling for chrome-devtools-frontend third_party |
| 185 | const tsConfig = JSON.parse( |
| 186 | fs.readFileSync( |
| 187 | path.join(process.cwd(), 'tsconfig.json'), |
| 188 | 'utf-8', |
| 189 | ), |
| 190 | ); |
| 191 | const thirdPartyDirectories = tsConfig.include.filter(location => |
| 192 | location.includes( |
| 193 | 'node_modules/chrome-devtools-frontend/front_end/third_party', |
| 194 | ), |
| 195 | ); |
| 196 | |
| 197 | const manualLicenses = []; |
| 198 | // Add chrome-devtools-frontend main license |
| 199 | const cdtfLicensePath = path.join( |
| 200 | process.cwd(), |
| 201 | 'node_modules/chrome-devtools-frontend/LICENSE', |
| 202 | ); |
| 203 | if (fs.existsSync(cdtfLicensePath)) { |
| 204 | manualLicenses.push( |
| 205 | [ |
| 206 | 'Name: chrome-devtools-frontend', |
| 207 | 'License: Apache-2.0', |
| 208 | '', |
| 209 | fs.readFileSync(cdtfLicensePath, 'utf-8'), |
| 210 | ].join('\n'), |
| 211 | ); |
| 212 | } |
| 213 | |
| 214 | // Add chrome-devtools-frontend main license |
| 215 | const lighthouseLicensePath = path.join( |
| 216 | process.cwd(), |