36 lines
1.7 KiB
TypeScript
36 lines
1.7 KiB
TypeScript
export function renderFeatureConfigSchemaLine(value: unknown): string {
|
|
const featureConfigSchema = record(value);
|
|
return ` feature-config-schema: warning=${boolText(featureConfigSchema.warning)} blocking=${boolText(featureConfigSchema.blocking)} code=${stringValue(featureConfigSchema.code)} path=${stringValue(featureConfigSchema.schemaPath)} errors=${stringValue(featureConfigSchema.errorCount)} first=${compactLine(stringValue(featureConfigSchema.firstError))}`;
|
|
}
|
|
|
|
export function featureConfigSchemaHistoryFields(value: unknown): string[][] {
|
|
const featureConfigSchema = record(value);
|
|
return [
|
|
["featureConfigWarning", stringValue(featureConfigSchema.warning)],
|
|
["featureConfigBlocking", stringValue(featureConfigSchema.blocking)],
|
|
["featureConfigCode", stringValue(featureConfigSchema.code)],
|
|
["featureConfigSchemaPath", stringValue(featureConfigSchema.schemaPath)],
|
|
["featureConfigErrorCount", stringValue(featureConfigSchema.errorCount)],
|
|
["featureConfigFirstError", compactLine(stringValue(featureConfigSchema.firstError))],
|
|
];
|
|
}
|
|
|
|
function record(value: unknown): Record<string, unknown> {
|
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : {};
|
|
}
|
|
|
|
function stringValue(value: unknown, fallback = "-"): string {
|
|
if (typeof value === "string" && value.length > 0) return value;
|
|
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
return fallback;
|
|
}
|
|
|
|
function boolText(value: unknown): string {
|
|
return value === true ? "true" : "false";
|
|
}
|
|
|
|
function compactLine(value: string): string {
|
|
const trimmed = value.replace(/\s+/gu, " ").trim();
|
|
return trimmed.length > 0 ? trimmed.slice(0, 120) : "-";
|
|
}
|