Skip to content

Commit

Permalink
chore(cli): add deprecation notice (#4988)
Browse files Browse the repository at this point in the history
* feat(cli): add deprecation message

* chore: changesets
  • Loading branch information
shadcn authored Sep 27, 2024
1 parent 96880e7 commit 5fc9ade
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-plums-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"shadcn-ui": patch
---

add deprecation notice
3 changes: 3 additions & 0 deletions packages/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

A CLI for adding components to your project.

> [!WARNING]
> The shadcn-ui CLI is going to be deprecated soon. Bug fixes and new features should be added to the `.packages/shadcn` instead.
## Usage

Use the `init` command to initialize dependencies for a new project.
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync, promises as fs } from "fs"
import path from "path"
import { DEPRECATED_MESSAGE } from "@/src/deprecated"
import { getConfig } from "@/src/utils/get-config"
import { getPackageManager } from "@/src/utils/get-package-manager"
import { handleError } from "@/src/utils/handle-error"
Expand Down Expand Up @@ -43,6 +44,8 @@ export const add = new Command()
.option("-p, --path <path>", "the path to add the component to.")
.action(async (components, opts) => {
try {
console.log(DEPRECATED_MESSAGE)

const options = addOptionsSchema.parse({
components,
...opts,
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { existsSync, promises as fs } from "fs"
import path from "path"
import { DEPRECATED_MESSAGE } from "@/src/deprecated"
import {
DEFAULT_COMPONENTS,
DEFAULT_TAILWIND_CONFIG,
Expand Down Expand Up @@ -55,6 +56,8 @@ export const init = new Command()
)
.action(async (opts) => {
try {
console.log(DEPRECATED_MESSAGE)

const options = initOptionsSchema.parse(opts)
const cwd = path.resolve(options.cwd)

Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/deprecated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import chalk from "chalk"

export const DEPRECATED_MESSAGE = chalk.yellow(
`\nNote: The shadcn-ui CLI is going to be deprecated soon. Please use ${chalk.bold(
"npx shadcn"
)} instead.\n`
)
2 changes: 2 additions & 0 deletions packages/cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { diff } from "@/src/commands/diff"
import { init } from "@/src/commands/init"
import { Command } from "commander"

import { DEPRECATED_MESSAGE } from "./deprecated"
import { getPackageInfo } from "./utils/get-package-info"

process.on("SIGINT", () => process.exit(0))
Expand All @@ -15,6 +16,7 @@ async function main() {
const program = new Command()
.name("shadcn-ui")
.description("add components and dependencies to your project")
.addHelpText("after", DEPRECATED_MESSAGE)
.version(
packageInfo.version || "1.0.0",
"-v, --version",
Expand Down

0 comments on commit 5fc9ade

Please sign in to comment.