@graphenedata/cli 0.0.10 → 0.0.11

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 CHANGED
@@ -5,6 +5,7 @@ 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 {fileURLToPath} from 'url'
8
9
  import dotenv from 'dotenv'
9
10
  import {config, loadConfig} from '../lang/config.ts'
10
11
  import {runServeInBackground, stopGrapheneIfRunning} from './background.ts'
@@ -14,8 +15,12 @@ import {loginPkce} from './auth.ts'
14
15
 
15
16
  dotenv.config({quiet: true})
16
17
  const program = new Command()
18
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
19
+ // in dev: cli/cli.ts -> cli/package.json. in dist: cli/dist/cli/cli.js -> cli/package.json
20
+ const pkgPath = fs.existsSync(path.join(__dirname, 'package.json')) ? path.join(__dirname, 'package.json') : path.join(__dirname, '../../package.json')
21
+ const pkg = fs.readJsonSync(pkgPath)
17
22
 
18
- program.name('graphene').description('Graphene CLI').version('1.0.0')
23
+ program.name('graphene').description('Graphene CLI').version(pkg.version, '-v, --version')
19
24
 
20
25
  program.hook('preAction', async () => {
21
26
  if (process.env.CLI_DELAY) { // useful if you want to attach a debugger