@knowcode/doc-builder 1.0.1 → 1.0.3

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.0.3] - 2025-01-19
9
+
10
+ ### Fixed
11
+ - Fixed "path argument must be string" error in deploy command
12
+ - Improved Vercel CLI detection with helpful installation instructions
13
+ - Made config loading more lenient for missing directories
14
+ - Auto-build documentation if not already built before deployment
15
+ - Better error messages with stack traces for debugging
16
+
17
+ ### Added
18
+ - Automatic preparation of deployment files (index.html redirect)
19
+ - Check for Vercel CLI before attempting deployment
20
+ - Build documentation automatically if output directory doesn't exist
21
+ - More robust vercel.json generation for static sites
22
+
23
+ ## [1.0.2] - 2025-01-19
24
+
25
+ ### Fixed
26
+ - Fixed remaining JUNO references in CLI help text
27
+ - Enhanced help documentation with detailed Vercel CLI setup instructions
28
+ - Added comprehensive deployment troubleshooting guide
29
+ - Improved Quick Start section with step-by-step instructions
30
+ - Added "What gets created" explanations for init command
31
+
32
+ ### Added
33
+ - Requirements section in main help
34
+ - Example for creating docs from scratch
35
+ - Vercel installation options (npm and Homebrew)
36
+ - Clear instructions for disabling Vercel deployment protection
37
+
8
38
  ## [1.0.1] - 2025-01-19
9
39
 
10
40
  ### Fixed
package/cli.js CHANGED
@@ -8,7 +8,7 @@ const fs = require('fs-extra');
8
8
  const path = require('path');
9
9
  const { build } = require('./lib/builder');
10
10
  const { startDevServer } = require('./lib/dev-server');
11
- const { deployToVercel, setupVercelProject } = require('./lib/deploy');
11
+ const { deployToVercel, setupVercelProject, prepareDeployment } = require('./lib/deploy');
12
12
  const { loadConfig, createDefaultConfig } = require('./lib/config');
13
13
  const { execSync } = require('child_process');
14
14
 
@@ -25,7 +25,7 @@ program
25
25
  .description(packageJson.description)
26
26
  .version(packageJson.version)
27
27
  .addHelpText('before', `
28
- ${chalk.cyan('šŸš€ @juno/doc-builder')} - Transform your markdown into beautiful documentation sites
28
+ ${chalk.cyan('šŸš€ @knowcode/doc-builder')} - Transform your markdown into beautiful documentation sites
29
29
 
30
30
  ${chalk.yellow('What it does:')}
31
31
  • Converts markdown files to static HTML with a beautiful Notion-inspired theme
@@ -34,10 +34,24 @@ ${chalk.yellow('What it does:')}
34
34
  • Deploys to Vercel with one command (zero configuration)
35
35
  • Optional authentication to protect private documentation
36
36
 
37
+ ${chalk.yellow('Requirements:')}
38
+ • Node.js 14+ installed
39
+ • A ${chalk.cyan('docs/')} folder with markdown files (or specify custom folder)
40
+ • Vercel CLI for deployment (optional)
41
+
37
42
  ${chalk.yellow('Quick Start:')}
38
- ${chalk.gray('$')} npx @juno/doc-builder ${chalk.gray('# Build and deploy to Vercel')}
39
- ${chalk.gray('$')} npx @juno/doc-builder build ${chalk.gray('# Build HTML files only')}
40
- ${chalk.gray('$')} npx @juno/doc-builder dev ${chalk.gray('# Start development server')}
43
+ ${chalk.cyan('1. Create your docs:')}
44
+ ${chalk.gray('$')} mkdir docs
45
+ ${chalk.gray('$')} echo "# My Documentation" > docs/README.md
46
+
47
+ ${chalk.cyan('2. Build and deploy:')}
48
+ ${chalk.gray('$')} npx @knowcode/doc-builder ${chalk.gray('# Build and deploy to Vercel')}
49
+ ${chalk.gray(' or')}
50
+ ${chalk.gray('$')} npx @knowcode/doc-builder build ${chalk.gray('# Build HTML files only')}
51
+ ${chalk.gray('$')} npx @knowcode/doc-builder dev ${chalk.gray('# Start development server')}
52
+
53
+ ${chalk.yellow('No docs folder yet?')}
54
+ ${chalk.gray('$')} npx @knowcode/doc-builder init --example ${chalk.gray('# Create example docs')}
41
55
  `);
