mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
Add comprehensive JSONC support for opencode.jsonc files
- Store raw JSONC content in database, parse on-the-fly for validation - Return rawContent field in API response for editing with comments preserved - Update frontend to use rawContent for config editing - Accept string or object content in create/update requests - Download configs as .jsonc when they contain comments - Add strip-json-comments dependency for JSONC parsing - Add .jsonc MIME type support in backend file service This preserves comments in opencode.jsonc files when editing through the UI
This commit is contained in:
1 parent
7a647cb316
commit
4eec4e5c27
12 files changed
+138
-66
No files matched your search
@@ -6,6 +6,7 @@ import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { Textarea } from '@/components/ui/textarea'
|
||||
import { Switch } from '@/components/ui/switch'
|
||||
import stripJsonComments from 'strip-json-comments'
|
||||
|
||||
interface CreateConfigDialogProps {
|
||||
isOpen: boolean
|
||||
@@ -62,11 +63,11 @@ export function CreateConfigDialog({ isOpen, onOpenChange, onCreate, isUpdating
|
||||
reader.onload = (e) => {
|
||||
const fileContent = e.target?.result as string
|
||||
try {
|
||||
JSON.parse(fileContent)
|
||||
JSON.parse(stripJsonComments(fileContent))
|
||||
setContent(fileContent)
|
||||
setName(file.name.replace('.json', '').replace('.jsonc', ''))
|
||||
} catch {
|
||||
window.alert('Invalid JSON file')
|
||||
window.alert('Invalid JSON/JSONC file')
|
||||
}
|
||||
}
|
||||
reader.readAsText(file)
|
||||
|
||||
Reference in new issue
Block a user