| 1 |
"use strict"; |
| 2 |
|
| 3 |
// NOTE: This script must be run _after_ build-data.js |
| 4 |
|
| 5 |
const path = require("path"); |
| 6 |
|
| 7 |
const { |
| 8 |
generateData, |
| 9 |
environments, |
| 10 |
writeFile, |
| 11 |
defineLegacyPluginAliases, |
| 12 |
} = require("./utils-build-data"); |
| 13 |
|
| 14 |
const pluginBugfixes = require("./data/plugin-bugfixes"); |
| 15 |
const pluginFeatures = require("./data/plugin-features"); |
| 16 |
|
| 17 |
const { data: dataWithBugfixes, overlapping } = generateData( |
| 18 |
environments, |
| 19 |
Object.assign({}, pluginBugfixes, pluginFeatures) |
| 20 |
); |
| 21 |
|
| 22 |
const dataWithoutBugfixes = require("../data/plugins.json"); |
| 23 |
|
| 24 |
for (const [key, support] of Object.entries(dataWithBugfixes)) { |
| 25 |
const originalSupport = dataWithoutBugfixes[key]; |
| 26 |
if ( |
| 27 |
originalSupport && |
| 28 |
Object.keys(support).length === Object.keys(originalSupport).length && |
| 29 |
Object.keys(support).every(env => support[env] === originalSupport[env]) |
| 30 |
) { |
| 31 |
// The data with and without bugfixes is the same; we can avoid saving it twice. |
| 32 |
delete dataWithBugfixes[key]; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
for (const [filename, data] of [ |
| 37 |
["plugin-bugfixes", dataWithBugfixes], |
| 38 |
["overlapping-plugins", overlapping], |
| 39 |
]) { |
| 40 |
const dataPath = path.join(__dirname, `../data/${filename}.json`); |
| 41 |
|
| 42 |
if (!writeFile(defineLegacyPluginAliases(data), dataPath, filename)) { |
| 43 |
process.exitCode = 1; |
| 44 |
break; |
| 45 |
} |
| 46 |
} |