-
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
Changes from all commits
aabf248
c917e42
63f86fc
bb7f169
8515134
fe9aace
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@liam-hq/db-structure": patch | ||
--- | ||
|
||
:sparkles: prism's wasm URL can now be overridden | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,5 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
prism.wasm |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { parse } from '@liam-hq/db-structure/parser' | ||
// biome-ignore lint/correctness/noNodejsModules: Required for the server component to read the wasm file | ||
import path from 'node:path' | ||
import { parse, setPrismWasmUrl } from '@liam-hq/db-structure/parser' | ||
import { cookies } from 'next/headers' | ||
import { notFound } from 'next/navigation' | ||
import ERDViewer from './erdViewer' | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. process.cwd() gives the root path of Next.js. 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') | ||
if (errors.length > 0) { | ||
Comment on lines
+30
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temporarily changed to support only schema.rb. |
||
for (const error of errors) { | ||
console.error(error) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,9 @@ const gitCommitHash = execSync('git rev-parse --short HEAD').toString().trim() | |
const releaseDate = new Date().toISOString().split('T')[0] | ||
|
||
const nextConfig: NextConfig = { | ||
outputFileTracingIncludes: { | ||
'/erd/p/\\[\\.\\.\\.slug\\]': ['./prism.wasm'], | ||
}, | ||
Comment on lines
+9
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
env: { | ||
NEXT_PUBLIC_GIT_HASH: gitCommitHash, | ||
NEXT_PUBLIC_RELEASE_DATE: releaseDate, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Here it is ran with postinstall. |
||
"start": "next start" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ export { | |
parse, | ||
type SupportedFormat, | ||
supportedFormatSchema, | ||
setPrismWasmUrl, | ||
} from './parser/index.js' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ export { | |
processor, | ||
UnsupportedTokenError, | ||
} from './parser.js' | ||
export { setPrismWasmUrl } from './loadPrism.js' |
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.