@knowcode/doc-builder 1.0.2 → 1.0.4

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,35 @@ 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.4] - 2025-01-19
9
+
10
+ ### Added
11
+ - Comprehensive Vercel CLI prompt explanations in help text
12
+ - Step-by-step answers for all Vercel setup questions
13
+ - Hints in prompts to guide users through setup
14
+ - Pre-deployment guidance showing what Vercel will ask
15
+ - Better project name sanitization for Vercel URLs
16
+
17
+ ### Improved
18
+ - More detailed deployment help with exact answers to provide
19
+ - Clearer instructions for first-time vs. subsequent deployments
20
+ - Visual question/answer format in help documentation
21
+
22
+ ## [1.0.3] - 2025-01-19
23
+
24
+ ### Fixed
25
+ - Fixed "path argument must be string" error in deploy command
26
+ - Improved Vercel CLI detection with helpful installation instructions
27
+ - Made config loading more lenient for missing directories
28
+ - Auto-build documentation if not already built before deployment
29
+ - Better error messages with stack traces for debugging
30
+
31
+ ### Added
32
+ - Automatic preparation of deployment files (index.html redirect)
33
+ - Check for Vercel CLI before attempting deployment
34
+ - Build documentation automatically if output directory doesn't exist
35
+ - More robust vercel.json generation for static sites
36
+
8
37
  ## [1.0.2] - 2025-01-19
9
38
 
10
39
  ### 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
 
@@ -141,11 +141,36 @@ ${chalk.yellow('First-time Vercel Setup:')}
141
141
  ${chalk.cyan('3. Run doc-builder deploy:')}
142
142
  ${chalk.gray('$')} npx @knowcode/doc-builder deploy
143
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
144
+ You'll be asked several questions:
145
+
146
+ ${chalk.green('Q: Would you like to set up a new Vercel project?')}
147
+ Answer: ${chalk.yellow('Yes')} (first time only)
148
+
149
+ ${chalk.green('Q: What is your project name?')}
150
+ → Answer: ${chalk.yellow('Your project name')} (e.g., "my-docs" or "gasworld")
151
+
152
+ ${chalk.green('Q: Which framework preset?')}
153
+ → Answer: ${chalk.yellow('Other (Static HTML)')} (always choose this)
154
+
155
+ ${chalk.green('Q: Make the deployment publicly accessible?')}
156
+ → Answer: ${chalk.yellow('Yes')} for public docs, ${chalk.yellow('No')} for private
157
+
158
+ ${chalk.gray('Then Vercel CLI will ask:')}
159
+
160
+ ${chalk.green('Q: Set up [your directory]?')}
161
+ → Answer: ${chalk.yellow('Yes')}
162
+
163
+ ${chalk.green('Q: Which scope should contain your project?')}
164
+ → Answer: ${chalk.yellow('Select your account')} (usually your username)
165
+
166
+ ${chalk.green('Q: Link to existing project?')}
167
+ → Answer: ${chalk.yellow('No')} (first time), ${chalk.yellow('Yes')} (if redeploying)
168
+
169
+ ${chalk.green('Q: In which directory is your code located?')}
170
+ → Answer: ${chalk.yellow('./html')} (or your output directory)
171
+
172
+ ${chalk.green('Q: Want to modify these settings?')}
173
+ → Answer: ${chalk.yellow('No')} (doc-builder handles this)
149
174
 
150
175
  ${chalk.cyan('4. Configure Access (Important!):')}
151
176
  After deployment, go to your Vercel dashboard:
@@ -166,7 +191,34 @@ ${chalk.yellow('Troubleshooting:')}
166
191
  const spinner = ora('Deploying to Vercel...').start();
167
192
 
