UNPKG

convex

Version:

Client for the Convex Cloud

41 lines (40 loc) 1.53 kB
"use strict"; import { Command, Option } from "commander"; import chalk from "chalk"; import { oneoffContext } from "./lib/context.js"; import { checkAuthorization, performLogin } from "./lib/login.js"; export const login = new Command("login").description("Login to Convex").addOption(new Option("--override-auth-url <url>").hideHelp()).addOption(new Option("--override-auth-client <id>").hideHelp()).addOption(new Option("--override-auth-username <username>").hideHelp()).addOption(new Option("--override-auth-password <password>").hideHelp()).option( "--device-name <name>", "Provide a name for the device being authorized" ).option( "-f, --force", "Proceed with login even if a valid access token already exists for this device" ).option( "--no-open", "Don't automatically open the login link in the default browser" ).action(async (options, cmd) => { const ctx = oneoffContext; if (await checkAuthorization(ctx) && !options.force) { console.log( chalk.green( "This device has previously been authorized and is ready for use with Convex." ) ); return; } if (!!options.overrideAuthUsername !== !!options.overrideAuthPassword) { cmd.error( "If overriding credentials, both username and password must be provided" ); } await performLogin( ctx, options.overrideAuthUrl, options.overrideAuthClient, options.overrideAuthUsername, options.overrideAuthPassword, options.open, options.deviceName ); }); //# sourceMappingURL=login.js.map