use splashcat exporter when set using cli flags

splashcat-exporter-v2
Rosalina 2024-01-14 02:48:38 -05:00
parent cb0df39102
commit 94fb731fe0
No known key found for this signature in database
2 changed files with 25 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import { FileExporter } from "./exporters/file.ts";
import { delay, showError } from "./utils.ts";
import { GameFetcher } from "./GameFetcher.ts";
import { DEFAULT_ENV, Env } from "./env.ts";
import { SplashcatExporter } from "./exporters/splashcat.ts";
export type Opts = {
profilePath: string;
@ -220,6 +221,29 @@ export class App {
out.push(new FileExporter(state.fileExportPath));
}
if (exporters.includes("splashcat")) {
if (!state.splashcatApiKey) {
const key = (await this.env.prompts.prompt(
"Splashcat API key is not set. Please enter below.",
)).trim();
if (!key) {
this.env.logger.error("API key is required.");
Deno.exit(1);
}
await this.profile.writeState({
...state,
splashcatApiKey: key,
});
}
out.push(
new SplashcatExporter({
splashcatApiKey: this.profile.state.splashcatApiKey!,
uploadMode: this.opts.monitor ? "Monitoring" : "Manual",
env: this.env,
}),
);
}
return out;
}
exporterProgress(title: string) {

View File

@ -30,6 +30,7 @@ export type State = {
statInkApiKey?: string;
fileExportPath: string;
monitorInterval: number;
splashcatApiKey?: string;
};
export const DEFAULT_STATE: State = {