@knowcode/doc-builder 1.0.5 → 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,45 @@ 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
+
27
+ ## [1.0.6] - 2025-01-19
28
+
29
+ ### Added
30
+ - Much more prominent and helpful Vercel setup instructions
31
+ - Step-by-step visual guide with numbered steps and emojis
32
+ - Warning about common "username/html" project linking mistake
33
+ - Detection and warning for existing project deployments
34
+ - Comprehensive troubleshooting for "html/html does not exist" error
35
+ - Clear instructions for fixing Root Directory settings
36
+
37
+ ### Improved
38
+ - Enhanced visual formatting for Vercel prompts with boxes and colors
39
+ - Added critical warnings about NOT linking to generic "html" projects
40
+ - Better error detection and user guidance
41
+ - More helpful project settings URLs
42
+
43
+ ### Fixed
44
+ - Updated vercel.json to use empty strings instead of false values
45
+ - Added installCommand to vercel.json for better compatibility
46
+
8
47
  ## [1.0.5] - 2025-01-19
9
48
 
10
49
  ### Fixed
package/cli.js CHANGED
@@ -185,6 +185,24 @@ ${chalk.yellow('Troubleshooting:')}
185
185
  • ${chalk.cyan('Command not found:')} Install Vercel CLI globally
186
186
  • ${chalk.cyan('Not authenticated:')} Run ${chalk.gray('vercel login')}
187
187
  • ${chalk.cyan('Project not linked:')} Delete ${chalk.gray('.vercel')} folder and redeploy
