UNPKG

flowbite-react

Version:

Official React components built for Flowbite and Tailwind CSS

1 lines 3.43 kB
{"version":3,"file":"setup-plugin-bun.cjs","sources":["../../../../src/cli/commands/plugins/setup-plugin-bun.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport toml from \"@iarna/toml\";\nimport { pluginName, pluginPath } from \"../../consts\";\nimport { joinNormalizedPath } from \"../../utils/normalize-path\";\nimport { updateBuildConfig } from \"../../utils/update-build-config\";\n\nexport async function setupPluginBun(configPath: string) {\n try {\n // update bunfig.toml\n const bunfig = await fs.readFile(configPath, \"utf-8\");\n const bunfigContent = toml.parse(bunfig) as { serve?: { static?: { plugins?: string[] } } };\n const bunPluginPath = joinNormalizedPath(pluginPath, \"bun\");\n\n if (bunfigContent.serve?.static?.plugins?.includes(pluginName)) {\n return;\n }\n\n bunfigContent.serve ??= {};\n bunfigContent.serve.static ??= {};\n bunfigContent.serve.static.plugins ??= [];\n\n if (!bunfigContent.serve.static.plugins.includes(bunPluginPath)) {\n bunfigContent.serve.static.plugins.push(bunPluginPath);\n\n console.log(`Updating ${configPath} with flowbite-react configuration...`);\n await fs.writeFile(configPath, toml.stringify(bunfigContent), \"utf-8\");\n }\n\n // update build.ts\n const buildConfigPath = \"build.ts\";\n const buildConfig = await fs.readFile(buildConfigPath, \"utf-8\");\n const updatedBuildConfig = updateBuildConfig({\n content: buildConfig,\n pluginName,\n pluginImportPath: bunPluginPath,\n });\n\n if (buildConfig !== updatedBuildConfig) {\n console.log(`Updating ${buildConfigPath} with flowbite-react configuration...`);\n await fs.writeFile(buildConfigPath, updatedBuildConfig, \"utf-8\");\n }\n } catch (error) {\n console.error(`Failed to update ${configPath} file...`, error);\n }\n}\n"],"names":["joinNormalizedPath","pluginPath","pluginName","updateBuildConfig"],"mappings":";;;;;;;;AAMO,eAAe,cAAc,CAAC,UAAU,EAAE;AACjD,EAAE,IAAI,EAAE,EAAE,EAAE;AACZ,EAAE,IAAI;AACN,IAAI,MAAM,MAAM,GAAG,MAAM,E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