@knowcode/doc-builder 1.8.0 → 1.8.1

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 (47) hide show
  1. package/.claude/settings.local.json +4 -1
  2. package/CHANGELOG.md +7 -0
  3. package/assets/js/main.js +10 -6
  4. package/html/README.html +43 -5
  5. package/html/auth.js +62 -13
  6. package/html/documentation-index.html +43 -5
  7. package/html/guides/authentication-default-change.html +43 -5
  8. package/html/guides/authentication-guide.html +43 -5
  9. package/html/guides/claude-workflow-guide.html +43 -5
  10. package/html/guides/documentation-standards.html +43 -5
  11. package/html/guides/phosphor-icons-guide.html +43 -5
  12. package/html/guides/private-directory-authentication.html +237 -117
  13. package/html/guides/public-site-deployment.html +43 -5
  14. package/html/guides/search-engine-verification-guide.html +43 -5
  15. package/html/guides/seo-guide.html +43 -5
  16. package/html/guides/seo-optimization-guide.html +43 -5
  17. package/html/guides/troubleshooting-guide.html +43 -5
  18. package/html/guides/windows-setup-guide.html +43 -5
  19. package/html/index.html +43 -5
  20. package/html/js/auth.js +118 -39
  21. package/html/js/main.js +10 -6
  22. package/html/login.html +4 -4
  23. package/html/logout.html +2 -2
  24. package/html/private/cache-control-anti-pattern.html +66 -5
  25. package/html/private/launch/README.html +66 -5
  26. package/html/private/launch/auth-cleanup-summary.html +66 -5
  27. package/html/private/launch/bubble-plugin-specification.html +66 -5
  28. package/html/private/launch/go-to-market-strategy.html +66 -5
  29. package/html/private/launch/launch-announcements.html +66 -5
  30. package/html/private/launch/vercel-deployment-auth-setup.html +66 -5
  31. package/html/private/next-steps-walkthrough.html +66 -5
  32. package/html/private/supabase-auth-implementation-completed.html +66 -5
  33. package/html/private/supabase-auth-implementation-plan.html +66 -5
  34. package/html/private/supabase-auth-integration-plan.html +66 -5
  35. package/html/private/supabase-auth-setup-guide.html +66 -5
  36. package/html/private/test-private-doc.html +66 -5
  37. package/html/robots.txt +4 -0
  38. package/html/sitemap.xml +43 -43
  39. package/html/vercel-cli-setup-guide.html +43 -5
  40. package/html/vercel-first-time-setup-guide.html +43 -5
  41. package/lib/config.js +15 -21
  42. package/lib/core-builder.js +9 -1
  43. package/lib/supabase-auth.js +20 -14
  44. package/package.json +1 -1
  45. package/user-management/README.md +276 -51
  46. package/user-management/add-users.sh +635 -262
  47. package/user-management/create-user.js +65 -0
@@ -1,81 +1,306 @@
1
- # User Management for Doc-Builder Sites
1
+ # Doc-Builder User Management System
2
2
 
3
- This directory contains a simple scripted solution for managing user access to Supabase-authenticated documentation sites.
3
+ A comprehensive user management solution for Supabase-authenticated documentation sites using the Supabase CLI.
4
4
 
5
- ## Quick Start
5
+ ## 🚀 Quick Start
6
6
 
7
7
  ```bash
8
- # List all documentation sites
9
- ./add-users.sh sites
8
+ # Initial setup
9
+ ./add-users.sh setup
10
+
11
+ # Add a user
12
+ ./add-users.sh add wru-bid-analysis.vercel.app user@email.com
13
+
14
+ # List all users for a site
15
+ ./add-users.sh list wru-bid-analysis.vercel.app
16
+ ```
17
+
18
+ ## 📋 Prerequisites
19
+
20
+ 1. **Install Supabase CLI**:
21
+ ```bash
22
+ npm install -g supabase
23
+ ```
24
+
25
+ 2. **Login to Supabase**:
26
+ ```bash
27
+ supabase login
28
+ ```
29
+
30
+ 3. **Link your project** (or use the setup command):
31
+ ```bash
32
+ ./add-users.sh setup
33
+ ```
34
+
35
+ ## 🔧 Installation
36
+
37
+ The user management system is self-contained in this folder:
38
+
39
+ ```
40
+ user-management/
41
+ ├── add-users.sh # Main script
42
+ ├── users.txt # Example bulk user file
43
+ ├── README.md # This documentation
44
+ └── .env.example # Environment variables template
45
+ ```
46
+
47
+ ## 📖 Commands
48
+
49
+ ### Setup
50
+
51
+ Initialize and link your Supabase project:
52
+
53
+ ```bash
54
+ ./add-users.sh setup
55
+ ```
56
+
57
+ This will:
58
+ - Check if Supabase CLI is installed
59
+ - Verify you're logged in
60
+ - Link your project (prompts for project ID)
61
+ - Test the database connection
62
+ - Save configuration for future use
63
+
64
+ ### Add User
65
+
66
+ Create a user and grant them access to a specific site:
10
67
 
