Skip to content

Commit a780d67

Browse files
committed
feat: not require shadcn cli installed
1 parent 5e94185 commit a780d67

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"description": "The command line interface for Intent UI.",
66
"main": "dist/index.js",
77
"bin": {
8-
"intentui": "src/index.ts"
8+
"intentui": "src/index.ts",
9+
"shadcnClone": "dist/shadcn/index.js"
910
},
10-
"files": ["dist", "src/resources", "LICENSE", "README.md", "package.json"],
11+
"files": ["dist", "LICENSE", "README.md", "package.json"],
1112
"repository": {
1213
"type": "git",
1314
"url": "git+https://github.com/intentuilabs/cli.git"
@@ -17,7 +18,7 @@
1718
"dev": "bun build ./src/index.ts --outdir ./dist --target=node --minify --watch",
1819
"start": "bun ./src/index.ts",
1920
"prepare": "npx husky",
20-
"build": "bun build ./src/index.ts --outdir ./dist --target=node --minify",
21+
"build": "bun build ./src/index.ts --outdir ./dist --target=node --minify && cp -r ./node_modules/shadcn/dist/ ./dist/shadcn",
2122
"format": "biome lint --fix && biome check --write",
2223
"test": "bun run build && bun link",
2324
"preview": "bun run build && bun link",

src/commands/add.command.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { Args, Command, Options } from "@effect/cli"
2-
import { Effect } from "effect"
2+
import { Effect, pipe } from "effect"
33
import { REGISTRY_URL } from "~/consts"
44

55
import { Command as RawCommand } from "@effect/platform"
66

77
export const componentNames = Args.text({ name: "componentNames" }).pipe(Args.repeated)
8+
89
export const isBlock = Options.boolean("b")
910
export const isStyle = Options.boolean("s")
11+
1012
export const componentType = Options.choice("type", ["ui", "block", "style"]).pipe(
1113
Options.withAlias("t"),
1214
Options.withDefault("ui"),
@@ -16,15 +18,16 @@ export const addCommand = Command.make(
1618
"add",
1719
{ componentNames, isBlock, isStyle, componentType },
1820
({ componentNames, isBlock, isStyle, componentType }) =>
19-
Effect.gen(function* ($) {
21+
Effect.gen(function* () {
2022
const type = isBlock ? "block" : isStyle ? "style" : componentType
21-
const componentPaths = yield* $(
23+
24+
const componentPaths = yield* pipe(
2225
Effect.forEach(componentNames, (name) =>
2326
Effect.succeed(`${REGISTRY_URL}/r/${type}-${name}.json`),
2427
),
2528
)
26-
return yield* $(
27-
RawCommand.make("bunx", "shadcn", "add", ...componentPaths).pipe(
29+
return yield* pipe(
30+
RawCommand.make("shadcnClone", "add", ...componentPaths).pipe(
2831
RawCommand.stdin("inherit"),
2932
RawCommand.stdout("inherit"),
3033
RawCommand.stderr("inherit"),

src/commands/init.command.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { REGISTRY_URL } from "~/consts"
66

77
import { BunCommandExecutor } from "@effect/platform-bun"
88

9-
const shadcnInit = RawCommand.make("bunx", "shadcn", "init", `${REGISTRY_URL}/r/default.json`).pipe(
9+
const shadcnInit = RawCommand.make("shadcnClone", "init", `${REGISTRY_URL}/r/default.json`).pipe(
1010
RawCommand.stdin("inherit"),
1111
RawCommand.stdout("inherit"),
1212
RawCommand.stderr("inherit"),
@@ -15,16 +15,5 @@ const shadcnInit = RawCommand.make("bunx", "shadcn", "init", `${REGISTRY_URL}/r/
1515
export const initCommand = Command.make("init", {}, () =>
1616
Effect.gen(function* () {
1717
const results = yield* RawCommand.exitCode(shadcnInit)
18-
// const test = yield* Effect.tryPromise(
19-
// async () =>
20-
// await execa(
21-
// "bunx",
22-
// ["shadcn", "init", `${REGISTRY_URL}/r/default.json`],
23-
// {
24-
// stdio: "inherit",
25-
// reject: false,
26-
// },
27-
// ),
28-
// );
2918
}).pipe(Effect.scoped, Effect.provide(BunCommandExecutor.layer)),
3019
).pipe(Command.withDescription("Initializes the project and sets up necessary configurations."))

src/commands/theme.command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const themeCommand = Command.make("theme", { theme }, (config) =>
1010
Effect.gen(function* () {
1111
const themePath = `${REGISTRY_URL}/r/style/${config.theme}`
1212

13-
const exitCode = yield* RawCommand.make("bunx", "shadcn", "add", themePath).pipe(
13+
const exitCode = yield* RawCommand.make("shadcnClone", "add", themePath).pipe(
1414
RawCommand.stdin("inherit"),
1515
RawCommand.stdout("inherit"),
1616
RawCommand.stderr("inherit"),

0 commit comments

Comments
 (0)