@cubic-dev-ai/cli 1.6.2 → 1.6.4

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/cubic CHANGED
@@ -1,71 +1,61 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- if [ -n "$CUBIC_BIN_PATH" ]; then
5
- resolved="$CUBIC_BIN_PATH"
6
- else
7
- # Get the real path of this script, resolving any symlinks
8
- script_path="$0"
9
- while [ -L "$script_path" ]; do
10
- link_target="$(readlink "$script_path")"
11
- case "$link_target" in
12
- /*) script_path="$link_target" ;;
13
- *) script_path="$(dirname "$script_path")/$link_target" ;;
14
- esac
15
- done
16
- script_dir="$(dirname "$script_path")"
17
- script_dir="$(cd "$script_dir" && pwd)"
18
-
19
- # Map platform names
20
- case "$(uname -s)" in
21
- Darwin) platform="darwin" ;;
22
- Linux) platform="linux" ;;
23
- MINGW*|CYGWIN*|MSYS*) platform="win32" ;;
24
- *) platform="$(uname -s | tr '[:upper:]' '[:lower:]')" ;;
25
- esac
26
-
27
- # Map architecture names
28
- case "$(uname -m)" in
29
- x86_64|amd64) arch="x64" ;;
30
- aarch64) arch="arm64" ;;
31
- armv7l) arch="arm" ;;
32
- *) arch="$(uname -m)" ;;
33
- esac
34
-
35
- name="@cubic-dev-ai/cli-${platform}-${arch}"
36
- binary="cubic"
37
- [ "$platform" = "win32" ] && binary="cubic.exe"
38
-
39
- # Search for the binary starting from real script location
40
- resolved=""
41
- current_dir="$script_dir"
42
- while [ "$current_dir" != "/" ]; do
43
- candidate="$current_dir/node_modules/$name/bin/$binary"
44
- if [ -f "$candidate" ]; then
45
- resolved="$candidate"
46
- break
47
- fi
48
- current_dir="$(dirname "$current_dir")"
49
- done
50
-
51
- if [ -z "$resolved" ]; then
52
- printf "It seems that your package manager failed to install the right version of the cubic CLI for your platform. You can try manually installing the \"%s\" package\n" "$name" >&2
53
- exit 1
54
- fi
55
- fi
56
-
57
- # Handle SIGINT gracefully
58
- trap '' INT
59
-
60
- # Intercept installer command from npx wrapper context
61
- if [ "$1" = "install" ]; then
62
- exec "$resolved" "$@"
63
- fi
64
-
65
- # npx with no args should bootstrap setup flow in exec context
66
- if [ "$#" -eq 0 ] && [ "${npm_command:-}" = "exec" ]; then
67
- exec "$resolved" setup --mode install
68
- fi
69
-
70
- # Execute the binary with all arguments
71
- exec "$resolved" "$@"
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import { spawnSync } from "child_process"
6
+ import { fileURLToPath } from "url"
7
+
8
+ function platformName() {
9
+ if (process.platform === "win32") return "windows"
10
+ return process.platform
11
+ }
12
+
13
+ function archName() {
14
+ if (process.arch === "ia32") return "x86"
15
+ return process.arch
16
+ }
17
+
18
+ function resolveBinary() {
19
+ if (process.env.CUBIC_BIN_PATH) return process.env.CUBIC_BIN_PATH
20
+
21
+ const script = fs.realpathSync(fileURLToPath(import.meta.url))
22
+ const platform = platformName()
23
+ const arch = archName()
24
+ const name = `@cubic-dev-ai/cli-${platform}-${arch}`
25
+ const binary = platform === "windows" ? "cubic.exe" : "cubic"
26
+ let dir = path.dirname(script)
27
+
28
+ while (true) {
29
+ const candidate = path.join(dir, "node_modules", name, "bin", binary)
30
+ if (fs.existsSync(candidate)) return candidate
31
+
32
+ const parent = path.dirname(dir)
33
+ if (parent === dir) break
34
+ dir = parent
35
+ }
36
+
37
+ console.error(
38
+ `It seems that your package manager failed to install the right version of the cubic CLI for your platform. You can try manually installing the "${name}" package`,
39
+ )
40
+ process.exit(1)
41
+ }
42
+
43
+ const binary = resolveBinary()
44
+ const args = process.argv.slice(2)
45
+ const command = args.length === 0 && process.env.npm_command === "exec" ? ["setup", "--mode", "install"] : args
46
+ const result = spawnSync(binary, command, /*__CUBIC_SPAWN_OPTS__*/ { stdio: "inherit", windowsHide: false })
47
+
48
+ if (result.error) {
49
+ console.error(result.error.message)
50
+ process.exit(1)
51
+ }
52
+
53
+ if (result.signal) {
54
+ try {
55
+ process.kill(process.pid, result.signal)
56
+ } catch {
57
+ process.exit(1)
58
+ }
59
+ }
60
+
61
+ process.exit(result.status ?? 1)
package/bin/cubic.wrapper CHANGED
@@ -1,71 +1,61 @@
1
- #!/bin/sh
2
- set -e
3
-
4
- if [ -n "$CUBIC_BIN_PATH" ]; then
5
- resolved="$CUBIC_BIN_PATH"
6
- else
7
- # Get the real path of this script, resolving any symlinks
8
- script_path="$0"
9
- while [ -L "$script_path" ]; do
10
- link_target="$(readlink "$script_path")"
11
- case "$link_target" in
12
- /*) script_path="$link_target" ;;
13
- *) script_path="$(dirname "$script_path")/$link_target" ;;
14
- esac
15
- done
16
- script_dir="$(dirname "$script_path")"
17
- script_dir="$(cd "$script_dir" && pwd)"
18
-
19
- # Map platform names
20
- case "$(uname -s)" in
21
- Darwin) platform="darwin" ;;
22
- Linux) platform="linux" ;;
23
- MINGW*|CYGWIN*|MSYS*) platform="win32" ;;
24
- *) platform="$(uname -s | tr '[:upper:]' '[:lower:]')" ;;
25
- esac
26
-
27
- # Map architecture names
28
- case "$(uname -m)" in
29
- x86_64|amd64) arch="x64" ;;
30
- aarch64) arch="arm64" ;;
31
- armv7l) arch="arm" ;;
32
- *) arch="$(uname -m)" ;;
33
- esac
34
-
35
- name="@cubic-dev-ai/cli-${platform}-${arch}"
36
- binary="cubic"
37
- [ "$platform" = "win32" ] && binary="cubic.exe"
38
-
39
- # Search for the binary starting from real script location
40
- resolved=""
41
- current_dir="$script_dir"
42
- while [ "$current_dir" != "/" ]; do
43
- candidate="$current_dir/node_modules/$name/bin/$binary"
44
- if [ -f "$candidate" ]; then
45
- resolved="$candidate"
46
- break
47
- fi
48
- current_dir="$(dirname "$current_dir")"
49
- done
50
-
51
- if [ -z "$resolved" ]; then
52
- printf "It seems that your package manager failed to install the right version of the cubic CLI for your platform. You can try manually installing the \"%s\" package\n" "$name" >&2
53
- exit 1
54
- fi
55
- fi
56
-
57
- # Handle SIGINT gracefully
58
- trap '' INT
59
-
60
- # Intercept installer command from npx wrapper context
61
- if [ "$1" = "install" ]; then
62
- exec "$resolved" "$@"
63
- fi
64
-
65
- # npx with no args should bootstrap setup flow in exec context
66
- if [ "$#" -eq 0 ] && [ "${npm_command:-}" = "exec" ]; then
67
- exec "$resolved" setup --mode install
68
- fi
69
-
70
- # Execute the binary with all arguments
71
- exec "$resolved" "$@"
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "fs"
4
+ import path from "path"
5
+ import { spawnSync } from "child_process"
6
+ import { fileURLToPath } from "url"
7
+
8
+ function platformName() {
9
+ if (process.platform === "win32") return "windows"
10
+ return process.platform
11
+ }
12
+
13
+ function archName() {
14
+ if (process.arch === "ia32") return "x86"
15
+ return process.arch
16
+ }
17
+
18
+ function resolveBinary() {
19
+ if (process.env.CUBIC_BIN_PATH) return process.env.CUBIC_BIN_PATH
20
+
21
+ const script = fs.realpathSync(fileURLToPath(import.meta.url))
22
+ const platform = platformName()
23
+ const arch = archName()
24
+ const name = `@cubic-dev-ai/cli-${platform}-${arch}`
25
+ const binary = platform === "windows" ? "cubic.exe" : "cubic"
26
+ let dir = path.dirname(script)
27
+
28
+ while (true) {
29
+ const candidate = path.join(dir, "node_modules", name, "bin", binary)
30
+ if (fs.existsSync(candidate)) return candidate
31
+
32
+ const parent = path.dirname(dir)
33
+ if (parent === dir) break
34
+ dir = parent
35
+ }
36
+
37
+ console.error(
38
+ `It seems that your package manager failed to install the right version of the cubic CLI for your platform. You can try manually installing the "${name}" package`,
39
+ )
40
+ process.exit(1)
41
+ }
42
+
43
+ const binary = resolveBinary()
44
+ const args = process.argv.slice(2)
45
+ const command = args.length === 0 && process.env.npm_command === "exec" ? ["setup", "--mode", "install"] : args
46
+ const result = spawnSync(binary, command, /*__CUBIC_SPAWN_OPTS__*/ { stdio: "inherit", windowsHide: false })
47
+
48
+ if (result.error) {
49
+ console.error(result.error.message)
50
+ process.exit(1)
51
+ }
52
+
53
+ if (result.signal) {
54
+ try {
55
+ process.kill(process.pid, result.signal)
56
+ } catch {
57
+ process.exit(1)
58
+ }
59
+ }
60
+
61
+ process.exit(result.status ?? 1)
package/package.json CHANGED
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "name": "@cubic-dev-ai/cli",
3
+ "type": "module",
3
4
  "bin": {
4
5
  "cubic": "./bin/cubic"
5
6
  },