11
- # Add a single user to a site
12
- ./add-users.sh add wru-bid-analysis.vercel.app john@example.com
68
+ ```bash
69
+ ./add-users.sh add <site-url> <email>
70
+
71
+ # Example
72
+ ./add-users.sh add docs.example.com john@company.com
73
+ ```
74
+
75
+ This will:
76
+ - Create the user account if it doesn't exist
77
+ - Send them a password reset email
78
+ - Grant access to the specified site
79
+ - Show confirmation of access granted
13
80
 
14
- # Add multiple users from a file
15
- ./add-users.sh bulk wru-bid-analysis.vercel.app users.txt
81
+ ### Bulk Add Users
16
82
 
17
- # List all users with access to a site
83
+ Add multiple users from a file:
84
+
85
+ ```bash
86
+ ./add-users.sh bulk <site-url> <file>
87
+
88
+ # Example
89
+ ./add-users.sh bulk docs.example.com users.txt
90
+ ```
91
+
92
+ File format (users.txt):
93
+ ```
94
+ # Comments start with #
95
+ # One email per line
96
+ john@example.com
97
+ jane@example.com
98
+ admin@company.com
99
+ ```
100
+
101
+ ### List Users
102
+
103
+ Show all users with access to a site:
104
+
105
+ ```bash
106
+ ./add-users.sh list <site-url>
107
+
108
+ # Example
18
109
  ./add-users.sh list wru-bid-analysis.vercel.app
110
+ ```
111
+
112
+ Output includes:
113
+ - Email address
114
+ - When user was created
115
+ - When access was granted
116
+ - Last login time
117
+ - Total user count
118
+
119
+ ### Check User
19
120
 
20
- # Check if a user has access
21
- ./add-users.sh check wru-bid-analysis.vercel.app john@example.com
121
+ Check a user's status across all sites:
22
122
 
23
- # Remove user access
24
- ./add-users.sh remove wru-bid-analysis.vercel.app john@example.com
123
+ ```bash
124
+ ./add-users.sh check <email>
125
+
126
+ # Example
127
+ ./add-users.sh check user@example.com
25
128
  ```
26
129
 
27
- ## How It Works
130
+ Shows:
131
+ - If user exists
132
+ - All sites they have access to
133
+ - Last login information
134
+
135
+ ### Remove Access
28
136
 
29
- 1. The script generates SQL commands based on your input
30
- 2. Copy the generated SQL and run it in the Supabase SQL Editor
31
- 3. For new users, you'll need to create them in Supabase Dashboard first
137
+ Remove a user's access to a specific site:
32
138
 
33
- ## Files
139
+ ```bash
140
+ ./add-users.sh remove <site-url> <email>
34
141
 
35
- - `add-users.sh` - Main user management script
36
- - `users.txt` - Example file for bulk user additions
37
- - `USER-MANAGEMENT.md` - This documentation
142
+ # Example
143
+ ./add-users.sh remove docs.example.com user@example.com
144
+ ```
38
145
 
39
- ## Important URLs
146
+ Note: This only removes access, it doesn't delete the user account.
40
147
 
41
- - Supabase SQL Editor: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/sql
42
- - Supabase User Management: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
148
+ ### List Sites
43
149
 
44
- ## Workflow for Adding New Users
150
+ Show all documentation sites in the system:
45
151
 
46
- 1. First check if the user exists:
47
- ```bash
48
- ./add-users.sh check site-url user@email.com
49
- ```
152
+ ```bash
153
+ ./add-users.sh sites
154
+ ```
50
155
 
51
- 2. If the user doesn't exist:
52
- - Go to Supabase Dashboard > Authentication > Users
53
- - Click "Invite user"
54
- - Enter the email address
55
- - They'll receive an email to set their password
156
+ Shows:
157
+ - Site ID
158
+ - Domain
159
+ - Site name
160
+ - Creation date
161
+ - Number of users
56
162
 
