Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@iannisz/node-cms

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@iannisz/node-cms - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

75

compiler.js

@@ -16,3 +16,70 @@ "use strict";

var chalk = require("chalk");
exports.compile = function (pagesTable, pageTypesTable, compilePage, root) {
var node_json_database_1 = require("node-json-database");
// Write the ./root directory if it does not exist
if (!fs.existsSync('root')) {
fs.mkdirSync('root');
}
var pagesDB = node_json_database_1.db('pages.json');
// Create database if it does not exist
if (!pagesDB.exists) {
pagesDB.create();
}
// Create pageTypes table if it does not exist
if (!pagesDB.table('pageTypes').exists) {
var table = pagesDB.table('pageTypes');
table.create();
table.columns.add([
{
name: 'name',
dataType: 'String',
constraints: [
'primaryKey'
]
},
{
name: 'template',
dataType: 'JSON',
constraints: [
'notNull'
]
},
{
name: 'canAdd',
dataType: 'Boolean'
}
]);
}
// Create pages table if it does not exist
if (!pagesDB.table('pages').exists) {
var table = pagesDB.table('pages');
table.create();
table.columns.add([
{
name: 'id',
dataType: 'Int',
constraints: [
'primaryKey',
'autoIncrement'
]
},
{
name: 'pageType',
dataType: 'String',
foreignKey: {
table: 'pageTypes',
column: 'name'
}
},
{
name: 'pageContent',
dataType: 'JSON',
constraints: [
'notNull'
]
}
]);
}
var pageTypesTable = pagesDB.table('pageTypes').get();
var pagesTable = pagesDB.table('pages').get();
exports.compile = function (compilePage) {
// Store start time

@@ -27,3 +94,3 @@ var e_1, _a;

// Create directory, if needed
var directory = getDirectory(root + page.path);
var directory = getDirectory(page.path);
if (!fs.existsSync(directory)) {

@@ -34,4 +101,4 @@ fs.mkdirSync(directory);

// Write the file
fs.writeFileSync(root + page.path, page.html);
console.log(chalk.green('✔') + " Wrote file: " + chalk.yellow(root + page.path));
fs.writeFileSync(page.path, page.html);
console.log(chalk.green('✔') + " Wrote file: " + chalk.yellow(page.path));
}

@@ -38,0 +105,0 @@ };

import * as fs from 'fs'
import * as chalk from 'chalk'
import { Table } from 'node-json-database'
import { db } from 'node-json-database'
type PageCompiler = (pageContent: Object, pages: any) => { html: string, path: string }
type PageCompiler = (pageContent: Object, pages: Object) => {
html: string
path: string
}
export const compile = (pagesTable: Table, pageTypesTable: Table, compilePage: any, root: string) => {
interface ObjectOf<T> {
[key: string]: T
}
// Write the ./root directory if it does not exist
if (!fs.existsSync('root')) {
fs.mkdirSync('root')
}
const pagesDB = db('pages.json')
// Create database if it does not exist
if (!pagesDB.exists) {
pagesDB.create()
}
// Create pageTypes table if it does not exist
if (!pagesDB.table('pageTypes').exists) {
const table = pagesDB.table('pageTypes')
table.create()
table.columns.add([
{
name: 'name',
dataType: 'String',
constraints: [
'primaryKey'
]
},
{
name: 'template',
dataType: 'JSON',
constraints: [
'notNull'
]
},
{
name: 'canAdd',
dataType: 'Boolean'
}
])
}
// Create pages table if it does not exist
if (!pagesDB.table('pages').exists) {
const table = pagesDB.table('pages')
table.create()
table.columns.add([
{
name: 'id',
dataType: 'Int',
constraints: [
'primaryKey',
'autoIncrement'
]
},
{
name: 'pageType',
dataType: 'String',
foreignKey: {
table: 'pageTypes',
column: 'name'
}
},
{
name: 'pageContent',
dataType: 'JSON',
constraints: [
'notNull'
]
}
])
}
const pageTypesTable = pagesDB.table('pageTypes').get()
const pagesTable = pagesDB.table('pages').get()
export const compile = (compilePage: ObjectOf<PageCompiler>) => {
// Store start time

@@ -18,3 +105,3 @@

for (let i = 0; i < pages.length; i++) {
const pageCompiler = compilePage[pageType.name] as PageCompiler
const pageCompiler = compilePage[pageType.name]
const page = pageCompiler(pages[i].pageContent, pagesTable)

@@ -24,3 +111,3 @@

const directory = getDirectory(root + page.path)
const directory = getDirectory(page.path)

@@ -34,4 +121,4 @@ if (!fs.existsSync(directory)) {

fs.writeFileSync(root + page.path, page.html)
console.log(`${ chalk.green('✔') } Wrote file: ${ chalk.yellow(root + page.path) }`)
fs.writeFileSync(page.path, page.html)
console.log(`${ chalk.green('✔') } Wrote file: ${ chalk.yellow(page.path) }`)
}

@@ -38,0 +125,0 @@ }

2

package.json
{
"name": "@iannisz/node-cms",
"version": "0.0.7",
"version": "0.0.8",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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