chore: automated housekeeping...

This commit is contained in:
Pieter Vander Vennet 2025-07-10 18:26:31 +02:00
parent a190597905
commit 087e639020
382 changed files with 29496 additions and 2675 deletions

View file

@ -29,7 +29,7 @@ class SubstituteLayer extends Conversion<string | LayerConfigJson, LayerConfigJs
constructor(state: DesugaringContext) {
super(
"SubstituteLayer",
"Converts the identifier of a builtin layer into the actual layer, or converts a 'builtin' syntax with override in the fully expanded form. Note that 'tagRenderings+' will be inserted before 'leftover-questions'",
"Converts the identifier of a builtin layer into the actual layer, or converts a 'builtin' syntax with override in the fully expanded form. Note that 'tagRenderings+' will be inserted before 'leftover-questions'"
)
this._state = state
}
@ -72,8 +72,16 @@ class SubstituteLayer extends Conversion<string | LayerConfigJson, LayerConfigJs
for (const name of names) {
const found = Utils.Clone(state.sharedLayers.get(name))
if (found === undefined) {
const nearbyNames = Utils.sortedByLevenshteinDistance(name, Array.from(state.sharedLayers.keys()))
context.err("Layer with name " + name + " not found. Dit you mean one of "+nearbyNames.slice(0, 3))
const nearbyNames = Utils.sortedByLevenshteinDistance(
name,
Array.from(state.sharedLayers.keys())
)
context.err(
"Layer with name " +
name +
" not found. Dit you mean one of " +
nearbyNames.slice(0, 3)
)
reportNotFound(name)
continue
}
@ -504,7 +512,7 @@ class WarnForUnsubstitutedLayersInTheme extends DesugaringStep<ThemeConfigJson>
if (layer["builtin"] !== undefined) {
continue
}
if(layer["override"]!==undefined){
if (layer["override"] !== undefined) {
context.err("Got an `override` block without a `builtin`-specification")
continue
}
@ -603,8 +611,7 @@ class PostvalidateTheme extends DesugaringStep<ThemeConfigJson> {
return json
}
}
export class OrderTheme extends DesugaringStep<ThemeConfigJson>{
export class OrderTheme extends DesugaringStep<ThemeConfigJson> {
private static readonly themeAttributesOrder: ReadonlyArray<string> = Utils.Dedup(
(<ConfigMeta[]>themeconfig).filter((c) => c.path.length === 1).map((c) => c.path[0])
)
@ -622,7 +629,10 @@ class DeriveDescription extends DesugaringStep<ThemeConfigJson> {
private readonly _key: string
private readonly _sourceKey: "name"
constructor(key: "icon" | "description" | "title", sourceKey?: "name") {
super("DeriveDescription", "If a single layer and no description is given, steal the description from the layer")
super(
"DeriveDescription",
"If a single layer and no description is given, steal the description from the layer"
)
this._key = key
this._sourceKey = sourceKey
}
@ -631,11 +641,15 @@ class DeriveDescription extends DesugaringStep<ThemeConfigJson> {
if (json[this._key]) {
return json
}
const msg = "This theme has no "+this._key+". If there is only a single layer, we can steal it from this layer though. Current layers are "+json.layers.map(l => l["id"]).join("; ")
const msg =
"This theme has no " +
this._key +
". If there is only a single layer, we can steal it from this layer though. Current layers are " +
json.layers.map((l) => l["id"]).join("; ")
if (json.layers.length !== 1) {
context.err(msg)
}
const l = <LayerConfigJson> json.layers[0] // Already expanded
const l = <LayerConfigJson>json.layers[0] // Already expanded
context.info(`Added '${this._key}' to theme ${json.id} based on single layer`)
return {
...json,
@ -659,9 +673,9 @@ export class PrepareTheme extends Fuse<ThemeConfigJson> {
new PreparePersonalTheme(state),
new WarnForUnsubstitutedLayersInTheme(),
new On("layers", new Concat(new SubstituteLayer(state))),
new DeriveDescription( "description"),
new DeriveDescription( "icon"),
new DeriveDescription( "title", "name"),
new DeriveDescription("description"),
new DeriveDescription("icon"),
new DeriveDescription("title", "name"),
new SetDefault("socialImage", "assets/SocialImage.png", true),
// We expand all tagrenderings first...