@@ -7,23 +8,23 @@
7
8
  "preinstall": "bun ./preinstall.mjs || node ./preinstall.mjs",
8
9
  "postinstall": "bun ./postinstall.mjs || node ./postinstall.mjs"
9
10
  },
10
- "version": "1.6.2",
11
+ "version": "1.6.4",
11
12
  "repository": {
12
13
  "type": "git",
13
14
  "url": "git+https://github.com/mrge-io/cubic-cli.git",
14
15
  "directory": "packages/cubic"
15
16
  },
16
17
  "optionalDependencies": {
17
- "@cubic-dev-ai/cli-linux-arm64": "1.6.2",
18
- "@cubic-dev-ai/cli-linux-x64": "1.6.2",
19
- "@cubic-dev-ai/cli-linux-x64-baseline": "1.6.2",
20
- "@cubic-dev-ai/cli-linux-arm64-musl": "1.6.2",
21
- "@cubic-dev-ai/cli-linux-x64-musl": "1.6.2",
22
- "@cubic-dev-ai/cli-linux-x64-baseline-musl": "1.6.2",
23
- "@cubic-dev-ai/cli-darwin-arm64": "1.6.2",
24
- "@cubic-dev-ai/cli-darwin-x64": "1.6.2",
25
- "@cubic-dev-ai/cli-darwin-x64-baseline": "1.6.2",
26
- "@cubic-dev-ai/cli-windows-x64": "1.6.2",
27
- "@cubic-dev-ai/cli-windows-x64-baseline": "1.6.2"
18
+ "@cubic-dev-ai/cli-linux-arm64": "1.6.4",
19
+ "@cubic-dev-ai/cli-linux-x64": "1.6.4",
20
+ "@cubic-dev-ai/cli-linux-x64-baseline": "1.6.4",
21
+ "@cubic-dev-ai/cli-linux-arm64-musl": "1.6.4",
22
+ "@cubic-dev-ai/cli-linux-x64-musl": "1.6.4",
23
+ "@cubic-dev-ai/cli-linux-x64-baseline-musl": "1.6.4",
24
+ "@cubic-dev-ai/cli-darwin-arm64": "1.6.4",
25
+ "@cubic-dev-ai/cli-darwin-x64": "1.6.4",
26
+ "@cubic-dev-ai/cli-darwin-x64-baseline": "1.6.4",
27
+ "@cubic-dev-ai/cli-windows-x64": "1.6.4",
28
+ "@cubic-dev-ai/cli-windows-x64-baseline": "1.6.4"
28
29
  }
29
30
  }
package/preinstall.mjs CHANGED
@@ -1,11 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import fs from "fs"
4
- import path from "path"
5
3
  import os from "os"
6
- import { fileURLToPath } from "url"
7
-
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
9
4
 
10
5
  function main() {
11
6
  if (os.platform() !== "win32") {
@@ -13,27 +8,7 @@ function main() {
13
8
  return
14
9
  }
15
10
 
16
- console.log("Windows detected: Modifying package.json bin entry")
17
-
18
- // Read package.json
19
- const packageJsonPath = path.join(__dirname, "package.json")
20
- const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"))
21
-
22
- // Modify bin to point to .cmd file on Windows
23
- packageJson.bin = {
24
- cubic: "./bin/cubic.cmd",
25
- }
26
-
27
- // Write it back
28
- fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))
29
- console.log("Updated package.json bin to use cubic.cmd")
30
-
31
- // Now you can also remove the Unix script if you want
32
- const unixScript = path.join(__dirname, "bin", "cubic")
33
- if (fs.existsSync(unixScript)) {
34
- console.log("Removing Unix shell script")
35
- fs.unlinkSync(unixScript)
36
- }
11
+ console.log("Windows detected: using Node bin wrapper")
37
12
  }
38
13
 
39
14
  try {