Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: condition on prompt auth (prompts for authentication if an ORM is present and config.auth is falsy, either undefined or null.) #162

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/commands/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,19 @@ const promptUser = async (options?: InitOptions): Promise<InitOptions> => {
if (usePscale) dbProvider = "planetscale";
}

const auth = config.auth || !orm ? undefined : await askAuth(options);
// prompt auth
const hasOrm = !!config.orm || !!orm;
const auth = !hasOrm ? undefined : !config.auth ? await askAuth(options) : undefined;

// prompt auth provider
const authProviders =
auth === "next-auth"
? options?.authProviders || (await askAuthProvider())
: undefined;

const hasOrmAndAuth = !!(
config.auth ||
(auth && auth !== null && (config.orm || (orm && orm !== null)))
);
// prompt misc packages
const hasAuth = !!config.auth || !!auth;
const hasOrmAndAuth = hasOrm && hasAuth;
const packagesToInstall =
options.miscPackages ||
(await askMiscPackages(config.packages, hasOrmAndAuth));
Expand Down Expand Up @@ -198,9 +200,13 @@ export const addPackage = async (
}
if (promptResponse === null)
updateConfigFile({ orm: null, driver: null, provider: null });
} else {
promptResponse.orm = config.orm;
promptResponse.db = config.driver;
promptResponse.dbProvider = config.provider;
}
// check if auth
if (config.auth === undefined) {
if (!config.auth) {
if (promptResponse.auth && promptResponse.auth !== null)
spinner.text =
"Configuring " +
Expand Down