-
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
Call function to output DBStructure in cli
package
#88
Conversation
7eef20d
to
74345e4
Compare
- Add a `build` script to `frontend/package.json` and include build step in the CI workflow - Update CLI scripts to use `input.schema.rb` instead of `input.sql` - Modify smoke tests to reference the new input file format - Simplify `runPreprocess` function to use parsed schema input - Add a temporary workaround in `App.tsx` to set schema content - Refactor CLI documentation to reflect updated command usage
- Update `package.json` to specify ESM settings and adjust main/types entries - Add `generateParser.sh` script to simplify Peggy parser generation - Refactor imports in `parser.js` to use ES modules instead of CommonJS - Update TypeScript configuration for better ESM support and output - Adjust dependencies to use ESM versions of libraries like `lodash-es` and `pluralize-esm` - Add `.gitignore` to exclude `dist` directory from version control
759d859
to
cefb3e4
Compare
runPreprocess.ts
runPreprocess.ts
cli
package
frontend/packages/cli/package.json
Outdated
"dev": "pnpm run build:cli && node ./dist-cli/bin/cli.js erd dev --input ./fixtures/input.sql", | ||
"build": "pnpm run build:cli && node ./dist-cli/bin/cli.js erd build --input ./fixtures/input.sql", | ||
"preview": "pnpm run build:cli && node ./dist-cli/bin/cli.js erd preview", | ||
"build:cli": "tsc -p tsconfig.node.json", | ||
"command:dev": "pnpm run build && node ./dist-cli/bin/cli.js erd dev --input ./fixtures/input.schema.rb", | ||
"command:build": "pnpm run build && node ./dist-cli/bin/cli.js erd build --input ./fixtures/input.schema.rb", | ||
"command:preview": "pnpm run build && node ./dist-cli/bin/cli.js erd preview", | ||
"prebuild": "pnpm --filter @liam/db-structure run build", | ||
"build": "tsc -p tsconfig.node.json", |
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.
The scripts
have been updated:
build
now refers to building the CLI.command:build
now runsliam erd build --input ./fixtures/input.schema.rb
. This is intended for our development purposes.
frontend/packages/cli/package.json
Outdated
"test": "pnpm vitest" | ||
"test": "pnpm prebuild && pnpm vitest --watch=false" |
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.
- Added
--watch=false
to prevent the output from persisting in the terminal. - Calling
prebuild
to build the dependent packages beforehand for testing purposes.
I'm not entirely confident if this aligns perfectly with best practices for turbo
or pnpm workspaces
, but it seems to work well in my local environment.
"lodash.isequal": "^4.5.0", | ||
"lodash.sortby": "^4.7.0", | ||
"pluralize": "^8.0.0", | ||
"valibot": "^1.0.0-beta.5" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.9.3", | ||
"@packages/configs": "workspace:*", | ||
"lodash-es": "^4.17.21", | ||
"peggy": "^4.1.1", | ||
"pluralize-esm": "^9.0.5", |
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.
This is for ESM style.
- pluralize-esm is fork of https://github.com/plurals/pluralize .
- npm package: https://www.npmjs.com/package/pluralize-esm
- license: MIT
- lodash-es
- npm package: https://www.npmjs.com/package/lodash-es
- license: MIT (same as lodash)
--format es \ | ||
--dependencies \ | ||
'{ | ||
"pluralize": "pluralize-esm", | ||
"{ isEqual }": "lodash-es", | ||
"{ sortBy }": "lodash-es" | ||
}' \ |
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.
Settings for ESM style.
See --dependencies
options. doc: https://peggyjs.org/documentation.html
import schemaRbParser from './parser' | ||
import * as parser from './parser.js' | ||
|
||
export { schemaRbParser } | ||
export { parser } |
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.
This type of change is needed across all packages, but unfortunately, it can't be verified through unit tests within each package. We might need to add a lint rule (perhaps using eslint-plugin-import
?) to ensure this consistently.
"use strict"; | ||
import pluralize from "pluralize-esm"; | ||
import { isEqual } from "lodash-es"; | ||
import { sortBy } from "lodash-es"; |
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.
the effect of "gen:parser" script.
workaround {
"$schema": "https://turbo.build/schema.json",
"tasks": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist", "dist-cli"]
},
"dev": {
"cache": false,
"persistent": true
},
"gen": {
"dependsOn": ["^gen"]
},
"lint": {
"dependsOn": ["build", "gen", "^lint"]
},
"fmt": {},
"test": {
"outputs": []
},
"@liam/cli#test": {
"dependsOn": ["^build"]
}
}
} |
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 🚀
- Modified `.github/workflows/frontend-ci.yml` to run `pnpm lint` instead of `pnpm build && pnpm lint` - Updated `frontend/turbo.json` to add `^build` as a dependency for the `lint` task and specified `dist` and `dist-cli` as outputs for the `build` task
Summary
The
$ liam erd build --input
command now parses theschema.rb
format. This feature builds upon changes from PR #87 and PR #89.Related Issue
N/A
Changes
acbb208 : chore(cli): update build process and adjust input file references
build
script infrontend/package.json
and include build step in the CI workflowinput.schema.rb
instead ofinput.sql
App.tsx
to set schema contentf5d2c05 : db-structure: update package to use ESM and streamline parser generation
package.json
to specify ESM settings and adjust main/types entriesgenerateParser.sh
script to simplify Peggy parser generationparser.js
to use ES modules instead of CommonJSlodash-es
andpluralize-esm
.gitignore
to excludedist
directory from version controlcefb3e4 : chore(erd-core): add ESM support by specifying "type": "module" in package.json
"type": "module"
applied toerd-core
packageTesting
Setup:
Build the CLI:
Run the
build
andpreview
commands:Open http://localhost:4173, and you'll see the
users
table node, which is defined infixtures/input.schema.rb
.Other Information
N/A