@vibecodemax/cli 0.1.4 → 0.1.5

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.
Files changed (2) hide show
  1. package/dist/cli.js +31 -18
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -492,31 +492,44 @@ async function createAdminUser(supabaseUrl, serviceRoleKey, email, temporaryPass
492
492
  }
493
493
  return userId;
494
494
  }
495
- async function promoteAdminProfile(supabaseUrl, serviceRoleKey, userId, email) {
495
+ async function findAdminMembership(supabaseUrl, serviceRoleKey, userId) {
496
+ const result = await supabaseAdminRequest({
497
+ supabaseUrl,
498
+ serviceRoleKey,
499
+ method: "GET",
500
+ endpoint: `/rest/v1/admin_users?user_id=eq.${userId}&select=user_id,role`,
501
+ });
502
+ const rows = Array.isArray(result) ? result : [];
503
+ const row = rows.find((candidate) => {
504
+ if (!candidate || typeof candidate !== "object")
505
+ return false;
506
+ return candidate.user_id === userId;
507
+ });
508
+ return {
509
+ exists: Boolean(row),
510
+ role: typeof row?.role === "string" ? row.role : null,
511
+ };
512
+ }
513
+ async function promoteAdminUser(supabaseUrl, serviceRoleKey, userId) {
514
+ const existing = await findAdminMembership(supabaseUrl, serviceRoleKey, userId);
515
+ if (existing.exists)
516
+ return;
496
517
  await supabaseAdminRequest({
497
518
  supabaseUrl,
498
519
  serviceRoleKey,
499
520
  method: "POST",
500
- endpoint: "/rest/v1/profiles?on_conflict=id",
521
+ endpoint: "/rest/v1/admin_users",
501
522
  body: [
502
523
  {
503
- id: userId,
504
- email,
505
- name: "Admin User",
506
- role: "admin",
524
+ user_id: userId,
525
+ role: "super",
507
526
  },
508
527
  ],
509
528
  });
510
529
  }
511
- async function verifyAdminProfile(supabaseUrl, serviceRoleKey, userId) {
512
- const result = await supabaseAdminRequest({
513
- supabaseUrl,
514
- serviceRoleKey,
515
- method: "GET",
516
- endpoint: `/rest/v1/profiles?id=eq.${userId}&select=id,role`,
517
- });
518
- const rows = Array.isArray(result) ? result : [];
519
- return rows.some((row) => row && typeof row === "object" && row.role === "admin");
530
+ async function verifyAdminUser(supabaseUrl, serviceRoleKey, userId) {
531
+ const membership = await findAdminMembership(supabaseUrl, serviceRoleKey, userId);
532
+ return membership.exists;
520
533
  }
521
534
  async function ensureAdmin(flags) {
522
535
  const { values } = loadLocalEnv();
@@ -538,8 +551,8 @@ async function ensureAdmin(flags) {
538
551
  if (!userId) {
539
552
  fail("INVALID_RESPONSE", "Resolved admin user ID is missing after ensure-admin.");
540
553
  }
541
- await promoteAdminProfile(supabaseUrl, serviceRoleKey, userId, email);
542
- const verified = await verifyAdminProfile(supabaseUrl, serviceRoleKey, userId);
554
+ await promoteAdminUser(supabaseUrl, serviceRoleKey, userId);
555
+ const verified = await verifyAdminUser(supabaseUrl, serviceRoleKey, userId);
543
556
  if (!verified) {
544
557
  fail("ADMIN_VERIFY_FAILED", "The admin role could not be verified after promotion.");
545
558
  }
@@ -553,7 +566,7 @@ async function ensureAdmin(flags) {
553
566
  promoted: true,
554
567
  verified: true,
555
568
  defaultName: "Admin User",
556
- applied: ["auth_user", "admin_profile"],
569
+ applied: ["auth_user", "admin_users"],
557
570
  };
558
571
  if (temporaryPassword) {
559
572
  result.temporaryPassword = temporaryPassword;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibecodemax/cli",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "VibeCodeMax CLI — local provider setup for bootstrap and project configuration",
5
5
  "type": "module",
6
6
  "bin": {