@knowcode/doc-builder 1.5.10 → 1.5.12

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/CHANGELOG.md CHANGED
@@ -5,6 +5,42 @@ 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.5.12] - 2025-07-22
9
+
10
+ ### Documentation
11
+ - šŸ“š **Updated all Vercel documentation** for the simplified setup process
12
+ - ✨ **Rewrote vercel-first-time-setup-guide.md** with streamlined 6-step process
13
+ - šŸ”§ **Updated vercel-cli-setup-guide.md** to focus on installation and advanced usage
14
+ - šŸ“ **Simplified README.md deployment section** to 4 clear steps
15
+ - šŸ› **Updated troubleshooting-guide.md** with new deployment solutions
16
+ - šŸŽÆ **Removed references to complex prompts** and confusing options
17
+ - šŸ“– **Added 'What Changed' section** highlighting improvements
18
+
19
+ ### Documentation Improvements
20
+ - No more confusing "Found project xyz/html" prompts
21
+ - No more root directory confusion
22
+ - Clear, straightforward deployment flow
23
+ - Better error messages and solutions
24
+
25
+ ## [1.5.11] - 2025-07-22
26
+
27
+ ### Fixed
28
+ - Fixed Vercel deployment error: "routes cannot be present with rewrites"
29
+ - Replaced deprecated `routes` configuration with modern `rewrites` in vercel.json
30
+ - Deployment now works correctly with Vercel's latest API
31
+
32
+ ### Improved
33
+ - Dramatically simplified deployment prompts and warnings
34
+ - Reduced verbosity of console output during deployment
35
+ - Made setup instructions clearer and less intimidating
36
+ - Removed redundant and scary "CRITICAL WARNING" messages
37
+ - Streamlined the first-time deployment experience
38
+
39
+ ### Changed
40
+ - vercel.json now uses `rewrites` instead of deprecated `routes` property
41
+ - Cleaner, more professional console output throughout deployment process
42
+ - Better error messages that are helpful rather than alarming
43
+
8
44
  ## [1.5.10] - 2025-07-22
9
45
 
10
46
  ### Fixed
package/README.md CHANGED
@@ -86,22 +86,23 @@ doc-builder deploy
86
86
 
87
87
  ## First-Time Vercel Deployment
88
88
 
89
- When deploying for the first time, doc-builder will:
89
+ The deployment process is now simpler than ever:
90
90
 
91
- 1. Check if Vercel CLI is installed
92
- 2. Guide you through project setup
93
- 3. Create `vercel.json` configuration
94
- 4. Link your project to Vercel
95
- 5. Show important reminders about Vercel settings
91
+ 1. Run `npx @knowcode/doc-builder deploy`
92
+ 2. Answer a few simple questions (project name, etc.)
93
+ 3. Vercel CLI automatically detects and configures everything
94
+ 4. Get your live URL in seconds!
96
95
 
97
- ### Important Vercel Settings
96
+ ### Making Your Docs Public
98
97
 
99
- After deployment, go to your Vercel dashboard:
98
+ After deployment, if you want public access:
100
99
 
