@knowcode/doc-builder 1.0.2 → 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,21 @@ 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
+
8
23
  ## [1.0.2] - 2025-01-19
9
24
 
10
25
  ### 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
 
@@ -166,7 +166,34 @@ ${chalk.yellow('Troubleshooting:')}
166
166
  const spinner = ora('Deploying to Vercel...').start();
167
167
 
168
168
  try {
169
- 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);
170
197
 
171
198
  // Check if this is the first deployment
172
199
  const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
@@ -196,6 +223,9 @@ ${chalk.yellow('Troubleshooting:')}
196
223
  } catch (error) {
197
224
  spinner.fail('Deployment failed');
198
225
  console.error(chalk.red(error.message));
226
+ if (error.stack) {
227
+ console.error(chalk.gray(error.stack));
228
+ }
199
229
  process.exit(1);
200
230
  }
201
231
  });
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.2",
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": {