feat(spotify): implement milestone M2 auth

This commit is contained in:
2026-04-12 01:36:27 -05:00
parent f7dfb7d71d
commit c8c0876b7c
8 changed files with 670 additions and 5 deletions
+20 -2
View File
@@ -3,6 +3,8 @@
import minimist from "minimist";
import { fileURLToPath } from "node:url";
import { getAuthStatus, runAuthorizationFlow } from "./auth.js";
export interface CliDeps {
stdout: Pick<NodeJS.WriteStream, "write">;
stderr: Pick<NodeJS.WriteStream, "write">;
@@ -37,8 +39,24 @@ function notImplemented(command: string): CommandHandler {
export function createDefaultHandlers(): CommandHandlers {
return {
auth: notImplemented("auth"),
status: notImplemented("status"),
auth: async (_args, deps) => {
await runAuthorizationFlow();
deps.stdout.write("Spotify authorization complete.\n");
return 0;
},
status: async (args, deps) => {
const status = await getAuthStatus();
if (args.json) {
deps.stdout.write(`${JSON.stringify(status, null, 2)}\n`);
} else {
deps.stdout.write(`Spotify config: ${status.configFound ? "found" : "missing"}\n`);
deps.stdout.write(`Spotify token: ${status.tokenFound ? "found" : "missing"}\n`);
if (status.tokenFound) {
deps.stdout.write(`Spotify token expired: ${status.tokenExpired ? "yes" : "no"}\n`);
}
}
return status.configFound && status.tokenFound ? 0 : 1;
},
search: notImplemented("search"),
"list-playlists": notImplemented("list-playlists"),
"create-playlist": notImplemented("create-playlist"),