Skip to content

Commit

Permalink
Merge branch 'main' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte committed Jul 22, 2024
2 parents 54d6245 + eb947e8 commit 464442e
Show file tree
Hide file tree
Showing 552 changed files with 1,525 additions and 1,462 deletions.
29 changes: 29 additions & 0 deletions packages/cli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# shadcn-svelte

## 0.12.1

### Patch Changes

- d43d140: fix: Use correct cwd when syncing SvelteKit projects

## 0.12.0

### Minor Changes

- b6b4601: feat: Added `--no-deps` flag to `init` command

### Patch Changes

- b6b4601: breaking: Changed `--nodep` flag to `--no-deps` for `add` command

## 0.11.1

### Patch Changes

- c2d1ed6: fix: Fixes bug with incorrect flag assignments

## 0.11.0

### Minor Changes

- 6c9b9ee: feat: Added CLI flags for each option for `init`
- 6c9b9ee: feat: Removed TypeScript prompt in favor of auto detection

## 0.10.7

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shadcn-svelte",
"version": "0.10.7",
"version": "0.12.1",
"description": "Add components to your apps.",
"license": "MIT",
"author": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"tsup": "^8.0.0",
"type-fest": "^3.13.1",
"typescript": "^5.0.0",
"valibot": "^0.30.0",
"valibot": "^0.36.0",
"vitest": "^0.34.6"
}
}
34 changes: 15 additions & 19 deletions packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,23 @@ const addOptionsSchema = v.object({
overwrite: v.boolean(),
cwd: v.string(),
path: v.optional(v.string()),
nodep: v.boolean(),
deps: v.boolean(),
proxy: v.optional(v.string()),
});

type AddOptions = v.Output<typeof addOptionsSchema>;
type AddOptions = v.InferOutput<typeof addOptionsSchema>;

export const add = new Command()
.command("add")
.description("add components to your project")
.argument("[components...]", "name of components")
.option("--nodep", "skips adding & installing package dependencies.", false)
.option("-a, --all", "install all components to your project.", false)
.option("-y, --yes", "skip confirmation prompt.", false)
.option("-o, --overwrite", "overwrite existing files.", false)
.option("--proxy <proxy>", "fetch components from registry using a proxy.", getEnvProxy())
.option(
"-c, --cwd <cwd>",
"the working directory. defaults to the current directory.",
process.cwd()
)
.option("-p, --path <path>", "the path to add the component to.")
.option("-c, --cwd <cwd>", "the working directory", process.cwd())
.option("--no-deps", "skips adding & installing package dependencies")
.option("-a, --all", "install all components to your project", false)
.option("-y, --yes", "skip confirmation prompt", false)
.option("-o, --overwrite", "overwrite existing files", false)
.option("--proxy <proxy>", "fetch components from registry using a proxy", getEnvProxy())
.option("-p, --path <path>", "the path to add the component to")
.action(async (components, opts) => {
try {
intro();
Expand Down Expand Up @@ -101,7 +97,7 @@ async function runAdd(cwd: string, config: Config, options: AddOptions) {
message: `Which ${highlight("components")} would you like to install?`,
maxItems: 10,
options: registryIndex.map(({ name, dependencies, registryDependencies }) => {
const deps = [...(options.nodep ? [] : dependencies), ...registryDependencies];
const deps = [...(options.deps ? dependencies : []), ...registryDependencies];
return {
label: name,
value: name,
Expand Down Expand Up @@ -177,7 +173,7 @@ async function runAdd(cwd: string, config: Config, options: AddOptions) {

if (options.yes === false) {
const proceed = await p.confirm({
message: `Ready to install ${highlight("components")}${options.nodep ? "?" : ` and ${highlight("dependencies")}?`}`,
message: `Ready to install ${highlight("components")}${options.deps ? ` and ${highlight("dependencies")}?` : "?"}`,
initialValue: true,
});

Expand Down Expand Up @@ -218,10 +214,10 @@ async function runAdd(cwd: string, config: Config, options: AddOptions) {
}

// Add dependencies to the install list
if (options.nodep) {
item.dependencies.forEach((dep) => skippedDeps.add(dep));
} else {
if (options.deps) {
item.dependencies.forEach((dep) => dependencies.add(dep));
} else {
item.dependencies.forEach((dep) => skippedDeps.add(dep));
}

// Install Component
Expand Down Expand Up @@ -262,7 +258,7 @@ async function runAdd(cwd: string, config: Config, options: AddOptions) {

await p.tasks(tasks);

if (options.nodep) {
if (!options.deps) {
const prettyList = prettifyList([...skippedDeps], 7);
p.log.warn(
`Components have been installed ${color.bold.red("without")} the following ${highlight("dependencies")}:\n${color.gray(prettyList)}`
Expand Down
Loading

0 comments on commit 464442e

Please sign in to comment.