@knowcode/doc-builder 1.0.4 → 1.0.6

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,39 @@ 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.6] - 2025-01-19
9
+
10
+ ### Added
11
+ - Much more prominent and helpful Vercel setup instructions
12
+ - Step-by-step visual guide with numbered steps and emojis
13
+ - Warning about common "username/html" project linking mistake
14
+ - Detection and warning for existing project deployments
15
+ - Comprehensive troubleshooting for "html/html does not exist" error
16
+ - Clear instructions for fixing Root Directory settings
17
+
18
+ ### Improved
19
+ - Enhanced visual formatting for Vercel prompts with boxes and colors
20
+ - Added critical warnings about NOT linking to generic "html" projects
21
+ - Better error detection and user guidance
22
+ - More helpful project settings URLs
23
+
24
+ ### Fixed
25
+ - Updated vercel.json to use empty strings instead of false values
26
+ - Added installCommand to vercel.json for better compatibility
27
+
28
+ ## [1.0.5] - 2025-01-19
29
+
30
+ ### Fixed
31
+ - Fixed "vercel.json file should be inside of the provided root directory" error
32
+ - Deploy commands now run from the output directory (html/) instead of project root
33
+ - Vercel link command runs from correct directory during setup
34
+ - vercel.json is now created in the output directory where it belongs
35
+
36
+ ### Changed
37
+ - Simplified vercel.json configuration for static sites
38
+ - Updated deployment flow to work correctly with Vercel's expectations
39
+ - Vercel project detection now checks in output directory
40
+
8
41
  ## [1.0.4] - 2025-01-19
9
42
 
10
43
  ### Added
package/cli.js CHANGED
@@ -166,8 +166,7 @@ ${chalk.yellow('First-time Vercel Setup:')}
166
166
  ${chalk.green('Q: Link to existing project?')}
167
167
  → Answer: ${chalk.yellow('No')} (first time), ${chalk.yellow('Yes')} (if redeploying)
168
168
 
169
- ${chalk.green('Q: In which directory is your code located?')}
170
- → Answer: ${chalk.yellow('./html')} (or your output directory)
169
+ ${chalk.gray('Note: Vercel will auto-detect that we\'re deploying from the output directory')}
171
170
 
172
171
  ${chalk.green('Q: Want to modify these settings?')}
173
172
  → Answer: ${chalk.yellow('No')} (doc-builder handles this)
@@ -186,6 +185,24 @@ ${chalk.yellow('Troubleshooting:')}
186
185
  • ${chalk.cyan('Command not found:')} Install Vercel CLI globally
187
186
  • ${chalk.cyan('Not authenticated:')} Run ${chalk.gray('vercel login')}
