spec-up-t 1.2.5 → 1.2.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.
Files changed (37) hide show
  1. package/assets/compiled/body.js +9 -9
  2. package/assets/compiled/head.css +6 -5
  3. package/assets/css/collapse-definitions.css +41 -0
  4. package/assets/css/create-pdf.css +339 -0
  5. package/assets/css/horizontal-scroll-hint.css +6 -0
  6. package/assets/css/image-full-size.css +1 -5
  7. package/assets/css/index.css +5 -0
  8. package/assets/css/search.css +8 -8
  9. package/assets/css/terms-and-definitions.css +3 -3
  10. package/assets/js/add-bootstrap-classes-to-images.js +2 -5
  11. package/assets/js/collapse-definitions.js +260 -34
  12. package/assets/js/collapse-meta-info.js +37 -10
  13. package/assets/js/collapsibleMenu.js +0 -24
  14. package/assets/js/create-term-filter.js +36 -18
  15. package/assets/js/hide-show-utility-container.js +0 -1
  16. package/assets/js/horizontal-scroll-hint.js +2 -2
  17. package/assets/js/image-full-size.js +0 -2
  18. package/assets/js/insert-trefs.js +135 -49
  19. package/assets/js/search.js +34 -20
  20. package/{src → config}/asset-map.json +1 -0
  21. package/gulpfile.js +1 -1
  22. package/index.js +3 -3
  23. package/jest.config.js +20 -0
  24. package/package.json +3 -2
  25. package/src/collectExternalReferences/fetchTermsFromIndex.1.js +340 -0
  26. package/src/collectExternalReferences/fetchTermsFromIndex.js +1 -1
  27. package/src/collectExternalReferences/processXTrefsData.js +1 -1
  28. package/src/create-pdf.js +330 -21
  29. package/src/health-check/{output-gitignore-checker.js → destination-gitignore-checker.js} +40 -25
  30. package/src/health-check.js +38 -38
  31. package/src/markdown-it-extensions.js +2 -2
  32. package/src/utils/README.md +35 -0
  33. package/src/utils/file-opener.js +89 -0
  34. package/assets/css/pdf-styles.css +0 -170
  35. package/branches.md +0 -17
  36. package/src/README.md +0 -98
  37. /package/{src/config → config}/paths.js +0 -0
package/src/create-pdf.js CHANGED
@@ -29,7 +29,7 @@ const pdfLib = require('pdf-lib');
29
29
  let bootstrapCss = bootstrapExists ? fs.readFileSync(bootstrapCssPath, 'utf8') : '';
30
30
 
31
31
  // Path to PDF styles CSS
32
- const pdfStylesPath = path.resolve(process.cwd(), 'assets/css/pdf-styles.css');
32
+ const pdfStylesPath = path.resolve(process.cwd(), 'assets/css/create-pdf.css');
33
33
  const pdfStylesExist = fs.existsSync(pdfStylesPath);
34
34
  const pdfStylesCss = pdfStylesExist ? fs.readFileSync(pdfStylesPath, 'utf8') : '';
35
35
 
@@ -38,8 +38,14 @@ const pdfLib = require('pdf-lib');
38
38
 
39
39
  // Clean up unnecessary elements but be careful not to remove styles we need
40
40
  await page.evaluate(() => {
41
- document.querySelectorAll('[style*="display: none"], .d-print-none, script').forEach(element => element.remove());
41
+ // Preserve TOC if it exists (skip removing it even if it has display:none)
42
+ document.querySelectorAll('[style*="display: none"]:not(#toc):not(#toc *), .d-print-none:not(#toc):not(#toc *), script').forEach(element => element.remove());
42
43
  // Don't remove all style elements as some might be important
44
+
45
+ // If TOC doesn't exist, we'll need to create one
46
+ if (!document.getElementById('toc')) {
47
+ console.log('No TOC found in the document. Will create one.');
48
+ }
43
49
  });
44
50
 
45
51
  // Handle dynamically fetched cross-reference terms
