feat: complete TASK-WP5-03 asset allowlist
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 1m5s
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 1m5s
This commit is contained in:
@@ -5,6 +5,7 @@ import { isAbsolute, dirname, join, relative, resolve, sep } from "node:path";
|
||||
import { parse } from "csv-parse/sync";
|
||||
|
||||
import type { StaticStickerCatalog, StaticStickerCatalogItem } from "@dada/static-sticker-catalog";
|
||||
import { P0A_TEXT_TEMPLATE_IDS } from "@dada/template-registry";
|
||||
|
||||
type JsonObject = Record<string, unknown>;
|
||||
type CsvRow = Record<string, string>;
|
||||
@@ -487,6 +488,24 @@ export function compileAssetArchive(options: AssetCompilerOptions): AssetCompile
|
||||
ids.add(entry.canonical_id);
|
||||
}
|
||||
|
||||
const fontPanelIdBySha256 = new Map<string, string>();
|
||||
for (const entry of entries.filter((item) => item.collection_id === "font_panel")) {
|
||||
const value = entry.metadata.local_sha256;
|
||||
if (typeof value === "string" && /^[0-9a-f]{64}$/i.test(value)) fontPanelIdBySha256.set(value.toUpperCase(), entry.canonical_id);
|
||||
}
|
||||
const p0aTextIds = new Set<string>(P0A_TEXT_TEMPLATE_IDS);
|
||||
const fontRegistrations = new Map<string, { panelIds: string[]; sha256s: string[] }>();
|
||||
for (const entry of entries.filter((item) => item.collection_id === "text_templates" && p0aTextIds.has(item.canonical_id))) {
|
||||
const references = collectFiles(entry.metadata, ["fonts"], `${entry.canonical_id}.fonts`);
|
||||
const sha256s = references.map((reference) => {
|
||||
const path = resolveSourcePath(reference, entry.item_directory, entry.collection_root, `${entry.canonical_id} font`);
|
||||
return sha256(tracker.read(path, `${entry.canonical_id} font`));
|
||||
});
|
||||
const panelIds = [...new Set(sha256s.map((hash) => fontPanelIdBySha256.get(hash)).filter((id): id is string => id !== undefined))]
|
||||
.sort((left, right) => Number(left.slice(4)) - Number(right.slice(4)));
|
||||
fontRegistrations.set(entry.canonical_id, { panelIds, sha256s });
|
||||
}
|
||||
|
||||
const outputDirectory = resolve(options.outputDirectory);
|
||||
const outputRoots = [manifestDirectory, ...roots.roots.map((item) => item.path)];
|
||||
if (outputRoots.some((root) => inside(outputDirectory, root))) throw new Error("output directory is inside a source root");
|
||||
@@ -527,6 +546,12 @@ export function compileAssetArchive(options: AssetCompilerOptions): AssetCompile
|
||||
};
|
||||
if (entry.metadata.default_text !== undefined || entry.row.default_text !== undefined) item.default_text = entry.metadata.default_text ?? entry.row.default_text ?? "";
|
||||
if (defaultFont) item.default_font_reference = relativeReference(defaultFont, "default font");
|
||||
const fontRegistration = fontRegistrations.get(entry.canonical_id);
|
||||
if (fontRegistration) {
|
||||
item.font_panel_references = fontRegistration.panelIds;
|
||||
item.font_resource_sha256s = fontRegistration.sha256s;
|
||||
}
|
||||
if (entry.collection_id === "font_panel" && typeof entry.metadata.local_sha256 === "string") item.source_sha256 = entry.metadata.local_sha256.toUpperCase();
|
||||
if (preview) item.preview_reference = relativeReference(preview, "preview");
|
||||
if (typeof runtime.stable_style_id === "string") item.renderer_id = runtime.stable_style_id;
|
||||
return item;
|
||||
|
||||
Reference in New Issue
Block a user