chore(modules-sdk): Small fix to error wording (#7526)
* chore(modules-sdk): Small fix to error wording * rename variables * fix tests * rename plugins to providers in tests
This commit is contained in:
1 parent
e73b6ce691
commit
65ee18c5bc
5 files changed
+13
-13
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -21,7 +21,7 @@ describe("modules loader", () => {
|
|||||||
it("should register the provider service", async () => {
|
it("should register the provider service", async () => {
|
||||||
const moduleProviders = [
|
const moduleProviders = [
|
||||||
{
|
{
|
||||||
resolve: "@plugins/default",
|
resolve: "@providers/default",
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -46,7 +46,7 @@ describe("modules loader", () => {
|
|||||||
}
|
}
|
||||||
const moduleProviders = [
|
const moduleProviders = [
|
||||||
{
|
{
|
||||||
resolve: "@plugins/default",
|
resolve: "@providers/default",
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -65,7 +65,7 @@ describe("modules loader", () => {
|
|||||||
it("should log the errors if no service is defined", async () => {
|
it("should log the errors if no service is defined", async () => {
|
||||||
const moduleProviders = [
|
const moduleProviders = [
|
||||||
{
|
{
|
||||||
resolve: "@plugins/no-service",
|
resolve: "@providers/no-service",
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -74,7 +74,7 @@ describe("modules loader", () => {
|
|||||||
await moduleProviderLoader({ container, providers: moduleProviders })
|
await moduleProviderLoader({ container, providers: moduleProviders })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).toBe(
|
expect(error.message).toBe(
|
||||||
"No services found in plugin @plugins/no-service -- make sure your plugin has a default export of services."
|
"@providers/no-service doesn't seem to have a main service exported -- make sure your module has a default export of a service."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -82,7 +82,7 @@ describe("modules loader", () => {
|
|||||||
it("should throw if no default export is defined", async () => {
|
it("should throw if no default export is defined", async () => {
|
||||||
const moduleProviders = [
|
const moduleProviders = [
|
||||||
{
|
{
|
||||||
resolve: "@plugins/no-default",
|
resolve: "@providers/no-default",
|
||||||
options: {},
|
options: {},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@@ -91,7 +91,7 @@ describe("modules loader", () => {
|
|||||||
await moduleProviderLoader({ container, providers: moduleProviders })
|
await moduleProviderLoader({ container, providers: moduleProviders })
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error.message).toBe(
|
expect(error.message).toBe(
|
||||||
"No services found in plugin @plugins/no-default -- make sure your plugin has a default export of services."
|
"@providers/no-default doesn't seem to have a main service exported -- make sure your module has a default export of a service."
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export async function moduleProviderLoader({
|
|||||||
registerServiceFn?: (
|
registerServiceFn?: (
|
||||||
klass,
|
klass,
|
||||||
container: MedusaContainer,
|
container: MedusaContainer,
|
||||||
pluginDetails: any
|
moduleDetails: any
|
||||||
) => Promise<void>
|
) => Promise<void>
|
||||||
}) {
|
}) {
|
||||||
if (!providers?.length) {
|
if (!providers?.length) {
|
||||||
@@ -20,8 +20,8 @@ export async function moduleProviderLoader({
|
|||||||
}
|
}
|
||||||
|
|
||||||
await promiseAll(
|
await promiseAll(
|
||||||
providers.map(async (pluginDetails) => {
|
providers.map(async (moduleDetails) => {
|
||||||
await loadModuleProvider(container, pluginDetails, registerServiceFn)
|
await loadModuleProvider(container, moduleDetails, registerServiceFn)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -29,11 +29,11 @@ export async function moduleProviderLoader({
|
|||||||
export async function loadModuleProvider(
|
export async function loadModuleProvider(
|
||||||
container: MedusaContainer,
|
container: MedusaContainer,
|
||||||
provider: ModuleProvider,
|
provider: ModuleProvider,
|
||||||
registerServiceFn?: (klass, container, pluginDetails) => Promise<void>
|
registerServiceFn?: (klass, container, moduleDetails) => Promise<void>
|
||||||
) {
|
) {
|
||||||
let loadedProvider: any
|
let loadedProvider: any
|
||||||
|
|
||||||
const pluginName = provider.resolve ?? provider.provider_name ?? ""
|
const moduleName = provider.resolve ?? provider.provider_name ?? ""
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loadedProvider = provider.resolve
|
loadedProvider = provider.resolve
|
||||||
@@ -43,7 +43,7 @@ export async function loadModuleProvider(
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unable to find plugin ${pluginName} -- perhaps you need to install its package?`
|
`Unable to find module ${moduleName} -- perhaps you need to install its package?`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ export async function loadModuleProvider(
|
|||||||
|
|
||||||
if (!loadedProvider?.services?.length) {
|
if (!loadedProvider?.services?.length) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No services found in plugin ${provider.resolve} -- make sure your plugin has a default export of services.`
|
`${provider.resolve} doesn't seem to have a main service exported -- make sure your module has a default export of a service.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user