@@ -68,7 +74,7 @@ const pdfLib = require('pdf-lib');
68
74
  container.style.margin = '0 auto';
69
75
  container.style.padding = '0';
70
76
  });
71
-
77
+
72
78
  // Override any Bootstrap column constraints
73
79
  const columns = document.querySelectorAll('[class*="col-"]');
74
80
  columns.forEach(col => {
@@ -77,7 +83,7 @@ const pdfLib = require('pdf-lib');
77
83
  col.style.paddingLeft = '0';
78
84
  col.style.paddingRight = '0';
79
85
  });
80
-
86
+
81
87
  // Ensure body takes full width
82
88
  document.body.style.maxWidth = '100%';
83
89
  document.body.style.width = '100%';
@@ -113,18 +119,18 @@ const pdfLib = require('pdf-lib');
113
119
  document.querySelectorAll('table').forEach(table => {
114
120
  table.classList.add('table', 'table-bordered', 'table-striped', 'table-hover');
115
121
  });
116
-
122
+
117
123
  // Make sure meta-info is visible and toggle buttons are hidden
118
124
  document.querySelectorAll('.meta-info, .term-meta').forEach(meta => {
119
125
  meta.style.display = 'block';
120
126
  });
121
-
127
+
122
128
  document.querySelectorAll('.meta-toggle, button.meta-toggle').forEach(button => {
123
129
  button.style.display = 'none';
124
130
  });
125
131
  });
126
132
 
127
- // Inject logo, title, and description
133
+ // Inject logo, title, and description AND handle TOC creation if needed
128
134
  await page.evaluate((logo, logoLink, title, description) => {
129
135
  const titleWrapper = document.createElement('div');
130
136
  titleWrapper.className = 'text-center mb-5 pb-4 border-bottom';
@@ -155,9 +161,88 @@ const pdfLib = require('pdf-lib');
155
161
  }
156
162
 
157
163
  document.body.insertBefore(titleWrapper, document.body.firstChild);
164
+
165
+ // Create a Table of Contents if it doesn't exist
166
+ if (!document.getElementById('toc')) {
167
+ // Generate a TOC based on the headings in the document
168
+ const headings = Array.from(document.querySelectorAll('h1:not(.pdf-title), h2, h3, h4, h5, h6')).filter(h => {
169
+ // Only include headings with IDs that can be linked to
170
+ return h.id && h.id.trim() !== '';
171
+ });
172
+
173
+ if (headings.length > 0) {
174
+ // Create TOC container
175
+ const tocContainer = document.createElement('div');
176
+ tocContainer.id = 'toc';
177
+ tocContainer.className = 'toc-container';
178
+
179
+ // Create TOC heading
180
+ const tocHeading = document.createElement('h2');
181
+ tocHeading.textContent = 'Contents';
182
+ tocHeading.className = 'toc-heading';
183
+ tocContainer.appendChild(tocHeading);
184
+
185
+ // Create TOC list
186
+ const tocList = document.createElement('ul');
187
+ tocList.className = 'toc-list';
188
+ tocContainer.appendChild(tocList);
189
+
190
+ // Add all headings to the TOC
191
+ let currentLevel = 0;
192
+ let currentList = tocList;
193
+ let listStack = [tocList];
194
+
195
+ headings.forEach(heading => {
196
+ // Get heading level (1-6 for h1-h6)
197
+ const level = parseInt(heading.tagName[1]);
198
+
199
+ // Navigate to the correct nesting level
200
+ if (level > currentLevel) {
201
+ // Go deeper - create a new nested list
202
+ for (let i = currentLevel; i < level; i++) {
203
+ if (currentList.lastChild) {
204
+ const nestedList = document.createElement('ul');
205
+ currentList.lastChild.appendChild(nestedList);
206
+ listStack.push(nestedList);
207
+ currentList = nestedList;
208
+ } else {
209
+ // If no items exist yet, add a dummy item
210
+ const dummyItem = document.createElement('li');
211
+ const nestedList = document.createElement('ul');
212
+ dummyItem.appendChild(nestedList);
213
+ currentList.appendChild(dummyItem);
214
+ listStack.push(nestedList);
215
+ currentList = nestedList;
216
+ }
217
+ }
218
+ } else if (level < currentLevel) {
219
+ // Go up - pop from the stack
220
+ for (let i = currentLevel; i > level; i--) {
221
+ listStack.pop();
222
+ }
223
+ currentList = listStack[listStack.length - 1];
224
+ }
225
+
226
+ currentLevel = level;
227
+
228
+ // Create list item with link
229
+ const listItem = document.createElement('li');
230
+ const link = document.createElement('a');
231
+ link.href = '#' + heading.id;
232
+ link.textContent = heading.textContent;
233
+ listItem.appendChild(link);
234
+ currentList.appendChild(listItem);
235
+ });
236
+
237
+ // Insert the TOC after the title section
238
+ document.body.insertBefore(tocContainer, titleWrapper.nextSibling);
239
+
240
+ console.log('Generated a Table of Contents with ' + headings.length + ' entries.');
241
+ }
242
+ }
158
243
  }, logo, logoLink, title, description);
