Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4
chore: add build:bin and install:bin scripts#42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| #!/usr/bin/env bash | ||
| # Exit on error, catch unset variables, and fail a pipeline if any step fails. | ||
| set -euo pipefail | ||
| # Resolve this file’s directory, then the repo root, and run subsequent commands from there. | ||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)" | ||
| cd "${REPO_ROOT}" | ||
| # User-level bin dir | ||
| LOCAL_BIN="${HOME}/.local/bin" | ||
| # Marker (comment) in user profile for auto-updating the PATH | ||
| MARKER="# clerk-cli: ~/.local/bin on PATH" | ||
| # Compile the standalone binary, ensure the bin directory exists, then copy the binary into place. | ||
| bun run build:bin | ||
| mkdir -p "${LOCAL_BIN}" | ||
| install -m 755 "${REPO_ROOT}/dist/clerk" "${LOCAL_BIN}/clerk" | ||
| # Login shell name (used to pick config file and fish vs POSIX syntax). | ||
| shell_name() { | ||
| basename "${SHELL:-/bin/zsh}" | ||
| } | ||
| # Return true if we (or the user) already wired ~/.local/bin into shell startup files. | ||
| path_snippet_present() { | ||
| local f | ||
| for f in "${HOME}/.config/fish/config.fish" "${HOME}/.zshrc" "${HOME}/.bash_profile" "${HOME}/.bashrc" "${HOME}/.profile"; do | ||
| [[ -f "${f}" ]] || continue | ||
| grep -qF "${MARKER}" "${f}" && return 0 | ||
| grep -qF ".local/bin" "${f}" && return 0 | ||
| done | ||
| return 1 | ||
| } | ||
Comment on lines
+27
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cross-shell PATH detection can skip required shell config update (runtime install break). At Line 73, Proposed fix-path_snippet_present() {- local f- for f in "${HOME}/.config/fish/config.fish" "${HOME}/.zshrc" "${HOME}/.bash_profile" "${HOME}/.bashrc" "${HOME}/.profile"; do- [[ -f "${f}" ]] || continue- grep -qF "${MARKER}" "${f}" && return 0- grep -qF ".local/bin" "${f}" && return 0- done- return 1-}+path_snippet_present() {+ local f="$1"+ [[ -f "${f}" ]] || return 1+ grep -qF "${MARKER}" "${f}" && return 0+ grep -qF ".local/bin" "${f}" && return 0+ return 1+}
@@
-added_path_to_rc=false-rc=""-if path_snippet_present; then+added_path_to_rc=false+rc="$(pick_shell_config)"+if path_snippet_present "${rc}"; then
:
else
- rc="$(pick_shell_config)"
append_path_snippet "${rc}"
added_path_to_rc=true
fiAlso applies to: 73-79 🤖 Prompt for AI Agents | ||
| # Pick the startup file for the user’s login shell (fish, zsh, bash, or POSIX fallback). | ||
| pick_shell_config() { | ||
| case "$(shell_name)" in | ||
| fish) echo "${HOME}/.config/fish/config.fish" ;; | ||
| zsh) echo "${HOME}/.zshrc" ;; | ||
| bash) echo "${HOME}/.bash_profile" ;; | ||
| *) echo "${HOME}/.profile" ;; | ||
| esac | ||
| } | ||
| # Append a PATH snippet: fish uses fish_add_path; other shells use a POSIX export. | ||
| append_path_snippet() { | ||
| local config="$1" | ||
| mkdir -p "$(dirname "${config}")" | ||
| case "$(shell_name)" in | ||
| fish) | ||
| { | ||
| echo "" | ||
| echo "${MARKER}" | ||
| # fish_add_path is built into fish 3.2+ and updates PATH for new sessions. | ||
| echo "fish_add_path \$HOME/.local/bin" | ||
| } >>"${config}" | ||
| ;; | ||
| *) | ||
| { | ||
| echo "" | ||
| echo "${MARKER}" | ||
| echo "export PATH=\"\${HOME}/.local/bin:\${PATH}\"" | ||
| } >>"${config}" | ||
| ;; | ||
| esac | ||
| } | ||
| # Append PATH setup only when it isn’t already covered in the usual shell startup files. | ||
| added_path_to_rc=false | ||
| rc="" | ||
| if path_snippet_present; then | ||
| : | ||
| else | ||
| rc="$(pick_shell_config)" | ||
| append_path_snippet "${rc}" | ||
| added_path_to_rc=true | ||
| fi | ||
| # Friendly recap of what ran (always runs after a successful install). | ||
| echo "" | ||
| echo "Installation complete." | ||
| echo " • Built the standalone clerk binary" | ||
| echo " • Copied it to ${LOCAL_BIN}/clerk" | ||
| if [[ "${added_path_to_rc}" == true ]]; then | ||
| echo " • Added ~/.local/bin to your PATH via ${rc} (new terminals will pick this up automatically)." | ||
| echo " • To reload your PATH in this terminal, run: source ${rc}" | ||
| fi | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage for new install path (
build:bin/install:bin).Please add tests for the new binary-install flow (at minimum: verifies binary placement and PATH config behavior).
As per coding guidelines, "If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes."
🤖 Prompt for AI Agents