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

terraform

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terraform - npm Package Compare versions

Comparing version 0.5.0 to 0.5.2

22

lib/helpers/memoized.js

@@ -14,10 +14,10 @@

var fns = ['buildPriorityList', 'dataTree', 'getCurrent', 'sourceType', 'outputPath', 'outputType', 'shouldIgnore']
var fns = ['buildPriorityList', 'dataTree', 'getCurrent', 'sourceType', 'outputPath', 'outputType', 'shouldIgnore', 'findNearestLayout']
fns.forEach(function(fn){
exports[fn] = function(arg){
var key = fn + ':' + arg
var key = fn + ':' + JSON.stringify(arguments)
var fresh = cache.get(key)
if(fresh) return fresh
var hot = helpers[fn](arg)
var hot = helpers[fn].apply(this, arguments)
cache.set(key, hot)

@@ -28,8 +28,10 @@ return hot

exports.TerraformError = helpers.TerraformError
exports.processors = helpers.processors
exports.findFirstFile = helpers.findFirstFile
exports.walkData = helpers.walkData
exports.isTemplate = helpers.isTemplate
exports.isStylesheet = helpers.isStylesheet
exports.isJavaScript = helpers.isJavaScript
exports.TerraformError = helpers.TerraformError
exports.processors = helpers.processors
exports.findFirstFile = helpers.findFirstFile
exports.findNearestLayout = helpers.findNearestLayout
exports.walkData = helpers.walkData
exports.isTemplate = helpers.isTemplate
exports.isStylesheet = helpers.isStylesheet
exports.isJavaScript = helpers.isJavaScript

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

/**
* Priority List
* Build Priority List
*

@@ -34,18 +34,18 @@ * returns a priority list of files to look for on a given request.

*
* priorityList("foobar")
* buildPriorityList("foobar")
* => ["foobar", "foobar.html", "foobar.jade", "foobar.html.jade"]
*
* priorityList("foobar.css")
* buildPriorityList("foobar.css")
* => ["foobar.css", "foobar.less", "foobar.css.less"]
*
* priorityList("foobar.html")
* buildPriorityList("foobar.html")
* => ["foobar.html", "foobar.jade", "foobar.html.jade"]
*
* priorityList("foobar.jade")
* buildPriorityList("foobar.jade")
* => ["foobar.jade"]
*
* priorityList("foobar.html.jade.html")
* buildPriorityList("foobar.html.jade.html")
* => ["foobar.html.jade.html", "foobar.html.jade.jade", "foobar.html.jade.html.jade"]
*
* priorityList("hello/foobar")
* buildPriorityList("hello/foobar")
* => ["hello/foobar", "hello/foobar.html", "hello/foobar.jade", "hello/foobar.html.jade"]

@@ -55,3 +55,3 @@ *

exports.buildPriorityList = function(filePath){
var buildPriorityList = exports.buildPriorityList = function(filePath){

@@ -104,3 +104,3 @@ var list = []

*
* findFile(["foo.html", "foo.jade", "foo.html.jade"])
* findFirstFile("/path/to/public", ["foo.html", "foo.jade", "foo.html.jade"])
* => "foo.jade"

@@ -112,3 +112,3 @@ *

exports.findFirstFile = function(dir, arr) {
var findFirstFile = exports.findFirstFile = function(dir, arr) {
var dirPath = path.dirname(path.join(dir, arr[0]))

@@ -138,3 +138,33 @@ var fullPath = path.resolve(dirPath)

var layoutPriorityList = buildPriorityList("_layout.html")
/**
* Find Nearest Layout
*
* Walks up the tree to find the nearest _layout file. Returns relative path to root
*
* findNearestLayout("/path/to/public", "/path/to/public/nested/dir")
* => "_layout.jade"
*
* returns null if no layout is found.
*
*/
var findNearestLayout = exports.findNearestLayout = function(rootPath, dirPath) {
// lets make sure we are working with an absolute path
var dirPath = path.resolve(rootPath, (dirPath || ""))
var layout = findFirstFile(dirPath, layoutPriorityList)
// if we have a layout we return relative path
if(layout !== null)
return path.relative(rootPath, path.join(dirPath, layout))
return path.relative(rootPath, dirPath) !== ''
? findNearestLayout(rootPath, path.resolve(dirPath, ".."))
: null // we reached the root
}
/**
* Is Empty

@@ -241,38 +271,2 @@ *

*
* Walk Data Tree
*
* Recursive function that returns the data object accociated with path.
*
* var globals = {
* "public": {
* "articles": {
* "data": {
* "hello-world": "You Found Me!"
* }
* }
* }
* }
*
* walkData(["public", "articles", "hello-world"], globals) => "You Found Me!"
*/
var walkData = exports.walkData = function(tail, obj){
var tail = tail.slice(0) // clone array.
var head = tail.shift()
if(obj.hasOwnProperty(head)){
return walkData(tail, obj[head])
}else if(obj.hasOwnProperty("data")){
return obj["data"][head]
? obj["data"][head]
: null
}else{
return null
}
}
/**
*
* Get Current

@@ -279,0 +273,0 @@ *

@@ -1,2 +0,2 @@

var marked = require("marked")
var marked = require("marked").setOptions({ langPrefix: 'language-' })
var TerraformError = require("../../error").TerraformError

@@ -3,0 +3,0 @@

@@ -86,4 +86,2 @@ var fs = require('fs')

/**
* If no layout is passed in we want to use the default layout.
*
* Layout Priority:

@@ -97,22 +95,32 @@ *

// 1. check for layout passed in
if(!locals.hasOwnProperty('layout')){
// 2. _data.json layout
// TODO: Change this lookup relative to path.
var templateLocals = helpers.walkData(locals.current.path, data)
/**
* default layout
*/
if(templateLocals && templateLocals.hasOwnProperty('layout')){
if(templateLocals['layout'] !== true){
locals['layout'] = layout
// relative path
var dirname = path.dirname(filePath)
var layoutPriorityList = helpers.buildPriorityList(path.join(dirname, templateLocals['layout']))
// absolute path (fallback)
layoutPriorityList.push(templateLocals['layout'])
/**
* _data.json layout
*/
// return first existing file
// TODO: Throw error if null
locals['layout'] = helpers.findFirstFile(root, layoutPriorityList)
var templateLocals = helpers.walkData(locals.current.path, data)
}
}
if(templateLocals && templateLocals.hasOwnProperty('layout')){
locals['layout'] = templateLocals['layout']
// 3. default _layout file
if(!locals.hasOwnProperty('layout')){
locals['layout'] = helpers.findNearestLayout(root, path.dirname(filePath))
}
// 4. no layout (do nothing)
}

@@ -119,0 +127,0 @@

{
"name": "terraform",
"version": "0.5.0",
"description": "Foolproof Asset Pipeline used in the Harp",
"version": "0.5.2",
"description": "pre-processor engine that powers the harp web server",
"repository" : { "type" : "git", "url" : "https://github.com/sintaxi/terraform.git" },
"main": "./lib/terraform",

@@ -12,3 +13,4 @@ "scripts": {

{ "name": "Brock Whitten", "email": "brock@chloi.io" },
{ "name": "Brian Donovan", "email": "donovan@squareup.com" }
{ "name": "Brian Donovan", "email": "donovan@squareup.com" },
{ "name": "Kenneth Ormandy", "email": "kenneth@chloi.io" }
],

@@ -15,0 +17,0 @@ "license": "MIT",

# terraform
> Terraform is the pre-processor engine for the Harp Web Server. Terraform does not write or serve files. Ony processes.
> Terraform is the pre-processor engine for the Harp Web Server. Terraform does not write or serve files. It processes and provides a layout/partial paradgm.

@@ -19,4 +19,2 @@ ## Features

![](https://s3-us-west-2.amazonaws.com/harp-misc/terraform.jpg)
## Install

@@ -47,3 +45,3 @@

```javascript
planet.render('index.jade', function(error, body){
planet.render('index.jade', { "title": "Override the global title" }, function(error, body){
console.log(body)

@@ -55,4 +53,6 @@ })

Please run the tests
npm install
npm test
![](https://s3-us-west-2.amazonaws.com/harp-misc/terraform-tests.png)
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