Skip to content

Commit ef4b273

Browse files
authored
Merge pull request #43 from netresearch/feat/add-gcloud-google-workspace-cli
feat(catalog): add Google Cloud CLI and Google Workspace CLI
2 parents ceb2f2f + 3f15ef7 commit ef4b273

9 files changed

Lines changed: 157 additions & 3 deletions

File tree

catalog/gcloud.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "gcloud",
3+
"category": "platform",
4+
"install_method": "gcloud_installer",
5+
"description": "Google Cloud CLI for managing Google Cloud resources",
6+
"homepage": "https://cloud.google.com/sdk/gcloud",
7+
"binary_name": "gcloud",
8+
"skip_upstream": true,
9+
"notes": "Installed via Google Cloud SDK installer; self-updates with 'gcloud components update'"
10+
}

catalog/golangci-lint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"homepage": "https://github.com/golangci/golangci-lint",
77
"github_repo": "golangci/golangci-lint",
88
"binary_name": "golangci-lint",
9+
"target_dir": "go_bin",
910
"download_url_template": "https://github.com/golangci/golangci-lint/releases/download/{version}/golangci-lint-{version_nov}-linux-{arch}.tar.gz",
1011
"arch_map": {
1112
"x86_64": "amd64",

catalog/google-workspace-cli.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "google-workspace-cli",
3+
"category": "platform",
4+
"install_method": "github_release_binary",
5+
"description": "Google Workspace command-line interface",
6+
"homepage": "https://github.com/googleworkspace/cli",
7+
"github_repo": "googleworkspace/cli",
8+
"binary_name": "gws",
9+
"download_url_template": "https://github.com/googleworkspace/cli/releases/download/{version}/gws-{arch}-unknown-linux-gnu.tar.gz",
10+
"arch_map": {
11+
"x86_64": "x86_64",
12+
"aarch64": "aarch64"
13+
}
14+
}

