@gv-sh/specgen-app 0.3.0 → 0.4.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SpecGen App - Complete Platform
2
2
 
3
- [![Version](https://img.shields.io/badge/version-0.3.0-blue.svg)](https://github.com/gv-sh/specgen-app)
3
+ [![Version](https://img.shields.io/badge/version-0.4.0-blue.svg)](https://github.com/gv-sh/specgen-app)
4
4
 
5
5
  A unified deployment package for the SpecGen speculative fiction generator platform.
6
6
 
@@ -12,6 +12,25 @@ A unified deployment package for the SpecGen speculative fiction generator platf
12
12
 
13
13
  ## Quick Start
14
14
 
15
+ ### Using NPX (Recommended)
16
+
17
+ ```bash
18
+ # Create and enter your project directory
19
+ mkdir specgen-project
20
+ cd specgen-project
21
+
22
+ # Run setup directly with npx
23
+ npx @gv-sh/specgen-app setup
24
+
25
+ # Start in development mode
26
+ npx @gv-sh/specgen-app dev
27
+
28
+ # Or start in production mode
29
+ npx @gv-sh/specgen-app production
30
+ ```
31
+
32
+ ### Using NPM Scripts
33
+
15
34
  1. **Setup**:
16
35
  ```bash
17
36
  npm run setup
@@ -36,15 +55,127 @@ A unified deployment package for the SpecGen speculative fiction generator platf
36
55
  - Admin Interface: http://localhost:3001
37
56
  - API: http://localhost:3000
38
57
 
39
- ## Production Deployment
58
+ ## Deployment Options
59
+
60
+ ### Option 1: Quick NPX Deployment to Remote Server
61
+
62
+ If you have SSH access to a server (like an EC2 instance), this is the fastest way to deploy:
63
+
64
+ 1. **Save your SSH key** to a file (e.g., `key.pem`) and set permissions:
65
+ ```bash
66
+ chmod 400 key.pem
67
+ ```
68
+
69
+ 2. **SSH into your server**:
70
+ ```bash
71
+ ssh -i "key.pem" ubuntu@your-server-ip
72
+ ```
73
+
74
+ 3. **Install Node.js 18 or higher**:
75
+ ```bash
76
+ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
77
+ sudo apt-get install -y nodejs
78
+ ```
79
+
80
+ 4. **Install and run SpecGen**:
81
+ ```bash
82
+ # Create and enter project directory
83
+ mkdir specgen
84
+ cd specgen
85
+
86
+ # Run the setup
87
+ npx @gv-sh/specgen-app setup
88
+
89
+ # Start in production mode
90
+ npx @gv-sh/specgen-app production
91
+ ```
92
+
93
+ 5. **Keep the service running with PM2** (recommended):
94
+ ```bash
95
+ sudo npm install -g pm2
96
+ pm2 start "npx @gv-sh/specgen-app production" --name "specgen"
97
+ pm2 startup
98
+ pm2 save
99
+ ```
100
+
101
+ 6. **Access your application**:
102
+ - User Interface: http://your-server-ip:3002
103
+ - Admin Interface: http://your-server-ip:3001
104
+ - API: http://your-server-ip:3000
105
+
106
+ ### Option 2: Global NPM Package Deployment
107
+
108
+ #### Local Machine Deployment
109
+
110
+ 1. **Install globally** (recommended for deployment):
111
+ ```bash
112
+ npm install -g @gv-sh/specgen-app
113
+ ```
114
+
115
+ 2. **Create a project directory**:
116
+ ```bash
117
+ mkdir specgen-project
118
+ cd specgen-project
119
+ ```
120
+
121
+ 3. **Initialize and setup**:
122
+ ```bash
123
+ specgen-app setup
124
+ ```
125
+ During setup, you'll be prompted to enter your OpenAI API key.
126
+
127
+ 4. **Start the application**:
128
+ - Development mode: `specgen-app dev`
129
+ - Production mode: `specgen-app production`
130
+
131
+ #### Remote Server Deployment
132
+
133
+ 1. **SSH into your server**:
134
+ ```bash
135
+ ssh -i "your-key.pem" username@your-server
136
+ ```
137
+
138
+ 2. **Install Node.js** (if not already installed):
139
+ ```bash
140
+ curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
141
+ sudo apt-get install -y nodejs
142
+ ```
40
143
 
41
- ### Build
144
+ 3. **Create a project directory**:
145
+ ```bash
146
+ mkdir specgen
147
+ cd specgen
148
+ ```
149
+
150
+ 4. **Install SpecGen globally**:
151
+ ```bash
152
+ npm install -g @gv-sh/specgen-app
153
+ ```
154
+
155
+ 5. **Setup the application**:
156
+ ```bash
157
+ specgen-app setup
158
+ ```
159
+
160
+ 6. **Start in production mode**:
161
+ ```bash
162
+ specgen-app production
163
+ ```
164
+
165
+ ### Option 3: Manual Deployment
166
+
167
+ Alternatively, you can deploy manually using the repository:
168
+
169
+ #### Build and Run Locally
42
170
  ```bash
171
+ git clone https://github.com/gv-sh/specgen-app.git
172
+ cd specgen-app
173
+ npm run setup
43
174
  npm run build
44
- npm start
175
+ npm run production
45
176
  ```
46
177
 
47
- ### AWS Deployment
178
+ #### AWS Deployment Script
48
179
 
49
180
  1. Launch Ubuntu 22.04 instance with SSH access
50
181
  2. Run deployment script:
@@ -58,6 +189,28 @@ sudo ./deploy.sh
58
189
 
59
190
  ## Management Commands
60
191
 
192
+ When using NPX or global installation:
193
+ ```bash
194
+ # Check status
195
+ npx @gv-sh/specgen-app deploy:status
196
+ # or when installed globally
197
+ specgen-app deploy:status
198
+
199
+ # Stop services
200
+ npx @gv-sh/specgen-app deploy:stop
201
+ # or
202
+ specgen-app deploy:stop
203
+
204
+ # Restart services
205
+ npx @gv-sh/specgen-app deploy:restart
206
+ # or
207
+ specgen-app deploy:restart
208
+
209
+ # Update to latest version
210
+ npm update -g @gv-sh/specgen-app
211
+ ```
212
+
213
+ When using the repository:
61
214
  ```bash
62
215
  # Stop services
63
216
  npm run deploy:stop
@@ -75,11 +228,33 @@ npm run deploy:status
75
228
  npm run deploy:backup
76
229
  ```
77
230
 
231
+ ## Available Commands
232
+
233
+ The following commands are available when using `npx @gv-sh/specgen-app` or `specgen-app` (if installed globally):
234
+
235
+ - `setup` - Set up the SpecGen application
236
+ - `production` - Run the application in production mode
237
+ - `dev` - Run the application in development mode
238
+ - `deploy` - Deploy the application
239
+ - `deploy:stop` - Stop the deployed application
240
+ - `deploy:restart` - Restart the deployed application
241
+ - `deploy:update` - Update the deployed application
242
+ - `deploy:status` - Check the status of the deployed application
243
+ - `deploy:backup` - Create a backup of the deployed application
244
+ - `troubleshoot` - Run troubleshooting checks
245
+
78
246
  ## Troubleshooting
79
247
 
80
248
  If you encounter issues:
81
249
 
82
250
  ```bash
251
+ # Using npx
252
+ npx @gv-sh/specgen-app troubleshoot
253
+
254
+ # Using global installation
255
+ specgen-app troubleshoot
256
+
257
+ # For repository installation
83
258
  npm run troubleshoot
84
259
  ```
85
260
 
@@ -87,4 +262,4 @@ This will check your setup and identify common problems.
87
262
 
88
263
  ## Environment Variables
89
264
 
90
- The setup script creates necessary environment files automatically. You only need to add your OpenAI API key to `server/.env`.
265
+ The setup script creates necessary environment files automatically. You only need to add your OpenAI API key during setup or later to `server/.env`.
package/bin/cli.js ADDED
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execSync } = require('child_process');
4
+ const path = require('path');
5
+ const fs = require('fs');
6
+
7
+ // Find the root directory of the package
8
+ const findPackageRoot = () => {
9
+ // When installed as a dependency, the package will be in node_modules/@gv-sh/specgen-app
10
+ // When running directly from the package, we're already at the root
11
+ const packageJsonPath = path.resolve(__dirname, '../package.json');
12
+
13
+ if (fs.existsSync(packageJsonPath)) {
14
+ return path.dirname(packageJsonPath);
15
+ }
16
+
17
+ throw new Error('Could not locate package root directory');
18
+ };
19
+
20
+ const runScript = (scriptName) => {
21
+ try {
22
+ const packageRoot = findPackageRoot();
23
+ process.chdir(packageRoot);
24
+
25
+ console.log(`📦 Running ${scriptName} script...`);
26
+ execSync(`npm run ${scriptName}`, { stdio: 'inherit' });
27
+
28
+ console.log(`✅ ${scriptName} completed successfully`);
29
+ } catch (error) {
30
+ console.error(`❌ Error during ${scriptName}:`, error.message);
31
+ process.exit(1);
32
+ }
33
+ };
34
+
35
+ const command = process.argv[2];
36
+
37
+ switch (command) {
38
+ case 'setup':
39
+ runScript('setup');
40
+ break;
41
+ case 'production':
42
+ runScript('production');
43
+ break;
44
+ case 'dev':
45
+ runScript('dev');
46
+ break;
47
+ case 'deploy':
48
+ runScript('deploy');
49
+ break;
50
+ case 'deploy:stop':
51
+ runScript('deploy:stop');
52
+ break;
53
+ case 'deploy:restart':
54
+ runScript('deploy:restart');
55
+ break;
56
+ case 'deploy:update':
57
+ runScript('deploy:update');
58
+ break;
59
+ case 'deploy:status':
60
+ runScript('deploy:status');
61
+ break;
62
+ case 'deploy:backup':
63
+ runScript('deploy:backup');
64
+ break;
65
+ case 'troubleshoot':
66
+ runScript('troubleshoot');
67
+ break;
68
+ default:
69
+ console.log('Usage: specgen-app <command>');
70
+ console.log('\nAvailable commands:');
71
+ console.log(' setup - Set up the SpecGen application');
72
+ console.log(' production - Run the application in production mode');
73
+ console.log(' dev - Run the application in development mode');
74
+ console.log(' deploy - Deploy the application');
75
+ console.log(' deploy:stop - Stop the deployed application');
76
+ console.log(' deploy:restart - Restart the deployed application');
77
+ console.log(' deploy:update - Update the deployed application');
78
+ console.log(' deploy:status - Check the status of the deployed application');
79
+ console.log(' deploy:backup - Create a backup of the deployed application');
80
+ console.log(' troubleshoot - Run troubleshooting checks');
81
+ }
package/index.js ADDED
@@ -0,0 +1,14 @@
1
+ // This file makes the package importable
2
+ // The main functionality is provided through the CLI
3
+
4
+ module.exports = {
5
+ version: require('./package.json').version,
6
+ description: 'SpecGen Application Package',
7
+
8
+ // Export script paths for programmatic access
9
+ scripts: {
10
+ setup: require.resolve('./scripts/setup.sh'),
11
+ dev: require.resolve('./scripts/dev.sh'),
12
+ production: require.resolve('./scripts/production.sh')
13
+ }
14
+ };
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@gv-sh/specgen-app",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Complete SpecGen application with server, admin, and user interfaces",
5
5
  "main": "index.js",
6
+ "bin": {
7
+ "specgen-app": "./bin/cli.js"
8
+ },
6
9
  "scripts": {
7
10
  "setup": "chmod +x scripts/setup.sh && ./scripts/setup.sh",
8
11
  "dev": "chmod +x scripts/dev.sh && ./scripts/dev.sh",
@@ -16,7 +19,8 @@
16
19
  "deploy:update": "chmod +x scripts/update.sh && ./scripts/update.sh",
17
20
  "deploy:status": "chmod +x scripts/status.sh && ./scripts/status.sh",
18
21
  "deploy:backup": "chmod +x scripts/backup.sh && ./scripts/backup.sh",
19
- "troubleshoot": "chmod +x scripts/troubleshoot.sh && ./scripts/troubleshoot.sh"
22
+ "troubleshoot": "chmod +x scripts/troubleshoot.sh && ./scripts/troubleshoot.sh",
23
+ "postinstall": "chmod +x bin/cli.js"
20
24
  },
21
25
  "dependencies": {
22
26
  "@gv-sh/specgen-server": "0.9.0",
@@ -1,6 +1,12 @@
1
1
  #!/bin/bash
2
2
 
3
- # Make all scripts executable
4
- chmod +x scripts/*.sh
3
+ # SpecGen Package Deployment Script
4
+ echo "📦 Making files executable..."
5
5
 
6
- echo "✅ All scripts are now executable"
6
+ # Make all shell scripts executable
7
+ find scripts -name "*.sh" -exec chmod +x {} \;
8
+
9
+ # Make CLI executable
10
+ chmod +x bin/cli.js
11
+
12
+ echo "✅ All scripts are now executable"