188
+
189
+ ${chalk.red.bold('• Path "html/html" does not exist error:')}
190
+ ${chalk.yellow('This happens when Vercel has the wrong Root Directory setting.')}
191
+
192
+ ${chalk.green('Fix:')}
193
+ 1. Go to your Vercel project settings
194
+ 2. Under "Build & Development Settings"
195
+ 3. Set "Root Directory" to ${chalk.yellow.bold('empty (leave blank)')}
196
+ 4. Save and redeploy
197
+
198
+ ${chalk.red.bold('• Linked to wrong project (username/html):')}
199
+ ${chalk.yellow('Never link to the generic "html" project!')}
200
+
201
+ ${chalk.green('Fix:')}
202
+ 1. Delete the ${chalk.gray('html/.vercel')} folder
203
+ 2. Run deployment again
204
+ 3. When asked "Link to existing project?" say ${chalk.red.bold('NO')}
205
+ 4. Create a new project with your actual name
188
206
  `)
189
207
  .action(async (options) => {
190
208
  const spinner = ora('Deploying to Vercel...').start();
@@ -254,6 +272,48 @@ ${chalk.yellow('Troubleshooting:')}
254
272
  }
255
273
  });
256
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
+
257
317
  // Init command
258
318
  program
259
319
  .command('init')
package/lib/deploy.js CHANGED
@@ -59,23 +59,41 @@ async function setupVercelProject(config) {
59
59
  }
60
60
 
61
61
  // Create vercel.json for static site
62
+ // Use empty string instead of false to avoid Vercel issues
62
63
  const vercelConfig = {
63
- buildCommand: false,
64
+ buildCommand: "",
64
65
  outputDirectory: ".",
66
+ installCommand: "",
65
67
  framework: null
66
68
  };
67
69
 
68
70
  fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
69
71
  console.log(chalk.green(`✅ Created vercel.json in ${config.outputDir || 'html'} directory`));
70
72
 
71
- // Run Vercel setup
72
- console.log(chalk.blue('\n🔗 Linking to Vercel...\n'));
73
- console.log(chalk.yellow('📝 Vercel will now ask additional questions:\n'));
74
- console.log(chalk.gray('• Set up and deploy? → Yes'));
75
- console.log(chalk.gray('• Which scope? → Select your account'));
76
- console.log(chalk.gray(' Link to existing? → No (first time)'));
77
- console.log(chalk.gray('• Project name? → ' + answers.projectName));
78
- console.log(chalk.gray(' Override settings? No\n'));
73
+ // Run Vercel setup with prominent instructions
74
+ console.log(chalk.blue('\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
75
+ console.log(chalk.blue('🔗 Linking to Vercel - IMPORTANT INSTRUCTIONS'));
76
+ console.log(chalk.blue('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
77
+
78
+ console.log(chalk.yellow('⚠️ FOLLOW THESE ANSWERS CAREFULLY:\n'));
79
+
80
+ console.log(chalk.white('1️⃣ ') + chalk.green('Set up "~/Documents/.../html"?'));
81
+ console.log(chalk.white(' 👉 Answer: ') + chalk.yellow.bold('YES') + '\n');
82
+
83
+ console.log(chalk.white('2️⃣ ') + chalk.green('Which scope should contain your project?'));
84
+ console.log(chalk.white(' 👉 Answer: ') + chalk.yellow.bold('Select your account') + ' (usually your username)\n');
85
+
86
+ console.log(chalk.white('3️⃣ ') + chalk.green('Found project "username/html". Link to it?'));
87
+ console.log(chalk.white(' 👉 Answer: ') + chalk.red.bold('NO') + ' (this is NOT your project!)\n');
88
+
89
+ console.log(chalk.white('4️⃣ ') + chalk.green('Link to different existing project?'));
90
+ console.log(chalk.white(' 👉 Answer: ') + chalk.yellow.bold('YES') + ' if you have an existing project');
91
+ console.log(chalk.white(' 👉 Answer: ') + chalk.yellow.bold('NO') + ' to create new project\n');
92
+
93
+ console.log(chalk.white('5️⃣ ') + chalk.green('What\'s the name of your existing project?'));
94
+ console.log(chalk.white(' 👉 Answer: ') + chalk.yellow.bold(answers.projectName) + ' (your actual project name)\n');
95
+
96
+ console.log(chalk.blue('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n'));
79
97
 
80
98
  try {
81
99
  // Run vercel link from the output directory
@@ -90,11 +108,18 @@ async function setupVercelProject(config) {
90
108
 
91
109
  // Important reminders for Vercel settings
92
110
  console.log(chalk.yellow('\n⚠️ IMPORTANT: Vercel Project Settings\n'));
93
- console.log(chalk.white('After deployment, go to your Vercel dashboard and:'));
94
- console.log(chalk.gray('1. Navigate to Project Settings > General'));
95
- console.log(chalk.gray('2. Under "Security", find "Deployment Protection"'));
96
- console.log(chalk.gray('3. Set "Deployment Protection" to "Disabled" for public access'));
97
- console.log(chalk.gray('4. Or configure authentication if you want to keep it private'));
111
+ console.log(chalk.white('After deployment, go to your Vercel dashboard:'));
112
+ console.log();
113
+ console.log(chalk.red.bold('🔴 CRITICAL: Check Root Directory Setting'));
114
+ console.log(chalk.white('1. Go to: ') + chalk.cyan(`https://vercel.com/${answers.projectName}/settings`));
115
+ console.log(chalk.white('2. Under "Build & Development Settings"'));
116
+ console.log(chalk.white('3. Make sure "Root Directory" is ') + chalk.yellow.bold('EMPTY or "./"'));
117
+ console.log(chalk.white(' (NOT "html" or any other directory)'));
118
+ console.log();
119
+ console.log(chalk.yellow('🔐 For Public Access:'));
120
+ console.log(chalk.white('1. Navigate to Project Settings > General'));
121
+ console.log(chalk.white('2. Under "Security", find "Deployment Protection"'));
122
+ console.log(chalk.white('3. Set "Deployment Protection" to ') + chalk.yellow.bold('Disabled'));
98
123
  console.log();
99
124
  console.log(chalk.cyan('Dashboard URL: https://vercel.com/dashboard'));
100
125
  console.log();
@@ -120,12 +145,43 @@ async function deployToVercel(config, isProd = false) {
120
145
  throw new Error(`Output directory ${outputPath} does not exist. Run 'doc-builder build' first.`);
121
146
  }
122
147
 
148
+ // Check for existing project link and warn about common issues
149
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
150
+ if (fs.existsSync(vercelProjectPath)) {
151
+ try {
152
+ const projectInfo = fs.readJsonSync(vercelProjectPath);
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
+
173
+ } catch (e) {
174
+ // Ignore read errors
175
+ }
176
+ }
177
+
123
178
  // Create vercel.json in output directory for deployment
124
179
  const vercelConfigPath = path.join(outputPath, 'vercel.json');
125
180
  if (!fs.existsSync(vercelConfigPath)) {
126
181
  const vercelConfig = {
127
- buildCommand: false,
182
+ buildCommand: "",
128
183
  outputDirectory: ".",
184
+ installCommand: "",
129
185
  framework: null
130
186
  };
131
187
  fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
@@ -147,6 +203,23 @@ async function deployToVercel(config, isProd = false) {
147
203
 
148
204
  return deployUrl;
149
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
+ }
150
223
  throw new Error(`Vercel deployment failed: ${error.message}`);
151
224
  }
152
225
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.0.5",
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": {