catalog/gosec.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"homepage": "https://github.com/securego/gosec",
77
"github_repo": "securego/gosec",
88
"binary_name": "gosec",
9+
"target_dir": "go_bin",
910
"download_url_template": "https://github.com/securego/gosec/releases/download/{version}/gosec_{version_nov}_linux_{arch}.tar.gz",
1011
"arch_map": {
1112
"x86_64": "amd64",

catalog/tree.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"homepage": "https://github.com/Old-Man-Programmer/tree",
77
"github_repo": "Old-Man-Programmer/tree",
88
"binary_name": "tree",
9+
"version_flag": "--version",
910
"script": "install_tree.sh",
1011
"tags": [
1112
"file-utils"

catalog/vhs.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "vhs",
3+
"category": "general",
4+
"install_method": "github_release_binary",
5+
"description": "CLI home video recorder - write terminal GIFs as code",
6+
"homepage": "https://github.com/charmbracelet/vhs",
7+
"github_repo": "charmbracelet/vhs",
8+
"binary_name": "vhs",
9+
"target_dir": "go_bin",
10+
"download_url_template": "https://github.com/charmbracelet/vhs/releases/download/{version}/vhs_{version_nov}_Linux_{arch}.tar.gz",
11+
"arch_map": {
12+
"x86_64": "x86_64",
13+
"aarch64": "arm64"
14+
}
15+
}

scripts/install_go.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ install_go() {
7070
echo "Downloading Go ${FULL_VERSION} SDK..."
7171
"$FULL_BINARY" download || true
7272

73-
# Create symlink from go1.24 -> go1.24.12 for convenience
73+
# Update symlink from go1.24 -> go1.24.12
7474
GOBIN="$(go env GOPATH)/bin"
75-
if [ -x "$GOBIN/$FULL_BINARY" ] && [ ! -e "$GOBIN/$BINARY" ]; then
75+
if [ -x "$GOBIN/$FULL_BINARY" ]; then
7676
ln -sf "$FULL_BINARY" "$GOBIN/$BINARY" 2>/dev/null || true
77-
echo "Created symlink: $BINARY -> $FULL_BINARY"
77+
echo "Updated symlink: $BINARY -> $FULL_BINARY"
7878
fi
7979
fi
8080
else
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/env bash
2+
# Google Cloud CLI installer
3+
set -euo pipefail
4+
5+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
6+
. "$DIR/lib/install_strategy.sh"
7+
8+
TOOL="${1:-gcloud}"
9+
CATALOG_FILE="$DIR/../catalog/$TOOL.json"
10+
11+
if [ ! -f "$CATALOG_FILE" ]; then
12+
echo "Error: Catalog file not found: $CATALOG_FILE" >&2
13+
exit 1
14+
fi
15+
16+
BINARY_NAME="$(jq -r '.binary_name' "$CATALOG_FILE")"
17+
GCLOUD_SDK="$HOME/google-cloud-sdk"
18+
GCLOUD_BIN="$GCLOUD_SDK/bin"
19+
20+
# Ensure SDK bin is in PATH for detection and post-install
21+
if [ -d "$GCLOUD_BIN" ]; then
22+
export PATH="$GCLOUD_BIN:$PATH"
23+
fi
24+
25+
# Get current version
26+
before="$(command -v "$BINARY_NAME" >/dev/null 2>&1 && "$BINARY_NAME" version 2>/dev/null | head -1 || true)"
27+
28+
if command -v "$BINARY_NAME" >/dev/null 2>&1; then
29+
# Already installed - use built-in update (quiet)
30+
"$BINARY_NAME" components update --quiet 2>&1 | tail -1
31+
elif [ -d "$GCLOUD_SDK" ]; then
32+
# SDK directory exists but gcloud not functional - try to recover
33+
if [ -x "$GCLOUD_BIN/$BINARY_NAME" ]; then
34+
"$GCLOUD_BIN/$BINARY_NAME" components update --quiet 2>&1 | tail -1
35+
else
36+
echo "[$TOOL] Error: $GCLOUD_SDK exists but gcloud not found in $GCLOUD_BIN" >&2
37+
echo "[$TOOL] Remove $GCLOUD_SDK and re-run to reinstall" >&2
38+
exit 1
39+
fi
40+
else
41+
# Fresh install via Google Cloud SDK installer (quiet)
42+
TMP="$(mktemp -d)"
43+
INSTALLER_URL="https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz"
44+
echo "[$TOOL] Downloading Google Cloud SDK..."
45+
curl -fsSL "$INSTALLER_URL" -o "$TMP/google-cloud-sdk.tar.gz"
46+
tar -xzf "$TMP/google-cloud-sdk.tar.gz" -C "$HOME"
47+
rm -rf "$TMP"
48+
49+
# Run install script quietly (no prompts, no PATH modification, no usage reporting)
50+
"$GCLOUD_SDK/install.sh" --quiet --usage-reporting false --command-completion false --path-update false 2>&1 | tail -1
51+
52+
export PATH="$GCLOUD_BIN:$PATH"
53+
fi
54+
55+
# Symlink gcloud (and gsutil, bq) into user bin so it's in PATH without SDK-specific setup
56+
BIN_DIR="$(get_install_dir "$BINARY_NAME")"
57+
mkdir -p "$BIN_DIR" 2>/dev/null || true
58+
for cmd in gcloud gsutil bq; do
59+
if [ -x "$GCLOUD_BIN/$cmd" ]; then
60+
ln -sf "$GCLOUD_BIN/$cmd" "$BIN_DIR/$cmd"
61+
fi
62+
done
63+
64+
# Report
65+
after="$(command -v "$BINARY_NAME" >/dev/null 2>&1 && "$BINARY_NAME" version 2>/dev/null | head -1 || true)"
66+
path="$(command -v "$BINARY_NAME" 2>/dev/null || true)"
67+
printf "[%s] before: %s\n" "$TOOL" "${before:-<none>}"
68+
printf "[%s] after: %s\n" "$TOOL" "${after:-<none>}"
69+
if [ -n "$path" ]; then printf "[%s] path: %s\n" "$TOOL" "$path"; fi
70+
71+
# Refresh snapshot after successful installation
72+
refresh_snapshot "$TOOL"

scripts/lib/install_strategy.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@ get_install_dir() {
1010
local prefix="${PREFIX:-$HOME/.local}"
1111
local bin_dir=""
1212

13+
# Check for per-tool target_dir override from catalog
14+
if [ -n "$tool_name" ] && [ -n "${CATALOG_FILE:-}" ] && [ -f "${CATALOG_FILE:-}" ]; then
15+
local target_dir
16+
target_dir="$(jq -r '.target_dir // empty' "$CATALOG_FILE" 2>/dev/null || true)"
17+
if [ -n "$target_dir" ]; then
18+
case "$target_dir" in
19+
go_bin)
20+
# Go binary convention: update in place, fresh install to best-guess GOPATH/bin
21+
local current_path
22+
current_path="$(command -v "$tool_name" 2>/dev/null || true)"
23+
if [ -n "$current_path" ]; then
24+
# Already installed - keep it where it is
25+
echo "$(dirname "$current_path")"
26+
else
27+
# Fresh install - best-guess Go bin folder:
28+
# 1. GOPATH/bin if GOPATH is set
29+
# 2. `go env GOPATH`/bin if go is available
30+
# 3. ~/go/bin (Go's default GOPATH)
31+
if [ -n "${GOPATH:-}" ]; then
32+
echo "$GOPATH/bin"
33+
elif command -v go >/dev/null 2>&1; then
34+
echo "$(go env GOPATH 2>/dev/null)/bin"
35+
else
36+
echo "$HOME/go/bin"
37+
fi
38+
fi
39+
return
40+
;;
41+
*)
42+
# Generic target_dir: expand ~ and $HOME
43+
target_dir="${target_dir/#\~/$HOME}"
44+
target_dir="${target_dir//\$\{HOME\}/$HOME}"
45+
target_dir="${target_dir//\$HOME/$HOME}"
46+
echo "$target_dir"
47+
return
48+
;;
49+
esac
50+
fi
51+
fi
52+
1353
case "$strategy" in
1454
CURRENT)
1555
# Keep tool where it is currently installed

0 commit comments

Comments
 (0)