@knowcode/doc-builder 1.2.11 → 1.3.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.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,36 @@ 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.3.0] - 2025-07-19
9
+
10
+ ### BREAKING CHANGE
11
+ - **Default behavior changed**: Running `npx @knowcode/doc-builder` without arguments now shows help instead of building and deploying
12
+ - To deploy, explicitly use: `npx @knowcode/doc-builder deploy`
13
+
14
+ ### Changed
15
+ - Updated TL;DR in help text to show `npx @knowcode/doc-builder deploy`
16
+ - Reordered commands in help to show deploy as the recommended action
17
+ - Updated README.md to reflect the new default behavior
18
+
19
+ ### Why this change?
20
+ - Prevents accidental deployments when users just want to see available commands
21
+ - Makes the tool more predictable - no actions without explicit commands
22
+ - Aligns with standard CLI tool behavior
23
+
24
+ ## [1.2.12] - 2025-07-19
25
+
26
+ ### Added
27
+ - Support for alternative config file formats (site.title → siteName mapping)
28
+ - Support for input/output directory mapping in config files
29
+ - Debug logging for site name configuration
30
+
31
+ ### Fixed
32
+ - Header now properly displays the project name from config instead of generic "Documentation"
33
+ - Config loader now handles both old and new config formats
34
+
35
+ ### Documentation
36
+ - Updated GasWorld config to use correct format with siteName: 'GasWorld'
37
+
8
38
  ## [1.2.11] - 2025-07-19
9
39
 
10
40
  ### Fixed
package/README.md CHANGED
@@ -31,17 +31,15 @@ Perfect for project documentation, API references, knowledge bases, or any conte
31
31
  No installation needed! Just run:
32
32
 
33
33
  ```bash
34
- # Build and deploy to Vercel (default action)
35
- npx @knowcode/doc-builder
34
+ # Build and deploy to Vercel
35
+ npx @knowcode/doc-builder deploy
36
36
 
37
- # Or use specific commands:
37
+ # Other available commands:
38
38
  npx @knowcode/doc-builder build # Build HTML files only
39
39
  npx @knowcode/doc-builder dev # Start development server
40
- npx @knowcode/doc-builder deploy # Deploy to Vercel
40
+ npx @knowcode/doc-builder # Show help (default behavior)
41
41
  ```
42
42
 
43
- The default action (no command specified) will build your documentation and deploy it to Vercel.
44
-
45
43
  ## Installation (Optional)
46
44
 
47
45
  For faster execution and offline use:
package/cli.js CHANGED
@@ -15,11 +15,6 @@ const { execSync } = require('child_process');
15
15
  // Package info
16
16
  const packageJson = require('./package.json');
17
17
 
18
- // Default to build command if no args provided
19
- if (process.argv.length === 2) {
20
- process.argv.push('build');
21
- }
22
-
23
18
  program
24
19
  .name('doc-builder')
25
20
  .description(packageJson.description)
