claude-switch-profile 1.4.17 → 1.4.19
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/.github/workflows/update-brew.yml +92 -0
- package/Formula/claude-switch-profile.rb +34 -0
- package/README.md +27 -1
- package/install.sh +44 -0
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
name: Update Homebrew Formula
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags: ['v*']
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
inputs:
|
|
8
|
+
version:
|
|
9
|
+
description: 'Version to publish (e.g. 1.4.17)'
|
|
10
|
+
required: true
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
bump-formula:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
permissions:
|
|
16
|
+
contents: write # Cho phép GITHUB_TOKEN mặc định được ghi dữ liệu vào repo này
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout Repository
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Resolve Version
|
|
22
|
+
id: version
|
|
23
|
+
run: |
|
|
24
|
+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
|
25
|
+
VERSION="${{ github.event.inputs.version }}"
|
|
26
|
+
else
|
|
27
|
+
VERSION="${{ github.ref_name }}"
|
|
28
|
+
VERSION="${VERSION#v}"
|
|
29
|
+
fi
|
|
30
|
+
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
31
|
+
echo "Tarball version target: $VERSION"
|
|
32
|
+
|
|
33
|
+
- name: Fetch NPM Package Info
|
|
34
|
+
id: fetch
|
|
35
|
+
run: |
|
|
36
|
+
VERSION="${{ steps.version.outputs.version }}"
|
|
37
|
+
TARBALL_URL="https://registry.npmjs.org/claude-switch-profile/-/claude-switch-profile-${VERSION}.tgz"
|
|
38
|
+
|
|
39
|
+
echo "Waiting 15 seconds to ensure NPM registry propagation..."
|
|
40
|
+
sleep 15
|
|
41
|
+
|
|
42
|
+
echo "Downloading tarball to calculate SHA256..."
|
|
43
|
+
curl -sL $TARBALL_URL -o package.tgz
|
|
44
|
+
|
|
45
|
+
SHA256=$(shasum -a 256 package.tgz | awk '{print $1}')
|
|
46
|
+
|
|
47
|
+
if [ -z "$SHA256" ]; then
|
|
48
|
+
echo "Failed to calculate SHA256. Tarball might not exist yet."
|
|
49
|
+
exit 1
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
echo "url=$TARBALL_URL" >> $GITHUB_OUTPUT
|
|
53
|
+
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
|
|
54
|
+
|
|
55
|
+
- name: Generate New Formula
|
|
56
|
+
run: |
|
|
57
|
+
cat << 'EOF' > Formula/claude-switch-profile.rb
|
|
58
|
+
require "language/node"
|
|
59
|
+
|
|
60
|
+
class ClaudeSwitchProfile < Formula
|
|
61
|
+
desc "CLI tool for managing multiple Claude Code profiles"
|
|
62
|
+
homepage "https://github.com/ThanhThi2895/claude-switch-profile"
|
|
63
|
+
url "${{ steps.fetch.outputs.url }}"
|
|
64
|
+
sha256 "${{ steps.fetch.outputs.sha256 }}"
|
|
65
|
+
license "MIT"
|
|
66
|
+
|
|
67
|
+
depends_on "node"
|
|
68
|
+
|
|
69
|
+
def install
|
|
70
|
+
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
|
|
71
|
+
bin.install_symlink Dir["#{libexec}/bin/*"]
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
test do
|
|
75
|
+
assert_match "Usage: csp", shell_output("#{bin}/csp --help")
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
EOF
|
|
79
|
+
|
|
80
|
+
- name: Commit and Push to Same Repo
|
|
81
|
+
run: |
|
|
82
|
+
git config user.name "github-actions[bot]"
|
|
83
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
84
|
+
git add Formula/claude-switch-profile.rb
|
|
85
|
+
|
|
86
|
+
if git diff --staged --quiet; then
|
|
87
|
+
echo "No formula changes detected."
|
|
88
|
+
else
|
|
89
|
+
git commit -m "Bump Homebrew formula to v${{ steps.version.outputs.version }}"
|
|
90
|
+
git push
|
|
91
|
+
echo "Successfully updated local Homebrew formula!"
|
|
92
|
+
fi
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Homebrew Formula Template for claude-switch-profile
|
|
2
|
+
#
|
|
3
|
+
# INSTRUCTIONS FOR MAINTAINER:
|
|
4
|
+
# 1. Create a new GitHub repository named `homebrew-tap` (e.g. `ThanhThi2895/homebrew-tap`).
|
|
5
|
+
# 2. Inside that repository, create a `Formula/` directory.
|
|
6
|
+
# 3. Copy this file into `Formula/claude-switch-profile.rb`.
|
|
7
|
+
# 4. Update the `url` and `sha256` fields with the latest npm tarball release.
|
|
8
|
+
# (You can get the tarball url from `npm view claude-switch-profile dist.tarball`)
|
|
9
|
+
# (You must calculate the sha256 of the tarball, e.g. `curl -sL <tarball_url> | shasum -a 256`)
|
|
10
|
+
|
|
11
|
+
require "language/node"
|
|
12
|
+
|
|
13
|
+
class ClaudeSwitchProfile < Formula
|
|
14
|
+
desc "CLI tool for managing multiple Claude Code profiles"
|
|
15
|
+
homepage "https://github.com/ThanhThi2895/claude-switch-profile"
|
|
16
|
+
url "https://registry.npmjs.org/claude-switch-profile/-/claude-switch-profile-1.4.17.tgz"
|
|
17
|
+
sha256 "REPLACE_WITH_ACTUAL_SHA256_OF_TARBALL"
|
|
18
|
+
license "MIT"
|
|
19
|
+
|
|
20
|
+
depends_on "node"
|
|
21
|
+
|
|
22
|
+
def install
|
|
23
|
+
# Language::Node.std_npm_install_args securely installs the node module into
|
|
24
|
+
# the Homebrew Cellar, making it completely independent of any global Node.js
|
|
25
|
+
# managers like NVM or FNM that the user might be running.
|
|
26
|
+
system "npm", "install", *Language::Node.std_npm_install_args(libexec)
|
|
27
|
+
bin.install_symlink Dir["#{libexec}/bin/*"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
test do
|
|
31
|
+
# Simple test to verify the CLI initializes correctly
|
|
32
|
+
assert_match "Usage: csp", shell_output("#{bin}/csp --help")
|
|
33
|
+
end
|
|
34
|
+
end
|
package/README.md
CHANGED
|
@@ -20,11 +20,37 @@ Profiles are stored in `~/.claude-profiles/` and are never managed by Claude Cod
|
|
|
20
20
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
23
|
+
CSP distributes using decoupled local installations. This ensures your `csp` command doesn't spontaneously break or disappear when switching Node compilation environments via managers like `nvm` or `fnm`.
|
|
24
|
+
|
|
25
|
+
**Requirements:** Node.js >= 18.0.0 | macOS/Linux/Windows 10+
|
|
26
|
+
|
|
27
|
+
### Option 1: Standalone Bash Installer (Recommended)
|
|
28
|
+
|
|
29
|
+
Creates an isolated environment untouched by NVM lifecycle changes (Supports macOS, Linux, and Windows Git Bash):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
curl -fsSL https://raw.githubusercontent.com/ThanhThi2895/claude-switch-profile/main/install.sh | bash
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
*Note: The script safely creates a resilient executable wrapper at `~/.local/bin/csp`. Please ensure `~/.local/bin` is in your `$PATH`.*
|
|
36
|
+
|
|
37
|
+
### Option 2: Homebrew (macOS / Linux)
|
|
38
|
+
|
|
39
|
+
Leverages Homebrew's own managed cellars to isolate the Node engine:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
brew tap ThanhThi2895/claude-switch-profile
|
|
43
|
+
brew install claude-switch-profile
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Option 3: Global NPM (Legacy Fallback)
|
|
47
|
+
|
|
48
|
+
⚠️ **Not Recommended:** Global installs tie the tool to your *current* Node version. The `csp` command will disappear from `$PATH` if you change node versions.
|
|
49
|
+
|
|
23
50
|
```bash
|
|
24
51
|
npm install -g claude-switch-profile
|
|
25
52
|
```
|
|
26
53
|
|
|
27
|
-
**Requirements:** Node.js >= 18.0.0 | macOS/Linux/Windows 10+
|
|
28
54
|
|
|
29
55
|
## Quick Start
|
|
30
56
|
|
package/install.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Claude Switch Profile (CSP) - Standalone Installer
|
|
3
|
+
# This script installs CSP into an isolated directory to avoid Node.js version management issues.
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
PACKAGE_NAME="claude-switch-profile"
|
|
8
|
+
INSTALL_DIR="$HOME/.csp-cli"
|
|
9
|
+
BIN_DIR="$HOME/.local/bin"
|
|
10
|
+
|
|
11
|
+
echo "=> 🪄 Installing $PACKAGE_NAME..."
|
|
12
|
+
|
|
13
|
+
# 1. Prepare isolated installation directory
|
|
14
|
+
mkdir -p "$INSTALL_DIR"
|
|
15
|
+
cd "$INSTALL_DIR"
|
|
16
|
+
|
|
17
|
+
# Prevent npm from searching up the directory tree
|
|
18
|
+
if [ ! -f "package.json" ]; then
|
|
19
|
+
echo '{"name":"csp-cli-env","private":true}' > package.json
|
|
20
|
+
fi
|
|
21
|
+
|
|
22
|
+
# 2. Install the package explicitly in this isolated directory
|
|
23
|
+
echo "=> 📦 Downloading package from npm..."
|
|
24
|
+
npm install --omit=dev --silent "$PACKAGE_NAME@latest"
|
|
25
|
+
|
|
26
|
+
# 3. Create absolute wrapper script
|
|
27
|
+
echo "=> 🔗 Setting up executable wrapper..."
|
|
28
|
+
mkdir -p "$BIN_DIR"
|
|
29
|
+
|
|
30
|
+
WRAPPER_PATH="$BIN_DIR/csp"
|
|
31
|
+
|
|
32
|
+
cat << 'EOF' > "$WRAPPER_PATH"
|
|
33
|
+
#!/usr/bin/env bash
|
|
34
|
+
# Wrapper for claude-switch-profile (Isolated Environment)
|
|
35
|
+
exec node "$HOME/.csp-cli/node_modules/claude-switch-profile/bin/csp.js" "$@"
|
|
36
|
+
EOF
|
|
37
|
+
|
|
38
|
+
chmod +x "$WRAPPER_PATH"
|
|
39
|
+
|
|
40
|
+
echo "=> ✅ Installation complete!"
|
|
41
|
+
echo ""
|
|
42
|
+
echo "=> 🚀 The 'csp' command is now installed at: $WRAPPER_PATH"
|
|
43
|
+
echo "=> ⚠️ Please ensure $BIN_DIR is in your system \$PATH."
|
|
44
|
+
echo " (You may need to add: export PATH=\"\$HOME/.local/bin:\$PATH\" to your ~/.bashrc or ~/.zshrc)"
|