From 5fc9ade413ea10da422a2439b5cc2027fb2a055e Mon Sep 17 00:00:00 2001 From: shadcn Date: Fri, 27 Sep 2024 17:43:16 +0400 Subject: [PATCH] chore(cli): add deprecation notice (#4988) * feat(cli): add deprecation message * chore: changesets --- .changeset/small-plums-swim.md | 5 +++++ packages/cli/README.md | 3 +++ packages/cli/src/commands/add.ts | 3 +++ packages/cli/src/commands/init.ts | 3 +++ packages/cli/src/deprecated.ts | 7 +++++++ packages/cli/src/index.ts | 2 ++ 6 files changed, 23 insertions(+) create mode 100644 .changeset/small-plums-swim.md create mode 100644 packages/cli/src/deprecated.ts diff --git a/.changeset/small-plums-swim.md b/.changeset/small-plums-swim.md new file mode 100644 index 000000000..cd25161ef --- /dev/null +++ b/.changeset/small-plums-swim.md @@ -0,0 +1,5 @@ +--- +"shadcn-ui": patch +--- + +add deprecation notice diff --git a/packages/cli/README.md b/packages/cli/README.md index 49b9014fd..816337065 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -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. diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index 3bded1a9b..abf509f49 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -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" @@ -43,6 +44,8 @@ export const add = new Command() .option("-p, --path ", "the path to add the component to.") .action(async (components, opts) => { try { + console.log(DEPRECATED_MESSAGE) + const options = addOptionsSchema.parse({ components, ...opts, diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 78893dc53..4ba66f47c 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -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, @@ -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) diff --git a/packages/cli/src/deprecated.ts b/packages/cli/src/deprecated.ts new file mode 100644 index 000000000..e143fb3e0 --- /dev/null +++ b/packages/cli/src/deprecated.ts @@ -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` +) diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index f92c33c27..5a3e938d8 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -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)) @@ -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",