fix(product): The bin scripts should include a shebang and import in the body (#4296)

This commit is contained in:
Adrien de Peretti
2023-06-15 19:42:49 +02:00
committed by GitHub
parent 1d91fa4e08
commit 30d89044f1
11 changed files with 82 additions and 124 deletions
@@ -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()
+3 -1
View File
@@ -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>`
)
}
+9 -3
View File
@@ -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()