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

web: support schema.rb for rendering ER diagrams #388

Merged
merged 6 commits into from
Dec 26, 2024

Conversation

MH4GF
Copy link
Member

@MH4GF MH4GF commented Dec 26, 2024

Copy link

changeset-bot bot commented Dec 26, 2024

🦋 Changeset detected

Latest commit: fe9aace

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@liam-hq/db-structure Patch
@liam-hq/erd-web Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

"@liam-hq/db-structure": patch
---

:sparkles: prism's wasm URL can now be overridden
Copy link
Member Author

Choose a reason for hiding this comment

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

📝 Only db-structure is bumped because it is not used in cli.

@@ -23,8 +25,10 @@ export default async function Page({

const input = await res.text()

// Currently supports Postgres only
const { value: dbStructure, errors } = await parse(input, 'postgres')
setPrismWasmUrl(path.resolve(process.cwd(), 'prism.wasm'))
Copy link
Member Author

Choose a reason for hiding this comment

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

process.cwd() gives the root path of Next.js.
By following the file from here, the wasm file can be accessed in the local environment as well as on Vercel.

ref: Reading files on Vercel during Next.js ISR | François Best

Comment on lines +30 to +31
// Currently supports schema.rb only
const { value: dbStructure, errors } = await parse(input, 'schemarb')
Copy link
Member Author

Choose a reason for hiding this comment

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

Temporarily changed to support only schema.rb.
I plan to create a PR to implement the format identification process after this.

Comment on lines +4 to +6
outputFileTracingIncludes: {
'/erd/p/\\[\\.\\.\\.slug\\]': ['./prism.wasm'],
},
Copy link
Member Author

Choose a reason for hiding this comment

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

Define the file to be referenced from the request handler function corresponding to the path on Vercel.

ref: How can I use files in Vercel Functions?

@@ -24,6 +24,7 @@
"fmt:biome": "biome check --write --unsafe .",
"lint": "pnpm run '/^lint:.*/'",
"lint:biome": "biome check .",
"postinstall": "cp ../../packages/db-structure/src/parser/schemarb/prism.wasm prism.wasm",
Copy link
Member Author

Choose a reason for hiding this comment

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

Here it is ran with postinstall.
There is a possible way to include it in the webpack bundle with CopyWebpackPlugin, but the new turbopack for Next.js that we are currently using is not compatible with the webpack plugin, so I did not adopt it.

@MH4GF MH4GF marked this pull request as ready for review December 26, 2024 06:54
@MH4GF MH4GF requested a review from a team as a code owner December 26, 2024 06:54
@MH4GF MH4GF requested review from hoshinotsuyoshi, FunamaYukina, junkisai and sasamuku and removed request for a team December 26, 2024 06:54
Copy link
Member

@sasamuku sasamuku left a comment

Choose a reason for hiding this comment

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

LGTM!
Now we can see schemarb on Web 🎉

@MH4GF MH4GF enabled auto-merge December 26, 2024 08:53
@MH4GF MH4GF added this pull request to the merge queue Dec 26, 2024
Merged via the queue into main with commit 016ac22 Dec 26, 2024
13 checks passed
@MH4GF MH4GF deleted the support-schema-rb-for-web branch December 26, 2024 08:55
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

Successfully merging this pull request may close these issues.

2 participants