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:
1 parent
d4e042e9ad
commit
13fe2f6776
7 files changed
+45
-11
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"@medusajs/framework": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(framework): migration scripts regexp
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
"watch": "tsc --watch ",
|
"watch": "tsc --watch ",
|
||||||
"watch:test": "tsc --watch",
|
"watch:test": "tsc --watch",
|
||||||
"build": "rimraf dist && tsc --build",
|
"build": "rimraf dist && tsc --build",
|
||||||
"test": "jest --runInBand --bail --passWithNoTests --forceExit"
|
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@medusajs/cli": "^2.3.1",
|
"@medusajs/cli": "^2.3.1",
|
||||||
|
|||||||
Whitespace-only changes.
@@ -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 { jest } from "@jest/globals"
|
||||||
import path from "path"
|
import { MedusaContainer } from "@medusajs/types"
|
||||||
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
import { ContainerRegistrationKeys, Modules } from "@medusajs/utils"
|
||||||
|
import path from "path"
|
||||||
|
import { MigrationScriptsMigrator } from "../run-migration-scripts"
|
||||||
|
|
||||||
const mockPgConnection = {
|
const mockPgConnection = {
|
||||||
raw: jest.fn(),
|
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 { MedusaContainer } from "@medusajs/types"
|
||||||
import { ContainerRegistrationKeys } from "../utils"
|
|
||||||
import { Knex } from "@mikro-orm/knex"
|
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 {
|
export abstract class Migrator {
|
||||||
protected abstract migration_table_name: string
|
protected abstract migration_table_name: string
|
||||||
@@ -135,9 +135,9 @@ export abstract class Migrator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const scriptFiles = glob.sync("*.{js,(!d.)ts}", {
|
const scriptFiles = glob.sync("*.{js,ts}", {
|
||||||
cwd: basePath,
|
cwd: basePath,
|
||||||
ignore: ["**/index.{js,ts}"],
|
ignore: ["**/index.{js,ts}", "**/*.d.ts"],
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!scriptFiles?.length) {
|
if (!scriptFiles?.length) {
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ async function getEntitiesForModule(path: string) {
|
|||||||
const entities = [] as any[]
|
const entities = [] as any[]
|
||||||
|
|
||||||
const entityPaths = glob.sync(join(path, "models", "*.ts"), {
|
const entityPaths = glob.sync(join(path, "models", "*.ts"), {
|
||||||
ignore: ["**/index.{js,ts}"],
|
ignore: ["**/index.{js,ts}", "**/*.d.ts"],
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const entityPath of entityPaths) {
|
for (const entityPath of entityPaths) {
|
||||||
|
|||||||
Reference in new issue
Block a user