s3si.ts/scripts/find-id.ts

35 lines
899 B
TypeScript
Raw Normal View History

2022-10-21 07:37:11 -04:00
import { base64 } from "../deps.ts";
import { FileExporterType } from "../src/exporters/file.ts";
const dirs = Deno.args;
const files: string[] = [];
for (const dir of dirs) {
for await (const entry of Deno.readDir(dir)) {
if (entry.isFile) {
files.push(`${dir}/${entry.name}`);
}
}
}
const ids = new Map<string, string>();
for (const file of files) {
try {
const content: FileExporterType = JSON.parse(await Deno.readTextFile(file));
2022-11-28 08:33:35 -05:00
if (content.type === "SUMMARY") continue;
2022-10-21 07:37:11 -04:00
const id = content.data.detail.id;
2024-01-31 03:08:32 -05:00
const rawId = base64.decodeBase64(id);
2022-10-21 07:37:11 -04:00
const uuid = new TextDecoder().decode(rawId.slice(rawId.length - 36));
if (ids.has(uuid)) {
console.log(
`Duplicate: ${uuid}:${id} in ${file} and ${uuid}:${ids.get(uuid)}`,
);
}
ids.set(uuid, id);
} catch (e) {
console.log("Failed to process file", file, e);
}
}