goatchain-cli 0.0.67-beta.9 → 0.0.69

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/goatchain.mjs CHANGED
@@ -4,7 +4,7 @@ import fs from 'node:fs'
4
4
  import os from 'node:os'
5
5
  import path from 'node:path'
6
6
  import process from 'node:process'
7
- import { fileURLToPath } from 'node:url'
7
+ import { fileURLToPath, pathToFileURL } from 'node:url'
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url)
10
10
  const __dirname = path.dirname(__filename)
@@ -26,8 +26,53 @@ const wrapperPm
26
26
  : 'npm'
27
27
 
28
28
  const args = process.argv.slice(2)
29
- const forwardArgs = args[0] === 'opentui' ? args.slice(1) : args
30
- runOpentui(forwardArgs)
29
+ const routing = resolveRouting(args)
30
+
31
+ if (routing.target === 'opentui') {
32
+ runOpentui(routing.forwardArgs)
33
+ }
34
+ else {
35
+ await runInk()
36
+ }
37
+
38
+ function resolveRouting(argv) {
39
+ // Explicit `goatchain ink ...` forces the Ink TUI.
40
+ if (argv[0] === 'ink')
41
+ return { target: 'ink', forwardArgs: argv.slice(1) }
42
+ // Explicit `goatchain opentui ...` also routes to the opentui binary
43
+ // (kept for backwards compatibility; opentui is now the default).
44
+ if (argv[0] === 'opentui')
45
+ return { target: 'opentui', forwardArgs: argv.slice(1) }
46
+
47
+ // Default: everything goes to the opentui binary.
48
+ return { target: 'opentui', forwardArgs: argv }
49
+ }
50
+
51
+ async function runInk() {
52
+ const inkEntry = path.join(__dirname, '..', 'dist', 'ink.mjs')
53
+ if (!fs.existsSync(inkEntry)) {
54
+ console.error('[goatchain] Ink bundle missing: ' + inkEntry)
55
+ console.error('[goatchain] Try reinstalling goatchain-cli.')
56
+ process.exit(1)
57
+ }
58
+ // Inject wrapper identity so the in-process upgrade check targets the
59
+ // npm wrapper package rather than upstream `dimcode`.
60
+ process.env.DIMCODE_NPM_PACKAGE = 'goatchain-cli'
61
+ process.env.DIMCODE_NPM_PACKAGE_MANAGER = wrapperPm
62
+ // goatchain-cli is a beta-only channel: ignore any stable releases on the
63
+ // registry when deciding whether to upgrade.
64
+ process.env.DIMCODE_NPM_PACKAGE_BETA_ONLY = '1'
65
+ if (wrapperVersion)
66
+ process.env.DIMCODE_NPM_PACKAGE_VERSION = wrapperVersion
67
+ try {
68
+ await import(pathToFileURL(inkEntry).href)
69
+ }
70
+ catch (err) {
71
+ console.error('[goatchain] Failed to start Ink TUI:')
72
+ console.error(err)
73
+ process.exit(1)
74
+ }
75
+ }
31
76
 
32
77
  function runOpentui(restArgs) {
33
78
  const envPath = process.env.DIMCODE_BIN_PATH
@@ -49,8 +94,8 @@ function runOpentui(restArgs) {
49
94
  const archMap = { x64: 'x64', arm64: 'arm64' }
50
95
  const platform = platformMap[os.platform()] || os.platform()
51
96
  const arch = archMap[os.arch()] || os.arch()
52
- const base = 'dimcode-' + platform + '-' + arch
53
- const binary = platform === 'windows' ? 'dimcode.exe' : 'dimcode'
97
+ const base = 'goatchain-cli-' + platform + '-' + arch
98
+ const binary = platform === 'windows' ? 'goatchain.exe' : 'goatchain'
54
99
 
55
100
  if (process.env.DIMCODE_DEBUG) {
56
101
  console.error('[goatchain] Wrapper version: ' + wrapperVersion)