authverse 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  var import_commander = require("commander");
27
27
 
28
28
  // cli/init.ts
29
- var import_inquirer = __toESM(require("inquirer"), 1);
29
+ var import_inquirer3 = __toESM(require("inquirer"), 1);
30
30
 
31
31
  // script/prisma.ts
32
32
  var import_url2 = require("url");
@@ -174,6 +174,7 @@ ${layoutContent}`;
174
174
  };
175
175
 
176
176
  // script/prisma.ts
177
+ var import_inquirer = __toESM(require("inquirer"), 1);
177
178
  var import_meta2 = {};
178
179
  var prismaRun = async ({ authUi, database }) => {
179
180
  try {
@@ -248,25 +249,73 @@ BETTER_AUTH_SECRET=${secret}`);
248
249
  BETTER_AUTH_URL=http://localhost:3000
249
250
  `);
250
251
  }
251
- const srcPath = import_path2.default.join(projectDir, "src");
252
- const folder = srcPath ? "" : "src";
253
- const libPath = import_path2.default.join(projectDir, folder, "lib");
252
+ const srcFolder = import_fs2.default.existsSync(import_path2.default.join(projectDir, "src")) ? "src" : "";
253
+ const libPath = import_path2.default.join(projectDir, srcFolder, "lib");
254
254
  if (!import_fs2.default.existsSync(libPath)) {
255
255
  import_fs2.default.mkdirSync(libPath, { recursive: true });
256
256
  }
257
- const authTemplatePath = import_path2.default.resolve(
258
- __dirname,
259
- `./template/lib/${database}/auth.ts`
260
- );
261
- const authDestinationPath = import_path2.default.join(libPath, "auth.ts");
262
- import_fs2.default.copyFileSync(authTemplatePath, authDestinationPath);
263
- const authClientTemplatePath = import_path2.default.resolve(
264
- __dirname,
265
- "./template/lib/auth-client.ts"
266
- );
267
- const authClientDestinationPath = import_path2.default.join(libPath, "auth-client.ts");
268
- import_fs2.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
269
- const serverPath = import_path2.default.join(projectDir, folder, "server");
257
+ const authPath = import_path2.default.join(libPath, "auth.ts");
258
+ const authClientPath = import_path2.default.join(libPath, "auth-client.ts");
259
+ if (import_fs2.default.existsSync(authPath) || import_fs2.default.existsSync(authClientPath)) {
260
+ const answers = await import_inquirer.default.prompt([
261
+ {
262
+ type: "confirm",
263
+ name: "overwrite",
264
+ message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
265
+ default: false
266
+ }
267
+ ]);
268
+ if (answers.overwrite) {
269
+ const authTemplatePath = import_path2.default.resolve(
270
+ __dirname,
271
+ `./template/lib/${database}/auth.ts`
272
+ );
273
+ const authDestinationPath = import_path2.default.join(libPath, "auth.ts");
274
+ import_fs2.default.copyFileSync(authTemplatePath, authDestinationPath);
275
+ const authClientTemplatePath = import_path2.default.resolve(
276
+ __dirname,
277
+ "./template/lib/auth-client.ts"
278
+ );
279
+ const authClientDestinationPath = import_path2.default.join(libPath, "auth-client.ts");
280
+ import_fs2.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
281
+ if (srcFolder === "src") {
282
+ const authContextPath = import_path2.default.join(libPath, "auth.ts");
283
+ const authContextContent = import_fs2.default.readFileSync(authContextPath, "utf-8");
284
+ import_fs2.default.writeFileSync(
285
+ authContextPath,
286
+ authContextContent.replace(
287
+ 'import { PrismaClient } from "@/generated/prisma/client";',
288
+ 'import { PrismaClient } from "../../generated/prisma/client";'
289
+ )
290
+ );
291
+ }
292
+ }
293
+ } else {
294
+ const authTemplatePath = import_path2.default.resolve(
295
+ __dirname,
296
+ `./template/lib/${database}/auth.ts`
297
+ );
298
+ const authDestinationPath = import_path2.default.join(libPath, "auth.ts");
299
+ import_fs2.default.copyFileSync(authTemplatePath, authDestinationPath);
300
+ const authClientTemplatePath = import_path2.default.resolve(
301
+ __dirname,
302
+ "./template/lib/auth-client.ts"
303
+ );
304
+ const authClientDestinationPath = import_path2.default.join(libPath, "auth-client.ts");
305
+ import_fs2.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
306
+ if (srcFolder === "src") {
307
+ const authContextPath = import_path2.default.join(libPath, "auth.ts");
308
+ const authContextContent = import_fs2.default.readFileSync(authContextPath, "utf-8");
309
+ import_fs2.default.writeFileSync(
310
+ authContextPath,
311
+ authContextContent.replace(
312
+ 'import { PrismaClient } from "@/generated/prisma/client";',
313
+ 'import { PrismaClient } from "../../generated/prisma/client";'
314
+ )
315
+ );
316
+ }
317
+ }
318
+ const serverPath = import_path2.default.join(projectDir, srcFolder, "server");
270
319
  if (!import_fs2.default.existsSync(serverPath)) {
271
320
  import_fs2.default.mkdirSync(serverPath, { recursive: true });
272
321
  }
@@ -282,6 +331,7 @@ BETTER_AUTH_URL=http://localhost:3000
282
331
  );
283
332
  const routeDestinationDir = import_path2.default.join(
284
333
  projectDir,
334
+ srcFolder,
285
335
  "app",
286
336
  "api",
287
337
  "auth",
@@ -296,11 +346,24 @@ BETTER_AUTH_URL=http://localhost:3000
296
346
  __dirname,
297
347
  "./template/proxy/proxy.ts"
298
348
  );
299
- const proxyDestinationDir = import_path2.default.join(projectDir, folder);
349
+ const proxyDestinationDir = import_path2.default.join(projectDir, srcFolder);
300
350
  const proxyDestinationPath = import_path2.default.join(proxyDestinationDir, "proxy.ts");
301
351
  import_fs2.default.copyFileSync(proxyTemplatePath, proxyDestinationPath);
352
+ const gitignorePath = import_path2.default.join(projectDir, ".gitignore");
353
+ const gitignoreContent = import_fs2.default.readFileSync(gitignorePath, "utf-8");
354
+ if (srcFolder === "src") {
355
+ import_fs2.default.writeFileSync(
356
+ gitignorePath,
357
+ gitignoreContent.replace("/src/generated/prisma", "/generated")
358
+ );
359
+ } else {
360
+ import_fs2.default.writeFileSync(
361
+ gitignorePath,
362
+ gitignoreContent.replace("generated/prisma", "/generated")
363
+ );
364
+ }
302
365
  if (authUi) {
303
- await authUiRun({ folder });
366
+ await authUiRun({ folder: srcFolder });
304
367
  } else {
305
368
  console.log(
306
369
  import_chalk2.default.green(
@@ -318,6 +381,7 @@ var import_chalk3 = __toESM(require("chalk"), 1);
318
381
  var import_path3 = __toESM(require("path"), 1);
319
382
  var import_url3 = require("url");
320
383
  var import_fs3 = __toESM(require("fs"), 1);
384
+ var import_inquirer2 = __toESM(require("inquirer"), 1);
321
385
  var import_meta3 = {};
322
386
  var drizzleRun = async (authUi) => {
323
387
  try {
@@ -351,43 +415,98 @@ BETTER_AUTH_SECRET=${secret}`);
351
415
  BETTER_AUTH_URL=http://localhost:3000
