@knowcode/doc-builder 1.8.1 → 1.8.2

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 (42) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/html/README.html +3 -3
  3. package/html/auth.js +2 -2
  4. package/html/documentation-index.html +3 -3
  5. package/html/guides/authentication-default-change.html +3 -3
  6. package/html/guides/authentication-guide.html +10 -7
  7. package/html/guides/claude-workflow-guide.html +3 -3
  8. package/html/guides/documentation-standards.html +3 -3
  9. package/html/guides/phosphor-icons-guide.html +3 -3
  10. package/html/guides/private-directory-authentication.html +25 -18
  11. package/html/guides/public-site-deployment.html +3 -3
  12. package/html/guides/search-engine-verification-guide.html +3 -3
  13. package/html/guides/seo-guide.html +3 -3
  14. package/html/guides/seo-optimization-guide.html +3 -3
  15. package/html/guides/troubleshooting-guide.html +3 -3
  16. package/html/guides/windows-setup-guide.html +3 -3
  17. package/html/index.html +3 -3
  18. package/html/js/auth.js +2 -2
  19. package/html/login.html +2 -2
  20. package/html/private/cache-control-anti-pattern.html +5 -4
  21. package/html/private/launch/README.html +5 -4
  22. package/html/private/launch/auth-cleanup-summary.html +5 -4
  23. package/html/private/launch/bubble-plugin-specification.html +5 -4
  24. package/html/private/launch/go-to-market-strategy.html +5 -4
  25. package/html/private/launch/launch-announcements.html +5 -4
  26. package/html/private/launch/vercel-deployment-auth-setup.html +5 -4
  27. package/html/private/next-steps-walkthrough.html +5 -4
  28. package/html/private/supabase-auth-implementation-completed.html +5 -4
  29. package/html/private/supabase-auth-implementation-plan.html +5 -4
  30. package/html/private/supabase-auth-integration-plan.html +5 -4
  31. package/html/private/supabase-auth-setup-guide.html +5 -4
  32. package/html/private/test-private-doc.html +5 -4
  33. package/html/private/user-management-tooling.html +587 -0
  34. package/html/sitemap.xml +49 -43
  35. package/html/vercel-cli-setup-guide.html +3 -3
  36. package/html/vercel-first-time-setup-guide.html +3 -3
  37. package/lib/config.js +12 -13
  38. package/lib/core-builder.js +4 -4
  39. package/lib/shared-auth-config.js +21 -0
  40. package/package.json +1 -1
  41. package/user-management/README.md +8 -4
  42. package/user-management/add-users.sh +37 -11