188
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
189
206
  `)
190
207
  .action(async (options) => {
191
208
  const spinner = ora('Deploying to Vercel...').start();
@@ -221,8 +238,8 @@ ${chalk.yellow('Troubleshooting:')}
221
238
  await prepareDeployment(config);
222
239
 
223
240
  // Check if this is the first deployment
224
- const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
225
- if (!fs.existsSync(vercelConfigPath)) {
241
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
242
+ if (!fs.existsSync(vercelProjectPath)) {
226
243
  spinner.stop();
227
244
  console.log(chalk.yellow('\n🚀 First time deploying to Vercel!\n'));
228
245
 
@@ -355,8 +372,8 @@ program
355
372
  const deploySpinner = ora('Deploying to Vercel...').start();
356
373
 
357
374
  // Check if this is the first deployment
358
- const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
359
- if (!fs.existsSync(vercelConfigPath)) {
375
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
376
+ if (!fs.existsSync(vercelProjectPath)) {
360
377
  deploySpinner.stop();
361
378
  console.log(chalk.yellow('\n🚀 First time deploying to Vercel!\n'));
362
379
 
package/lib/deploy.js CHANGED
@@ -49,34 +49,58 @@ async function setupVercelProject(config) {
49
49
  }
50
50
  ]);
51
51
 
52
- // Create vercel.json if it doesn't exist
53
- const vercelConfigPath = path.join(process.cwd(), 'vercel.json');
54
- if (!fs.existsSync(vercelConfigPath)) {
55
- const vercelConfig = {
56
- outputDirectory: config.outputDir || 'html',
57
- framework: null, // Static HTML
58
- buildCommand: "", // No build needed - we already built
59
- devCommand: "", // No dev command
60
- installCommand: "", // No install needed
61
- public: answers.publicAccess
62
- };
63
-
64
- fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
65
- console.log(chalk.green('✅ Created vercel.json'));
52
+ // Create vercel.json in the output directory
53
+ const outputDir = path.join(process.cwd(), config.outputDir || 'html');
54
+ const vercelConfigPath = path.join(outputDir, 'vercel.json');
55
+
56
+ // Ensure output directory exists
57
+ if (!fs.existsSync(outputDir)) {
58
+ fs.mkdirSync(outputDir, { recursive: true });
66
59
  }
67
60
 
68
- // Run Vercel setup
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'));
61
+ // Create vercel.json for static site
62
+ // Use empty string instead of false to avoid Vercel issues
63
+ const vercelConfig = {
64
+ buildCommand: "",
65
+ outputDirectory: ".",
66
+ installCommand: "",
67
+ framework: null
68
+ };
69
+
70
+ fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
71
+ console.log(chalk.green(`✅ Created vercel.json in ${config.outputDir || 'html'} directory`));
72
+
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'));
77
97
 
78
98
  try {
79
- execSync('vercel link', { stdio: 'inherit' });
99
+ // Run vercel link from the output directory
100
+ execSync('vercel link', {
101
+ stdio: 'inherit',
102
+ cwd: outputDir
103
+ });
80
104
  } catch (error) {
81
105
  console.error(chalk.red('Failed to link Vercel project'));
82
106
  process.exit(1);
@@ -84,11 +108,18 @@ async function setupVercelProject(config) {
84
108
 
85
109
  // Important reminders for Vercel settings
86
110
  console.log(chalk.yellow('\n⚠️ IMPORTANT: Vercel Project Settings\n'));
87
- console.log(chalk.white('After deployment, go to your Vercel dashboard and:'));
88
- console.log(chalk.gray('1. Navigate to Project Settings > General'));
89
- console.log(chalk.gray('2. Under "Security", find "Deployment Protection"'));
90
- console.log(chalk.gray('3. Set "Deployment Protection" to "Disabled" for public access'));
91
- 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'));
92
123
  console.log();
93
124
  console.log(chalk.cyan('Dashboard URL: https://vercel.com/dashboard'));
94
125
  console.log();
@@ -114,13 +145,38 @@ async function deployToVercel(config, isProd = false) {
114
145
  throw new Error(`Output directory ${outputPath} does not exist. Run 'doc-builder build' first.`);
115
146
  }
116
147
 
148
+ // Check for existing project link
149
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
150
+ if (fs.existsSync(vercelProjectPath)) {
151
+ try {
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`));
156
+ } catch (e) {
157
+ // Ignore read errors
158
+ }
159
+ }
160
+
161
+ // Create vercel.json in output directory for deployment
162
+ const vercelConfigPath = path.join(outputPath, 'vercel.json');
163
+ if (!fs.existsSync(vercelConfigPath)) {
164
+ const vercelConfig = {
165
+ buildCommand: "",
166
+ outputDirectory: ".",
167
+ installCommand: "",
168
+ framework: null
169
+ };
170
+ fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
171
+ }
172
+
117
173
  // Deploy command
118
174
  const deployCmd = isProd ? 'vercel --prod' : 'vercel';
119
175
 
120
176
  try {
121
- // Run deployment and capture output
177
+ // Run deployment from the output directory
122
178
  const output = execSync(deployCmd, {
123
- cwd: process.cwd(),
179
+ cwd: outputPath,
124
180
  encoding: 'utf8'
125
181
  });
126
182
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {