Skip to content

Commit 32c5015

Browse files
authored
fix: generate posix paths for migrations (medusajs#11468)
Fixes: FRMW-2913 Related Github issue - medusajs#11330
1 parent b53ea77 commit 32c5015

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

.changeset/unlucky-buses-cheat.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@medusajs/medusa": patch
3+
"@medusajs/utils": patch
4+
---
5+
6+
fix: generate posix paths for migrations

packages/core/utils/src/common/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,5 @@ export * from "./upper-case-first"
8181
export * from "./validate-handle"
8282
export * from "./wrap-handler"
8383
export * from "./merge-plugin-modules"
84-
export * from "./merge-metadata"
84+
export * from "./to-unix-slash"
85+
export * from "./merge-metadata"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export function toUnixSlash(path: string) {
2+
const isExtendedLengthPath = path.startsWith("\\\\?\\")
3+
if (isExtendedLengthPath) {
4+
return path
5+
}
6+
7+
return path.replace(/\\/g, "/")
8+
}

packages/medusa/src/commands/plugin/db/generate.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
import { glob } from "glob"
12
import { logger } from "@medusajs/framework/logger"
23
import {
3-
defineMikroOrmCliConfig,
4+
toUnixSlash,
45
DmlEntity,
56
dynamicImport,
7+
defineMikroOrmCliConfig,
68
} from "@medusajs/framework/utils"
79
import { dirname, join } from "path"
810

911
import { MetadataStorage } from "@mikro-orm/core"
1012
import { MikroORM } from "@mikro-orm/postgresql"
11-
import { glob } from "glob"
1213

1314
const TERMINAL_SIZE = process.stdout.columns
1415

@@ -24,7 +25,7 @@ const main = async function ({ directory }) {
2425
}[]
2526

2627
const modulePaths = glob.sync(
27-
join(directory, "src", "modules", "*", "index.ts")
28+
toUnixSlash(join(directory, "src", "modules", "*", "index.ts"))
2829
)
2930

3031
for (const path of modulePaths) {
@@ -61,7 +62,7 @@ const main = async function ({ directory }) {
6162
async function getEntitiesForModule(path: string) {
6263
const entities = [] as any[]
6364

64-
const entityPaths = glob.sync(join(path, "models", "*.ts"), {
65+
const entityPaths = glob.sync(toUnixSlash(join(path, "models", "*.ts")), {
6566
ignore: ["**/index.{js,ts}", "**/*.d.ts"],
6667
})
6768

0 commit comments

Comments
 (0)