@knowcode/doc-builder 1.0.6 → 1.0.7

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,25 @@ 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.7] - 2025-01-19
9
+
10
+ ### Added
11
+ - New `reset-vercel` command to fix deployment issues
12
+ - Pre-deployment warning about Root Directory settings
13
+ - Automatic detection of "html/html does not exist" error with clear fix instructions
14
+ - Visual deployment status with project information
15
+ - Better error messages that extract and show the settings URL
16
+
17
+ ### Improved
18
+ - Enhanced error handling with specific instructions for Root Directory issues
19
+ - Clear visual separation for deployment warnings
20
+ - More prominent pre-deployment checks
21
+ - Direct links to Vercel project settings
22
+
23
+ ### Fixed
24
+ - Better handling of the common "html/html" path error
25
+ - Clearer recovery instructions when deployment fails
26
+
8
27
  ## [1.0.6] - 2025-01-19
9
28
 
10
29
  ### Added
package/cli.js CHANGED
@@ -272,6 +272,48 @@ ${chalk.yellow('Troubleshooting:')}
272
272
  }
273
273
  });
274
274
 
275
+ // Reset command for Vercel issues
276
+ program
277
+ .command('reset-vercel')
278
+ .description('Reset Vercel configuration (fixes common deployment issues)')
279
+ .option('-c, --config <path>', 'path to config file (default: doc-builder.config.js)')
280
+ .addHelpText('after', `
281
+ ${chalk.yellow('What this does:')}
282
+ • Removes .vercel folder from your output directory
283
+ • Lets you set up a fresh Vercel project
284
+ • Fixes "html/html does not exist" errors
285
+ • Fixes wrong project linking issues
286
+
287
+ ${chalk.yellow('When to use:')}
288
+ • After "html/html does not exist" error
289
+ • When linked to wrong project (e.g., username/html)
290
+ • When Root Directory settings are incorrect
291
+ `)
292
+ .action(async (options) => {
293
+ try {
294
+ const config = await loadConfig(options.config || 'doc-builder.config.js', options);
295
+ const outputPath = path.join(process.cwd(), config.outputDir || 'html');
296
+ const vercelPath = path.join(outputPath, '.vercel');
297
+
298
+ if (fs.existsSync(vercelPath)) {
299
+ console.log(chalk.yellow('🗑️ Removing .vercel folder from ' + config.outputDir + '...'));
300
+ fs.removeSync(vercelPath);
301
+ console.log(chalk.green('✅ Vercel configuration reset!'));
302
+ console.log(chalk.gray('\nNow run deployment again:'));
303
+ console.log(chalk.cyan(' npx @knowcode/doc-builder deploy'));
304
+ console.log(chalk.gray('\nThis time:'));
305
+ console.log(chalk.gray('• Create a NEW project (not username/html)'));
306
+ console.log(chalk.gray('• Use a descriptive name like "my-docs"'));
307
+ console.log(chalk.gray('• Leave Root Directory EMPTY'));
308
+ } else {
309
+ console.log(chalk.gray('No .vercel folder found. Ready for fresh deployment!'));
310
+ }
311
+ } catch (error) {
312
+ console.error(chalk.red(error.message));
313
+ process.exit(1);
314
+ }
315
+ });
316
+
275
317
  // Init command
276
318
  program
277
319
  .command('init')
package/lib/deploy.js CHANGED
@@ -145,14 +145,31 @@ async function deployToVercel(config, isProd = false) {
145
145
  throw new Error(`Output directory ${outputPath} does not exist. Run 'doc-builder build' first.`);
146
146
  }
147
147
 
148
- // Check for existing project link
148
+ // Check for existing project link and warn about common issues
149
149
  const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
150
150
  if (fs.existsSync(vercelProjectPath)) {
151
151
  try {
152
152
  const projectInfo = fs.readJsonSync(vercelProjectPath);
153
- console.log(chalk.yellow('\n⚠️ Deploying to existing project: ') + chalk.cyan(projectInfo.projectId || 'unknown'));
154
- console.log(chalk.yellow('If deployment fails with path errors, check your Root Directory setting:'));
155
- console.log(chalk.cyan(`https://vercel.com/dashboard/project/${projectInfo.projectId || 'settings'}\n`));
153
+ const projectId = projectInfo.projectId || 'unknown';
154
+
155
+ console.log(chalk.blue('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
156
+ console.log(chalk.yellow('📦 Deploying to existing Vercel project'));
157
+ console.log(chalk.blue('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
158
+
159
+ console.log(chalk.white('Project ID: ') + chalk.cyan(projectId));
160
+
161
+ // Check if .vercel/project.json has rootDirectory set
162
+ if (projectInfo.settings && projectInfo.settings.rootDirectory) {
163
+ console.log(chalk.red.bold('\n⚠️ WARNING: Root Directory is set to: ') + chalk.yellow(projectInfo.settings.rootDirectory));
164
+ console.log(chalk.red('This may cause deployment to fail!\n'));
165
+ }
166
+
167
+ console.log(chalk.yellow.bold('\n⚡ BEFORE CONTINUING:'));
168
+ console.log(chalk.white('1. Check your Root Directory setting at:'));
169
+ console.log(chalk.cyan(` https://vercel.com/dashboard/project/${projectId}`));
170
+ console.log(chalk.white('2. Root Directory should be ') + chalk.green.bold('EMPTY (blank)'));
171
+ console.log(chalk.white('3. If it says "html", ') + chalk.red.bold('DELETE IT NOW!\n'));
172
+
156
173
  } catch (e) {
157
174
  // Ignore read errors
158
175
  }
@@ -186,6 +203,23 @@ async function deployToVercel(config, isProd = false) {
186
203
 
187
204
  return deployUrl;
188
205
  } catch (error) {
206
+ // Check if this is the common "html/html" path error
207
+ if (error.message && error.message.includes('html/html') && error.message.includes('does not exist')) {
208
+ console.log(chalk.red.bold('\n❌ ERROR: Vercel has incorrect Root Directory settings!\n'));
209
+ console.log(chalk.yellow('The project is configured with Root Directory = "html"'));
210
+ console.log(chalk.yellow('But we are already deploying FROM the html directory.\n'));
211
+
212
+ console.log(chalk.green.bold('🔧 TO FIX THIS:\n'));
213
+ console.log(chalk.white('1. Go to: ') + chalk.cyan(error.message.match(/https:\/\/vercel\.com\/[^\s]+/)?.[0] || 'https://vercel.com/dashboard'));
214
+ console.log(chalk.white('2. Find "Root Directory" under "Build & Development Settings"'));
215
+ console.log(chalk.white('3. ') + chalk.yellow.bold('DELETE the "html" value (leave it EMPTY)'));
216
+ console.log(chalk.white('4. Click "Save"'));
217
+ console.log(chalk.white('5. Run this command again\n'));
218
+
219
+ console.log(chalk.gray('Alternative: Delete html/.vercel folder and set up fresh'));
220
+
221
+ throw new Error('Root Directory misconfiguration - see instructions above');
222
+ }
189
223
  throw new Error(`Vercel deployment failed: ${error.message}`);
190
224
  }
191
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {