Skip to content

Commit

Permalink
chore: remove unused function, log error
Browse files Browse the repository at this point in the history
  • Loading branch information
junghyeonsu committed Oct 2, 2024
1 parent 7f0e9d7 commit 1f658f9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/utils/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export async function getRawConfig(cwd: string): Promise<RawConfig | null> {

return rawConfigSchema.parse(configResult.config);
} catch (error) {
console.log(error);
throw new Error(`Invalid configuration found in ${cwd}/seed-design.json.`);
}
}
30 changes: 3 additions & 27 deletions packages/cli/src/utils/get-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import path from "path";
import type { z } from "zod";
import {
type ComponentMetadataWithRegistrySchema,
type componentMetadataSchemaWithRegistry,
componentMetadataIndexSchema,
type ComponentMetadataWithRegistrySchema,
} from "@/src/schema";
import type { Config } from "@/src/utils/get-config";

const BASE_URL =
process.env.NODE_ENV === "prod" ? "https://component-seed.design.io" : "http://localhost:3000";
Expand All @@ -16,7 +12,7 @@ export async function fetchComponentMetadatas(
try {
const results = await Promise.all(
fileNames.map(async (fileName) => {
const response = await fetch(`${BASE_URL}/registry/components/${fileName}.json`);
const response = await fetch(`${BASE_URL}/registry/component/${fileName}.json`);
return await response.json();
}),
);
Expand All @@ -34,27 +30,7 @@ export async function getMetadataIndex() {

return componentMetadataIndexSchema.parse(result);
} catch (error) {
console.log(error);
throw new Error(`Failed to fetch components from ${BASE_URL}.`);
}
}

export async function getItemTargetPath(
config: Config,
item: Pick<z.infer<typeof componentMetadataSchemaWithRegistry>, "type">,
override?: string,
) {
if (override) {
return override;
}

// if (config.aliases.ui) {
// return config.resolvedPaths.ui;
// }

const [parent, type] = item.type.split(":");
if (!(parent in config.resolvedPaths)) {
return null;
}

return path.join(config.resolvedPaths[parent as keyof typeof config.resolvedPaths], type);
}

0 comments on commit 1f658f9

Please sign in to comment.