352
416
  `);
353
417
  }
354
- const srcPath = import_path3.default.join(projectDir, "src");
355
- const folder = srcPath ? "" : "src";
356
- const libPath = import_path3.default.join(projectDir, folder, "lib");
418
+ const srcFolder = import_fs3.default.existsSync(import_path3.default.join(projectDir, "src")) ? "src" : "";
419
+ const libPath = import_path3.default.join(projectDir, srcFolder, "lib");
357
420
  if (!import_fs3.default.existsSync(libPath)) {
358
421
  import_fs3.default.mkdirSync(libPath, { recursive: true });
359
422
  }
360
- const authTemplatePath = import_path3.default.resolve(
361
- __dirname,
362
- "./template/lib/auth-drizzle.ts"
363
- );
364
- const authDestinationPath = import_path3.default.join(libPath, "auth.ts");
365
- import_fs3.default.copyFileSync(authTemplatePath, authDestinationPath);
366
- const authClientTemplatePath = import_path3.default.resolve(
367
- __dirname,
368
- "./template/lib/auth-client.ts"
369
- );
370
- const authClientDestinationPath = import_path3.default.join(libPath, "auth-client.ts");
371
- import_fs3.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
423
+ const authPath = import_path3.default.join(libPath, "auth.ts");
424
+ const authClientPath = import_path3.default.join(libPath, "auth-client.ts");
425
+ if (import_fs3.default.existsSync(authPath) || import_fs3.default.existsSync(authClientPath)) {
426
+ const answers = await import_inquirer2.default.prompt([
427
+ {
428
+ type: "confirm",
429
+ name: "overwrite",
430
+ message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
431
+ default: false
432
+ }
433
+ ]);
434
+ if (answers.overwrite) {
435
+ const authTemplatePath = import_path3.default.resolve(
436
+ __dirname,
437
+ "./template/lib/auth-drizzle.ts"
438
+ );
439
+ const authDestinationPath = import_path3.default.join(libPath, "auth.ts");
440
+ import_fs3.default.copyFileSync(authTemplatePath, authDestinationPath);
441
+ const authClientTemplatePath = import_path3.default.resolve(
442
+ __dirname,
443
+ "./template/lib/auth-client.ts"
444
+ );
445
+ const authClientDestinationPath = import_path3.default.join(libPath, "auth-client.ts");
446
+ import_fs3.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
447
+ }
448
+ } else {
449
+ const authTemplatePath = import_path3.default.resolve(
450
+ __dirname,
451
+ "./template/lib/auth-drizzle.ts"
452
+ );
453
+ const authDestinationPath = import_path3.default.join(libPath, "auth.ts");
454
+ import_fs3.default.copyFileSync(authTemplatePath, authDestinationPath);
455
+ const authClientTemplatePath = import_path3.default.resolve(
456
+ __dirname,
457
+ "./template/lib/auth-client.ts"
458
+ );
459
+ const authClientDestinationPath = import_path3.default.join(libPath, "auth-client.ts");
460
+ import_fs3.default.copyFileSync(authClientTemplatePath, authClientDestinationPath);
461
+ }
372
462
  const dbTemplatePath = import_path3.default.resolve(__dirname, "./template/db");
373
- const dbDir = import_path3.default.join(projectDir, folder, "db");
463
+ const dbDir = import_path3.default.join(projectDir, srcFolder, "db");
374
464
  if (!import_fs3.default.existsSync(dbDir)) {
375
465
  import_fs3.default.mkdirSync(dbDir, { recursive: true });
376
466
  }
377
- const dbDestinationPath = import_path3.default.join(dbDir, "drizzle.ts");
378
- import_fs3.default.copyFileSync(`${dbTemplatePath}/drizzle.ts`, dbDestinationPath);
379
- const schemaDestinationPath = import_path3.default.join(dbDir, "schema.ts");
380
- import_fs3.default.copyFileSync(`${dbTemplatePath}/schema.ts`, schemaDestinationPath);
381
- const drizzleConfigTemplatePath = import_path3.default.resolve(
382
- __dirname,
383
- "./template/config/drizzle.config.ts"
384
- );
385
- const drizzleConfigDestinationPath = import_path3.default.join(
386
- projectDir,
387
- "drizzle.config.ts"
388
- );
389
- import_fs3.default.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
390
- const serverPath = import_path3.default.join(projectDir, folder, "server");
467
+ const drizzlePath = import_path3.default.join(projectDir, srcFolder, "/db/drizzle.ts");
468
+ const schemaPath = import_path3.default.join(projectDir, srcFolder, "/db/schema.ts");
469
+ if (import_fs3.default.existsSync(drizzlePath) || import_fs3.default.existsSync(schemaPath)) {
470
+ const answers = await import_inquirer2.default.prompt([
471
+ {
472
+ type: "confirm",
473
+ name: "overwrite",
474
+ message: "Your schema or drizzle file already exists. Do you want to overwrite it?",
475
+ default: false
476
+ }
477
+ ]);
478
+ if (answers.overwrite) {
479
+ const schemaDestinationPath = import_path3.default.join(dbDir, "schema.ts");
480
+ import_fs3.default.copyFileSync(`${dbTemplatePath}/schema.ts`, schemaDestinationPath);
481
+ }
482
+ } else {
483
+ const dbDestinationPath = import_path3.default.join(dbDir, "drizzle.ts");
484
+ import_fs3.default.copyFileSync(`${dbTemplatePath}/drizzle.ts`, dbDestinationPath);
485
+ const schemaDestinationPath = import_path3.default.join(dbDir, "schema.ts");
486
+ import_fs3.default.copyFileSync(`${dbTemplatePath}/schema.ts`, schemaDestinationPath);
487
+ }
488
+ if (srcFolder == "src") {
489
+ const drizzleConfigTemplatePath = import_path3.default.resolve(
490
+ __dirname,
491
+ "./template/config/drizzle.config-src.ts"
492
+ );
493
+ const drizzleConfigDestinationPath = import_path3.default.join(
494
+ projectDir,
495
+ "drizzle.config.ts"
496
+ );
497
+ import_fs3.default.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
498
+ } else {
499
+ const drizzleConfigTemplatePath = import_path3.default.resolve(
500
+ __dirname,
501
+ "./template/config/drizzle.config.ts"
502
+ );
503
+ const drizzleConfigDestinationPath = import_path3.default.join(
504
+ projectDir,
505
+ "drizzle.config.ts"
506
+ );
507
+ import_fs3.default.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
508
+ }
509
+ const serverPath = import_path3.default.join(projectDir, srcFolder, "server");
391
510
  if (!import_fs3.default.existsSync(serverPath)) {
392
511
  import_fs3.default.mkdirSync(serverPath, { recursive: true });
393
512
  }
@@ -403,6 +522,7 @@ BETTER_AUTH_URL=http://localhost:3000
403
522
  );
404
523
  const routeDestinationDir = import_path3.default.join(
405
524
  projectDir,
525
+ srcFolder,
406
526
  "app",
407
527
  "api",
408
528
  "auth",
@@ -417,11 +537,11 @@ BETTER_AUTH_URL=http://localhost:3000
417
537
  __dirname,
418
538
  "./template/proxy/proxy.ts"
419
539
  );
420
- const proxyDestinationDir = import_path3.default.join(projectDir, folder);
540
+ const proxyDestinationDir = import_path3.default.join(projectDir, srcFolder);
421
541
  const proxyDestinationPath = import_path3.default.join(proxyDestinationDir, "proxy.ts");
422
542
  import_fs3.default.copyFileSync(proxyTemplatePath, proxyDestinationPath);
423
543
  if (authUi) {
424
- await authUiRun({ folder });
544
+ await authUiRun({ folder: srcFolder });
425
545
  } else {
426
546
  console.log(
427
547
  import_chalk3.default.green(
@@ -773,7 +893,7 @@ var initAnswer = async () => {
773
893
  framework = hasNext ? "Next js" : "tanstack state";
774
894
  }
775
895
  console.log(`\u2714 Detected framework: ${framework}`);
776
- const answers = await import_inquirer.default.prompt([
896
+ const answers = await import_inquirer3.default.prompt([
777
897
  {
778
898
  type: "list",
779
899
  name: "orm",
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  import { Command } from "commander";
5
5
 
6
6
  // cli/init.ts
7
- import inquirer from "inquirer";
7
+ import inquirer3 from "inquirer";
8
8
 
9
9
  // script/prisma.ts
10
10
  import { fileURLToPath as fileURLToPath2 } from "url";
@@ -151,6 +151,7 @@ ${layoutContent}`;
151
151
  };