101
- 1. Navigate to **Project Settings > General**
102
- 2. Under **Security**, find **Deployment Protection**
103
- 3. Set to **Disabled** for public access
104
- 4. Or configure authentication for private docs
100
+ 1. Go to [Vercel Dashboard](https://vercel.com/dashboard)
101
+ 2. Click your project → Settings → Deployment Protection
102
+ 3. Set **Vercel Authentication** to **Disabled**
103
+ 4. Save changes
104
+
105
+ See the [First-Time Setup Guide](docs/vercel-first-time-setup-guide.md) for a complete walkthrough.
105
106
 
106
107
  ## Configuration (optional - can be managed with CLI)
107
108
 
package/cli.js CHANGED
@@ -683,20 +683,12 @@ ${chalk.yellow('Troubleshooting:')}
683
683
  const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
684
684
  if (!fs.existsSync(vercelProjectPath)) {
685
685
  spinner.stop();
686
- console.log(chalk.yellow('\nšŸš€ First time deploying to Vercel!\n'));
686
+ console.log(chalk.blue('\nšŸš€ First time deploying to Vercel!\n'));
687
687
 
688
- // Show critical warning about Root Directory
689
- console.log(chalk.bgRed.white.bold('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
690
- console.log(chalk.bgRed.white.bold(' āš ļø CRITICAL WARNING - READ BEFORE CONTINUING! '));
691
- console.log(chalk.bgRed.white.bold('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
692
-
693
- console.log(chalk.yellow.bold('During setup, if Vercel asks about Root Directory:'));
694
- console.log(chalk.red.bold('• LEAVE IT EMPTY (blank)'));
695
- console.log(chalk.red.bold('• DO NOT ENTER "html"'));
696
- console.log(chalk.red.bold('• We are ALREADY deploying from the html folder!\n'));
697
-
698
- console.log(chalk.white('Setting Root Directory to "html" will cause errors.'));
699
- console.log(chalk.white('You\'ll need to fix it in project settings later.\n'));
688
+ console.log(chalk.yellow('šŸ“ Important: When asked about settings:'));
689
+ console.log(chalk.gray(' • Root Directory: ') + chalk.green('leave empty'));
690
+ console.log(chalk.gray(' • We handle the build process for you'));
691
+ console.log();
700
692
 
701
693
  const setupConfirm = await prompts({
702
694
  type: 'confirm',
package/lib/deploy.js CHANGED
@@ -94,14 +94,10 @@ async function setupVercelProject(config) {
94
94
  ]
95
95
  }
96
96
  ],
97
- "routes": [
97
+ "rewrites": [
98
98
  {
99
- "handle": "filesystem"
100
- },
101
- {
102
- "src": "/(.*)",
103
- "status": 404,
104
- "dest": "/404.html"
99
+ "source": "/(.*)",
100
+ "destination": "/404.html"
105
101
  }
106
102
  ]
107
103
  };
@@ -130,41 +126,17 @@ async function setupVercelProject(config) {
130
126
  }
131
127
  }
132
128
 
133
- // Run Vercel setup with prominent instructions
134
- console.log(chalk.blue('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
135
- console.log(chalk.blue('šŸ”— Linking to Vercel - IMPORTANT INSTRUCTIONS'));
136
- console.log(chalk.blue('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
137
-
138
- console.log(chalk.yellow('āš ļø FOLLOW THESE ANSWERS CAREFULLY:\n'));
139
-
140
- console.log(chalk.white('1ļøāƒ£ ') + chalk.green('Set up "~/Documents/.../html"?'));
141
- console.log(chalk.white(' šŸ‘‰ Answer: ') + chalk.yellow.bold('YES') + '\n');
142
-
143
- console.log(chalk.white('2ļøāƒ£ ') + chalk.green('Which scope should contain your project?'));
144
- console.log(chalk.white(' šŸ‘‰ Answer: ') + chalk.yellow.bold('Select your account') + ' (usually your username)\n');
145
-
146
- console.log(chalk.white('3ļøāƒ£ ') + chalk.green('Found project "username/html". Link to it?'));
147
- console.log(chalk.white(' šŸ‘‰ Answer: ') + chalk.red.bold('NO') + ' (this is NOT your project!)\n');
148
-
149
- console.log(chalk.white('4ļøāƒ£ ') + chalk.green('Link to different existing project?'));
150
- console.log(chalk.white(' šŸ‘‰ Answer: ') + chalk.yellow.bold('YES') + ' if you have an existing project');
151
- console.log(chalk.white(' šŸ‘‰ Answer: ') + chalk.yellow.bold('NO') + ' to create new project\n');
152
-
153
- console.log(chalk.white('5ļøāƒ£ ') + chalk.yellow('If you answered YES to #4:'));
154
- console.log(chalk.white(' ') + chalk.green('What\'s the name of your existing project?'));
155
- console.log(chalk.white(' šŸ‘‰ Answer: ') + chalk.yellow.bold(answers.projectName) + ' (your existing project name)\n');
156
-
157
- console.log(chalk.white('5ļøāƒ£ ') + chalk.yellow('If you answered NO to #4:'));
158
- console.log(chalk.white(' ') + chalk.green('What is your project name?'));
159
- console.log(chalk.white(' šŸ‘‰ Answer: ') + chalk.yellow.bold(answers.projectName) + ' (e.g., "my-docs" or "gasworld")\n');
160
-
161
- console.log(chalk.red.bold('āš ļø CRITICAL WARNING ABOUT ROOT DIRECTORY:\n'));
162
- console.log(chalk.bgRed.white.bold(' If Vercel asks about Root Directory or shows it in settings: '));
163
- console.log(chalk.bgRed.white.bold(' LEAVE IT COMPLETELY EMPTY! DO NOT ENTER "html"! '));
164
- console.log(chalk.white('\nWe are already in the html folder - setting Root Directory'));
165
- console.log(chalk.white('to "html" will cause "html/html does not exist" errors!\n'));
129
+ // Run Vercel setup with simplified instructions
130
+ console.log(chalk.blue('\nšŸ”— Linking to Vercel...\n'));
166
131
 
167
- console.log(chalk.blue('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
132
+ console.log(chalk.yellow('When Vercel CLI asks:'));
133
+ console.log(chalk.gray('• Set up and deploy: ') + chalk.green('YES'));
134
+ console.log(chalk.gray('• Which scope: ') + chalk.green('Select your account'));
135
+ console.log(chalk.gray('• Link to existing project: ') + chalk.green('YES/NO') + chalk.gray(' (your choice)'));
136
+ console.log(chalk.gray('• Project name: ') + chalk.green(answers.projectName));
137
+ console.log(chalk.gray('• Directory with code: ') + chalk.yellow('./') + chalk.gray(' (current directory)'));
138
+ console.log(chalk.gray('• Modify settings: ') + chalk.red('NO'));
139
+ console.log();
168
140
 
169
141
  try {
170
142
  // Run vercel link from the output directory
@@ -177,37 +149,19 @@ async function setupVercelProject(config) {
177
149
  process.exit(1);
178
150
  }
179
151
 
180
- // Important reminders for Vercel settings
181
- console.log(chalk.red('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
182
- console.log(chalk.red.bold('🚨 CRITICAL POST-SETUP STEP - DO THIS NOW!'));
183
- console.log(chalk.red('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
184
-
185
- console.log(chalk.yellow.bold('Vercel may have set Root Directory incorrectly!\n'));
186
-
187
- console.log(chalk.white.bold('1. GO TO YOUR PROJECT SETTINGS NOW:'));
188
- console.log(chalk.cyan(` https://vercel.com/${answers.projectName}/settings\n`));
189
-
190
- console.log(chalk.white.bold('2. Find "Root Directory" under "Build & Development Settings"\n'));
191
-
192
- console.log(chalk.white.bold('3. CHECK THE VALUE:'));
193
- console.log(chalk.green(' āœ… CORRECT: ') + chalk.green.bold('Empty (blank) or "./"'));
194
- console.log(chalk.red(' āŒ WRONG: ') + chalk.red.bold('"html" or any other value\n'));
195
-
196
- console.log(chalk.white.bold('4. IF IT SAYS "html":'));
197
- console.log(chalk.yellow(' • DELETE the value completely'));
198
- console.log(chalk.yellow(' • Leave it EMPTY'));
199
- console.log(chalk.yellow(' • Click SAVE\n'));
200
-
201
- console.log(chalk.bgRed.white.bold(' Failure to do this will cause deployment errors! '));
202
- console.log();
203
- console.log(chalk.yellow('šŸ” For Public Access:'));
204
- console.log(chalk.white('1. Navigate to Project Settings > General'));
205
- console.log(chalk.white('2. Under "Security", find "Deployment Protection"'));
206
- console.log(chalk.white('3. Set "Deployment Protection" to ') + chalk.yellow.bold('Disabled'));
207
- console.log();
208
- console.log(chalk.cyan('Dashboard URL: https://vercel.com/dashboard'));
152
+ // Post-setup reminder
153
+ console.log(chalk.yellow('\nšŸ“ Quick Setup Check:'));
154
+ console.log(chalk.gray(`1. Visit: https://vercel.com/${answers.projectName}/settings`));
155
+ console.log(chalk.gray('2. Under "Build & Development Settings":'));
156
+ console.log(chalk.gray(' - Root Directory should be ') + chalk.green('empty'));
157
+ console.log(chalk.gray(' - If it shows "html", delete it'));
209
158
  console.log();
210
159
 
160
+ if (answers.publicAccess) {
161
+ console.log(chalk.gray('3. For public access, disable "Deployment Protection"'));
162
+ console.log();
163
+ }
164
+
211
165
  // Add .vercel to .gitignore if not already there
212
166
  const gitignorePath = path.join(process.cwd(), '.gitignore');
213
167
  if (fs.existsSync(gitignorePath)) {
@@ -276,14 +230,10 @@ async function deployToVercel(config, isProd = false) {
276
230
  ]
277
231
  }
278
232
  ],
279
- "routes": [
233
+ "rewrites": [
280
234
  {
281
- "handle": "filesystem"
282
- },
283
- {
284
- "src": "/(.*)",
285
- "status": 404,
286
- "dest": "/404.html"
235
+ "source": "/(.*)",
236
+ "destination": "/404.html"
287
237
  }
288
238
  ]
289
239
  };
@@ -466,33 +416,14 @@ async function deployToVercel(config, isProd = false) {
466
416
  async function prepareDeployment(config) {
467
417
  const outputDir = path.join(process.cwd(), config.outputDir || 'html');
468
418
 
469
- // Log version for debugging
470
- const packageJson = require('../package.json');
471
- console.log(chalk.blue(`\nšŸ“¦ Preparing deployment with @knowcode/doc-builder v${packageJson.version}`));
472
-
473
419
  // Create index.html from README.html if needed
474
- console.log(chalk.blue('\nšŸ“ Deployment preparation - index.html check:'));
475
420
  const indexPath = path.join(outputDir, 'index.html');
476
421
  const readmePath = path.join(outputDir, 'README.html');
477
422
 
478
- console.log(chalk.gray(` - Output directory: ${outputDir}`));
479
- console.log(chalk.gray(` - Output dir exists: ${fs.existsSync(outputDir)}`));
480
-
481
- if (fs.existsSync(outputDir)) {
482
- const files = fs.readdirSync(outputDir);
483
- const htmlFiles = files.filter(f => f.endsWith('.html'));
484
- console.log(chalk.gray(` - Total files: ${files.length}`));
485
- console.log(chalk.gray(` - HTML files: [${htmlFiles.slice(0, 5).join(', ')}${htmlFiles.length > 5 ? '...' : ''}]`));
486
- }
487
-
488
- console.log(chalk.gray(` - Checking index.html: ${fs.existsSync(indexPath) ? 'exists' : 'missing'}`));
489
- console.log(chalk.gray(` - Index path: ${indexPath}`));
490
-
491
423
  // Check if we need to create/replace index.html
492
424
  let shouldCreateIndex = false;
493
425
 
494
426
  if (!fs.existsSync(indexPath)) {
495
- console.log(chalk.yellow(' āš ļø index.html is missing, attempting to create...'));
496
427
  shouldCreateIndex = true;
497
428
  } else {
498
429
  // Check if existing index.html needs replacement
@@ -500,47 +431,25 @@ async function prepareDeployment(config) {
500
431
  const indexContent = fs.readFileSync(indexPath, 'utf8');
501
432
 
502
433
  if (indexStats.size < 3000 || (indexContent.includes('<title>Documentation</title>') && indexContent.includes('<ul>') && !indexContent.includes('class="navigation"'))) {
503
- console.log(chalk.yellow(` āš ļø Existing index.html appears to be a directory listing (${indexStats.size} bytes), will replace`));
504
434
  shouldCreateIndex = true;
505
435
  } else if (!indexContent.includes('@knowcode/doc-builder')) {
506
- console.log(chalk.yellow(' āš ļø Existing index.html was not created by doc-builder, will replace'));
507
436
  shouldCreateIndex = true;
508
437
  }
509
438
  }
510
439
 
511
440
  if (shouldCreateIndex) {
512
- console.log(chalk.gray(` - Checking README.html: ${fs.existsSync(readmePath) ? 'exists' : 'missing'}`));
513
- console.log(chalk.gray(` - README path: ${readmePath}`));
441
+ // Check for README.html
514
442
 
515
443
  if (fs.existsSync(readmePath)) {
516
444
  // Copy README.html to index.html for proper root page
517
- console.log(chalk.blue(' → Copying README.html to index.html...'));
518
445
  try {
519
446
  fs.copyFileSync(readmePath, indexPath);
520
- console.log(chalk.green(' āœ… Successfully copied README.html to index.html'));
521
-
522
- // Verify the copy
523
- if (fs.existsSync(indexPath)) {
524
- const readmeStats = fs.statSync(readmePath);
525
- const indexStats = fs.statSync(indexPath);
526
- console.log(chalk.gray(` - README.html size: ${readmeStats.size} bytes`));
527
- console.log(chalk.gray(` - index.html size: ${indexStats.size} bytes`));
528
-
529
- if (readmeStats.size === indexStats.size) {
530
- console.log(chalk.green(' āœ… File sizes match - copy successful'));
531
- } else {
532
- console.log(chalk.yellow(' āš ļø File sizes do not match!'));
533
- }
534
- } else {
535
- console.log(chalk.red(' āŒ ERROR: index.html was not created after copy!'));
536
- }
537
447
  } catch (error) {
538
- console.log(chalk.red(` āŒ ERROR copying file: ${error.message}`));
539
- console.log(chalk.red(` - Error stack: ${error.stack}`));
448
+ console.error(chalk.red(`Error creating index.html: ${error.message}`));
540
449
  }
541
450
  } else {
542
451
  // If no README.html, find first available HTML file or create informative page
543
- console.log(chalk.yellow('āš ļø No README.html found, looking for other HTML files...'));
452
+ // No README.html, look for other HTML files
544
453
 
545
454
  // Find first available HTML file
546
455
  const htmlFiles = fs.readdirSync(outputDir)
@@ -550,7 +459,7 @@ async function prepareDeployment(config) {
550
459
  if (htmlFiles.length > 0) {
551
460
  // Redirect to first HTML file
552
461
  const firstFile = htmlFiles[0];
553
- console.log(chalk.green(`āœ… Creating index.html redirect to ${firstFile}`));
462
+ // Create index.html redirect
554
463
  const redirectIndex = `<!DOCTYPE html>
555
464
  <html>
556
465
  <head>
@@ -569,48 +478,27 @@ async function prepareDeployment(config) {
569
478
  </body>
570
479
  </html>`;
571
480
  fs.writeFileSync(indexPath, redirectIndex);
572
- console.log(chalk.green(`āœ… Created index.html redirect to ${firstFile}`));
481
+ // Created redirect
573
482
  } else {
574
483
  // No HTML files at all - this should never happen after build
575
- console.log(chalk.red('āŒ No HTML files found in output directory!'));
576
- console.log(chalk.yellow('šŸ“Œ This indicates a build issue. Please run: npx @knowcode/doc-builder build'));
484
+ console.error(chalk.red('No HTML files found. Run: npx @knowcode/doc-builder build'));
577
485
 
578
486
  // Create emergency fallback page
579
487
  const { createDefaultIndexPage } = require('./core-builder');
580
488
  const fallbackIndex = await createDefaultIndexPage(outputDir, config, packageJson.version);
581
489
  fs.writeFileSync(indexPath, fallbackIndex);
582
- console.log(chalk.green('āœ… Created fallback index.html with instructions'));
490
+ // Created fallback index.html
583
491
  }
584
492
  }
585
493
  } else {
586
- console.log(chalk.gray(' āœ“ index.html already exists and appears valid'));
587
- const stats = fs.statSync(indexPath);
588
- console.log(chalk.gray(` - Keeping existing index.html (${stats.size} bytes)`));
494
+ // index.html already exists and is valid
589
495
  }
590
496
 
591
- // Final check - log what files exist
592
- console.log(chalk.blue('\nšŸ“ Final deployment state:'));
593
-
594
- // Double-check index.html one more time
497
+ // Final check
595
498
  const finalIndexExists = fs.existsSync(indexPath);
596
- console.log(chalk[finalIndexExists ? 'green' : 'red'](` - index.html: ${finalIndexExists ? 'EXISTS' : 'MISSING'}`));
597
-
598
- if (finalIndexExists) {
599
- const stats = fs.statSync(indexPath);
600
- console.log(chalk.gray(` - index.html size: ${stats.size} bytes`));
601
- console.log(chalk.gray(` - index.html modified: ${stats.mtime.toISOString()}`));
602
- }
603
-
604
- const finalFiles = fs.readdirSync(outputDir)
605
- .filter(file => file.endsWith('.html'))
606
- .slice(0, 5); // Show first 5 HTML files
607
- console.log(chalk.gray(`\n HTML files in ${outputDir}:`));
608
- finalFiles.forEach(file => {
609
- const size = fs.statSync(path.join(outputDir, file)).size;
610
- console.log(chalk.gray(` - ${file} (${size} bytes)`));
611
- });
612
- if (fs.readdirSync(outputDir).filter(f => f.endsWith('.html')).length > 5) {
613
- console.log(chalk.gray(` - ... and ${fs.readdirSync(outputDir).filter(f => f.endsWith('.html')).length - 5} more HTML files`));
499
+ if (!finalIndexExists) {
500
+ console.error(chalk.red('Failed to create index.html'));
501
+ throw new Error('Deployment preparation failed');
614
502
  }
615
503
  }
616
504
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {