@tgrv/cli 1.0.0

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.
Files changed (3) hide show
  1. package/bin/tgrv.exe +0 -0
  2. package/index.js +51 -0
  3. package/package.json +13 -0
package/bin/tgrv.exe ADDED
Binary file
package/index.js ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env node
2
+
3
+ import os from 'os';
4
+ import path from 'path';
5
+ import fs from 'fs';
6
+ import { createRequire } from 'module';
7
+ import { spawn } from 'child_process';
8
+ import { fileURLToPath } from 'url';
9
+
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = path.dirname(__filename);
12
+ const require = createRequire(import.meta.url);
13
+
14
+ const platform = os.platform();
15
+ const arch = os.arch();
16
+ const pkgName = `@tgrv/tgrv-${platform}-${arch}`;
17
+ const binName = platform === 'win32' ? 'tgrv.exe' : 'tgrv';
18
+
19
+ function resolveBinary() {
20
+ // 1. Resolve via optionalDependencies
21
+ try {
22
+ const pkgPath = require.resolve(`${pkgName}/package.json`);
23
+ const binaryPath = path.join(path.dirname(pkgPath), 'bin', binName);
24
+ if (fs.existsSync(binaryPath)) return binaryPath;
25
+ } catch (e) {}
26
+
27
+ // 2. Monorepo fallback (local dev)
28
+ const monorepoPath = path.join(__dirname, '..', `tgrv-${platform}-${arch}`, 'bin', binName);
29
+ if (fs.existsSync(monorepoPath)) return monorepoPath;
30
+
31
+ // 3. Fallback to sibling bin
32
+ const siblingBin = path.join(__dirname, 'bin', binName);
33
+ if (fs.existsSync(siblingBin)) return siblingBin;
34
+
35
+ return null;
36
+ }
37
+
38
+ const binaryPath = resolveBinary();
39
+
40
+ if (!binaryPath) {
41
+ console.error(`\n[TGRV FATAL] Binary not found for platform: ${platform}-${arch}`);
42
+ console.error(`Optional dependency '${pkgName}' might have failed to install.\n`);
43
+ process.exit(1);
44
+ }
45
+
46
+ const args = process.argv.slice(2);
47
+ const tgrv = spawn(binaryPath, args, { stdio: 'inherit' });
48
+
49
+ tgrv.on('exit', (code) => {
50
+ process.exit(code || 0);
51
+ });
package/package.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "@tgrv/cli",
3
+ "version": "1.0.0",
4
+ "description": "Gravity Standalone Runtime CLI",
5
+ "bin": {
6
+ "tgrv": "index.js"
7
+ },
8
+ "type": "module",
9
+ "optionalDependencies": {
10
+ "@tgrv/win32-x64": "1.0.0",
11
+ "@tgrv/linux-x64": "1.0.0"
12
+ }
13
+ }