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

fix: replace hard coded components path with the resolved path #1612

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function runUpdate(cwd: string, config: cliConfig.Config, options: UpdateO
const components = options.components;
const registryIndex = await registry.getRegistryIndex();

const componentDir = path.resolve(config.resolvedPaths.components, "ui");
const componentDir = path.resolve(config.resolvedPaths.ui);
if (!existsSync(componentDir)) {
throw error(`Component directory ${color.cyan(componentDir)} does not exist.`);
}
Expand Down
16 changes: 16 additions & 0 deletions packages/cli/test/fixtures/config-custom/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"style": "new-york",
"tailwind": {
"config": "custom-tailwind.config.js",
"css": "src/custom-app.pcss",
"baseColor": "zinc"
},
"aliases": {
"components": "$lib/custom-components",
"utils": "$lib/custom-utils",
"ui": "$lib/components/custom-ui",
"hooks": "$lib/custom-hooks"
},
"typescript": true,
"registry": "https://next.shadcn-svelte.com/registry"
}
16 changes: 16 additions & 0 deletions packages/cli/test/fixtures/config-custom/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "test-cli-config-full",
"version": "0.0.0",
"private": true,
"devDependencies": {
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3"
},
"type": "module"
}
14 changes: 14 additions & 0 deletions packages/cli/test/fixtures/config-custom/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
}
28 changes: 28 additions & 0 deletions packages/cli/test/utils/get-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,32 @@ describe("getConfig", () => {
registry: `${SITE_BASE_URL}/registry`,
});
});

it("handles cases where a full custom config is present", async () => {
expect(await getConf("config-custom")).toEqual({
style: "new-york",
tailwind: {
config: "custom-tailwind.config.js",
css: "src/custom-app.pcss",
baseColor: "zinc",
},
aliases: {
components: "$lib/custom-components",
utils: "$lib/custom-utils",
ui: "$lib/components/custom-ui",
hooks: "$lib/custom-hooks",
},
resolvedPaths: {
tailwindConfig: resolvePath("../fixtures/config-custom/custom-tailwind.config.js"),
tailwindCss: resolvePath("../fixtures/config-custom/src/custom-app.pcss"),
cwd: resolvePath("../fixtures/config-custom"),
components: resolvePath("../fixtures/config-custom/src/lib/custom-components"),
utils: resolvePath("../fixtures/config-custom/src/lib/custom-utils"),
ui: resolvePath("../fixtures/config-custom/src/lib/components/custom-ui"),
hooks: resolvePath("../fixtures/config-custom/src/lib/custom-hooks"),
},
typescript: true,
registry: `${SITE_BASE_URL}/registry`,
});
});
});