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

fix: Changes required for @prettier/sync v0.5.2 #151

Closed
TonyGravagno opened this issue Aug 29, 2024 · 3 comments
Closed

fix: Changes required for @prettier/sync v0.5.2 #151

TonyGravagno opened this issue Aug 29, 2024 · 3 comments

Comments

@TonyGravagno
Copy link
Collaborator

TonyGravagno commented Aug 29, 2024

We can't update from @prettier/sync v0.3.0 to the current 0.5.2 yet because of an issue noted in #150. These notes are only relevant when that package has been updated.

That package has changed its interfaces. Code in formatByPrettier.ts should be changed from this:

import prettier from "@prettier/sync";

export const formatByPrettier = (str: string): string =>
	prettier.format(str, {
		parser: "babel-ts",
	});

To something like this ref ReadMe :

import * as prettier from "prettier";
import makeSynchronized from "make-synchronized";
export default makeSynchronized(this, async function formatByPrettier(str: string) {
	return await prettier.format(str, {
		parser: "babel-ts",
	});
});

The package 'make-synchronized' will need to be added as a direct dependency in mysql-to-zod.

That will also require imports to be changed to something like this:

import formatByPrettier from "./formatByPrettier";

and code that uses that functionality might need to be modified:

const formatted = await formatByPrettier(schemaRawText);

Yes, I know the intent of using the "/sync" code is that the functionality needs to be synchronized (does it really?) but it seems async code must be wrapped in the synchronization process.

I don't understand all of this yet, I'm just reporting what I'm finding. :)

@araera111
Copy link
Owner

Thank you for your detailed report.

Since prettier is used for formatting purposes, any library that achieves the desired formatting will be acceptable. I will review the changes and consider updating to the new version, incorporating make-synchronized, and adapting the imports as needed.

Additionally, I will also explore whether biome can be used for formatting as an alternative.

Thank you again for bringing this to our attention. Your input is valuable as we work to address these issues.

@TonyGravagno
Copy link
Collaborator Author

Thanks. Hmm, I said we cannot update to prettier/sync v0.5.2 yet because of this issue: prettier/prettier-synchronized#22. However, I'm running that version now with the changes I provided above. Since the only problem is with running in debug mode, and we already have that problem with the current version anyway, maybe it's OK to update and then just update again when a new version is available with that one fix.

Sorry about the verbosity and confusion ... I'm learning these details as I'm working with the code...

@araera111 araera111 changed the title Changes required for @prettier/sync v0.5.2 feat: Changes required for @prettier/sync v0.5.2 Aug 30, 2024
@araera111 araera111 changed the title feat: Changes required for @prettier/sync v0.5.2 fix: Changes required for @prettier/sync v0.5.2 Aug 30, 2024
@araera111
Copy link
Owner

I've modified the code to use asynchronous prettier format function. Both during actual execution and while debugging, it seems to be working without any issues.

Thank you for bringing this to my attention!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants