@peterbe/clorb 0.0.8 → 0.0.10
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/README.md +48 -0
- package/install.sh +123 -0
- package/package.json +4 -3
- package/src/utils.ts +0 -1
package/README.md
CHANGED
|
@@ -8,6 +8,54 @@ Example use:
|
|
|
8
8
|
➜ clorb my-cool-branch
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
This will clone the current **default orb** and create a new one
|
|
12
|
+
called `clorb--my-cool-branch`. Now, you can enter that orb by typing:
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
orbctl run -m clorb--my-cool-branch
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
If you don't want it to clone from the **default** orb, you can pass a
|
|
19
|
+
second argument, which orb to clone from. For example:
|
|
20
|
+
|
|
21
|
+
```text
|
|
22
|
+
➜ clorb some-other-branch clorb--my-cool-branch
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Install
|
|
26
|
+
|
|
27
|
+
Run this in a terminal:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
curl -fsSL https://raw.githubusercontent.com/peterbe/clorb/main/install.sh | bash
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The [`install.sh`](install.sh) script:
|
|
34
|
+
|
|
35
|
+
1. Figures out your operating system and CPU architecture (e.g. macOS on
|
|
36
|
+
Apple Silicon → `clorb-darwin-arm64`, Linux on Intel/AMD → `clorb-linux-x64`).
|
|
37
|
+
2. Looks up the latest version on
|
|
38
|
+
[GitHub releases](https://github.com/peterbe/clorb/releases).
|
|
39
|
+
3. Downloads the matching binary to `~/bin/clorb` and makes it executable,
|
|
40
|
+
creating `~/bin/` if it doesn't already exist.
|
|
41
|
+
4. If `~/bin` isn't already on your `$PATH`, appends
|
|
42
|
+
`export PATH="$HOME/bin:$PATH"` to your shell config (`~/.zshrc`,
|
|
43
|
+
`~/.bashrc`/`~/.bash_profile`, or `~/.profile`).
|
|
44
|
+
|
|
45
|
+
New terminals will find `clorb` automatically. In the terminal where you ran
|
|
46
|
+
the installer, run the `source ...` command it prints (or just open a new
|
|
47
|
+
terminal).
|
|
48
|
+
|
|
49
|
+
To upgrade, run the same command again. To uninstall, delete `~/bin/clorb`.
|
|
50
|
+
|
|
51
|
+
If you'd rather read the script before running it:
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
curl -fsSL https://raw.githubusercontent.com/peterbe/clorb/main/install.sh -o install.sh
|
|
55
|
+
less install.sh
|
|
56
|
+
bash install.sh
|
|
57
|
+
```
|
|
58
|
+
|
|
11
59
|
## Other commands
|
|
12
60
|
|
|
13
61
|
### Purge all Orbs created with clorb
|
package/install.sh
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Installs the latest release of clorb from
|
|
4
|
+
# https://github.com/peterbe/clorb/releases into ~/bin/
|
|
5
|
+
#
|
|
6
|
+
# Usage:
|
|
7
|
+
# curl -fsSL https://raw.githubusercontent.com/peterbe/clorb/main/install.sh | bash
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
REPO="peterbe/clorb"
|
|
12
|
+
INSTALL_DIR="$HOME/bin"
|
|
13
|
+
BINARY_NAME="clorb"
|
|
14
|
+
|
|
15
|
+
err() {
|
|
16
|
+
echo "Error: $*" >&2
|
|
17
|
+
exit 1
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
command -v curl >/dev/null 2>&1 || err "curl is required but not installed."
|
|
21
|
+
|
|
22
|
+
# --- Detect OS -------------------------------------------------------------
|
|
23
|
+
case "$(uname -s)" in
|
|
24
|
+
Darwin) os="darwin" ;;
|
|
25
|
+
Linux) os="linux" ;;
|
|
26
|
+
MINGW* | MSYS* | CYGWIN*) os="windows" ;;
|
|
27
|
+
*) err "Unsupported operating system: $(uname -s)" ;;
|
|
28
|
+
esac
|
|
29
|
+
|
|
30
|
+
# --- Detect architecture ---------------------------------------------------
|
|
31
|
+
case "$(uname -m)" in
|
|
32
|
+
arm64 | aarch64) arch="arm64" ;;
|
|
33
|
+
x86_64 | amd64) arch="x64" ;;
|
|
34
|
+
*) err "Unsupported architecture: $(uname -m)" ;;
|
|
35
|
+
esac
|
|
36
|
+
|
|
37
|
+
# On Apple Silicon, a shell running under Rosetta reports x86_64.
|
|
38
|
+
# Prefer the native binary if the hardware supports arm64.
|
|
39
|
+
if [ "$os" = "darwin" ] && [ "$arch" = "x64" ]; then
|
|
40
|
+
if [ "$(sysctl -n hw.optional.arm64 2>/dev/null || echo 0)" = "1" ]; then
|
|
41
|
+
arch="arm64"
|
|
42
|
+
fi
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
asset="clorb-${os}-${arch}"
|
|
46
|
+
if [ "$os" = "windows" ]; then
|
|
47
|
+
[ "$arch" = "x64" ] || err "Only x64 is supported on Windows."
|
|
48
|
+
asset="${asset}.exe"
|
|
49
|
+
BINARY_NAME="clorb.exe"
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
# --- Find the latest version -----------------------------------------------
|
|
53
|
+
# GitHub redirects /releases/latest to /releases/tag/<version>.
|
|
54
|
+
latest_url=$(curl -fsSLI -o /dev/null -w '%{url_effective}' "https://github.com/${REPO}/releases/latest") ||
|
|
55
|
+
err "Could not determine the latest release."
|
|
56
|
+
version="${latest_url##*/}"
|
|
57
|
+
[ -n "$version" ] && [ "$version" != "latest" ] || err "Could not determine the latest release."
|
|
58
|
+
|
|
59
|
+
download_url="https://github.com/${REPO}/releases/download/${version}/${asset}"
|
|
60
|
+
|
|
61
|
+
echo "Installing clorb ${version} (${asset}) into ${INSTALL_DIR}"
|
|
62
|
+
|
|
63
|
+
# --- Download --------------------------------------------------------------
|
|
64
|
+
mkdir -p "$INSTALL_DIR"
|
|
65
|
+
|
|
66
|
+
tmp_file=$(mktemp)
|
|
67
|
+
trap 'rm -f "$tmp_file"' EXIT
|
|
68
|
+
|
|
69
|
+
curl -fSL --progress-bar "$download_url" -o "$tmp_file" ||
|
|
70
|
+
err "Failed to download ${download_url}"
|
|
71
|
+
|
|
72
|
+
chmod 755 "$tmp_file"
|
|
73
|
+
mv "$tmp_file" "${INSTALL_DIR}/${BINARY_NAME}"
|
|
74
|
+
|
|
75
|
+
echo "Installed ${INSTALL_DIR}/${BINARY_NAME}"
|
|
76
|
+
|
|
77
|
+
# --- Make sure ~/bin is on the PATH ----------------------------------------
|
|
78
|
+
case ":${PATH}:" in
|
|
79
|
+
*":${INSTALL_DIR}:"* | *":${INSTALL_DIR}/:"* | *":~/bin:"*)
|
|
80
|
+
;;
|
|
81
|
+
*)
|
|
82
|
+
case "$(basename "${SHELL:-}")" in
|
|
83
|
+
zsh) rc_file="$HOME/.zshrc" ;;
|
|
84
|
+
bash)
|
|
85
|
+
if [ "$os" = "darwin" ]; then
|
|
86
|
+
rc_file="$HOME/.bash_profile"
|
|
87
|
+
else
|
|
88
|
+
rc_file="$HOME/.bashrc"
|
|
89
|
+
fi
|
|
90
|
+
;;
|
|
91
|
+
fish) rc_file="$HOME/.config/fish/config.fish" ;;
|
|
92
|
+
*) rc_file="$HOME/.profile" ;;
|
|
93
|
+
esac
|
|
94
|
+
|
|
95
|
+
if [ "$(basename "${SHELL:-}")" = "fish" ]; then
|
|
96
|
+
path_line="fish_add_path \$HOME/bin"
|
|
97
|
+
else
|
|
98
|
+
path_line='export PATH="$HOME/bin:$PATH"'
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
if [ -f "$rc_file" ] && grep -qF "$path_line" "$rc_file"; then
|
|
102
|
+
:
|
|
103
|
+
else
|
|
104
|
+
mkdir -p "$(dirname "$rc_file")"
|
|
105
|
+
{
|
|
106
|
+
echo ""
|
|
107
|
+
echo "# Added by the clorb installer"
|
|
108
|
+
echo "$path_line"
|
|
109
|
+
} >>"$rc_file"
|
|
110
|
+
echo "Added ${INSTALL_DIR} to your PATH in ${rc_file}"
|
|
111
|
+
fi
|
|
112
|
+
|
|
113
|
+
echo ""
|
|
114
|
+
echo "To start using clorb in this terminal, run:"
|
|
115
|
+
echo ""
|
|
116
|
+
echo " source ${rc_file}"
|
|
117
|
+
echo ""
|
|
118
|
+
echo "(New terminal sessions will pick it up automatically.)"
|
|
119
|
+
;;
|
|
120
|
+
esac
|
|
121
|
+
|
|
122
|
+
echo ""
|
|
123
|
+
echo "Run 'clorb --help' to get started."
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peterbe/clorb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "A CLI tool for cloning Orbstack VMs by git branches",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"orb",
|
|
8
|
+
"orbctl",
|
|
9
|
+
"orbstack"
|
|
9
10
|
],
|
|
10
11
|
"bugs": {
|
|
11
12
|
"url": "https://github.com/peterbe/clorb/issues"
|
package/src/utils.ts
CHANGED
|
@@ -148,7 +148,6 @@ export async function interactiveInput(message: string): Promise<string> {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
export async function cloneOrb(source: string, destination: string, debug = false): Promise<void> {
|
|
151
|
-
console.log(["orbctl", "clone", source, destination].join(" "));
|
|
152
151
|
const { exitCode, stdout, stderr } = await run(["orbctl", "clone", source, destination]);
|
|
153
152
|
if (exitCode !== 0) {
|
|
154
153
|
throw new Error(`Failed to clone orb: ${stderr}`);
|