New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

corvid-local-site

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

corvid-local-site - npm Package Compare versions

Comparing version 0.1.35 to 0.1.36

src/prettify.js

2

package.json
{
"name": "corvid-local-site",
"version": "0.1.35",
"version": "0.1.36",
"description": "",

@@ -5,0 +5,0 @@ "scripts": {

@@ -15,2 +15,3 @@ const fs = require("fs-extra");

const flat = require("flat");
const { prettyStringify, tryToPrettifyJsonString } = require("./prettify");

@@ -20,4 +21,4 @@ const flatten = data => flat(data, { delimiter: "/", safe: true });

const removeFileExtension = filename => filename.replace(/\.[^/.]+$/, "");
const stringify = content => JSON.stringify(content, null, 2);
const isEmptyFolder = content => isObject_(content);
const readWrite = (siteRootPath, filesWatcher) => {

@@ -166,3 +167,3 @@ const fullPath = filePath => path.resolve(siteRootPath, filePath);

const writeFilesPromises = filesToWrite.map(file =>
filesWatcher.ignoredWriteFile(file.path, stringify(file.content))
filesWatcher.ignoredWriteFile(file.path, prettyStringify(file.content))
);

@@ -194,3 +195,9 @@

const updates = modifiedFiles.map(file =>
filesWatcher.ignoredWriteFile(sitePaths.toLocalCode(file), file.content)
filesWatcher.ignoredWriteFile(
sitePaths.toLocalCode(file),
// TODO: refactor. we shouldn't deal with specific file types here
sitePaths.isEditorDatabaseSchemaPath(file.path)
? tryToPrettifyJsonString(file.content)
: file.content
)
);

@@ -197,0 +204,0 @@

@@ -36,13 +36,19 @@ const path = require("path");

const matchEditorPageFile = filePath => filePath.match(/^\/{0,1}public\/pages/);
const isEditorPageCodePath = filePath =>
!!filePath.match(/^\/{0,1}public\/pages/);
const matchLocalPageFile = filePath =>
filePath.match(/^\/{0,1}frontend\/(pages|lightboxes)\/.*\.([^.]*)\.js/);
const matchLocalPageCodePath = filePath =>
filePath.match(
/^\/{0,1}frontend\/(pages|lightboxes)\/.*\.(?<pageId>[^.]*)\.js/
);
const matchEditorMasterPageFile = filePath =>
filePath.match(/^\/{0,1}public\/pages\/masterPage.js/);
const isEditorMasterPageCodePath = filePath =>
!!filePath.match(/^\/{0,1}public\/pages\/masterPage.js/);
const matchLocalMasterPageFile = filePath =>
filePath.match(/^\/{0,1}frontend\/site.js/);
const isLocalMsterPageCodePath = filePath =>
!!filePath.match(/^\/{0,1}frontend\/site.js/);
const isEditorDatabaseSchemaPath = isEditorDatabaseSchemaPath =>
!!isEditorDatabaseSchemaPath.match(/^\/{0,1}\.schemas/);
const pages = (page = null, extention = fileExtention) =>

@@ -95,8 +101,8 @@ path.posix.join(

const fromLocalCode = filePath => {
const matchesPage = matchLocalPageFile(filePath);
if (matchLocalMasterPageFile(filePath)) {
if (isLocalMsterPageCodePath(filePath)) {
return `${publicFolder}/pages/masterPage.js`;
}
if (matchLocalPageFile(filePath)) {
const [pageId] = matchesPage.slice(-1);
const localPageCodeMatches = matchLocalPageCodePath(filePath);
if (localPageCodeMatches) {
const pageId = localPageCodeMatches.groups.pageId;
return `${publicFolder}/pages/${pageId}${pageCodeExtention}`;

@@ -112,10 +118,9 @@ }

const toLocalCode = file => {
if (matchEditorPageFile(file.path)) {
if (matchEditorMasterPageFile(file.path)) {
return "frontend/site.js";
}
const {
metaData: { pageId, isPopup, title }
} = file;
const toLocalCode = ({ path, metaData = {} }) => {
if (isEditorMasterPageCodePath(path)) {
return "frontend/site.js";
}
if (isEditorPageCodePath(path)) {
const { pageId, isPopup, title } = metaData;
return isPopup

@@ -125,7 +130,8 @@ ? lightboxes({ pageId, title }, pageCodeExtention)

}
if (file.path.match(/^\/{0,1}\.schemas/)) {
return file.path.replace(/^\/{0,1}.schemas\//, "database/");
if (isEditorDatabaseSchemaPath(path)) {
return path.replace(/^\/{0,1}.schemas\//, "database/");
}
return file.path;
return path;
};

@@ -157,3 +163,4 @@

pages,
site
site,
isEditorDatabaseSchemaPath
};

@@ -12,3 +12,3 @@ const flatten_ = require("lodash/flatten");

const stringify = content => JSON.stringify(content, null, 2);
const prettyStringify = content => JSON.stringify(content, null, 2);
const removeSpaces = string => string.replace(/\s/g, titleCharReplacement);

@@ -44,3 +44,3 @@

path: wixFilePath(name, parentPath),
content: stringify(content)
content: prettyStringify(content)
});

@@ -68,3 +68,3 @@

path: `${PATH_PAGES}/${pageFileName(page)}`,
content: stringify(page)
content: prettyStringify(page)
});

@@ -84,3 +84,3 @@

path: `${PATH_LIGHTBOXES}/${lightboxFileName(lightbox)}`,
content: stringify(lightbox)
content: prettyStringify(lightbox)
});

@@ -117,3 +117,3 @@

path: `${PATH_DATABASE}/${collectionName}.json`,
content: schema
content: prettyStringify(schema)
});

@@ -120,0 +120,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc