@knowcode/doc-builder 1.1.2 → 1.1.4

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.1.4] - 2025-01-19
9
+
10
+ ### Fixed
11
+ - Removed deprecated --no-clipboard option
12
+ - Fixed 404 errors with better index.html handling
13
+ - Added fallback index.html when README.html doesn't exist
14
+ - Production deployment now correctly uses --prod flag
15
+
16
+ ### Added
17
+ - Auto-generated index.html with file listing if no README
18
+ - Better logging during deployment preparation
19
+ - Console messages when creating index.html
20
+
21
+ ### Changed
22
+ - Simplified deployment arguments
23
+ - Cleaner deployment command without unnecessary flags
24
+
25
+ ## [1.1.3] - 2025-01-19
26
+
27
+ ### Fixed
28
+ - Real-time output from Vercel CLI during deployment
29
+ - Fixed 404 errors by adding cleanUrls configuration
30
+ - Deployment now shows progress as it happens
31
+
32
+ ### Added
33
+ - cleanUrls: true in vercel.json for proper URL handling
34
+ - trailingSlash: false to prevent redirect issues
35
+ - Real-time streaming of Vercel deployment output
36
+
37
+ ### Changed
38
+ - Switched from execSync to spawn for live deployment output
39
+ - Better URL extraction from deployment output
40
+
8
41
  ## [1.1.2] - 2025-01-19
9
42
 
10
43
  ### Changed
package/lib/deploy.js CHANGED
@@ -64,7 +64,9 @@ async function setupVercelProject(config) {
64
64
  "outputDirectory": ".",
65
65
  "devCommand": "",
66
66
  "installCommand": "",
67
- "framework": null
67
+ "framework": null,
68
+ "cleanUrls": true,
69
+ "trailingSlash": false
68
70
  };
69
71
 
70
72
  fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
@@ -177,17 +179,15 @@ async function deployToVercel(config, isProd = false) {
177
179
  "outputDirectory": ".",
178
180
  "devCommand": "",
179
181
  "installCommand": "",
180
- "framework": null
182
+ "framework": null,
183
+ "cleanUrls": true,
184
+ "trailingSlash": false
181
185
  };
182
186
  fs.writeJsonSync(vercelConfigPath, vercelConfig, { spaces: 2 });
183
187
  }
184
188
 
185
189
  // Deploy command with explicit build settings
186
- // Override any project settings that might be causing issues
187
- const deployArgs = [
188
- '--build-env', 'VERCEL_BUILD_OUTPUT_DIRECTORY=.',
189
- '--no-clipboard'
190
- ];
190
+ const deployArgs = [];
191
191
 
192
192
  if (isProd) {
193
193
  deployArgs.push('--prod');
@@ -196,22 +196,51 @@ async function deployToVercel(config, isProd = false) {
196
196
  const deployCmd = `vercel ${deployArgs.join(' ')}`;
197
197
 
198
198
  try {
199
- // Run deployment from the output directory
200
- const output = execSync(deployCmd, {
201
- cwd: outputPath,
202
- encoding: 'utf8',
203
- env: {
204
- ...process.env,
205
- // Force Vercel to skip build
206
- VERCEL_BUILD_SKIP: '1'
207
- }
208
- });
209
-
210
- // Extract URL from output
211
- const urlMatch = output.match(/https:\/\/[^\s]+/);
212
- const deployUrl = urlMatch ? urlMatch[0] : 'Check Vercel dashboard';
199
+ // Run deployment from the output directory with real-time output
200
+ const { spawn } = require('child_process');
213
201
 
214
- return deployUrl;
202
+ return new Promise((resolve, reject) => {
203
+ const vercelProcess = spawn('vercel', deployArgs, {
204
+ cwd: outputPath,
205
+ env: {
206
+ ...process.env,
207
+ // Force Vercel to skip build
208
+ VERCEL_BUILD_SKIP: '1'
209
+ },
210
+ shell: true
211
+ });
212
+
213
+ let deployUrl = '';
214
+
215
+ // Capture stdout in real-time
216
+ vercelProcess.stdout.on('data', (data) => {
217
+ const output = data.toString();
218
+ process.stdout.write(output); // Show output in real-time
219
+
220
+ // Try to extract URL from output
221
+ const urlMatch = output.match(/https:\/\/[^\s]+/);
222
+ if (urlMatch) {
223
+ deployUrl = urlMatch[0];
224
+ }
225
+ });
226
+
227
+ // Capture stderr
228
+ vercelProcess.stderr.on('data', (data) => {
229
+ process.stderr.write(data.toString());
230
+ });
231
+
232
+ vercelProcess.on('close', (code) => {
233
+ if (code === 0) {
234
+ resolve(deployUrl || 'Check Vercel dashboard');
235
+ } else {
236
+ reject(new Error(`Vercel deployment failed with code ${code}`));
237
+ }
238
+ });
239
+
240
+ vercelProcess.on('error', (err) => {
241
+ reject(new Error(`Failed to start Vercel process: ${err.message}`));
242
+ });
243
+ });
215
244
  } catch (error) {
216
245
  // Check if this is the common "html/html" path error
217
246
  if (error.message && error.message.includes('html/html') && error.message.includes('does not exist')) {
@@ -266,7 +295,7 @@ async function prepareDeployment(config) {
266
295
  if (!fs.existsSync(indexPath)) {
267
296
  const readmePath = path.join(outputDir, 'README.html');
268
297
  if (fs.existsSync(readmePath)) {
269
- // Create redirect
298
+ // Create redirect to README.html
270
299
  const redirectHtml = `<!DOCTYPE html>
271
300
  <html>
272
301
  <head>
@@ -278,6 +307,37 @@ async function prepareDeployment(config) {
278
307
  </body>
279
308
  </html>`;
280
309
  fs.writeFileSync(indexPath, redirectHtml);
310
+ console.log(chalk.green('✅ Created index.html redirect to README.html'));
311
+ } else {
312
+ // If no README.html, create a basic index listing all HTML files
313
+ const htmlFiles = fs.readdirSync(outputDir)
314
+ .filter(file => file.endsWith('.html') && file !== 'index.html')
315
+ .sort();
316
+
317
+ if (htmlFiles.length > 0) {
318
+ const indexHtml = `<!DOCTYPE html>
319
+ <html>
320
+ <head>
321
+ <title>Documentation</title>
322
+ <style>
323
+ body { font-family: -apple-system, sans-serif; max-width: 800px; margin: 40px auto; padding: 0 20px; }
324
+ h1 { color: #333; }
325
+ ul { list-style: none; padding: 0; }
326
+ li { margin: 10px 0; }
327
+ a { color: #0066cc; text-decoration: none; }
328
+ a:hover { text-decoration: underline; }
329
+ </style>
330
+ </head>
331
+ <body>
332
+ <h1>Documentation</h1>
333
+ <ul>
334
+ ${htmlFiles.map(file => `<li><a href="${file}">${file.replace('.html', '')}</a></li>`).join('\n ')}
335
+ </ul>
336
+ </body>
337
+ </html>`;
338
+ fs.writeFileSync(indexPath, indexHtml);
339
+ console.log(chalk.green('✅ Created index.html with file listing'));
340
+ }
281
341
  }
282
342
  }
283
343
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knowcode/doc-builder",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "Reusable documentation builder for markdown-based sites with Vercel deployment support",
5
5
  "main": "index.js",
6
6
  "bin": {