-
-
Notifications
You must be signed in to change notification settings - Fork 241
chore: add localias configuration for npmx.test #1393
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
Open
vinnymac
wants to merge
3
commits into
npmx-dev:main
Choose a base branch
from
vinnymac:vt/local
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+174
−0
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # Localias configuration | ||
| # See: https://github.com/peterldowns/localias | ||
| # Usage: localias set npmx.test 3000 | ||
| # Visit: https://npmx.test | ||
|
|
||
| - from: npmx.test | ||
| to: http://127.0.0.1:3000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| R='\033[0;31m' G='\033[0;32m' Y='\033[1;33m' B='\033[0;34m' NC='\033[0m' | ||
|
|
||
| error_exit() { | ||
| echo -e "\n${R}✗ $1${NC}" >&2 | ||
| [ -n "$2" ] && echo -e "${Y}→ $2${NC}" >&2 | ||
| exit 1 | ||
| } | ||
|
|
||
| # Detect operating system | ||
| detect_os() { | ||
| case "$(uname -s)" in | ||
| Darwin*) | ||
| echo "macos" | ||
| ;; | ||
| Linux*) | ||
| if grep -qi microsoft /proc/version 2>/dev/null; then | ||
| echo "wsl" | ||
| else | ||
| echo "linux" | ||
| fi | ||
| ;; | ||
| MINGW*|MSYS*|CYGWIN*) | ||
| echo "windows" | ||
| ;; | ||
| *) | ||
| echo "unknown" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| OS_TYPE=$(detect_os) | ||
|
|
||
| echo -e "\n🌐 Configure npmx.test domain for local development" | ||
|
|
||
| # Check for unsupported platforms | ||
| if [ "$OS_TYPE" = "windows" ]; then | ||
| error_exit "Windows is not supported by Localias" \ | ||
| "Please use WSL2 instead: https://learn.microsoft.com/windows/wsl/install" | ||
| fi | ||
|
|
||
| if [ "$OS_TYPE" = "unknown" ]; then | ||
| error_exit "Unsupported operating system" "Localias supports macOS, Linux, and WSL2" | ||
| fi | ||
|
|
||
| # Check prerequisites with platform-specific instructions | ||
| if ! command -v localias &>/dev/null; then | ||
| case "$OS_TYPE" in | ||
| macos) | ||
| error_exit "Localias not installed" "brew install peterldowns/tap/localias" | ||
| ;; | ||
| linux|wsl) | ||
| error_exit "Localias not installed" "go install github.com/peterldowns/localias/cmd/localias@latest" | ||
| ;; | ||
| esac | ||
| fi | ||
|
|
||
| [ -f ".localias.yml" ] || error_exit ".localias.yml not found" "Run from project root" | ||
|
|
||
| # Linux/WSL: Check and configure privileged port capability | ||
| if [ "$OS_TYPE" = "linux" ] || [ "$OS_TYPE" = "wsl" ]; then | ||
| LOCALIAS_PATH=$(which localias) | ||
| if ! getcap "$LOCALIAS_PATH" 2>/dev/null | grep -q "cap_net_bind_service"; then | ||
| echo -e "${Y}⚙ Configuring privileged port access for Localias${NC}" | ||
| echo "This allows Localias to bind to ports 80 and 443 without sudo" | ||
| sudo setcap CAP_NET_BIND_SERVICE=+eip "$LOCALIAS_PATH" || \ | ||
| error_exit "Failed to set capabilities" "Run: sudo setcap CAP_NET_BIND_SERVICE=+eip \$(which localias)" | ||
| echo -e "${G}✓ Capabilities configured${NC}" | ||
| fi | ||
| fi | ||
|
|
||
| # Check if already configured | ||
| if localias list 2>/dev/null | grep -q "npmx.test"; then | ||
| echo -e "${Y}⚠ npmx.test already configured${NC}" | ||
| if localias status &>/dev/null; then | ||
| echo -e "${G}✓ Daemon running${NC} - visit ${B}https://npmx.test${NC}" | ||
| exit 0 | ||
| fi | ||
| echo "Restarting daemon..." | ||
| else | ||
| echo "Configuring npmx.test → localhost:3000 (requires sudo)" | ||
| read -p "Press Enter to continue or Ctrl+C to cancel... " | ||
| localias set npmx.test 3000 || error_exit "Failed to configure alias" "Check sudo access" | ||
| fi | ||
|
|
||
| # Start daemon | ||
| echo "Starting localias daemon (requires sudo)..." | ||
| sudo localias stop 2>/dev/null || true | ||
| if ! sudo localias start; then | ||
| error_exit "Failed to start daemon" "Check ports 80/443 or run: sudo localias start" | ||
| fi | ||
vinnymac marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| # Verify | ||
| sleep 1 | ||
| if ! localias status &>/dev/null; then | ||
| error_exit "Daemon not running" "Run manually: sudo localias start" | ||
| fi | ||
|
|
||
| echo -e "\n${G}✓ Setup complete${NC}" | ||
| echo -e " Start dev server: ${B}pnpm dev${NC}" | ||
| echo -e " Visit: ${B}https://npmx.test${NC}" | ||
| echo -e " Remove: ${B}pnpm setup:local:uninstall${NC}" | ||
|
|
||
| # Platform-specific notes | ||
| if [ "$OS_TYPE" = "wsl" ]; then | ||
| echo -e "\n${Y}ℹ WSL2 Note:${NC}" | ||
| echo -e " - SSL certificates work in WSL browsers" | ||
| echo -e " - For Windows browsers, manually install cert from:" | ||
| echo -e " ~/.localias/certs/npmx.test.crt" | ||
| fi | ||
|
|
||
| # AtProto OAuth caveat | ||
| echo -e "\n${Y}⚠ AtProto OAuth Note:${NC}" | ||
| echo -e " When using Bluesky login, the OAuth callback will redirect to" | ||
| echo -e " ${B}http://127.0.0.1:3000${NC} instead of ${B}npmx.test${NC}" | ||
| echo -e " This is required per AtProto spec for localhost development." | ||
| echo -e " Your session will work correctly after the redirect." | ||
| echo -e " See: ${B}https://atproto.com/specs/oauth#localhost-client-development${NC}" | ||
|
|
||
| echo "" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.