Skip to content

Commit

Permalink
update valibot
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 committed Jul 18, 2024
1 parent a4e0964 commit 1972dbe
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
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"
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/commands/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const addOptionsSchema = v.object({
proxy: v.optional(v.string()),
});

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

export const add = new Command()
.command("add")
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const updateOptionsSchema = v.object({
yes: v.boolean(),
});

type UpdateOptions = v.Output<typeof updateOptionsSchema>;
type UpdateOptions = v.InferOutput<typeof updateOptionsSchema>;

export const update = new Command()
.command("update")
Expand Down
24 changes: 15 additions & 9 deletions packages/cli/src/utils/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,33 @@ export const rawConfigSchema = v.object({
// cssVariables: v.boolean().default(true)
}),
aliases: v.object({
components: v.transform(v.string(), (v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, "")),
utils: v.transform(v.string(), (v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, "")),
components: v.pipe(
v.string(),
v.transform((v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, ""))
),
utils: v.pipe(
v.string(),
v.transform((v) => v.replace(/[\u{0080}-\u{FFFF}]/gu, ""))
),
}),
typescript: v.optional(v.boolean(), true),
});

export type RawConfig = v.Output<typeof rawConfigSchema>;
export type RawConfig = v.InferOutput<typeof rawConfigSchema>;

export const configSchema = v.merge([
rawConfigSchema,
v.object({
export const configSchema = v.object({
...rawConfigSchema.entries,
...v.object({
resolvedPaths: v.object({
tailwindConfig: v.string(),
tailwindCss: v.string(),
utils: v.string(),
components: v.string(),
}),
}),
]);
}).entries,
});

export type Config = v.Output<typeof configSchema>;
export type Config = v.InferOutput<typeof configSchema>;

export async function getConfig(cwd: string) {
const config = await getRawConfig(cwd);
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/utils/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as schemas from "./schema.js";

const baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://shadcn-svelte.com";

export type RegistryItem = v.Output<typeof schemas.registryItemSchema>;
export type RegistryItem = v.InferOutput<typeof schemas.registryItemSchema>;

export async function getRegistryIndex() {
try {
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function getRegistryBaseColor(baseColor: string) {
}
}

type RegistryIndex = v.Output<typeof schemas.registryIndexSchema>;
type RegistryIndex = v.InferOutput<typeof schemas.registryIndexSchema>;
export async function resolveTree(index: RegistryIndex, names: string[], includeRegDeps = true) {
const tree: RegistryIndex = [];

Expand Down Expand Up @@ -108,7 +108,7 @@ export async function fetchTree(config: Config, tree: RegistryIndex) {

export function getItemTargetPath(
config: Config,
item: Pick<v.Output<typeof schemas.registryItemWithContentSchema>, "type">,
item: Pick<v.InferOutput<typeof schemas.registryItemWithContentSchema>, "type">,
override?: string
) {
// Allow overrides for all items but ui.
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/utils/registry/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ export const registryItemSchema = v.object({

export const registryIndexSchema = v.array(registryItemSchema);

export const registryItemWithContentSchema = v.merge([
registryItemSchema,
v.object({
export const registryItemWithContentSchema = v.object({
...registryItemSchema.entries,
...v.object({
files: v.array(
v.object({
name: v.string(),
content: v.string(),
})
),
}),
]);
}).entries,
});

export const registryWithContentSchema = v.array(registryItemWithContentSchema);

Expand Down
11 changes: 9 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1972dbe

Please sign in to comment.