@soulbatical/tetra-dev-toolkit 1.21.0 → 1.21.1
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/lib/audits/doctor-audit.js +103 -2
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
import { readFileSync, writeFileSync, existsSync } from 'fs'
|
|
14
|
-
import { join } from 'path'
|
|
14
|
+
import { join, resolve, dirname } from 'path'
|
|
15
15
|
import { execSync } from 'child_process'
|
|
16
16
|
import { glob } from 'glob'
|
|
17
17
|
|
|
@@ -419,7 +419,107 @@ function checkDarkMode(files) {
|
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
/**
|
|
422
|
-
*
|
|
422
|
+
* CRITICAL 7: All @source directives in globals.css must resolve to existing paths,
|
|
423
|
+
* and at least one must point to @soulbatical/tetra-ui/dist so Tailwind v4 generates
|
|
424
|
+
* AppShell layout utility classes (ml-64, ml-16, etc.).
|
|
425
|
+
*
|
|
426
|
+
* Root cause this prevents: a path with one too few `../` segments silently scans
|
|
427
|
+
* nothing, causing AppShell margins to never be generated and pages to render
|
|
428
|
+
* underneath the fixed sidebar.
|
|
429
|
+
*/
|
|
430
|
+
function checkTetraUiSourcePath(files, projectRoot) {
|
|
431
|
+
if (!files.globalsCss) {
|
|
432
|
+
return {
|
|
433
|
+
id: 'tetraUiSourcePath',
|
|
434
|
+
severity: 'critical',
|
|
435
|
+
label: 'tetra-ui @source path',
|
|
436
|
+
pass: false,
|
|
437
|
+
detail: 'globals.css not found',
|
|
438
|
+
fixable: false,
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
const globalsCssFullPath = join(projectRoot, files.globalsCss.path)
|
|
443
|
+
const globalsCssDir = dirname(globalsCssFullPath)
|
|
444
|
+
const content = files.globalsCss.content
|
|
445
|
+
|
|
446
|
+
// Collect all @source directives
|
|
447
|
+
const sourceRegex = /@source\s+["']([^"']+)["']/g
|
|
448
|
+
const sourcePaths = []
|
|
449
|
+
let match
|
|
450
|
+
while ((match = sourceRegex.exec(content)) !== null) {
|
|
451
|
+
sourcePaths.push(match[1])
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
if (sourcePaths.length === 0) {
|
|
455
|
+
// No @source directives — skip to avoid false positives on minimal setups
|
|
456
|
+
return {
|
|
457
|
+
id: 'tetraUiSourcePath',
|
|
458
|
+
severity: 'critical',
|
|
459
|
+
label: 'tetra-ui @source path',
|
|
460
|
+
pass: true,
|
|
461
|
+
detail: `no @source directives in ${files.globalsCss.path} (skipped)`,
|
|
462
|
+
fixable: false,
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Check every @source path resolves to an existing directory/file
|
|
467
|
+
const broken = []
|
|
468
|
+
for (const sourcePath of sourcePaths) {
|
|
469
|
+
const resolvedPath = resolve(globalsCssDir, sourcePath)
|
|
470
|
+
if (!existsSync(resolvedPath)) {
|
|
471
|
+
broken.push({ raw: sourcePath, resolved: resolvedPath })
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
if (broken.length > 0) {
|
|
476
|
+
const first = broken[0]
|
|
477
|
+
const extra = broken.length > 1 ? ` (and ${broken.length - 1} more)` : ''
|
|
478
|
+
return {
|
|
479
|
+
id: 'tetraUiSourcePath',
|
|
480
|
+
severity: 'critical',
|
|
481
|
+
label: 'tetra-ui @source path',
|
|
482
|
+
pass: false,
|
|
483
|
+
detail: `@source "${first.raw}" resolves to non-existent path: ${first.resolved}${extra}` +
|
|
484
|
+
` — fix: @source "../../../node_modules/@soulbatical/tetra-ui/dist"` +
|
|
485
|
+
` (adjust depth to reach node_modules from ${files.globalsCss.path})`,
|
|
486
|
+
fixable: false,
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Check at least one @source entry covers tetra-ui/dist so AppShell
|
|
491
|
+
// margin classes (ml-64, ml-16, etc.) are generated by Tailwind v4
|
|
492
|
+
const tetraUiDistPaths = sourcePaths.filter(sourcePath => {
|
|
493
|
+
const resolvedPath = resolve(globalsCssDir, sourcePath)
|
|
494
|
+
return resolvedPath.includes('@soulbatical/tetra-ui') && resolvedPath.includes('dist')
|
|
495
|
+
})
|
|
496
|
+
|
|
497
|
+
if (tetraUiDistPaths.length === 0) {
|
|
498
|
+
return {
|
|
499
|
+
id: 'tetraUiSourcePath',
|
|
500
|
+
severity: 'critical',
|
|
501
|
+
label: 'tetra-ui @source path',
|
|
502
|
+
pass: false,
|
|
503
|
+
detail: `no @source entry pointing to @soulbatical/tetra-ui/dist found in ${files.globalsCss.path}` +
|
|
504
|
+
` — AppShell layout classes (ml-64, ml-16, etc.) will not be generated by Tailwind v4.` +
|
|
505
|
+
` Add: @source "../../../node_modules/@soulbatical/tetra-ui/dist"` +
|
|
506
|
+
` (adjust relative depth as needed)`,
|
|
507
|
+
fixable: false,
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
return {
|
|
512
|
+
id: 'tetraUiSourcePath',
|
|
513
|
+
severity: 'critical',
|
|
514
|
+
label: 'tetra-ui @source path',
|
|
515
|
+
pass: true,
|
|
516
|
+
detail: `@source "${tetraUiDistPaths[0]}" exists in ${files.globalsCss.path}`,
|
|
517
|
+
fixable: false,
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* HIGH 8: tetra-core version should be recent.
|
|
423
523
|
*/
|
|
424
524
|
function checkTetraCoreVersion(files) {
|
|
425
525
|
const pkgContent = files.backendPackageJson?.content
|
|
@@ -771,6 +871,7 @@ export async function runDoctorAudit(projectRoot) {
|
|
|
771
871
|
checkNextThemes(projectRoot),
|
|
772
872
|
checkCssTokens(files),
|
|
773
873
|
checkDarkMode(files),
|
|
874
|
+
checkTetraUiSourcePath(files, projectRoot),
|
|
774
875
|
// HIGH
|
|
775
876
|
checkTetraCoreVersion(files),
|
|
776
877
|
appShellCheck,
|