-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(next): Update command doesn't update component code (#1421)
Co-authored-by: AdrianGonz97 <31664583+AdrianGonz97@users.noreply.github.com> fixes #1368
- Loading branch information
Showing
5 changed files
with
122 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"shadcn-svelte": patch | ||
--- | ||
|
||
fix: Ensure `utils.(js|ts)` is not fetched from the registry on `update` command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"shadcn-svelte": patch | ||
--- | ||
|
||
fix: `update` command now properly updates components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import { getItemTargetPath } from "../../../src/utils/registry/index"; | ||
import { SITE_BASE_URL } from "../../../src/constants"; | ||
|
||
const config = { | ||
style: "new-york", | ||
tailwind: { | ||
config: "tailwind.config.js", | ||
css: "src/app.pcss", | ||
baseColor: "zinc", | ||
}, | ||
aliases: { | ||
utils: "$lib/utils", | ||
components: "$lib/components", | ||
hooks: "$lib/hooks", | ||
ui: "$lib/components/ui", | ||
}, | ||
// not how they will look in the end but works for the tests | ||
resolvedPaths: { | ||
components: "./src/lib/components", | ||
tailwindConfig: "./tailwind.config.js", | ||
tailwindCss: "./src/app.pcss", | ||
utils: "./src/lib/utils", | ||
cwd: "./", | ||
hooks: "./src/lib/hooks", | ||
ui: "./src/lib/components/ui", | ||
}, | ||
typescript: true, | ||
registry: `${SITE_BASE_URL}/registry`, | ||
}; | ||
|
||
describe("getItemTargetPath", () => { | ||
it("returns null if invalid type missing `:`", async () => { | ||
expect( | ||
getItemTargetPath(config, { | ||
name: "label", | ||
dependencies: ["bits-ui@next"], | ||
registryDependencies: [], | ||
files: [ | ||
//... snip this since it doesn't matter | ||
], | ||
// @ts-expect-error Comes from over the wire in prod | ||
type: "registry", | ||
}) | ||
).toEqual(null); | ||
}); | ||
|
||
it("returns null if `item.type` has invalid `:<type>`", async () => { | ||
expect( | ||
getItemTargetPath(config, { | ||
name: "label", | ||
dependencies: ["bits-ui@next"], | ||
registryDependencies: [], | ||
files: [ | ||
//... snip this since it doesn't matter | ||
], | ||
// @ts-expect-error Comes from over the wire in prod | ||
type: "registry:foo", | ||
}) | ||
).toEqual(null); | ||
}); | ||
|
||
it("disallows overrides for `registry:ui`", async () => { | ||
expect( | ||
getItemTargetPath( | ||
config, | ||
{ | ||
name: "label", | ||
dependencies: ["bits-ui@next"], | ||
registryDependencies: [], | ||
files: [ | ||
//... snip this since it doesn't matter | ||
], | ||
type: "registry:ui", | ||
}, | ||
"./override-path" | ||
) | ||
).toEqual("src/lib/components/ui"); | ||
}); | ||
|
||
it("resolves item target path", async () => { | ||
expect( | ||
getItemTargetPath(config, { | ||
name: "label", | ||
dependencies: ["bits-ui@next"], | ||
registryDependencies: [], | ||
files: [ | ||
//... snip this since it doesn't matter | ||
], | ||
type: "registry:ui", | ||
}) | ||
).toEqual("src/lib/components/ui"); | ||
}); | ||
}); |