[FEATURE] Add interactive setup scripts for Windows, Linux, and macOS - #447
[FEATURE] Add interactive setup scripts for Windows, Linux, and macOS#447HindzStark wants to merge 1 commit into
Conversation
|
@HindzStark is attempting to deploy a commit to the AJEET PRATAP SINGH's projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughAdds Windows, Linux, and macOS setup scripts. The scripts validate environment files, install dependencies, generate the Prisma client, optionally run migrations, and print local startup instructions. Package commands and setup documentation expose the new workflows. ChangesCross-platform setup
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Developer
participant SetupScript
participant pnpm
participant Prisma
participant Database
Developer->>SetupScript: Run OS-specific setup command
SetupScript->>pnpm: Install workspace dependencies
SetupScript->>Prisma: Generate Prisma client
SetupScript->>Database: Optionally run development migrations
SetupScript-->>Developer: Show startup command and local URLs
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@setup/setup-linux.sh`:
- Around line 52-78: Setup scripts can report completion despite empty quoted
API secrets, incomplete web configuration, or declined file creation. Update
setup/setup-linux.sh lines 52-78 and setup/setup-mac.sh lines 52-78, plus
setup/setup-windows.ps1 lines 52-69, so API validation rejects empty quoted
values and halts before dependency installation when invalid. Update
setup/setup-linux.sh lines 87-109, setup/setup-mac.sh lines 87-109, and
setup/setup-windows.ps1 lines 78-102 to require NEXT_PUBLIC_API_URL and
NEXTAUTH_SECRET and stop when creation is declined or validation fails. Keep
setup/README.md lines 44-48 unchanged only if these claims remain accurate after
enforcing the validation contract.
- Around line 97-102: The setup scripts are writing a fixed NEXTAUTH_SECRET, so
update the secret generation flow in setup/setup-linux.sh, setup/setup-mac.sh,
and setup/setup-windows.ps1 to produce a unique cryptographically secure value
per setup or prompt for a developer-provided one. Use the existing env-file
write logic in each script, keep NEXTAUTH_URL and NEXT_PUBLIC_API_URL unchanged,
and ensure the generated secret is what gets written for apps/web/.env.local.
In `@setup/setup-windows.ps1`:
- Around line 111-116: Update the setup script’s pnpm install and Prisma command
paths to check $LASTEXITCODE immediately after each command and exit with that
same code when nonzero. Ensure failures stop execution before subsequent setup
steps can print completion messages, covering both dependency-install branches
and every Prisma invocation.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 32d8587e-50ae-4a31-bc49-0cc2d257142a
📒 Files selected for processing (5)
package.jsonsetup/README.mdsetup/setup-linux.shsetup/setup-mac.shsetup/setup-windows.ps1
| if check_env_key "$API_ENV_PATH" "DATABASE_URL" && check_env_key "$API_ENV_PATH" "JWT_SECRET"; then | ||
| echo -e "${GREEN}✅ apps/api/.env is fully configured with essential keys.${NC}" | ||
| else | ||
| echo -e "${RED}⚠️ apps/api/.env exists but is missing essential variables!${NC}" | ||
| API_NEEDS_ATTENTION=true | ||
| fi | ||
| fi | ||
|
|
||
| if [ "$API_NEEDS_ATTENTION" = true ]; then | ||
| echo "" | ||
| echo -e "${CYAN}📌 Important environment variables for apps/api/.env:${NC}" | ||
| echo -e "${GRAY} - DATABASE_URL (e.g., postgresql://postgres:postgres@localhost:5432/opensox?schema=public)${NC}" | ||
| echo -e "${GRAY} - JWT_SECRET (e.g., a-random-secret-key)${NC}" | ||
| echo -e "${GRAY} - PORT (default: 8080)${NC}" | ||
| echo "" | ||
|
|
||
| if [ ! -f "$API_ENV_PATH" ]; then | ||
| read -p "Would you like to copy apps/api/.env.example to apps/api/.env now? (Y/n) " -n 1 -r | ||
| echo "" | ||
| if [[ $REPLY =~ ^[Yy]$ ]] || [[ -z $REPLY ]]; then | ||
| cp "$API_ENV_EXAMPLE" "$API_ENV_PATH" | ||
| echo -e "${GREEN}✅ Created apps/api/.env from .env.example. Please review and update DATABASE_URL if needed.${NC}" | ||
| else | ||
| echo -e "${YELLOW}Please create apps/api/.env manually with essential keys before running the app.${NC}" | ||
| fi | ||
| fi | ||
| fi |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Fail setup until required environment values validate.
The API check accepts quoted-empty values such as JWT_SECRET="". The web check accepts any existing .env.local, including one without NEXT_PUBLIC_API_URL or NEXTAUTH_SECRET. The scripts also continue with installation and Prisma setup after configuration remains incomplete. A valid API configuration, a missing web file, and a declined creation prompt can still produce Setup Complete.
setup/setup-linux.sh#L52-L78: Reject empty quoted API values and stop before dependency installation when API configuration remains invalid.setup/setup-linux.sh#L87-L109: ValidateNEXT_PUBLIC_API_URLandNEXTAUTH_SECRET; stop when the user declines creation or values remain invalid.setup/setup-windows.ps1#L52-L69: Reject empty quoted API values and stop before dependency installation when API configuration remains invalid.setup/setup-windows.ps1#L78-L102: ValidateNEXT_PUBLIC_API_URLandNEXTAUTH_SECRET; stop when the user declines creation or values remain invalid.setup/setup-mac.sh#L52-L78: Reject empty quoted API values and stop before dependency installation when API configuration remains invalid.setup/setup-mac.sh#L87-L109: ValidateNEXT_PUBLIC_API_URLandNEXTAUTH_SECRET; stop when the user declines creation or values remain invalid.setup/README.md#L44-L48: Keep these statements only after the scripts enforce this validation contract.
📍 Affects 4 files
setup/setup-linux.sh#L52-L78(this comment)setup/setup-linux.sh#L87-L109setup/setup-windows.ps1#L52-L69setup/setup-windows.ps1#L78-L102setup/setup-mac.sh#L52-L78setup/setup-mac.sh#L87-L109setup/README.md#L44-L48
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@setup/setup-linux.sh` around lines 52 - 78, Setup scripts can report
completion despite empty quoted API secrets, incomplete web configuration, or
declined file creation. Update setup/setup-linux.sh lines 52-78 and
setup/setup-mac.sh lines 52-78, plus setup/setup-windows.ps1 lines 52-69, so API
validation rejects empty quoted values and halts before dependency installation
when invalid. Update setup/setup-linux.sh lines 87-109, setup/setup-mac.sh lines
87-109, and setup/setup-windows.ps1 lines 78-102 to require NEXT_PUBLIC_API_URL
and NEXTAUTH_SECRET and stop when creation is declined or validation fails. Keep
setup/README.md lines 44-48 unchanged only if these claims remain accurate after
enforcing the validation contract.
| cat <<EOF > "$WEB_ENV_PATH" | ||
| # Required for Local Setup | ||
| NEXT_PUBLIC_API_URL="http://localhost:8080" | ||
| NEXTAUTH_SECRET="opensox-local-dev-secret-key" | ||
| NEXTAUTH_URL="http://localhost:3000" | ||
| EOF |
There was a problem hiding this comment.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -C 3 'NEXTAUTH_SECRET|secret:' \
setup/setup-linux.sh \
setup/setup-windows.ps1 \
setup/setup-mac.sh \
apps/web/src/middleware.tsRepository: apsinghdev/opensox
Length of output: 3686
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "Files:"
fd -a 'middleware\.ts$|setup-(linux|mac|windows)\.(sh|ps1)$' . | sed 's#^\./##'
echo
echo "Relevant setup snippets:"
for f in setup/setup-linux.sh setup/setup-mac.sh setup/setup-windows.ps1; do
echo "--- $f ---"
sed -n '80,106p' "$f"
done
echo
echo "Middleware snippet:"
sed -n '1,40p' apps/web/src/middleware.ts
echo
echo "Search for NEXTAUTH_SECRET references:"
rg -n 'NEXTAUTH_SECRET|opensox-local-dev-secret-key|NextAuth|JWT' -S .Repository: apsinghdev/opensox
Length of output: 8757
Broken Authentication (CWE-798): Use of Hard-coded Credentials
Reachability path
● Entry
setup/setup-mac.sh:52
check_env_key
│
▼
● Sink
setup/setup-linux.sh
Generate a unique NEXTAUTH_SECRET for each setup.
The setup scripts write the known value opensox-local-dev-secret-key into apps/web/.env.local, and apps/web/src/middleware.ts uses it for JWT validation. Generate a cryptographically secure secret per setup, or require the developer to provide one.
setup/setup-linux.sh#L100setup/setup-mac.sh#L100setup/setup-windows.ps1#L92
📍 Affects 3 files
setup/setup-linux.sh#L97-L102(this comment)setup/setup-windows.ps1#L89-L95setup/setup-mac.sh#L97-L102
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@setup/setup-linux.sh` around lines 97 - 102, The setup scripts are writing a
fixed NEXTAUTH_SECRET, so update the secret generation flow in
setup/setup-linux.sh, setup/setup-mac.sh, and setup/setup-windows.ps1 to produce
a unique cryptographically secure value per setup or prompt for a
developer-provided one. Use the existing env-file write logic in each script,
keep NEXTAUTH_URL and NEXT_PUBLIC_API_URL unchanged, and ensure the generated
secret is what gets written for apps/web/.env.local.
| if (-not (Test-Path (Join-Path $RootDir "node_modules"))) { | ||
| Write-Host "Installing dependencies with pnpm..." -ForegroundColor Cyan | ||
| pnpm install | ||
| } else { | ||
| Write-Host "[OK] Root node_modules found. Checking for updates..." -ForegroundColor Green | ||
| pnpm install --prefer-offline |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
rg -n -C 2 'pnpm|LASTEXITCODE|\bexit\b|PSNativeCommandUseErrorActionPreference' \
setup/setup-windows.ps1Repository: apsinghdev/opensox
Length of output: 1594
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
printf '%s\n' '--- setup/setup-windows.ps1 ---'
cat -n setup/setup-windows.ps1 | sed -n '1,175p'
printf '%s\n' '--- native-command context ---'
rg -n -C 4 '(^|[^A-Za-z])pnpm([^A-Za-z]|$)|LASTEXITCODE|ErrorActionPreference|PSNativeCommandUseErrorActionPreference|exit\b|throw\b' \
setup/setup-windows.ps1
printf '%s\n' '--- structural check: pnpm command and following lines ---'
python3 - <<'PY'
from pathlib import Path
import re
path = Path("setup/setup-windows.ps1")
lines = path.read_text().splitlines()
for i, line in enumerate(lines):
if re.search(r'(?<![\w-])pnpm(?:\s|$)', line) and not line.lstrip().startswith("#"):
following = lines[i + 1:i + 4]
guarded = any("$LASTEXITCODE" in x or re.search(r"\b(exit|throw)\b", x) for x in following)
print(f"{path}:{i+1}: {line.strip()}")
print(f" immediate-next-3-lines-have-status-or-termination={guarded}")
PYRepository: apsinghdev/opensox
Length of output: 11148
🌐 Web query:
site:learn.microsoft.com PowerShell about_Automatic_Variables LASTEXITCODE powershell.exe -File exit code native command nonzero
💡 Result:
In PowerShell, the $LASTEXITCODE automatic variable stores the exit code returned by the last native program or PowerShell script that was executed [1][2]. Conventionally, an exit code of 0 indicates success, while any non-zero value indicates failure [2][3]. Key characteristics of $LASTEXITCODE include: Native Command Behavior: When a native command is executed, its exit code is automatically captured in
Citations:
- 1: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.6
- 2: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_error_handling?view=powershell-7.6
- 3: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_scripts?view=powershell-7.6
- 4: https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.nativecommandexitexception?view=powershellsdk-7.6.0
- 5: https://learn.microsoft.com/ka-ge/powershell/scripting/learn/shell/running-commands?view=powershell-7.5
- 6: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1
- 7: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_pwsh?view=powershell-7.6
- 8: https://learn.microsoft.com/th-th/powershell/module/microsoft.powershell.core/about/about_powershell_exe?view=powershell-5.1
- 9: https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/avoidassignmenttoautomaticvariable?view=ps-modules
Stop when a pnpm command fails.
Check $LASTEXITCODE and run exit $LASTEXITCODE immediately after each install and Prisma command. Otherwise, the script can continue and print Setup Complete after a failed command.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@setup/setup-windows.ps1` around lines 111 - 116, Update the setup script’s
pnpm install and Prisma command paths to check $LASTEXITCODE immediately after
each command and exit with that same code when nonzero. Ensure failures stop
execution before subsequent setup steps can print completion messages, covering
both dependency-install branches and every Prisma invocation.
Summary
This PR adds interactive setup scripts for Windows, Linux, and macOS to simplify the local development setup process.
Changes
setup-windows.ps1setup-linux.shsetup-mac.shpnpm install)pnpm exec prisma generate)README.mdwith streamlined setup instructions for all supported operating systemsBenefits
Closes #445
Summary by CodeRabbit
New Features
Documentation