@gv-sh/specgen-app 0.1.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/release.yml +15 -3
- package/README.md +8 -2
- package/package.json +6 -4
- package/scripts/make-executable.sh +6 -0
- package/scripts/production.sh +90 -0
- package/scripts/setup.sh +47 -7
@@ -39,10 +39,22 @@ jobs:
|
|
39
39
|
- name: Install dependencies
|
40
40
|
run: npm install
|
41
41
|
|
42
|
-
- name: Test setup process
|
42
|
+
- name: Test setup and production process
|
43
43
|
run: |
|
44
|
-
#
|
45
|
-
|
44
|
+
# Create an automated setup process for CI environment
|
45
|
+
mkdir -p server
|
46
|
+
|
47
|
+
# Create a CI-specific .env file with a dummy API key
|
48
|
+
echo "OPENAI_API_KEY=sk-test1234\nNODE_ENV=test\nPORT=3000" > server/.env
|
49
|
+
|
50
|
+
# Run normal setup with the environment variable to indicate CI mode
|
51
|
+
CI=true npm run setup
|
52
|
+
|
53
|
+
# Make scripts executable
|
54
|
+
npm run make-executable
|
55
|
+
|
56
|
+
# Test production script in CI mode
|
57
|
+
CI=true timeout 10s ./scripts/production.sh || true
|
46
58
|
|
47
59
|
# Verify all components are extracted
|
48
60
|
if [ ! -d "server" ]; then
|
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SpecGen App - Complete Platform
|
2
2
|
|
3
|
-
[](https://github.com/gv-sh/specgen-app)
|
4
4
|
|
5
5
|
A unified deployment package for the SpecGen speculative fiction generator platform.
|
6
6
|
|
@@ -16,14 +16,20 @@ A unified deployment package for the SpecGen speculative fiction generator platf
|
|
16
16
|
```bash
|
17
17
|
npm run setup
|
18
18
|
```
|
19
|
+
During setup, you'll be prompted to enter your OpenAI API key.
|
19
20
|
|
20
|
-
2. **Add OpenAI API Key** to `server/.env`
|
21
|
+
2. **Add OpenAI API Key** to `server/.env` if you skipped during setup
|
21
22
|
|
22
23
|
3. **Start Development**:
|
23
24
|
```bash
|
24
25
|
npm run dev
|
25
26
|
```
|
26
27
|
|
28
|
+
4. **Start Production** (optimized build with API key validation):
|
29
|
+
```bash
|
30
|
+
npm run production
|
31
|
+
```
|
32
|
+
|
27
33
|
## Access URLs
|
28
34
|
|
29
35
|
- User Interface: http://localhost:3002
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@gv-sh/specgen-app",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.0",
|
4
4
|
"description": "Complete SpecGen application with server, admin, and user interfaces",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -8,6 +8,8 @@
|
|
8
8
|
"dev": "chmod +x scripts/dev.sh && ./scripts/dev.sh",
|
9
9
|
"build": "cd admin && npm run build && cd ../user && npm run build",
|
10
10
|
"start": "cd server && npm start",
|
11
|
+
"production": "chmod +x scripts/production.sh && ./scripts/production.sh",
|
12
|
+
"make-executable": "chmod +x scripts/make-executable.sh && ./scripts/make-executable.sh",
|
11
13
|
"deploy": "chmod +x scripts/deploy.sh && ./scripts/deploy.sh",
|
12
14
|
"deploy:stop": "chmod +x scripts/stop.sh && ./scripts/stop.sh",
|
13
15
|
"deploy:restart": "chmod +x scripts/restart.sh && ./scripts/restart.sh",
|
@@ -17,9 +19,9 @@
|
|
17
19
|
"troubleshoot": "chmod +x scripts/troubleshoot.sh && ./scripts/troubleshoot.sh"
|
18
20
|
},
|
19
21
|
"dependencies": {
|
20
|
-
"@gv-sh/specgen-server": "
|
21
|
-
"@gv-sh/specgen-admin": "
|
22
|
-
"@gv-sh/specgen-user": "
|
22
|
+
"@gv-sh/specgen-server": "0.9.0",
|
23
|
+
"@gv-sh/specgen-admin": "0.9.0",
|
24
|
+
"@gv-sh/specgen-user": "0.9.0"
|
23
25
|
},
|
24
26
|
"devDependencies": {
|
25
27
|
"concurrently": "^8.2.2"
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# SpecGen Production Script
|
4
|
+
set -e
|
5
|
+
|
6
|
+
echo "🚀 Starting SpecGen in production mode..."
|
7
|
+
|
8
|
+
# Function to check if port is available
|
9
|
+
check_port() {
|
10
|
+
local port=$1
|
11
|
+
if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
|
12
|
+
return 1 # Port in use
|
13
|
+
else
|
14
|
+
return 0 # Port available
|
15
|
+
fi
|
16
|
+
}
|
17
|
+
|
18
|
+
# Verify OpenAI API key
|
19
|
+
if [ -f "server/.env" ]; then
|
20
|
+
# In CI mode, skip API key validation
|
21
|
+
if [ "$CI" = "true" ]; then
|
22
|
+
echo "CI mode detected - skipping API key validation"
|
23
|
+
elif grep -q "OPENAI_API_KEY=your_openai_api_key_here" server/.env; then
|
24
|
+
echo "⚠️ No OpenAI API key detected!"
|
25
|
+
echo "Enter your OpenAI API key: "
|
26
|
+
read -r OPENAI_KEY
|
27
|
+
|
28
|
+
if [ -z "$OPENAI_KEY" ]; then
|
29
|
+
echo "❌ No API key provided. Cannot start in production mode."
|
30
|
+
exit 1
|
31
|
+
else
|
32
|
+
# Update the API key in the .env file
|
33
|
+
sed -i.bak "s/OPENAI_API_KEY=.*/OPENAI_API_KEY=$OPENAI_KEY/" server/.env
|
34
|
+
rm -f server/.env.bak
|
35
|
+
echo "✅ API key updated in server/.env"
|
36
|
+
fi
|
37
|
+
fi
|
38
|
+
else
|
39
|
+
echo "❌ server/.env file not found. Run 'npm run setup' first."
|
40
|
+
exit 1
|
41
|
+
fi
|
42
|
+
|
43
|
+
# Verify directories exist
|
44
|
+
for dir in server admin user; do
|
45
|
+
if [ ! -d "$dir" ]; then
|
46
|
+
echo "❌ $dir directory not found. Run 'npm run setup' first."
|
47
|
+
exit 1
|
48
|
+
fi
|
49
|
+
done
|
50
|
+
|
51
|
+
# Check if dependencies are installed
|
52
|
+
for dir in server admin user; do
|
53
|
+
if [ ! -d "$dir/node_modules" ]; then
|
54
|
+
echo "Installing $dir dependencies..."
|
55
|
+
cd "$dir" && npm install
|
56
|
+
cd ..
|
57
|
+
fi
|
58
|
+
done
|
59
|
+
|
60
|
+
# Set production environment
|
61
|
+
export NODE_ENV=production
|
62
|
+
|
63
|
+
echo "Building web interfaces..."
|
64
|
+
# Build React apps for production
|
65
|
+
cd admin && npm run build && cd ..
|
66
|
+
cd user && npm run build && cd ..
|
67
|
+
|
68
|
+
# Create production-ready .env for server
|
69
|
+
cat > server/.env.production << EOF
|
70
|
+
$(cat server/.env)
|
71
|
+
NODE_ENV=production
|
72
|
+
EOF
|
73
|
+
|
74
|
+
# Kill existing processes on required ports if needed
|
75
|
+
echo "Checking ports..."
|
76
|
+
for port in 3000 3001 3002; do
|
77
|
+
if ! check_port $port; then
|
78
|
+
echo "Port $port is in use. Attempting to free it..."
|
79
|
+
lsof -ti:$port | xargs kill -9 2>/dev/null || true
|
80
|
+
sleep 1
|
81
|
+
fi
|
82
|
+
done
|
83
|
+
|
84
|
+
# Start production server
|
85
|
+
echo "Starting production server..."
|
86
|
+
if [ "$CI" = "true" ]; then
|
87
|
+
echo "CI mode detected - skipping server start"
|
88
|
+
else
|
89
|
+
cd server && NODE_ENV=production npm start
|
90
|
+
fi
|
package/scripts/setup.sh
CHANGED
@@ -107,14 +107,50 @@ done
|
|
107
107
|
echo "🔧 Setting up environment files..."
|
108
108
|
|
109
109
|
# Server .env
|
110
|
-
if [ ! -f server/.env ]; then
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
if [ ! -f server/.env ] || [ "$CI" = "true" ]; then
|
111
|
+
# If in CI mode, use a dummy key
|
112
|
+
if [ "$CI" = "true" ]; then
|
113
|
+
# If in CI environment and .env already exists, just use it
|
114
|
+
if [ -f server/.env ]; then
|
115
|
+
echo "Using existing .env file for CI environment"
|
116
|
+
else
|
117
|
+
# Create a CI .env file
|
118
|
+
cat > server/.env << EOF
|
119
|
+
OPENAI_API_KEY=sk-test1234
|
120
|
+
NODE_ENV=test
|
121
|
+
PORT=3000
|
122
|
+
EOF
|
123
|
+
echo "Created test .env file for CI environment"
|
124
|
+
fi
|
125
|
+
KEY_PROVIDED=true
|
126
|
+
else
|
127
|
+
# Normal interactive mode
|
128
|
+
# Prompt for OpenAI API key
|
129
|
+
echo "To use SpecGen, you need an OpenAI API key."
|
130
|
+
echo "Enter your OpenAI API key (or press enter to set it later): "
|
131
|
+
read -r OPENAI_KEY
|
132
|
+
|
133
|
+
# If key is provided, use it, otherwise use placeholder
|
134
|
+
if [ -z "$OPENAI_KEY" ]; then
|
135
|
+
OPENAI_KEY="your_openai_api_key_here"
|
136
|
+
KEY_PROVIDED=false
|
137
|
+
else
|
138
|
+
KEY_PROVIDED=true
|
139
|
+
fi
|
140
|
+
|
141
|
+
cat > server/.env << EOF
|
142
|
+
# OpenAI API key
|
143
|
+
OPENAI_API_KEY=$OPENAI_KEY
|
114
144
|
NODE_ENV=development
|
115
145
|
PORT=3000
|
116
146
|
EOF
|
117
|
-
|
147
|
+
|
148
|
+
if [ "$KEY_PROVIDED" = true ]; then
|
149
|
+
echo "✅ OpenAI API key saved to server/.env"
|
150
|
+
else
|
151
|
+
echo "⚠️ No OpenAI API key provided. You'll need to add it later to server/.env"
|
152
|
+
fi
|
153
|
+
fi
|
118
154
|
fi
|
119
155
|
|
120
156
|
# Admin .env.development
|
@@ -140,8 +176,12 @@ fi
|
|
140
176
|
echo "✅ Setup complete!"
|
141
177
|
echo ""
|
142
178
|
echo "Next steps:"
|
143
|
-
|
144
|
-
echo "
|
179
|
+
if [ "$KEY_PROVIDED" = false ]; then
|
180
|
+
echo "1. Add your OpenAI API key to server/.env"
|
181
|
+
echo "2. Run 'npm run dev' to start all services"
|
182
|
+
else
|
183
|
+
echo "1. Run 'npm run dev' to start all services"
|
184
|
+
fi
|
145
185
|
echo ""
|
146
186
|
echo "Access URLs:"
|
147
187
|
echo " 🌐 User Interface: http://localhost:3002"
|