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

shadcx does not respect alias field #3831

Open
yf-yang opened this issue Dec 5, 2024 · 9 comments
Open

shadcx does not respect alias field #3831

yf-yang opened this issue Dec 5, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@yf-yang
Copy link
Collaborator

yf-yang commented Dec 5, 2024

Description

When designating aliases.ui, shadcx still add component to components/plate-ui folder

My components.json:

{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "default",
  "rsc": true,
  "tsx": true,
  "tailwind": {
    "config": "tailwind.config.ts",
    "css": "src/index.css",
    "baseColor": "slate",
    "cssVariables": true,
    "prefix": ""
  },
  "iconLibrary": "react-icons/lu",
  "aliases": {
    "components": "@/components",
    "utils": "@udecode/cn",
    "plate-ui": "@/components/plateUi",
    "ui": "@/components/shadcnUi"
  },
  "registries": {
    "plate": {
      "aliases": {
        "ui": "@/components/plateUi",
        "plate-ui": "@/components/plateUi"
      },
      "url": "https://platejs.org/r"
    }
  }
}

I've specified multiple combinations of "alias" and "plate-ui", but

pnpm shadcx add plate/resizable
✔ Checking registry.
✔ Installing dependencies.
✔ Created 1 file:
  - src/components/plate-ui/resizable.tsx

Reproduction URL

No response

Reproduction steps

Check description

Plate version

[email protected]

Slate React version

Unrelated

Screenshots

No response

Logs

No response

Browsers

No response

@yf-yang yf-yang added the bug Something isn't working label Dec 5, 2024
@yf-yang
Copy link
Collaborator Author

yf-yang commented Dec 5, 2024

Investigation:

let targetDir = getRegistryItemFileTargetPath(file, config);
const fileName = basename(file.path);
let filePath = path.join(targetDir, fileName);
if (file.target) {
filePath = resolveTargetDir(projectInfo, config, file.target);
targetDir = path.dirname(filePath);
}

Line 74, the path is resolved to registries.plate.aliases.ui

Line 78, it is overridden by the component's config

Sample file:

"target": "components/plate-ui/resizable.tsx",

@zbeyens
Copy link
Member

zbeyens commented Dec 6, 2024

Does it work with shadcn? If so, can you spot the code diff?

@yf-yang
Copy link
Collaborator Author

yf-yang commented Dec 6, 2024

I checked shadcn's source code, it seems they are completely different?

@yf-yang
Copy link
Collaborator Author

yf-yang commented Dec 6, 2024

I see, let me confirm how shadcn works. It does work with shadcn.

@zbeyens
Copy link
Member

zbeyens commented Dec 6, 2024

shadcx should only be an extension of shadcn. We regularly sync with the latest version of shadcn, but we may have missed edge cases

@yf-yang
Copy link
Collaborator Author

yf-yang commented Dec 7, 2024

I'm confused, shadcx's cli code is completely different from shadcn's. Is it copied from shadcn repository at some time before?

@yf-yang
Copy link
Collaborator Author

yf-yang commented Dec 7, 2024

With "registries", shadcn does not recognize components.json, too. I guess they validate the schema

@zbeyens
Copy link
Member

zbeyens commented Dec 7, 2024

shadcn-ui/ui#5963

@yf-yang
Copy link
Collaborator Author

yf-yang commented Dec 10, 2024

My bad 🤣. I check shadcn's cli package and didn't see related codes. Now I realize its the shadcn package. I'll compare them later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants