@gallop.software/studio 2.3.173 → 2.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/bin/studio.mjs CHANGED
@@ -24,6 +24,15 @@ Studio - Media Manager
24
24
 
25
25
  Usage:
26
26
  studio [options]
27
+ studio <command> [options]
28
+
29
+ Commands:
30
+ scan Scan for new media files and update metadata
31
+ process [prefix] Generate thumbnails for unprocessed images
32
+ push [prefix] Upload local images to CDN (R2)
33
+ download [prefix] Download cloud images to local storage
34
+ fonts woff2 <folder> Convert TTF/OTF to woff2
35
+ fonts assign <folder> --name <n> Generate src/fonts/<n>.ts
27
36
 
28
37
  Options:
29
38
  --workspace <path> Path to the project workspace (default: current directory)
@@ -32,9 +41,15 @@ Options:
32
41
  --help, -h Show this help message
33
42
 
34
43
  Examples:
35
- studio # Run in current directory
36
- studio --workspace ~/my-project # Run for specific project
37
- studio --port 3002 --open # Use custom port and open browser
44
+ studio # Start the web UI
45
+ studio --workspace ~/my-project # Start for specific project
46
+ studio scan # Scan for new files
47
+ studio process # Process all unprocessed images
48
+ studio process portfolio # Process images in /portfolio/
49
+ studio push # Push all local images to CDN
50
+ studio download # Download all cloud images
51
+ studio fonts woff2 inter # Convert _fonts/inter/ to woff2
52
+ studio fonts assign inter --name heading # Generate src/fonts/heading.ts
38
53
  `)
39
54
  process.exit(0)
40
55
  }
@@ -46,22 +61,52 @@ if (!existsSync(workspace)) {
46
61
  process.exit(1)
47
62
  }
48
63
 
49
- // Check for public folder
50
- const publicPath = resolve(workspace, 'public')
51
- if (!existsSync(publicPath)) {
52
- console.error(`Error: No 'public' folder found in workspace: ${workspace}`)
53
- console.error('Studio requires a public folder to manage media files.')
54
- process.exit(1)
55
- }
64
+ // Check for CLI subcommands
65
+ const knownCommands = ['scan', 'process', 'push', 'download', 'fonts']
66
+ const command = args.find(a => !a.startsWith('-') && knownCommands.includes(a))
67
+
68
+ if (command) {
69
+ // Remove command from args, also remove --workspace and its value, --port and its value
70
+ const subArgs = []
71
+ let skipNext = false
72
+ for (const a of args) {
73
+ if (skipNext) {
74
+ skipNext = false
75
+ continue
76
+ }
77
+ if (a === command) continue
78
+ if (a === '--workspace' || a === '--port') {
79
+ skipNext = true
80
+ continue
81
+ }
82
+ if (a === '--open' || a === '-o') continue
83
+ subArgs.push(a)
84
+ }
56
85
 
57
- // Start the server
58
- import('../dist/server/index.js').then((mod) => {
59
- mod.startServer({
60
- port,
61
- workspace,
62
- open: shouldOpen,
86
+ import('../dist/cli/index.js').then(mod => {
87
+ mod.run(command, workspace, subArgs)
88
+ }).catch(error => {
89
+ console.error('CLI command failed:', error)
90
+ process.exit(1)
63
91
  })
64
- }).catch((error) => {
65
- console.error('Failed to start Studio server:', error)
66
- process.exit(1)
67
- })
92
+ } else {
93
+ // Check for public folder (only needed for server mode)
94
+ const publicPath = resolve(workspace, 'public')
95
+ if (!existsSync(publicPath)) {
96
+ console.error(`Error: No 'public' folder found in workspace: ${workspace}`)
97
+ console.error('Studio requires a public folder to manage media files.')
98
+ process.exit(1)
99
+ }
100
+
101
+ // Start the server
102
+ import('../dist/server/index.js').then((mod) => {
103
+ mod.startServer({
104
+ port,
105
+ workspace,
106
+ open: shouldOpen,
107
+ })
108
+ }).catch((error) => {
109
+ console.error('Failed to start Studio server:', error)
110
+ process.exit(1)
111
+ })
112
+ }