UNPKG

flowbite-react

Version:

Official React components built for Flowbite and Tailwind CSS

1 lines 2.29 kB
{"version":3,"file":"setup-register.cjs","sources":["../../../src/cli/commands/setup-register.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport cjson from \"comment-json\";\nimport { packageJsonFile } from \"../consts\";\nimport { getPackageJson } from \"../utils/get-package-json\";\n\n/**\n * Sets up the register script in the project's package.json file.\n *\n * This function checks if the postinstall script already exists in the package.json file.\n * If it does not exist, it adds the register command to the postinstall script.\n * If it does exist, it appends the register command to the existing postinstall script.\n */\nexport async function setupRegister() {\n try {\n const registerCommand = \"flowbite-react register\";\n const packageJson = await getPackageJson();\n\n if (!packageJson.scripts) {\n packageJson.scripts = {};\n }\n\n if (!packageJson.scripts.postinstall?.includes(registerCommand)) {\n console.log(`Adding postinstall register script to ${packageJsonFile}...`);\n if (packageJson.scripts.postinstall) {\n packageJson.scripts.postinstall += ` && ${registerCommand}`;\n } else {\n packageJson.scripts.postinstall = registerCommand;\n }\n await fs.writeFile(packageJsonFile, cjson.stringify(packageJson, null, 2));\n }\n } catch (error) {\n console.error(`Failed to setup ${packageJsonFile}:`, error);\n }\n}\n"],"names":["getPackageJson","packageJsonFile"],"mappings":";;;;;;;AAKO,eAAe,aAAa,GAAG;AACtC,EAAE,IAAI;AACN,IAAI,MAAM,eAAe,GAAG,yBAAyB;AACrD,IAAI,MAAM,WAAW,GAAG,MAAMA,6BAAc,EAAE;AAC9C,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE;AAC9B,MAAM,WAAW,CAAC,OAAO,GAAG,EAAE;AAC9B,IAAI;AACJ,IAAI,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,QAAQ,CAAC,eAAe,CAAC,EAAE;AACrE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,sCAAsC,EAAEC,sBAAe,CAAC,GAAG,CAAC,CAAC;AAChF,MAAM,IAAI,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE;AAC3C,QAAQ,WAAW,CAAC,OAAO,CAAC,WAAW,IAAI,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM;AACb,QAAQ,WAAW,CAAC,OAAO,CAAC,WAAW,GAAG,eAAe;AACzD,MAAM;AACN,MAAM,MAAM,EAAE,CAAC,SAAS,CAACA,sBAAe,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAChF,IAAI;AACJ,EAAE,CAAC,CAAC,OAAO,KAAK,EAAE;AAClB,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,gBAAgB,EAAEA,sBAAe,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;AAC/D,EAAE;AACF;;;;"}