UNPKG

flowbite-react

Version:

Official React components built for Flowbite and Tailwind CSS

1 lines 1.46 kB
{"version":3,"file":"get-tailwind-version.cjs","sources":["../../../src/cli/utils/get-tailwind-version.ts"],"sourcesContent":["import { getModulePackageJson } from \"./get-module-package-json\";\n\n/**\n * Gets the version of Tailwind CSS used in the project.\n *\n * This function attempts to read the version from the `tailwindcss/package.json` file.\n *\n * @throws {Error} If the detected Tailwind CSS major version is not 3 or 4\n * @returns {Promise<3 | 4>} `3` if the version is 3.x, `4` if the version is 4.x\n */\nexport async function getTailwindVersion(): Promise<3 | 4> {\n const tailwindcssPackageJson = await getModulePackageJson(\"tailwindcss\");\n\n if (!tailwindcssPackageJson) {\n throw new Error(\"Tailwind CSS is not installed\");\n }\n\n const major = parseInt(tailwindcssPackageJson.version.split(\".\")[0], 10);\n if (major === 3 || major === 4) {\n return major;\n }\n\n throw new Error(`Unsupported Tailwind CSS major version: ${major}`);\n}\n"],"names":["getModulePackageJson"],"mappings":";;;;AAEO,eAAe,kBAAkB,GAAG;AAC3C,EAAE,MAAM,sBAAsB,GAAG,MAAMA,yCAAoB,CAAC,aAAa,CAAC;AAC1E,EAAE,IAAI,CAAC,sBAAsB,EAAE;AAC/B,IAAI,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC;AACpD;AACA,EAAE,MAAM,KAAK,GAAG,QAAQ,CAAC,sBAAsB,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC1E,EAAE,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE;AAClC,IAAI,OAAO,KAAK;AAChB;AACA,EAAE,MAAM,IAAI,KAAK,CAAC,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC,CAAC;AACrE;;;;"}