42
56
 
43
57
  // Build command
@@ -113,19 +127,73 @@ ${chalk.yellow('Examples:')}
113
127
  ${chalk.gray('$')} doc-builder deploy --prod ${chalk.gray('# Deploy to production')}
114
128
  ${chalk.gray('$')} doc-builder deploy --no-build ${chalk.gray('# Deploy existing build')}
115
129
 
116
- ${chalk.yellow('First-time setup:')}
117
- The tool will guide you through:
118
- 1. Installing Vercel CLI (if needed)
119
- 2. Creating a new Vercel project
120
- 3. Configuring deployment settings
130
+ ${chalk.yellow('First-time Vercel Setup:')}
131
+
132
+ ${chalk.cyan('1. Install Vercel CLI:')}
133
+ ${chalk.gray('$')} npm install -g vercel
134
+ ${chalk.gray(' or')}
135
+ ${chalk.gray('$')} brew install vercel ${chalk.gray('# macOS with Homebrew')}
136
+
137
+ ${chalk.cyan('2. Login to Vercel:')}
138
+ ${chalk.gray('$')} vercel login
139
+ ${chalk.gray(' This will open your browser to authenticate')}
121
140
 
122
- ${chalk.yellow('Important:')} After deployment, disable Vercel Authentication in project settings for public docs.
141
+ ${chalk.cyan('3. Run doc-builder deploy:')}
142
+ ${chalk.gray('$')} npx @knowcode/doc-builder deploy
143
+
144
+ The tool will:
145
+ • Create a new Vercel project
146
+ • Link it to your documentation
147
+ • Deploy your site
148
+ • Provide you with a URL
149
+
150
+ ${chalk.cyan('4. Configure Access (Important!):')}
151
+ After deployment, go to your Vercel dashboard:
152
+ • Navigate to Project Settings → General
153
+ • Under "Deployment Protection", set to ${chalk.yellow('Disabled')}
154
+ • This allows public access to your docs
155
+
156
+ ${chalk.yellow('Subsequent Deployments:')}
157
+ ${chalk.gray('$')} npx @knowcode/doc-builder ${chalk.gray('# Deploy preview')}
158
+ ${chalk.gray('$')} npx @knowcode/doc-builder deploy --prod ${chalk.gray('# Deploy to production')}
159
+
160
+ ${chalk.yellow('Troubleshooting:')}
161
+ • ${chalk.cyan('Command not found:')} Install Vercel CLI globally
162
+ • ${chalk.cyan('Not authenticated:')} Run ${chalk.gray('vercel login')}
163
+ • ${chalk.cyan('Project not linked:')} Delete ${chalk.gray('.vercel')} folder and redeploy
123
164
  `)
124
165
  .action(async (options) => {
125
166
  const spinner = ora('Deploying to Vercel...').start();
126
167
 
127
168
  try {
128
- const config = await loadConfig(options.config, options);
169
+ const config = await loadConfig(options.config || 'doc-builder.config.js', options);
170
+
171
+ // First check if Vercel CLI is installed
172
+ try {
173
+ execSync('vercel --version', { stdio: 'ignore' });
174
+ } catch (vercelError) {
175
+ spinner.fail('Vercel CLI not found');
176
+ console.log(chalk.yellow('\nšŸ“¦ Vercel CLI is required for deployment\n'));
177
+ console.log(chalk.cyan('Install it with one of these commands:'));
178
+ console.log(chalk.gray(' npm install -g vercel'));
179
+ console.log(chalk.gray(' yarn global add vercel'));
180
+ console.log(chalk.gray(' brew install vercel # macOS\n'));
181
+ console.log(chalk.yellow('Then run deployment again:'));
182
+ console.log(chalk.gray(' npx @knowcode/doc-builder deploy\n'));
183
+ process.exit(1);
184
+ }
185
+
186
+ // Check if we need to build first
187
+ const outputPath = path.join(process.cwd(), config.outputDir || 'html');
188
+ if (!fs.existsSync(outputPath) || !options.noBuild) {
189
+ spinner.stop();
190
+ console.log(chalk.blue('\nšŸ“¦ Building documentation first...\n'));
191
+ await build(config);
192
+ spinner.start('Deploying to Vercel...');
193
+ }
194
+
195
+ // Prepare deployment files
196
+ await prepareDeployment(config);
129
197
 
130
198
  // Check if this is the first deployment
131
199
  const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
@@ -155,6 +223,9 @@ ${chalk.yellow('Important:')} After deployment, disable Vercel Authentication in
155
223
  } catch (error) {
156
224
  spinner.fail('Deployment failed');
157
225
  console.error(chalk.red(error.message));
226
+ if (error.stack) {
227
+ console.error(chalk.gray(error.stack));
228
+ }
158
229
  process.exit(1);
159
230
  }
160
231
  });
@@ -169,6 +240,19 @@ program
169
240
  ${chalk.yellow('Examples:')}
170
241
  ${chalk.gray('$')} doc-builder init --config ${chalk.gray('# Create doc-builder.config.js')}
171
242
  ${chalk.gray('$')} doc-builder init --example ${chalk.gray('# Create example docs folder')}
243
+ ${chalk.gray('$')} doc-builder init --example --config ${chalk.gray('# Create both')}
244
+
245
+ ${chalk.yellow('What gets created:')}
246
+ ${chalk.cyan('--example:')} Creates a docs/ folder with:
247
+ • README.md with welcome message and mermaid diagram
248
+ • getting-started.md with setup instructions
249
+ • guides/configuration.md with config options
250
+
251
+ ${chalk.cyan('--config:')} Creates doc-builder.config.js with:
252
+ • Site name and description
253
+ • Feature toggles (auth, dark mode, etc.)
254
+ • Directory paths
255
+ • Authentication settings
172
256
  `)
