mapcomplete/scripts/lint.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-09-26 18:21:29 +02:00
import ScriptUtils from "./ScriptUtils";
import {writeFileSync} from "fs";
2021-12-21 18:35:31 +01:00
import {FixLegacyTheme, UpdateLegacyLayer} from "../Models/ThemeConfig/LegacyJsonConvert";
2021-09-26 18:21:29 +02:00
/*
* This script reads all theme and layer files and reformats them inplace
* Use with caution, make a commit beforehand!
2021-09-26 19:56:40 +02:00
*/
const layerFiles = ScriptUtils.getLayerFiles();
for (const layerFile of layerFiles) {
2021-11-21 03:48:05 +01:00
try {
2022-01-26 21:40:38 +01:00
const state: any = undefined; // FIXME
const fixed = new UpdateLegacyLayer().convertStrict(state, layerFile.parsed, "While linting " + layerFile.path);
2021-12-21 18:35:31 +01:00
writeFileSync(layerFile.path, JSON.stringify(fixed, null, " "))
2021-11-21 03:48:05 +01:00
} catch (e) {
console.error("COULD NOT LINT LAYER" + layerFile.path + ":\n\t" + e)
}
2021-09-26 19:56:40 +02:00
}
2021-09-26 19:59:51 +02:00
2021-09-26 19:56:40 +02:00
const themeFiles = ScriptUtils.getThemeFiles()
for (const themeFile of themeFiles) {
2021-11-21 03:48:05 +01:00
try {
2022-01-26 21:40:38 +01:00
const state: any = undefined; // FIXME
const fixed = new FixLegacyTheme().convertStrict(state, themeFile.parsed, "While linting " + themeFile.path);
2021-12-21 18:35:31 +01:00
writeFileSync(themeFile.path, JSON.stringify(fixed, null, " "))
2021-11-21 03:48:05 +01:00
} catch (e) {
console.error("COULD NOT LINT THEME" + themeFile.path + ":\n\t" + e)
}
2021-09-26 19:58:11 +02:00
}