| 
									
										
										
										
											2023-12-20 17:09:58 +08:00
										 |  |  | const fs = require('fs'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-07-11 17:38:43 +08:00
										 |  |  | const printAffectedPluginsSection = require('./levitate-show-affected-plugins'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-20 17:09:58 +08:00
										 |  |  | const data = JSON.parse(fs.readFileSync('data.json', 'utf8')); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-08 20:52:02 +08:00
										 |  |  | const isFork = Boolean(process.env.IS_FORK || false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 16:19:30 +08:00
										 |  |  | function stripAnsi(str) { | 
					
						
							|  |  |  |   return str.replace(/\x1b\[[0-9;]*m/g, ''); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-12-20 17:09:58 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | const printSection = (title, items) => { | 
					
						
							| 
									
										
										
										
											2023-12-20 20:40:47 +08:00
										 |  |  |   let output = `<h4>${title}</h4>`; | 
					
						
							| 
									
										
										
										
											2023-12-20 17:09:58 +08:00
										 |  |  |   items.forEach((item) => { | 
					
						
							| 
									
										
										
										
											2023-12-20 20:40:47 +08:00
										 |  |  |     const language = item.declaration ? 'typescript' : 'diff'; | 
					
						
							|  |  |  |     const code = item.declaration ? item.declaration : stripAnsi(item.diff); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 16:19:30 +08:00
										 |  |  |     output += `<b>${item.name}</b><br>\n`; | 
					
						
							|  |  |  |     output += `<sub>${item.location}</sub><br>\n`; | 
					
						
							|  |  |  |     output += `<pre lang="${language}">\n${code}\n</pre><br>\n`; | 
					
						
							| 
									
										
										
										
											2023-12-20 17:09:58 +08:00
										 |  |  |   }); | 
					
						
							|  |  |  |   return output; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let markdown = ''; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (data.removals.length > 0) { | 
					
						
							|  |  |  |   markdown += printSection('Removals', data.removals); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | if (data.changes.length > 0) { | 
					
						
							|  |  |  |   markdown += printSection('Changes', data.changes); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-08 20:52:02 +08:00
										 |  |  | // The logic below would need access to secrets for accessing BigQuery, however that's not available on forks.
 | 
					
						
							|  |  |  | if ((data.removals.length > 0 || data.changes.length > 0) && !isFork) { | 
					
						
							| 
									
										
										
										
											2024-08-08 17:20:58 +08:00
										 |  |  |   markdown += printAffectedPluginsSection(data); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-11 17:38:43 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-20 17:09:58 +08:00
										 |  |  | console.log(markdown); |