/** * @copyright NHCarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { writeFile } from "node:fs/promises"; import { join } from "node:path"; import { getFiles } from "./utils/getFiles.js"; import { getStrings } from "./utils/getStrings.js"; const projectId = process.env.CROWDIN_PROJECT_ID; const apiUrl = process.env.CROWDIN_API_URL; const token = process.env.CROWDIN_TOKEN; if ( projectId === undefined || projectId === "" || apiUrl === undefined || apiUrl === "" || token === undefined || token === "" ) { throw new Error(`Project ID or API URL is missing! Did you run this script with 'op run'?`); } const files = await getFiles(projectId, apiUrl, token); const strings = await getStrings(projectId, apiUrl, token); await writeFile( join(import.meta.dirname, "..", "..", "data", "crowdin-files.json"), JSON.stringify(files, null, 2), "utf-8", ); await writeFile( join(import.meta.dirname, "..", "..", "data", "crowdin-strings.json"), JSON.stringify(strings, null, 2), "utf-8", ); console.log("Loaded files and strings!");