import chalk from "chalk"; import { consola } from "consola"; import { ctx } from "context"; import { encrypt } from "lib/crypto"; import { env } from "lib/env"; import tables from "schema"; const args = process.argv.slice(2); const clientId = args[0]; const clientSecret = args[1]; if (!clientId || !clientSecret) { consola.error( "Please provide Spotify Client ID and Client Secret as command line arguments", ); consola.info( chalk.greenBright("Usage: ts-node spotify.ts "), ); process.exit(1); } await ctx.db .insert(tables.spotifyApps) .values([ { spotifyAppId: clientId, spotifySecret: encrypt(clientSecret, env.SPOTIFY_ENCRYPTION_KEY), }, ]) .onConflictDoNothing() .execute(); process.exit(0);