add generated .medusa/types to local plugins (#13777)
Co-authored-by: Adrien de Peretti <adrien.deperetti@gmail.com>
This commit is contained in:
co-authored by
Adrien de Peretti
parent
fb11f0f272
commit
125694626e
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
feat(medusa): add generated .medusa/types to local plugins
|
||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
dynamicImport,
|
dynamicImport,
|
||||||
FileSystem,
|
FileSystem,
|
||||||
generateContainerTypes,
|
generateContainerTypes,
|
||||||
|
getResolvedPlugins,
|
||||||
gqlSchemaToTypes,
|
gqlSchemaToTypes,
|
||||||
GracefulShutdownServer,
|
GracefulShutdownServer,
|
||||||
isFileSkipped,
|
isFileSkipped,
|
||||||
@@ -272,28 +273,36 @@ async function start(args: {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (generateTypes) {
|
if (generateTypes) {
|
||||||
const typesDirectory = path.join(directory, ".medusa/types")
|
const configModule = container.resolve(
|
||||||
|
ContainerRegistrationKeys.CONFIG_MODULE
|
||||||
|
)
|
||||||
|
const localPlugins = (await getResolvedPlugins(directory, configModule, true))
|
||||||
|
.filter((p) => p.admin?.type === "local")
|
||||||
|
|
||||||
/**
|
for (const plugin of localPlugins) {
|
||||||
* Cleanup existing types directory before creating new artifacts
|
const typesDirectory = path.join(plugin.admin!.resolve, "../../.medusa/types")
|
||||||
*/
|
|
||||||
await new FileSystem(typesDirectory).cleanup({ recursive: true })
|
|
||||||
|
|
||||||
await generateContainerTypes(modules, {
|
/**
|
||||||
outputDir: typesDirectory,
|
* Cleanup existing types directory before creating new artifacts
|
||||||
interfaceName: "ModuleImplementations",
|
*/
|
||||||
})
|
await new FileSystem(typesDirectory).cleanup({ recursive: true })
|
||||||
logger.debug("Generated container types")
|
|
||||||
|
|
||||||
if (gqlSchema) {
|
await generateContainerTypes(modules, {
|
||||||
await gqlSchemaToTypes({
|
|
||||||
outputDir: typesDirectory,
|
outputDir: typesDirectory,
|
||||||
filename: "query-entry-points",
|
interfaceName: "ModuleImplementations",
|
||||||
interfaceName: "RemoteQueryEntryPoints",
|
|
||||||
schema: gqlSchema,
|
|
||||||
joinerConfigs: MedusaModule.getAllJoinerConfigs(),
|
|
||||||
})
|
})
|
||||||
logger.debug("Generated modules types")
|
logger.debug("Generated container types")
|
||||||
|
|
||||||
|
if (gqlSchema) {
|
||||||
|
await gqlSchemaToTypes({
|
||||||
|
outputDir: typesDirectory,
|
||||||
|
filename: "query-entry-points",
|
||||||
|
interfaceName: "RemoteQueryEntryPoints",
|
||||||
|
schema: gqlSchema,
|
||||||
|
joinerConfigs: MedusaModule.getAllJoinerConfigs(),
|
||||||
|
})
|
||||||
|
logger.debug("Generated modules types")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user