@knowcode/doc-builder 1.0.3 → 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,33 @@ 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
+
21
+ ## [1.0.4] - 2025-01-19
22
+
23
+ ### Added
24
+ - Comprehensive Vercel CLI prompt explanations in help text
25
+ - Step-by-step answers for all Vercel setup questions
26
+ - Hints in prompts to guide users through setup
27
+ - Pre-deployment guidance showing what Vercel will ask
28
+ - Better project name sanitization for Vercel URLs
29
+
30
+ ### Improved
31
+ - More detailed deployment help with exact answers to provide
32
+ - Clearer instructions for first-time vs. subsequent deployments
33
+ - Visual question/answer format in help documentation
34
+
8
35
  ## [1.0.3] - 2025-01-19
9
36
 
10
37
  ### Fixed
package/cli.js CHANGED
@@ -141,11 +141,35 @@ ${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.gray('Note: Vercel will auto-detect that we\'re deploying from the output directory')}
170
+
171
+ ${chalk.green('Q: Want to modify these settings?')}
172
+ → Answer: ${chalk.yellow('No')} (doc-builder handles this)
149
173
 
150
174
  ${chalk.cyan('4. Configure Access (Important!):')}
151
175
  After deployment, go to your Vercel dashboard:
@@ -196,8 +220,8 @@ ${chalk.yellow('Troubleshooting:')}
196
220
  await prepareDeployment(config);
197
221
 
198
222
  // Check if this is the first deployment
199
- const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
200
- if (!fs.existsSync(vercelConfigPath)) {
223
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
224
+ if (!fs.existsSync(vercelProjectPath)) {
201
225
  spinner.stop();
202
226
  console.log(chalk.yellow('\n🚀 First time deploying to Vercel!\n'));
203
227
 
@@ -330,8 +354,8 @@ program
330
354
  const deploySpinner = ora('Deploying to Vercel...').start();
331
355
 
332
356
  // Check if this is the first deployment
333
- const vercelConfigPath = path.join(process.cwd(), '.vercel', 'project.json');
334
- if (!fs.existsSync(vercelConfigPath)) {
357
+ const vercelProjectPath = path.join(outputPath, '.vercel', 'project.json');
358
+ if (!fs.existsSync(vercelProjectPath)) {
335
359
  deploySpinner.stop();
336
360
  console.log(chalk.yellow('\n🚀 First time deploying to Vercel!\n'));
337
361
 
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,37 +37,52 @@ 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
 
49
- // Create vercel.json if it doesn't exist
50
- const vercelConfigPath = path.join(process.cwd(), 'vercel.json');
51
- if (!fs.existsSync(vercelConfigPath)) {
52
- const vercelConfig = {
53
- outputDirectory: config.outputDir || 'html',
54
- framework: null, // Static HTML
55
- buildCommand: "", // No build needed - we already built
56
- devCommand: "", // No dev command
57
- installCommand: "", // No install needed
58
- public: answers.publicAccess
59
- };
60
-
61
- fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
62
- 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 });
63
59
  }
64
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
+
65
71
  // Run Vercel setup
66
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'));
67
79
 
68
80
  try {
69
- execSync('vercel link', { stdio: 'inherit' });
81
+ // Run vercel link from the output directory
82
+ execSync('vercel link', {
83
+ stdio: 'inherit',
84
+ cwd: outputDir
85
+ });
70
86
  } catch (error) {
71
87
  console.error(chalk.red('Failed to link Vercel project'));
72
88
  process.exit(1);
@@ -104,13 +120,24 @@ async function deployToVercel(config, isProd = false) {
104
120
  throw new Error(`Output directory ${outputPath} does not exist. Run 'doc-builder build' first.`);
105
121
  }
106
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
+
107
134
  // Deploy command
108
135
  const deployCmd = isProd ? 'vercel --prod' : 'vercel';
109
136
 
110
137
  try {
111
- // Run deployment and capture output
138
+ // Run deployment from the output directory
112
139
  const output = execSync(deployCmd, {
113
- cwd: process.cwd(),
140
+ cwd: outputPath,
114
141
  encoding: 'utf8'
115
142
  });
116
143
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.0.3",
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": {