159
-
160
- // Direct manipulation of definition lists to ensure proper styling in PDF
244
+
245
+ // Direct manipulation of definition lists and TOC to ensure proper styling in PDF
161
246
  await page.evaluate(() => {
162
247
  // Process all definition lists
163
248
  const definitionLists = document.querySelectorAll('dl.terms-and-definitions-list');
@@ -168,7 +253,7 @@ const pdfLib = require('pdf-lib');
168
253
  // Remove background and borders with !important to override any existing styles
169
254
  term.setAttribute('style', term.getAttribute('style') + '; background: transparent !important; background-color: transparent !important; background-image: none !important; border: none !important; border-radius: 0 !important; padding: 0.5rem 0 !important;');
170
255
  });
171
-
256
+
172
257
  // Ensure all meta-info content is visible
173
258
  const metaInfoContents = list.querySelectorAll('dd.meta-info-content-wrapper');
174
259
  metaInfoContents.forEach(content => {
@@ -179,42 +264,266 @@ const pdfLib = require('pdf-lib');
179
264
  content.style.padding = '0.5rem 0';
180
265
  content.style.margin = '0';
181
266
  content.style.lineHeight = 'normal';
182
-
267
+
183
268
  // Remove the collapsed class if present
184
269
  content.classList.remove('collapsed');
185
270
  });
186
-
271
+
187
272
  // Hide all meta-info toggle buttons
188
273
  const toggleButtons = list.querySelectorAll('.meta-info-toggle-button');
189
274
  toggleButtons.forEach(button => {
190
275
  button.style.display = 'none';
191
276
  });
192
277
  });
193
-
278
+
194
279
  // Special handling for ALL transcluded terms with blue background - no class restrictions
195
280
  document.querySelectorAll('.transcluded-xref-term').forEach(el => {
196
281
  // Use the most aggressive approach possible to override the blue background
197
282
  el.setAttribute('style', el.getAttribute('style') + '; background: transparent !important; background-color: transparent !important; background-image: none !important;');
198
-
283
+
199
284
  // Also process any child elements to ensure complete removal of background
200
285
  Array.from(el.children).forEach(child => {
201
286
  child.setAttribute('style', child.getAttribute('style') + '; background: transparent !important; background-color: transparent !important; background-image: none !important;');
202
287
  });
203
288
  });
204
-
289
+
205
290
  // Remove any inline styles that might be setting backgrounds
206
291
  document.querySelectorAll('style').forEach(styleTag => {
207
292
  let cssText = styleTag.textContent;
208
293
  // If the style tag contains transcluded-xref-term styles, modify them
209
294
  if (cssText.includes('transcluded-xref-term') && cssText.includes('background')) {
210
- cssText = cssText.replace(/dt\.transcluded-xref-term[^}]+}/g,
211
- 'dt.transcluded-xref-term, dd.transcluded-xref-term { background: transparent !important; background-color: transparent !important; background-image: none !important; }');
295
+ cssText = cssText.replace(/dt\.transcluded-xref-term[^}]+}/g,
296
+ 'dt.transcluded-xref-term, dd.transcluded-xref-term { background: transparent !important; background-color: transparent !important; background-image: none !important; }');
212
297
  styleTag.textContent = cssText;
213
298
  }
214
- });
299
+ }); // Format Table of Contents for book-like layout
300
+ const toc = document.getElementById('toc');
301
+ if (toc) {
302
+ // Make sure TOC is visible
303
+ toc.style.display = 'block';
304
+ toc.style.visibility = 'visible';
305
+ toc.style.opacity = '1';
306
+
307
+ // Create a new TOC div for the PDF using a completely different approach
308
+ const pdfToc = document.createElement('div');
309
+ pdfToc.id = 'pdf-toc';
310
+
311
+ // Ensure TOC has a header
312
+ const tocHeading = document.createElement('h2');
313
+ tocHeading.textContent = 'Contents';
314
+ tocHeading.style.textAlign = 'center';
315
+ tocHeading.style.fontWeight = 'bold';
316
+ tocHeading.style.marginBottom = '1.5rem';
317
+ tocHeading.style.paddingBottom = '0.5rem';
318
+ tocHeading.style.borderBottom = '1px solid #000';
319
+ pdfToc.appendChild(tocHeading);
320
+
321
+ // Create a fresh TOC structure - completely rebuilding it
322
+ const tocList = document.createElement('ul');
323
+ tocList.style.listStyleType = 'none';
324
+ tocList.style.padding = '0';
325
+ tocList.style.margin = '0';
326
+ pdfToc.appendChild(tocList);
327
+
328
+ // Find all section headings to include in the TOC
329
+ // Look for both original TOC entries and also scan document headings
330
+ const tocOriginalLinks = toc.querySelectorAll('a');
331
+
332
+ // Process each TOC link to create a new TOC item
333
+ tocOriginalLinks.forEach((link, index) => {
334
+ const li = document.createElement('li');
335
+ const rowDiv = document.createElement('div');
336
+ rowDiv.className = 'toc-row';
337
+
338
+ const title = document.createElement('a');
339
+ title.href = link.getAttribute('href');
340
+ title.textContent = link.textContent;
341
+ title.className = 'toc-title';
342
+ title.setAttribute('data-target-id', link.getAttribute('href').substring(1)); // Store the target id
343
+ // Ensure no blue color or underline for TOC links
344
+ title.style.color = '#000';
345
+ title.style.textDecoration = 'none';
346
+ title.style.borderBottom = 'none';
347
+ title.style.backgroundColor = 'transparent';
348
+
349
+ const leader = document.createElement('div');
350
+ leader.className = 'toc-leader';
351
+
352
+ // Create page number placeholder - we'll fill in actual page numbers later
353
+ const pageNumber = document.createElement('span');
354
+ pageNumber.className = 'toc-page-number';
355
+ pageNumber.textContent = ''; // Empty for now
356
+ pageNumber.setAttribute('data-for-id', link.getAttribute('href').substring(1));
357
+ pageNumber.style.position = 'absolute';
358
+ pageNumber.style.right = '0';
359
+
360
+ rowDiv.appendChild(title);
361
+ rowDiv.appendChild(leader);
362
+ li.appendChild(rowDiv);
363
+ li.appendChild(pageNumber);
364
+
365
+ // Determine nesting level from original TOC
366
+ let level = 0;
367
+ let parent = link.closest('li');
368
+ while (parent) {
369
+ const parentList = parent.closest('ul');
370
+ if (parentList && parentList !== toc) {
371
+ level++;
372
+ parent = parentList.closest('li');
373
+ } else {
374
+ break;
375
+ }
376
+ }
377
+
378
+ // Apply indentation based on level
379
+ if (level > 0) {
380
+ li.style.paddingLeft = (level * 15) + 'px';
381
+ }
382
+
383
+ tocList.appendChild(li);
384
+ });
385
+
386
+ // Insert the new TOC at the beginning of the document after the title
387
+ const titleWrapper = document.querySelector('.text-center.mb-5.pb-4.border-bottom');
388
+ if (titleWrapper && titleWrapper.nextSibling) {
389
+ document.body.insertBefore(pdfToc, titleWrapper.nextSibling);
390
+ } else {
391
+ document.body.insertBefore(pdfToc, document.body.firstChild);
392
+ }
393
+
394
+ // Force page break before TOC
395
+ pdfToc.style.breakBefore = 'page';
396
+ pdfToc.style.pageBreakBefore = 'always';
397
+
398
+ // Force page break after TOC
399
+ const tocNext = pdfToc.nextElementSibling;
400
+ if (tocNext) {
401
+ tocNext.style.breakBefore = 'page';
402
+ tocNext.style.pageBreakBefore = 'always';
403
+ }
404
+
405
+ // Hide the original TOC
406
+ toc.style.display = 'none';
407
+ }
408
+ });
409
+
410
+ console.log('Generating PDF with proper TOC page numbers...');
411
+
412
+ // First, generate a draft PDF to calculate the page positions of each heading
413
+ const draftPdfBuffer = await page.pdf({
414
+ format: 'A4',
415
+ displayHeaderFooter: true,
416
+ footerTemplate: `
417
+ <div style="width: 100%; text-align: center; font-size: 10pt; margin-top: 10mm;">
418
+ Page <span class="pageNumber"></span> of <span class="totalPages"></span>
419
+ </div>
420
+ `,
421
+ headerTemplate: '<div></div>',
422
+ preferCSSPageSize: true,
423
+ printBackground: true,
424
+ margin: { top: '10mm', bottom: '10mm', left: '10mm', right: '10mm' }
425
+ });
426
+
427
+ // Now extract the page numbers from the tooltips and update the TOC entries
428
+ await page.evaluate(() => {
429
+ // Find the PDF TOC
430
+ const pdfToc = document.getElementById('pdf-toc');
431
+ if (!pdfToc) return;
432
+
433
+ const tocEntries = pdfToc.querySelectorAll('.toc-page-number');
434
+ const originalToc = document.getElementById('toc');
435
+
436
+ if (originalToc) {
437
+ // Get all links from the original TOC that have tooltip data
438
+ const originalLinks = originalToc.querySelectorAll('a[title], a[data-bs-title]');
439
+
440
+ // Create a mapping from heading IDs to page numbers based on tooltips
441
+ const idToPageMap = {};
442
+
443
+ originalLinks.forEach(link => {
444
+ // Extract the heading ID from href
445
+ const href = link.getAttribute('href');
446
+ if (!href || !href.startsWith('#')) return;
447
+
448
+ const headingId = href.substring(1);
449
+
450
+ // Extract page number from tooltip text (e.g., "Go to page 5")
451
+ const tooltipText = link.getAttribute('title') || link.getAttribute('data-bs-title');
452
+ if (!tooltipText) return;
453
+
454
+ const pageNumberMatch = tooltipText.match(/Go to page (\d+)/i);
455
+ if (pageNumberMatch && pageNumberMatch[1]) {
456
+ const pageNumber = parseInt(pageNumberMatch[1], 10);
457
+ if (!isNaN(pageNumber)) {
458
+ idToPageMap[headingId] = pageNumber;
459
+ }
460
+ }
461
+ });
462
+
463
+ // Now update the TOC page numbers using the extracted values
464
+ tocEntries.forEach(entry => {
465
+ const targetId = entry.getAttribute('data-for-id');
466
+ if (targetId && idToPageMap[targetId]) {
467
+ entry.textContent = idToPageMap[targetId];
468
+ // Ensure page numbers are clearly visible with proper styling
469
+ entry.style.visibility = 'visible';
470
+ entry.style.opacity = '1';
471
+ entry.style.color = '#000';
472
+ entry.style.background = '#fff';
473
+ entry.style.padding = '0 4px';
474
+ entry.style.fontWeight = 'normal';
475
+ }
476
+ });
477
+ } else {
478
+ // Fallback to old estimation method if original TOC is not available
479
+ console.log('Original TOC not found, using page number estimation method');
480
+
481
+ // Find all headings with IDs (potential TOC targets)
482
+ const headingsWithIds = Array.from(document.querySelectorAll('h1, h2, h3, h4, h5, h6')).filter(h => h.id);
483
+
484
+ // Use real offsets for more accurate page numbers
485
+ const idToPosition = {};
486
+
487
+ headingsWithIds.forEach(heading => {
488
+ const rect = heading.getBoundingClientRect();
489
+ idToPosition[heading.id] = {
490
+ top: rect.top + window.scrollY,
491
+ id: heading.id
492
+ };
493
+ });
494
+
495
+ // Sort by vertical position
496
+ const sortedPositions = Object.values(idToPosition).sort((a, b) => a.top - b.top);
497
+
498
+ // A4 page height (mm to pixels at 96 DPI)
499
+ const pageHeight = 297 * 96 / 25.4;
500
+ const effectivePageHeight = pageHeight - 20; // Account for margins
501
+
502
+ // Start on page 3 (after title and TOC)
503
+ let currentPage = 3;
504
+ let currentOffset = 0;
505
+
506
+ // Calculate page numbers based on relative positions
507
+ sortedPositions.forEach(pos => {
508
+ while (pos.top > currentOffset + effectivePageHeight) {
509
+ currentPage++;
510
+ currentOffset += effectivePageHeight;
511
+ }
512
+
513
+ idToPosition[pos.id].page = currentPage;
514
+ });
515
+
516
+ // Update TOC entries with calculated page numbers
517
+ tocEntries.forEach(entry => {
518
+ const targetId = entry.getAttribute('data-for-id');
519
+ if (targetId && idToPosition[targetId] && idToPosition[targetId].page) {
520
+ entry.textContent = idToPosition[targetId].page;
521
+ }
522
+ });
523
+ }
215
524
  });
