-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
🦋 Changeset detectedLatest commit: fe9aace The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
ec06fa8
to
b67e2fe
Compare
b67e2fe
to
ee6fb21
Compare
ee6fb21
to
8515134
Compare
"@liam-hq/db-structure": patch | ||
--- | ||
|
||
:sparkles: prism's wasm URL can now be overridden |
There was a problem hiding this comment.
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')) |
There was a problem hiding this comment.
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
// Currently supports schema.rb only | ||
const { value: dbStructure, errors } = await parse(input, 'schemarb') |
There was a problem hiding this comment.
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.
outputFileTracingIncludes: { | ||
'/erd/p/\\[\\.\\.\\.slug\\]': ['./prism.wasm'], | ||
}, |
There was a problem hiding this comment.
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.
@@ -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", |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 🎉
Schema.rb format files can now be opened 👍🏻
https://liam-erd-de01oyuvp-route-06-core.vercel.app/erd/p/raw.githubusercontent.com/mastodon/mastodon/877090518682b6c77ba9bdfa0231afd56daec44d/db/schema.rb