qumra-cli 2.1.0 → 2.4.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.
- package/.claude/settings.local.json +8 -1
- package/CLAUDE.md +174 -0
- package/dist/cli.js +1421 -543
- package/package.json +1 -1
|
@@ -23,7 +23,14 @@
|
|
|
23
23
|
"Bash(git commit -m \"$\\(cat <<''EOF''\nfeat: Replace qumra-engine with local proxy server\n\n- Add ThemeProxyService for proxying requests to store URL\n- Add ThemeHotReloadService for WebSocket-based live reload\n- Add ThemeAssetMapperService for mapping CDN URLs to local files\n- Update ThemeWatcherService with file change callback\n- Remove qumra-engine dependency\n- Add http-proxy-middleware and cheerio dependencies\n\nThis implements a Shopify-style development experience where:\n- Local assets \\(CSS, JS, images\\) are served from the theme folder\n- HTML responses are rewritten to use local asset URLs\n- CSS changes are hot-swapped without full page reload\n- Other changes trigger full page reload\n- All files are still uploaded to server for SSR\n\nCo-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>\nEOF\n\\)\")",
|
|
24
24
|
"Bash(npm version:*)",
|
|
25
25
|
"Bash(npm publish)",
|
|
26
|
-
"Bash(npm publish:*)"
|
|
26
|
+
"Bash(npm publish:*)",
|
|
27
|
+
"Bash(DEBUG=*)",
|
|
28
|
+
"Bash(npm link:*)",
|
|
29
|
+
"Bash(git commit:*)",
|
|
30
|
+
"Bash(git checkout:*)",
|
|
31
|
+
"Bash(git clean:*)",
|
|
32
|
+
"Bash(git merge:*)",
|
|
33
|
+
"Bash(git branch:*)"
|
|
27
34
|
]
|
|
28
35
|
}
|
|
29
36
|
}
|
package/CLAUDE.md
CHANGED
|
@@ -30,6 +30,7 @@ src/
|
|
|
30
30
|
│ ├── config/ # ConfigService - project-level .qumra/qumra.config.json
|
|
31
31
|
│ ├── storage/ # StorageService - user-level ~/.config/qumra-cli/
|
|
32
32
|
│ ├── logger/ # LoggerService - formatted console output with chalk
|
|
33
|
+
│ │ └── blessed-ui.ts # BlessedUI - Terminal UI with panels and shortcuts
|
|
33
34
|
│ ├── graphql/ # GraphqlService - graphql-request wrapper with auth
|
|
34
35
|
│ ├── tunnel/ # TunnelService - cloudflared tunnel management
|
|
35
36
|
│ └── constants.ts # API endpoints and constants
|
|
@@ -57,9 +58,182 @@ src/
|
|
|
57
58
|
## External Services
|
|
58
59
|
|
|
59
60
|
- GraphQL API: `https://api.qumra.cloud/graphql`
|
|
61
|
+
- REST Upload API: `https://api.qumra.cloud/v1/upload`
|
|
60
62
|
- Realtime WebSocket: `wss://realtime.qumra.cloud`
|
|
61
63
|
- Login Portal: `https://app.qumra.cloud/auth/login`
|
|
64
|
+
- Theme Editor: `https://app.qumra.cloud/store/{subdomain}/themes/{appThemeId}`
|
|
62
65
|
|
|
63
66
|
## Build Configuration
|
|
64
67
|
|
|
65
68
|
Rollup bundles `src/main.ts` into `dist/cli.js` as CommonJS with shebang. External packages: qumra-engine, NestJS packages, fsevents.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Theme Dev Command (`qumra theme dev`)
|
|
73
|
+
|
|
74
|
+
### Overview
|
|
75
|
+
|
|
76
|
+
The theme dev command starts a local development server for theme development with:
|
|
77
|
+
- Proxy server to forward requests to the store
|
|
78
|
+
- Hot reload for live updates
|
|
79
|
+
- File watcher for syncing changes
|
|
80
|
+
- BlessedUI for terminal interface
|
|
81
|
+
|
|
82
|
+
### Flow
|
|
83
|
+
|
|
84
|
+
1. Load `qumra.config.json` to get `themeVersionId`
|
|
85
|
+
2. Show store selection (inquirer prompt)
|
|
86
|
+
3. Install theme on store via `installTheme` mutation → returns `appTheme._id`
|
|
87
|
+
4. Start hot reload WebSocket server
|
|
88
|
+
5. Start proxy server
|
|
89
|
+
6. Start BlessedUI terminal interface
|
|
90
|
+
7. Start file watcher
|
|
91
|
+
|
|
92
|
+
### Key IDs
|
|
93
|
+
|
|
94
|
+
- `themeId` - The theme's unique ID (from qumra.config.json)
|
|
95
|
+
- `themeVersionId` - The specific version ID (from qumra.config.json)
|
|
96
|
+
- `appTheme._id` - Returned from `installTheme` mutation, used for:
|
|
97
|
+
- Proxy header: `X-Qumra-App-Theme`
|
|
98
|
+
- Theme Editor URL
|
|
99
|
+
- File sync operations
|
|
100
|
+
|
|
101
|
+
### Services Architecture
|
|
102
|
+
|
|
103
|
+
#### ThemeProxyService (`theme-proxy.service.ts`)
|
|
104
|
+
|
|
105
|
+
Express server that:
|
|
106
|
+
- Serves local `/assets` from theme folder
|
|
107
|
+
- Proxies all other requests to store URL
|
|
108
|
+
- Adds headers:
|
|
109
|
+
- `X-Qumra-Dev-Mode: true`
|
|
110
|
+
- `X-Qumra-App-Theme: {appTheme._id}`
|
|
111
|
+
- Injects hot reload script into HTML responses
|
|
112
|
+
- Adds dev mode indicator badge
|
|
113
|
+
|
|
114
|
+
**Important**: Don't rewrite asset URLs in HTML - just serve `/assets` locally and let backend URLs pass through unchanged.
|
|
115
|
+
|
|
116
|
+
#### ThemeWatcherService (`theme-watcher.service.ts`)
|
|
117
|
+
|
|
118
|
+
File watcher using chokidar with different sync handlers per folder:
|
|
119
|
+
|
|
120
|
+
| Folder | File Type | Sync Method | Endpoint |
|
|
121
|
+
|--------|-----------|-------------|----------|
|
|
122
|
+
| `assets` | all | CDN Presigned URL | GraphQL `CdnPresignedUrl` → upload to presigned URL |
|
|
123
|
+
| `layouts` | `.njk` | REST Upload | `POST /v1/upload` |
|
|
124
|
+
| `templates` | `.njk` | REST Upload | `POST /v1/upload` |
|
|
125
|
+
| `ui` | `.njk`, `.css` | REST Upload | `POST /v1/upload` |
|
|
126
|
+
| `locales` | `.json` | REST Upload | `POST /v1/upload` |
|
|
127
|
+
| `widgets` | `.njk` | REST Upload | `POST /v1/upload` |
|
|
128
|
+
| `widgets` | `.json` | GraphQL | `SyncWidget` mutation |
|
|
129
|
+
| `pages` | `.json` | GraphQL | `SyncThemePage` mutation |
|
|
130
|
+
| `settings` | `.json` | GraphQL | `UpdateThemeVersionSettings` mutation |
|
|
131
|
+
|
|
132
|
+
**Features**:
|
|
133
|
+
- 300ms debounce to prevent rapid consecutive syncs
|
|
134
|
+
- No initial sync on startup (only watches for changes)
|
|
135
|
+
- Different handlers based on file type and folder
|
|
136
|
+
|
|
137
|
+
#### ThemeHotReloadService (`theme-hot-reload.service.ts`)
|
|
138
|
+
|
|
139
|
+
WebSocket server (Socket.IO) for live reload:
|
|
140
|
+
- Listens for file changes from watcher
|
|
141
|
+
- Notifies connected browsers
|
|
142
|
+
- CSS changes: hot swap without page reload
|
|
143
|
+
- Other changes: full page reload
|
|
144
|
+
|
|
145
|
+
**Client Script**: Injected into HTML before `</body>`:
|
|
146
|
+
```html
|
|
147
|
+
<script src="https://cdn.socket.io/4.6.0/socket.io.min.js"></script>
|
|
148
|
+
<script>
|
|
149
|
+
(function() {
|
|
150
|
+
var socket = io('http://localhost:{port}');
|
|
151
|
+
socket.on('file-change', function(event) {
|
|
152
|
+
if (event.type === 'css') {
|
|
153
|
+
// Hot swap CSS
|
|
154
|
+
} else {
|
|
155
|
+
window.location.reload();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
})();
|
|
159
|
+
</script>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**Important**: Socket.IO library must be loaded BEFORE the client script that uses it.
|
|
163
|
+
|
|
164
|
+
### BlessedUI (`blessed-ui.ts`)
|
|
165
|
+
|
|
166
|
+
Terminal UI using `blessed` library:
|
|
167
|
+
- Info box with theme/store details and URLs
|
|
168
|
+
- Log panel for sync/proxy activity
|
|
169
|
+
- Footer with keyboard shortcuts (q: quit, o: open browser, s: open store, e: theme editor)
|
|
170
|
+
|
|
171
|
+
**Gotchas**:
|
|
172
|
+
- Must set `mouse: false` to prevent click-exit issues
|
|
173
|
+
- Don't use `console.log` after BlessedUI starts (interferes with terminal control)
|
|
174
|
+
- Wait ~100ms after inquirer prompt before starting BlessedUI (stdin release)
|
|
175
|
+
|
|
176
|
+
### GraphQL Mutations
|
|
177
|
+
|
|
178
|
+
```graphql
|
|
179
|
+
# Install theme on store
|
|
180
|
+
mutation InstallTheme($input: InstallThemeInput!) {
|
|
181
|
+
installTheme(input: $input) {
|
|
182
|
+
_id # This is appTheme._id
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
# Sync page
|
|
187
|
+
mutation SyncThemePage($input: SyncThemePageInput!) {
|
|
188
|
+
syncThemePage(input: $input) { success message }
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
# Sync widget schema
|
|
192
|
+
mutation SyncWidget($input: SyncWidgetInput!) {
|
|
193
|
+
syncWidget(input: $input) { success message }
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
# Update settings
|
|
197
|
+
mutation UpdateThemeVersionSettings($input: UpdateThemeVersionSettingsInput!) {
|
|
198
|
+
updateThemeVersionSettings(input: $input) { success message }
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
# Get CDN presigned URL for assets
|
|
202
|
+
mutation CdnPresignedUrl($cdnPresignedInput: CdnPresignedInput!) {
|
|
203
|
+
cdnPresignedUrl(cdnPresignedInput: $cdnPresignedInput) {
|
|
204
|
+
success message presignedUrl
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Settings Files
|
|
210
|
+
|
|
211
|
+
The `settings/` folder has specific JSON files:
|
|
212
|
+
- `settings-schema.json` - Theme settings schema
|
|
213
|
+
- `settings-data.json` - Theme settings values
|
|
214
|
+
- `header-schema.json` - Header settings schema
|
|
215
|
+
- `header-data.json` - Header settings values
|
|
216
|
+
- `footer-schema.json` - Footer settings schema
|
|
217
|
+
- `footer-data.json` - Footer settings values
|
|
218
|
+
- `templates-settings.json` - Templates configuration
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## App Dev Command (`qumra app dev`)
|
|
223
|
+
|
|
224
|
+
Similar to theme dev but:
|
|
225
|
+
- Uses cloudflared tunnel for HTTPS
|
|
226
|
+
- Spawns `npx react-router dev` child process
|
|
227
|
+
- Updates app's `developmentUrl` on backend
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## Reference: Old CLI (`../qumra-cli`)
|
|
232
|
+
|
|
233
|
+
The new NestJS CLI should match the old CLI's behavior. Key reference files:
|
|
234
|
+
- `src/services/themes/watcher/` - File sync handlers
|
|
235
|
+
- `src/utils/uploadFileToServer.ts` - REST upload to `/v1/upload`
|
|
236
|
+
- `src/utils/uploadFileToCdnPresignedUrl.ts` - CDN upload via presigned URL
|
|
237
|
+
- `src/utils/syncThemePage.ts` - GraphQL page sync
|
|
238
|
+
- `src/utils/syncWidgetSchema.ts` - GraphQL widget sync
|
|
239
|
+
- `src/utils/syncThemeVersionSettings.ts` - GraphQL settings sync
|