216
525
 
217
- // Generate PDF
526
+ // Final PDF generation with correct page numbers
218
527
  const pdfBuffer = await page.pdf({
219
528
  path: path.resolve(process.cwd(), 'docs/index.pdf'),
220
529
  format: 'A4',
@@ -228,7 +537,7 @@ const pdfLib = require('pdf-lib');
228
537
  preferCSSPageSize: true,
229
538
  printBackground: true,
230
539
  quality: 100,
231
- margin: { top: '10mm', bottom: '10mm', left: '3mm', right: '3mm' }
540
+ margin: { top: '10mm', bottom: '10mm', left: '10mm', right: '10mm' }
232
541
  });
233
542
 
234
543
  await browser.close();
@@ -248,4 +557,4 @@ const pdfLib = require('pdf-lib');
248
557
  } catch (error) {
249
558
  console.error('❌ Error generating PDF:', error);
250
559
  }
251
- })();
560
+ })();
@@ -1,6 +1,17 @@
1
+ /**
2
+ * @file destination-gitignore-checker.js
3
+ * @description Checks if the final destination directory (from output_path in specs.json)
4
+ * is being ignored by Git. This is the directory where index.html is generated,
5
+ * NOT the temporary .cache directory (formerly called "output").
6
+ *
7
+ * Important: This file deals with concept #1 (output_path from specs.json),
8
+ * not concept #2 (the temporary .cache directory for build artifacts).
9
+ */
10
+
1
11
  const fs = require('fs');
