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

trails

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trails - npm Package Compare versions

Comparing version 1.0.0 to 1.0.2

2

index.js

@@ -89,2 +89,3 @@ /*eslint no-console: 0 */

this.config.main.packs.forEach(Pack => new Pack(this))
delete this.config.env // Delete env config, now it has been merge
}

@@ -134,2 +135,3 @@

this.emit('trails:stop')
lib.Trails.unbindEvents(this)

@@ -136,0 +138,0 @@

@@ -47,6 +47,4 @@ /*eslint no-console: 0 */

delete config.env
// merge remaining environment-specific config properties
return Object.assign({ }, config, envConfig, configTemplate)
return Object.assign({ }, config, configTemplate)
},

@@ -126,6 +124,30 @@

*/
unfreezeConfig (app) {
unfreezeConfig (app, modules) {
const unfreeze = (target, source) => {
const propNames = Object.getOwnPropertyNames(source)
propNames.forEach(name => {
const prop = source[name]
if (!prop || typeof prop !== 'object' || prop.constructor !== Object) {
target[name] = prop
return
}
const ignoreModule = modules.find(moduleId => require.cache[moduleId].exports === prop)
if (ignoreModule) {
return
}
target[name] = { }
unfreeze(target[name], prop)
})
return target
}
Object.defineProperties(app, {
config: {
value: Object.assign({ }, app.config)
value: unfreeze({ }, app.config),
configurable: true
}

@@ -169,3 +191,5 @@ })

})
app.once('trails:stop', () => lib.Trails.unfreezeConfig(app))
app.once('trails:stop', () => {
lib.Trails.unfreezeConfig(app, app.loadedModules)
})
app.once('trails:error:fatal', err => app.stop(err))

@@ -172,0 +196,0 @@ },

2

package.json
{
"name": "trails",
"version": "1.0.0",
"version": "1.0.2",
"description": "Modern Web Application Framework for Node.js",

@@ -5,0 +5,0 @@ "keywords": [

@@ -27,3 +27,3 @@ [![Trails.js][trails-image]][trails-url]

Trails uses [Yeoman](http://yeoman.io/) to generate scaffolding for new
applications, and to create resources inside the application.
applications, and to create resources inside the application.

@@ -55,3 +55,3 @@ ```sh

```sh
$ npm start
$ node server.js
```

@@ -83,3 +83,3 @@

#### Tutorials
#### Tutorials
- [Getting started](http://blog.jaumard.com/en/2016/01/05/getting-started-with-trails/)

@@ -119,3 +119,3 @@ - [Create a custom Trailpack](http://blog.jaumard.com/en/2016/01/06/create-a-trailpack-for-trails/)

and offers an upgrade path from existing Sails applications, but it utilizes
exactly zero lines of code from the original Sails project.
exactly zero lines of code from the original Sails project.

@@ -122,0 +122,0 @@ #### Q. Can I use my own ORM, Webserver, whatever?

'use strict'
const Errors = require('../../lib/errors')
const assert = require('assert')

@@ -5,0 +4,0 @@ const lib = require('../../lib')

@@ -17,35 +17,43 @@ 'use strict'

env: {
mergetest1: {
merged: 'yes',
extraneous: 'assigned'
envTest1: {
log: {
merged: 'yes',
extraneous: 'assigned'
}
},
mergetest2: {
nested: {
envTest2: {
log: {
nested: {
merged: 'yes',
extraneous: 'assigned'
},
merged: 'yes',
extraneous: 'assigned'
},
merged: 'yes',
extraneous: 'assigned'
}
},
mergetest3: {
nested: {
envTest3: {
log: {
nested: {
merged: 'yes',
extraneous: 'assigned',
deeplyNested: {
merged: 'yes',
extraneous: 'assigned'
}
},
merged: 'yes',
extraneous: 'assigned',
deeplyNested: {
merged: 'yes',
extraneous: 'assigned'
}
},
merged: 'yes',
extraneous: 'assigned'
extraneous: 'assigned'
}
}
},
merged: 'no',
nested: {
log: {
merged: 'no',
deeplyNested: {
merged: 'no'
}
},
normal: 'yes'
nested: {
merged: 'no',
deeplyNested: {
merged: 'no'
}
},
normal: 'yes'
}
}

@@ -59,10 +67,10 @@ })

it('should merge basic env config', () => {
process.env.NODE_ENV = 'mergetest1'
process.env.NODE_ENV = 'envTest1'
const config = lib.Trails.buildConfig(testConfig)
assert(config)
assert.equal(config.merged, 'yes')
assert.equal(config.extraneous, 'assigned')
assert.equal(config.normal, 'yes')
assert.equal(config.nested.merged, 'no')
assert.equal(config.log.merged, 'yes')
assert.equal(config.log.extraneous, 'assigned')
assert.equal(config.log.normal, 'yes')
assert.equal(config.log.nested.merged, 'no')

@@ -73,14 +81,14 @@ assert.equal(config.main.maxListeners, 128)

it('should merge nested env config', () => {
process.env.NODE_ENV = 'mergetest2'
process.env.NODE_ENV = 'envTest2'
const config = lib.Trails.buildConfig(testConfig)
assert(config)
assert.equal(config.merged, 'yes')
assert.equal(config.nested.merged, 'yes')
assert.equal(config.log.merged, 'yes')
assert.equal(config.log.nested.merged, 'yes')
assert.equal(config.extraneous, 'assigned')
assert.equal(config.nested.extraneous, 'assigned')
assert.equal(config.normal, 'yes')
assert.equal(config.extraneous, 'assigned')
assert.equal(config.normal, 'yes')
assert.equal(config.log.extraneous, 'assigned')
assert.equal(config.log.nested.extraneous, 'assigned')
assert.equal(config.log.normal, 'yes')
assert.equal(config.log.extraneous, 'assigned')
assert.equal(config.log.normal, 'yes')

@@ -91,17 +99,17 @@ assert.equal(config.main.maxListeners, 128)

it('should merge deeply nested env config', () => {
process.env.NODE_ENV = 'mergetest3'
process.env.NODE_ENV = 'envTest3'
const config = lib.Trails.buildConfig(testConfig)
assert(config)
assert.equal(config.merged, 'yes')
assert.equal(config.nested.merged, 'yes')
assert.equal(config.nested.deeplyNested.merged, 'yes')
assert.equal(config.log.merged, 'yes')
assert.equal(config.log.nested.merged, 'yes')
assert.equal(config.log.nested.deeplyNested.merged, 'yes')
assert.equal(config.extraneous, 'assigned')
assert.equal(config.nested.extraneous, 'assigned')
assert.equal(config.nested.deeplyNested.extraneous, 'assigned')
assert.equal(config.log.extraneous, 'assigned')
assert.equal(config.log.nested.extraneous, 'assigned')
assert.equal(config.log.nested.deeplyNested.extraneous, 'assigned')
assert.equal(config.normal, 'yes')
assert.equal(config.extraneous, 'assigned')
assert.equal(config.normal, 'yes')
assert.equal(config.log.normal, 'yes')
assert.equal(config.log.extraneous, 'assigned')
assert.equal(config.log.normal, 'yes')

@@ -116,6 +124,6 @@ assert.equal(config.main.maxListeners, 128)

assert(config)
assert.equal(config.merged, 'no')
assert.equal(config.normal, 'yes')
assert(!config.extraneous)
assert(!config.env)
assert.equal(config.log.merged, 'no')
assert.equal(config.log.normal, 'yes')
assert(!config.log.extraneous)
assert(config.env)

@@ -125,6 +133,6 @@ assert.equal(config.main.maxListeners, 128)

it('should remove "env" property from config', () => {
it('should keep "env" property from config', () => {
process.env.NODE_ENV = 'mergetest2'
const config = lib.Trails.buildConfig(testConfig)
assert(!config.env)
assert(config.env)
})

@@ -230,3 +238,3 @@ })

describe('#unfreezeConfig', () => {
it('should unfreeze config object', () => {
it('should unfreeze shallow config object', () => {
const app = {

@@ -241,6 +249,27 @@ config: {

lib.Trails.unfreezeConfig(app)
lib.Trails.unfreezeConfig(app, [ ])
app.config.a = 2
assert.equal(app.config.a, 2)
})
it('should unfreeze deep config object', () => {
const app = {
config: {
main: {
paths: {
root: 'rootpath',
temp: 'temppath'
},
foo: 1
}
}
}
lib.Trails.freezeConfig(app.config, [ ])
assert.throws(() => app.config.main.paths.root = 'newrootpath', Error)
lib.Trails.unfreezeConfig(app, [ ])
app.config.main.paths.root = 'newrootpath'
assert.equal(app.config.main.paths.root, 'newrootpath')
assert.equal(app.config.main.paths.temp, 'temppath')
assert.equal(app.config.main.foo, 1)
})
})

@@ -247,0 +276,0 @@

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