57
- 3. Grant access to the site:
163
+ ### Delete User
164
+
165
+ Permanently delete a user (removes from ALL sites):
166
+
167
+ ```bash
168
+ ./add-users.sh delete-user <email>
169
+
170
+ # Example
171
+ ./add-users.sh delete-user user@example.com
172
+ ```
173
+
174
+ ⚠️ **Warning**: This is permanent and cannot be undone!
175
+
176
+ ## ⚠️ Important Limitations
177
+
178
+ The Supabase CLI doesn't support direct user creation. The script offers two workarounds:
179
+
180
+ 1. **Manual Creation** (Recommended): Opens the Supabase dashboard where you can invite users
181
+ 2. **Programmatic Creation** (Advanced): If you provide your service_role key, the script can create users using the Admin API
182
+
183
+ ## 🔐 Security Notes
184
+
185
+ 1. **User Creation**: When users are created, they receive a password reset email to set their own password
186
+ 2. **Access Control**: Users only see sites they have explicit access to
187
+ 3. **Audit Trail**: All access grants are timestamped in the database
188
+ 4. **No Passwords**: The system never handles or stores passwords directly
189
+ 5. **Service Role Key**: If using programmatic creation, your service_role key is never stored
190
+
191
+ ## 🛠️ Troubleshooting
192
+
193
+ ### "Supabase CLI not found"
194
+
195
+ Install the Supabase CLI:
196
+ ```bash
197
+ npm install -g supabase
198
+ ```
199
+
200
+ ### "Not logged in to Supabase"
201
+
202
+ Login to your Supabase account:
203
+ ```bash
204
+ supabase login
205
+ ```
206
+
207
+ ### "Project not linked"
208
+
209
+ Run the setup command:
210
+ ```bash
211
+ ./add-users.sh setup
212
+ ```
213
+
214
+ ### "Site not found"
215
+
216
+ Make sure the site exists in the `docbuilder_sites` table. You can check with:
217
+ ```bash
218
+ ./add-users.sh sites
219
+ ```
220
+
221
+ ### "User already exists"
222
+
223
+ This is fine - the script will continue and grant access to the site.
224
+
225
+ ### "Access already granted"
226
+
227
+ The user already has access to this site. No action needed.
228
+
229
+ ## 📊 Database Schema
230
+
231
+ The system uses two main tables:
232
+
233
+ ### docbuilder_sites
234
+ - `id` (UUID) - Primary key
235
+ - `domain` (TEXT) - Site URL without https://
236
+ - `name` (TEXT) - Display name
237
+ - `created_at` (TIMESTAMP)
238
+
239
+ ### docbuilder_access
240
+ - `user_id` (UUID) - References auth.users
241
+ - `site_id` (UUID) - References docbuilder_sites
242
+ - `created_at` (TIMESTAMP)
243
+
244
+ ## 🎯 Common Workflows
245
+
246
+ ### Setting up a new documentation site
247
+
248
+ 1. Add the site to the database (manually or via SQL)
249
+ 2. Add users who should have access:
58
250
  ```bash
59
- ./add-users.sh add site-url user@email.com
251
+ ./add-users.sh add my-docs.vercel.app user1@example.com
252
+ ./add-users.sh add my-docs.vercel.app user2@example.com
60
253
  ```
61
- Copy and run the generated SQL
62
254
 
63
- 4. Verify access was granted:
255
+ ### Onboarding multiple team members
256
+
257
+ 1. Create a users.txt file with all email addresses
258
+ 2. Run bulk add:
64
259
  ```bash
65
- ./add-users.sh list site-url
260
+ ./add-users.sh bulk my-docs.vercel.app users.txt
66
261
  ```
67
262
 
68
- ## Bulk User Addition
263
+ ### Auditing access
264
+
265
+ Check who has access to a site:
266
+ ```bash
267
+ ./add-users.sh list my-docs.vercel.app
268
+ ```
269
+
270
+ Check what sites a user can access:
271
+ ```bash
272
+ ./add-users.sh check user@example.com
273
+ ```
274
+
275
+ ### Offboarding a user
276
+
277
+ Remove from specific site:
278
+ ```bash
279
+ ./add-users.sh remove my-docs.vercel.app former-employee@example.com
280
+ ```
281
+
282
+ Or remove completely:
283
+ ```bash
284
+ ./add-users.sh delete-user former-employee@example.com
285
+ ```
286
+
287
+ ## 🔧 Configuration
288
+
289
+ The script stores its configuration in `.supabase-config` after setup. You can also set environment variables:
290
+
291
+ - `SUPABASE_PROJECT_ID` - Your project ID
292
+ - `SUPABASE_DB_URL` - Database connection URL (optional)
293
+
294
+ ## 📝 Notes
69
295
 
70
- 1. Edit `users.txt` with one email per line
71
- 2. Run: `./add-users.sh bulk site-url users.txt`
72
- 3. The script will generate SQL for all users
73
- 4. Create any missing users in Supabase first
74
- 5. Run the SQL to grant access
296
+ - Site URLs should be entered without `https://` prefix
297
+ - Users receive password reset emails when created
298
+ - The script uses the Supabase CLI for all operations
299
+ - All actions are logged with colored output for clarity
300
+ - Destructive operations require confirmation
75
301
 
76
- ## Notes
302
+ ## 🆘 Support
77
303
 
78
- - Site URLs should be without the `https://` prefix
79
- - Users must exist in Supabase before you can grant them access
80
- - The script only generates SQL - you need to run it manually
81
- - This gives you a chance to review before making changes
304
+ - GitHub: https://github.com/wapdat/doc-builder
305
+ - Documentation: https://doc-builder-delta.vercel.app
306
+ - Supabase Dashboard: https://supabase.com/dashboard