corvid-fake-local-mode-editor
Advanced tools
Comparing version 0.1.31 to 0.1.32
{ | ||
"name": "corvid-fake-local-mode-editor", | ||
"version": "0.1.31", | ||
"version": "0.1.32", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -20,2 +20,9 @@ const io = require("socket.io-client"); | ||
// TODO: refactor schemas to be something different than code. than we won't need to handle it in such a weird way | ||
const isSchemaPath = filePath => filePath.startsWith(".schemas/"); | ||
const ensureSchemaStructure = schemaContent => | ||
JSON.stringify(JSON.parse(schemaContent)); | ||
const connectToLocalServer = port => { | ||
@@ -187,3 +194,7 @@ return new Promise((resolve, reject) => { | ||
(result, value) => | ||
Object.assign(result, { [value.path]: value.content }), | ||
Object.assign(result, { | ||
[value.path]: isSchemaPath(value.path) | ||
? ensureSchemaStructure(value.content) | ||
: value.content | ||
}), | ||
{} | ||
@@ -204,2 +215,5 @@ ) | ||
const modifyCodeFile = (filePath, content) => { | ||
if (isSchemaPath(filePath)) { | ||
content = ensureSchemaStructure(content); | ||
} | ||
set_(editorState.codeFiles.current, filePath.split("/"), content); | ||
@@ -230,10 +244,2 @@ }; | ||
const modifyCollectionSchema = (collectionName, newContent) => { | ||
set_( | ||
editorState.codeFiles.current, | ||
[".schemas", `${collectionName}.json`], | ||
newContent | ||
); | ||
}; | ||
const registerDocumentChange = cb => { | ||
@@ -280,3 +286,2 @@ editorState.documentChangesLocally.push(cb); | ||
deletePageCodeFile, | ||
modifyCollectionSchema, | ||
registerDocumentChange, | ||
@@ -283,0 +288,0 @@ registerCodeChange, |
@@ -141,3 +141,3 @@ const merge_ = require("lodash/merge"); | ||
path: `.schemas/${collectionName}.json`, | ||
content: schema | ||
content: JSON.stringify(schema) | ||
}); | ||
@@ -144,0 +144,0 @@ |
Sorry, the diff of this file is not supported yet
18114
484