@gallop.software/studio 2.0.5 → 2.0.7

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 @@
1
+ export { GET, POST, DELETE } from '../../../../dist/handlers/index.mjs'
package/bin/studio.mjs CHANGED
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawn } from 'child_process'
4
- import { resolve, dirname } from 'path'
4
+ import { resolve, dirname, join } from 'path'
5
5
  import { fileURLToPath } from 'url'
6
- import { existsSync } from 'fs'
6
+ import { existsSync, mkdirSync, cpSync, writeFileSync, rmSync } from 'fs'
7
+ import { tmpdir } from 'os'
7
8
 
8
9
  const __filename = fileURLToPath(import.meta.url)
9
10
  const __dirname = dirname(__filename)
@@ -63,9 +64,62 @@ console.log(`
63
64
  └─────────────────────────────────────┘
64
65
  `)
65
66
 
66
- // Find the next binary
67
+ // Create a temp directory for the Studio app
67
68
  const studioRoot = resolve(__dirname, '..')
68
- const nextBin = resolve(studioRoot, 'node_modules', '.bin', 'next')
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')
69
123
 
70
124
  if (!existsSync(nextBin)) {
71
125
  console.error('Error: Next.js not found. Please run: npm install')
@@ -79,10 +133,10 @@ const env = {
79
133
  NODE_ENV: 'development',
80
134
  }
81
135
 
82
- // Start Next.js dev server
136
+ // Start Next.js dev server from temp directory
83
137
  const child = spawn(nextBin, ['dev', '-p', '3001'], {
84
138
  stdio: 'inherit',
85
- cwd: studioRoot,
139
+ cwd: tempDir,
86
140
  env,
87
141
  })
88
142
 
@@ -95,16 +149,26 @@ if (shouldOpen) {
95
149
  }
96
150
 
97
151
  // Handle process termination
98
- process.on('SIGINT', () => {
152
+ const cleanup = () => {
99
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
+ }
100
160
  process.exit(0)
101
- })
161
+ }
102
162
 
103
- process.on('SIGTERM', () => {
104
- child.kill('SIGTERM')
105
- process.exit(0)
106
- })
163
+ process.on('SIGINT', cleanup)
164
+ process.on('SIGTERM', cleanup)
107
165
 
108
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
+ }
109
173
  process.exit(code || 0)
110
174
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gallop.software/studio",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "Standalone media manager for Gallop templates - upload, process, and sync images to CDN",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1 +0,0 @@
1
- export { GET, POST, DELETE } from '../../../../src/handlers'
File without changes
File without changes