@gv-sh/specgen-app 0.1.3

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.
@@ -0,0 +1,2 @@
1
+ GENERATE_SOURCEMAP=true
2
+ SKIP_PREFLIGHT_CHECK=true
@@ -0,0 +1,49 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*' # Triggers on version tags like v0.1.0, v0.1.1, etc.
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout code
14
+ uses: actions/checkout@v4
15
+
16
+ - name: Setup Node.js
17
+ uses: actions/setup-node@v4
18
+ with:
19
+ node-version: '18'
20
+ registry-url: 'https://registry.npmjs.org'
21
+
22
+ - name: Install dependencies
23
+ run: npm install
24
+
25
+ - name: Test setup process
26
+ run: |
27
+ # Run setup to verify everything works
28
+ npm run setup
29
+
30
+ # Verify all components are extracted
31
+ if [ ! -d "server" ]; then
32
+ echo "Error: server directory not found"
33
+ exit 1
34
+ fi
35
+ if [ ! -d "admin" ]; then
36
+ echo "Error: admin directory not found"
37
+ exit 1
38
+ fi
39
+ if [ ! -d "user" ]; then
40
+ echo "Error: user directory not found"
41
+ exit 1
42
+ fi
43
+
44
+ echo "Setup verification completed successfully"
45
+
46
+ - name: Publish to NPM
47
+ run: npm publish
48
+ env:
49
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # SpecGen App - Complete Platform
2
+
3
+ A unified deployment package for the SpecGen speculative fiction generator platform.
4
+
5
+ ## Components
6
+
7
+ - **Server**: Node.js API with OpenAI integration
8
+ - **Admin**: React admin interface for content management
9
+ - **User**: React user interface for story generation
10
+
11
+ ## Quick Start
12
+
13
+ 1. **Setup**:
14
+ ```bash
15
+ npm run setup
16
+ ```
17
+
18
+ 2. **Add OpenAI API Key** to `server/.env`
19
+
20
+ 3. **Start Development**:
21
+ ```bash
22
+ npm run dev
23
+ ```
24
+
25
+ ## Access URLs
26
+
27
+ - User Interface: http://localhost:3002
28
+ - Admin Interface: http://localhost:3001
29
+ - API: http://localhost:3000
30
+
31
+ ## Production Deployment
32
+
33
+ ### Build
34
+ ```bash
35
+ npm run build
36
+ npm start
37
+ ```
38
+
39
+ ### AWS Deployment
40
+
41
+ 1. Launch Ubuntu 22.04 instance with SSH access
42
+ 2. Run deployment script:
43
+
44
+ ```bash
45
+ # On AWS instance
46
+ wget https://github.com/gv-sh/specgen-app/raw/main/scripts/deploy.sh
47
+ chmod +x deploy.sh
48
+ sudo ./deploy.sh
49
+ ```
50
+
51
+ ## Management Commands
52
+
53
+ ```bash
54
+ # Stop services
55
+ npm run deploy:stop
56
+
57
+ # Restart services
58
+ npm run deploy:restart
59
+
60
+ # Update to latest
61
+ npm run deploy:update
62
+
63
+ # Check status
64
+ npm run deploy:status
65
+
66
+ # Create backup
67
+ npm run deploy:backup
68
+ ```
69
+
70
+ ## Troubleshooting
71
+
72
+ If you encounter issues:
73
+
74
+ ```bash
75
+ npm run troubleshoot
76
+ ```
77
+
78
+ This will check your setup and identify common problems.
79
+
80
+ ## Environment Variables
81
+
82
+ The setup script creates necessary environment files automatically. You only need to add your OpenAI API key to `server/.env`.
package/cleanup.sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ # Remove backup scripts
4
+ echo "🧹 Removing backup script files..."
5
+ rm -f scripts/*.backup
6
+ echo "✅ Cleanup complete!"
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@gv-sh/specgen-app",
3
+ "version": "0.1.3",
4
+ "description": "Complete SpecGen application with server, admin, and user interfaces",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "setup": "chmod +x scripts/setup.sh && ./scripts/setup.sh",
8
+ "dev": "chmod +x scripts/dev.sh && ./scripts/dev.sh",
9
+ "build": "cd admin && npm run build && cd ../user && npm run build",
10
+ "start": "cd server && npm start",
11
+ "deploy": "chmod +x scripts/deploy.sh && ./scripts/deploy.sh",
12
+ "deploy:stop": "chmod +x scripts/stop.sh && ./scripts/stop.sh",
13
+ "deploy:restart": "chmod +x scripts/restart.sh && ./scripts/restart.sh",
14
+ "deploy:update": "chmod +x scripts/update.sh && ./scripts/update.sh",
15
+ "deploy:status": "chmod +x scripts/status.sh && ./scripts/status.sh",
16
+ "deploy:backup": "chmod +x scripts/backup.sh && ./scripts/backup.sh",
17
+ "troubleshoot": "chmod +x scripts/troubleshoot.sh && ./scripts/troubleshoot.sh"
18
+ },
19
+ "dependencies": {
20
+ "@gv-sh/specgen-server": "*",
21
+ "@gv-sh/specgen-admin": "*",
22
+ "@gv-sh/specgen-user": "*"
23
+ },
24
+ "devDependencies": {
25
+ "concurrently": "^8.2.2"
26
+ },
27
+ "author": "gv-sh",
28
+ "publishConfig": {
29
+ "access": "public"
30
+ }
31
+ }
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+
3
+ # Backup SpecGen application and database
4
+ set -e
5
+
6
+ BACKUP_DIR="/opt/backups/specgen"
7
+ DATE=$(date +%Y%m%d-%H%M%S)
8
+ BACKUP_NAME="specgen-backup-$DATE"
9
+
10
+ echo "Creating backup: $BACKUP_NAME"
11
+
12
+ # Create backup directory
13
+ sudo mkdir -p $BACKUP_DIR
14
+
15
+ # Stop services for consistent backup
16
+ pm2 stop specgen-server
17
+
18
+ # Create backup
19
+ echo "Backing up application files..."
20
+ sudo tar -czf "$BACKUP_DIR/$BACKUP_NAME.tar.gz" -C /opt specgen-app
21
+
22
+ # Backup database separately if it exists
23
+ if [ -f /opt/specgen-app/server/data/database.json ]; then
24
+ echo "Backing up database..."
25
+ sudo cp /opt/specgen-app/server/data/database.json "$BACKUP_DIR/database-$DATE.json"
26
+ fi
27
+
28
+ # Restart services
29
+ pm2 start ecosystem.config.js
30
+
31
+ # Clean old backups (keep last 5)
32
+ echo "Cleaning old backups..."
33
+ cd $BACKUP_DIR
34
+ sudo ls -t *.tar.gz | tail -n +6 | sudo xargs rm -f || true
35
+ sudo ls -t database-*.json | tail -n +6 | sudo xargs rm -f || true
36
+
37
+ echo "Backup completed: $BACKUP_DIR/$BACKUP_NAME.tar.gz"
@@ -0,0 +1,189 @@
1
+ #!/bin/bash
2
+
3
+ # AWS Ubuntu Deployment Script for SpecGen
4
+ set -e
5
+
6
+ # Colors for output
7
+ RED='\033[0;31m'
8
+ GREEN='\033[0;32m'
9
+ YELLOW='\033[1;33m'
10
+ NC='\033[0m' # No Color
11
+
12
+ echo -e "${GREEN}Starting SpecGen deployment...${NC}"
13
+
14
+ # Update system
15
+ echo -e "${YELLOW}Updating system packages...${NC}"
16
+ sudo apt update && sudo apt upgrade -y
17
+
18
+ # Install Node.js 18
19
+ echo -e "${YELLOW}Installing Node.js 18...${NC}"
20
+ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
21
+ sudo apt-get install -y nodejs
22
+
23
+ # Install PM2
24
+ echo -e "${YELLOW}Installing PM2...${NC}"
25
+ sudo npm install -g pm2
26
+
27
+ # Install Nginx
28
+ echo -e "${YELLOW}Installing Nginx...${NC}"
29
+ sudo apt install -y nginx
30
+
31
+ # Create application directory
32
+ sudo mkdir -p /opt/specgen-app
33
+ cd /opt/specgen-app
34
+
35
+ # Download and extract packages
36
+ echo -e "${YELLOW}Downloading SpecGen packages...${NC}"
37
+ npm pack @gv-sh/specgen-server
38
+ npm pack @gv-sh/specgen-admin
39
+ npm pack @gv-sh/specgen-user
40
+
41
+ # Extract packages
42
+ tar -xzf gv-sh-specgen-server-*.tgz && mv package server
43
+ tar -xzf gv-sh-specgen-admin-*.tgz && mv package admin
44
+ tar -xzf gv-sh-specgen-user-*.tgz && mv package user
45
+
46
+ # Install dependencies
47
+ echo -e "${YELLOW}Installing dependencies...${NC}"
48
+ cd server && npm install --production
49
+ cd ../admin && npm install --production
50
+ cd ../user && npm install --production
51
+ cd ..
52
+
53
+ # Setup environment
54
+ echo -e "${YELLOW}Setting up environment...${NC}"
55
+ read -p "Enter your OpenAI API key: " OPENAI_KEY
56
+ read -p "Enter your domain (or IP): " DOMAIN
57
+
58
+ # Server .env
59
+ echo "OPENAI_API_KEY=$OPENAI_KEY" | sudo tee server/.env
60
+ echo "NODE_ENV=production" | sudo tee -a server/.env
61
+ echo "PORT=3000" | sudo tee -a server/.env
62
+
63
+ # Admin .env.production
64
+ echo "REACT_APP_API_URL=http://$DOMAIN" | sudo tee admin/.env.production
65
+ echo "GENERATE_SOURCEMAP=false" | sudo tee -a admin/.env.production
66
+
67
+ # User .env.production
68
+ echo "REACT_APP_API_URL=http://$DOMAIN" | sudo tee user/.env.production
69
+ echo "GENERATE_SOURCEMAP=false" | sudo tee -a user/.env.production
70
+
71
+ # Build React apps
72
+ echo -e "${YELLOW}Building React applications...${NC}"
73
+ cd admin && NODE_ENV=production npm run build
74
+ cd ../user && NODE_ENV=production npm run build
75
+ cd ..
76
+
77
+ # Create PM2 ecosystem
78
+ cat > ecosystem.config.js << 'EOF'
79
+ module.exports = {
80
+ apps: [{
81
+ name: 'specgen-server',
82
+ script: './server/index.js',
83
+ instances: 1,
84
+ autorestart: true,
85
+ watch: false,
86
+ max_memory_restart: '512M',
87
+ env: {
88
+ NODE_ENV: 'production',
89
+ PORT: 3000
90
+ }
91
+ }]
92
+ };
93
+ EOF
94
+
95
+ # Start server with PM2
96
+ echo -e "${YELLOW}Starting server with PM2...${NC}"
97
+ pm2 start ecosystem.config.js
98
+ pm2 startup
99
+ pm2 save
100
+
101
+ # Configure Nginx
102
+ echo -e "${YELLOW}Configuring Nginx...${NC}"
103
+ sudo tee /etc/nginx/sites-available/specgen << 'EOF'
104
+ server {
105
+ listen 80 default_server;
106
+ server_name _;
107
+
108
+ # API
109
+ location /api/ {
110
+ proxy_pass http://localhost:3000/api/;
111
+ proxy_http_version 1.1;
112
+ proxy_set_header Upgrade $http_upgrade;
113
+ proxy_set_header Connection 'upgrade';
114
+ proxy_set_header Host $host;
115
+ proxy_set_header X-Real-IP $remote_addr;
116
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
117
+ proxy_set_header X-Forwarded-Proto $scheme;
118
+ proxy_cache_bypass $http_upgrade;
119
+ }
120
+
121
+ # Admin UI
122
+ location /admin/ {
123
+ alias /opt/specgen-app/admin/build/;
124
+ try_files $uri $uri/ /admin/index.html;
125
+ }
126
+
127
+ # User UI (default)
128
+ location / {
129
+ root /opt/specgen-app/user/build;
130
+ try_files $uri $uri/ /index.html;
131
+ }
132
+
133
+ # Security headers
134
+ add_header X-Frame-Options DENY;
135
+ add_header X-Content-Type-Options nosniff;
136
+ add_header X-XSS-Protection "1; mode=block";
137
+
138
+ # Gzip compression
139
+ gzip on;
140
+ gzip_comp_level 5;
141
+ gzip_min_length 256;
142
+ gzip_proxied any;
143
+ gzip_vary on;
144
+ gzip_types
145
+ application/javascript
146
+ application/json
147
+ application/x-javascript
148
+ application/xml
149
+ application/xml+rss
150
+ text/css
151
+ text/javascript
152
+ text/plain
153
+ text/xml;
154
+ }
155
+ EOF
156
+
157
+ # Enable site
158
+ sudo ln -sf /etc/nginx/sites-available/specgen /etc/nginx/sites-enabled/
159
+ sudo rm -f /etc/nginx/sites-enabled/default
160
+
161
+ # Test and reload Nginx
162
+ sudo nginx -t
163
+ sudo systemctl restart nginx
164
+
165
+ # Configure firewall
166
+ echo -e "${YELLOW}Configuring firewall...${NC}"
167
+ sudo ufw allow ssh
168
+ sudo ufw allow 'Nginx Full'
169
+ sudo ufw --force enable
170
+
171
+ # Initialize database
172
+ echo -e "${YELLOW}Initializing database...${NC}"
173
+ cd server && npm run init-db
174
+
175
+ echo -e "${GREEN}Deployment complete!${NC}"
176
+ echo -e "${GREEN}Access your application at:${NC}"
177
+ echo -e " User Interface: http://your-server-ip/"
178
+ echo -e " Admin Interface: http://your-server-ip/admin/"
179
+ echo -e " API: http://your-server-ip/api/"
180
+
181
+ # Setup SSL (optional)
182
+ read -p "Would you like to set up SSL with Let's Encrypt? (y/n): " setup_ssl
183
+ if [[ $setup_ssl == "y" ]]; then
184
+ read -p "Enter your domain name: " domain_name
185
+ sudo apt install -y certbot python3-certbot-nginx
186
+ sudo certbot --nginx -d $domain_name
187
+ fi
188
+
189
+ echo -e "${GREEN}Setup complete!${NC}"
package/scripts/dev.sh ADDED
@@ -0,0 +1,56 @@
1
+ #!/bin/bash
2
+
3
+ # SpecGen Development Script
4
+ set -e
5
+
6
+ echo "🚀 Starting SpecGen development servers..."
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
+ # Kill existing processes on required ports if needed
19
+ echo "Checking ports..."
20
+ for port in 3000 3001 3002; do
21
+ if ! check_port $port; then
22
+ echo "Port $port is in use. Attempting to free it..."
23
+ lsof -ti:$port | xargs kill -9 2>/dev/null || true
24
+ sleep 1
25
+ fi
26
+ done
27
+
28
+ # Verify directories exist
29
+ for dir in server admin user; do
30
+ if [ ! -d "$dir" ]; then
31
+ echo "❌ $dir directory not found. Run 'npm run setup' first."
32
+ exit 1
33
+ fi
34
+ done
35
+
36
+ # Check if dependencies are installed
37
+ for dir in server admin user; do
38
+ if [ ! -d "$dir/node_modules" ]; then
39
+ echo "Installing $dir dependencies..."
40
+ cd "$dir" && npm install
41
+ cd ..
42
+ fi
43
+ done
44
+
45
+ # Set development environment
46
+ export NODE_ENV=development
47
+
48
+ # Start development servers
49
+ echo "Starting development servers..."
50
+ npx concurrently \
51
+ --prefix "[{name}]" \
52
+ --names "server,admin,user" \
53
+ --prefix-colors "cyan,magenta,yellow" \
54
+ "cd server && npm run dev" \
55
+ "cd admin && npm start" \
56
+ "cd user && npm start"
@@ -0,0 +1,19 @@
1
+ #!/bin/bash
2
+
3
+ # Restart SpecGen services
4
+ set -e
5
+
6
+ echo "Restarting SpecGen services..."
7
+
8
+ # Restart PM2 processes
9
+ pm2 restart specgen-server || echo "Starting server..."
10
+ pm2 start ecosystem.config.js || echo "Server started"
11
+
12
+ # Restart Nginx
13
+ sudo systemctl restart nginx
14
+
15
+ # Show status
16
+ pm2 status
17
+ sudo systemctl status nginx --no-pager -l
18
+
19
+ echo "SpecGen restarted successfully"
@@ -0,0 +1,149 @@
1
+ #!/bin/bash
2
+
3
+ # SpecGen App Setup Script
4
+ set -e
5
+
6
+ echo "🚀 Setting up SpecGen App..."
7
+
8
+ # Check Node.js
9
+ if ! command -v npm &> /dev/null; then
10
+ echo "❌ npm not found. Please install Node.js from https://nodejs.org/"
11
+ exit 1
12
+ fi
13
+
14
+ # Function to safely remove directories with permission handling
15
+ safe_remove() {
16
+ if [ -d "$1" ]; then
17
+ echo "Removing $1..."
18
+ chmod -R u+w "$1" 2>/dev/null || true
19
+ rm -rf "$1" 2>/dev/null || true
20
+ # If still exists, try with sudo
21
+ if [ -d "$1" ]; then
22
+ echo "Using elevated permissions to remove $1..."
23
+ sudo rm -rf "$1" 2>/dev/null || true
24
+ fi
25
+ fi
26
+ }
27
+
28
+ # Clean existing directories with proper permission handling
29
+ echo "Cleaning existing directories..."
30
+ safe_remove "server"
31
+ safe_remove "admin"
32
+ safe_remove "user"
33
+ rm -f *.tgz package 2>/dev/null || true
34
+
35
+ # Install dependencies to get latest versions
36
+ echo "📦 Installing dependencies..."
37
+ npm install
38
+
39
+ # Download npm packages
40
+ echo "📦 Downloading packages..."
41
+ npm pack @gv-sh/specgen-server
42
+ npm pack @gv-sh/specgen-admin
43
+ npm pack @gv-sh/specgen-user
44
+
45
+ # Extract packages
46
+ echo "📁 Extracting packages..."
47
+
48
+ # Extract server
49
+ if [ -f "gv-sh-specgen-server-"*.tgz ]; then
50
+ echo "Extracting server..."
51
+ tar -xzf gv-sh-specgen-server-*.tgz
52
+ mv package server
53
+ rm gv-sh-specgen-server-*.tgz
54
+ fi
55
+
56
+ # Extract admin
57
+ if [ -f "gv-sh-specgen-admin-"*.tgz ]; then
58
+ echo "Extracting admin..."
59
+ tar -xzf gv-sh-specgen-admin-*.tgz
60
+ mv package admin
61
+ rm gv-sh-specgen-admin-*.tgz
62
+ fi
63
+
64
+ # Extract user
65
+ if [ -f "gv-sh-specgen-user-"*.tgz ]; then
66
+ echo "Extracting user..."
67
+ tar -xzf gv-sh-specgen-user-*.tgz
68
+ mv package user
69
+ rm gv-sh-specgen-user-*.tgz
70
+ fi
71
+
72
+ # Patch package.json files to fix React scripts
73
+ echo "🔧 Patching package scripts..."
74
+
75
+ # Fix user package start script
76
+ if [ -f "user/package.json" ]; then
77
+ echo "Fixing user package start script..."
78
+ # Replace the start script to use react-scripts instead of missing scripts/start.js
79
+ sed -i.bak 's|"start": "cross-env PORT=3002 REACT_APP_API_URL=http://localhost:3000 node scripts/start.js"|"start": "cross-env PORT=3002 REACT_APP_API_URL=http://localhost:3000 react-scripts start"|g' user/package.json
80
+ rm -f user/package.json.bak
81
+ fi
82
+
83
+ # Fix admin package start script if needed
84
+ if [ -f "admin/package.json" ]; then
85
+ echo "Checking admin package start script..."
86
+ # Check if admin has similar issue
87
+ if grep -q "node scripts/start.js" admin/package.json; then
88
+ echo "Fixing admin package start script..."
89
+ sed -i.bak 's|node scripts/start.js|react-scripts start|g' admin/package.json
90
+ rm -f admin/package.json.bak
91
+ fi
92
+ fi
93
+
94
+ # Install dependencies for each component
95
+ echo "📚 Installing dependencies..."
96
+ for dir in server admin user; do
97
+ if [ -d "$dir" ]; then
98
+ echo "Installing $dir dependencies..."
99
+ cd "$dir" && npm install
100
+ cd ..
101
+ else
102
+ echo "⚠️ Warning: $dir directory not found"
103
+ fi
104
+ done
105
+
106
+ # Setup environment files
107
+ echo "🔧 Setting up environment files..."
108
+
109
+ # Server .env
110
+ if [ ! -f server/.env ]; then
111
+ cat > server/.env << 'EOF'
112
+ # Add your OpenAI API key here
113
+ OPENAI_API_KEY=your_openai_api_key_here
114
+ NODE_ENV=development
115
+ PORT=3000
116
+ EOF
117
+ echo "Created server/.env - Please add your OpenAI API key"
118
+ fi
119
+
120
+ # Admin .env.development
121
+ if [ -d admin ]; then
122
+ cat > admin/.env.development << 'EOF'
123
+ REACT_APP_API_URL=http://localhost:3000
124
+ PORT=3001
125
+ SKIP_PREFLIGHT_CHECK=true
126
+ GENERATE_SOURCEMAP=true
127
+ EOF
128
+ fi
129
+
130
+ # User .env.development
131
+ if [ -d user ]; then
132
+ cat > user/.env.development << 'EOF'
133
+ REACT_APP_API_URL=http://localhost:3000
134
+ PORT=3002
135
+ SKIP_PREFLIGHT_CHECK=true
136
+ GENERATE_SOURCEMAP=true
137
+ EOF
138
+ fi
139
+
140
+ echo "✅ Setup complete!"
141
+ echo ""
142
+ echo "Next steps:"
143
+ echo "1. Add your OpenAI API key to server/.env"
144
+ echo "2. Run 'npm run dev' to start all services"
145
+ echo ""
146
+ echo "Access URLs:"
147
+ echo " 🌐 User Interface: http://localhost:3002"
148
+ echo " ⚙️ Admin Interface: http://localhost:3001"
149
+ echo " 🔧 API: http://localhost:3000"
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+
3
+ # Show SpecGen application status
4
+ set -e
5
+
6
+ echo "=== SpecGen Application Status ==="
7
+
8
+ # PM2 processes
9
+ echo -e "\nPM2 Processes:"
10
+ pm2 list
11
+
12
+ # Nginx status
13
+ echo -e "\nNginx Status:"
14
+ sudo systemctl status nginx --no-pager -l
15
+
16
+ # Server logs (last 20 lines)
17
+ echo -e "\nServer Logs (last 20 lines):"
18
+ pm2 logs specgen-server --lines 20
19
+
20
+ # Disk usage of app directory
21
+ echo -e "\nDisk Usage:"
22
+ du -sh /opt/specgen-app
23
+
24
+ # Memory usage
25
+ echo -e "\nMemory Usage:"
26
+ free -h
27
+
28
+ # Port status
29
+ echo -e "\nPort Status:"
30
+ sudo netstat -tlpn | grep -E ':80|:3000|:443'
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+
3
+ # Stop SpecGen services
4
+ set -e
5
+
6
+ echo "Stopping SpecGen services..."
7
+
8
+ # Stop PM2 processes
9
+ pm2 stop specgen-server || echo "Server not running"
10
+
11
+ # Stop Nginx (optional - uncomment if needed)
12
+ # sudo systemctl stop nginx
13
+
14
+ echo "SpecGen stopped successfully"
@@ -0,0 +1,88 @@
1
+ #!/bin/bash
2
+
3
+ # SpecGen Troubleshooting Script
4
+ echo "🔍 SpecGen Troubleshooting"
5
+ echo "========================="
6
+
7
+ # Check Node.js and npm
8
+ echo "📦 Node.js/npm versions:"
9
+ node -v
10
+ npm -v
11
+ echo ""
12
+
13
+ # Check if packages are extracted
14
+ echo "📁 Component directories:"
15
+ for dir in server admin user; do
16
+ if [ -d "$dir" ]; then
17
+ echo " ✓ $dir exists"
18
+ if [ -f "$dir/package.json" ]; then
19
+ version=$(cat "$dir/package.json" | grep '"version"' | sed 's/.*"version": "\([^"]*\)".*/\1/')
20
+ echo " Version: $version"
21
+ fi
22
+ else
23
+ echo " ❌ $dir missing - run npm run setup"
24
+ fi
25
+ done
26
+ echo ""
27
+
28
+ # Check environment files
29
+ echo "🔧 Environment files:"
30
+ if [ -f "server/.env" ]; then
31
+ if grep -q "your_openai_api_key_here" server/.env; then
32
+ echo " ⚠️ server/.env needs OpenAI API key"
33
+ else
34
+ echo " ✓ server/.env configured"
35
+ fi
36
+ else
37
+ echo " ❌ server/.env missing"
38
+ fi
39
+
40
+ for dir in admin user; do
41
+ if [ -f "$dir/.env.development" ]; then
42
+ echo " ✓ $dir/.env.development exists"
43
+ else
44
+ echo " ❌ $dir/.env.development missing"
45
+ fi
46
+ done
47
+ echo ""
48
+
49
+ # Check port availability
50
+ echo "🌐 Port status:"
51
+ for port in 3000 3001 3002; do
52
+ if lsof -Pi :$port -sTCP:LISTEN -t >/dev/null 2>&1; then
53
+ process=$(lsof -Pi :$port -sTCP:LISTEN -t | xargs ps -o comm= -p)
54
+ echo " ❌ Port $port in use by: $process"
55
+ else
56
+ echo " ✓ Port $port available"
57
+ fi
58
+ done
59
+ echo ""
60
+
61
+ # Check dependencies
62
+ echo "📚 Dependencies:"
63
+ for dir in server admin user; do
64
+ if [ -d "$dir/node_modules" ]; then
65
+ echo " ✓ $dir/node_modules exists"
66
+ else
67
+ echo " ❌ $dir/node_modules missing - run: cd $dir && npm install"
68
+ fi
69
+ done
70
+ echo ""
71
+
72
+ # Check for common CSS/styling issues
73
+ echo "🎨 CSS and Build files:"
74
+ for dir in admin user; do
75
+ if [ -d "$dir" ]; then
76
+ echo " $dir:"
77
+ if [ -f "$dir/src/index.css" ]; then
78
+ echo " ✓ index.css exists"
79
+ else
80
+ echo " ❌ index.css missing"
81
+ fi
82
+ if [ -f "$dir/tailwind.config.js" ]; then
83
+ echo " ✓ tailwind.config.js exists"
84
+ else
85
+ echo " ⚠️ tailwind.config.js missing (may be normal)"
86
+ fi
87
+ fi
88
+ done
@@ -0,0 +1,72 @@
1
+ #!/bin/bash
2
+
3
+ # Update SpecGen to latest versions
4
+ set -e
5
+
6
+ echo "Updating SpecGen application..."
7
+
8
+ # Backup current deployment
9
+ echo "Creating backup..."
10
+ sudo cp -r /opt/specgen-app /opt/specgen-app-backup-$(date +%Y%m%d-%H%M%S)
11
+
12
+ # Stop services
13
+ echo "Stopping services..."
14
+ pm2 stop specgen-server
15
+
16
+ # Navigate to app directory
17
+ cd /opt/specgen-app
18
+
19
+ # Download latest packages
20
+ echo "Downloading latest packages..."
21
+ npm pack @gv-sh/specgen-server
22
+ npm pack @gv-sh/specgen-admin
23
+ npm pack @gv-sh/specgen-user
24
+
25
+ # Backup existing components
26
+ sudo mv server server-backup || true
27
+ sudo mv admin admin-backup || true
28
+ sudo mv user user-backup || true
29
+
30
+ # Extract new packages
31
+ echo "Extracting new packages..."
32
+ tar -xzf gv-sh-specgen-server-*.tgz && mv package server
33
+ tar -xzf gv-sh-specgen-admin-*.tgz && mv package admin
34
+ tar -xzf gv-sh-specgen-user-*.tgz && mv package user
35
+
36
+ # Clean up tgz files
37
+ rm -f *.tgz
38
+
39
+ # Patch package.json files to fix scripts
40
+ echo "Patching package scripts..."
41
+ chmod +x scripts/patch-packages.sh
42
+ ./scripts/patch-packages.sh
43
+
44
+ # Copy environment files from backup
45
+ echo "Restoring environment files..."
46
+ sudo cp server-backup/.env server/.env || echo "No server .env to restore"
47
+ sudo cp admin-backup/.env.production admin/.env.production || echo "No admin .env to restore"
48
+ sudo cp user-backup/.env.production user/.env.production || echo "No user .env to restore"
49
+
50
+ # Install dependencies
51
+ echo "Installing dependencies..."
52
+ cd server && npm install --production
53
+ cd ../admin && npm install --production
54
+ cd ../user && npm install --production
55
+ cd ..
56
+
57
+ # Build React apps
58
+ echo "Building React applications..."
59
+ cd admin && NODE_ENV=production npm run build
60
+ cd ../user && NODE_ENV=production npm run build
61
+ cd ..
62
+
63
+ # Start services
64
+ echo "Starting services..."
65
+ pm2 start ecosystem.config.js
66
+
67
+ # Clean up old backups (keep last 3)
68
+ echo "Cleaning up old component backups..."
69
+ sudo rm -rf server-backup admin-backup user-backup
70
+
71
+ echo "Update completed successfully!"
72
+ echo "Check logs with: pm2 logs specgen-server"