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

new cli #79

Merged
merged 10 commits into from
Nov 13, 2024
Merged

new cli #79

merged 10 commits into from
Nov 13, 2024

Conversation

hoshinotsuyoshi
Copy link
Member

@hoshinotsuyoshi hoshinotsuyoshi commented Nov 8, 2024

Summary

This PR introduces a new CLI tool called liam that wraps Vite commands (build, dev, and preview). It includes a preprocessing feature for .sql files, converting them into a JSON format and saving them in the public directory.

Related Issue

N/A

Changes

  • Added liam CLI Tool:
    • Created bin/cli.ts using commander for command-line interface functionality.
    • Implemented runPreprocess function to read .sql files and convert them to schema.json in the public directory.
  • Sample SQL File:
    • Added fixtures/input.sql as a sample input for CLI testing.
  • Updated .gitignore:
    • Added dist-cli and public/schema.json to the ignore list.
  • Modified package.json:
    • Added a bin entry for liam.
    • Updated scripts to build and run the CLI tool.
    • Included commander and @types/commander as dependencies.
  • Updated TypeScript Configurations:
    • Enabled incremental builds and specified dist-cli as the output directory.
  • Changes to App.tsx:
    • Added logic to fetch schema.json asynchronously and display the content in the UI.
  • 7a6aa44 : $ pnpm add commander
  • 5270bee : Update dependencies
  • 27ba010 : Add 'incremental' option to avoid TS5111 error
  • f9c2de6 : Update tsconfig files to specify output directories
  • a6d8b88 : Implement initial CLI functionality and update package configuration
  • 2ccf588 : Display file content in a <pre> tag for demo purposes in App.tsx
  • 7bcd8d2 : Update README

Testing

1. Verifying CLI Functionality

# (cd to frontend/packages/cli)
# Clean up temporary directories for a fresh start
$ rm -rf dist dist-cli/ node_modules/.tmp
# Enable `liam` command.
$ pnpm run build:cli
$ pnpm link --global
$ cd (some other directory you like...)

$ echo 'brabra' > some.sql

$ liam erd build --input some.sql
# Outputs:
# - dist/
# - public/schema.json

$ liam erd preview

I confirmed that Preview server is running at http://localhost:4173

2024-11-08 16 25 56

2. Verifying npm Scripts

# (cd to frontend/packages/cli)
# Clean up temporary directories for a fresh start
$ rm -rf dist dist-cli/ node_modules/.tmp
$ pnpm run build
# Outputs:
# - dist/
# - public/schema.json

$ pnpm run preview

I confirmed that Preview server is running at http://localhost:4173 ✓ .

(Note: Running $ pnpm run build will display the contents of fixtures/input.sql.)

2024-11-08 16 08 06
$ pnpm run dev

I confirmed that Dev server is running at http://localhost:5173 ✓ .
HMR is worked ✓.

@hoshinotsuyoshi hoshinotsuyoshi self-assigned this Nov 8, 2024
Base automatically changed from setup-erd-generator to main November 8, 2024 06:39
@hoshinotsuyoshi hoshinotsuyoshi force-pushed the setup-erd-generator-cli branch from 6cc80b1 to 34f516b Compare November 8, 2024 06:53
- `@types/node` for bin/cli.ts
- move vite to dependencies from devDependencies
- Fixed TS5111 error: "Option 'tsBuildInfoFile' cannot be specified without specifying option 'incremental' or 'composite' or if not running 'tsc -b'."
- Added `"incremental": true` to both `tsconfig.app.json` and `tsconfig.node.json` to ensure TypeScript incremental builds are enabled.
- Added `"outDir": "dist"` to `tsconfig.app.json` to define the output directory for compiled web application files.
- Added `"outDir": "dist-cli"` and set `"noEmit": false` in `tsconfig.node.json` to enable emitting compiled files for the CLI.
- Updated `tsconfig.node.json` to include `bin` in the `include` paths for TypeScript compilation.
- Added `liam-cli` implementation using `commander` to run `build`, `dev`, and `preview` commands.
- Implemented SQL file preprocessing that converts `.sql` content to JSON and outputs it in the `public/schema.json`.
- Configured Vite options in `bin/cli.ts` for building and previewing the web application.
- Added `fixtures/input.sql` as a sample SQL file for testing.
- Updated `.gitignore` to exclude `dist-cli` and `public/schema.json`.
- Updated `package.json`:
  - Added `bin` configuration to expose `liam-cli`.
  - Defined npm scripts for building and running the CLI.
- Added a placeholder `.keep` file in the `public` directory.
- Added state and useEffect hook to fetch and display `/schema.json` content.
- Rendered the file content inside a styled <pre> tag for demonstration.
@hoshinotsuyoshi hoshinotsuyoshi force-pushed the setup-erd-generator-cli branch from 34f516b to 7bcd8d2 Compare November 8, 2024 07:35
@hoshinotsuyoshi hoshinotsuyoshi marked this pull request as ready for review November 8, 2024 07:39
@hoshinotsuyoshi hoshinotsuyoshi requested a review from a team as a code owner November 8, 2024 07:39
@hoshinotsuyoshi hoshinotsuyoshi requested review from FunamaYukina, junkisai, MH4GF and sasamuku and removed request for a team November 8, 2024 07:39
Copy link
Member

@MH4GF MH4GF left a comment

Choose a reason for hiding this comment

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

Thanks!!
I only check the README and commented on it!

frontend/packages/cli/README.md Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

Nice README! 😄

Copy link
Member

@FunamaYukina FunamaYukina left a comment

Choose a reason for hiding this comment

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

I followed the instructions in the README and was able to successfully test the build, dev, and preview commands, as well as the liam command in my local environment. 👍Thank you for your support!

frontend/packages/cli/bin/cli.ts Show resolved Hide resolved
@hoshinotsuyoshi hoshinotsuyoshi requested a review from a team as a code owner November 13, 2024 00:50
@hoshinotsuyoshi
Copy link
Member Author

hoshinotsuyoshi commented Nov 13, 2024

Resolved the conflict with #84 by aligning the changes made in this commit.

I've confirmed that everything mentioned under Testing is working as expected. ✅

 Conflicts:
	frontend/packages/cli/.gitignore
	frontend/packages/cli/package.json
	frontend/pnpm-lock.yaml
@hoshinotsuyoshi hoshinotsuyoshi added this pull request to the merge queue Nov 13, 2024
Merged via the queue into main with commit e41f2a1 Nov 13, 2024
6 checks passed
@hoshinotsuyoshi hoshinotsuyoshi deleted the setup-erd-generator-cli branch November 13, 2024 05:20
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.

3 participants