@knowcode/doc-builder 1.0.4 → 1.0.5

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,19 @@ 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.5] - 2025-01-19
9
+
10
+ ### Fixed
11
+ - Fixed "vercel.json file should be inside of the provided root directory" error
12
+ - Deploy commands now run from the output directory (html/) instead of project root
13
+ - Vercel link command runs from correct directory during setup
14
+ - vercel.json is now created in the output directory where it belongs
15
+
16
+ ### Changed
17
+ - Simplified vercel.json configuration for static sites
18
+ - Updated deployment flow to work correctly with Vercel's expectations
19
+ - Vercel project detection now checks in output directory
20
+
8
21
  ## [1.0.4] - 2025-01-19
9
22
 
10
23
  ### 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)
@@ -221,8 +220,8 @@ ${chalk.yellow('Troubleshooting:')}
221
220
  await prepareDeployment(config);
222
221
 
223
222
  // Check if this is the first deployment
224
- const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
225
- if (!fs.existsSync(vercelConfigPath)) {
223
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
224
+ if (!fs.existsSync(vercelProjectPath)) {
226
225
  spinner.stop();
227
226
  console.log(chalk.yellow('\n🚀 First time deploying to Vercel!\n'));
228
227
 
@@ -355,8 +354,8 @@ program
355
354
  const deploySpinner = ora('Deploying to Vercel...').start();
356
355
 
357
356
  // Check if this is the first deployment
358
- const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
359
- if (!fs.existsSync(vercelConfigPath)) {
357
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
358
+ if (!fs.existsSync(vercelProjectPath)) {
360
359
  deploySpinner.stop();
361
360
  console.log(chalk.yellow('\n🚀 First time deploying to Vercel!\n'));
362
361
 
package/lib/deploy.js CHANGED
@@ -49,34 +49,40 @@ 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
 
61
+ // Create vercel.json for static site
62
+ const vercelConfig = {
63
+ buildCommand: false,
64
+ outputDirectory: ".",
65
+ framework: null
66
+ };
67
+
68
+ fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
69
+ console.log(chalk.green(`✅ Created vercel.json in ${config.outputDir || 'html'} directory`));
70
+
68
71
  // Run Vercel setup
69
72
  console.log(chalk.blue('\n🔗 Linking to Vercel...\n'));
70
73
  console.log(chalk.yellow('📝 Vercel will now ask additional questions:\n'));
71
- console.log(chalk.gray('• Set up [directory]? → Yes'));
74
+ console.log(chalk.gray('• Set up and deploy? → Yes'));
72
75
  console.log(chalk.gray('• Which scope? → Select your account'));
73
76
  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'));
77
+ console.log(chalk.gray('• Project name? → ' + answers.projectName));
78
+ console.log(chalk.gray('• Override settings? → No\n'));
77
79
 
78
80
  try {
79
- execSync('vercel link', { stdio: 'inherit' });
81
+ // Run vercel link from the output directory
82
+ execSync('vercel link', {
83
+ stdio: 'inherit',
84
+ cwd: outputDir
85
+ });
80
86
  } catch (error) {
81
87
  console.error(chalk.red('Failed to link Vercel project'));
82
88
  process.exit(1);
@@ -114,13 +120,24 @@ async function deployToVercel(config, isProd = false) {
114
120
  throw new Error(`Output directory ${outputPath} does not exist. Run 'doc-builder build' first.`);
115
121
  }
116
122
 
123
+ // Create vercel.json in output directory for deployment
124
+ const vercelConfigPath = path.join(outputPath, 'vercel.json');
125
+ if (!fs.existsSync(vercelConfigPath)) {
126
+ const vercelConfig = {
127
+ buildCommand: false,
128
+ outputDirectory: ".",
129
+ framework: null
130
+ };
131
+ fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
132
+ }
133
+
117
134
  // Deploy command
118
135
  const deployCmd = isProd ? 'vercel --prod' : 'vercel';
119
136
 
120
137
  try {
121
- // Run deployment and capture output
138
+ // Run deployment from the output directory
122
139
  const output = execSync(deployCmd, {
123
- cwd: process.cwd(),
140
+ cwd: outputPath,
124
141
  encoding: 'utf8'
125
142
  });
126
143
 
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.5",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {