Skip to content

Commit

Permalink
Merge branch 'main' into feat/erd-header
Browse files Browse the repository at this point in the history
  • Loading branch information
junkisai committed Dec 3, 2024
2 parents ddfc434 + 8bd97ba commit 99efc55
Show file tree
Hide file tree
Showing 19 changed files with 119 additions and 3,308 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,19 @@ jobs:
- uses: ./.github/actions/pnpm-setup
with:
working-directory: ${{ env.working-directory }}

- name: Create GitHub App Token
uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.CI_TRIGGER_APP_ID }}
private-key: ${{ secrets.CI_TRIGGER_APP_PRIVATE_KEY }}

- name: Create Release Pull Request or Publish to npm
uses: changesets/[email protected]
with:
cwd: ${{ env.working-directory }}
publish: pnpm changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions frontend/.changeset/metal-crabs-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@liam-hq/cli": patch
---

Use GitHub App Token for release workflow in GitHub Actions
2 changes: 1 addition & 1 deletion frontend/docs/packages-license.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ As of December 3, 2024 6:41am. 996 total
* 59 ISC
* 28 Apache 2.0
* 14 Simplified BSD
* 12 New BSD
* 11 New BSD
* 3 MIT OR Apache-2.0
* 3 BlueOak-1.0.0
* 2 LGPL-3.0-or-later
Expand Down
3 changes: 2 additions & 1 deletion frontend/packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
},
"scripts": {
"build": "pnpm run '/^build:.*/'",
"build:cli": "rollup -c",
"build:cli": "rollup -c && pnpm run cp:prism",
"build:vite": "vite build",
"command:build": "node ./dist-cli/bin/cli.js erd build --input fixtures/input.schema.rb",
"cp:prism": "cp ../db-structure/node_modules/@ruby/prism/src/prism.wasm ./dist-cli/bin/prism.wasm",
"dev": "pnpm command:build && cp dist/schema.json public/ && pnpm run '/^dev:.*/'",
"dev:app": "vite",
"dev:css": "tcm src --watch",
Expand Down
8 changes: 4 additions & 4 deletions frontend/packages/cli/src/cli/runPreprocess.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { describe, expect, it } from 'vitest'
import { runPreprocess } from './runPreprocess'

describe('runPreprocess', () => {
it('should create schema.json with the SQL content in the specified directory', () => {
it('should create schema.json with the SQL content in the specified directory', async () => {
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-distDir-'))
const inputPath = path.join(tmpDir, 'input.sql')

const sqlContent = 'CREATE TABLE test (id INT, name VARCHAR(255));'
fs.writeFileSync(inputPath, sqlContent, 'utf8')

const outputFilePath = runPreprocess(inputPath, tmpDir)
const outputFilePath = await runPreprocess(inputPath, tmpDir)
if (!outputFilePath) throw new Error('Implement the test')

expect(fs.existsSync(outputFilePath)).toBe(true)
Expand All @@ -21,11 +21,11 @@ describe('runPreprocess', () => {
expect(outputContent.tables).toBeDefined()
})

it('should throw an error if the input file does not exist', () => {
it('should throw an error if the input file does not exist', async () => {
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'test-distDir-'))
const nonExistentPath = path.join(tmpDir, 'non-existent.sql')

expect(() => runPreprocess(nonExistentPath, tmpDir)).toThrow(
await expect(runPreprocess(nonExistentPath, tmpDir)).rejects.toThrow(
'Invalid input path. Please provide a valid file.',
)
})
Expand Down
4 changes: 2 additions & 2 deletions frontend/packages/cli/src/cli/runPreprocess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs, { readFileSync } from 'node:fs'
import path from 'node:path'
import { parse } from '@liam-hq/db-structure/parser'

export function runPreprocess(inputPath: string, outputDir: string) {
export async function runPreprocess(inputPath: string, outputDir: string) {
if (!fs.existsSync(inputPath)) {
throw new Error('Invalid input path. Please provide a valid file.')
}
Expand All @@ -11,7 +11,7 @@ export function runPreprocess(inputPath: string, outputDir: string) {

// TODO: Expand support to additional formats, e.g., 'postgres'
const format = 'schemarb'
const json = parse(input, format)
const json = await parse(input, format)

const filePath = path.join(outputDir, 'schema.json')

Expand Down
4 changes: 0 additions & 4 deletions frontend/packages/db-structure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@
"@biomejs/biome": "1.9.3",
"@liam-hq/configs": "workspace:*",
"@pgsql/types": "15.0.2",
"lodash-es": "4.17.21",
"peggy": "4.1.1",
"pluralize-esm": "9.0.5",
"typescript": "5",
"vitest": "2.1.4"
},
"scripts": {
"build": "tsc",
"fmt": "pnpm run '/^fmt:.*/'",
"fmt:biome": "biome check --write --unsafe .",
"gen:parser": "./scripts/generateParser.sh",
"lint": "pnpm run '/^lint:.*/'",
"lint:biome": "biome check .",
"lint:tsc": "tsc --noEmit",
Expand Down
12 changes: 0 additions & 12 deletions frontend/packages/db-structure/scripts/generateParser.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ exports[`parse > should parse schema.rb to JSON correctly 1`] = `
"default": null,
"increment": false,
"name": "id",
"notNull": false,
"notNull": true,
"primary": true,
"type": "varchar",
"unique": false,
"type": "uuid",
"unique": true,
},
"is_deleted": {
"check": null,
Expand Down
5 changes: 1 addition & 4 deletions frontend/packages/db-structure/src/parser/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { DBStructure } from 'src/schema/index.js'
import { processor as schemarbPrismProcessor } from './schemarb-prism/index.js'
import { processor as schemarbProcessor } from './schemarb/index.js'
import { processor as postgresqlProcessor } from './sql/index.js'

type SupportedFormat = 'schemarb' | 'postgres' | 'schemarb-prism'
type SupportedFormat = 'schemarb' | 'postgres'

// TODO: Add error handling and tests
export const parse = (
Expand All @@ -13,8 +12,6 @@ export const parse = (
switch (format) {
case 'schemarb':
return schemarbProcessor(str)
case 'schemarb-prism':
return schemarbPrismProcessor(str)
case 'postgres':
return postgresqlProcessor(str)
default:
Expand Down
170 changes: 0 additions & 170 deletions frontend/packages/db-structure/src/parser/schemarb-prism/index.test.ts

This file was deleted.

This file was deleted.

33 changes: 0 additions & 33 deletions frontend/packages/db-structure/src/parser/schemarb/converter.ts

This file was deleted.

Loading

0 comments on commit 99efc55

Please sign in to comment.