Skip to content

Commit 5452956

Browse files
authored
Merge branch 'main' into friday-demos
2 parents 86d782f + 5d03256 commit 5452956

2 files changed

Lines changed: 50 additions & 81 deletions

File tree

scripts/check-image-locations.js

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,8 @@ async function main() {
224224
!excludedPaths.some(excluded => file.includes(excluded))
225225
);
226226

227-
console.log(`📄 Found ${filteredFiles.length} documentation files\n`);
228-
229227
// First pass: identify shared images
230-
console.log('🔍 Identifying shared images...\n');
231228
const { sharedImages, imageUsageMap } = buildSharedImagesMap(filteredFiles);
232-
console.log(`📊 Found ${sharedImages.size} images used by multiple pages\n`);
233229

234230
const allIssues = [];
235231
let totalImages = 0;
@@ -276,62 +272,51 @@ async function main() {
276272
}
277273
}
278274

279-
// Display results
275+
// Display summary header first
280276
if (allIssues.length === 0) {
281-
console.log('✅ All images are in the correct locations!\n');
277+
console.log('✅ No image issues found!\n');
282278
} else {
283-
console.log(`❌ Found ${allIssues.length} image issues:\n`);
279+
console.log(`❌ Found ${allIssues.length} image issue(s):\n`);
280+
console.log(` • ${missingImages} missing image(s)`);
281+
console.log(` • ${misplacedImages} misplaced image(s)`);
282+
console.log(` • ${invalidTypes} invalid file type(s)\n`);
284283

285284
// Group by issue type
286285
const missingIssues = allIssues.filter(i => i.type === 'missing');
287286
const locationIssues = allIssues.filter(i => i.type === 'wrong-location');
288287
const typeIssues = allIssues.filter(i => i.type === 'invalid-type');
289288

290289
if (missingIssues.length > 0) {
291-
console.log(`📁 Missing Images (${missingIssues.length}):\n`);
292-
missingIssues.forEach(({ file, line, imagePath, message }) => {
290+
console.log('─'.repeat(40));
291+
console.log('MISSING IMAGES:\n');
292+
missingIssues.forEach(({ file, line, imagePath }) => {
293293
console.log(` 📄 ${file}:${line}`);
294-
console.log(` 🔗 ${imagePath}`);
295-
console.log(` ❌ ${message}\n`);
294+
console.log(` ${imagePath}\n`);
296295
});
297296
}
298297

299298
if (locationIssues.length > 0) {
300-
console.log(`📍 Misplaced Images (${locationIssues.length}):\n`);
301-
locationIssues.forEach(({ file, line, imagePath, expectedDir, actualDir, suggestion }) => {
299+
console.log('─'.repeat(40));
300+
console.log('MISPLACED IMAGES:\n');
301+
locationIssues.forEach(({ file, line, imagePath, expectedDir, actualDir }) => {
302302
console.log(` 📄 ${file}:${line}`);
303-
console.log(` 🔗 ${imagePath}`);
304-
console.log(` ❌ Expected in: ${expectedDir}/`);
305-
console.log(` 📍 Actually in: ${actualDir}/`);
306-
console.log(` 💡 ${suggestion}\n`);
303+
console.log(` ${imagePath}`);
304+
console.log(` Expected: ${expectedDir}/`);
305+
console.log(` Actual: ${actualDir}/\n`);
307306
});
308307
}
309308

310309
if (typeIssues.length > 0) {
311-
console.log(`⚠️ Invalid File Types (${typeIssues.length}):\n`);
310+
console.log('─'.repeat(40));
311+
console.log('INVALID FILE TYPES:\n');
312312
typeIssues.forEach(({ file, line, imagePath, message }) => {
313313
console.log(` 📄 ${file}:${line}`);
314-
console.log(` 🔗 ${imagePath}`);
315-
console.log(` ${message}\n`);
314+
console.log(` ${imagePath}`);
315+
console.log(` ${message}\n`);
316316
});
317317
}
318318
}
319319

320-
// Summary
321-
console.log('─'.repeat(60));
322-
console.log(`Total images checked: ${totalImages}`);
323-
console.log(`Shared images (used by 2+ files): ${sharedImagesCount}`);
324-
console.log(`Missing images: ${missingImages}`);
325-
console.log(`Misplaced images: ${misplacedImages}`);
326-
console.log(`Invalid file types: ${invalidTypes}`);
327-
console.log('─'.repeat(60));
328-
329-
console.log('\n💡 Image Placement Rules:');
330-
console.log(' • Images should mirror page structure');
331-
console.log(' • guides/dashboard.mdx → images/guides/dashboard/');
332-
console.log(' • Shared images (used by multiple pages) are automatically allowed');
333-
console.log(' • See CONTRIBUTING.md for full guidelines\n');
334-
335320
// Exit with error if issues found
336321
process.exit(allIssues.length > 0 ? 1 : 0);
337322
}

scripts/check-links.js

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,6 @@ async function main() {
286286
!excludedPaths.some(excluded => file.includes(excluded))
287287
);
288288

289-
console.log(`📄 Found ${filteredFiles.length} documentation files\n`);
290-
291289
const brokenLinks = [];
292290
const externalLinks = [];
293291
let totalLinks = 0;
@@ -325,56 +323,54 @@ async function main() {
325323
}
326324

327325
// Check for orphaned pages
328-
console.log('🔍 Checking for orphaned pages (not in docs.json)...\n');
329326
const docsJson = loadDocsJson();
330327
const orphanedPages = findOrphanedPages(filteredFiles, docsJson);
331328

332329
// Check redirects
333-
console.log('🔍 Checking redirects in docs.json...\n');
334330
const redirects = extractRedirects(docsJson);
335331
const redirectIssues = validateRedirects(redirects);
336332

337-
// Display results
338-
if (brokenLinks.length === 0) {
339-
console.log('✅ No broken internal links found!\n');
333+
// Calculate total issues for summary header
334+
const totalIssues = brokenLinks.length + orphanedPages.length + redirectIssues.length;
335+
336+
// Print summary header first
337+
if (totalIssues === 0) {
338+
console.log('✅ No issues found!\n');
340339
} else {
341-
console.log(`❌ Found ${brokenLinks.length} broken internal links:\n`);
342-
343-
brokenLinks.forEach(({ file, url, line, type, triedPaths }) => {
344-
console.log(`📄 ${file}:${line}`);
345-
console.log(` 🔗 Broken link: ${url}`);
346-
console.log(` 📍 Type: ${type}`);
347-
if (triedPaths) {
348-
console.log(` 🔍 Tried paths:`);
349-
triedPaths.slice(0, 2).forEach(p => {
350-
console.log(` - ${path.relative(process.cwd(), p)}`);
351-
});
352-
}
353-
console.log('');
340+
console.log(`❌ Found ${totalIssues} issue(s):\n`);
341+
console.log(` • ${brokenLinks.length} broken link(s)`);
342+
console.log(` • ${orphanedPages.length} orphaned page(s)`);
343+
console.log(`${redirectIssues.length} invalid redirect(s)\n`);
344+
}
345+
346+
// Display broken links details
347+
if (brokenLinks.length > 0) {
348+
console.log('─'.repeat(40));
349+
console.log('BROKEN LINKS:\n');
350+
brokenLinks.forEach(({ file, url, line }) => {
351+
console.log(` 📄 ${file}:${line}`);
352+
console.log(` ${url}\n`);
354353
});
355354
}
356355

357-
// Display orphaned pages
358-
if (orphanedPages.length === 0) {
359-
console.log('✅ No orphaned pages found!\n');
360-
} else {
361-
console.log(`⚠️ Found ${orphanedPages.length} orphaned pages (exist but not in docs.json):\n`);
356+
// Display orphaned pages details
357+
if (orphanedPages.length > 0) {
358+
console.log('─'.repeat(40));
359+
console.log('ORPHANED PAGES (not in docs.json):\n');
362360
orphanedPages.forEach(page => {
363361
console.log(` 📄 ${page}.mdx`);
364362
});
365-
console.log('\n💡 These pages exist but are not linked in docs.json navigation.\n');
363+
console.log('');
366364
}
367365

368-
// Display redirect issues
369-
if (redirectIssues.length === 0) {
370-
console.log('✅ All redirects are valid!\n');
371-
} else {
372-
console.log(`❌ Found ${redirectIssues.length} invalid redirects in docs.json:\n`);
366+
// Display redirect issues details
367+
if (redirectIssues.length > 0) {
368+
console.log('─'.repeat(40));
369+
console.log('INVALID REDIRECTS:\n');
373370
redirectIssues.forEach(({ source, destination, issue }) => {
374371
console.log(` 🔀 ${source}${destination}`);
375-
console.log(` ${issue}\n`);
372+
console.log(` ${issue}\n`);
376373
});
377-
console.log('💡 When moving pages, ensure redirect destinations exist.\n');
378374
}
379375

380376
// Check external links if requested
@@ -402,20 +398,8 @@ async function main() {
402398
}
403399
}
404400

405-
// Summary
406-
console.log('─'.repeat(60));
407-
console.log(`Total links checked: ${totalLinks}`);
408-
console.log(`Broken internal links: ${brokenLinks.length}`);
409-
console.log(`Orphaned pages: ${orphanedPages.length}`);
410-
console.log(`Invalid redirects: ${redirectIssues.length}`);
411-
if (CHECK_EXTERNAL) {
412-
console.log(`External links checked: ${externalLinks.length}`);
413-
}
414-
console.log('─'.repeat(60));
415-
416401
// Exit with error if issues found
417-
const hasIssues = brokenLinks.length > 0 || orphanedPages.length > 0 || redirectIssues.length > 0;
418-
process.exit(hasIssues ? 1 : 0);
402+
process.exit(totalIssues > 0 ? 1 : 0);
419403
}
420404

421405
main();

0 commit comments

Comments
 (0)