From eb2eb241bafc48fd79a1f2430bb58ebb7b7bd610 Mon Sep 17 00:00:00 2001 From: Matchu Date: Sat, 2 Oct 2021 01:01:29 -0700 Subject: [PATCH] Use the first Auth0 connection instead of prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Oh right, we have another prompt we need to not prompt for, lol :p Here, I just assume that there's one database connection on the Auth0 account. If that's not true, the script will error—not because this is a fundamentally unresolvable problem, but because I don't want to write code for configuring a situation that doesn't exist yet :p --- scripts/export-users-to-auth0.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/export-users-to-auth0.js b/scripts/export-users-to-auth0.js index 9cadf98..5aed213 100644 --- a/scripts/export-users-to-auth0.js +++ b/scripts/export-users-to-auth0.js @@ -19,7 +19,6 @@ // as a opt-in flag for now, in case I'm forgetting something 😅 const { argv } = require("yargs"); const { ManagementClient } = require("auth0"); -const inquirer = require("inquirer"); const PromisePool = require("es6-promise-pool"); const connectToDb = require("../src/server/db"); @@ -41,14 +40,14 @@ async function main() { }); const connections = await connectionsPromise; - const { connectionId } = await inquirer.prompt([ - { - name: "connectionId", - type: "list", - message: "Which Auth0 connection should we import to?", - choices: connections.map((c) => ({ name: c.name, value: c.id })), - }, - ]); + if (connections.length === 0) { + throw new Error(`no connections found on the Auth0 account`); + } else if (connections.length > 1) { + throw new Error( + `Not yet implemented: when there is more than one Auth0 connection, specify which one to use.` + ); + } + const connectionId = connections[0].id; let conditionSQL = "1"; let conditionValues = [];