Skip to content

Commit e18049c

Browse files
Chris KhanChris Khan
authored andcommitted
feat: add one-click setup automation scripts
- Add setup.sh for macOS/Linux automated setup - Add setup.ps1 for Windows PowerShell automated setup - Add 'npm run setup' command for cross-platform convenience - Update README with prominent one-click setup instructions - Scripts automatically handle Node.js, Yarn, .env, and dependencies - Provide colored output and clear success/error messages
1 parent 2288736 commit e18049c

4 files changed

Lines changed: 273 additions & 0 deletions

File tree

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,51 @@ _Perp Dex As A Service - Powered by Injective_
1616

1717
This repository is self‑contained and vendors the shared `injective-ui` layer, so you can run it without fetching external layers.
1818

19+
### 🚀 One-Click Setup (Recommended)
20+
21+
Clone the repo and run the setup script - it handles everything automatically!
22+
23+
**macOS / Linux:**
24+
```bash
25+
git clone git@github.com:InjectiveLabs/pdaas.git
26+
cd pdaas
27+
./setup.sh
28+
```
29+
30+
**Windows (PowerShell):**
31+
```powershell
32+
git clone git@github.com:InjectiveLabs/pdaas.git
33+
cd pdaas
34+
.\setup.ps1
35+
```
36+
37+
**Alternative (if you already have Node.js installed):**
38+
```bash
39+
git clone git@github.com:InjectiveLabs/pdaas.git
40+
cd pdaas
41+
npm run setup
42+
```
43+
44+
The setup script will:
45+
- ✓ Check and install Node.js 20 (if needed)
46+
- ✓ Check and install Yarn Classic (if needed)
47+
- ✓ Copy `.env.example` to `.env`
48+
- ✓ Install all dependencies
49+
- ✓ Get you ready to code!
50+
51+
Then just run:
52+
```bash
53+
yarn dev
54+
```
55+
56+
🎉 **That's it!** Your dev server will be running at `http://127.0.0.1:3000`
57+
58+
---
59+
60+
### 📖 Manual Setup (Advanced)
61+
62+
If you prefer to set things up manually or want more control:
63+
1964
### Prerequisites
2065

