fix: Commands loading entrypoints (#7404)
* fix: enable worker mode when executing user and migrate commands * refactor: do not enable worker mode for migrate command * refactor: auto detect is application is using ts-node * refactor: remove directories node from config * style: update comments next to enabling worker mode
This commit is contained in:
1 parent
c198e2329c
commit
965a50d483
5 files changed
+14
-21
No files matched your search
@@ -875,16 +875,6 @@ export type ConfigModule = {
|
|||||||
* :::
|
* :::
|
||||||
*/
|
*/
|
||||||
featureFlags: Record<string, boolean | string>
|
featureFlags: Record<string, boolean | string>
|
||||||
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*
|
|
||||||
* @privateRemarks
|
|
||||||
* Since this is a temporary config, maybe let's not include it in the generated reference for now.
|
|
||||||
*/
|
|
||||||
directories?: {
|
|
||||||
srcDir?: string
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PluginDetails = {
|
export type PluginDetails = {
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ const runLinkMigrations = async (directory) => {
|
|||||||
|
|
||||||
const main = async function ({ directory }) {
|
const main = async function ({ directory }) {
|
||||||
const args = process.argv
|
const args = process.argv
|
||||||
|
|
||||||
args.shift()
|
args.shift()
|
||||||
args.shift()
|
args.shift()
|
||||||
args.shift()
|
args.shift()
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ export default async function ({
|
|||||||
track("CLI_USER", { with_id: !!id })
|
track("CLI_USER", { with_id: !!id })
|
||||||
const app = express()
|
const app = express()
|
||||||
try {
|
try {
|
||||||
|
/**
|
||||||
|
* Enabling worker mode to prevent discovering/loading
|
||||||
|
* of API routes from the starter kit
|
||||||
|
*/
|
||||||
|
process.env.MEDUSA_WORKER_MODE = "worker"
|
||||||
|
|
||||||
const { container } = await loaders({
|
const { container } = await loaders({
|
||||||
directory,
|
directory,
|
||||||
expressApp: app,
|
expressApp: app,
|
||||||
|
|||||||
@@ -102,8 +102,5 @@ export default (rootDirectory: string): ConfigModule => {
|
|||||||
modules: configModule.modules ?? {},
|
modules: configModule.modules ?? {},
|
||||||
featureFlags: configModule?.featureFlags ?? {},
|
featureFlags: configModule?.featureFlags ?? {},
|
||||||
plugins: configModule?.plugins ?? [],
|
plugins: configModule?.plugins ?? [],
|
||||||
directories: configModule?.directories ?? {
|
|
||||||
srcDir: "dist",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,10 +106,7 @@ function resolvePlugin(pluginName: string): {
|
|||||||
|
|
||||||
export function getResolvedPlugins(
|
export function getResolvedPlugins(
|
||||||
rootDirectory: string,
|
rootDirectory: string,
|
||||||
configModule: {
|
configModule: ConfigModule,
|
||||||
plugins: ConfigModule["plugins"]
|
|
||||||
directories?: ConfigModule["directories"]
|
|
||||||
},
|
|
||||||
isMedusaProject = false
|
isMedusaProject = false
|
||||||
): undefined | PluginDetails[] {
|
): undefined | PluginDetails[] {
|
||||||
if (isMedusaProject) {
|
if (isMedusaProject) {
|
||||||
@@ -117,10 +114,14 @@ export function getResolvedPlugins(
|
|||||||
* Grab directory for loading resources inside a starter kit from
|
* Grab directory for loading resources inside a starter kit from
|
||||||
* the medusa-config file.
|
* the medusa-config file.
|
||||||
*
|
*
|
||||||
* This is because, we do not have a "dist" directory inside a starter
|
* When using ts-node we will read resources from "src" directory
|
||||||
* kit. Instead we discover resources from the "src" directory.
|
* otherwise from "dist" directory.
|
||||||
*/
|
*/
|
||||||
const extensionDirectoryPath = configModule.directories?.srcDir ?? "dist"
|
const extensionDirectoryPath = process[
|
||||||
|
Symbol.for("ts-node.register.instance")
|
||||||
|
]
|
||||||
|
? "src"
|
||||||
|
: "dist"
|
||||||
const extensionDirectory = path.join(rootDirectory, extensionDirectoryPath)
|
const extensionDirectory = path.join(rootDirectory, extensionDirectoryPath)
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user