152
152
 
153
153
  // script/prisma.ts
154
+ import inquirer from "inquirer";
154
155
  var prismaRun = async ({ authUi, database }) => {
155
156
  try {
156
157
  const projectDir = process.cwd();
@@ -224,25 +225,73 @@ BETTER_AUTH_SECRET=${secret}`);
224
225
  BETTER_AUTH_URL=http://localhost:3000
225
226
  `);
226
227
  }
227
- const srcPath = path2.join(projectDir, "src");
228
- const folder = srcPath ? "" : "src";
229
- const libPath = path2.join(projectDir, folder, "lib");
228
+ const srcFolder = fs2.existsSync(path2.join(projectDir, "src")) ? "src" : "";
229
+ const libPath = path2.join(projectDir, srcFolder, "lib");
230
230
  if (!fs2.existsSync(libPath)) {
231
231
  fs2.mkdirSync(libPath, { recursive: true });
232
232
  }
233
- const authTemplatePath = path2.resolve(
234
- __dirname,
235
- `./template/lib/${database}/auth.ts`
236
- );
237
- const authDestinationPath = path2.join(libPath, "auth.ts");
238
- fs2.copyFileSync(authTemplatePath, authDestinationPath);
239
- const authClientTemplatePath = path2.resolve(
240
- __dirname,
241
- "./template/lib/auth-client.ts"
242
- );
243
- const authClientDestinationPath = path2.join(libPath, "auth-client.ts");
244
- fs2.copyFileSync(authClientTemplatePath, authClientDestinationPath);
245
- const serverPath = path2.join(projectDir, folder, "server");
233
+ const authPath = path2.join(libPath, "auth.ts");
234
+ const authClientPath = path2.join(libPath, "auth-client.ts");
235
+ if (fs2.existsSync(authPath) || fs2.existsSync(authClientPath)) {
236
+ const answers = await inquirer.prompt([
237
+ {
238
+ type: "confirm",
239
+ name: "overwrite",
240
+ message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
241
+ default: false
242
+ }
243
+ ]);
244
+ if (answers.overwrite) {
245
+ const authTemplatePath = path2.resolve(
246
+ __dirname,
247
+ `./template/lib/${database}/auth.ts`
248
+ );
249
+ const authDestinationPath = path2.join(libPath, "auth.ts");
250
+ fs2.copyFileSync(authTemplatePath, authDestinationPath);
251
+ const authClientTemplatePath = path2.resolve(
252
+ __dirname,
253
+ "./template/lib/auth-client.ts"
254
+ );
255
+ const authClientDestinationPath = path2.join(libPath, "auth-client.ts");
256
+ fs2.copyFileSync(authClientTemplatePath, authClientDestinationPath);
257
+ if (srcFolder === "src") {
258
+ const authContextPath = path2.join(libPath, "auth.ts");
259
+ const authContextContent = fs2.readFileSync(authContextPath, "utf-8");
260
+ fs2.writeFileSync(
261
+ authContextPath,
262
+ authContextContent.replace(
263
+ 'import { PrismaClient } from "@/generated/prisma/client";',
264
+ 'import { PrismaClient } from "../../generated/prisma/client";'
265
+ )
266
+ );
267
+ }
268
+ }
269
+ } else {
270
+ const authTemplatePath = path2.resolve(
271
+ __dirname,
272
+ `./template/lib/${database}/auth.ts`
273
+ );
274
+ const authDestinationPath = path2.join(libPath, "auth.ts");
275
+ fs2.copyFileSync(authTemplatePath, authDestinationPath);
276
+ const authClientTemplatePath = path2.resolve(
277
+ __dirname,
278
+ "./template/lib/auth-client.ts"
279
+ );
280
+ const authClientDestinationPath = path2.join(libPath, "auth-client.ts");
281
+ fs2.copyFileSync(authClientTemplatePath, authClientDestinationPath);
282
+ if (srcFolder === "src") {
283
+ const authContextPath = path2.join(libPath, "auth.ts");
284
+ const authContextContent = fs2.readFileSync(authContextPath, "utf-8");
285
+ fs2.writeFileSync(
286
+ authContextPath,
287
+ authContextContent.replace(
288
+ 'import { PrismaClient } from "@/generated/prisma/client";',
289
+ 'import { PrismaClient } from "../../generated/prisma/client";'
290
+ )
291
+ );
292
+ }
293
+ }
294
+ const serverPath = path2.join(projectDir, srcFolder, "server");
246
295
  if (!fs2.existsSync(serverPath)) {
247
296
  fs2.mkdirSync(serverPath, { recursive: true });
248
297
  }
