npm automatically picks up GITHUB_TOKEN / NPM_TOKEN from the build environment and writes them as _authToken entries in /root/.npmrc and /usr/local/etc/npmrc during 'npm install -g'. Add a cleanup RUN step that removes any npmrc file containing auth tokens before the image is finalised, and explicitly deletes the two most common registry auth keys via 'npm config delete'. Also add .npmrc to .dockerignore as an extra guard against accidentally COPY-ing a local credential file into the build context. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
62 lines
2.2 KiB
Bash
Executable file
62 lines
2.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# launch.sh — Pick a project folder and start Claude Code
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
# ─── First-time setup ─────────────────────────────────────────────────────────
|
|
if [[ ! -f "$SCRIPT_DIR/.env" ]]; then
|
|
echo "Looks like this is your first time. Running setup..."
|
|
echo ""
|
|
"$SCRIPT_DIR/setup.sh" || exit 1
|
|
echo ""
|
|
fi
|
|
|
|
# ─── Folder picker ────────────────────────────────────────────────────────────
|
|
pick_folder() {
|
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
# macOS — native Finder dialog
|
|
osascript -e \
|
|
'tell application "Finder" to POSIX path of (choose folder with prompt "Select the project folder to work on:")' \
|
|
2>/dev/null | tr -d '\n'
|
|
elif command -v zenity &>/dev/null; then
|
|
# Linux — GNOME/GTK dialog
|
|
zenity --file-selection --directory \
|
|
--title="Select your project folder" 2>/dev/null
|
|
elif command -v kdialog &>/dev/null; then
|
|
# Linux — KDE dialog
|
|
kdialog --getexistingdirectory "$HOME" \
|
|
--title "Select your project folder" 2>/dev/null
|
|
else
|
|
echo ""
|
|
fi
|
|
}
|
|
|
|
folder=$(pick_folder || true)
|
|
|
|
# Fallback: text prompt (no GUI available, or user cancelled dialog)
|
|
if [[ -z "$folder" ]]; then
|
|
echo "Enter the path to your project folder"
|
|
echo "(Tip: you can drag the folder into this window, then press Enter)"
|
|
echo ""
|
|
read -rp "> " folder
|
|
# Clean up: strip surrounding quotes and trailing whitespace from drag-and-drop
|
|
folder="${folder%"${folder##*[![:space:]]}"}"
|
|
folder="${folder#\'}" ; folder="${folder%\'}"
|
|
folder="${folder#\"}" ; folder="${folder%\"}"
|
|
# Expand ~ to home directory
|
|
folder="${folder/#\~/$HOME}"
|
|
fi
|
|
|
|
if [[ -z "$folder" ]]; then
|
|
echo "No folder selected. Exiting."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -d "$folder" ]]; then
|
|
echo "Folder not found: $folder"
|
|
exit 1
|
|
fi
|
|
|
|
cd "$folder"
|
|
exec "$SCRIPT_DIR/claude.sh" start
|