@graphenedata/cli 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.ts +39 -6
- package/dist/cli/cli.js +407 -157
- package/dist/docs/graphene.md +4 -38
- package/dist/ui/app.css +33 -2
- package/dist/ui/component-utilities/echarts.js +10 -1
- package/dist/ui/internal/NavSidebar.svelte +383 -0
- package/dist/ui/internal/telemetry.ts +2 -1
- package/dist/ui/public/inter-latin-ext.woff2 +0 -0
- package/dist/ui/public/inter-latin.woff2 +0 -0
- package/dist/ui/web.js +15 -16
- package/package.json +7 -6
- package/dist/ui/playwright.config.ts +0 -30
- /package/dist/ui/{assets → public}/favicon.ico +0 -0
package/cli.ts
CHANGED
|
@@ -5,18 +5,17 @@ import {printDiagnostics, printTable} from './printer.ts'
|
|
|
5
5
|
import {analyze, getDiagnostics, loadWorkspace, toSql, type Query} from '../lang/core.ts'
|
|
6
6
|
import fs from 'fs-extra'
|
|
7
7
|
import path from 'path'
|
|
8
|
-
import
|
|
8
|
+
import dotenv from 'dotenv'
|
|
9
|
+
import {config, loadConfig} from '../lang/config.ts'
|
|
9
10
|
import {runServeInBackground, stopGrapheneIfRunning} from './background.ts'
|
|
10
11
|
import {check} from './check.ts'
|
|
11
|
-
import {runQuery} from './connections/index.ts'
|
|
12
|
+
import {getConnection, runQuery} from './connections/index.ts'
|
|
12
13
|
import {loginPkce} from './auth.ts'
|
|
13
14
|
|
|
15
|
+
dotenv.config({quiet: true})
|
|
14
16
|
const program = new Command()
|
|
15
17
|
|
|
16
|
-
program
|
|
17
|
-
.name('graphene')
|
|
18
|
-
.description('Graphene CLI')
|
|
19
|
-
.version('1.0.0')
|
|
18
|
+
program.name('graphene').description('Graphene CLI').version('1.0.0')
|
|
20
19
|
|
|
21
20
|
program.hook('preAction', async () => {
|
|
22
21
|
if (process.env.CLI_DELAY) { // useful if you want to attach a debugger
|
|
@@ -51,6 +50,40 @@ program
|
|
|
51
50
|
printTable(res.rows)
|
|
52
51
|
})
|
|
53
52
|
|
|
53
|
+
program.command('schema')
|
|
54
|
+
.description('Inspect database tables or describe a table')
|
|
55
|
+
.argument('[schema | table]', 'Optional schema or table name to describe')
|
|
56
|
+
.action(async (tableArg: string) => {
|
|
57
|
+
let connection = await getConnection()
|
|
58
|
+
let datasets = await connection.listDatasets()
|
|
59
|
+
|
|
60
|
+
// if there's no arg and more than one dataset, just list the datasets
|
|
61
|
+
if (!tableArg && datasets.length > 1) {
|
|
62
|
+
return console.log(`Datasets available:\n${datasets.join('\n')}`)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// figure out if you're wanting to list tables in a schema/dataset
|
|
66
|
+
let dsToList: string | null = null
|
|
67
|
+
let parts = tableArg ? tableArg.split('.') : []
|
|
68
|
+
if (datasets.includes(tableArg)) dsToList = tableArg // you gave the name of a dataset
|
|
69
|
+
else if (!tableArg && datasets.length == 1) dsToList = datasets[0] // only one dataset, and no args
|
|
70
|
+
else if (!tableArg && config.namespace) dsToList = config.namespace // default namespace configured
|
|
71
|
+
else if (!tableArg && config.dialect == 'duckdb') dsToList = '<default>'
|
|
72
|
+
else if (tableArg && config.dialect == 'snowflake' && parts.length == 2) dsToList = tableArg
|
|
73
|
+
|
|
74
|
+
if (dsToList) {
|
|
75
|
+
let tables = await connection.listTables(dsToList)
|
|
76
|
+
return console.log(`Tables${dsToList ? ` in ${dsToList}` : ''}:\n${tables.join('\n')}`)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// otherwise, assume you're wanting to see tables
|
|
80
|
+
let cols = await connection.describeTable(tableArg)
|
|
81
|
+
if (!cols.length) return console.log(`Table ${tableArg} not found`)
|
|
82
|
+
console.log(`table ${tableArg} (`)
|
|
83
|
+
cols.forEach(col => console.log(` ${col.name} ${col.dataType}`))
|
|
84
|
+
console.log(')')
|
|
85
|
+
})
|
|
86
|
+
|
|
54
87
|
program
|
|
55
88
|
.command('serve')
|
|
56
89
|
.description('Run the local server')
|