diff --git a/.gitignore b/.gitignore index ca48f09..2a025c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -*.json +profile.json .vscode/ export/ cache/ diff --git a/deno.json b/deno.json new file mode 100644 index 0000000..7086295 --- /dev/null +++ b/deno.json @@ -0,0 +1,19 @@ +{ + "tasks": { + "check": "deno check s3si.ts", + "fmt": "deno fmt", + "fmt:check": "deno fmt --check", + "lint": "deno lint", + "run": "deno run -A" + }, + "fmt": { + "files": { + "exclude": [ + "export/", + "cache/", + ".vscode/", + "profile.json" + ] + } + } +} diff --git a/scripts/find-id.ts b/scripts/find-id.ts new file mode 100644 index 0000000..3255a30 --- /dev/null +++ b/scripts/find-id.ts @@ -0,0 +1,33 @@ +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(); + +for (const file of files) { + try { + const content: FileExporterType = JSON.parse(await Deno.readTextFile(file)); + const id = content.data.detail.id; + const rawId = base64.decode(id); + 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); + } +} diff --git a/src/exporters/file.ts b/src/exporters/file.ts index eff1b1f..c6f96d9 100644 --- a/src/exporters/file.ts +++ b/src/exporters/file.ts @@ -2,7 +2,7 @@ import { BattleExporter, VsBattle } from "../types.ts"; import { base64, path } from "../../deps.ts"; import { NSOAPP_VERSION, S3SI_VERSION } from "../constant.ts"; -type FileExporterType = { +export type FileExporterType = { type: "VS" | "COOP"; nsoVersion: string; s3siVersion: string;