diff --git a/.changeset/unlucky-buses-cheat.md b/.changeset/unlucky-buses-cheat.md new file mode 100644 index 0000000000..dcc7acc7a4 --- /dev/null +++ b/.changeset/unlucky-buses-cheat.md @@ -0,0 +1,6 @@ +--- +"@medusajs/medusa": patch +"@medusajs/utils": patch +--- + +fix: generate posix paths for migrations diff --git a/packages/core/utils/src/common/index.ts b/packages/core/utils/src/common/index.ts index 4f81129c3c..af5d0171b6 100644 --- a/packages/core/utils/src/common/index.ts +++ b/packages/core/utils/src/common/index.ts @@ -81,4 +81,5 @@ export * from "./upper-case-first" export * from "./validate-handle" export * from "./wrap-handler" export * from "./merge-plugin-modules" -export * from "./merge-metadata" +export * from "./to-unix-slash" +export * from "./merge-metadata" \ No newline at end of file diff --git a/packages/core/utils/src/common/to-unix-slash.ts b/packages/core/utils/src/common/to-unix-slash.ts new file mode 100644 index 0000000000..5c3ad5390a --- /dev/null +++ b/packages/core/utils/src/common/to-unix-slash.ts @@ -0,0 +1,8 @@ +export function toUnixSlash(path: string) { + const isExtendedLengthPath = path.startsWith("\\\\?\\") + if (isExtendedLengthPath) { + return path + } + + return path.replace(/\\/g, "/") +} diff --git a/packages/medusa/src/commands/plugin/db/generate.ts b/packages/medusa/src/commands/plugin/db/generate.ts index 518beccfdb..4b29d37ab1 100644 --- a/packages/medusa/src/commands/plugin/db/generate.ts +++ b/packages/medusa/src/commands/plugin/db/generate.ts @@ -1,14 +1,15 @@ +import { glob } from "glob" import { logger } from "@medusajs/framework/logger" import { - defineMikroOrmCliConfig, + toUnixSlash, DmlEntity, dynamicImport, + defineMikroOrmCliConfig, } from "@medusajs/framework/utils" import { dirname, join } from "path" import { MetadataStorage } from "@mikro-orm/core" import { MikroORM } from "@mikro-orm/postgresql" -import { glob } from "glob" const TERMINAL_SIZE = process.stdout.columns @@ -24,7 +25,7 @@ const main = async function ({ directory }) { }[] const modulePaths = glob.sync( - join(directory, "src", "modules", "*", "index.ts") + toUnixSlash(join(directory, "src", "modules", "*", "index.ts")) ) for (const path of modulePaths) { @@ -61,7 +62,7 @@ const main = async function ({ directory }) { async function getEntitiesForModule(path: string) { const entities = [] as any[] - const entityPaths = glob.sync(join(path, "models", "*.ts"), { + const entityPaths = glob.sync(toUnixSlash(join(path, "models", "*.ts")), { ignore: ["**/index.{js,ts}", "**/*.d.ts"], })