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

cli init-command #399

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 166 additions & 1 deletion docs/packages-license.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


## Summary
* 889 MIT
* 904 MIT
* 59 ISC
* 30 Apache 2.0
* 14 Simplified BSD
Expand Down Expand Up @@ -753,6 +753,160 @@ LGPL-3.0-or-later permitted



<a name="@inquirer/checkbox"></a>
### @inquirer/checkbox v4.0.4
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/confirm"></a>
### @inquirer/confirm v5.1.1
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/core"></a>
### @inquirer/core v10.1.2
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/editor"></a>
### @inquirer/editor v4.2.1
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/expand"></a>
### @inquirer/expand v4.0.4
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/figures"></a>
### @inquirer/figures v1.0.9
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/input"></a>
### @inquirer/input v4.1.1
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/number"></a>
### @inquirer/number v3.0.4
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/password"></a>
### @inquirer/password v4.0.4
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/prompts"></a>
### @inquirer/prompts v7.2.1
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/rawlist"></a>
### @inquirer/rawlist v4.0.4
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/search"></a>
### @inquirer/search v3.0.4
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/select"></a>
### @inquirer/select v4.0.4
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@inquirer/type"></a>
### @inquirer/type v3.0.2
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="@isaacs/cliui"></a>
### @isaacs/cliui v8.0.2
####
Expand Down Expand Up @@ -11248,6 +11402,17 @@ Unknown manually approved



<a name="yoctocolors-cjs"></a>
### yoctocolors-cjs v2.1.2
####

##### Paths
* /home/runner/work/liam/liam

<a href="http://opensource.org/licenses/mit-license">MIT</a> permitted



<a name="zod"></a>
### zod v3.23.8
####
Expand Down
87 changes: 87 additions & 0 deletions frontend/packages/cli/bin/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,91 @@
#!/usr/bin/env node
import fs from 'node:fs/promises'
import path from 'node:path'
import inquirer from 'inquirer'
import { program } from '../src/index.js'

type WorkflowType = 'dsl' | 'pg_dump' | 'unsupported'

// Helper function to generate workflows
function generateWorkflow(type: WorkflowType) {
const workflows = {
dsl: 'Generating GitHub Actions Workflow for DSL-based parsing and ER build...',
pg_dump: 'Generating GitHub Actions Workflow for pg_dump and ERD build...',
unsupported:
'Error: Not supported. Please visit our documentation or discussion for help.',
}
console.info(workflows[type])

if (type !== 'unsupported') {
const fileName = 'liam-erd-workflow.yml'
const filePath = path.resolve(process.cwd(), fileName)
fs.writeFile(
filePath,
`# Example workflow for ${type}
# This is a placeholder for the actual workflow content.`,
)
console.info('')
console.info(`Workflow generated: ${filePath}`)
}
}

type DatabaseOrOrmTitle =
| 'Ruby on Rails'
| 'PostgreSQL'
| 'Prisma'
| 'Drizzle'
| 'Other'
type DatabaseOrOrmParseStrategy = 'nativeParsing' | 'usePgDump' | 'unsupported'
type DatabaseOrOrm = {
title: DatabaseOrOrmTitle
parseStrategy: DatabaseOrOrmParseStrategy
}

const databaseOrOrms: DatabaseOrOrm[] = [
{ title: 'Ruby on Rails', parseStrategy: 'nativeParsing' },
{ title: 'PostgreSQL', parseStrategy: 'usePgDump' },
{ title: 'Prisma', parseStrategy: 'unsupported' },
{ title: 'Drizzle', parseStrategy: 'unsupported' },
{ title: 'Other', parseStrategy: 'unsupported' },
]

async function runSetup() {
const databaseOrOrmTitles = databaseOrOrms.map(
(databaseOrOrm) => databaseOrOrm.title,
)
const { databaseOrOrm } = (await inquirer.prompt([
{
type: 'list',
name: 'databaseOrOrm',
message: 'Select Database or ORM:',
choices: databaseOrOrmTitles,
},
])) as { databaseOrOrm: DatabaseOrOrmTitle }
console.info(`Selected: ${databaseOrOrm}`)

const databaseOrOrm2 = databaseOrOrms.find((d) => d.title === databaseOrOrm)
if (databaseOrOrm2 === undefined) {
return
}
if (databaseOrOrm2.parseStrategy === 'nativeParsing') {
generateWorkflow('dsl')
return
}
if (databaseOrOrm2.parseStrategy === 'usePgDump') {
generateWorkflow('pg_dump')
} else {
generateWorkflow('unsupported')
}
}

program
.command('init')
.description('Initialize the setup process for your database or ORM')
.action(async () => {
console.info('')
console.info('👾 Welcome to the @liam-hq/cli setup process!')
console.info('')
await runSetup()
})

program.parse(process.argv)
1 change: 1 addition & 0 deletions frontend/packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
},
"dependencies": {
"commander": "12.1.0",
"inquirer": "12.3.0",
"react": "18.3.1",
"react-dom": "18",
"valibot": "^1.0.0-beta.5"
Expand Down
2 changes: 1 addition & 1 deletion frontend/packages/cli/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export default {
}),
execute('chmod +x dist-cli/bin/cli.js'),
],
external: ['commander'],
external: ['commander', 'inquirer'],
}
1 change: 1 addition & 0 deletions frontend/packages/cli/src/cli/smoke.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('CLI Smoke Test', () => {

Commands:
erd ERD commands
init Initialize the setup process for your database or ORM
help [command] display help for command
"
`)
Expand Down
Loading
Loading