fix(WP4-07): 兼容迁移后的字体资源路径
Dada P0-A isolated Windows CI / validate-and-package (push) Canceled after 0s
Dada P0-A isolated Windows CI / validate-and-package (push) Canceled after 0s
This commit is contained in:
@@ -228,7 +228,13 @@ function readCsv(tracker: SourceTracker, path: string, label: string): CsvRow[]
|
||||
|
||||
function itemDirectoryFor(collection: CollectionConfig, catalogPath: string, row: CsvRow): { directory: string; metadataPath: string } {
|
||||
if (collection.id === "font_panel") {
|
||||
const resourceDir = requireString(row.resource_dir, "font resource_dir");
|
||||
const configuredResourceDir = requireString(row.resource_dir, "font resource_dir");
|
||||
const normalizedResourceDir = configuredResourceDir.replaceAll("\\", "/");
|
||||
const relocationMarker = "/resources/font_packages/";
|
||||
const markerIndex = normalizedResourceDir.lastIndexOf(relocationMarker);
|
||||
const resourceDir = isAbsolute(configuredResourceDir) && !inside(configuredResourceDir, collection.root.path) && markerIndex >= 0
|
||||
? relativeReference(normalizedResourceDir.slice(markerIndex + 1), "font resource_dir relocation")
|
||||
: configuredResourceDir;
|
||||
const directory = resolveSourcePath(resourceDir, collection.root.path, collection.root.path, "font resource_dir");
|
||||
return { directory, metadataPath: resolveSourcePath("metadata.json", directory, collection.root.path, "font metadata") };
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ if (!existsSync(stickerRoot)) throw new Error("static sticker source is unavaila
|
||||
|
||||
const complexDirectory = resolve(runDirectory, "inputs", "complex");
|
||||
const staticDirectory = resolve(runDirectory, "inputs", "static");
|
||||
const normalizedHandoffDirectory = resolve(runDirectory, "inputs", "normalized-handoff");
|
||||
mkdirSync(whiteDirectory, { recursive: true });
|
||||
mkdirSync(colorDirectory, { recursive: true });
|
||||
|
||||
@@ -41,10 +42,10 @@ const normalizedHandoff = {
|
||||
root: resolve(dirname(handoffManifest), collection.root),
|
||||
})),
|
||||
};
|
||||
const normalizedHandoffPath = resolve(complexDirectory, "sticker_web_catalog_manifest.normalized.json");
|
||||
mkdirSync(complexDirectory, { recursive: true });
|
||||
copyFileSync(resolve(dirname(handoffManifest), sourceHandoff.web_handoff), resolve(complexDirectory, normalizedHandoff.web_handoff));
|
||||
copyFileSync(resolve(dirname(handoffManifest), sourceHandoff.validation), resolve(complexDirectory, normalizedHandoff.validation));
|
||||
const normalizedHandoffPath = resolve(normalizedHandoffDirectory, "sticker_web_catalog_manifest.normalized.json");
|
||||
mkdirSync(normalizedHandoffDirectory, { recursive: true });
|
||||
copyFileSync(resolve(dirname(handoffManifest), sourceHandoff.web_handoff), resolve(normalizedHandoffDirectory, normalizedHandoff.web_handoff));
|
||||
copyFileSync(resolve(dirname(handoffManifest), sourceHandoff.validation), resolve(normalizedHandoffDirectory, normalizedHandoff.validation));
|
||||
writeFileSync(normalizedHandoffPath, `${JSON.stringify(normalizedHandoff, null, 2)}\n`);
|
||||
|
||||
const complex = compileAssetArchive({
|
||||
|
||||
@@ -190,6 +190,27 @@ describe("TDD-WP5-MAN-001 readonly asset compiler", () => {
|
||||
expect(repeated.report.derived_files).toEqual({ created: 0, reused: 4, total: 4 });
|
||||
});
|
||||
|
||||
it("safely relocates legacy absolute font package paths after an archive move", () => {
|
||||
const fixture = createFixture();
|
||||
const catalogPath = join(fixture.sourceRoot, "fonts", "reports", "font_panel_catalog.csv");
|
||||
const metadata = JSON.parse(readFileSync(join(fixture.sourceRoot, "fonts", "resources", "font_packages", "FONT001_Test", "metadata.json"), "utf8")) as { local_sha256: string };
|
||||
csv(catalogPath, [{
|
||||
candidate_id: "FONT001",
|
||||
display_name: "Test Font",
|
||||
font_family: "Dada Test",
|
||||
local_sha256: metadata.local_sha256,
|
||||
panel_order: "1",
|
||||
resource_dir: "C:/Users/legacy/Desktop/sticker_text/fonts/resources/font_packages/FONT001_Test",
|
||||
resource_status: "verified_extracted",
|
||||
}]);
|
||||
|
||||
expect(() => compileAssetArchive({
|
||||
manifestPath: fixture.manifestPath,
|
||||
outputDirectory: fixture.outputRoot,
|
||||
releaseVersion: "fixture-v1",
|
||||
})).not.toThrow();
|
||||
});
|
||||
|
||||
it("rejects evidence collections, traversal and output inside a source root", () => {
|
||||
const fixture = createFixture();
|
||||
const manifest = JSON.parse(readFileSync(fixture.manifestPath, "utf8")) as { collections: unknown[] };
|
||||
|
||||
Reference in New Issue
Block a user