The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
chore: v2.0.0-canary.71
vholik6b077ff0a332
diff --git a/packages/admin/package.json b/packages/admin/package.jsonindex 2c8474208..52bfabd75 100644--- a/packages/admin/package.json+++ b/packages/admin/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/admin",- "version": "2.0.0-canary.70",+ "version": "2.0.0-canary.71","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex bf50ec5ec..7f330f7e0 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/cli",- "version": "2.0.0-canary.70",+ "version": "2.0.0-canary.71","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",@@ -28,7 +28,6 @@},"dependencies": {"@antfu/ni": "^27.0.1",- "chokidar": "^4.0.3","commander": "^14.0.2","cosmiconfig": "^9.0.0","deepmerge": "^4.3.1",diff --git a/packages/cli/src/commands/codegen.ts b/packages/cli/src/commands/codegen.tsindex d6b50ac96..bafd5a594 100644--- a/packages/cli/src/commands/codegen.ts+++ b/packages/cli/src/commands/codegen.ts@@ -1,16 +1,13 @@import * as path from "path";import { Command } from "commander";-import chokidar from "chokidar";import { z } from "zod";import { writeRouteTypes } from "@/src/codegen";import { handleError } from "@/src/utils/handle-error";import { logger } from "@/src/utils/logger";import { spinner } from "@/src/utils/spinner";-import { highlighter } from "../utils/highlighter";export const codegenOptionsSchema = z.object({cwd: z.string(),- watch: z.boolean().default(false),});export const codegen = new Command()@@ -21,11 +18,9 @@ export const codegen = new Command()"the working directory. defaults to the current directory.",process.cwd())- .option("-w, --watch", "watch for changes and regenerate types", false).action(async (opts) => {await runCodegen({cwd: path.resolve(opts.cwd),- watch: opts.watch,});});@@ -39,73 +34,9 @@ async function runCodegen(opts: z.infer<typeof codegenOptionsSchema>) {codegenSpinner.succeed('Route types generated successfully.');- if (options.watch) {- await watchForChanges(options.cwd);- } else {- logger.break();- }+ logger.break();} catch (error) {logger.break();handleError(error);}}--async function watchForChanges(cwd: string) {- const apiDir = path.join(cwd, "src", "api");-- const watcher = chokidar.watch('.', {- cwd: apiDir,- persistent: true,- ignoreInitial: true,- });-- let debounceTimer: NodeJS.Timeout | null = null;-- const cleanup = async () => {- if (debounceTimer) {- clearTimeout(debounceTimer);- debounceTimer = null;- }- await watcher.close();- logger.break();- logger.info(`Watcher stopped.`);- };-- const regenerate = async (filePath: string) => {- logger.info(`Change detected in ${highlighter.info(filePath)}. Regenerating...`);- try {- await writeRouteTypes(cwd);- } catch (error) {- logger.error(`Failed to regenerate route types:`, error);- logger.break();- }- };-- const debouncedRegenerate = (filePath: string) => {- if (debounceTimer) {- clearTimeout(debounceTimer);- }- debounceTimer = setTimeout(() => regenerate(filePath), 100);- };-- watcher- .on("add", debouncedRegenerate)- .on("change", debouncedRegenerate)- .on("unlink", debouncedRegenerate)- .on("ready", () => {- logger.info(`Watching for changes... (Press Ctrl+C to stop)`);- })- .on("error", (error) => {- logger.error(`Watcher error:`, error);- logger.break();- });-- await new Promise<void>((resolve) => {- const shutdown = () => {- cleanup().then(resolve);- };-- process.once("SIGINT", shutdown);- process.once("SIGTERM", shutdown);- });-}diff --git a/packages/client/package.json b/packages/client/package.jsonindex dd538c467..e8174eacd 100644--- a/packages/client/package.json+++ b/packages/client/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/client",- "version": "2.0.0-canary.70",+ "version": "2.0.0-canary.71","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/core-plugin/package.json b/packages/core-plugin/package.jsonindex e4c229709..e85847539 100644--- a/packages/core-plugin/package.json+++ b/packages/core-plugin/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/core-plugin",- "version": "2.0.0-canary.70",+ "version": "2.0.0-canary.71","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/core-plugin/src/modules/codegen/index.ts b/packages/core-plugin/src/modules/codegen/index.tsnew file mode 100644index 000000000..91ae9f59c--- /dev/null+++ b/packages/core-plugin/src/modules/codegen/index.ts@@ -0,0 +1,7 @@+import { Module } from "@medusajs/framework/utils"+import CodegenModuleService from "./services/codegen-module-service"+import { MercurModules } from "@mercurjs/types"++export default Module(MercurModules.CODEGEN, {+ service: CodegenModuleService,+})diff --git a/packages/core-plugin/src/modules/codegen/services/codegen-module-service.ts b/packages/core-plugin/src/modules/codegen/services/codegen-module-service.tsnew file mode 100644index 000000000..d8a6a4a99--- /dev/null+++ b/packages/core-plugin/src/modules/codegen/services/codegen-module-service.ts@@ -0,0 +1,36 @@+import { exec } from "child_process"+import { Logger } from "@medusajs/medusa"++export default class CodegenModuleService {+ private readonly logger: Logger++ constructor({ logger }: { logger: Logger }) {+ this.logger = logger+ }++ __hooks = {+ onApplicationStart: async () => {+ await this.onApplicationStart()+ },+ }++ async onApplicationStart(): Promise<void> {+ try {+ await this.runCodegen_()+ } catch (error) {+ this.logger.warn(`Codegen failed: ${error}`)+ }+ }++ private runCodegen_(): Promise<void> {+ return new Promise((resolve, reject) => {+ exec("npx mercurjs codegen", { cwd: process.cwd() }, (error, _stdout, stderr) => {+ if (error) {+ reject(stderr || error.message)+ return+ }+ resolve()+ })+ })+ }+}diff --git a/packages/dashboard-sdk/package.json b/packages/dashboard-sdk/package.jsonindex 27ef59452..e8c377c3c 100644--- a/packages/dashboard-sdk/package.json+++ b/packages/dashboard-sdk/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/dashboard-sdk",- "version": "2.0.0-canary.70",+ "version": "2.0.0-canary.71","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/dashboard-shared/package.json b/packages/dashboard-shared/package.jsonindex 529a55ed2..cd3cc8703 100644--- a/packages/dashboard-shared/package.json+++ b/packages/dashboard-shared/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/dashboard-shared",- "version": "2.0.0-canary.70",+ "version": "2.0.0-canary.71","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/packages/types/src/modules.ts b/packages/types/src/modules.tsindex 8e07cfa88..387cadff1 100644--- a/packages/types/src/modules.ts+++ b/packages/types/src/modules.ts@@ -5,4 +5,5 @@ export enum MercurModules {CUSTOM_FIELDS = "custom_fields",VENDOR_UI = "vendor_ui",ADMIN_UI = "admin_ui",+ CODEGEN = "codegen",}diff --git a/packages/vendor/package.json b/packages/vendor/package.jsonindex 8e5b0c191..09e5aba57 100644--- a/packages/vendor/package.json+++ b/packages/vendor/package.json@@ -1,6 +1,6 @@{"name": "@mercurjs/vendor",- "version": "2.0.0-canary.70",+ "version": "2.0.0-canary.71","repository": {"type": "git","url": "https://github.com/mercurjs/mercur",diff --git a/templates/basic/apps/admin/package.json b/templates/basic/apps/admin/package.jsonindex 4a1980387..c55ac2ca0 100644--- a/templates/basic/apps/admin/package.json+++ b/templates/basic/apps/admin/package.json@@ -11,16 +11,16 @@},"dependencies": {"@medusajs/icons": "^2.13.3",- "@mercurjs/dashboard-sdk": "2.0.0-canary.70",- "@mercurjs/dashboard-shared": "2.0.0-canary.70",- "@mercurjs/admin": "2.0.0-canary.70",+ "@mercurjs/dashboard-sdk": "2.0.0-canary.71",+ "@mercurjs/dashboard-shared": "2.0.0-canary.71",+ "@mercurjs/admin": "2.0.0-canary.71","react": "^18.0.0","react-dom": "^18.0.0","react-i18next": "13.5.0","@tanstack/react-query": "5.64.2","@medusajs/ui": "4.1.1","react-router-dom": "6.30.3",- "@mercurjs/client": "2.0.0-canary.70",+ "@mercurjs/client": "2.0.0-canary.71","@acme/api": "*","@tanstack/react-table": "8.20.5","react-hook-form": "7.49.1",diff --git a/templates/basic/apps/vendor/package.json b/templates/basic/apps/vendor/package.jsonindex a84d2acd3..14bc1e42b 100644--- a/templates/basic/apps/vendor/package.json+++ b/templates/basic/apps/vendor/package.json@@ -11,16 +11,16 @@},"dependencies": {"@medusajs/icons": "^2.13.3",- "@mercurjs/dashboard-sdk": "2.0.0-canary.70",- "@mercurjs/dashboard-shared": "2.0.0-canary.70",- "@mercurjs/vendor": "2.0.0-canary.70",+ "@mercurjs/dashboard-sdk": "2.0.0-canary.71",+ "@mercurjs/dashboard-shared": "2.0.0-canary.71",+ "@mercurjs/vendor": "2.0.0-canary.71","react": "^18.0.0","react-dom": "^18.0.0","react-i18next": "13.5.0","@tanstack/react-query": "5.64.2","@medusajs/ui": "4.1.1","react-router-dom": "6.30.3",- "@mercurjs/client": "2.0.0-canary.70",+ "@mercurjs/client": "2.0.0-canary.71","@acme/api": "*","@tanstack/react-table": "8.20.5","react-hook-form": "7.49.1",diff --git a/templates/basic/packages/api/medusa-config.ts b/templates/basic/packages/api/medusa-config.tsindex a21ecb6dc..e23379482 100644--- a/templates/basic/packages/api/medusa-config.ts+++ b/templates/basic/packages/api/medusa-config.ts@@ -33,6 +33,9 @@ module.exports = defineConfig({appDir: path.join(__dirname, '../../apps/vendor'),path: '/seller'} as DashboardModuleOptions+ },+ {+ resolve: '@mercurjs/core-plugin/modules/codegen',}],plugins: [{diff --git a/templates/basic/packages/api/package.json b/templates/basic/packages/api/package.jsonindex 210ceefdc..ad6f64f91 100644--- a/templates/basic/packages/api/package.json+++ b/templates/basic/packages/api/package.json@@ -18,12 +18,10 @@"medusa"],"scripts": {- "build": "npx @mercurjs/cli@canary codegen && medusa build",+ "build": "medusa build","seed": "medusa exec ./src/scripts/seed.ts","start": "medusa start",- "dev:medusa": "medusa develop",- "dev": "concurrently --kill-others npm:dev:*",- "dev:codegen": "npx @mercurjs/cli@canary codegen --watch",+ "dev": "medusa develop","test:integration:http": "TEST_TYPE=integration:http NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit","test:integration:modules": "TEST_TYPE=integration:modules NODE_OPTIONS=--experimental-vm-modules jest --silent=false --runInBand --forceExit","test:unit": "TEST_TYPE=unit NODE_OPTIONS=--experimental-vm-modules jest --silent --runInBand --forceExit"@@ -36,8 +34,8 @@"@medusajs/admin-shared": "^2.13.3","@medusajs/medusa": "^2.13.3","@medusajs/draft-order": "2.13.3",- "@mercurjs/core-plugin": "2.0.0-canary.70",- "@mercurjs/types": "2.0.0-canary.70",+ "@mercurjs/core-plugin": "2.0.0-canary.71",+ "@mercurjs/types": "2.0.0-canary.71","zod": "3.25.76","http-proxy-middleware": "^3.0.3"},@@ -54,8 +52,7 @@"react": "^18.3.1","react-dom": "^18.3.1","ts-node": "^10.9.2",- "concurrently": "^9.2.1",- "typescript": "5.9.3",+"typescript": "5.9.3","vite": "^5.4.21","yalc": "^1.0.0-pre.53"},