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

Commit 58d23e3

Browse files
committed
release beta-4
1 parent 7f6f78d commit 58d23e3

2 files changed

Lines changed: 33 additions & 28 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@intentui/cli",
33
"type": "module",
4-
"version": "2.9.8-beta-3",
4+
"version": "2.9.8-beta-4",
55
"description": "The command line interface for Intent UI.",
66
"main": "dist/index.js",
77
"bin": {

src/commands/add.command.ts

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
import { Args, Command, Options } from "@effect/cli"
2-
import { Console, Effect, Schema, pipe } from "effect"
3-
import { REGISTRY_URL } from "~/consts"
4-
52
import {
63
HttpClient,
74
HttpClientRequest,
85
HttpClientResponse,
96
Command as RawCommand,
107
} from "@effect/platform"
118
import chalk from "chalk"
9+
import { Console, Effect, Schema, pipe } from "effect"
10+
import { REGISTRY_URL } from "~/consts"
1211
import { Component } from "~/schema/component"
1312

1413
export const componentNames = Args.text({ name: "componentNames" }).pipe(Args.repeated)
1514

1615
export const isBlock = Options.boolean("b")
1716
export const isStyle = Options.boolean("s")
18-
1917
export const allComponents = Options.boolean("all").pipe(
2018
Options.withAlias("a"),
2119
Options.withDefault(false),
2220
)
23-
24-
export const overwrite = Options.boolean("overwrite").pipe(Options.withDefault(false))
25-
21+
export const overwrite = Options.boolean("overwrite").pipe(
22+
Options.withAlias("o"),
23+
Options.withDefault(false),
24+
)
2625
export const componentType = Options.choice("type", ["ui", "block", "style"]).pipe(
2726
Options.withAlias("t"),
2827
Options.withDefault("ui"),
@@ -35,43 +34,49 @@ export const addCommand = Command.make(
3534
Effect.gen(function* () {
3635
const type = isBlock ? "block" : isStyle ? "style" : componentType
3736

38-
const componentPaths = yield* pipe(
39-
Effect.forEach(componentNames, (name) =>
40-
Effect.succeed(
41-
name.startsWith("http")
42-
? name
43-
: name.startsWith("-")
44-
? null
45-
: `${REGISTRY_URL}/r/${type}-${name}.json`
46-
),
47-
),
48-
Effect.map((list) => list.filter((url): url is string => url !== null))
49-
)
50-
51-
if (!allComponents && componentPaths.length === 0) {
37+
if (!allComponents && componentNames.length === 0) {
5238
yield* Console.log(chalk.red("No components selected"))
5339
yield* Console.log(chalk.red("Please select a component or use --all"))
5440
return
5541
}
5642

5743
if (allComponents) {
5844
const client = yield* HttpClient.HttpClient.pipe()
59-
6045
const response = yield* HttpClientRequest.get("https://intentui.com/r/index.json").pipe(
6146
client.execute,
6247
Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Array(Component))),
6348
)
64-
6549
const components = response.map((c) => `${REGISTRY_URL}/r/${c.name}.json`)
66-
componentPaths.push(...components)
50+
const args = ["add"]
51+
if (overwrite) args.push("--overwrite")
52+
args.push(...components)
53+
return yield* pipe(
54+
RawCommand.make("shadcnClone", ...args).pipe(
55+
RawCommand.stdin("inherit"),
56+
RawCommand.stdout("inherit"),
57+
RawCommand.stderr("inherit"),
58+
RawCommand.exitCode,
59+
),
60+
)
6761
}
6862

69-
const args = ["add"]
63+
const manualOverwrite =
64+
overwrite || componentNames.includes("--overwrite") || componentNames.includes("-o")
65+
66+
const cleanedComponentNames = componentNames.filter(
67+
(name) => name !== "--overwrite" && name !== "-o",
68+
)
7069

71-
if (overwrite) {
70+
const componentPaths = yield* pipe(
71+
Effect.forEach(cleanedComponentNames, (name) =>
72+
Effect.succeed(name.startsWith("http") ? name : `${REGISTRY_URL}/r/${type}-${name}.json`),
73+
),
74+
)
75+
76+
const args = ["add"]
77+
if (manualOverwrite) {
7278
args.push("--overwrite")
7379
}
74-
7580
args.push(...componentPaths)
7681

7782
return yield* pipe(

0 commit comments

Comments
 (0)