-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
135 lines (116 loc) · 3.69 KB
/
Copy pathinit.sh
File metadata and controls
135 lines (116 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
# tether -- Development Environment Setup
# This script is idempotent -- safe to re-run at any time.
# Run it at the start of every agent session to ensure deps are current.
set -euo pipefail
echo "========================================"
echo " tether -- Dev Environment Setup"
echo "========================================"
echo ""
# ------------------------------------------
# 1. Check required tools
# ------------------------------------------
echo "Checking required tools..."
check_tool() {
if ! command -v "$1" &> /dev/null; then
echo "ERROR: $1 is not installed. Please install it before continuing."
exit 1
fi
}
check_tool node
check_tool npm
check_tool git
# Check Node.js version (need >= 18)
NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1)
if [ "$NODE_VERSION" -lt 18 ]; then
echo "ERROR: Node.js >= 18 required. Current: $(node -v)"
exit 1
fi
echo " node: $(node -v)"
echo " npm: $(npm -v)"
echo " git: $(git --version)"
echo ""
# ------------------------------------------
# 2. Install dependencies (root workspace)
# ------------------------------------------
echo "Installing dependencies..."
if [ -f "package.json" ]; then
npm install
else
echo "WARNING: No package.json found at project root."
echo " If this is the initializer session, you need to scaffold the project first."
fi
echo ""
# ------------------------------------------
# 3. Install Azure Function dependencies
# ------------------------------------------
if [ -d "functions" ] && [ -f "functions/package.json" ]; then
echo "Installing Azure Function dependencies..."
(cd functions && npm install)
echo ""
fi
# ------------------------------------------
# 4. Generate Prisma client
# ------------------------------------------
if [ -f "prisma/schema.prisma" ]; then
echo "Generating Prisma client..."
npx prisma generate
echo ""
else
echo "NOTE: prisma/schema.prisma not found yet. Skipping Prisma generate."
echo ""
fi
# ------------------------------------------
# 5. Set up environment file
# ------------------------------------------
if [ -f ".env.example" ] && [ ! -f ".env.local" ]; then
echo "Creating .env.local from .env.example..."
cp .env.example .env.local
echo " IMPORTANT: Edit .env.local with your actual credentials."
echo ""
elif [ -f ".env.local" ]; then
echo ".env.local already exists -- skipping copy."
echo ""
fi
# ------------------------------------------
# 6. Run database migrations (if applicable)
# ------------------------------------------
if [ -f "prisma/schema.prisma" ] && [ -f ".env.local" ]; then
echo "Pushing database schema..."
npx prisma db push --skip-generate 2>/dev/null || {
echo "NOTE: prisma db push failed. This is expected if DATABASE_URL is not configured."
}
echo ""
fi
# ------------------------------------------
# 7. Status summary
# ------------------------------------------
echo "========================================"
echo " Setup Summary"
echo "========================================"
echo ""
echo " Node.js: $(node -v)"
echo " npm: $(npm -v)"
if [ -f "package.json" ]; then
echo " Root deps: installed"
else
echo " Root deps: NOT FOUND (need package.json)"
fi
if [ -f "prisma/schema.prisma" ]; then
echo " Prisma: schema found"
else
echo " Prisma: no schema yet"
fi
if [ -f ".env.local" ]; then
echo " Environment: .env.local exists"
else
echo " Environment: NO .env.local (create from .env.example)"
fi
echo ""
echo " To start dev server: ./scripts/dev-up.sh"
echo " To run tests: npm test"
echo " To check types: npx tsc --noEmit"
echo ""
echo "========================================"
echo " Ready!"
echo "========================================"