fix: exit process with a status code when build fails (#11206)
Fixes: FRMW-2897 CLOSES CLO-434 Still need the frontend Admin bundler to provide some way to know if the build has failed or not.
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"@medusajs/framework": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: exit process with a status code when build fails
|
||||||
@@ -315,12 +315,12 @@ export class Compiler {
|
|||||||
this.#logger.warn(
|
this.#logger.warn(
|
||||||
`Backend build completed with errors (${tracker.getSeconds()}s)`
|
`Backend build completed with errors (${tracker.getSeconds()}s)`
|
||||||
)
|
)
|
||||||
} else {
|
return false
|
||||||
this.#logger.info(
|
|
||||||
`Backend build completed successfully (${tracker.getSeconds()}s)`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.#logger.info(
|
||||||
|
`Backend build completed successfully (${tracker.getSeconds()}s)`
|
||||||
|
)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,7 +359,7 @@ export class Compiler {
|
|||||||
this.#logger.info(
|
this.#logger.info(
|
||||||
"Skipping admin build, since its disabled inside the medusa-config file"
|
"Skipping admin build, since its disabled inside the medusa-config file"
|
||||||
)
|
)
|
||||||
return false
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -435,12 +435,12 @@ export class Compiler {
|
|||||||
this.#logger.warn(
|
this.#logger.warn(
|
||||||
`Plugin build completed with errors (${tracker.getSeconds()}s)`
|
`Plugin build completed with errors (${tracker.getSeconds()}s)`
|
||||||
)
|
)
|
||||||
} else {
|
return false
|
||||||
this.#logger.info(
|
|
||||||
`Plugin build completed successfully (${tracker.getSeconds()}s)`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.#logger.info(
|
||||||
|
`Plugin build completed successfully (${tracker.getSeconds()}s)`
|
||||||
|
)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,23 +7,28 @@ export default async function build({
|
|||||||
}: {
|
}: {
|
||||||
directory: string
|
directory: string
|
||||||
adminOnly: boolean
|
adminOnly: boolean
|
||||||
}): Promise<boolean> {
|
}) {
|
||||||
logger.info("Starting build...")
|
logger.info("Starting build...")
|
||||||
const compiler = new Compiler(directory, logger)
|
const compiler = new Compiler(directory, logger)
|
||||||
|
|
||||||
const tsConfig = await compiler.loadTSConfigFile()
|
const tsConfig = await compiler.loadTSConfigFile()
|
||||||
if (!tsConfig) {
|
if (!tsConfig) {
|
||||||
logger.error("Unable to compile application")
|
logger.error("Unable to compile application")
|
||||||
return false
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const promises: Promise<any>[] = []
|
const promises: Promise<boolean>[] = []
|
||||||
if (!adminOnly) {
|
if (!adminOnly) {
|
||||||
promises.push(compiler.buildAppBackend(tsConfig))
|
promises.push(compiler.buildAppBackend(tsConfig))
|
||||||
}
|
}
|
||||||
|
|
||||||
const bundler = await import("@medusajs/admin-bundler")
|
const bundler = await import("@medusajs/admin-bundler")
|
||||||
promises.push(compiler.buildAppFrontend(adminOnly, tsConfig, bundler))
|
promises.push(compiler.buildAppFrontend(adminOnly, tsConfig, bundler))
|
||||||
await Promise.all(promises)
|
const responses = await Promise.all(promises)
|
||||||
return true
|
|
||||||
|
if (responses.every((response) => response === true)) {
|
||||||
|
process.exit(0)
|
||||||
|
} else {
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,24 @@
|
|||||||
import { Compiler } from "@medusajs/framework/build-tools"
|
import { Compiler } from "@medusajs/framework/build-tools"
|
||||||
import { logger } from "@medusajs/framework/logger"
|
import { logger } from "@medusajs/framework/logger"
|
||||||
export default async function build({
|
export default async function build({ directory }: { directory: string }) {
|
||||||
directory,
|
|
||||||
}: {
|
|
||||||
directory: string
|
|
||||||
}): Promise<boolean> {
|
|
||||||
logger.info("Starting build...")
|
logger.info("Starting build...")
|
||||||
const compiler = new Compiler(directory, logger)
|
const compiler = new Compiler(directory, logger)
|
||||||
|
|
||||||
const tsConfig = await compiler.loadTSConfigFile()
|
const tsConfig = await compiler.loadTSConfigFile()
|
||||||
if (!tsConfig) {
|
if (!tsConfig) {
|
||||||
logger.error("Unable to compile plugin")
|
logger.error("Unable to compile plugin")
|
||||||
return false
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
const bundler = await import("@medusajs/admin-bundler")
|
const bundler = await import("@medusajs/admin-bundler")
|
||||||
await compiler.buildPluginBackend(tsConfig)
|
const responses = await Promise.all([
|
||||||
await compiler.buildPluginAdminExtensions(bundler)
|
compiler.buildPluginBackend(tsConfig),
|
||||||
return true
|
compiler.buildPluginAdminExtensions(bundler),
|
||||||
|
])
|
||||||
|
|
||||||
|
if (responses.every((response) => response === true)) {
|
||||||
|
process.exit(0)
|
||||||
|
} else {
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user