Skip to content
This repository was archived by the owner on Sep 10, 2025. It is now read-only.

Commit b1fecd0

Browse files
committed
add required plugin to css
1 parent 981f2f4 commit b1fecd0

3 files changed

Lines changed: 64 additions & 22 deletions

File tree

bun.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
"@effect/cli": "^0.61.0",
5151
"@effect/platform": "^0.82.0",
5252
"@effect/platform-node": "^0.80.0",
53-
"chalk": "^5.4.1",
5453
"effect": "^3.15.0",
54+
"chalk": "^5.4.1",
5555
"figlet": "^1.8.1",
5656
"nanoid": "^5.1.5",
5757
"rc9": "^2.1.2",

src/commands/init.command.ts

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Command } from "@effect/cli"
22
import { Console, Effect } from "effect"
3+
import { Command as RawCommand, FileSystem } from "@effect/platform"
4+
import { NodeFileSystem } from "@effect/platform-node"
35

4-
import { FileSystem, Command as RawCommand } from "@effect/platform"
56
import { REGISTRY_URL } from "~/consts"
67

78
import { NodeCommandExecutor } from "@effect/platform-node"
8-
99
const shadcnInit = RawCommand.make("shadcnClone", "init", `${REGISTRY_URL}/r/default.json`).pipe(
1010
RawCommand.stdin("inherit"),
1111
RawCommand.stdout("inherit"),
@@ -16,13 +16,55 @@ export const initCommand = Command.make("init", {}, () =>
1616
Effect.gen(function* () {
1717
const fileSytem = yield* FileSystem.FileSystem
1818

19+
const componentsJsonPath = "components.json"
1920
const hasIntentUiConfig = yield* fileSytem.exists("intentui.json")
20-
const hasComponentJson = yield* fileSytem.exists("component.json")
21+
const hasComponentsJson = yield* fileSytem.exists(componentsJsonPath)
2122

22-
if (hasIntentUiConfig && !hasComponentJson) {
23+
if (hasIntentUiConfig && !hasComponentsJson) {
2324
yield* Console.log("Migrating to new config format...")
2425
}
2526

26-
const results = yield* RawCommand.exitCode(shadcnInit)
27-
}).pipe(Effect.scoped, Effect.provide(NodeCommandExecutor.layer)),
27+
yield* RawCommand.exitCode(shadcnInit)
28+
const exists = yield* fileSytem.exists(componentsJsonPath)
29+
30+
if (!exists) return
31+
32+
const jsonStr = yield* fileSytem.readFileString(componentsJsonPath)
33+
const json = yield* Effect.try(() => JSON.parse(jsonStr))
34+
35+
if (!json.tailwind?.css) return
36+
37+
const cssPath = json.tailwind.css
38+
const cssExists = yield* fileSytem.exists(cssPath)
39+
40+
if (!cssExists) return
41+
42+
const content = yield* fileSytem.readFileString(cssPath)
43+
44+
const lines = content.split("\n")
45+
46+
const alreadyHas = (line: string) => lines.some((l) => l.trim() === line)
47+
48+
const injectLines = [
49+
'@import "tw-animate-css";',
50+
'@plugin "tailwindcss-react-aria-components";',
51+
].filter((line) => !alreadyHas(line))
52+
53+
if (injectLines.length === 0) return
54+
55+
const tailwindIndex = lines.findIndex((l) => l.trim() === '@import "tailwindcss";')
56+
57+
if (tailwindIndex === -1) return
58+
59+
lines.splice(tailwindIndex + 1, 0, ...injectLines)
60+
61+
const patched = lines.join("\n")
62+
63+
yield* fileSytem.writeFileString(cssPath, patched)
64+
65+
}).pipe(
66+
Effect.scoped,
67+
Effect.provide(NodeCommandExecutor.layer),
68+
Effect.provide(NodeFileSystem.layer),
69+
),
2870
).pipe(Command.withDescription("Initializes the project and sets up necessary configurations."))

0 commit comments

Comments
 (0)