Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename remote-query-entry-points.d.ts to query-entry-points.d.ts #10831

Merged
merged 4 commits into from
Jan 7, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/medusa/src/commands/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,23 @@ async function start(args: {
})

if (generateTypes) {
const typesDirectory = path.join(directory, ".medusa/types")

/**
* Cleanup existing types directory before creating new artifacts
*/
await new FileSystem(typesDirectory).cleanup({ recursive: true })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a hygiene, we should always remove existing files and then create new artifacts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think thats a good practice, but should we instead let each generator to clean up their own file to be sure we don't have other generated content that gets removed by mistake and not generated at the same time or from the same place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. That will be nice too. Right now, I was thinking of this flow

  • The .medusa/types directory is dedicated to writing generated output.
  • We cleanup this directory before we generate any new output.
  • Then dedicated actions will generate their output with clean slate.

But I agree, if one of those actions does not run under a certain condition, then the whole cleanup strategy won't work. For now, that's not the case, but I am happy to tweak the logic if you think we should address that right now 👍


await generateContainerTypes(modules, {
outputDir: path.join(directory, ".medusa/types"),
outputDir: typesDirectory,
interfaceName: "ModuleImplementations",
})
logger.debug("Generated container types")

if (gqlSchema) {
const outputDirGeneratedTypes = path.join(directory, ".medusa/types")
await gqlSchemaToTypes({
outputDir: outputDirGeneratedTypes,
filename: "remote-query-entry-points",
outputDir: typesDirectory,
filename: "query-entry-points",
interfaceName: "RemoteQueryEntryPoints",
schema: gqlSchema,
joinerConfigs: MedusaModule.getAllJoinerConfigs(),
Expand Down
Loading