feat: add find-id

main
spacemeowx2 2022-10-21 19:37:11 +08:00
parent 03166a3e19
commit 3ddf181560
4 changed files with 54 additions and 2 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
*.json
profile.json
.vscode/
export/
cache/

19
deno.json Normal file
View File

@ -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"
]
}
}
}

33
scripts/find-id.ts Normal file
View File

@ -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<string, string>();
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);
}
}

View File

@ -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;