From d64a32c023ea08a53e6426c97ddd1b117d785ccc Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Thu, 31 Mar 2022 03:13:07 +0200 Subject: [PATCH] Add extractInlineLayer to linting script --- scripts/lint.ts | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/lint.ts b/scripts/lint.ts index 00d2840a7f..ba964fd531 100644 --- a/scripts/lint.ts +++ b/scripts/lint.ts @@ -1,9 +1,10 @@ import ScriptUtils from "./ScriptUtils"; -import {writeFileSync} from "fs"; +import {mkdirSync, writeFileSync} from "fs"; import {FixLegacyTheme, UpdateLegacyLayer} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert"; import Translations from "../UI/i18n/Translations"; import {Translation} from "../UI/i18n/Translation"; import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson"; +import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson"; /* * This script reads all theme and layer files and reformats them inplace @@ -49,11 +50,27 @@ function addArticleToPresets(layerConfig: {presets?: {title: any}[]}){ //*/ } +function extractInlineLayer(theme: LayoutConfigJson){ + for (let i = 0; i < theme.layers.length; i++){ + const layer = theme.layers[i]; + if(typeof layer === "string"){ + continue + } + if(layer["override"] !== undefined){ + continue + } + const l = layer + mkdirSync("./assets/layers/"+l.id) + writeFileSync("./assets/layers/"+l.id+"/"+l.id+".json", JSON.stringify(l, null, " ")) + theme.layers[i] = l.id + } +} + const layerFiles = ScriptUtils.getLayerFiles(); for (const layerFile of layerFiles) { try { const fixed = new UpdateLegacyLayer().convertStrict(layerFile.parsed, "While linting " + layerFile.path); - addArticleToPresets(fixed) + addArticleToPresets(fixed) writeFileSync(layerFile.path, JSON.stringify(fixed, null, " ")) } catch (e) { console.error("COULD NOT LINT LAYER" + layerFile.path + ":\n\t" + e) @@ -69,7 +86,7 @@ for (const themeFile of themeFiles) { addArticleToPresets( layer) } } - + // extractInlineLayer(fixed) writeFileSync(themeFile.path, JSON.stringify(fixed, null, " ")) } catch (e) { console.error("COULD NOT LINT THEME" + themeFile.path + ":\n\t" + e)