prjct-cli 0.11.1 → 0.11.2

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.
Files changed (2) hide show
  1. package/bin/serve.js +90 -26
  2. package/package.json +1 -1
package/bin/serve.js CHANGED
@@ -5,27 +5,94 @@
5
5
  *
6
6
  * Launches the prjct web interface with Claude Code CLI integration.
7
7
  * Uses your existing Claude subscription via PTY - no API costs!
8
+ *
9
+ * Auto-installs dependencies on first run.
8
10
  */
9
11
 
10
- const { spawn } = require('child_process')
12
+ const { spawn, spawnSync } = require('child_process')
11
13
  const path = require('path')
12
14
  const fs = require('fs')
13
15
 
14
- const serverDir = path.join(__dirname, '..', 'packages', 'server')
15
- const webDir = path.join(__dirname, '..', 'packages', 'web')
16
+ const packagesDir = path.join(__dirname, '..', 'packages')
17
+ const sharedDir = path.join(packagesDir, 'shared')
18
+ const webDir = path.join(packagesDir, 'web')
16
19
 
17
20
  // Parse arguments
18
21
  const args = process.argv.slice(2)
19
- const portArg = args.find(a => a.startsWith('--port='))
20
- const port = portArg ? portArg.split('=')[1] : '3333'
21
- const webPort = '3000'
22
+ const portArg = args.find((a) => a.startsWith('--port='))
23
+ const port = portArg ? portArg.split('=')[1] : '3000'
22
24
 
23
- // Check if packages exist
24
- if (!fs.existsSync(serverDir) || !fs.existsSync(webDir)) {
25
- console.error('❌ Web packages not found. Run from prjct-cli directory.')
25
+ // Check if web package exists
26
+ if (!fs.existsSync(webDir)) {
27
+ console.error('❌ Web package not found.')
28
+ console.error(' This might be a broken installation.')
29
+ console.error(' Try reinstalling: npm install -g prjct-cli')
26
30
  process.exit(1)
27
31
  }
28
32
 
33
+ // Check if dependencies are installed
34
+ const sharedNodeModules = path.join(sharedDir, 'node_modules')
35
+ const webNodeModules = path.join(webDir, 'node_modules')
36
+ const needsSharedInstall = fs.existsSync(sharedDir) && !fs.existsSync(sharedNodeModules)
37
+ const needsWebInstall = !fs.existsSync(webNodeModules)
38
+
39
+ if (needsSharedInstall || needsWebInstall) {
40
+ console.log(`
41
+ ╔═══════════════════════════════════════════════════════════╗
42
+ ║ ║
43
+ ║ ⚡ prjct - First Time Setup ║
44
+ ║ ║
45
+ ║ Installing web dependencies... ║
46
+ ║ This only happens once. ║
47
+ ║ ║
48
+ ╚═══════════════════════════════════════════════════════════╝
49
+ `)
50
+
51
+ // Install shared dependencies first (if exists)
52
+ if (needsSharedInstall) {
53
+ console.log('📦 Installing packages/shared dependencies...')
54
+ const sharedInstall = spawnSync('npm', ['install'], {
55
+ cwd: sharedDir,
56
+ stdio: 'inherit',
57
+ shell: true,
58
+ })
59
+
60
+ if (sharedInstall.status !== 0) {
61
+ console.error('❌ Failed to install shared dependencies')
62
+ process.exit(1)
63
+ }
64
+
65
+ // Build shared package
66
+ console.log('🔨 Building shared package...')
67
+ const sharedBuild = spawnSync('npm', ['run', 'build'], {
68
+ cwd: sharedDir,
69
+ stdio: 'inherit',
70
+ shell: true,
71
+ })
72
+
73
+ if (sharedBuild.status !== 0) {
74
+ console.error('⚠️ Warning: Failed to build shared package')
75
+ }
76
+ }
77
+
78
+ // Install web dependencies
79
+ if (needsWebInstall) {
80
+ console.log('📦 Installing packages/web dependencies...')
81
+ const webInstall = spawnSync('npm', ['install'], {
82
+ cwd: webDir,
83
+ stdio: 'inherit',
84
+ shell: true,
85
+ })
86
+
87
+ if (webInstall.status !== 0) {
88
+ console.error('❌ Failed to install web dependencies')
89
+ process.exit(1)
90
+ }
91
+ }
92
+
93
+ console.log('✅ Dependencies installed!\n')
94
+ }
95
+
29
96
  console.log(`
30
97
  ╔═══════════════════════════════════════════════════════════╗
31
98
  ║ ║
@@ -33,34 +100,35 @@ console.log(`
33
100
  ║ ║
34
101
  ║ Starting web server... ║
35
102
  ║ ║
36
- API: http://localhost:${port} ║
37
- ║ Web: http://localhost:${webPort} ║
38
- ║ Claude: ws://localhost:${port}/ws/claude ║
103
+ Web: http://localhost:${port} ║
39
104
  ║ ║
40
105
  ║ Using your Claude subscription - $0 API costs ║
41
106
  ║ ║
42
107
  ╚═══════════════════════════════════════════════════════════╝
43
108
  `)
44
109
 
45
- // Start server
46
- const server = spawn('npm', ['run', 'dev'], {
47
- cwd: serverDir,
48
- stdio: 'inherit',
49
- shell: true,
50
- env: { ...process.env, PORT: port }
51
- })
52
-
53
110
  // Start web dev server
54
111
  const web = spawn('npm', ['run', 'dev'], {
55
112
  cwd: webDir,
56
113
  stdio: 'inherit',
57
- shell: true
114
+ shell: true,
115
+ env: { ...process.env, PORT: port },
58
116
  })
59
117
 
118
+ // Open browser after a short delay
119
+ setTimeout(() => {
120
+ const openCmd =
121
+ process.platform === 'darwin'
122
+ ? 'open'
123
+ : process.platform === 'win32'
124
+ ? 'start'
125
+ : 'xdg-open'
126
+ spawn(openCmd, [`http://localhost:${port}`], { shell: true })
127
+ }, 3000)
128
+
60
129
  // Handle shutdown
61
130
  const cleanup = () => {
62
131
  console.log('\n👋 Shutting down prjct server...')
63
- server.kill()
64
132
  web.kill()
65
133
  process.exit(0)
66
134
  }
@@ -69,10 +137,6 @@ process.on('SIGINT', cleanup)
69
137
  process.on('SIGTERM', cleanup)
70
138
 
71
139
  // Handle errors
72
- server.on('error', (err) => {
73
- console.error('Server error:', err.message)
74
- })
75
-
76
140
  web.on('error', (err) => {
77
141
  console.error('Web error:', err.message)
78
142
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prjct-cli",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
4
4
  "description": "Built for Claude - Ship fast, track progress, stay focused. Developer momentum tool for indie hackers.",
5
5
  "main": "core/index.js",
6
6
  "bin": {