e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
91 lines
2.2 KiB
TypeScript
91 lines
2.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { add, createAddComponentsPlan } from "../../src/commands/add";
|
|
|
|
describe("add command", () => {
|
|
it("exposes package manager override options", () => {
|
|
expect(
|
|
add.options.find((option) => option.long === "--use-npm"),
|
|
).toBeDefined();
|
|
expect(
|
|
add.options.find((option) => option.long === "--use-pnpm"),
|
|
).toBeDefined();
|
|
expect(
|
|
add.options.find((option) => option.long === "--use-yarn"),
|
|
).toBeDefined();
|
|
expect(
|
|
add.options.find((option) => option.long === "--use-bun"),
|
|
).toBeDefined();
|
|
});
|
|
});
|
|
|
|
describe("createAddComponentsPlan", () => {
|
|
it("uses npx --yes for npm", () => {
|
|
expect(
|
|
createAddComponentsPlan({
|
|
components: ["thread"],
|
|
packageManager: "npm",
|
|
yes: true,
|
|
cwd: "/repo",
|
|
}),
|
|
).toEqual({
|
|
command: "npx",
|
|
args: [
|
|
"--yes",
|
|
"shadcn@latest",
|
|
"add",
|
|
"https://r.assistant-ui.com/thread.json",
|
|
"--yes",
|
|
"--cwd",
|
|
"/repo",
|
|
],
|
|
});
|
|
});
|
|
|
|
it("uses pnpm dlx for pnpm", () => {
|
|
expect(
|
|
createAddComponentsPlan({
|
|
components: ["thread", "markdown-text"],
|
|
packageManager: "pnpm",
|
|
overwrite: true,
|
|
cwd: "/repo",
|
|
path: "components/assistant-ui",
|
|
}),
|
|
).toEqual({
|
|
command: "pnpm",
|
|
args: [
|
|
"dlx",
|
|
"shadcn@latest",
|
|
"add",
|
|
"https://r.assistant-ui.com/thread.json",
|
|
"https://r.assistant-ui.com/markdown-text.json",
|
|
"--overwrite",
|
|
"--cwd",
|
|
"/repo",
|
|
"--path",
|
|
"components/assistant-ui",
|
|
],
|
|
});
|
|
});
|
|
|
|
it("uses bunx for bun", () => {
|
|
expect(
|
|
createAddComponentsPlan({
|
|
components: ["thread"],
|
|
packageManager: "bun",
|
|
}),
|
|
).toEqual({
|
|
command: "bunx",
|
|
args: ["shadcn@latest", "add", "https://r.assistant-ui.com/thread.json"],
|
|
});
|
|
});
|
|
|
|
it("rejects invalid component names", () => {
|
|
expect(() =>
|
|
createAddComponentsPlan({
|
|
components: ["../thread"],
|
|
packageManager: "pnpm",
|
|
}),
|
|
).toThrow("Invalid component name: ../thread");
|
|
});
|
|
});
|