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: update schema URLs in CLI commands and configuration files for consistency

vholik6caa2972ee7a
diff --git a/packages/cli/README.md b/packages/cli/README.md
index a234848be..322a20d90 100644
--- a/packages/cli/README.md
+++ b/packages/cli/README.md
@@ -336,7 +336,7 @@ The CLI uses a `blocks.json` file for configuration. This file is created when y
```json
{
- "$schema": "https://mercurjs.com/schema.json",
+ "$schema": "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/schema/registry.json",
"aliases": {
"workflows": "@/src/workflows",
"api": "@/src/api",
diff --git a/packages/cli/src/commands/build.ts b/packages/cli/src/commands/build.ts
index d171eb16f..d0fdef71c 100644
--- a/packages/cli/src/commands/build.ts
+++ b/packages/cli/src/commands/build.ts
@@ -12,6 +12,7 @@ import { logger } from "@/src/utils/logger";
import { spinner } from "@/src/utils/spinner";
import { Command } from "commander";
import { z } from "zod";
+import { REGISTRY_ITEM_SCHEMA_URL } from "../registry";
export const buildOptionsSchema = z.object({
cwd: z.string(),
@@ -27,7 +28,7 @@ export const build = new Command()
.option(
"-o, --output <path>",
"destination directory for json files",
- "./registry"
+ "./r"
)
.option(
"-c, --cwd <cwd>",
@@ -122,7 +123,7 @@ async function buildRegistry(opts: z.infer<typeof buildOptionsSchema>) {
// Add the schema to the registry item.
registryItem["$schema"] =
- "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/schema/registry-item.json";
+ REGISTRY_ITEM_SCHEMA_URL;
for (const file of registryItem.files) {
const absPath = path.resolve(resolvePaths.cwd, file.path);
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts
index 2451d0d9a..9cc0a48c3 100644
--- a/packages/cli/src/commands/init.ts
+++ b/packages/cli/src/commands/init.ts
@@ -4,7 +4,7 @@ import path from "path";
import prompts from "prompts";
import { z } from "zod";
import { preFlightInit } from "../preflights/preflight-init";
-import { BUILTIN_REGISTRIES } from "../registry/constants";
+import { BUILTIN_REGISTRIES, REGISTRY_SCHEMA_URL } from "../registry/constants";
import { clearRegistryContext } from "../registry/context";
import { rawConfigSchema } from "../schema";
import { getConfig, resolveConfigPaths } from "../utils/get-config";
@@ -101,7 +101,7 @@ async function promptForConfig(opts: z.infer<typeof initOptionsSchema>) {
// Skip prompts if defaults flag is set
if (opts.defaults) {
return rawConfigSchema.parse({
- $schema: "https://mercurjs.com/schema.json",
+ $schema: REGISTRY_SCHEMA_URL,
aliases: {
workflows: "@workspace/packages/api/src/workflows",
api: "@workspace/packages/api/src/api",
@@ -169,7 +169,7 @@ async function promptForConfig(opts: z.infer<typeof initOptionsSchema>) {
);
return rawConfigSchema.parse({
- $schema: "https://mercurjs.com/schema.json",
+ $schema: REGISTRY_SCHEMA_URL,
aliases: {
workflows: options.workflows ?? "@workspace/packages/api/src/workflows",
api: options.api ?? "@workspace/packages/api/src/api",
@@ -190,7 +190,7 @@ async function promptForMinimalConfig(
// If --defaults is passed, use default values
if (opts.defaults) {
return rawConfigSchema.parse({
- $schema: "https://mercurjs.com/schema.json",
+ $schema: REGISTRY_SCHEMA_URL,
aliases: {
workflows: "@workspace/packages/api/src/workflows",
api: "@workspace/packages/api/src/api",
diff --git a/packages/cli/src/registry/constants.ts b/packages/cli/src/registry/constants.ts
index 76b87c31a..632884c65 100644
--- a/packages/cli/src/registry/constants.ts
+++ b/packages/cli/src/registry/constants.ts
@@ -1,6 +1,9 @@
import type { z } from "zod";
import type { registryConfigSchema } from "./schema";
+export const REGISTRY_SCHEMA_URL = "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/schema/registry.json";
+export const REGISTRY_ITEM_SCHEMA_URL = "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/schema/registry-item.json";
+
// Registry URL can be customized via environment variable
// Supports branch names: https://raw.githubusercontent.com/{owner}/{repo}/{branch}/packages/registry/registry
export const REGISTRY_URL =
diff --git a/packages/registry/blocks.json b/packages/registry/blocks.json
new file mode 100644
index 000000000..d1b056f33
--- /dev/null
+++ b/packages/registry/blocks.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/schema/registry.json",
+ "aliases": {
+ "workflows": "@/workflows",
+ "api": "@/api",
+ "links": "@/links",
+ "modules": "@/modules",
+ "vendor": "@/vendor",
+ "admin": "@/admin",
+ "lib": "@/lib"
+ },
+ "registries": {}
+}
\ No newline at end of file
diff --git a/packages/registry/package.json b/packages/registry/package.json
index f4e541470..65c979495 100644
--- a/packages/registry/package.json
+++ b/packages/registry/package.json
@@ -5,7 +5,8 @@
"type": "module",
"scripts": {
"build": "tsc",
- "dev": "tsc --watch"
+ "dev": "tsc --watch",
+ "build:registry": "mercurjs build ./r"
},
"dependencies": {},
"devDependencies": {
diff --git a/templates/basic/blocks.json b/templates/basic/blocks.json
index 4ff2c9219..14a77ed21 100644
--- a/templates/basic/blocks.json
+++ b/templates/basic/blocks.json
@@ -1,5 +1,5 @@
{
- "$schema": "https://mercurjs.com/schema.json",
+ "$schema": "https://raw.githubusercontent.com/mercurjs/mercur/new/packages/registry/schema/registry.json",
"aliases": {
"workflows": "packages/api/src/workflows",
"api": "packages/api/src/api",
@@ -10,4 +10,4 @@
"lib": "packages/api/src/lib"
},
"registries": {}
-}
+}
\ No newline at end of file