2
12
  const path = require('path');
3
- const { execSync } = require('child_process');
13
+ const { spawnSync } = require('child_process');
14
+ const fileOpener = require('../utils/file-opener');
4
15
 
5
16
  /**
6
17
  * Checks if a path is gitignored
@@ -13,8 +24,11 @@ function isPathGitIgnored(projectRoot, targetPath) {
13
24
  // Use git check-ignore to determine if the path is ignored
14
25
  // If command exits with status 0, path is ignored
15
26
  // If command exits with status 1, path is not ignored
16
- execSync(`git -C "${projectRoot}" check-ignore -q "${targetPath}"`, { stdio: 'ignore' });
17
- return true; // Path is ignored (command exited with status 0)
27
+ const gitPath = fileOpener.getCommandPath('git');
28
+ const result = spawnSync(gitPath, ['-C', projectRoot, 'check-ignore', '-q', targetPath], {
29
+ stdio: 'ignore'
30
+ });
31
+ return result.status === 0; // Path is ignored (command exited with status 0)
18
32
  } catch (error) {
19
33
  console.log(`Error checking if path is gitignored: ${error.message}`);
20
34
  return false; // Path is not ignored (command exited with non-zero status)
@@ -87,11 +101,11 @@ function extractOutputPath(specsPath) {
87
101
  }
88
102
 
89
103
  /**
90
- * Check if the output directory exists
104
+ * Check if the final destination directory (from output_path) exists
91
105
  * @param {string} projectRoot - Root directory of the project
92
106
  * @param {string} outputPath - Output path from specs.json
93
107
  * @param {string} normalizedPath - Normalized output path
94
- * @returns {Object} - Result with output directory check
108
+ * @returns {Object} - Result with final destination directory check
95
109
  */
