UNPKG

flowbite-react

Version:

Official React components built for Flowbite and Tailwind CSS

1 lines 2.69 kB
{"version":3,"file":"generate-class-list.cjs","sources":["../../../src/cli/commands/generate-class-list.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport { allowedExtensions, classListFilePath, excludeDirs } from \"../consts\";\nimport { buildClassList } from \"../utils/build-class-list\";\nimport { extractComponentImports } from \"../utils/extract-component-imports\";\nimport { findFiles } from \"../utils/find-files\";\nimport { getConfig } from \"../utils/get-config\";\n\nexport async function generateClassList() {\n try {\n const config = await getConfig();\n\n if (!config.components.length) {\n const files = await findFiles({\n patterns: allowedExtensions.map((ext) => `**/*${ext}`),\n excludeDirs,\n });\n const importedComponents = new Set<string>();\n\n for (const file of files) {\n const content = await fs.readFile(file, \"utf-8\");\n\n for (const component of extractComponentImports(content)) {\n importedComponents.add(component);\n }\n }\n\n if (importedComponents.size > 0) {\n config.components = [...importedComponents];\n }\n }\n\n const classList = buildClassList(config);\n\n console.log(`Generating ${classListFilePath} file...`);\n await fs.writeFile(classListFilePath, JSON.stringify(classList, null, 2), { flag: \"w\" });\n } catch (error) {\n console.error(`Failed to generate ${classListFilePath}:`, error);\n }\n}\n"],"names":["getConfig","findFiles","allowedExtensions","excludeDirs","extractComponentImports","buildClassList","classListFilePath"],"mappings":";;;;;;;;;AAOO,eAAe,iBAAiB,GAAG;AAC1C,EAAE,IAAI;AACN,IAAI,MAAM,MAAM,GAAG,MAAMA,mBAAS,EAAE;AACpC,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE;AACnC,MAAM,MAAM,KAAK,GAAG,MAAMC,mBAAS,CAAC;AACpC,QAAQ,QAAQ,EAAEC,wBAAiB,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC;AAC9D,qBAAQC;AACR,OAAO,CAAC;AACR,MAAM,MAAM,kBAAkB,mBAAmB,IAAI,GAAG,EAAE;AAC1D,MAAM,KAAK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