@usezynx/cli 0.1.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 (2) hide show
  1. package/bin/zynx.js +83 -0
  2. package/package.json +24 -0
package/bin/zynx.js ADDED
@@ -0,0 +1,83 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ const { spawnSync } = require('child_process');
5
+ const path = require('path');
6
+ const fs = require('fs');
7
+
8
+ // Windows x64 only for v0.1. macOS/Linux entries will be added once cross-build
9
+ // CI produces those binaries (see docs/CLI_NPM_DISTRIBUTION.md).
10
+ const PLATFORM_MAP = {
11
+ 'win32-x64': {
12
+ pkg: '@usezynx/cli-win32-x64',
13
+ bin: 'zynx.exe'
14
+ }
15
+ };
16
+
17
+ const currentKey = `${process.platform}-${process.arch}`;
18
+ const target = PLATFORM_MAP[currentKey];
19
+
20
+ if (!target) {
21
+ console.error(
22
+ `[zynx] Error: ${currentKey} is not supported yet. The Zynx CLI currently ships ` +
23
+ 'for Windows x64 only.'
24
+ );
25
+ process.exit(1);
26
+ }
27
+
28
+ function resolveBinaryPath() {
29
+ // 1. Try resolving package main / location via require.resolve
30
+ try {
31
+ const pkgPath = require.resolve(`${target.pkg}/package.json`);
32
+ const candidate = path.join(path.dirname(pkgPath), target.bin);
33
+ if (fs.existsSync(candidate)) {
34
+ return candidate;
35
+ }
36
+ } catch {}
37
+
38
+ // 2. Direct lookup in parent or adjacent node_modules
39
+ const searchRoots = [
40
+ path.join(__dirname, '..', 'node_modules', target.pkg, target.bin),
41
+ path.join(__dirname, '..', '..', target.pkg, target.bin),
42
+ path.join(__dirname, '..', '..', '..', 'node_modules', target.pkg, target.bin)
43
+ ];
44
+
45
+ for (const candidate of searchRoots) {
46
+ if (fs.existsSync(candidate)) {
47
+ return candidate;
48
+ }
49
+ }
50
+
51
+ // 3. Development fallback: local target directory
52
+ const devBin = process.platform === 'win32'
53
+ ? path.join(__dirname, '..', '..', '..', 'target', 'release', 'zynx.exe')
54
+ : path.join(__dirname, '..', '..', '..', 'target', 'release', 'zynx');
55
+ if (fs.existsSync(devBin)) {
56
+ return devBin;
57
+ }
58
+
59
+ return null;
60
+ }
61
+
62
+ const binaryPath = resolveBinaryPath();
63
+
64
+ if (!binaryPath) {
65
+ console.error(
66
+ `[zynx] Error: Could not locate native executable for ${currentKey}.\n` +
67
+ `Expected package '${target.pkg}' to be installed.\n` +
68
+ 'If you installed with --no-optional, please reinstall without that flag.'
69
+ );
70
+ process.exit(1);
71
+ }
72
+
73
+ const child = spawnSync(binaryPath, process.argv.slice(2), {
74
+ stdio: 'inherit',
75
+ windowsHide: false
76
+ });
77
+
78
+ if (child.error) {
79
+ console.error(`[zynx] Failed to spawn binary: ${child.error.message}`);
80
+ process.exit(1);
81
+ }
82
+
83
+ process.exit(child.status ?? 0);
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@usezynx/cli",
3
+ "version": "0.1.0",
4
+ "description": "Native CLI for ZynxTerminal (Windows x64)",
5
+ "license": "MIT",
6
+ "os": [
7
+ "win32"
8
+ ],
9
+ "cpu": [
10
+ "x64"
11
+ ],
12
+ "bin": {
13
+ "zynx": "bin/zynx.js"
14
+ },
15
+ "files": [
16
+ "bin/"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "optionalDependencies": {
22
+ "@usezynx/cli-win32-x64": "0.1.0"
23
+ }
24
+ }