168
193
  try {
169
- const config = await loadConfig(options.config, options);
194
+ const config = await loadConfig(options.config || 'doc-builder.config.js', options);
195
+
196
+ // First check if Vercel CLI is installed
197
+ try {
198
+ execSync('vercel --version', { stdio: 'ignore' });
199
+ } catch (vercelError) {
200
+ spinner.fail('Vercel CLI not found');
201
+ console.log(chalk.yellow('\n📦 Vercel CLI is required for deployment\n'));
202
+ console.log(chalk.cyan('Install it with one of these commands:'));
203
+ console.log(chalk.gray(' npm install -g vercel'));
204
+ console.log(chalk.gray(' yarn global add vercel'));
205
+ console.log(chalk.gray(' brew install vercel # macOS\n'));
206
+ console.log(chalk.yellow('Then run deployment again:'));
207
+ console.log(chalk.gray(' npx @knowcode/doc-builder deploy\n'));
208
+ process.exit(1);
209
+ }
210
+
211
+ // Check if we need to build first
212
+ const outputPath = path.join(process.cwd(), config.outputDir || 'html');
213
+ if (!fs.existsSync(outputPath) || !options.noBuild) {
214
+ spinner.stop();
215
+ console.log(chalk.blue('\n📦 Building documentation first...\n'));
216
+ await build(config);
217
+ spinner.start('Deploying to Vercel...');
218
+ }
219
+
220
+ // Prepare deployment files
221
+ await prepareDeployment(config);
170
222
 
171
223
  // Check if this is the first deployment
172
224
  const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
@@ -196,6 +248,9 @@ ${chalk.yellow('Troubleshooting:')}
196
248
  } catch (error) {
197
249
  spinner.fail('Deployment failed');
198
250
  console.error(chalk.red(error.message));
251
+ if (error.stack) {
252
+ console.error(chalk.gray(error.stack));
253
+ }
199
254
  process.exit(1);
200
255
  }
201
256
  });
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
@@ -25,7 +25,8 @@ async function setupVercelProject(config) {
25
25
  type: 'text',
26
26
  name: 'projectName',
27
27
  message: 'What is your project name?',
28
- initial: config.siteName || 'my-docs'
28
+ initial: config.siteName.toLowerCase().replace(/[^a-z0-9-]/g, '-') || 'my-docs',
29
+ hint: 'This will be your URL: project-name.vercel.app'
29
30
  },
30
31
  {
31
32
  type: 'select',
@@ -36,13 +37,15 @@ async function setupVercelProject(config) {
36
37
  { title: 'Next.js', value: 'nextjs' },
37
38
  { title: 'Vite', value: 'vite' }
38
39
  ],
39
- initial: 0
40
+ initial: 0,
41
+ hint: 'Choose "Other (Static HTML)" for doc-builder'
40
42
  },
41
43
  {
42
44
  type: 'confirm',
43
45
  name: 'publicAccess',
44
46
  message: 'Make the deployment publicly accessible?',
45
- initial: true
47
+ initial: true,
48
+ hint: 'Choose Yes for public docs, No for team-only access'
46
49
  }
47
50
  ]);
48
51
 
@@ -51,10 +54,10 @@ async function setupVercelProject(config) {
51
54
  if (!fs.existsSync(vercelConfigPath)) {
52
55
  const vercelConfig = {
53
56
  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",
57
+ framework: null, // Static HTML
58
+ buildCommand: "", // No build needed - we already built
59
+ devCommand: "", // No dev command
60
+ installCommand: "", // No install needed
58
61
  public: answers.publicAccess
59
62
  };
60
63
 
@@ -64,6 +67,13 @@ async function setupVercelProject(config) {
64
67
 
65
68
  // Run Vercel setup
66
69
  console.log(chalk.blue('\n🔗 Linking to Vercel...\n'));
70
+ console.log(chalk.yellow('📝 Vercel will now ask additional questions:\n'));
71
+ console.log(chalk.gray('• Set up [directory]? → Yes'));
72
+ console.log(chalk.gray('• Which scope? → Select your account'));
73
+ console.log(chalk.gray('• Link to existing? → No (first time)'));
74
+ console.log(chalk.gray('• Project name? → Same as above'));
75
+ console.log(chalk.gray('• Code directory? → ./html (or your output dir)'));
76
+ console.log(chalk.gray('• Modify settings? → No\n'));
67
77
 
68
78
  try {
69
79
  execSync('vercel link', { stdio: 'inherit' });
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.4",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {