|
|
|
|
@ -9,24 +9,12 @@ import { toggleMorfo } from '../morfo/components/toggle'
|
|
|
|
|
import { lintEidosCss } from './lint'
|
|
|
|
|
|
|
|
|
|
function readEidos(name: string): string {
|
|
|
|
|
// Components migrated to subfolder layout (e.g. toggle/) live at
|
|
|
|
|
// `components/{name}/{name}.css`; older flat layout still uses
|
|
|
|
|
// `components/{name}.css`. Try the subfolder first, fall back to flat.
|
|
|
|
|
const subfolderPath = resolve(`src/uix/eidos/components/${name}/${name}.css`)
|
|
|
|
|
const flatPath = resolve(`src/uix/eidos/components/${name}.css`)
|
|
|
|
|
try {
|
|
|
|
|
return readFileSync(subfolderPath, 'utf-8')
|
|
|
|
|
} catch {
|
|
|
|
|
return readFileSync(flatPath, 'utf-8')
|
|
|
|
|
}
|
|
|
|
|
return readFileSync(resolve(`src/uix/eidos/components/${name}/${name}.css`), 'utf-8')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function listEidosCssComponents(): string[] {
|
|
|
|
|
const eidosDir = resolve('src/uix/eidos/components')
|
|
|
|
|
return readdirSync(eidosDir, { withFileTypes: true }).flatMap((entry) => {
|
|
|
|
|
if (entry.isFile() && entry.name.endsWith('.css')) {
|
|
|
|
|
return [entry.name.replace(/\.css$/, '')]
|
|
|
|
|
}
|
|
|
|
|
if (!entry.isDirectory()) return []
|
|
|
|
|
|
|
|
|
|
const cssPath = resolve(eidosDir, entry.name, `${entry.name}.css`)
|
|
|
|
|
@ -34,7 +22,19 @@ function listEidosCssComponents(): string[] {
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function listRootCssFiles(): string[] {
|
|
|
|
|
const eidosDir = resolve('src/uix/eidos/components')
|
|
|
|
|
return readdirSync(eidosDir, { withFileTypes: true })
|
|
|
|
|
.filter((entry) => entry.isFile() && entry.name.endsWith('.css'))
|
|
|
|
|
.map((entry) => entry.name)
|
|
|
|
|
.sort()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('eidos component contract coverage', () => {
|
|
|
|
|
it('keeps component CSS inside component subdirectories', () => {
|
|
|
|
|
expect(listRootCssFiles()).toEqual([])
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('has a morfo file for every eidos CSS component', () => {
|
|
|
|
|
const missing = listEidosCssComponents().filter(
|
|
|
|
|
(name) => !existsSync(resolve(`src/uix/morfo/components/${name}.ts`))
|
|
|
|
|
|