@knowcode/doc-builder 1.7.6 → 1.8.0

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/.claude/settings.local.json +3 -1
  2. package/CHANGELOG.md +22 -0
  3. package/assets/css/notion-style.css +9 -1
  4. package/html/README.html +5 -19
  5. package/html/css/notion-style.css +9 -1
  6. package/html/documentation-index.html +5 -19
  7. package/html/guides/authentication-default-change.html +5 -19
  8. package/html/guides/authentication-guide.html +189 -262
  9. package/html/guides/claude-workflow-guide.html +5 -19
  10. package/html/guides/documentation-standards.html +5 -19
  11. package/html/guides/phosphor-icons-guide.html +5 -19
  12. package/html/guides/private-directory-authentication.html +352 -0
  13. package/html/guides/public-site-deployment.html +11 -24
  14. package/html/guides/search-engine-verification-guide.html +5 -19
  15. package/html/guides/seo-guide.html +5 -19
  16. package/html/guides/seo-optimization-guide.html +5 -19
  17. package/html/guides/troubleshooting-guide.html +5 -19
  18. package/html/guides/windows-setup-guide.html +5 -19
  19. package/html/index.html +5 -19
  20. package/html/private/cache-control-anti-pattern.html +347 -0
  21. package/html/private/launch/README.html +289 -0
  22. package/html/private/launch/auth-cleanup-summary.html +279 -0
  23. package/html/private/launch/bubble-plugin-specification.html +925 -0
  24. package/html/private/launch/go-to-market-strategy.html +655 -0
  25. package/html/private/launch/launch-announcements.html +585 -0
  26. package/html/private/launch/vercel-deployment-auth-setup.html +329 -0
  27. package/html/private/next-steps-walkthrough.html +624 -0
  28. package/html/private/supabase-auth-implementation-completed.html +372 -0
  29. package/html/private/supabase-auth-implementation-plan.html +529 -0
  30. package/html/private/supabase-auth-integration-plan.html +657 -0
  31. package/html/private/supabase-auth-setup-guide.html +484 -0
  32. package/html/private/test-private-doc.html +220 -0
  33. package/html/sitemap.xml +113 -29
  34. package/html/vercel-cli-setup-guide.html +5 -19
  35. package/html/vercel-first-time-setup-guide.html +5 -19
  36. package/lib/config.js +24 -0
  37. package/lib/core-builder.js +40 -6
  38. package/lib/supabase-auth.js +60 -11
  39. package/package.json +1 -1
  40. package/user-management/README.md +81 -0
  41. package/user-management/add-users.sh +357 -0
  42. package/user-management/users.txt +15 -0
@@ -65,8 +65,8 @@
65
65
  "name": "Knowcode Ltd",
66
66
  "url": "https://knowcode.tech"
67
67
  },
68
- "datePublished": "2025-07-25T13:49:06.580Z",
69
- "dateModified": "2025-07-25T13:49:06.580Z",
68
+ "datePublished": "2025-07-26T09:59:23.016Z",
69
+ "dateModified": "2025-07-26T09:59:23.016Z",
70
70
  "mainEntityOfPage": {
71
71
  "@type": "WebPage",
72
72
  "@id": "https://doc-builder-delta.vercel.app/vercel-first-time-setup-guide.html"
@@ -99,7 +99,7 @@
99
99
 
100
100
  <div class="header-actions">
101
101
  <div class="deployment-info">
102
- <span class="deployment-date" title="Built with doc-builder v1.7.5">Last updated: Jul 25, 2025, 01:49 PM UTC</span>
102
+ <span class="deployment-date" title="Built with doc-builder v1.8.0">Last updated: Jul 26, 2025, 09:59 AM UTC</span>
103
103
  </div>
104
104
 
105
105
 
@@ -158,31 +158,17 @@
158
158
  </a>
159
159
  <div class="nav-content collapsed" id="nav-guides-1">
160
160
  <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>
161
- <a href="/guides/authentication-guide.html" class="nav-item" data-tooltip="🚨 This authentication method has been REMOVED in version 2.0.0 due to serious security flaws."><i class="fas fa-file-alt"></i> Authentication Guide</a>
162
- <a href="/guides/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>
161
+ <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>
163
162
  <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>
164
163
  <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>
165
- <a href="/guides/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>
166
164
  <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>
165
+ <a href="/guides/private-directory-authentication.html" class="nav-item" data-tooltip="The @knowcode/doc-builder now includes automatic authentication for documents placed in a directory."><i class="fas fa-file-alt"></i> Private Directory Authentication</a>
167
166
  <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>
168
167
  <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>
169
168
  <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>
170
169
  <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>
171
- <a href="/guides/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>
172
- <a href="/guides/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>
173
- <a href="/guides/supabase-auth-setup-guide.html" class="nav-item" data-tooltip="@knowcode/doc-builder now supports enterprise-grade authentication through Supabase, replacing the previous insecure basic authentication."><i class="fas fa-file-alt"></i> Supabase Auth Setup Guide</a>
174
170
  <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>
175
- <a href="/guides/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>
176
171
  <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>
177
- <div class="nav-section" data-level="1">
178
- <a class="nav-title collapsible" href="/launch/README.html" data-target="nav-launch-1" >
179
- <i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Launch
180
- </a>
181
- <div class="nav-content collapsed" id="nav-launch-1">
182
- <a href="/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>
183
- <a href="/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>
184
- <a href="/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>
185
- <a href="/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></div></div>
186
172
  </nav>
187
173
  <div class="resize-handle"></div>
188
174
  </aside>
package/lib/config.js CHANGED
@@ -303,6 +303,30 @@ async function loadConfig(configPath, options = {}) {
303
303
  console.log(chalk.gray(`Create it with: mkdir ${config.docsDir} && echo "# Documentation" > ${config.docsDir}/README.md`));
304
304
  }
305
305
  // Don't throw error - let commands handle missing directories appropriately
306
+ } else {
307
+ // Check for private directory and auto-enable authentication if found
308
+ const privatePath = path.join(docsPath, 'private');
309
+ if (fs.existsSync(privatePath) && fs.statSync(privatePath).isDirectory()) {
310
+ // Only auto-enable if not already configured
311
+ if (!config.features.authentication) {
312
+ console.log(chalk.blue('🔐 Found private directory - automatically enabling Supabase authentication'));
313
+ config.features.authentication = 'supabase';
314
+ config.features.autoAuthEnabled = true; // Track that this was auto-enabled
315
+
316
+ // Check if Supabase credentials are configured
317
+ if (!config.auth.supabaseUrl || !config.auth.supabaseAnonKey || !config.auth.siteId) {
318
+ console.warn(chalk.yellow('⚠️ Supabase credentials not configured. Private directory found but authentication will not work.'));
319
+ console.warn(chalk.yellow(' To enable authentication, set the following in your config:'));
320
+ console.warn(chalk.yellow(' - auth.supabaseUrl'));
321
+ console.warn(chalk.yellow(' - auth.supabaseAnonKey'));
322
+ console.warn(chalk.yellow(' - auth.siteId'));
323
+ console.warn(chalk.yellow(''));
324
+ console.warn(chalk.yellow(' Or disable authentication by removing the private directory.'));
325
+ // Disable authentication if credentials are missing
326
+ config.features.authentication = false;
327
+ }
328
+ }
329
+ }
306
330
  }
307
331
 
308
332
  return config;
@@ -362,6 +362,21 @@ ${seoTags}
362
362
  visibility: visible;
363
363
  opacity: 1;
364
364
  }
365
+ /* Style auth button consistently */
366
+ .auth-btn {
367
+ background: none;
368
+ border: none;
369
+ color: var(--text-secondary);
370
+ cursor: pointer;
371
+ padding: 0.5rem;
372
+ border-radius: 0.5rem;
373
+ transition: all 0.2s;
374
+ font-size: 1.1rem;
375
+ }
376
+ .auth-btn:hover {
377
+ background: var(--bg-secondary);
378
+ color: var(--text-primary);
379
+ }
365
380
  </style>
366
381
  ` : ''}
367
382
 
@@ -389,8 +404,8 @@ ${seoTags}
389
404
  </div>
390
405
 
391
406
  ${config.features?.authentication === 'supabase' ? `
392
- <a href="${relativePath}logout.html" class="logout-btn" title="Logout">
393
- <i class="fas fa-sign-out-alt"></i>
407
+ <a href="${relativePath}login.html" class="auth-btn" title="Login/Logout">
408
+ <i class="fas fa-sign-in-alt"></i>
394
409
  </a>
395
410
  ` : ''}
396
411
 
@@ -484,10 +499,23 @@ const folderDescriptions = {
484
499
  };
485
500
 
486
501
  // Build navigation structure with rich functionality
487
- function buildNavigationStructure(files, currentFile) {
502
+ function buildNavigationStructure(files, currentFile, config = {}) {
488
503
  const tree = { files: [], folders: {} };
489
504
 
505
+ // Check if authentication is enabled
506
+ const isAuthEnabled = config.features?.authentication === 'supabase';
507
+
508
+ // Filter files based on authentication status and whether we're building for an authenticated page
509
+ // We'll pass a flag from processMarkdownFile to indicate if this is a private page
510
+ const isPrivatePage = currentFile && (currentFile.startsWith('private/') || currentFile.includes('/private/'));
511
+ const shouldIncludePrivate = isAuthEnabled && isPrivatePage;
512
+
490
513
  files.forEach(file => {
514
+ // Skip private files if we're not on an authenticated page
515
+ if (file.isPrivate && !shouldIncludePrivate) {
516
+ return;
517
+ }
518
+
491
519
  const parts = file.urlPath.split('/');
492
520
  let current = tree;
493
521
 
@@ -704,8 +732,8 @@ async function processMarkdownFile(filePath, outputPath, allFiles, config) {
704
732
  // Process content
705
733
  const htmlContent = processMarkdownContent(content, config);
706
734
 
707
- // Build navigation
708
- const navigation = buildNavigationStructure(allFiles, urlPath);
735
+ // Build navigation - pass config to handle private file filtering
736
+ const navigation = buildNavigationStructure(allFiles, urlPath, config);
709
737
 
710
738
  // Generate full HTML (pass original content and front matter for SEO)
711
739
  const html = generateHTML(title, htmlContent, navigation, urlPath, config, content, frontMatter);
@@ -740,12 +768,18 @@ async function getAllMarkdownFiles(dir, baseDir = dir) {
740
768
  const content = await fs.readFile(fullPath, 'utf-8');
741
769
  const summary = extractSummary(content);
742
770
 
771
+ // Check if this file is in the private directory
772
+ const isPrivate = relativePath.split(path.sep)[0] === 'private' ||
773
+ relativePath.startsWith('private/') ||
774
+ relativePath.startsWith('private\\');
775
+
743
776
  files.push({
744
777
  path: fullPath,
745
778
  relativePath,
746
779
  urlPath,
747
780
  displayName,
748
- summary
781
+ summary,
782
+ isPrivate
749
783
  });
750
784
  }
751
785
  }
@@ -58,11 +58,22 @@ class SupabaseAuth {
58
58
  // Check authentication and site access
59
59
  async function checkAuth() {
60
60
  try {
61
+ // Check if current page is in private directory
62
+ const currentPath = window.location.pathname;
63
+ const isPrivatePage = currentPath.includes('/private/');
64
+
61
65
  // Get current user session
62
66
  const { data: { user }, error: userError } = await supabaseClient.auth.getUser();
63
67
 
64
68
  if (userError || !user) {
65
- redirectToLogin();
69
+ // Only redirect if we're on a private page
70
+ if (isPrivatePage) {
71
+ redirectToLogin();
72
+ } else {
73
+ // Public page, just show it
74
+ document.body.classList.add('authenticated'); // Use same class to show body
75
+ updateAuthButton(false);
76
+ }
66
77
  return;
67
78
  }
68
79
 
@@ -75,17 +86,30 @@ class SupabaseAuth {
75
86
  .single();
76
87
 
77
88
  if (accessError || !access) {
78
- showAccessDenied();
89
+ if (isPrivatePage) {
90
+ showAccessDenied();
91
+ } else {
92
+ // Public page, just show it
93
+ document.body.classList.add('authenticated');
94
+ updateAuthButton(false);
95
+ }
79
96
  return;
80
97
  }
81
98
 
82
99
  // User is authenticated and has access
83
100
  console.log('User authenticated and authorized');
84
101
  document.body.classList.add('authenticated');
102
+ updateAuthButton(true);
85
103
 
86
104
  } catch (error) {
87
105
  console.error('Auth check failed:', error);
88
- redirectToLogin();
106
+ if (window.location.pathname.includes('/private/')) {
107
+ redirectToLogin();
108
+ } else {
109
+ // Public page, show it anyway
110
+ document.body.classList.add('authenticated');
111
+ updateAuthButton(false);
112
+ }
89
113
  }
90
114
  }
91
115
 
@@ -110,16 +134,41 @@ class SupabaseAuth {
110
134
  \`;
111
135
  }
112
136
 
113
- // Add logout functionality
137
+ // Function to update auth button
138
+ function updateAuthButton(isAuthenticated) {
139
+ const authBtn = document.querySelector('.auth-btn');
140
+ if (authBtn) {
141
+ const icon = authBtn.querySelector('i');
142
+ if (icon) {
143
+ if (isAuthenticated) {
144
+ icon.className = 'fas fa-sign-out-alt';
145
+ authBtn.title = 'Logout';
146
+ authBtn.href = '/logout.html';
147
+ } else {
148
+ icon.className = 'fas fa-sign-in-alt';
149
+ authBtn.title = 'Login';
150
+ authBtn.href = '/login.html';
151
+ }
152
+ }
153
+ }
154
+ }
155
+
156
+ // Add auth button functionality
114
157
  document.addEventListener('DOMContentLoaded', function() {
115
- const logoutLinks = document.querySelectorAll('a[href*="logout"]');
116
- logoutLinks.forEach(link => {
117
- link.addEventListener('click', async function(e) {
118
- e.preventDefault();
119
- await supabaseClient.auth.signOut();
120
- window.location.href = '/logout.html';
158
+ const authBtn = document.querySelector('.auth-btn');
159
+ if (authBtn) {
160
+ authBtn.addEventListener('click', async function(e) {
161
+ // Check if we're logged in
162
+ const { data: { user } } = await supabaseClient.auth.getUser();
163
+ if (user) {
164
+ // Logged in - sign out
165
+ e.preventDefault();
166
+ await supabaseClient.auth.signOut();
167
+ window.location.href = '/logout.html';
168
+ }
169
+ // If not logged in, normal navigation to login page will occur
121
170
  });
122
- });
171
+ }
123
172
  });
124
173
 
125
174
  // Run auth check
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.7.6",
3
+ "version": "1.8.0",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -0,0 +1,81 @@
1
+ # User Management for Doc-Builder Sites
2
+
3
+ This directory contains a simple scripted solution for managing user access to Supabase-authenticated documentation sites.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # List all documentation sites
9
+ ./add-users.sh sites
10
+
11
+ # Add a single user to a site
12
+ ./add-users.sh add wru-bid-analysis.vercel.app john@example.com
13
+
14
+ # Add multiple users from a file
15
+ ./add-users.sh bulk wru-bid-analysis.vercel.app users.txt
16
+
17
+ # List all users with access to a site
18
+ ./add-users.sh list wru-bid-analysis.vercel.app
19
+
20
+ # Check if a user has access
21
+ ./add-users.sh check wru-bid-analysis.vercel.app john@example.com
22
+
23
+ # Remove user access
24
+ ./add-users.sh remove wru-bid-analysis.vercel.app john@example.com
25
+ ```
26
+
27
+ ## How It Works
28
+
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
32
+
33
+ ## Files
34
+
35
+ - `add-users.sh` - Main user management script
36
+ - `users.txt` - Example file for bulk user additions
37
+ - `USER-MANAGEMENT.md` - This documentation
38
+
39
+ ## Important URLs
40
+
41
+ - Supabase SQL Editor: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/sql
42
+ - Supabase User Management: https://supabase.com/dashboard/project/xcihhnfcitjrwbynxmka/auth/users
43
+
44
+ ## Workflow for Adding New Users
45
+
46
+ 1. First check if the user exists:
47
+ ```bash
48
+ ./add-users.sh check site-url user@email.com
49
+ ```
50
+
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
56
+
57
+ 3. Grant access to the site:
58
+ ```bash
59
+ ./add-users.sh add site-url user@email.com
60
+ ```
61
+ Copy and run the generated SQL
62
+
63
+ 4. Verify access was granted:
64
+ ```bash
65
+ ./add-users.sh list site-url
66
+ ```
67
+
68
+ ## Bulk User Addition
69
+
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
75
+
76
+ ## Notes
77
+
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