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

ender

Package Overview
Dependencies
Maintainers
5
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ender - npm Package Compare versions

Comparing version 2.0.5 to 2.1.0

lib/args-parser.js

2

buster.js

@@ -30,3 +30,3 @@ /*!

environment: 'node'
, tests: [ 'test/unit/*-test.js' ]
, tests: [ 'test/unit/*-test.js', 'test/unit/commands/*-test.js' ]
, libs: [ 'test/common.js' ]

@@ -33,0 +33,0 @@ }

@@ -33,10 +33,41 @@ /*!

var errno = require('errno')
, EnderError = errno.custom.createError('EnderError')
var errno = require('errno')
module.exports.FilesystemError = errno.custom.FilesystemError
module.exports.EnderError = EnderError
module.exports.BuildParseError = errno.custom.createError('BuildParseError', EnderError)
module.exports.JSONParseError = errno.custom.createError('JSONParseError', EnderError)
module.exports.ChildProcessError = errno.custom.createError('ChildProcessError', EnderError)
module.exports.CompressionError = errno.custom.createError('CompressionError', EnderError)
, EnderError = errno.custom.createError('EnderError')
, ArgumentParserError = errno.custom.createError('ArgumentParserError', EnderError)
, InstallError = errno.custom.createError('InstallError', EnderError)
, BuildError = errno.custom.createError('BuildError', EnderError)
, PackageError = errno.custom.createError('PackageError', EnderError)
, RepositoryError = errno.custom.createError('RepositoryError', EnderError)
, CommandError = errno.custom.createError('CommandError', EnderError)
module.exports = {
FilesystemError : errno.custom.FilesystemError
, JSONParseError : errno.custom.createError('JSONParseError')
, EnderError : EnderError
, ArgumentParserError : ArgumentParserError
, UnknownCommandError : errno.custom.createError('UnknownCommandError', ArgumentParserError)
, UnknownOptionError : errno.custom.createError('UnknownOptionError', ArgumentParserError)
, InstallError : InstallError
, DependencyLoopError : errno.custom.createError('DependencyLoopError', InstallError)
, BuildError : BuildError
, MinifyError : errno.custom.createError('MinifyError', BuildError)
, TemplateError : errno.custom.createError('TemplateError', BuildError)
, PackageError : PackageError
, PackageNotFoundError : errno.custom.createError('PackageNotFoundError', PackageError)
, PackageNotLocalError : errno.custom.createError('PackageNotLocalError', PackageError)
, RepositoryError : RepositoryError
, RepositorySetupError : errno.custom.createError('RepositorySetupError', RepositoryError)
, RepositoryCommandError : errno.custom.createError('RepositoryCommandError', RepositoryError)
, CommandError : CommandError
, BuildParseError : errno.custom.createError('BuildParseError', CommandError)
, ChildProcessError : errno.custom.createError('ChildProcessError', CommandError)
, CompressionError : errno.custom.createError('CompressionError', CommandError)
}

@@ -36,30 +36,36 @@ /*!

//FIXME: remove this after 0.8 available on travis
!('exists' in require('fs')) && (function () {
require('fs').exists = require('path').exists
require('fs').existsSync = require('path').existsSync
}())
process.title = 'Ender'
var sysUtil = require('util')
, argsParser = require('ender-args-parser')
, Output = require('./output/output')
var argsParser = require('./args-parser')
// basic error handler, differentiates between 'known' EnderErrors and everything else
, complete = function (out, callback, err) {
if (err) out.error(err)
callback(err)
}
// public entry point can be used with a standard argv array or a string for API usage
, exec = function (argv, callback) {
, exec = function (argv, log, callback) {
var parseType = 'parse'
, options
, exe
, out
, complete = function (err) {
if (err && log) {
var name = (err.name || 'Error').replace(/([a-z])([A-Z])/g, '$1 $2')
log.error('{red}{bold}' + name + ': {/bold}' + err.message + '{/red}')
if (options.debug) {
log.error(err.stack)
if (err.cause) log.error('Caused by:\n' + err.cause.stack)
} else log.error('Run with --debug to see more information')
}
callback(err)
}
if (arguments.length < 3) {
callback = log
log = undefined
}
if (typeof argv == 'string') {
// for API use: ender.exec('ender <cmd>', cb)
argv = argv.split(/\s/).slice(1)
argv = argv.split(/\s/).slice(1)
parseType = 'parseClean' // parseClean knows there aren't 2 preceeding tokens

@@ -70,17 +76,9 @@ }

options = argsParser[parseType](argv)
// get the module to execute and it's partner output module
exe = options && require('./main-' + options.main)
out = options && require('./output/main-' + options.main + '-output').create(sysUtil, options.debug, options.quiet)
if (exe && out) {
exe.exec(options, out, complete.bind(null, out, callback))
} // else err? argsParser should take care of this if it's list of mains corresponds to the modules we have
require('./commands/' + options.command).exec(options, log, complete)
} catch (ex) {
// create a generic/base 'out' module which can do the error printing
out = Output.create(sysUtil, argv.indexOf('--debug') != -1)
complete(out, callback, ex)
options = options || { debug: argv.indexOf('--debug') != -1 }
complete(ex)
}
}
module.exports.exec = exec
module.exports.exec = exec

@@ -25,7 +25,74 @@ /*!

var fs = require('fs')
, sysUtil = require('util')
, tty = require('tty')
, argsParser = require('./args-parser')
, FilesystemError = require('./errors').FilesystemError
, BuildParseError = require('./errors').BuildParseError
// 'Packages:' is optional because it's not in <= 0.8.x Ender builds
, buildInfoRegex = /\n {2}\* Build: ender ([^\n]*)\s\S*(?:(?: {2}\* Packages: )([^\n]*))?/
, defaultClientLib = 'ender-core'
, defaultModuleLib = 'ender-commonjs'
, getCorePackages = function (options) {
var corePackages = []
if (options['client-lib'] != 'none')
corePackages.push(options['client-lib'] || defaultClientLib)
if (options['module-lib'] != 'none')
corePackages.push(options['module-lib'] || defaultModuleLib)
return corePackages
}
, packageList = function (options) {
var ids = options.packages && options.packages.length ? options.packages : [ '.' ]
return getCorePackages(options).concat(ids)
}
// for --use <file>
var getInputFilenameFromOptions = function (options) {
, getInputFilenameFromOptions = function (options) {
return options.use ? options.use.replace(/(\.js)?$/, '.js') : 'ender.js'
}
, parseContext = function (file, callback) {
fs.open(file, 'r', function (err, fd) {
if (err) return callback(new FilesystemError(err))
var buffer = new Buffer(2048)
fs.read(fd, buffer, 0, 2048, null, function (err, bytesRead, buffer) {
if (err) return callback(new FilesystemError(err))
fs.close(fd, function () {
// err? who cares, we have our data, let's use it and run for the hills!
var options
, error
, match = String(buffer).match(buildInfoRegex)
if (!match) {
error = 'Could not parse ender spec from "' + file + '" (not an Ender build file?)'
return callback(new BuildParseError(error))
}
try {
options = argsParser.parseClean(match[1].split(' '))
} catch (ex) {
error = 'Could not parse ender spec from "' + file + '"'
return callback(new BuildParseError(error, ex))
}
callback(null, {
options : options
, packages : match[2] && match[2].split(' ')
})
})
})
})
}
, toKb = function (size) {

@@ -36,5 +103,55 @@ size = Math.round(size / 1024 * 10) / 10

, styles = {
'bold': ['\033[1m', '\033[22m']
, 'italic': ['\033[3m', '\033[23m']
, 'underline': ['\033[4m', '\033[24m']
, 'inverse': ['\033[7m', '\033[27m']
, 'black': ['\033[30m', '\033[39m']
, 'red': ['\033[31m', '\033[39m']
, 'green': ['\033[32m', '\033[39m']
, 'yellow': ['\033[33m', '\033[39m']
, 'blue': ['\033[34m', '\033[39m']
, 'magenta': ['\033[35m', '\033[39m']
, 'cyan': ['\033[36m', '\033[39m']
, 'white': ['\033[37m', '\033[39m']
, 'default': ['\033[39m', '\033[39m']
, 'grey': ['\033[90m', '\033[39m']
, 'bgBlack': ['\033[40m', '\033[49m']
, 'bgRed': ['\033[41m', '\033[49m']
, 'bgGreen': ['\033[42m', '\033[49m']
, 'bgYellow': ['\033[43m', '\033[49m']
, 'bgBlue': ['\033[44m', '\033[49m']
, 'bgMagenta': ['\033[45m', '\033[49m']
, 'bgCyan': ['\033[46m', '\033[49m']
, 'bgWhite': ['\033[47m', '\033[49m']
, 'bgDefault': ['\033[49m', '\033[49m']
}
, tagPattern = /\{([^}\s]+)\}([\S\s]*?)\{\/\1\}/g
, renderTemplate = function (template) {
return template.replace(tagPattern, function (all, tag, content) {
content = renderTemplate(content)
if (!(tag in styles)) return '{' + tag + '}' + content + '{/' + tag + '}'
else if (tty.isatty(1)) return styles[tag][0] + content + styles[tag][1]
else return content
})
}
, defaultLogger = {
info : function (template) { sysUtil.print(renderTemplate(template) + '\n') }
, warn : function (template) { sysUtil.print(renderTemplate(template) + '\n') }
, error : function (template) { sysUtil.print(renderTemplate(template) + '\n') }
}
module.exports = parseContext
module.exports = {
toKb : toKb
getCorePackages : getCorePackages
, packageList : packageList
, getInputFilenameFromOptions : getInputFilenameFromOptions
}
, parseContext : parseContext
, toKb : toKb
, defaultLogger : defaultLogger
}
{
"name": "ender"
, "description": "Open Module JavaScript Framework"
, "version": "2.0.5"
, "version": "2.1.0"
, "authors": [

@@ -15,17 +15,10 @@ "Andrew McCollum (https://github.com/amccollum)"

, "dependencies": {
"ender-args-parser" : "1.0.3"
, "ender-builder" : "1.0.5"
, "ender-installer" : "1.0.3"
, "ender-package" : "1.0.3"
, "ender-repository" : "1.0.3"
, "colors" : "~0.6.0"
"archy" : "~0.0.2"
, "async" : "~0.2.10"
, "hogan.js" : "~2.0.0"
, "archy" : "~0.0.2"
, "colors-tmpl" : "~0.1.0"
, "errno" : "~0.0.5"
, "glob" : "~3.2.9"
, "mu2" : "~0.5.20"
, "npm" : "~1.4.6"
, "semver" : "~2.2.1"
, "xregexp" : "~2.0.0"
, "errno" : "~0.0.3"
}

@@ -43,3 +36,2 @@ , "directories": {

, "mkfiletree" : "*"
, "require-subvert" : "*"
}

@@ -46,0 +38,0 @@ , "bin": {

@@ -45,4 +45,3 @@ /*!

if (err) {
require('colors')
console.log('\nWARNING: java not available on this system, can\'t test Closure'.magenta.bold.inverse)
console.log('\nWARNING: java not available on this system, can\'t test Closure')
}

@@ -49,0 +48,0 @@ done()

@@ -29,3 +29,2 @@ /*!

, refute = require('referee').refute
, ender = require('../../lib/main')
, fs = require('fs')

@@ -35,29 +34,27 @@ , path = require('path')

, ender = require('../../lib/main')
buster.testCase('Functional: version', {
'setUp': function () {
this.output = []
this.stub(util, 'print', function (s) {
this.output.push(s)
}.bind(this))
}
'exec version': function (done) {
var logArg = {
infoActual: ''
, warnActual: ''
, errorActual: ''
, 'exec version (API)': function (complete) {
fs.readFile(path.resolve(__dirname, '../../package.json'), 'utf-8', function (err, contents) {
, info: function (str) { logArg.infoActual += str + '\n' }
, warn: function (str) { logArg.warnActual += str + '\n' }
, error: function (str) { logArg.errorActual += str + '\n' }
}
fs.readFile(path.resolve(__dirname, '..', '..', 'package.json'), 'utf-8', function (err, contents) {
refute(err, 'read package.json')
var expectedVersion = contents.match(/"version"\s*:\s*"([^"]+)"/)[1]
logArg.infoExpected = 'Active version: v' + contents.match(/"version"\s*:\s*"([^"]+)"/)[1] + '\n'
ender.exec('ender version', function () {
var actualVersionString
this.output.forEach(function (str) {
if (/^Active /.test(str))
actualVersionString = str.replace(/[^\w\:\s\.\-]/, '')
}.bind(this))
assert.equals(actualVersionString, 'Active version: v' + expectedVersion, 'printed correct version string')
complete()
}.bind(this))
}.bind(this))
ender.exec('ender version', logArg, function () {
assert.equals(logArg.infoActual, logArg.infoExpected, 'printed correct version string')
done()
})
})
}
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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