Skip to content
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

Can't use update command if components.json is customized #1532

Open
grvcoelho opened this issue Dec 5, 2024 · 4 comments
Open

Can't use update command if components.json is customized #1532

grvcoelho opened this issue Dec 5, 2024 · 4 comments

Comments

@grvcoelho
Copy link

Describe the bug

Important: using shadcn-svelte@next

I've initialized a new repo with init command and changed the paths to these:

components.json:

{
	"$schema": "https://next.shadcn-svelte.com/schema.json",
	"style": "default",
	"tailwind": {
		"config": "tailwind.config.ts",
		"css": "src/app.css",
		"baseColor": "neutral"
	},
	"aliases": {
		"components": "$lib/ui",
		"utils": "$lib/ui/utils/index",
		"ui": "$lib/ui/ds",
		"hooks": "$lib/ui/hooks"
	},
	"typescript": true,
	"registry": "https://next.shadcn-svelte.com/registry"
}

I used the add command and it works properly.

However the update command seems to have a problem with the customized paths

  shadcn-svelte  v1.0.0-next.4
│
└  [CLI Error]: Component directory <path_to_my_project>/src/lib/ui/ui does not exist.

Reproduction

  1. Init with different paths for components/hooks/utils/etc
  2. Add some components
  3. Try and use the update command

Logs

No response

System Info

System:
    OS: macOS 15.0
    CPU: (8) arm64 Apple M1
    Memory: 153.53 MB / 8.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.18.0 - ~/.local/share/nvm/v20.18.0/bin/node
    npm: 10.8.2 - ~/.local/share/nvm/v20.18.0/bin/npm
    pnpm: 9.12.0 - /opt/homebrew/bin/pnpm
    Watchman: 2024.11.11.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 131.0.6778.86
    Safari: 18.0
  npmPackages:
    @sveltejs/kit: ^2.9.0 => 2.9.0
    bits-ui: 1.0.0-next.66 => 1.0.0-next.66
    formsnap: 2.0.0-next.1 => 2.0.0-next.1
    lucide-svelte: ^0.468.0 => 0.468.0
    mode-watcher: ^0.5.0 => 0.5.0
    svelte: ^5.0.0 => 5.6.2
    svelte-sonner: ^0.3.28 => 0.3.28
    sveltekit-superforms: ^2.21.1 => 2.21.1
    vaul-svelte: 1.0.0-next.3 => 1.0.0-next.3

Severity

annoyance

@ieedan
Copy link
Contributor

ieedan commented Dec 10, 2024

I can't seem to reproduce this with the details you provided. Can you try and provide a stackblitz or repository that this can be reproduced in?

@Slartibartfass2
Copy link

Hi, I came across the same problem with the following components.json:

{
    "$schema": "https://next.shadcn-svelte.com/schema.json",
    "style": "default",
    "tailwind": {
        "config": "tailwind.config.js",
        "css": "src/app.css",
        "baseColor": "slate"
    },
    "aliases": {
        "components": "$lib/components",
        "utils": "$lib/utils/shadcn-helper",
        "ui": "$lib/components/primitives",
        "hooks": "$lib/hooks"
    },
    "typescript": true,
    "registry": "https://next.shadcn-svelte.com/registry"
}

I found a fix that resolves this issue for me:
In

const componentDir = path.resolve(config.resolvedPaths.components, "ui");
the ui directory is hardcoded.
The correct way would be to use the resolved alias path:

const componentDir = path.resolve(config.resolvedPaths.ui);

I hope this helps.

Slartibartfass2 added a commit to SE-UUlm/snowballr-frontend that referenced this issue Jan 2, 2025
…ompatibility issue

In Svelte 5.16.0 the code of the shadcn components got broken due to a bug.
This got fixed in huntabyte/shadcn-svelte#1585.
To reproduce this I ran the shadcn cli update command locally (commit f06d2a1133c9df77902e62d4da79842a6b0af329).
Due to a bug in the cli command, which was already reported in huntabyte/shadcn-svelte#1532
I had to adjust the code.
The update command did overwrite some customizations we already made, which I undid.
Slartibartfass2 added a commit to SE-UUlm/snowballr-frontend that referenced this issue Jan 6, 2025
…ompatibility issue

In Svelte 5.16.0 the code of the shadcn components got broken due to a bug.
This got fixed in huntabyte/shadcn-svelte#1585.
To reproduce this I ran the shadcn cli update command locally (commit f06d2a1133c9df77902e62d4da79842a6b0af329).
Due to a bug in the cli command, which was already reported in huntabyte/shadcn-svelte#1532
I had to adjust the code.
The update command did overwrite some customizations we already made, which I undid.
@Slartibartfass2
Copy link

@huntabyte I would be happy to help and create a pull request.

@huntabyte
Copy link
Owner

That would be great @Slartibartfass2 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants