@hznrkv/sidebar 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +30 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -462,6 +462,17 @@ export default function Root() {
|
|
|
462
462
|
async function main() {
|
|
463
463
|
console.log("\n@hznrkv/sidebar — instalador\n")
|
|
464
464
|
|
|
465
|
+
// 0. Tema
|
|
466
|
+
const { theme } = await prompts({
|
|
467
|
+
type: "select",
|
|
468
|
+
name: "theme",
|
|
469
|
+
message: "Tema padrão:",
|
|
470
|
+
choices: [
|
|
471
|
+
{ title: "Dark", value: "dark" },
|
|
472
|
+
{ title: "Light", value: "light" },
|
|
473
|
+
],
|
|
474
|
+
})
|
|
475
|
+
|
|
465
476
|
// 1. Next.js
|
|
466
477
|
const pkg = readJson("package.json")
|
|
467
478
|
const hasNext = pkg?.dependencies?.next || pkg?.devDependencies?.next
|
|
@@ -604,23 +615,34 @@ async function main() {
|
|
|
604
615
|
}
|
|
605
616
|
}
|
|
606
617
|
|
|
607
|
-
//
|
|
618
|
+
// 8. Patch no root layout
|
|
608
619
|
const rootLayoutPath = path.join(cwd, "src/app/layout.tsx")
|
|
609
620
|
if (fs.existsSync(rootLayoutPath)) {
|
|
610
621
|
let rootLayout = fs.readFileSync(rootLayoutPath, "utf8")
|
|
622
|
+
|
|
623
|
+
// TooltipProvider
|
|
611
624
|
if (!rootLayout.includes("TooltipProvider")) {
|
|
612
625
|
rootLayout = rootLayout.replace(
|
|
613
626
|
/^(import .+from .+;\n)/m,
|
|
614
627
|
`$1import { TooltipProvider } from "@/components/ui/tooltip"\n`
|
|
615
628
|
)
|
|
616
|
-
rootLayout = rootLayout.replace(
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
629
|
+
rootLayout = rootLayout.replace(
|
|
630
|
+
/<body([^>]*)>\s*\{children\}\s*<\/body>/,
|
|
631
|
+
`<body$1><TooltipProvider>{children}</TooltipProvider></body>`
|
|
632
|
+
)
|
|
633
|
+
rootLayout = rootLayout.replace(
|
|
634
|
+
/<body([^>]*)>([\s\S]*?)<\/body>/,
|
|
635
|
+
(_, attrs, inner) => `<body${attrs}><TooltipProvider>${inner.trim()}</TooltipProvider></body>`
|
|
636
|
+
)
|
|
623
637
|
}
|
|
638
|
+
|
|
639
|
+
// Tema: remove dark existente e reaplica conforme escolha
|
|
640
|
+
rootLayout = rootLayout
|
|
641
|
+
.replace(/"h-full dark"/, '"h-full"')
|
|
642
|
+
.replace(/"h-full"/, theme === "dark" ? '"h-full dark"' : '"h-full"')
|
|
643
|
+
|
|
644
|
+
fs.writeFileSync(rootLayoutPath, rootLayout, "utf8")
|
|
645
|
+
console.log(` ✔ src/app/layout.tsx (TooltipProvider + tema ${theme})`)
|
|
624
646
|
}
|
|
625
647
|
|
|
626
648
|
console.log("\n✔ Sidebar instalada com sucesso!")
|