@@ -258,6 +307,7 @@ BETTER_AUTH_URL=http://localhost:3000
258
307
  );
259
308
  const routeDestinationDir = path2.join(
260
309
  projectDir,
310
+ srcFolder,
261
311
  "app",
262
312
  "api",
263
313
  "auth",
@@ -272,11 +322,24 @@ BETTER_AUTH_URL=http://localhost:3000
272
322
  __dirname,
273
323
  "./template/proxy/proxy.ts"
274
324
  );
275
- const proxyDestinationDir = path2.join(projectDir, folder);
325
+ const proxyDestinationDir = path2.join(projectDir, srcFolder);
276
326
  const proxyDestinationPath = path2.join(proxyDestinationDir, "proxy.ts");
277
327
  fs2.copyFileSync(proxyTemplatePath, proxyDestinationPath);
328
+ const gitignorePath = path2.join(projectDir, ".gitignore");
329
+ const gitignoreContent = fs2.readFileSync(gitignorePath, "utf-8");
330
+ if (srcFolder === "src") {
331
+ fs2.writeFileSync(
332
+ gitignorePath,
333
+ gitignoreContent.replace("/src/generated/prisma", "/generated")
334
+ );
335
+ } else {
336
+ fs2.writeFileSync(
337
+ gitignorePath,
338
+ gitignoreContent.replace("generated/prisma", "/generated")
339
+ );
340
+ }
278
341
  if (authUi) {
279
- await authUiRun({ folder });
342
+ await authUiRun({ folder: srcFolder });
280
343
  } else {
281
344
  console.log(
282
345
  chalk2.green(
@@ -294,6 +357,7 @@ import chalk3 from "chalk";
294
357
  import path3 from "path";
295
358
  import { fileURLToPath as fileURLToPath3 } from "url";
296
359
  import fs3 from "fs";
360
+ import inquirer2 from "inquirer";
297
361
  var drizzleRun = async (authUi) => {
298
362
  try {
299
363
  const projectDir = process.cwd();
@@ -326,43 +390,98 @@ BETTER_AUTH_SECRET=${secret}`);
326
390
  BETTER_AUTH_URL=http://localhost:3000
327
391
  `);
328
392
  }
329
- const srcPath = path3.join(projectDir, "src");
330
- const folder = srcPath ? "" : "src";
331
- const libPath = path3.join(projectDir, folder, "lib");
393
+ const srcFolder = fs3.existsSync(path3.join(projectDir, "src")) ? "src" : "";
394
+ const libPath = path3.join(projectDir, srcFolder, "lib");
332
395
  if (!fs3.existsSync(libPath)) {
333
396
  fs3.mkdirSync(libPath, { recursive: true });
334
397
  }
335
- const authTemplatePath = path3.resolve(
336
- __dirname,
337
- "./template/lib/auth-drizzle.ts"
338
- );
339
- const authDestinationPath = path3.join(libPath, "auth.ts");
340
- fs3.copyFileSync(authTemplatePath, authDestinationPath);
341
- const authClientTemplatePath = path3.resolve(
342
- __dirname,
343
- "./template/lib/auth-client.ts"
344
- );
345
- const authClientDestinationPath = path3.join(libPath, "auth-client.ts");
346
- fs3.copyFileSync(authClientTemplatePath, authClientDestinationPath);
398
+ const authPath = path3.join(libPath, "auth.ts");
399
+ const authClientPath = path3.join(libPath, "auth-client.ts");
400
+ if (fs3.existsSync(authPath) || fs3.existsSync(authClientPath)) {
401
+ const answers = await inquirer2.prompt([
402
+ {
403
+ type: "confirm",
404
+ name: "overwrite",
405
+ message: "Do you want to overwrite existing auth lib/auth.ts or lib/auth-client.ts",
406
+ default: false
407
+ }
408
+ ]);
409
+ if (answers.overwrite) {
410
+ const authTemplatePath = path3.resolve(
411
+ __dirname,
412
+ "./template/lib/auth-drizzle.ts"
413
+ );
414
+ const authDestinationPath = path3.join(libPath, "auth.ts");
415
+ fs3.copyFileSync(authTemplatePath, authDestinationPath);
416
+ const authClientTemplatePath = path3.resolve(
417
+ __dirname,
418
+ "./template/lib/auth-client.ts"
419
+ );
420
+ const authClientDestinationPath = path3.join(libPath, "auth-client.ts");
421
+ fs3.copyFileSync(authClientTemplatePath, authClientDestinationPath);
422
+ }
423
+ } else {
424
+ const authTemplatePath = path3.resolve(
425
+ __dirname,
426
+ "./template/lib/auth-drizzle.ts"
427
+ );
428
+ const authDestinationPath = path3.join(libPath, "auth.ts");
429
+ fs3.copyFileSync(authTemplatePath, authDestinationPath);
430
+ const authClientTemplatePath = path3.resolve(
431
+ __dirname,
432
+ "./template/lib/auth-client.ts"
433
+ );
434
+ const authClientDestinationPath = path3.join(libPath, "auth-client.ts");
435
+ fs3.copyFileSync(authClientTemplatePath, authClientDestinationPath);
436
+ }
347
437
  const dbTemplatePath = path3.resolve(__dirname, "./template/db");
348
- const dbDir = path3.join(projectDir, folder, "db");
438
+ const dbDir = path3.join(projectDir, srcFolder, "db");
349
439
  if (!fs3.existsSync(dbDir)) {
350
440
  fs3.mkdirSync(dbDir, { recursive: true });
351
441
  }
352
- const dbDestinationPath = path3.join(dbDir, "drizzle.ts");
353
- fs3.copyFileSync(`${dbTemplatePath}/drizzle.ts`, dbDestinationPath);
354
- const schemaDestinationPath = path3.join(dbDir, "schema.ts");
355
- fs3.copyFileSync(`${dbTemplatePath}/schema.ts`, schemaDestinationPath);
356
- const drizzleConfigTemplatePath = path3.resolve(
357
- __dirname,
358
- "./template/config/drizzle.config.ts"
359
- );
360
- const drizzleConfigDestinationPath = path3.join(
361
- projectDir,
362
- "drizzle.config.ts"
363
- );
364
- fs3.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
365
- const serverPath = path3.join(projectDir, folder, "server");
442
+ const drizzlePath = path3.join(projectDir, srcFolder, "/db/drizzle.ts");
443
+ const schemaPath = path3.join(projectDir, srcFolder, "/db/schema.ts");
444
+ if (fs3.existsSync(drizzlePath) || fs3.existsSync(schemaPath)) {
445
+ const answers = await inquirer2.prompt([
446
+ {
447
+ type: "confirm",
448
+ name: "overwrite",
449
+ message: "Your schema or drizzle file already exists. Do you want to overwrite it?",
450
+ default: false
451
+ }
452
+ ]);
453
+ if (answers.overwrite) {
454
+ const schemaDestinationPath = path3.join(dbDir, "schema.ts");
455
+ fs3.copyFileSync(`${dbTemplatePath}/schema.ts`, schemaDestinationPath);
456
+ }
457
+ } else {
458
+ const dbDestinationPath = path3.join(dbDir, "drizzle.ts");
459
+ fs3.copyFileSync(`${dbTemplatePath}/drizzle.ts`, dbDestinationPath);
460
+ const schemaDestinationPath = path3.join(dbDir, "schema.ts");
461
+ fs3.copyFileSync(`${dbTemplatePath}/schema.ts`, schemaDestinationPath);
462
+ }
463
+ if (srcFolder == "src") {
464
+ const drizzleConfigTemplatePath = path3.resolve(
465
+ __dirname,
466
+ "./template/config/drizzle.config-src.ts"
467
+ );
468
+ const drizzleConfigDestinationPath = path3.join(
469
+ projectDir,
470
+ "drizzle.config.ts"
471
+ );
472
+ fs3.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
473
+ } else {
474
+ const drizzleConfigTemplatePath = path3.resolve(
475
+ __dirname,
476
+ "./template/config/drizzle.config.ts"
477
+ );
478
+ const drizzleConfigDestinationPath = path3.join(
479
+ projectDir,
480
+ "drizzle.config.ts"
481
+ );
482
+ fs3.copyFileSync(drizzleConfigTemplatePath, drizzleConfigDestinationPath);
483
+ }
484
+ const serverPath = path3.join(projectDir, srcFolder, "server");
366
485
  if (!fs3.existsSync(serverPath)) {
367
486
  fs3.mkdirSync(serverPath, { recursive: true });
368
487
  }
@@ -378,6 +497,7 @@ BETTER_AUTH_URL=http://localhost:3000
378
497
  );
379
498
  const routeDestinationDir = path3.join(
380
499
  projectDir,
500
+ srcFolder,
381
501
  "app",
382
502
  "api",
383
503
  "auth",
@@ -392,11 +512,11 @@ BETTER_AUTH_URL=http://localhost:3000
392
512
  __dirname,
393
513
  "./template/proxy/proxy.ts"
394
514
  );
395
- const proxyDestinationDir = path3.join(projectDir, folder);
515
+ const proxyDestinationDir = path3.join(projectDir, srcFolder);
396
516
  const proxyDestinationPath = path3.join(proxyDestinationDir, "proxy.ts");
397
517
  fs3.copyFileSync(proxyTemplatePath, proxyDestinationPath);
398
518
  if (authUi) {
399
- await authUiRun({ folder });
519
+ await authUiRun({ folder: srcFolder });
400
520
  } else {
401
521
  console.log(
402
522
  chalk3.green(
@@ -745,7 +865,7 @@ var initAnswer = async () => {
745
865
  framework = hasNext ? "Next js" : "tanstack state";
746
866
  }
747
867
  console.log(`\u2714 Detected framework: ${framework}`);
748
- const answers = await inquirer.prompt([
868
+ const answers = await inquirer3.prompt([
749
869
  {
750
870
  type: "list",
751
871
  name: "orm",
@@ -0,0 +1,13 @@
1
+ import { config } from "dotenv";
2
+ import { defineConfig } from "drizzle-kit";
3
+
4
+ config({ path: ".env" });
5
+
6
+ export default defineConfig({
7
+ schema: "./src/db/schema.ts",
8
+ out: "./src/migrations",
9
+ dialect: "postgresql",
10
+ dbCredentials: {
11
+ url: process.env.DATABASE_URL!,
12
+ },
13
+ });
package/package.json CHANGED
@@ -1,9 +1,11 @@
1
1
  {
2
2
  "name": "authverse",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Authverse Fast modern CLI to generate full auth systems with OAuth Prisma Drizzle better auth and ready-to-use ShadCN UI screens",
5
5
  "repository": {
6
- "url": "git+https://github.com/abdirahmanmahamoud/authverse.git"
6
+ "url": "git+https://github.com/abdirahmanmahamoud/authverse.git",
7
+ "type": "git",
8
+ "directory": "package/authverse"
7
9
  },
8
10
  "homepage": "https://authverse.dev",
9
11
  "license": "MIT",
@@ -45,7 +47,7 @@
45
47
  "dependencies": {
46
48
  "chalk": "^5.6.2",
47
49
  "commander": "^14.0.2",
48
- "inquirer": "^12.10.0"
50
+ "inquirer": "^13.1.0"
49
51
  },
50
52
  "devDependencies": {
51
53
  "@semantic-release/changelog": "^6.0.3",