Skip to content

[FEATURE] Add interactive setup scripts for Windows, Linux, and macOS - #447

Open
HindzStark wants to merge 1 commit into
apsinghdev:mainfrom
HindzStark:feat/auto-setup-scripts
Open

[FEATURE] Add interactive setup scripts for Windows, Linux, and macOS#447
HindzStark wants to merge 1 commit into
apsinghdev:mainfrom
HindzStark:feat/auto-setup-scripts

Conversation

@HindzStark

@HindzStark HindzStark commented Aug 5, 2026

Copy link
Copy Markdown

Summary

This PR adds interactive setup scripts for Windows, Linux, and macOS to simplify the local development setup process.

Changes

  • Added setup-windows.ps1
  • Added setup-linux.sh
  • Added setup-mac.sh
  • Added interactive prompts for required environment variables
  • Automated dependency installation (pnpm install)
  • Automated Prisma client generation (pnpm exec prisma generate)
  • Automated initial database migration/setup
  • Updated README.md with streamlined setup instructions for all supported operating systems

Benefits

  • Reduces manual setup steps
  • Provides a consistent onboarding experience across platforms
  • Minimizes configuration errors for new contributors

Closes #445

Summary by CodeRabbit

  • New Features

    • Added interactive setup commands for Windows, Linux, and macOS.
    • Setup guides users through environment configuration, dependency installation, client generation, and optional database migrations.
    • Added completion guidance with local service URLs.
  • Documentation

    • Added cross-platform setup documentation with quick-start instructions and configuration details.

@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds 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.

Changes

Cross-platform setup

Layer / File(s) Summary
Setup commands and documentation
package.json, setup/README.md
Adds OS-specific package commands and documents the setup workflow for Windows, Linux, and macOS.
Environment validation and creation
setup/setup-linux.sh, setup/setup-mac.sh, setup/setup-windows.ps1
Checks required API and web environment values and optionally creates missing files from templates or default local values.
Workspace and database initialization
setup/setup-linux.sh, setup/setup-mac.sh, setup/setup-windows.ps1
Installs dependencies, generates the Prisma client, optionally runs development migrations, and prints local service instructions.

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
Loading

Possibly related PRs

  • apsinghdev/opensox#446: Adds the same cross-platform setup scripts, package commands, and setup documentation.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The scripts cover all three operating systems and setup tasks, but they optionally create missing environment files, contrary to [#445]. Remove automatic .env and .env.local creation; prompt users to create and verify the files before setup continues.
Out of Scope Changes check ⚠️ Warning Optional automatic creation of .env and .env.local files is outside [#445], which requires prompting and verification without automatic file creation. Delete file-generation paths and retain validation, reminders, and confirmation of user-provided environment files.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the addition of interactive setup scripts for Windows, Linux, and macOS.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between a0c8d78 and 4782aa0.

📒 Files selected for processing (5)
  • package.json
  • setup/README.md
  • setup/setup-linux.sh
  • setup/setup-mac.sh
  • setup/setup-windows.ps1

Comment thread setup/setup-linux.sh
Comment on lines +52 to +78
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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: Validate NEXT_PUBLIC_API_URL and NEXTAUTH_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: Validate NEXT_PUBLIC_API_URL and NEXTAUTH_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: Validate NEXT_PUBLIC_API_URL and NEXTAUTH_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-L109
  • setup/setup-windows.ps1#L52-L69
  • setup/setup-windows.ps1#L78-L102
  • setup/setup-mac.sh#L52-L78
  • setup/setup-mac.sh#L87-L109
  • setup/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.

Comment thread setup/setup-linux.sh
Comment on lines +97 to +102
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 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.ts

Repository: 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#L100
  • setup/setup-mac.sh#L100
  • setup/setup-windows.ps1#L92
📍 Affects 3 files
  • setup/setup-linux.sh#L97-L102 (this comment)
  • setup/setup-windows.ps1#L89-L95
  • setup/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.

Comment thread setup/setup-windows.ps1
Comment on lines +111 to +116
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.ps1

Repository: 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}")
PY

Repository: 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 $LASTEXITCODE [1][2]. PowerShell cmdlet errors do not affect this variable [2]. In modern PowerShell (7.4+), you can enable a feature that causes non-zero exit codes from native commands to throw a NativeCommandExitException [2][4]. This allows you to treat these failures as terminating errors within a try/catch block [2]. Additionally, when a native command returns a non-zero exit code, the automatic variable $? is set to $false [5]. Process Exit Codes (powershell.exe / pwsh): When you run a PowerShell process (e.g., pwsh -Command...), the exit code of that process depends on the final state of the execution [1][6][7]. If the final command succeeds, the process exit code is 0 [6][7]. If the final command fails or a script-terminating error occurs (e.g., via throw or -ErrorAction Stop), the process exit code is typically set to 1 [1][6][7]. If the last command is an external program or script that explicitly returns a non-zero exit code, that specific code is often converted to 1 for the parent process exit code [6][7]. To pass a specific non-zero exit code from a PowerShell script or command string to the parent process, you must explicitly use the exit keyword, such as exit $LASTEXITCODE [7][8]. Note that $LASTEXITCODE is a read-only-style variable intended for PowerShell's internal state management; you should avoid assigning values to it in your own code [9].

Citations:


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a Auto Setup files for Windows ,Linux ,Mac os for Devloper to easily setup in one click

1 participant