@graphenedata/cli 0.0.10 → 0.0.12

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/bin.js ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {fileURLToPath} from 'url'
4
+ import {dirname, join} from 'path'
5
+ import {existsSync} from 'fs'
6
+
7
+ const __dirname = dirname(fileURLToPath(import.meta.url))
8
+ const devCli = join(__dirname, 'cli.ts')
9
+
10
+ // If Graphene has been npm-linked in, we can run cli.ts directly to avoid the build step
11
+ if (existsSync(devCli)) {
12
+ await import('./cli.ts')
13
+ } else {
14
+ await import('./dist/cli/cli.js')
15
+ }
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