Skip to content

The fresh new CLI. #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,293 changes: 1,293 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

Binary file removed bun.lockb
Binary file not shown.
62 changes: 22 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@
"description": "The command line interface for Intent UI.",
"main": "dist/index.js",
"bin": {
"intentui": "dist/index.js"
"intentuii": "src/index.ts",
"intentui": "dist/index.js",
"shadcnClone": "dist/shadcn/index.js"
},
"files": [
"dist",
"src/resources",
"LICENSE",
"README.md",
"package.json"
],
"files": ["dist", "LICENSE", "README.md", "package.json"],
"repository": {
"type": "git",
"url": "git+https://github.com/intentuilabs/cli.git"
Expand All @@ -23,55 +19,41 @@
"dev": "bun build ./src/index.ts --outdir ./dist --target=node --minify --watch",
"start": "bun ./src/index.ts",
"prepare": "npx husky",
"build": "bun build ./src/index.ts --outdir ./dist --target=node --minify",
"build": "bun build ./src/index.ts --outdir ./dist --target=node --minify && cp -r ./node_modules/shadcn/dist/ ./dist/shadcn",
"format": "biome lint --fix && biome check --write",
"test": "bun run build && bun link",
"preview": "bun run clean && bun run build && bun link",
"test": "bun run build && bun link @intentui/cli && bun run dev",
"preview": "bun run build && bun link",
"pr": "bun run build && git commit -a",
"pre": "chmod a+x dist/index.js",
"release": "export GITHUB_TOKEN=$(cat .github_token) && release-it",
"typecheck": "tsc --noEmit"
},
"keywords": [
"cli",
"intentui cli",
"Intent UI",
"design-system"
],
"keywords": ["cli", "intentui cli", "Intent UI", "design-system"],
"author": "Irsyad A. Panjaitan",
"license": "MIT",
"devDependencies": {
"@biomejs/biome": "^1.9.4",
"@changesets/cli": "^2.27.11",
"@commitlint/cli": "^19.6.1",
"@commitlint/config-conventional": "^19.6.0",
"@release-it/conventional-changelog": "^10.0.0",
"@types/babel__core": "^7.20.5",
"@types/diff": "^7.0.0",
"@changesets/cli": "^2.29.3",
"@commitlint/cli": "^19.8.1",
"@commitlint/config-conventional": "^19.8.1",
"@release-it/conventional-changelog": "^10.0.1",
"@types/bun": "latest",
"@types/figlet": "^1.7.0",
"@types/fs-extra": "^11.0.4",
"@types/inquirer": "^9.0.7",
"@types/node": "^22.10.7",
"husky": "^9.1.7",
"release-it": "^18.1.1",
"release-it": "^19.0.2",
"rimraf": "^6.0.1",
"typescript": "^5.7.3"
"typescript": "^5.8.3"
},
"dependencies": {
"@antfu/ni": "^23.2.0",
"@inquirer/prompts": "^7.2.3",
"arktype": "^2.0.0",
"async-listen": "^3.0.1",
"@effect/cli": "^0.60.1",
"@effect/platform": "^0.81.1",
"@effect/platform-node": "^0.78.1",
"chalk": "^5.4.1",
"commander": "^13.0.0",
"diff": "^7.0.0",
"nanoid": "^5.0.9",
"open": "^10.1.0",
"ora": "^8.1.1",
"effect": "^3.14.22",
"figlet": "^1.8.1",
"nanoid": "^5.1.5",
"rc9": "^2.1.2",
"strip-json-comments": "^5.0.1",
"sucrase": "^3.35.0",
"ts-morph": "^25.0.0"
"shadcn": "^2.5.0"
},
"release-it": {
"git": {
Expand Down
77 changes: 77 additions & 0 deletions src/commands/add.command.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { Args, Command, Options } from "@effect/cli"
import { Console, Effect, Schema, pipe } from "effect"
import { REGISTRY_URL } from "~/consts"

import {
HttpClient,
HttpClientRequest,
HttpClientResponse,
Command as RawCommand,
} from "@effect/platform"
import chalk from "chalk"
import { Component } from "~/schema/component"

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

export const isBlock = Options.boolean("b")
export const isStyle = Options.boolean("s")

export const allComponents = Options.boolean("all").pipe(
Options.withAlias("a"),
Options.withDefault(false),
)

export const componentType = Options.choice("type", ["ui", "block", "style"]).pipe(
Options.withAlias("t"),
Options.withDefault("ui"),
)

export const addCommand = Command.make(
"add",
{ componentNames, isBlock, isStyle, componentType, allComponents },
({ componentNames, isBlock, isStyle, componentType, allComponents }) =>
Effect.gen(function* () {
const type = isBlock ? "block" : isStyle ? "style" : componentType

const componentPaths = yield* pipe(
Effect.forEach(componentNames, (name) =>
Effect.succeed(`${REGISTRY_URL}/r/${type}-${name}.json`),
),
)

if (!allComponents && componentPaths.length === 0) {
yield* Console.log(chalk.red("No components selected"))
yield* Console.log(chalk.red("Please select a component or use --all"))
return
}

if (allComponents) {
const client = yield* HttpClient.HttpClient.pipe()

const response = yield* HttpClientRequest.get("https://intentui.com/r/index.json").pipe(
client.execute,
Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Array(Component))),
)

return yield* RawCommand.make(
"shadcnClone",
"add",
...response.map((c) => `https://intentui.com/r/${c.name}.json`),
).pipe(
RawCommand.stdin("inherit"),
RawCommand.stdout("inherit"),
RawCommand.stderr("inherit"),
RawCommand.exitCode,
)
}

return yield* pipe(
RawCommand.make("shadcnClone", "add", ...componentPaths).pipe(
RawCommand.stdin("inherit"),
RawCommand.stdout("inherit"),
RawCommand.stderr("inherit"),
RawCommand.exitCode,
),
)
}),
).pipe(Command.withDescription("Adds UI components or blocks to your project."))
Loading