fix(modules-sdk): Resolve discovery location properly (#7345)
This commit is contained in:
@@ -187,7 +187,7 @@ export async function loadModuleMigrations(
|
|||||||
const migrationScriptOptions = {
|
const migrationScriptOptions = {
|
||||||
moduleName: resolution.definition.key,
|
moduleName: resolution.definition.key,
|
||||||
models: moduleResources.models,
|
models: moduleResources.models,
|
||||||
pathToMigrations: moduleResources.normalizedPath + "/dist/migrations",
|
pathToMigrations: moduleResources.normalizedPath + "/migrations",
|
||||||
}
|
}
|
||||||
|
|
||||||
runMigrations ??= ModulesSdkUtils.buildMigrationScript(
|
runMigrations ??= ModulesSdkUtils.buildMigrationScript(
|
||||||
@@ -238,7 +238,7 @@ async function loadResources(
|
|||||||
logger: Logger
|
logger: Logger
|
||||||
): Promise<ModuleResource> {
|
): Promise<ModuleResource> {
|
||||||
const modulePath = moduleResolution.resolutionPath as string
|
const modulePath = moduleResolution.resolutionPath as string
|
||||||
let normalizedPath = modulePath.replace("dist/", "").replace("index.js", "")
|
let normalizedPath = modulePath.replace("index.js", "")
|
||||||
normalizedPath = resolve(normalizedPath)
|
normalizedPath = resolve(normalizedPath)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -248,13 +248,11 @@ async function loadResources(
|
|||||||
|
|
||||||
const [moduleService, services, models, repositories] = await Promise.all([
|
const [moduleService, services, models, repositories] = await Promise.all([
|
||||||
import(modulePath).then((moduleExports) => moduleExports.default.service),
|
import(modulePath).then((moduleExports) => moduleExports.default.service),
|
||||||
importAllFromDir(resolve(normalizedPath, "dist", "services")).catch(
|
importAllFromDir(resolve(normalizedPath, "services")).catch(
|
||||||
defaultOnFail
|
defaultOnFail
|
||||||
),
|
),
|
||||||
importAllFromDir(resolve(normalizedPath, "dist", "models")).catch(
|
importAllFromDir(resolve(normalizedPath, "models")).catch(defaultOnFail),
|
||||||
defaultOnFail
|
importAllFromDir(resolve(normalizedPath, "repositories")).catch(
|
||||||
),
|
|
||||||
importAllFromDir(resolve(normalizedPath, "dist", "repositories")).catch(
|
|
||||||
defaultOnFail
|
defaultOnFail
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
@@ -277,7 +275,7 @@ async function loadResources(
|
|||||||
repositories: potentialRepositories,
|
repositories: potentialRepositories,
|
||||||
services: potentialServices,
|
services: potentialServices,
|
||||||
moduleResolution,
|
moduleResolution,
|
||||||
migrationPath: normalizedPath + "/dist/migrations",
|
migrationPath: normalizedPath + "/migrations",
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -286,7 +284,7 @@ async function loadResources(
|
|||||||
repositories: potentialRepositories,
|
repositories: potentialRepositories,
|
||||||
loaders: finalLoaders,
|
loaders: finalLoaders,
|
||||||
moduleService,
|
moduleService,
|
||||||
normalizedPath
|
normalizedPath,
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
@@ -363,7 +361,7 @@ function prepareLoaders({
|
|||||||
const connectionLoader = ModulesSdkUtils.mikroOrmConnectionLoaderFactory({
|
const connectionLoader = ModulesSdkUtils.mikroOrmConnectionLoaderFactory({
|
||||||
moduleName: moduleResolution.definition.key,
|
moduleName: moduleResolution.definition.key,
|
||||||
moduleModels: models,
|
moduleModels: models,
|
||||||
migrationsPath: migrationPath, //normalizedPath + "/dist/migrations",
|
migrationsPath: migrationPath,
|
||||||
})
|
})
|
||||||
finalLoaders.push(connectionLoader)
|
finalLoaders.push(connectionLoader)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user