fix(product): The bin scripts should include a shebang and import in the body (#4296)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user