Skip to content

The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.

Refactor CLI initialization to improve directory structure and enhance project branding consistency.

vholik8e7688bf1064
diff --git a/packages/cli/src/commands/view.ts b/packages/cli/src/commands/view.ts
new file mode 100644
index 000000000..483d3acb7
--- /dev/null
+++ b/packages/cli/src/commands/view.ts
@@ -0,0 +1,48 @@
+import { Command } from "commander";
+import path from "path";
+import { z } from "zod";
+import { getRegistryItems } from "../registry/api";
+import { clearRegistryContext } from "../registry/context";
+import { createConfig, getConfig } from "../utils/get-config";
+import { handleError } from "../utils/handle-error";
+
+const viewOptionsSchema = z.object({
+ cwd: z.string(),
+});
+
+export const view = new Command()
+ .name("view")
+ .description("view block details from the registry")
+ .argument("<blocks...>", "the block names to view")
+ .option(
+ "-c, --cwd <cwd>",
+ "the working directory. defaults to the current directory.",
+ process.cwd()
+ )
+ .action(async (items: string[], opts) => {
+ try {
+ const options = viewOptionsSchema.parse({
+ cwd: path.resolve(opts.cwd),
+ type: opts.type,
+ });
+
+ let config = await getConfig(options.cwd);
+ if (!config) {
+ config = createConfig({
+ resolvedPaths: {
+ cwd: options.cwd,
+ },
+ });
+ }
+
+ const payload = await getRegistryItems(items, {
+ config,
+ });
+ console.log(JSON.stringify(payload, null, 2));
+ process.exit(0);
+ } catch (error) {
+ handleError(error);
+ } finally {
+ clearRegistryContext();
+ }
+ });