fix(framework): migration scripts regexp (#11072)
FIXES FRMW-2879 **What** The exclusion regexp was broken and instead use the ignore options of the glob sync function to properly ignore definition files
This commit is contained in:
committed by
GitHub
parent
d4e042e9ad
commit
13fe2f6776
6
.changeset/nervous-carrots-draw.md
Normal file
6
.changeset/nervous-carrots-draw.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@medusajs/medusa": patch
|
||||
"@medusajs/framework": patch
|
||||
---
|
||||
|
||||
fix(framework): migration scripts regexp
|
||||
@@ -51,7 +51,7 @@
|
||||
"watch": "tsc --watch ",
|
||||
"watch:test": "tsc --watch",
|
||||
"build": "rimraf dist && tsc --build",
|
||||
"test": "jest --runInBand --bail --passWithNoTests --forceExit"
|
||||
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@medusajs/cli": "^2.3.1",
|
||||
|
||||
0
packages/core/framework/src/migrations/__fixtures__/project/migration-scripts/test.d.ts
vendored
Normal file
0
packages/core/framework/src/migrations/__fixtures__/project/migration-scripts/test.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function test() {
|
||||
console.log("test")
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { MedusaContainer } from "@medusajs/types"
|
||||
import { MigrationScriptsMigrator } from "../run-migration-scripts"
|
||||
import { jest } from "@jest/globals"
|
||||
import path from "path"
|
||||
import { MedusaContainer } from "@medusajs/types"
|
||||
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||
import path from "path"
|
||||
import { MigrationScriptsMigrator } from "../run-migration-scripts"
|
||||
|
||||
const mockPgConnection = {
|
||||
raw: jest.fn(),
|
||||
@@ -171,4 +171,29 @@ describe("MigrationScriptsMigrator", () => {
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe("loadMigrationFiles", () => {
|
||||
it("should load migration files correctly", async () => {
|
||||
const result = await migrator.loadMigrationFiles([
|
||||
path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"__fixtures__",
|
||||
"project",
|
||||
"migration-scripts"
|
||||
),
|
||||
])
|
||||
expect(result).toHaveLength(1)
|
||||
expect(result[0]).toEqual(
|
||||
path.join(
|
||||
__dirname,
|
||||
"..",
|
||||
"__fixtures__",
|
||||
"project",
|
||||
"migration-scripts",
|
||||
"test.ts"
|
||||
)
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { join } from "path"
|
||||
import { glob } from "glob"
|
||||
import { logger } from "../logger"
|
||||
import { MedusaContainer } from "@medusajs/types"
|
||||
import { ContainerRegistrationKeys } from "../utils"
|
||||
import { Knex } from "@mikro-orm/knex"
|
||||
import { glob } from "glob"
|
||||
import { join } from "path"
|
||||
import { logger } from "../logger"
|
||||
import { ContainerRegistrationKeys } from "../utils"
|
||||
|
||||
export abstract class Migrator {
|
||||
protected abstract migration_table_name: string
|
||||
@@ -135,9 +135,9 @@ export abstract class Migrator {
|
||||
}
|
||||
|
||||
try {
|
||||
const scriptFiles = glob.sync("*.{js,(!d.)ts}", {
|
||||
const scriptFiles = glob.sync("*.{js,ts}", {
|
||||
cwd: basePath,
|
||||
ignore: ["**/index.{js,ts}"],
|
||||
ignore: ["**/index.{js,ts}", "**/*.d.ts"],
|
||||
})
|
||||
|
||||
if (!scriptFiles?.length) {
|
||||
|
||||
@@ -62,7 +62,7 @@ async function getEntitiesForModule(path: string) {
|
||||
const entities = [] as any[]
|
||||
|
||||
const entityPaths = glob.sync(join(path, "models", "*.ts"), {
|
||||
ignore: ["**/index.{js,ts}"],
|
||||
ignore: ["**/index.{js,ts}", "**/*.d.ts"],
|
||||
})
|
||||
|
||||
for (const entityPath of entityPaths) {
|
||||
|
||||
Reference in New Issue
Block a user