2166
#### 1. Install Node.js 20 LTS

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"buffer": true
1313
},
1414
"scripts": {
15+
"setup": "node -e \"require('child_process').execSync(process.platform === 'win32' ? 'powershell -ExecutionPolicy Bypass -File ./setup.ps1' : 'bash ./setup.sh', {stdio: 'inherit'})\"",
1516
"fetch:data": "ts-node -P tsconfig-script.json ./scripts/marketMap.ts && ts-node -P tsconfig-script.json ./scripts/tokens.ts && ts-node -P tsconfig-script.json ./scripts/restriction.ts && ts-node -P tsconfig-script.json ./scripts/swap.ts && ts-node -P tsconfig-script.json ./scripts/denom.ts",
1617
"github:version": "ts-node -P tsconfig-script.json ./scripts/github.ts",
1718
"dev": "nuxi dev",

setup.ps1

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# 🚀 PDAAS One-Click Setup Script (Windows PowerShell)
2+
# This script will install Node.js, Yarn, dependencies, and get you ready to dev!
3+
4+
$ErrorActionPreference = "Stop"
5+
6+
Write-Host "🌟 Welcome to PDAAS Setup!" -ForegroundColor Cyan
7+
Write-Host "================================" -ForegroundColor Cyan
8+
Write-Host ""
9+
10+
# Function to print colored output
11+
function Print-Success {
12+
param([string]$message)
13+
Write-Host "$message" -ForegroundColor Green
14+
}
15+
16+
function Print-Error {
17+
param([string]$message)
18+
Write-Host "$message" -ForegroundColor Red
19+
}
20+
21+
function Print-Info {
22+
param([string]$message)
23+
Write-Host "$message" -ForegroundColor Yellow
24+
}
25+
26+
# Check if Node.js is installed
27+
Print-Info "Checking Node.js version..."
28+
try {
29+
$nodeVersion = (node --version).Substring(1).Split('.')[0]
30+
if ([int]$nodeVersion -ge 20 -and [int]$nodeVersion -lt 23) {
31+
Print-Success "Node.js $(node --version) is installed and compatible!"
32+
} else {
33+
Print-Error "Node.js version $(node --version) found, but we need v20.x"
34+
Print-Info "Please install Node.js 20 from https://nodejs.org/"
35+
exit 1
36+
}
37+
} catch {
38+
Print-Error "Node.js is not installed"
39+
Print-Info "Please install Node.js 20 from https://nodejs.org/"
40+
Print-Info "Or use a version manager like nvm-windows or Volta"
41+
exit 1
42+
}
43+
44+
# Check if Yarn is installed
45+
Print-Info "Checking Yarn installation..."
46+
try {
47+
$yarnVersion = (yarn --version).Split('.')[0]
48+
if ([int]$yarnVersion -eq 1) {
49+
Print-Success "Yarn Classic $(yarn --version) is installed!"
50+
} else {
51+
Print-Info "Found Yarn $yarnVersion but we need Yarn Classic (v1)"
52+
Print-Info "Installing Yarn Classic via Corepack..."
53+
corepack enable
54+
corepack prepare yarn@1.22.22 --activate
55+
Print-Success "Yarn Classic installed!"
56+
}
57+
} catch {
58+
Print-Info "Installing Yarn Classic..."
59+
try {
60+
corepack enable
61+
corepack prepare yarn@1.22.22 --activate
62+
Print-Success "Yarn Classic installed via Corepack!"
63+
} catch {
64+
Print-Info "Corepack not available, using npm..."
65+
npm install -g yarn@1.22.22
66+
Print-Success "Yarn Classic installed via npm!"
67+
}
68+
}
69+
70+
# Create .env file if it doesn't exist
71+
Print-Info "Setting up environment variables..."
72+
if (-not (Test-Path .env)) {
73+
Copy-Item .env.example .env
74+
Print-Success "Created .env file from .env.example"
75+
Print-Info "You can customize .env later if needed"
76+
} else {
77+
Print-Success ".env file already exists"
78+
}
79+
80+
# Install dependencies
81+
Print-Info "Installing project dependencies (this may take a few minutes)..."
82+
yarn install
83+
84+
Print-Success "Dependencies installed!"
85+
86+
Write-Host ""
87+
Write-Host "================================" -ForegroundColor Cyan
88+
Write-Host "🎉 Setup Complete!" -ForegroundColor Green
89+
Write-Host "================================" -ForegroundColor Cyan
90+
Write-Host ""
91+
Write-Host "You're all set! To start developing:" -ForegroundColor White
92+
Write-Host ""
93+
Write-Host " yarn dev" -ForegroundColor Yellow
94+
Write-Host ""
95+
Write-Host "The app will be available at:" -ForegroundColor White
96+
Write-Host " http://127.0.0.1:3000" -ForegroundColor Yellow
97+
Write-Host ""
98+
Write-Host "Happy coding! 🚀" -ForegroundColor Cyan
99+
Write-Host ""
100+

setup.sh

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/bin/bash
2+
3+
# 🚀 PDAAS One-Click Setup Script
4+
# This script will install Node.js, Yarn, dependencies, and get you ready to dev!
5+
6+
set -e # Exit on any error
7+
8+
echo "🌟 Welcome to PDAAS Setup!"
9+
echo "================================"
10+
echo ""
11+
12+
# Colors for output
13+
RED='\033[0;31m'
14+
GREEN='\033[0;32m'
15+
YELLOW='\033[1;33m'
16+
NC='\033[0m' # No Color
17+
18+
# Function to print colored output
19+
print_success() {
20+
echo -e "${GREEN}${NC} $1"
21+
}
22+
23+
print_error() {
24+
echo -e "${RED}${NC} $1"
25+
}
26+
27+
print_info() {
28+
echo -e "${YELLOW}${NC} $1"
29+
}
30+
31+
# Check if Node.js 20 is installed
32+
print_info "Checking Node.js version..."
33+
if command -v node &> /dev/null; then
34+
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
35+
if [ "$NODE_VERSION" -ge 20 ] && [ "$NODE_VERSION" -lt 23 ]; then
36+
print_success "Node.js $(node -v) is installed and compatible!"
37+
else
38+
print_error "Node.js version $(node -v) found, but we need v20.x"
39+
print_info "Installing Node.js 20..."
40+
41+
# Try to install via nvm if available
42+
if command -v nvm &> /dev/null; then
43+
nvm install 20
44+
nvm use 20
45+
print_success "Node.js 20 installed via nvm!"
46+
else
47+
print_error "Please install Node.js 20 manually from https://nodejs.org/"
48+
print_info "Or install nvm first: curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash"
49+
exit 1
50+
fi
51+
fi
52+
else
53+
print_error "Node.js is not installed"
54+
55+
# Try to install via nvm if available
56+
if [ -f "$HOME/.nvm/nvm.sh" ]; then
57+
print_info "Found nvm, installing Node.js 20..."
58+
source "$HOME/.nvm/nvm.sh"
59+
nvm install 20
60+
nvm use 20
61+
print_success "Node.js 20 installed via nvm!"
62+
else
63+
print_error "Please install Node.js 20 first!"
64+
print_info "Easiest way: Install nvm and run this script again"
65+
print_info "curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash"
66+
print_info "Then restart your terminal and run this script again"
67+
exit 1
68+
fi
69+
fi
70+
71+
# Check if Yarn is installed
72+
print_info "Checking Yarn installation..."
73+
if command -v yarn &> /dev/null; then
74+
YARN_VERSION=$(yarn --version | cut -d'.' -f1)
75+
if [ "$YARN_VERSION" -eq 1 ]; then
76+
print_success "Yarn Classic $(yarn --version) is installed!"
77+
else
78+
print_info "Found Yarn $YARN_VERSION but we need Yarn Classic (v1)"
79+
print_info "Installing Yarn Classic via Corepack..."
80+
corepack enable
81+
corepack prepare yarn@1.22.22 --activate
82+
print_success "Yarn Classic installed!"
83+
fi
84+
else
85+
print_info "Installing Yarn Classic..."
86+
if command -v corepack &> /dev/null; then
87+
corepack enable
88+
corepack prepare yarn@1.22.22 --activate
89+
print_success "Yarn Classic installed via Corepack!"
90+
else
91+
print_info "Corepack not available, using npm..."
92+
npm install -g yarn@1.22.22
93+
print_success "Yarn Classic installed via npm!"
94+
fi
95+
fi
96+
97+
# Create .env file if it doesn't exist
98+
print_info "Setting up environment variables..."
99+
if [ ! -f .env ]; then
100+
cp .env.example .env
101+
print_success "Created .env file from .env.example"
102+
print_info "You can customize .env later if needed"
103+
else
104+
print_success ".env file already exists"
105+
fi
106+
107+
# Install dependencies
108+
print_info "Installing project dependencies (this may take a few minutes)..."
109+
yarn install
110+
111+
print_success "Dependencies installed!"
112+
113+
echo ""
114+
echo "================================"
115+
echo -e "${GREEN}🎉 Setup Complete!${NC}"
116+
echo "================================"
117+
echo ""
118+
echo "You're all set! To start developing:"
119+
echo ""
120+
echo -e " ${YELLOW}yarn dev${NC}"
121+
echo ""
122+
echo "The app will be available at:"
123+
echo -e " ${YELLOW}http://127.0.0.1:3000${NC}"
124+
echo ""
125+
echo "Happy coding! 🚀"
126+
echo ""
127+

0 commit comments

Comments
 (0)