Skip to content

Commit

Permalink
Merge pull request #502 from senecajs/defaults
Browse files Browse the repository at this point in the history
Removal of default plugins
  • Loading branch information
mcdonnelldean authored Aug 23, 2016
2 parents 10efa0e + 8d5c804 commit 824e7f0
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 462 deletions.
17 changes: 0 additions & 17 deletions lib/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
var Util = require('util')
var _ = require('lodash')
var Eraro = require('eraro')
var Parambulator = require('parambulator')
var Common = require('./common')

// Shortcuts
Expand All @@ -19,16 +18,6 @@ var internals = {
'... }. The correct format is: function(options) { ... }. For more details, ' +
'please see http://senecajs.org/tutorials/how-to-write-a-plugin.html'
}
}),
schema: Parambulator({
type$: 'object',
required$: ['name', 'init'],
string$: ['name'],
function$: ['init', 'service'],
object$: ['options']
}, {
topname: 'plugin',
msgprefix: 'register(plugin): '
})
}

Expand All @@ -38,12 +27,6 @@ module.exports.register = function (so, callpoint) {
return function api_register (plugin) {
var seneca = this

internals.schema.validate(plugin, function (err) {
if (err) {
throw err
}
})

var preload = plugin.init.preload
preload = _.isFunction(preload) ? preload : _.noop
var meta = preload.call(seneca, plugin) || {}
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@
"minimist": "1.2.0",
"nid": "0.3.2",
"norma": "0.3.0",
"parambulator": "1.5.2",
"patrun": "0.5.0",
"rolling-stats": "0.1.1",
"semver": "5.3.0",
"seneca-parambulator": "0.2.0",
"seneca-legacy-logger": "0.1.0",
"seneca-basic": "0.4.0",
"seneca-repl": "0.2.0",
"seneca-transport": "2.0.0",
"use-plugin": "0.3.1"
},
Expand Down Expand Up @@ -103,7 +99,6 @@
"eslint-config-seneca": "3.x.x",
"eslint-plugin-hapi": "4.x.x",
"eslint-plugin-standard": "2.x.x",
"joi": "9.0.x",
"lab": "11.0.x",
"seneca-entity": "1.2.x",
"seneca-error-test": "0.2.x"
Expand Down
54 changes: 3 additions & 51 deletions seneca.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var Makeuse = require('use-plugin')
var Nid = require('nid')
var Norma = require('norma')
var Patrun = require('patrun')
var Parambulator = require('parambulator')
var Stats = require('rolling-stats')


Expand All @@ -42,15 +41,6 @@ var internals = {
msgmap: Errors,
override: true
}),
schema: Parambulator({
tag: { string$: true },
idlen: { integer$: true },
timeout: { integer$: true },
errhandler: { function$: true }
}, {
topname: 'options',
msgprefix: 'seneca({...}): '
}),
defaults: {
// Tag this Seneca instance, will be appended to instance identifier.
tag: '-',
Expand All @@ -64,8 +54,6 @@ var internals = {
// Register (true) default plugins. Set false to not register when
// using custom versions.
default_plugins: {
basic: true,
repl: true,
transport: true
},

Expand Down Expand Up @@ -170,13 +158,9 @@ var internals = {

// backwards compatibility settings
legacy: {

// use old error codes, until version 3.x
error_codes: true,

// use parambulator for message validation, until version 3.x
validate: true,

// use old logging, until version 3.x
logging: true
}
Expand Down Expand Up @@ -227,19 +211,10 @@ module.exports = function init (seneca_options, more_options) {
seneca.decorate('findplugin', Plugins.api_decorations.findplugin)
seneca.decorate('plugins', Plugins.api_decorations.plugins)


if (options.legacy.validate) {
seneca.use(require('seneca-parambulator'))
}

// HACK: makes this sync - FIX: use preload
if (options.default_plugins.repl) {
require('seneca-repl').call(seneca, options.repl)
}

// Register default plugins, unless turned off by options.
if (options.default_plugins.basic) { seneca.use(require('seneca-basic')) }
if (options.default_plugins.transport) { seneca.use(require('seneca-transport')) }
if (options.default_plugins.transport) {
seneca.use(require('seneca-transport'))
}

// Register plugins specified in options.
_.each(options.plugins, function (plugindesc) {
Expand Down Expand Up @@ -295,13 +270,6 @@ function make_seneca (initial_options) {
// Define options
var so = private$.optioner.set(initial_options)

// TODO: remove parambulator dep from Seneca; do this another way
internals.schema.validate(so, function (err) {
if (err) {
throw err
}
})

// Create internal tools.
var actnid = Nid({length: so.idlen})
var refnid = function () { return '(' + actnid() + ')' }
Expand Down Expand Up @@ -945,22 +913,6 @@ function make_seneca (initial_options) {
return self
}

// TODO: move repl functionality to seneca-repl

root.inrepl = function () {
var self = this

self.on('act-out', function () {
Legacy.loghandler.print.apply(null, arrayify(arguments))
})

self.on('error', function () {
var args = arrayify(arguments)
args.unshift('ERROR: ')
Legacy.loghandler.print.apply(null, args)
})
}

// Return self. Mostly useful as a check that this is a Seneca instance.
function api_seneca () {
return this
Expand Down
117 changes: 0 additions & 117 deletions test/basic.test.js

This file was deleted.

30 changes: 0 additions & 30 deletions test/error.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ describe('error', function () {

it('act_not_found', act_not_found)

it('param_caller', param_caller)

it('exec_action_throw_basic', exec_action_throw_basic)
it('exec_action_throw_nolog', exec_action_throw_nolog)
it('exec_action_errhandler_throw', exec_action_errhandler_throw)
Expand Down Expand Up @@ -92,34 +90,6 @@ describe('error', function () {
})
}

function param_caller (done) {
var ctxt = {errlog: null}
var si = make_seneca(ctxt)

si.ready(function () {
si.add('a:1,b:{required$:true}', function (args, done) { this.good({x: 1}) })

// ~~ CASE: callback; args-invalid; err-result; err-logged
si.act('a:1', function (err) {
assert.equal('act_invalid_msg', err.code)

if (si.options().legacy.logging) {
assert.equal('act_invalid_msg', ctxt.errlog[14])
}
else {
assert.equal('act_invalid_msg', ctxt.errlog.code)
}

// ~~ CASE: callback; args-valid
si.act('a:1,b:1', function (err, out) {
assert.equal(err, null)
assert.equal(1, out.x)
done()
})
})
})
}

function exec_action_throw_basic (done) {
var ctxt = {errlog: null, done: done, log: true, name: 'throw'}
var si = make_seneca(ctxt)
Expand Down
Loading

0 comments on commit 824e7f0

Please sign in to comment.