@@ -0,0 +1,587 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <meta name="description" content="This document provides comprehensive documentation for the Supabase user management system created for doc-builder authenticated sites.">
7
+ <title>User Management Tooling | @knowcode/doc-builder</title>
8
+
9
+ <meta name="author" content="Lindsay Smith">
10
+ <meta name="keywords" content="documentation, markdown, static site generator, vercel, notion-style, user, supabase">
11
+ <meta name="robots" content="index, follow">
12
+ <link rel="canonical" href="https://doc-builder-delta.vercel.app/private/user-management-tooling.html">
13
+
14
+ <!-- Open Graph / Facebook -->
15
+ <meta property="og:type" content="article">
16
+ <meta property="og:url" content="https://doc-builder-delta.vercel.app/private/user-management-tooling.html">
17
+ <meta property="og:title" content="User Management Tooling | @knowcode/doc-builder">
18
+ <meta property="og:description" content="This document provides comprehensive documentation for the Supabase user management system created for doc-builder authenticated sites.">
19
+ <meta property="og:image" content="https://doc-builder-delta.vercel.app/og-default.png">
20
+ <meta property="og:site_name" content="@knowcode/doc-builder">
21
+ <meta property="og:locale" content="en_US">
22
+
23
+ <!-- Twitter Card -->
24
+ <meta name="twitter:card" content="summary_large_image">
25
+ <meta name="twitter:site" content="@planbbackups">
26
+ <meta name="twitter:creator" content="@planbbackups">
27
+ <meta name="twitter:title" content="User Management Tooling | @knowcode/doc-builder">
28
+ <meta name="twitter:description" content="This document provides comprehensive documentation for the Supabase user management system created for doc-builder authenticated sites.">
29
+ <meta name="twitter:image" content="https://doc-builder-delta.vercel.app/og-default.png">
30
+
31
+ <!-- Custom Meta Tags -->
32
+ <meta name="google-site-verification" content="FtzcDTf5BQ9K5EfnGazQkgU2U4FiN3ITzM7gHwqUAqQ">
33
+ <meta name="msvalidate.01" content="B2D8C4C12C530D47AA962B24CAA09630">
34
+
35
+ <!-- Fonts -->
36
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet">
37
+
38
+ <!-- Icons -->
39
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
40
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@phosphor-icons/web@2.1.1/src/regular/style.css">
41
+
42
+ <!-- Mermaid -->
43
+ <script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
44
+
45
+ <!-- Styles -->
46
+ <link rel="stylesheet" href="/css/notion-style.css">
47
+
48
+
49
+ <!-- Hide content until auth check -->
50
+ <style>
51
+ body {
52
+ visibility: hidden;
53
+ opacity: 0;
54
+ transition: opacity 0.3s ease;
55
+ }
56
+ body.authenticated {
57
+ visibility: visible;
58
+ opacity: 1;
59
+ }
60
+ /* Show login/logout pages immediately */
61
+ body.auth-page {
62
+ visibility: visible;
63
+ opacity: 1;
64
+ }
65
+ /* Style auth button consistently */
66
+ .auth-btn {
67
+ background: none;
68
+ border: none;
69
+ color: var(--text-secondary);
70
+ cursor: pointer;
71
+ padding: 0.5rem;
72
+ border-radius: 0.5rem;
73
+ transition: all 0.2s;
74
+ font-size: 1.1rem;
75
+ }
76
+ .auth-btn:hover {
77
+ background: var(--bg-secondary);
78
+ color: var(--text-primary);
79
+ }
80
+ </style>
81
+
82
+
83
+ <!-- Favicon -->
84
+ <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>✨</text></svg>">
85
+
86
+ <script type="application/ld+json">
87
+ {
88
+ "@context": "https://schema.org",
89
+ "@type": "TechArticle",
90
+ "headline": "User Management Tooling",
91
+ "description": "This document provides comprehensive documentation for the Supabase user management system created for doc-builder authenticated sites.",
92
+ "author": {
93
+ "@type": "Person",
94
+ "name": "Lindsay Smith"
95
+ },
96
+ "publisher": {
97
+ "@type": "Organization",
98
+ "name": "Knowcode Ltd",
99
+ "url": "https://knowcode.tech"
100
+ },
101
+ "datePublished": "2025-07-26T10:38:42.038Z",
102
+ "dateModified": "2025-07-26T10:38:42.038Z",
103
+ "mainEntityOfPage": {
104
+ "@type": "WebPage",
105
+ "@id": "https://doc-builder-delta.vercel.app/private/user-management-tooling.html"
106
+ },
107
+ "breadcrumb": {
108
+ "@type": "BreadcrumbList",
109
+ "itemListElement": [
110
+ {
111
+ "@type": "ListItem",
112
+ "position": 1,
113
+ "name": "@knowcode/doc-builder",
114
+ "item": "https://doc-builder-delta.vercel.app"
115
+ },
116
+ {
117
+ "@type": "ListItem",
118
+ "position": 2,
119
+ "name": "Private",
120
+ "item": "https://doc-builder-delta.vercel.app/private/"
121
+ },
122
+ {
123
+ "@type": "ListItem",
124
+ "position": 3,
125
+ "name": "User Management Tooling",
126
+ "item": "https://doc-builder-delta.vercel.app/private/user-management-tooling.html"
127
+ }
128
+ ]
129
+ }
130
+ }
131
+ </script>
132
+ </head>
133
+ <body>
134
+ <!-- Header -->
135
+ <header class="header">
136
+ <div class="header-content">
137
+ <a href="/index.html" class="logo">@knowcode/doc-builder</a>
138
+
139
+ <div class="header-actions">
140
+ <div class="deployment-info">
141
+ <span class="deployment-date" title="Built with doc-builder v1.8.1">Last updated: Jul 26, 2025, 10:38 AM UTC</span>
142
+ </div>
143
+
144
+
145
+ <a href="../../login.html" class="auth-btn" title="Login/Logout">
146
+ <i class="fas fa-sign-in-alt"></i>
147
+ </a>
148
+
149
+
150
+ <button id="theme-toggle" class="theme-toggle" aria-label="Toggle theme">
151
+ <i class="fas fa-moon"></i>
152
+ </button>
153
+
154
+ <button id="menu-toggle" class="menu-toggle" aria-label="Toggle menu">
155
+ <i class="fas fa-bars"></i>
156
+ </button>
157
+ </div>
158
+ </div>
159
+ </header>
160
+
161
+ <!-- Preview Banner -->
162
+ <div id="preview-banner" class="preview-banner">
163
+ <div class="banner-content">
164
+ <i class="fas fa-exclamation-triangle banner-icon"></i>
165
+ <span class="banner-text">This documentation is a preview version - some content may be incomplete</span>
166
+ <button id="dismiss-banner" class="banner-dismiss" aria-label="Dismiss banner">
167
+ <i class="fas fa-times"></i>
168
+ </button>
169
+ </div>
170
+ </div>
171
+
172
+ <!-- Breadcrumbs -->
173
+ <nav class="breadcrumbs" id="breadcrumbs">
174
+ <!-- Breadcrumbs will be generated by JavaScript -->
175
+ </nav>
176
+
177
+ <!-- Main Content -->
178
+ <div class="main-wrapper">
179
+ <!-- Sidebar -->
180
+ <aside class="sidebar">
181
+ <div class="sidebar-header">
182
+ <div class="filter-box">
183
+ <input type="text" placeholder="Filter items..." class="filter-input" id="nav-filter">
184
+ <i class="fas fa-search filter-icon"></i>
185
+ </div>
186
+ </div>
187
+ <nav class="navigation">
188
+
189
+ <div class="nav-section" data-level="0">
190
+ <a class="nav-title" href="/README.html" >
191
+ <i class="fas fa-home"></i> Documentation
192
+ </a>
193
+ <div class="nav-content" >
194
+ <a href="/README.html" class="nav-item" data-tooltip="@knowcode/doc-builder."><i class="fas fa-file-alt"></i> Overview</a>
195
+ <a href="/documentation-index.html" class="nav-item" data-tooltip="This directory contains additional documentation for the @knowcode/doc-builder project, organized by topic and purpose."><i class="fas fa-file-alt"></i> Documentation Index</a>
196
+ <a href="/vercel-cli-setup-guide.html" class="nav-item" data-tooltip="This guide provides comprehensive instructions for installing the Vercel CLI across different operating systems."><i class="fas fa-file-alt"></i> Vercel Cli Setup Guide</a>
197
+ <a href="/vercel-first-time-setup-guide.html" class="nav-item" data-tooltip="This guide walks you through the Vercel deployment process when using ."><i class="fas fa-file-alt"></i> Vercel First Time Setup Guide</a></div></div>
198
+ <div class="nav-section" data-level="1">
199
+ <a class="nav-title collapsible" href="#" data-target="nav-guides-1" >
200
+ <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Guides
201
+ </a>
202
+ <div class="nav-content collapsed" id="nav-guides-1">
203
+ <a href="/guides/authentication-default-change.html" class="nav-item" data-tooltip="Starting from version 1.7.4, @knowcode/doc-builder now defaults to no authentication for all documentation sites."><i class="fas fa-file-alt"></i> Authentication Default Change</a>
204
+ <a href="/guides/authentication-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase - a secure, scalable authentication platform."><i class="fas fa-file-alt"></i> Authentication Guide</a>
205
+ <a href="/guides/claude-workflow-guide.html" class="nav-item" data-tooltip="This guide demonstrates an efficient workflow for using Claude Code with a refined CLAUDE.md file to create high-quality documentation and deploy it..."><i class="fas fa-file-alt"></i> Claude Workflow Guide</a>
206
+ <a href="/guides/documentation-standards.html" class="nav-item" data-tooltip="This document defines the documentation standards and conventions for the @knowcode/doc-builder project."><i class="fas fa-file-alt"></i> Documentation Standards</a>
207
+ <a href="/guides/phosphor-icons-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder automatically converts Unicode emojis in your markdown files to beautiful Phosphor icons in the generated HTML."><i class="fas fa-file-alt"></i> Phosphor Icons Guide</a>
208
+ <a href="/guides/private-directory-authentication.html" class="nav-item" data-tooltip="The @knowcode/doc-builder provides flexible authentication options to protect your documentation."><i class="fas fa-file-alt"></i> Private Directory Authentication</a>
209
+ <a href="/guides/public-site-deployment.html" class="nav-item" data-tooltip="The @knowcode/doc-builder now supports deploying public documentation sites without authentication."><i class="fas fa-file-alt"></i> Public Site Deployment</a>
210
+ <a href="/guides/search-engine-verification-guide.html" class="nav-item" data-tooltip="Search engine verification provides access to powerful webmaster tools:."><i class="fas fa-file-alt"></i> Search Engine Verification Guide</a>
211
+ <a href="/guides/seo-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder includes comprehensive SEO (Search Engine Optimization) features to help your documentation rank better in search results and..."><i class="fas fa-file-alt"></i> Seo Guide</a>
212
+ <a href="/guides/seo-optimization-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder includes comprehensive SEO (Search Engine Optimization) features that automatically optimize your documentation for search..."><i class="fas fa-file-alt"></i> Seo Optimization Guide</a>
213
+ <a href="/guides/troubleshooting-guide.html" class="nav-item" data-tooltip="This guide helps you resolve common issues when using @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Troubleshooting Guide</a>
214
+ <a href="/guides/windows-setup-guide.html" class="nav-item" data-tooltip="This guide helps Windows users set up the complete AI-powered documentation workflow using Claude Code, @knowcode/doc-builder, and Vercel."><i class="fas fa-file-alt"></i> Windows Setup Guide</a></div></div>
215
+ <div class="nav-section" data-level="1">
216
+ <a class="nav-title collapsible expanded" href="#" data-target="nav-private-1" >
217
+ <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Private
218
+ </a>
219
+ <div class="nav-content" id="nav-private-1">
220
+ <a href="/private/cache-control-anti-pattern.html" class="nav-item" data-tooltip="Cache Control Anti-Pattern: Why Aggressive Cache-Busting is Bad for Documentation Sites."><i class="fas fa-file-alt"></i> Cache Control Anti Pattern</a>
221
+ <a href="/private/next-steps-walkthrough.html" class="nav-item" data-tooltip="Now that we&#039;ve implemented Supabase authentication, let&#039;s walk through testing the implementation and preparing for deployment."><i class="fas fa-file-alt"></i> Next Steps Walkthrough</a>
222
+ <a href="/private/supabase-auth-implementation-completed.html" class="nav-item" data-tooltip="This document records the successful implementation of Supabase authentication in @knowcode/doc-builder v1.7.5+."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Completed</a>
223
+ <a href="/private/supabase-auth-implementation-plan.html" class="nav-item" data-tooltip="Supabase Auth Implementation Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Implementation Plan</a>
224
+ <a href="/private/supabase-auth-integration-plan.html" class="nav-item" data-tooltip="Supabase Authentication Integration Plan for @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Supabase Auth Integration Plan</a>
225
+ <a href="/private/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder supports enterprise-grade authentication through Supabase."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
226
+ <a href="/private/test-private-doc.html" class="nav-item" data-tooltip="Test Private Document."><i class="fas fa-file-alt"></i> Test Private Doc</a>
227
+ <a href="/private/user-management-tooling.html" class="nav-item active" data-tooltip="The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with."><i class="fas fa-file-alt"></i> User Management Tooling</a></div></div>
228
+ <div class="nav-section" data-level="2">
229
+ <a class="nav-title collapsible" href="/private/launch/README.html" data-target="nav-private-launch-2" >
230
+ <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
231
+ </a>
232
+ <div class="nav-content collapsed" id="nav-private-launch-2">
233
+ <a href="/private/launch/README.html" class="nav-item" data-tooltip="This directory contains all documentation related to the commercial launch of @knowcode/doc-builder, including go-to-market strategy, platform..."><i class="fas fa-file-alt"></i> Launch Overview</a>
234
+ <a href="/private/launch/auth-cleanup-summary.html" class="nav-item" data-tooltip="All references to the old client-side authentication system have been removed from @knowcode/doc-builder."><i class="fas fa-file-alt"></i> Auth Cleanup Summary</a>
235
+ <a href="/private/launch/bubble-plugin-specification.html" class="nav-item" data-tooltip="This document outlines the technical specification for creating a Bubble.io plugin that integrates @knowcode/doc-builder, enabling Bubble developers..."><i class="fas fa-file-alt"></i> Bubble Plugin Specification</a>
236
+ <a href="/private/launch/go-to-market-strategy.html" class="nav-item" data-tooltip="Go-to-Market Strategy &amp; Product Launch Plan."><i class="fas fa-file-alt"></i> Go To Market Strategy</a>
237
+ <a href="/private/launch/launch-announcements.html" class="nav-item" data-tooltip="This document contains ready-to-use announcement templates for launching @knowcode/doc-builder across various platforms and channels."><i class="fas fa-file-alt"></i> Launch Announcements</a>
238
+ <a href="/private/launch/vercel-deployment-auth-setup.html" class="nav-item" data-tooltip="Vercel Deployment Authentication Setup Guide."><i class="fas fa-file-alt"></i> Vercel Deployment Auth Setup</a></div></div>
239
+ </nav>
240
+ <div class="resize-handle"></div>
241
+ </aside>
242
+
243
+ <!-- Content Area -->
244
+ <main class="content">
245
+ <div class="content-inner">
246
+ <h1>User Management Tooling</h1>
247
+ <p>This document provides comprehensive documentation for the Supabase user management system created for doc-builder authenticated sites.</p>
248
+ <h2>Overview</h2>
249
+ <p>The user management system is a set of tools designed to manage user access to Supabase-authenticated documentation sites built with <code>@knowcode/doc-builder</code>. It provides a command-line interface for adding users, managing site access, and handling bulk operations.</p>
250
+ <h2>System Architecture</h2>
251
+ <h3>Components</h3>
252
+ <ol>
253
+ <li><p><strong>Main Script</strong> (<code>user-management/add-users.sh</code>)</p>
254
+ <ul>
255
+ <li>Bash script providing the primary CLI interface</li>
256
+ <li>Handles all user management operations</li>
257
+ <li>Beautiful colored output with comprehensive help system</li>
258
+ </ul>
259
+ </li>
260
+ <li><p><strong>Node.js Helper</strong> (<code>user-management/create-user.js</code>)</p>
261
+ <ul>
262
+ <li>Programmatic user creation using Supabase Admin API</li>
263
+ <li>Uses service role key for admin privileges</li>
264
+ <li>Handles password reset email sending</li>
265
+ </ul>
266
+ </li>
267
+ <li><p><strong>Configuration Files</strong></p>
268
+ <ul>
269
+ <li><code>.env.example</code> - Template for environment variables</li>
270
+ <li><code>.supabase-config</code> - Stores project ID after setup</li>
271
+ <li><code>users.txt</code> - Example bulk user file</li>
272
+ </ul>
273
+ </li>
274
+ </ol>
275
+ <h3>Database Schema</h3>
276
+ <p>The system works with two main tables:</p>
277
+ <p><strong>docbuilder_sites</strong></p>
278
+ <ul>
279
+ <li><code>id</code> (UUID) - Primary key</li>
280
+ <li><code>domain</code> (TEXT) - Site URL without https://</li>
281
+ <li><code>name</code> (TEXT) - Display name</li>
282
+ <li><code>created_at</code> (TIMESTAMP)</li>
283
+ </ul>
284
+ <p><strong>docbuilder_access</strong></p>
285
+ <ul>
286
+ <li><code>user_id</code> (UUID) - References auth.users</li>
287
+ <li><code>site_id</code> (UUID) - References docbuilder_sites</li>
288
+ <li><code>created_at</code> (TIMESTAMP)</li>
289
+ <li>Composite primary key on (user_id, site_id)</li>
290
+ </ul>
291
+ <h2>Implementation Details</h2>
292
+ <h3>User Creation Methods</h3>
293
+ <p>Due to Supabase CLI limitations (no direct user creation commands), the system offers three methods:</p>
294
+ <ol>
295
+ <li><p><strong>Manual Dashboard Creation</strong> (Recommended)</p>
296
+ <ul>
297
+ <li>Opens Supabase dashboard</li>
298
+ <li>User creates account via invitation</li>
299
+ <li>Most reliable method</li>
300
+ </ul>
301
+ </li>
302
+ <li><p><strong>Programmatic Creation</strong> (Advanced)</p>
303
+ <ul>
304
+ <li>Requires service role key</li>
305
+ <li>Uses Supabase Admin API</li>
306
+ <li>Automatically sends password reset email</li>
307
+ <li>Implementation:<pre><code class="language-javascript">const { data, error } = await supabase.auth.admin.createUser({
308
+ email: email,
309
+ email_confirm: true,
310
+ password: Math.random().toString(36).slice(2) + Math.random().toString(36).slice(2).toUpperCase()
311
+ });
312
+ </code></pre>
313
+ </li>
314
+ </ul>
315
+ </li>
316
+ <li><p><strong>Skip Creation</strong></p>
317
+ <ul>
318
+ <li>For users that already exist in the system</li>
319
+ <li>Proceeds directly to access granting</li>
320
+ </ul>
321
+ </li>
322
+ </ol>
323
+ <h3>SQL Execution Fallback Strategy</h3>
324
+ <p>The script implements multiple fallback methods for SQL execution to handle different Supabase CLI versions:</p>
325
+ <ol>
326
+ <li><p><strong>psql with DATABASE_URL</strong></p>
327
+ <ul>
328
+ <li>First attempt if DATABASE_URL is set</li>
329
+ <li>Direct PostgreSQL connection</li>
330
+ </ul>
331
+ </li>
332
+ <li><p><strong>Supabase db execute</strong></p>
333
+ <ul>
334
+ <li>For newer CLI versions (2.7+)</li>
335
+ <li>Pipes SQL through stdin</li>
336
+ </ul>
337
+ </li>
338
+ <li><p><strong>Manual execution</strong></p>
339
+ <ul>
340
+ <li>Shows SQL in terminal</li>
341
+ <li>Provides dashboard link</li>
342
+ <li>Waits for user confirmation</li>
343
+ </ul>
344
+ </li>
345
+ </ol>
346
+ <h3>Key Functions</h3>
347
+ <p><strong>execute_sql()</strong></p>
348
+ <ul>
349
+ <li>Attempts multiple SQL execution methods</li>
350
+ <li>Provides graceful degradation</li>
351
+ <li>Always ensures operation completion</li>
352
+ </ul>
353
+ <p><strong>create_user()</strong></p>
354
+ <ul>
355
+ <li>Checks if user exists</li>
356
+ <li>Offers creation options</li>
357
+ <li>Handles all three creation methods</li>
358
+ </ul>
359
+ <p><strong>grant_access()</strong></p>
360
+ <ul>
361
+ <li>Uses PL/pgSQL for atomic operations</li>
362
+ <li>Validates site and user existence</li>
363
+ <li>Handles duplicate access gracefully</li>
364
+ </ul>
365
+ <h2>Usage Guide</h2>
366
+ <h3>Initial Setup</h3>
367
+ <pre><code class="language-bash"># First time setup
368
+ cd user-management
369
+ ./add-users.sh setup
370
+
371
+ # Enter your Supabase project ID when prompted
372
+ # This links the project and saves configuration
373
+ </code></pre>
374
+ <h3>Common Operations</h3>
375
+ <p><strong>Add a single user:</strong></p>
376
+ <pre><code class="language-bash">./add-users.sh add wru-bid-analysis.vercel.app user@email.com
377
+ </code></pre>
378
+ <p><strong>Bulk add from file:</strong></p>
379
+ <pre><code class="language-bash">./add-users.sh bulk wru-bid-analysis.vercel.app users.txt
380
+ </code></pre>
381
+ <p><strong>List users for a site:</strong></p>
382
+ <pre><code class="language-bash">./add-users.sh list wru-bid-analysis.vercel.app
383
+ </code></pre>
384
+ <p><strong>Check user status:</strong></p>
385
+ <pre><code class="language-bash">./add-users.sh check user@email.com
386
+ </code></pre>
387
+ <p><strong>Remove access:</strong></p>
388
+ <pre><code class="language-bash">./add-users.sh remove wru-bid-analysis.vercel.app user@email.com
389
+ </code></pre>
390
+ <h3>File Formats</h3>
391
+ <p><strong>users.txt format:</strong></p>
392
+ <pre><code># Comments start with #
393
+ # One email per line
394
+ john@example.com
395
+ jane@example.com
396
+ admin@company.com
397
+ </code></pre>
398
+ <p><strong>.env format:</strong></p>
399
+ <pre><code class="language-bash"># Your Supabase project ID
400
+ SUPABASE_PROJECT_ID=your-project-id-here
401
+
402
+ # Optional: Service role key for programmatic creation
403
+ SUPABASE_SERVICE_ROLE_KEY=your-service-role-key-here
404
+
405
+ # Optional: Direct database URL
406
+ DATABASE_URL=postgresql://postgres:[password]@db.[project-id].supabase.co:5432/postgres
407
+ </code></pre>
408
+ <h2>Security Considerations</h2>
409
+ <ol>
410
+ <li><p><strong>Service Role Key</strong></p>
411
+ <ul>
412
+ <li>Never commit to version control</li>
413
+ <li>Only stored temporarily in memory</li>
414
+ <li>Used only for user creation</li>
415
+ </ul>
416
+ </li>
417
+ <li><p><strong>Password Management</strong></p>
418
+ <ul>
419
+ <li>System never handles user passwords</li>
420
+ <li>Random temporary passwords generated</li>
421
+ <li>Users must reset password via email</li>
422
+ </ul>
423
+ </li>
424
+ <li><p><strong>Access Control</strong></p>
425
+ <ul>
426
+ <li>Users only see sites they have access to</li>
427
+ <li>All operations are logged with timestamps</li>
428
+ <li>Destructive operations require confirmation</li>
429
+ </ul>
430
+ </li>
431
+ </ol>
432
+ <h2>Troubleshooting</h2>
433
+ <h3>Common Issues</h3>
434
+ <p><strong>&quot;unknown command &#39;users&#39; for &#39;supabase&#39;&quot;</strong></p>
435
+ <ul>
436
+ <li>Expected behavior - Supabase CLI doesn&#39;t have user commands</li>
437
+ <li>Use the manual dashboard method or service role key</li>
438
+ </ul>
439
+ <p><strong>&quot;unknown shorthand flag: &#39;f&#39; in -f&quot;</strong></p>
440
+ <ul>
441
+ <li>Old Supabase CLI version</li>
442
+ <li>Script automatically falls back to piping method</li>
443
+ </ul>
444
+ <p><strong>&quot;command not found: supabase db execute&quot;</strong></p>
445
+ <ul>
446
+ <li>CLI version 2.6.8 or older</li>
447
+ <li>Script provides SQL for manual execution</li>
448
+ </ul>
449
+ <h3>Recommended Solutions</h3>
450
+ <ol>
451
+ <li><p><strong>Update Supabase CLI</strong></p>
452
+ <pre><code class="language-bash">npm update -g supabase
453
+ </code></pre>
454
+ </li>
455
+ <li><p><strong>Set DATABASE_URL</strong></p>
456
+ <ul>
457
+ <li>Get from Supabase dashboard</li>
458
+ <li>Add to .env file</li>
459
+ <li>Enables direct psql execution</li>
460
+ </ul>
461
+ </li>
462
+ <li><p><strong>Use Service Role Key</strong></p>
463
+ <ul>
464
+ <li>For automated user creation</li>
465
+ <li>Find in project API settings</li>
466
+ </ul>
467
+ </li>
468
+ </ol>
469
+ <h2>Limitations</h2>
470
+ <ol>
471
+ <li><p><strong>User Deletion</strong></p>
472
+ <ul>
473
+ <li>CLI cannot delete users from auth.users</li>
474
+ <li>Only removes access records</li>
475
+ <li>Full deletion requires dashboard</li>
476
+ </ul>
477
+ </li>
478
+ <li><p><strong>Batch Operations</strong></p>
479
+ <ul>
480
+ <li>No transaction support across user creation</li>
481
+ <li>Failures are reported but don&#39;t roll back</li>
482
+ </ul>
483
+ </li>
484
+ <li><p><strong>CLI Version Dependencies</strong></p>
485
+ <ul>
486
+ <li>Features vary by Supabase CLI version</li>
487
+ <li>Script handles gracefully but manual steps may be needed</li>
488
+ </ul>
489
+ </li>
490
+ </ol>
491
+ <h2>Best Practices</h2>
492
+ <ol>
493
+ <li><p><strong>User Onboarding</strong></p>
494
+ <ul>
495
+ <li>Create users.txt file for teams</li>
496
+ <li>Use bulk add for efficiency</li>
497
+ <li>Verify with list command</li>
498
+ </ul>
499
+ </li>
500
+ <li><p><strong>Access Management</strong></p>
501
+ <ul>
502
+ <li>Regularly audit with list/check commands</li>
503
+ <li>Remove access promptly when needed</li>
504
+ <li>Document site ownership</li>
505
+ </ul>
506
+ </li>
507
+ <li><p><strong>Security</strong></p>
508
+ <ul>
509
+ <li>Keep service role key secure</li>
510
+ <li>Use .gitignore for sensitive files</li>
511
+ <li>Rotate keys periodically</li>
512
+ </ul>
513
+ </li>
514
+ </ol>
515
+ <h2>Integration with doc-builder</h2>
516
+ <p>The user management system integrates seamlessly with <code>@knowcode/doc-builder</code>:</p>
517
+ <ol>
518
+ <li><p><strong>Authentication Flow</strong></p>
519
+ <ul>
520
+ <li>Users receive password reset email</li>
521
+ <li>Set password and login</li>
522
+ <li>Access controlled by docbuilder_access table</li>
523
+ </ul>
524
+ </li>
525
+ <li><p><strong>Site Management</strong></p>
526
+ <ul>
527
+ <li>Each deployed doc site has entry in docbuilder_sites</li>
528
+ <li>Access is per-site, not global</li>
529
+ <li>Multiple sites can share users</li>
530
+ </ul>
531
+ </li>
532
+ <li><p><strong>Deployment Workflow</strong></p>
533
+ <ul>
534
+ <li>Deploy site with doc-builder</li>
535
+ <li>Add site to docbuilder_sites table</li>
536
+ <li>Use this tool to grant user access</li>
537
+ </ul>
538
+ </li>
539
+ </ol>
540
+ <h2>Future Enhancements</h2>
541
+ <p>Potential improvements identified:</p>
542
+ <ol>
543
+ <li><p><strong>API Integration</strong></p>
544
+ <ul>
545
+ <li>REST API for user management</li>
546
+ <li>Web interface for non-technical users</li>
547
+ <li>Webhook notifications</li>
548
+ </ul>
549
+ </li>
550
+ <li><p><strong>Enhanced Features</strong></p>
551
+ <ul>
552
+ <li>Role-based access control</li>
553
+ <li>Temporary access grants</li>
554
+ <li>Access expiration dates</li>
555
+ </ul>
556
+ </li>
557
+ <li><p><strong>Better CLI Integration</strong></p>
558
+ <ul>
559
+ <li>Direct integration with doc-builder CLI</li>
560
+ <li>Automated site creation on deployment</li>
561
+ <li>User sync from external systems</li>
562
+ </ul>
563
+ </li>
564
+ </ol>
565
+ <h2>Conclusion</h2>
566
+ <p>This user management system provides a robust solution for managing access to Supabase-authenticated documentation sites. Despite Supabase CLI limitations, it offers multiple workarounds and maintains a user-friendly interface with comprehensive error handling and beautiful terminal output.</p>
567
+ <p>The system successfully demonstrates how to work around platform limitations while providing a professional tool that handles real-world authentication and authorization requirements.</p>
568
+
569
+ </div>
570
+ </main>
571
+ </div>
572
+
573
+ <!-- Scripts -->
574
+ <script>
575
+ // Pass configuration to frontend
576
+ window.docBuilderConfig = {
577
+ features: {
578
+ showPdfDownload: true,
579
+ menuDefaultOpen: false
580
+ }
581
+ };
582
+ </script>
583
+ <script src="/js/main.js"></script>
584
+ <script src="https://unpkg.com/@supabase/supabase-js@2"></script>
585
+ <script src="/js/auth.js"></script>
586
+ </body>
587
+ </html>