@@ -27,7 +22,7 @@ program
27
22
  .addHelpText('before', `
28
23
  ${chalk.cyan('šŸš€ @knowcode/doc-builder')} - Transform your markdown into beautiful documentation sites
29
24
 
30
- ${chalk.bgGreen.black(' TL;DR ')} ${chalk.green('Just run:')} ${chalk.cyan.bold('npx @knowcode/doc-builder')} ${chalk.green('→ Your docs are live on Vercel!')}
25
+ ${chalk.bgGreen.black(' TL;DR ')} ${chalk.green('Just run:')} ${chalk.cyan.bold('npx @knowcode/doc-builder deploy')} ${chalk.green('→ Your docs are live on Vercel!')}
31
26
 
32
27
  ${chalk.gray('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━')}
33
28
 
@@ -36,7 +31,7 @@ ${chalk.yellow('What it does:')}
36
31
  • Automatically generates navigation from your folder structure
37
32
  • Supports mermaid diagrams, syntax highlighting, and dark mode
38
33
  • Deploys to Vercel with one command (zero configuration)
39
- • ${chalk.green.bold('NEW:')} Deploys directly to production by default (v1.1.0+)
34
+ • ${chalk.green.bold('NEW:')} Shows help by default, use 'deploy' to publish (v1.3.0+)
40
35
  • Optional authentication to protect private documentation
41
36
 
42
37
  ${chalk.yellow('Requirements:')}
@@ -50,8 +45,8 @@ ${chalk.yellow('Quick Start:')}
50
45
  ${chalk.gray('$')} echo "# My Documentation" > docs/README.md
51
46
 
52
47
  ${chalk.cyan('2. Build and deploy:')}
53
- ${chalk.gray('$')} npx @knowcode/doc-builder ${chalk.gray('# Build and deploy to production')}
54
- ${chalk.gray(' or')}
48
+ ${chalk.gray('$')} npx @knowcode/doc-builder ${chalk.gray('# Show help and available commands')}
49
+ ${chalk.gray('$')} npx @knowcode/doc-builder deploy ${chalk.gray('# Build and deploy to production')}
55
50
  ${chalk.gray('$')} npx @knowcode/doc-builder build ${chalk.gray('# Build HTML files only')}
56
51
  ${chalk.gray('$')} npx @knowcode/doc-builder dev ${chalk.gray('# Start development server')}
57
52
 
@@ -186,10 +181,10 @@ ${chalk.yellow('First-time Vercel Setup:')}
186
181
  • Under "Deployment Protection", set to ${chalk.yellow('Disabled')}
187
182
  • This allows public access to your docs
188
183
 
189
- ${chalk.yellow('Deployment Behavior (v1.1.0+):')}
184
+ ${chalk.yellow('Deployment Behavior:')}
190
185
  ${chalk.green.bold('šŸŽÆ DEFAULT: All deployments go to PRODUCTION')}
191
186
 
192
- ${chalk.gray('$')} npx @knowcode/doc-builder ${chalk.gray('# → yourdocs.vercel.app')}
187
+ ${chalk.gray('$')} npx @knowcode/doc-builder ${chalk.gray('# → Shows help (v1.3.0+)')}
193
188
  ${chalk.gray('$')} npx @knowcode/doc-builder deploy ${chalk.gray('# → yourdocs.vercel.app')}
194
189
  ${chalk.gray('$')} npx @knowcode/doc-builder deploy --no-prod ${chalk.gray('# → preview URL only')}
195
190
 
@@ -476,77 +471,11 @@ ${chalk.yellow('What gets created:')}
476
471
  }
477
472
  });
478
473
 
479
- // Add a default command handler for when doc-builder is run without arguments
480
- program
481
- .action(async () => {
482
- // Default action is build + deploy to production
483
- console.log(chalk.cyan('\nšŸš€ Building and deploying your documentation to production...\n'));
484
-
485
- try {
486
- // Build first
487
- const config = await loadConfig('doc-builder.config.js', { legacy: true });
488
- const buildSpinner = ora('Building documentation...').start();
489
- await build(config);
490
- buildSpinner.succeed('Documentation built successfully!');
491
-
492
- // Then deploy
493
- const deploySpinner = ora('Deploying to Vercel...').start();
494
-
495
- // Check if this is the first deployment
496
- const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
497
- if (!fs.existsSync(vercelProjectPath)) {
498
- deploySpinner.stop();
499
- console.log(chalk.yellow('\nšŸš€ First time deploying to Vercel!\n'));
500
-
501
- // Show critical warning about Root Directory
502
- console.log(chalk.bgRed.white.bold('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
503
- console.log(chalk.bgRed.white.bold(' āš ļø CRITICAL WARNING - READ BEFORE CONTINUING! '));
504
- console.log(chalk.bgRed.white.bold('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
505
-
506
- console.log(chalk.yellow.bold('During setup, if Vercel asks about Root Directory:'));
507
- console.log(chalk.red.bold('• LEAVE IT EMPTY (blank)'));
508
- console.log(chalk.red.bold('• DO NOT ENTER "html"'));
509
- console.log(chalk.red.bold('• We are ALREADY deploying from the html folder!\n'));
510
-
511
- const setupConfirm = await prompts({
512
- type: 'confirm',
513
- name: 'value',
514
- message: 'Would you like to set up a new Vercel project?',
515
- initial: true
516
- });
517
-
518
- if (setupConfirm.value) {
519
- await setupVercelProject(config);
520
- } else {
521
- console.log(chalk.gray('\nTo deploy manually, run: vercel'));
522
- console.log(chalk.gray('To skip deployment, run: doc-builder build\n'));
523
- process.exit(0);
524
- }
525
- deploySpinner.start('Deploying to Vercel...');
526
- }
527
-
528
- // Default to production deployment
529
- const url = await deployToVercel(config, true);
530
- deploySpinner.succeed(`Deployed successfully!`);
531
-
532
- // Extract project name from URL
533
- const projectName = url.match(/https:\/\/([^-]+)/)?.[1] || 'your-project';
534
-
535
- console.log(chalk.green('\nāœ… Deployment Complete!\n'));
536
- console.log(chalk.yellow('🌐 Your documentation is live at:'));
537
- console.log(chalk.cyan.bold(` ${projectName}.vercel.app`) + chalk.gray(' (Production URL - share this!)'));
538
- console.log();
539
- console.log(chalk.gray('This deployment also created a unique preview URL:'));
540
- console.log(chalk.gray(` ${url}`));
541
- console.log(chalk.gray(' (This URL is specific to this deployment)'));
542
- console.log();
543
-
544
- } catch (error) {
545
- console.error(chalk.red('\nError: ' + error.message));
546
- console.log(chalk.gray('\nTo build without deploying, run: doc-builder build'));
547
- process.exit(1);
548
- }
549
- });
550
-
551
474
  // Parse arguments
552
- program.parse(process.argv);
475
+ program.parse(process.argv);
476
+
477
+ // Show help if no command was provided
478
+ if (!process.argv.slice(2).length) {
479
+ program.outputHelp();
480
+ process.exit(0);
481
+ }
package/lib/config.js CHANGED
@@ -153,6 +153,27 @@ async function loadConfig(configPath, options = {}) {
153
153
  try {
154
154
  const customConfig = require(customConfigPath);
155
155
  config = { ...config, ...customConfig };
156
+
157
+ // Handle alternative config formats
158
+ if (customConfig.site) {
159
+ // Map site.title to siteName
160
+ if (customConfig.site.title) {
161
+ config.siteName = customConfig.site.title;
162
+ console.log(chalk.gray(` Using site name: ${config.siteName}`));
163
+ }
164
+ if (customConfig.site.description) {
165
+ config.siteDescription = customConfig.site.description;
166
+ }
167
+ }
168
+
169
+ // Map input/output to docsDir/outputDir
170
+ if (customConfig.input) {
171
+ config.docsDir = customConfig.input;
172
+ }
173
+ if (customConfig.output) {
174
+ config.outputDir = customConfig.output;
175
+ }
176
+
156
177
  console.log(chalk.gray(`Loaded config from ${configPath}`));
157
178
  } catch (error) {
158
179
  console.warn(chalk.yellow(`Warning: Failed to load config file: ${error.message}`));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.2.11",
3
+ "version": "1.3.0",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -9,14 +9,14 @@ const { execSync } = require('child_process');
9
9
  const path = require('path');
10
10
  const fs = require('fs');
11
11
 
12
- // Get the command from arguments
13
- const [,, command = 'build', ...args] = process.argv;
12
+ // Get the command from arguments - no default command
13
+ const [,, ...args] = process.argv;
14
14
 
15
15
  // Path to the actual CLI
16
16
  const cliPath = path.join(__dirname, '..', 'cli.js');
17
17
 
18
- // Build the command
19
- const fullCommand = `node "${cliPath}" ${command} ${args.join(' ')}`;
18
+ // Build the command - pass all arguments through
19
+ const fullCommand = `node "${cliPath}" ${args.join(' ')}`;
20
20
 
21
21
  try {
22
22
  // Execute the CLI with stdio inherited to preserve colors and interactivity