fix(product): The bin scripts should include a shebang and import in the body (#4296)
This commit is contained in:
@@ -36,8 +36,8 @@
|
||||
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@mikro-orm/cli": "5.7.4",
|
||||
"@mikro-orm/migrations": "5.7.4",
|
||||
"@mikro-orm/cli": "5.7.12",
|
||||
"@mikro-orm/migrations": "5.7.12",
|
||||
"cross-env": "^5.2.1",
|
||||
"jest": "^25.5.4",
|
||||
"medusa-test-utils": "^1.1.40",
|
||||
@@ -50,11 +50,11 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@medusajs/modules-sdk": "^1.8.3",
|
||||
"@medusajs/types": "*",
|
||||
"@medusajs/types": "^1.8.7",
|
||||
"@medusajs/utils": "^1.8.2",
|
||||
"@mikro-orm/core": "5.7.4",
|
||||
"@mikro-orm/migrations": "5.7.4",
|
||||
"@mikro-orm/postgresql": "5.7.4",
|
||||
"@mikro-orm/core": "5.7.12",
|
||||
"@mikro-orm/migrations": "5.7.12",
|
||||
"@mikro-orm/postgresql": "5.7.12",
|
||||
"awilix": "^8.0.0",
|
||||
"dotenv": "^16.1.4",
|
||||
"lodash": "^4.17.21"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { revertMigration } from "../migration-down"
|
||||
#!/usr/bin/env node
|
||||
|
||||
export default (async () => {
|
||||
const { revertMigration } = await import("../migration-down")
|
||||
const { config } = await import("dotenv")
|
||||
config()
|
||||
await revertMigration()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { runMigrations } from "../migration-up"
|
||||
#!/usr/bin/env node
|
||||
|
||||
export default (async () => {
|
||||
const { runMigrations } = await import("../migration-up")
|
||||
const { config } = await import("dotenv")
|
||||
config()
|
||||
await runMigrations()
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { run } from "../seed"
|
||||
import { EOL } from "os"
|
||||
|
||||
@@ -9,7 +11,7 @@ export default (async () => {
|
||||
config()
|
||||
if (!path) {
|
||||
throw new Error(
|
||||
`filePath is required.${EOL}Example: node_modules/@medusajs/product/dist/scripts/bin/run-seed.js <filePath>`
|
||||
`filePath is required.${EOL}Example: medusa-product-seed <filePath>`
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -33,11 +33,17 @@ export async function runMigrations({
|
||||
|
||||
try {
|
||||
const migrator = orm.getMigrator()
|
||||
await migrator.up()
|
||||
|
||||
logger?.info("Product module migration executed")
|
||||
const pendingMigrations = await migrator.getPendingMigrations()
|
||||
logger.info("Running pending migrations:", pendingMigrations)
|
||||
|
||||
await migrator.up({
|
||||
migrations: pendingMigrations.map((m) => m.name),
|
||||
})
|
||||
|
||||
logger.info("Product module migration executed")
|
||||
} catch (error) {
|
||||
logger?.error(`Product module migration failed to run - Error: ${error}`)
|
||||
logger.error(`Product module migration failed to run - Error: ${error}`)
|
||||
}
|
||||
|
||||
await orm.close()
|
||||
|
||||
@@ -1,35 +1,26 @@
|
||||
import { resolve } from "path"
|
||||
import { MikroORM, PostgreSqlDriver } from "@mikro-orm/postgresql"
|
||||
import { ProductServiceInitializeOptions } from "../types"
|
||||
import { TSMigrationGenerator } from "@mikro-orm/migrations"
|
||||
import { Utils } from "@mikro-orm/core"
|
||||
|
||||
export async function createConnection(
|
||||
database: ProductServiceInitializeOptions["database"],
|
||||
entities: any[]
|
||||
) {
|
||||
const schema = database.schema || "public"
|
||||
const orm = await MikroORM.init<PostgreSqlDriver>({
|
||||
discovery: { disableDynamicFileAccess: true },
|
||||
entities,
|
||||
debug: process.env.NODE_ENV === "development",
|
||||
baseDir: process.cwd(),
|
||||
clientUrl: database.clientUrl,
|
||||
schema: database.schema ?? "public",
|
||||
schema,
|
||||
driverOptions: database.driverOptions ?? {
|
||||
connection: { ssl: true },
|
||||
},
|
||||
tsNode: process.env.APP_ENV === "development",
|
||||
type: "postgresql",
|
||||
migrations: {
|
||||
path: resolve(__dirname, "../../dist/migrations"),
|
||||
pathTs: resolve(__dirname, "../../src/migrations"),
|
||||
glob: "!(*.d).{js,ts}",
|
||||
disableForeignKeys: false,
|
||||
silent: false,
|
||||
dropTables: false,
|
||||
transactional: true,
|
||||
allOrNothing: true,
|
||||
safe: true,
|
||||
generator: TSMigrationGenerator,
|
||||
path: Utils.detectTsNode() ? "src/migrations" : "dist/migrations",
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user