173
257
  .action(async (options) => {
174
258
  if (options.config) {
package/lib/config.js CHANGED
@@ -188,10 +188,12 @@ async function loadConfig(configPath, options = {}) {
188
188
  }
189
189
  }
190
190
 
191
- // Validate paths
191
+ // Validate paths - but be lenient for deploy command
192
192
  const docsPath = path.join(process.cwd(), config.docsDir);
193
193
  if (!fs.existsSync(docsPath)) {
194
- throw new Error(`Documentation directory not found: ${config.docsDir}`);
194
+ console.warn(chalk.yellow(`Warning: Documentation directory not found: ${config.docsDir}`));
195
+ console.log(chalk.gray(`Create it with: mkdir ${config.docsDir} && echo "# Documentation" > ${config.docsDir}/README.md`));
196
+ // Don't throw error - let commands handle missing directories appropriately
195
197
  }
196
198
 
197
199
  return config;
package/lib/deploy.js CHANGED
@@ -51,10 +51,10 @@ async function setupVercelProject(config) {
51
51
  if (!fs.existsSync(vercelConfigPath)) {
52
52
  const vercelConfig = {
53
53
  outputDirectory: config.outputDir || 'html',
54
- framework: answers.framework === 'other' ? null : answers.framework,
55
- buildCommand: "npm run build:docs",
56
- devCommand: "npm run dev:docs",
57
- installCommand: "npm install",
54
+ framework: null, // Static HTML
55
+ buildCommand: "", // No build needed - we already built
56
+ devCommand: "", // No dev command
57
+ installCommand: "", // No install needed
58
58
  public: answers.publicAccess
59
59
  };
60
60
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {