@knowcode/doc-builder 1.7.3 → 1.7.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.
- package/.claude/settings.local.json +6 -1
- package/CHANGELOG.md +24 -0
- package/README.md +23 -6
- package/RELEASE-NOTES-1.7.5.md +64 -0
- package/cli.js +214 -7
- package/grant-access.sql +15 -0
- package/html/README.html +14 -4
- package/html/auth.js +97 -0
- package/html/documentation-index.html +14 -4
- package/html/guides/authentication-default-change.html +302 -0
- package/html/guides/authentication-guide.html +32 -14
- package/html/guides/cache-control-anti-pattern.html +361 -0
- package/html/guides/claude-workflow-guide.html +14 -4
- package/html/guides/documentation-standards.html +14 -4
- package/html/guides/next-steps-walkthrough.html +638 -0
- package/html/guides/phosphor-icons-guide.html +14 -4
- package/html/guides/public-site-deployment.html +363 -0
- package/html/guides/search-engine-verification-guide.html +14 -4
- package/html/guides/seo-guide.html +14 -4
- package/html/guides/seo-optimization-guide.html +14 -4
- package/html/guides/supabase-auth-implementation-plan.html +543 -0
- package/html/guides/supabase-auth-integration-plan.html +671 -0
- package/html/guides/supabase-auth-setup-guide.html +498 -0
- package/html/guides/troubleshooting-guide.html +14 -4
- package/html/guides/vercel-deployment-auth-setup.html +337 -0
- package/html/guides/windows-setup-guide.html +14 -4
- package/html/index.html +14 -4
- package/html/launch/README.html +14 -4
- package/html/launch/bubble-plugin-specification.html +14 -4
- package/html/launch/go-to-market-strategy.html +14 -4
- package/html/launch/launch-announcements.html +14 -4
- package/html/login.html +102 -0
- package/html/logout.html +18 -0
- package/html/sitemap.xml +69 -21
- package/html/vercel-cli-setup-guide.html +14 -4
- package/html/vercel-first-time-setup-guide.html +14 -4
- package/lib/config.js +11 -26
- package/lib/core-builder.js +51 -87
- package/lib/supabase-auth.js +295 -0
- package/package.json +2 -1
- package/public-config.js +22 -0
- package/public-html/404.html +115 -0
- package/public-html/README.html +149 -0
- package/public-html/css/notion-style.css +2036 -0
- package/public-html/index.html +149 -0
- package/public-html/js/auth.js +67 -0
- package/public-html/js/main.js +1485 -0
- package/quick-test-commands.md +40 -0
- package/recordings/Screenshot 2025-07-24 at 18.22.01.png +0 -0
- package/setup-database.sql +41 -0
- package/test-auth-config.js +17 -0
- package/test-docs/README.md +39 -0
- package/test-html/404.html +115 -0
- package/test-html/README.html +172 -0
- package/test-html/auth.js +97 -0
- package/test-html/css/notion-style.css +2036 -0
- package/test-html/index.html +172 -0
- package/test-html/js/auth.js +97 -0
- package/test-html/js/main.js +1485 -0
- package/test-html/login.html +102 -0
- package/test-html/logout.html +18 -0
- package/update-domain.sql +9 -0
|
@@ -29,7 +29,12 @@
|
|
|
29
29
|
"Bash(mkdir:*)",
|
|
30
30
|
"Bash(cp:*)",
|
|
31
31
|
"Bash(./publish.sh)",
|
|
32
|
-
"Bash(mv:*)"
|
|
32
|
+
"Bash(mv:*)",
|
|
33
|
+
"WebFetch(domain:convert-to-markdown.vercel.app)",
|
|
34
|
+
"Bash(pkill:*)",
|
|
35
|
+
"Bash(curl:*)",
|
|
36
|
+
"Bash(./cli.js build:*)",
|
|
37
|
+
"Bash(./cli.js deploy:*)"
|
|
33
38
|
],
|
|
34
39
|
"deny": []
|
|
35
40
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,30 @@ All notable changes to @knowcode/doc-builder will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.5] - 2025-07-25
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **BREAKING**: Authentication is now disabled by default in all configurations
|
|
12
|
+
- Changed default `authentication: false` in both defaultConfig and notionInspiredPreset
|
|
13
|
+
- Public documentation sites now work out of the box without configuration
|
|
14
|
+
- Authentication must be explicitly enabled with `authentication: 'supabase'`
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
- `--no-auth` flag for build command to override authentication settings
|
|
18
|
+
- `--no-auth` flag for deploy command to override authentication settings
|
|
19
|
+
- Documentation for public site deployment workflows
|
|
20
|
+
- Migration guide for authentication changes
|
|
21
|
+
|
|
22
|
+
### Improved
|
|
23
|
+
- Simplified createDefaultConfig to only prompt for Supabase authentication
|
|
24
|
+
- Better alignment with common use case of public documentation
|
|
25
|
+
|
|
26
|
+
## [1.7.4] - 2025-07-24
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
- Republished package to fix potential npm registry issues
|
|
30
|
+
- No code changes from 1.7.3
|
|
31
|
+
|
|
8
32
|
## [1.7.3] - 2025-07-24
|
|
9
33
|
|
|
10
34
|
### Added
|
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ This aligns perfectly with our mission: beautiful documentation should be access
|
|
|
72
72
|
|
|
73
73
|
### 🎯 Advanced Features
|
|
74
74
|
- 🔍 **SEO Optimized** - Meta tags & structured data
|
|
75
|
-
- 🔐 **
|
|
75
|
+
- 🔐 **Optional Auth** - Supabase authentication (opt-in)
|
|
76
76
|
- 📊 **Mermaid Diagrams** - Built-in diagram support
|
|
77
77
|
- 🌙 **Dark Mode** - Automatic theme switching
|
|
78
78
|
- ☁️ **Vercel Deploy** - One-command deployment
|
|
@@ -210,20 +210,38 @@ module.exports = {
|
|
|
210
210
|
|
|
211
211
|
// Features
|
|
212
212
|
features: {
|
|
213
|
-
authentication:
|
|
213
|
+
authentication: 'supabase', // or false for no auth
|
|
214
214
|
changelog: true,
|
|
215
215
|
mermaid: true,
|
|
216
216
|
darkMode: true
|
|
217
217
|
},
|
|
218
218
|
|
|
219
|
-
// Authentication
|
|
219
|
+
// Supabase Authentication
|
|
220
220
|
auth: {
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
supabaseUrl: process.env.SUPABASE_URL,
|
|
222
|
+
supabaseAnonKey: process.env.SUPABASE_ANON_KEY,
|
|
223
|
+
siteId: process.env.DOC_SITE_ID
|
|
223
224
|
}
|
|
224
225
|
};
|
|
225
226
|
```
|
|
226
227
|
|
|
228
|
+
### 🔐 Authentication Setup
|
|
229
|
+
|
|
230
|
+
For secure documentation sites, use Supabase authentication:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Initialize authentication
|
|
234
|
+
npx @knowcode/doc-builder auth:init
|
|
235
|
+
|
|
236
|
+
# Add your site to database
|
|
237
|
+
npx @knowcode/doc-builder auth:add-site --domain docs.example.com --name "My Docs"
|
|
238
|
+
|
|
239
|
+
# Grant user access
|
|
240
|
+
npx @knowcode/doc-builder auth:grant --email user@example.com --site-id xxx
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
See the [Supabase Authentication Guide](docs/guides/supabase-auth-setup-guide.md) for complete setup instructions.
|
|
244
|
+
|
|
227
245
|
## 📋 Commands Overview
|
|
228
246
|
|
|
229
247
|
<table>
|
|
@@ -273,7 +291,6 @@ Options:
|
|
|
273
291
|
-i, --input <dir> Input directory (default: docs)
|
|
274
292
|
-o, --output <dir> Output directory (default: html)
|
|
275
293
|
--preset <preset> Use a preset configuration
|
|
276
|
-
--no-auth Disable authentication
|
|
277
294
|
--no-changelog Disable changelog generation
|
|
278
295
|
|
|
279
296
|
Examples:
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Release Notes - v1.7.5
|
|
2
|
+
|
|
3
|
+
## 🎉 Major Change: Authentication is Now Optional by Default!
|
|
4
|
+
|
|
5
|
+
Starting with v1.7.5, @knowcode/doc-builder defaults to creating **public documentation sites** without authentication. This aligns with the most common use case and makes it even easier to get started.
|
|
6
|
+
|
|
7
|
+
### What's New
|
|
8
|
+
|
|
9
|
+
#### 🔓 No Authentication by Default
|
|
10
|
+
- Documentation sites are now public by default
|
|
11
|
+
- No configuration needed for public docs
|
|
12
|
+
- Authentication must be explicitly enabled when needed
|
|
13
|
+
|
|
14
|
+
#### 🚀 New CLI Flags
|
|
15
|
+
- `--no-auth` flag for both build and deploy commands
|
|
16
|
+
- Override any authentication settings in your config
|
|
17
|
+
- Perfect for quick public deployments
|
|
18
|
+
|
|
19
|
+
### Examples
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Deploy public documentation (default behavior)
|
|
23
|
+
npx @knowcode/doc-builder deploy
|
|
24
|
+
|
|
25
|
+
# Force public deployment even if config has auth
|
|
26
|
+
npx @knowcode/doc-builder deploy --no-auth
|
|
27
|
+
|
|
28
|
+
# Enable authentication in config
|
|
29
|
+
# doc-builder.config.js
|
|
30
|
+
module.exports = {
|
|
31
|
+
features: {
|
|
32
|
+
authentication: 'supabase' // Explicitly enable
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Migration Guide
|
|
38
|
+
|
|
39
|
+
#### If you want PUBLIC documentation:
|
|
40
|
+
No changes needed! Your sites are now public by default.
|
|
41
|
+
|
|
42
|
+
#### If you want PRIVATE documentation:
|
|
43
|
+
Add this to your config:
|
|
44
|
+
```javascript
|
|
45
|
+
features: {
|
|
46
|
+
authentication: 'supabase'
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Why This Change?
|
|
51
|
+
|
|
52
|
+
- Most documentation should be publicly accessible
|
|
53
|
+
- Reduces friction for new users
|
|
54
|
+
- Makes the tool more intuitive
|
|
55
|
+
- Authentication becomes an intentional choice
|
|
56
|
+
|
|
57
|
+
### Full Changelog
|
|
58
|
+
|
|
59
|
+
- **Changed**: Authentication disabled by default in all configurations
|
|
60
|
+
- **Added**: `--no-auth` flags for build and deploy commands
|
|
61
|
+
- **Improved**: Simplified configuration prompts
|
|
62
|
+
- **Docs**: Added public site deployment guide
|
|
63
|
+
|
|
64
|
+
This is a breaking change, but one that makes the tool simpler and more aligned with common use cases.
|
package/cli.js
CHANGED
|
@@ -13,6 +13,7 @@ const { loadConfig, createDefaultConfig } = require('./lib/config');
|
|
|
13
13
|
const { generateDescription } = require('./lib/seo');
|
|
14
14
|
const { execSync } = require('child_process');
|
|
15
15
|
const matter = require('gray-matter');
|
|
16
|
+
const SupabaseAuth = require('./lib/supabase-auth');
|
|
16
17
|
|
|
17
18
|
// Package info
|
|
18
19
|
const packageJson = require('./package.json');
|
|
@@ -70,22 +71,31 @@ program
|
|
|
70
71
|
.option('-o, --output <dir>', 'output directory for HTML files (default: html)')
|
|
71
72
|
.option('--preset <preset>', 'use a preset configuration (available: notion-inspired)')
|
|
72
73
|
.option('--legacy', 'use legacy mode for backward compatibility')
|
|
73
|
-
.option('--no-auth', 'disable authentication even if configured')
|
|
74
74
|
.option('--no-changelog', 'disable automatic changelog generation')
|
|
75
75
|
.option('--no-pdf', 'hide PDF download icon in header')
|
|
76
76
|
.option('--menu-closed', 'start with navigation menu closed')
|
|
77
|
+
.option('--no-auth', 'build without authentication (for public sites)')
|
|
77
78
|
.addHelpText('after', `
|
|
78
79
|
${chalk.yellow('Examples:')}
|
|
79
80
|
${chalk.gray('$')} doc-builder build ${chalk.gray('# Build with defaults')}
|
|
80
81
|
${chalk.gray('$')} doc-builder build --input docs --output dist
|
|
81
82
|
${chalk.gray('$')} doc-builder build --preset notion-inspired ${chalk.gray('# Use Notion-inspired preset')}
|
|
82
83
|
${chalk.gray('$')} doc-builder build --config my-config.js ${chalk.gray('# Use custom config')}
|
|
84
|
+
${chalk.gray('$')} doc-builder build --no-auth ${chalk.gray('# Build public site without authentication')}
|
|
83
85
|
`)
|
|
84
86
|
.action(async (options) => {
|
|
85
87
|
const spinner = ora('Building documentation...').start();
|
|
86
88
|
|
|
87
89
|
try {
|
|
88
90
|
const config = await loadConfig(options.config || 'doc-builder.config.js', { ...options, command: 'build' });
|
|
91
|
+
|
|
92
|
+
// Handle no-auth option
|
|
93
|
+
if (options.auth === false) {
|
|
94
|
+
// Temporarily disable authentication for this build
|
|
95
|
+
config.features = config.features || {};
|
|
96
|
+
config.features.authentication = false;
|
|
97
|
+
}
|
|
98
|
+
|
|
89
99
|
await build(config);
|
|
90
100
|
spinner.succeed('Documentation built successfully!');
|
|
91
101
|
} catch (error) {
|
|
@@ -595,10 +605,12 @@ program
|
|
|
595
605
|
.option('--no-prod', 'deploy as preview instead of production')
|
|
596
606
|
.option('--force', 'force deployment without confirmation')
|
|
597
607
|
.option('--production-url <url>', 'override production URL for this deployment')
|
|
608
|
+
.option('--no-auth', 'build without authentication (for public sites)')
|
|
598
609
|
.addHelpText('after', `
|
|
599
610
|
${chalk.yellow('Examples:')}
|
|
600
611
|
${chalk.gray('$')} doc-builder deploy ${chalk.gray('# Deploy to production')}
|
|
601
612
|
${chalk.gray('$')} doc-builder deploy --no-prod ${chalk.gray('# Deploy preview only')}
|
|
613
|
+
${chalk.gray('$')} doc-builder deploy --no-auth ${chalk.gray('# Deploy public site without authentication')}
|
|
602
614
|
|
|
603
615
|
${chalk.yellow('First-time Vercel Setup:')}
|
|
604
616
|
|
|
@@ -744,6 +756,13 @@ ${chalk.yellow('Troubleshooting:')}
|
|
|
744
756
|
: 'https://' + options.productionUrl;
|
|
745
757
|
}
|
|
746
758
|
|
|
759
|
+
// Handle no-auth option
|
|
760
|
+
if (options.auth === false) {
|
|
761
|
+
// Temporarily disable authentication for this build
|
|
762
|
+
config.features = config.features || {};
|
|
763
|
+
config.features.authentication = false;
|
|
764
|
+
}
|
|
765
|
+
|
|
747
766
|
// Always build first
|
|
748
767
|
spinner.stop();
|
|
749
768
|
console.log(chalk.blue('\n📦 Building documentation first...\n'));
|
|
@@ -1466,7 +1485,7 @@ program
|
|
|
1466
1485
|
console.log(` • Favicon: ${chalk.green(config.favicon || '✨')}`);
|
|
1467
1486
|
|
|
1468
1487
|
console.log(chalk.yellow('\n✨ Features:'));
|
|
1469
|
-
console.log(` • Authentication: ${config.features?.authentication ? chalk.green('
|
|
1488
|
+
console.log(` • Authentication: ${config.features?.authentication === 'supabase' ? chalk.green('Supabase') : chalk.gray('Disabled')}`);
|
|
1470
1489
|
console.log(` • Dark mode: ${config.features?.darkMode !== false ? chalk.green('Enabled') : chalk.gray('Disabled')}`);
|
|
1471
1490
|
console.log(` • Mermaid diagrams: ${config.features?.mermaid !== false ? chalk.green('Enabled') : chalk.gray('Disabled')}`);
|
|
1472
1491
|
console.log(` • Changelog: ${config.features?.changelog !== false ? chalk.green('Enabled') : chalk.gray('Disabled')}`);
|
|
@@ -1475,10 +1494,11 @@ program
|
|
|
1475
1494
|
console.log(` • PDF download: ${config.features?.showPdfDownload !== false ? chalk.green('Shown') : chalk.gray('Hidden')}`);
|
|
1476
1495
|
console.log(` • Menu default: ${config.features?.menuDefaultOpen !== false ? chalk.green('Open') : chalk.gray('Closed')}`);
|
|
1477
1496
|
|
|
1478
|
-
if (config.features?.authentication) {
|
|
1479
|
-
console.log(chalk.yellow('\n🔐 Authentication:'));
|
|
1480
|
-
console.log(` •
|
|
1481
|
-
console.log(` •
|
|
1497
|
+
if (config.features?.authentication === 'supabase') {
|
|
1498
|
+
console.log(chalk.yellow('\n🔐 Supabase Authentication:'));
|
|
1499
|
+
console.log(` • Supabase URL: ${config.auth?.supabaseUrl ? chalk.green('Configured') : chalk.red('Missing')}`);
|
|
1500
|
+
console.log(` • Anonymous Key: ${config.auth?.supabaseAnonKey ? chalk.green('Configured') : chalk.red('Missing')}`);
|
|
1501
|
+
console.log(` • Site ID: ${config.auth?.siteId ? chalk.green('Configured') : chalk.red('Missing')}`);
|
|
1482
1502
|
}
|
|
1483
1503
|
|
|
1484
1504
|
if (config.seo?.enabled) {
|
|
@@ -1495,11 +1515,198 @@ program
|
|
|
1495
1515
|
}
|
|
1496
1516
|
});
|
|
1497
1517
|
|
|
1498
|
-
//
|
|
1518
|
+
// Authentication management commands
|
|
1519
|
+
program
|
|
1520
|
+
.command('auth:init')
|
|
1521
|
+
.description('Initialize Supabase authentication for this project')
|
|
1522
|
+
.option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
|
|
1523
|
+
.action(async (options) => {
|
|
1524
|
+
console.log(chalk.cyan('\n🔐 Initialize Supabase Authentication\n'));
|
|
1525
|
+
|
|
1526
|
+
try {
|
|
1527
|
+
const answers = await prompts([
|
|
1528
|
+
{
|
|
1529
|
+
type: 'text',
|
|
1530
|
+
name: 'supabaseUrl',
|
|
1531
|
+
message: 'Enter your Supabase project URL:',
|
|
1532
|
+
validate: (value) => value.match(/^https:\/\/\w+\.supabase\.co$/) ? true : 'Please enter a valid Supabase URL (https://xxx.supabase.co)'
|
|
1533
|
+
},
|
|
1534
|
+
{
|
|
1535
|
+
type: 'password',
|
|
1536
|
+
name: 'supabaseAnonKey',
|
|
1537
|
+
message: 'Enter your Supabase anonymous key:'
|
|
1538
|
+
},
|
|
1539
|
+
{
|
|
1540
|
+
type: 'text',
|
|
1541
|
+
name: 'siteName',
|
|
1542
|
+
message: 'Enter a name for this documentation site:',
|
|
1543
|
+
initial: 'Documentation'
|
|
1544
|
+
}
|
|
1545
|
+
]);
|
|
1546
|
+
|
|
1547
|
+
if (!answers.supabaseUrl || !answers.supabaseAnonKey) {
|
|
1548
|
+
console.log(chalk.yellow('Setup cancelled.'));
|
|
1549
|
+
return;
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// Create or update config file
|
|
1553
|
+
const configPath = options.config || 'doc-builder.config.js';
|
|
1554
|
+
const configContent = `module.exports = {
|
|
1555
|
+
siteName: '${answers.siteName}',
|
|
1556
|
+
|
|
1557
|
+
features: {
|
|
1558
|
+
authentication: 'supabase'
|
|
1559
|
+
},
|
|
1560
|
+
|
|
1561
|
+
auth: {
|
|
1562
|
+
supabaseUrl: '${answers.supabaseUrl}',
|
|
1563
|
+
supabaseAnonKey: '${answers.supabaseAnonKey}',
|
|
1564
|
+
siteId: '' // Will be set after creating site in database
|
|
1565
|
+
}
|
|
1566
|
+
};`;
|
|
1567
|
+
|
|
1568
|
+
await fs.writeFile(configPath, configContent);
|
|
1569
|
+
console.log(chalk.green(`✓ Configuration saved to ${configPath}`));
|
|
1570
|
+
|
|
1571
|
+
console.log(chalk.yellow('\n📋 Next steps:'));
|
|
1572
|
+
console.log('1. Create the database tables in your Supabase project (see documentation)');
|
|
1573
|
+
console.log('2. Add your site to the database using: doc-builder auth:add-site');
|
|
1574
|
+
console.log('3. Update the siteId in your config file');
|
|
1575
|
+
|
|
1576
|
+
} catch (error) {
|
|
1577
|
+
console.error(chalk.red('Error initializing auth:'), error.message);
|
|
1578
|
+
}
|
|
1579
|
+
});
|
|
1580
|
+
|
|
1581
|
+
program
|
|
1582
|
+
.command('auth:add-site')
|
|
1583
|
+
.description('Add a documentation site to Supabase database')
|
|
1584
|
+
.requiredOption('--domain <domain>', 'site domain (e.g., docs.example.com)')
|
|
1585
|
+
.requiredOption('--name <name>', 'site display name')
|
|
1586
|
+
.option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
|
|
1587
|
+
.action(async (options) => {
|
|
1588
|
+
console.log(chalk.cyan('\n🌐 Add Documentation Site\n'));
|
|
1589
|
+
|
|
1590
|
+
try {
|
|
1591
|
+
const config = await loadConfig(options.config || 'doc-builder.config.js', {});
|
|
1592
|
+
|
|
1593
|
+
if (config.features?.authentication !== 'supabase') {
|
|
1594
|
+
console.error(chalk.red('Error: Supabase authentication is not configured. Run "doc-builder auth:init" first.'));
|
|
1595
|
+
return;
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
// This would connect to Supabase and create the site record
|
|
1599
|
+
console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
|
|
1600
|
+
console.log('For now, manually add to your Supabase database:');
|
|
1601
|
+
console.log('');
|
|
1602
|
+
console.log(chalk.gray('INSERT INTO docbuilder_sites (domain, name)'));
|
|
1603
|
+
console.log(chalk.gray(`VALUES ('${options.domain}', '${options.name}');`));
|
|
1604
|
+
console.log('');
|
|
1605
|
+
console.log('Then update your config file with the returned site ID.');
|
|
1606
|
+
|
|
1607
|
+
} catch (error) {
|
|
1608
|
+
console.error(chalk.red('Error adding site:'), error.message);
|
|
1609
|
+
}
|
|
1610
|
+
});
|
|
1611
|
+
|
|
1612
|
+
program
|
|
1613
|
+
.command('auth:grant')
|
|
1614
|
+
.description('Grant user access to documentation site')
|
|
1615
|
+
.requiredOption('--email <email>', 'user email address')
|
|
1616
|
+
.requiredOption('--site-id <id>', 'site ID from database')
|
|
1617
|
+
.option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
|
|
1618
|
+
.action(async (options) => {
|
|
1619
|
+
console.log(chalk.cyan('\n👥 Grant User Access\n'));
|
|
1620
|
+
|
|
1621
|
+
try {
|
|
1622
|
+
const config = await loadConfig(options.config || 'doc-builder.config.js', {});
|
|
1623
|
+
|
|
1624
|
+
if (config.features?.authentication !== 'supabase') {
|
|
1625
|
+
console.error(chalk.red('Error: Supabase authentication is not configured.'));
|
|
1626
|
+
return;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
|
|
1630
|
+
console.log('For now, manually add to your Supabase database:');
|
|
1631
|
+
console.log('');
|
|
1632
|
+
console.log(chalk.gray('-- First, get the user ID from auth.users where email = \'user@example.com\''));
|
|
1633
|
+
console.log(chalk.gray('INSERT INTO docbuilder_access (user_id, site_id)'));
|
|
1634
|
+
console.log(chalk.gray(`VALUES ('user-uuid-here', '${options.siteId}');`));
|
|
1635
|
+
|
|
1636
|
+
} catch (error) {
|
|
1637
|
+
console.error(chalk.red('Error granting access:'), error.message);
|
|
1638
|
+
}
|
|
1639
|
+
});
|
|
1640
|
+
|
|
1641
|
+
program
|
|
1642
|
+
.command('auth:revoke')
|
|
1643
|
+
.description('Revoke user access to documentation site')
|
|
1644
|
+
.requiredOption('--email <email>', 'user email address')
|
|
1645
|
+
.requiredOption('--site-id <id>', 'site ID from database')
|
|
1646
|
+
.option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
|
|
1647
|
+
.action(async (options) => {
|
|
1648
|
+
console.log(chalk.cyan('\n🚫 Revoke User Access\n'));
|
|
1649
|
+
|
|
1650
|
+
try {
|
|
1651
|
+
const config = await loadConfig(options.config || 'doc-builder.config.js', {});
|
|
1652
|
+
|
|
1653
|
+
if (config.features?.authentication !== 'supabase') {
|
|
1654
|
+
console.error(chalk.red('Error: Supabase authentication is not configured.'));
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
|
|
1658
|
+
console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
|
|
1659
|
+
console.log('For now, manually remove from your Supabase database:');
|
|
1660
|
+
console.log('');
|
|
1661
|
+
console.log(chalk.gray('DELETE FROM docbuilder_access'));
|
|
1662
|
+
console.log(chalk.gray('WHERE user_id = (SELECT id FROM auth.users WHERE email = \'user@example.com\')'));
|
|
1663
|
+
console.log(chalk.gray(`AND site_id = '${options.siteId}';`));
|
|
1664
|
+
|
|
1665
|
+
} catch (error) {
|
|
1666
|
+
console.error(chalk.red('Error revoking access:'), error.message);
|
|
1667
|
+
}
|
|
1668
|
+
});
|
|
1669
|
+
|
|
1670
|
+
program
|
|
1671
|
+
.command('auth:list-users')
|
|
1672
|
+
.description('List users with access to documentation site')
|
|
1673
|
+
.requiredOption('--site-id <id>', 'site ID from database')
|
|
1674
|
+
.option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
|
|
1675
|
+
.action(async (options) => {
|
|
1676
|
+
console.log(chalk.cyan('\n👥 List Site Users\n'));
|
|
1677
|
+
|
|
1678
|
+
try {
|
|
1679
|
+
const config = await loadConfig(options.config || 'doc-builder.config.js', {});
|
|
1680
|
+
|
|
1681
|
+
if (config.features?.authentication !== 'supabase') {
|
|
1682
|
+
console.error(chalk.red('Error: Supabase authentication is not configured.'));
|
|
1683
|
+
return;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
console.log(chalk.yellow('🚧 This command requires Supabase admin integration.'));
|
|
1687
|
+
console.log('For now, manually query your Supabase database:');
|
|
1688
|
+
console.log('');
|
|
1689
|
+
console.log(chalk.gray('SELECT u.email, da.created_at as granted_at'));
|
|
1690
|
+
console.log(chalk.gray('FROM docbuilder_access da'));
|
|
1691
|
+
console.log(chalk.gray('JOIN auth.users u ON u.id = da.user_id'));
|
|
1692
|
+
console.log(chalk.gray(`WHERE da.site_id = '${options.siteId}';`));
|
|
1693
|
+
|
|
1694
|
+
} catch (error) {
|
|
1695
|
+
console.error(chalk.red('Error listing users:'), error.message);
|
|
1696
|
+
}
|
|
1697
|
+
});
|
|
1698
|
+
|
|
1699
|
+
// Update the help text to mention new commands
|
|
1499
1700
|
program.addHelpText('after', `
|
|
1500
1701
|
${chalk.cyan('📋 View Settings:')}
|
|
1501
1702
|
${chalk.gray('$')} doc-builder settings ${chalk.gray('# Show current configuration')}
|
|
1502
1703
|
${chalk.gray('$')} doc-builder settings --config custom.js ${chalk.gray('# Show specific config file')}
|
|
1704
|
+
|
|
1705
|
+
${chalk.cyan('🔐 Authentication Management:')}
|
|
1706
|
+
${chalk.gray('$')} doc-builder auth:init ${chalk.gray('# Set up Supabase authentication')}
|
|
1707
|
+
${chalk.gray('$')} doc-builder auth:add-site --domain docs.example.com --name "Company Docs"
|
|
1708
|
+
${chalk.gray('$')} doc-builder auth:grant --email user@example.com --site-id xxx
|
|
1709
|
+
${chalk.gray('$')} doc-builder auth:list-users --site-id xxx
|
|
1503
1710
|
`);
|
|
1504
1711
|
|
|
1505
1712
|
// Parse arguments
|
package/grant-access.sql
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
-- Grant access to test user
|
|
2
|
+
-- Run this in your Supabase SQL Editor
|
|
3
|
+
|
|
4
|
+
INSERT INTO docbuilder_access (user_id, site_id)
|
|
5
|
+
VALUES ('46cad259-9692-4df7-b19d-839e164a0390', '4d8a53bf-dcdd-48c0-98e0-cd1451518735');
|
|
6
|
+
|
|
7
|
+
-- Verify the access was granted
|
|
8
|
+
SELECT
|
|
9
|
+
u.email,
|
|
10
|
+
s.name as site_name,
|
|
11
|
+
da.created_at as access_granted
|
|
12
|
+
FROM docbuilder_access da
|
|
13
|
+
JOIN auth.users u ON u.id = da.user_id
|
|
14
|
+
JOIN docbuilder_sites s ON s.id = da.site_id
|
|
15
|
+
WHERE da.user_id = '46cad259-9692-4df7-b19d-839e164a0390';
|
package/html/README.html
CHANGED
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
<!-- Styles -->
|
|
46
46
|
<link rel="stylesheet" href="/css/notion-style.css">
|
|
47
47
|
|
|
48
|
+
|
|
49
|
+
|
|
48
50
|
<!-- Favicon -->
|
|
49
51
|
<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>">
|
|
50
52
|
|
|
@@ -63,8 +65,8 @@
|
|
|
63
65
|
"name": "Knowcode Ltd",
|
|
64
66
|
"url": "https://knowcode.tech"
|
|
65
67
|
},
|
|
66
|
-
"datePublished": "2025-07-
|
|
67
|
-
"dateModified": "2025-07-
|
|
68
|
+
"datePublished": "2025-07-25T13:01:14.155Z",
|
|
69
|
+
"dateModified": "2025-07-25T13:01:14.155Z",
|
|
68
70
|
"mainEntityOfPage": {
|
|
69
71
|
"@type": "WebPage",
|
|
70
72
|
"@id": "https://doc-builder-delta.vercel.app/README.html"
|
|
@@ -97,7 +99,7 @@
|
|
|
97
99
|
|
|
98
100
|
<div class="header-actions">
|
|
99
101
|
<div class="deployment-info">
|
|
100
|
-
<span class="deployment-date" title="Built with doc-builder v1.7.
|
|
102
|
+
<span class="deployment-date" title="Built with doc-builder v1.7.5">Last updated: Jul 25, 2025, 01:01 PM UTC</span>
|
|
101
103
|
</div>
|
|
102
104
|
|
|
103
105
|
|
|
@@ -155,14 +157,22 @@
|
|
|
155
157
|
<i class="fas fa-chevron-right collapse-icon"></i><i class="fas fa-folder"></i> Guides
|
|
156
158
|
</a>
|
|
157
159
|
<div class="nav-content" id="nav-guides-1">
|
|
158
|
-
<a href="/guides/authentication-
|
|
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>
|
|
159
163
|
<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>
|
|
160
164
|
<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've implemented Supabase authentication, let's walk through testing the implementation and preparing for deployment."><i class="fas fa-file-alt"></i> Next Steps Walkthrough</a>
|
|
161
166
|
<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>
|
|
167
|
+
<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>
|
|
162
168
|
<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>
|
|
163
169
|
<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>
|
|
164
170
|
<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>
|
|
165
174
|
<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>
|
|
166
176
|
<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>
|
|
167
177
|
<div class="nav-section" data-level="1">
|
|
168
178
|
<a class="nav-title collapsible expanded" href="/launch/README.html" data-target="nav-launch-1" >
|
package/html/auth.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Supabase Authentication for Documentation Site
|
|
4
|
+
* Generated by @knowcode/doc-builder
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
(function() {
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
// Skip auth check on login and logout pages
|
|
11
|
+
const currentPage = window.location.pathname;
|
|
12
|
+
if (currentPage === '/login.html' || currentPage === '/logout.html' ||
|
|
13
|
+
currentPage.includes('login') || currentPage.includes('logout')) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Initialize Supabase client
|
|
18
|
+
const { createClient } = supabase;
|
|
19
|
+
const supabaseClient = createClient('https://xcihhnfcitjrwbynxmka.supabase.co', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InhjaWhobmZjaXRqcndieW54bWthIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTM0Mzc2MzcsImV4cCI6MjA2OTAxMzYzN30.zvWp3JFIR8fBIiwuFF5gqOR_Kxb42baZS5fsBz60XOY', {
|
|
20
|
+
auth: {
|
|
21
|
+
persistSession: true,
|
|
22
|
+
autoRefreshToken: true,
|
|
23
|
+
detectSessionInUrl: true
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Check authentication and site access
|
|
28
|
+
async function checkAuth() {
|
|
29
|
+
try {
|
|
30
|
+
// Get current user session
|
|
31
|
+
const { data: { user }, error: userError } = await supabaseClient.auth.getUser();
|
|
32
|
+
|
|
33
|
+
if (userError || !user) {
|
|
34
|
+
redirectToLogin();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Check if user has access to this site
|
|
39
|
+
const { data: access, error: accessError } = await supabaseClient
|
|
40
|
+
.from('docbuilder_access')
|
|
41
|
+
.select('*')
|
|
42
|
+
.eq('user_id', user.id)
|
|
43
|
+
.eq('site_id', '4d8a53bf-dcdd-48c0-98e0-cd1451518735')
|
|
44
|
+
.single();
|
|
45
|
+
|
|
46
|
+
if (accessError || !access) {
|
|
47
|
+
showAccessDenied();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// User is authenticated and has access
|
|
52
|
+
console.log('User authenticated and authorized');
|
|
53
|
+
document.body.classList.add('authenticated');
|
|
54
|
+
|
|
55
|
+
} catch (error) {
|
|
56
|
+
console.error('Auth check failed:', error);
|
|
57
|
+
redirectToLogin();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Redirect to login page
|
|
62
|
+
function redirectToLogin() {
|
|
63
|
+
const currentUrl = window.location.pathname + window.location.search;
|
|
64
|
+
const loginUrl = '/login.html' + (currentUrl !== '/' ? '?redirect=' + encodeURIComponent(currentUrl) : '');
|
|
65
|
+
window.location.href = loginUrl;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Show access denied message
|
|
69
|
+
function showAccessDenied() {
|
|
70
|
+
document.body.classList.add('authenticated'); // Show the body
|
|
71
|
+
document.body.innerHTML = `
|
|
72
|
+
<div style="display: flex; justify-content: center; align-items: center; height: 100vh; font-family: Inter, sans-serif;">
|
|
73
|
+
<div style="text-align: center; max-width: 400px;">
|
|
74
|
+
<h1 style="color: #ef4444; margin-bottom: 1rem;">Access Denied</h1>
|
|
75
|
+
<p style="color: #6b7280; margin-bottom: 2rem;">You don't have permission to view this documentation site.</p>
|
|
76
|
+
<a href="/login.html" style="background: #3b82f6; color: white; padding: 0.75rem 1.5rem; border-radius: 0.5rem; text-decoration: none;">Try Different Account</a>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Add logout functionality
|
|
83
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
84
|
+
const logoutLinks = document.querySelectorAll('a[href*="logout"]');
|
|
85
|
+
logoutLinks.forEach(link => {
|
|
86
|
+
link.addEventListener('click', async function(e) {
|
|
87
|
+
e.preventDefault();
|
|
88
|
+
await supabaseClient.auth.signOut();
|
|
89
|
+
window.location.href = '/logout.html';
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Run auth check
|
|
95
|
+
checkAuth();
|
|
96
|
+
|
|
97
|
+
})();
|