96
110
  function checkOutputDirExists(projectRoot, outputPath, normalizedPath) {
97
111
  // Check if the path exists
@@ -100,17 +114,17 @@ function checkOutputDirExists(projectRoot, outputPath, normalizedPath) {
100
114
 
101
115
  if (!outputPathExists) {
102
116
  return {
103
- name: 'Output directory existence',
117
+ name: 'Final destination directory existence',
104
118
  status: 'warning',
105
119
  success: true, // Still considered a "success" for backward compatibility
106
- details: `Output directory "${outputPath}" does not exist yet. This is OK if you haven't rendered the specs yet.`
120
+ details: `Final destination directory "${outputPath}" does not exist yet. This is OK if you haven't rendered the specs yet.`
107
121
  };
108
122
  }
109
123
 
110
124
  return {
111
- name: 'Output directory existence',
125
+ name: 'Final destination directory existence',
112
126
  success: true,
113
- details: `Output directory "${outputPath}" exists`
127
+ details: `Final destination directory "${outputPath}" exists`
114
128
  };
115
129
  }
116
130
 
@@ -245,7 +259,7 @@ function findComplexHtmlPatterns(lines) {
245
259
  }
246
260
 
247
261
  /**
248
- * Check if HTML files in the output directory are being ignored by Git
262
+ * Check if HTML files in the final destination directory are being ignored by Git
249
263
  * @param {string} projectRoot - Root directory of the project
250
264
  * @param {string} normalizedPath - Normalized output path
251
265
  * @param {string} outputPath - Original output path
@@ -273,8 +287,8 @@ function checkHtmlFilesGitignore(projectRoot, normalizedPath, outputPath, releva
273
287
  name: 'Check if index.html files are gitignored',
274
288
  success: !isIndexHtmlIgnored,
275
289
  details: isIndexHtmlIgnored
276
- ? `index.html files in the output directory would be ignored by Git. This is problematic as they're crucial output files.`
277
- : `index.html files in the output directory are properly tracked by Git.`
290
+ ? `index.html files in the final destination directory would be ignored by Git. This is problematic as they're crucial output files.`
291
+ : `index.html files in the final destination directory are properly tracked by Git.`
278
292
  });
279
293
 
280
294
  // If index.html is ignored but we couldn't find an explicit pattern, look for more complex patterns
@@ -295,22 +309,22 @@ function checkHtmlFilesGitignore(projectRoot, normalizedPath, outputPath, releva
295
309
  }
296
310
 
297
311
  /**
298
- * Check if output directory is being ignored by Git
312
+ * Check if final destination directory (from output_path) is being ignored by Git
299
313
  * @param {string} projectRoot - Root directory of the project
300
314
  * @param {string} normalizedPath - Normalized output path
301
315
  * @param {string} outputPath - Original output path
302
316
  * @param {string} dirName - Directory name from path
303
317
  * @param {Array} relevantLines - Relevant lines from .gitignore
304
- * @returns {Array} - Results for output directory gitignore check
318
+ * @returns {Array} - Results for final destination directory gitignore check
305
319
  */
306
320
  function checkOutputDirIgnorePatterns(projectRoot, normalizedPath, outputPath, dirName, relevantLines) {
307
321
  const dirIgnorePatterns = findOutputDirIgnorePatterns(relevantLines, normalizedPath, dirName);
308
322
 
309
323
  if (dirIgnorePatterns.length > 0) {
310
324
  return [{
311
- name: 'Check if output directory is gitignored',
325
+ name: 'Check if final destination directory is gitignored',
312
326
  success: false,
313
- details: `Found patterns in .gitignore that would ignore the output directory: ${dirIgnorePatterns.join(', ')}. Remove these entries to ensure generated content is tracked.`
327
+ details: `Found patterns in .gitignore that would ignore the final destination directory: ${dirIgnorePatterns.join(', ')}. Remove these entries to ensure generated content is tracked.`
314
328
  }];
315
329
  }
316
330
 
@@ -318,20 +332,21 @@ function checkOutputDirIgnorePatterns(projectRoot, normalizedPath, outputPath, d
318
332
  const isIgnored = isPathGitIgnored(projectRoot, normalizedPath);
319
333
 
320
334
  return [{
321
- name: 'Check if output directory is gitignored',
335
+ name: 'Check if final destination directory is gitignored',
322
336
  success: !isIgnored,
323
337
  details: isIgnored
324
- ? `Output directory "${outputPath}" is being ignored by Git. This could be due to a complex pattern in .gitignore. Remove any entries that might affect this directory.`
325
- : `Output directory "${outputPath}" is not being ignored by Git, which is good.`
338
+ ? `Final destination directory "${outputPath}" is being ignored by Git. This could be due to a complex pattern in .gitignore. Remove any entries that might affect this directory.`
339
+ : `Final destination directory "${outputPath}" is not being ignored by Git, which is good.`
326
340
  }];
327
341
  }
328
342
 
329
343
  /**
330
- * Check if the output directory is being ignored by Git
344
+ * Check if the final destination directory (from output_path in specs.json) is being ignored by Git
345
+ * This checks the directory where index.html is generated, NOT the temporary .cache directory
331
346
  * @param {string} projectRoot - Root directory of the project
332
347
  * @returns {Promise<Array>} - Array of check results
333
348
  */
334
- async function checkOutputDirGitIgnore(projectRoot) {
349
+ async function checkDestinationGitIgnore(projectRoot) {
335
350
  const results = [];
336
351
 
337
352
  try {
@@ -369,7 +384,7 @@ async function checkOutputDirGitIgnore(projectRoot) {
369
384
  const relevantLines = getRelevantGitignoreLines(gitignoreContent);
370
385
  const dirName = path.basename(normalizedPath);
371
386
 
372
- // Check output directory ignore patterns
387
+ // Check final destination directory ignore patterns
373
388
  const dirResults = checkOutputDirIgnorePatterns(
374
389
  projectRoot, normalizedPath, outputPath, dirName, relevantLines
375
390
  );
@@ -383,9 +398,9 @@ async function checkOutputDirGitIgnore(projectRoot) {
383
398
 
384
399
  return results;
385
400
  } catch (error) {
386
- console.error('Error checking output directory gitignore status:', error);
401
+ console.error('Error checking final destination directory gitignore status:', error);
387
402
  return [{
388
- name: 'Output directory gitignore check',
403
+ name: 'Final destination directory gitignore check',
389
404
  success: false,
390
405
  details: `Error: ${error.message}`
391
406
  }];
@@ -393,5 +408,5 @@ async function checkOutputDirGitIgnore(projectRoot) {
393
408
  }
394
409
 
395
410
  module.exports = {
396
- checkOutputDirGitIgnore
411
+ checkDestinationGitIgnore
397
412
  };