Skip to content

Commit a6a353a

Browse files
committed
fix(install): download from npm registry instead of GitHub releases
Updated install.sh to fetch tarballs from npm registry instead of GitHub release assets. This allows the installer to work with the published @socketbin packages. Changes: - get_latest_version() now queries npm registry API - Download URL now points to npm registry tarball - Removes dependency on GitHub releases
1 parent c21011b commit a6a353a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

install.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,24 @@ detect_platform() {
6767
echo "${os}-${arch}"
6868
}
6969

70-
# Get the latest release version from GitHub.
70+
# Get the latest version from npm registry.
7171
get_latest_version() {
72+
local package_name="$1"
7273
local version
7374

74-
# Try using curl with GitHub API.
75+
# Try using curl with npm registry API.
7576
if command -v curl &> /dev/null; then
76-
version=$(curl -fsSL https://api.github.com/repos/SocketDev/socket-cli/releases/latest | grep -o '"tag_name": *"[^"]*"' | sed 's/"tag_name": *"\([^"]*\)"/\1/')
77+
version=$(curl -fsSL "https://registry.npmjs.org/${package_name}/latest" | grep -o '"version": *"[^"]*"' | head -1 | sed 's/"version": *"\([^"]*\)"/\1/')
7778
# Fallback to wget.
7879
elif command -v wget &> /dev/null; then
79-
version=$(wget -qO- https://api.github.com/repos/SocketDev/socket-cli/releases/latest | grep -o '"tag_name": *"[^"]*"' | sed 's/"tag_name": *"\([^"]*\)"/\1/')
80+
version=$(wget -qO- "https://registry.npmjs.org/${package_name}/latest" | grep -o '"version": *"[^"]*"' | head -1 | sed 's/"version": *"\([^"]*\)"/\1/')
8081
else
8182
error "Neither curl nor wget found. Please install one of them."
8283
exit 1
8384
fi
8485

8586
if [ -z "$version" ]; then
86-
error "Failed to fetch latest version from GitHub"
87+
error "Failed to fetch latest version from npm registry"
8788
exit 1
8889
fi
8990

@@ -121,15 +122,17 @@ install_socket_cli() {
121122
platform=$(detect_platform)
122123
success "Platform detected: $platform"
123124

125+
# Construct package name.
126+
package_name="@socketbin/cli-${platform}"
127+
124128
info "Fetching latest version..."
125-
version=$(get_latest_version)
129+
version=$(get_latest_version "$package_name")
126130
success "Latest version: $version"
127131

128-
# Construct package name and download URL.
129-
package_name="@socketbin/cli-${platform}"
130-
download_url="https://github.com/SocketDev/socket-cli/releases/download/${version}/socketbin-cli-${platform}.tgz"
132+
# Construct download URL from npm registry.
133+
download_url="https://registry.npmjs.org/${package_name}/-/cli-${platform}-${version}.tgz"
131134

132-
info "Downloading Socket CLI from $download_url"
135+
info "Downloading Socket CLI from npm registry"
133136

134137
# Create DLX directory structure.
135138
dlx_dir="${HOME}/.socket/_dlx"

0 commit comments

Comments
 (0)