@gallop.software/studio 2.0.7 → 2.1.1
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/bin/studio.mjs +17 -124
- package/dist/client/assets/index-TPS3nigu.js +74 -0
- package/dist/client/index.html +19 -0
- package/dist/{handlers/index.mjs → server/index.js} +242 -427
- package/dist/server/index.js.map +1 -0
- package/package.json +17 -32
- package/app/api/studio/[...path]/route.js +0 -1
- package/app/layout.jsx +0 -19
- package/app/page.jsx +0 -90
- package/dist/chunk-TRYWHLJ2.mjs +0 -32
- package/dist/chunk-TRYWHLJ2.mjs.map +0 -1
- package/dist/chunk-VI6QG6WT.js +0 -32
- package/dist/chunk-VI6QG6WT.js.map +0 -1
- package/dist/components/StudioUI.d.mts +0 -15
- package/dist/components/StudioUI.d.ts +0 -15
- package/dist/components/StudioUI.js +0 -6572
- package/dist/components/StudioUI.js.map +0 -1
- package/dist/components/StudioUI.mjs +0 -6572
- package/dist/components/StudioUI.mjs.map +0 -1
- package/dist/handlers/index.d.mts +0 -22
- package/dist/handlers/index.d.ts +0 -22
- package/dist/handlers/index.js +0 -2587
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/index.mjs.map +0 -1
- package/dist/index.d.mts +0 -90
- package/dist/index.d.ts +0 -90
- package/dist/index.js +0 -11
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -11
- package/dist/index.mjs.map +0 -1
- package/next.config.mjs +0 -20
package/bin/studio.mjs
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
|
-
import { existsSync, mkdirSync, cpSync, writeFileSync, rmSync } from 'fs'
|
|
7
|
-
import { tmpdir } from 'os'
|
|
8
|
-
|
|
9
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
10
|
-
const __dirname = dirname(__filename)
|
|
3
|
+
import { resolve } from 'path'
|
|
4
|
+
import { existsSync } from 'fs'
|
|
11
5
|
|
|
12
6
|
// Parse command line arguments
|
|
13
7
|
const args = process.argv.slice(2)
|
|
14
8
|
let workspace = process.cwd()
|
|
9
|
+
let port = 3001
|
|
15
10
|
let shouldOpen = false
|
|
16
11
|
|
|
17
12
|
for (let i = 0; i < args.length; i++) {
|
|
18
13
|
if (args[i] === '--workspace' && args[i + 1]) {
|
|
19
14
|
workspace = resolve(args[i + 1])
|
|
20
15
|
i++
|
|
16
|
+
} else if (args[i] === '--port' && args[i + 1]) {
|
|
17
|
+
port = parseInt(args[i + 1], 10)
|
|
18
|
+
i++
|
|
21
19
|
} else if (args[i] === '--open' || args[i] === '-o') {
|
|
22
20
|
shouldOpen = true
|
|
23
21
|
} else if (args[i] === '--help' || args[i] === '-h') {
|
|
@@ -29,13 +27,14 @@ Usage:
|
|
|
29
27
|
|
|
30
28
|
Options:
|
|
31
29
|
--workspace <path> Path to the project workspace (default: current directory)
|
|
30
|
+
--port <number> Port to run the server on (default: 3001)
|
|
32
31
|
--open, -o Open browser automatically
|
|
33
32
|
--help, -h Show this help message
|
|
34
33
|
|
|
35
34
|
Examples:
|
|
36
35
|
studio # Run in current directory
|
|
37
36
|
studio --workspace ~/my-project # Run for specific project
|
|
38
|
-
studio --
|
|
37
|
+
studio --port 3002 --open # Use custom port and open browser
|
|
39
38
|
`)
|
|
40
39
|
process.exit(0)
|
|
41
40
|
}
|
|
@@ -55,120 +54,14 @@ if (!existsSync(publicPath)) {
|
|
|
55
54
|
process.exit(1)
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// Create a temp directory for the Studio app
|
|
68
|
-
const studioRoot = resolve(__dirname, '..')
|
|
69
|
-
const tempDir = join(tmpdir(), 'gallop-studio')
|
|
70
|
-
|
|
71
|
-
// Clean up and recreate temp directory
|
|
72
|
-
if (existsSync(tempDir)) {
|
|
73
|
-
rmSync(tempDir, { recursive: true, force: true })
|
|
74
|
-
}
|
|
75
|
-
mkdirSync(tempDir, { recursive: true })
|
|
76
|
-
|
|
77
|
-
// Copy app files to temp directory
|
|
78
|
-
cpSync(join(studioRoot, 'app'), join(tempDir, 'app'), { recursive: true })
|
|
79
|
-
cpSync(join(studioRoot, 'dist'), join(tempDir, 'dist'), { recursive: true })
|
|
80
|
-
|
|
81
|
-
// Create package.json for the temp app
|
|
82
|
-
const packageJson = {
|
|
83
|
-
name: 'studio-temp',
|
|
84
|
-
private: true,
|
|
85
|
-
type: 'module',
|
|
86
|
-
dependencies: {}
|
|
87
|
-
}
|
|
88
|
-
writeFileSync(join(tempDir, 'package.json'), JSON.stringify(packageJson, null, 2))
|
|
89
|
-
|
|
90
|
-
// Create next.config.mjs
|
|
91
|
-
const nextConfig = `/** @type {import('next').NextConfig} */
|
|
92
|
-
const nextConfig = {
|
|
93
|
-
output: 'standalone',
|
|
94
|
-
compiler: {
|
|
95
|
-
emotion: true,
|
|
96
|
-
},
|
|
97
|
-
env: {
|
|
98
|
-
NEXT_PUBLIC_STUDIO_WORKSPACE: process.env.STUDIO_WORKSPACE || process.cwd(),
|
|
99
|
-
},
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export default nextConfig
|
|
103
|
-
`
|
|
104
|
-
writeFileSync(join(tempDir, 'next.config.mjs'), nextConfig)
|
|
105
|
-
|
|
106
|
-
// Create symlinks to node_modules from studioRoot
|
|
107
|
-
const nodeModulesSource = join(studioRoot, 'node_modules')
|
|
108
|
-
const nodeModulesTarget = join(tempDir, 'node_modules')
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
// Use cpSync with dereference to copy node_modules (or symlink if possible)
|
|
112
|
-
// For performance, we'll just create a symlink
|
|
113
|
-
const { symlinkSync } = await import('fs')
|
|
114
|
-
symlinkSync(nodeModulesSource, nodeModulesTarget, 'junction')
|
|
115
|
-
} catch (e) {
|
|
116
|
-
// If symlink fails, copy (slower but works)
|
|
117
|
-
console.log('Creating node_modules link...')
|
|
118
|
-
cpSync(nodeModulesSource, nodeModulesTarget, { recursive: true })
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Find the next binary
|
|
122
|
-
const nextBin = join(nodeModulesTarget, '.bin', 'next')
|
|
123
|
-
|
|
124
|
-
if (!existsSync(nextBin)) {
|
|
125
|
-
console.error('Error: Next.js not found. Please run: npm install')
|
|
57
|
+
// Start the server
|
|
58
|
+
import('../dist/server/index.js').then((mod) => {
|
|
59
|
+
mod.startServer({
|
|
60
|
+
port,
|
|
61
|
+
workspace,
|
|
62
|
+
open: shouldOpen,
|
|
63
|
+
})
|
|
64
|
+
}).catch((error) => {
|
|
65
|
+
console.error('Failed to start Studio server:', error)
|
|
126
66
|
process.exit(1)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Set up environment
|
|
130
|
-
const env = {
|
|
131
|
-
...process.env,
|
|
132
|
-
STUDIO_WORKSPACE: workspace,
|
|
133
|
-
NODE_ENV: 'development',
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Start Next.js dev server from temp directory
|
|
137
|
-
const child = spawn(nextBin, ['dev', '-p', '3001'], {
|
|
138
|
-
stdio: 'inherit',
|
|
139
|
-
cwd: tempDir,
|
|
140
|
-
env,
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
// Open browser if requested
|
|
144
|
-
if (shouldOpen) {
|
|
145
|
-
setTimeout(async () => {
|
|
146
|
-
const open = (await import('open')).default
|
|
147
|
-
open('http://localhost:3001')
|
|
148
|
-
}, 2000)
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Handle process termination
|
|
152
|
-
const cleanup = () => {
|
|
153
|
-
child.kill('SIGINT')
|
|
154
|
-
// Clean up temp directory
|
|
155
|
-
try {
|
|
156
|
-
rmSync(tempDir, { recursive: true, force: true })
|
|
157
|
-
} catch (e) {
|
|
158
|
-
// Ignore cleanup errors
|
|
159
|
-
}
|
|
160
|
-
process.exit(0)
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
process.on('SIGINT', cleanup)
|
|
164
|
-
process.on('SIGTERM', cleanup)
|
|
165
|
-
|
|
166
|
-
child.on('close', (code) => {
|
|
167
|
-
// Clean up temp directory
|
|
168
|
-
try {
|
|
169
|
-
rmSync(tempDir, { recursive: true, force: true })
|
|
170
|
-
} catch (e) {
|
|
171
|
-
// Ignore cleanup errors
|
|
172
|
-
}
|
|
173
|
-
process.exit(code || 0)
|
|
174
67
|
})
|