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:
@@ -40,7 +40,7 @@ export type AdminOptions = {
|
||||
/**
|
||||
* Configure the Vite configuration for the admin dashboard. This function receives the default Vite configuration
|
||||
* and returns the modified configuration. The default value is `undefined`.
|
||||
*
|
||||
*
|
||||
* @privateRemarks TODO Add example
|
||||
*/
|
||||
vite?: (config: InlineConfig) => InlineConfig
|
||||
@@ -401,9 +401,9 @@ export type ProjectConfigOptions = {
|
||||
* // ...
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
*
|
||||
* @deprecated use {@link http }'s `compression` property instead.
|
||||
*
|
||||
*
|
||||
*/
|
||||
http_compression?: HttpCompressionOptions
|
||||
|
||||
@@ -751,7 +751,7 @@ export type ConfigModule = {
|
||||
|
||||
/**
|
||||
* Admin dashboard configurations.
|
||||
*
|
||||
*
|
||||
* @example
|
||||
* ```js title="medusa-config.js"
|
||||
* module.exports = {
|
||||
@@ -875,16 +875,6 @@ export type ConfigModule = {
|
||||
* :::
|
||||
*/
|
||||
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 = {
|
||||
|
||||
@@ -42,7 +42,6 @@ const runLinkMigrations = async (directory) => {
|
||||
|
||||
const main = async function ({ directory }) {
|
||||
const args = process.argv
|
||||
|
||||
args.shift()
|
||||
args.shift()
|
||||
args.shift()
|
||||
|
||||
@@ -20,6 +20,12 @@ export default async function ({
|
||||
track("CLI_USER", { with_id: !!id })
|
||||
const app = express()
|
||||
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({
|
||||
directory,
|
||||
expressApp: app,
|
||||
|
||||
@@ -102,8 +102,5 @@ export default (rootDirectory: string): ConfigModule => {
|
||||
modules: configModule.modules ?? {},
|
||||
featureFlags: configModule?.featureFlags ?? {},
|
||||
plugins: configModule?.plugins ?? [],
|
||||
directories: configModule?.directories ?? {
|
||||
srcDir: "dist",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,10 +106,7 @@ function resolvePlugin(pluginName: string): {
|
||||
|
||||
export function getResolvedPlugins(
|
||||
rootDirectory: string,
|
||||
configModule: {
|
||||
plugins: ConfigModule["plugins"]
|
||||
directories?: ConfigModule["directories"]
|
||||
},
|
||||
configModule: ConfigModule,
|
||||
isMedusaProject = false
|
||||
): undefined | PluginDetails[] {
|
||||
if (isMedusaProject) {
|
||||
@@ -117,10 +114,14 @@ export function getResolvedPlugins(
|
||||
* Grab directory for loading resources inside a starter kit from
|
||||
* the medusa-config file.
|
||||
*
|
||||
* This is because, we do not have a "dist" directory inside a starter
|
||||
* kit. Instead we discover resources from the "src" directory.
|
||||
* When using ts-node we will read resources from "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)
|
||||
return [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user