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

base-runtimes

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base-runtimes - npm Package Compare versions

Comparing version 0.1.11 to 0.2.0

156

index.js

@@ -16,14 +16,40 @@ /*!

return function baseRuntimes(app) {
if (!isValidInstance(app)) return;
if (!utils.isValid(app, 'base-runtimes')) return;
var time = new utils.Time();
var log = utils.log;
this.on('starting', function(build) {
if (!silent(app, build, null)) {
starting(namespace(build));
// create build context
var ctx = {app: build};
ctx.key = toKey(namespace(build));
ctx.event = 'starting';
time.start(ctx.key);
ctx.time = '';
ctx.isBuild = true;
ctx.isSilent = silent(app, build, null);
if (app.hasListeners('build')) {
app.emit('build', ctx.event, ctx);
} else if (app.base.hasListeners('build')) {
app.base.emit('build', ctx.event, ctx);
} else if (!ctx.isSilent) {
console.error(log.timestamp, ctx.event, ctx.key, log.red(ctx.time));
}
});
this.on('finished', function(build) {
if (!silent(app, build, null)) {
finished(namespace(build));
this.on('finished', function(build, run) {
// create build context
var ctx = {app: build};
ctx.key = toKey(namespace(build));
ctx.time = time.end(ctx.key);
ctx.event = 'finished';
ctx.isBuild = true;
ctx.isSilent = silent(app, build, null);
if (app.hasListeners('build')) {
app.emit('build', ctx.event, ctx);
} else if (app.base.hasListeners('build')) {
app.base.emit('build', ctx.event, ctx);
} else if (!ctx.isSilent) {
console.error(log.timestamp, ctx.event, ctx.key, log.red(ctx.time));
}

@@ -33,5 +59,15 @@ });

this.on('task:starting', function(task) {
if (!silent(app, null, task)) {
if (task.name === 'noop') return;
starting(namespace(app), name(task) + ' task');
task.key = toKey(namespace(app), name(task) + ' task');
time.start('task:' + task.key);
task.event = 'starting';
task.time = '';
task.isTask = true;
task.isSilent = silent(app, null, task);
if (app.hasListeners('task')) {
app.emit('task', task.event, task);
} else if (app.base.hasListeners('task')) {
app.base.emit('task', task.event, task);
} else if (!task.isSilent) {
console.error(log.timestamp, task.event, task.key, log.red(task.time));
}

@@ -41,40 +77,65 @@ });

this.on('task:finished', function(task) {
if (!silent(app, null, task)) {
if (task.name === 'noop') return;
finished(namespace(app), name(task) + ' task');
task.key = toKey(namespace(app), name(task) + ' task');
task.time = time.end('task:' + task.key);
task.event = 'finished';
task.isTask = true;
task.isSilent = silent(app, null, task);
if (app.hasListeners('task')) {
app.emit('task', task.event, task);
} else if (app.base.hasListeners('task')) {
app.base.emit('task', task.event, task);
} else if (!task.isSilent) {
console.error(log.timestamp, task.event, task.key, log.red(task.time));
}
});
this.once('done', function() {
utils.timestamp('finished', utils.log.success);
});
/**
* Handle toggling of verbose and silent modes
*/
function starting(namespace, name) {
var key = toKey(namespace, name);
time.start(key);
utils.timestamp('starting', key);
}
function silent(app, build, task) {
var opts = utils.extend({}, app.base.options, app.options);
function finished(namespace, name) {
var key = toKey(namespace, name);
var prefix = key ? key + ' ' : '';
utils.timestamp('finished', prefix + utils.colors.magenta(time.end(key)));
}
if (build && build.options) {
opts = utils.extend({}, opts, build.options);
}
if (task && task.options) {
opts = utils.extend({}, opts, task.options);
}
function silent(app, build, task) {
if (app.options.verbose === true) {
var verbose = opts.verbose;
var silent = opts.silent;
// handle `verbose` first
if (typeof verbose === 'function') {
return verbose(app, build, task);
}
if (verbose === true) {
return false;
}
if (task && app.options.verbose === 'tasks') {
if (task && verbose === 'tasks') {
return false;
}
if (build && app.options.verbose === 'build') {
if (build && verbose === 'build') {
return false;
}
if (app.options.silent === true) {
// if not `verbose`, handle `silent`
if (typeof silent === 'function') {
return silent(app, build, task);
}
if (typeof silent === 'string') {
silent = [silent];
}
if (build && Array.isArray(silent) && isMatch(silent, build.alias)) {
return true;
}
if (task && task.options.silent === true) {
if (task && Array.isArray(silent) && isMatch(silent, task.name)) {
return true;
}
if (silent === true) {
return true;
}
}

@@ -87,3 +148,3 @@

function namespace(build) {
return build.env ? build.env.namespace : build.namespace;
return build.env ? build.env.namespace : (build.namespace || build._name);
}

@@ -94,4 +155,5 @@

if (namespace) {
namespace = stripDefault(namespace);
namespace = formatNamespace(namespace);
}
if (namespace && name) {

@@ -113,17 +175,25 @@ res = utils.colors.bold(utils.colors.cyan(namespace)) + ':' + utils.colors.yellow(name);

function stripDefault(name) {
function isMatch(name, val) {
return utils.mm(val, name).length !== 0;
}
function formatNamespace(name) {
if (name.indexOf('default.') === 0) {
return name.slice('default.'.length);
}
return name;
}
function isValidInstance(app, fn) {
if (!utils.isValid(app)) {
return false;
var segs = name.split('.');
var len = segs.length;
var idx = -1
var res = [];
while (++idx < len) {
var next = segs[idx + 1];
var seg = segs[idx];
if (next && next === seg) {
continue;
}
res.push(seg);
}
if (utils.isRegistered(app, 'base-runtimes', fn)) {
return false;
}
return true;
return res.join('.');
}
{
"name": "base-runtimes",
"description": "Plugin for adding composer-runtimes to base applications, complementing the base-tasks and base-generators plugins.",
"version": "0.1.11",
"version": "0.2.0",
"homepage": "https://github.com/node-base/base-runtimes",

@@ -14,2 +14,4 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",

"index.js",
"LICENSE",
"README.md",
"utils.js"

@@ -26,28 +28,39 @@ ],

"extend-shallow": "^2.0.1",
"is-registered": "^0.1.3",
"is-valid-instance": "^0.1.0",
"is-valid-app": "^0.2.0",
"lazy-cache": "^2.0.1",
"log-utils": "^0.1.3",
"log-utils": "^0.1.4",
"micromatch": "^2.3.10",
"time-diff": "^0.3.1"
},
"devDependencies": {
"base": "^0.8.1",
"base-task": "^0.4.3",
"base": "^0.11.1",
"base-app": "^0.2.6",
"base-task": "^0.6.1",
"gulp-format-md": "^0.1.9",
"mocha": "^2.4.5"
"mocha": "^2.5.3"
},
"keywords": [
"api",
"app",
"application",
"base",
"baseplugin",
"building-blocks",
"composer",
"create",
"diff",
"end",
"finish",
"framework",
"generate",
"generator",
"plugin",
"plugins",
"runtimes",
"start",
"task",
"time"
"time",
"tool",
"toolkit",
"tools"
],

@@ -81,3 +94,4 @@ "lintDeps": {

"composer-runtimes",
"verb"
"verb",
"verb-readme-generator"
],

@@ -84,0 +98,0 @@ "lint": {

@@ -12,5 +12,5 @@ 'use strict';

require('extend-shallow', 'extend');
require('is-registered');
require('is-valid-instance', 'isValid');
require('is-valid-app', 'isValid');
require('log-utils', 'log');
require('micromatch', 'mm');
require('time-diff', 'Time');

@@ -17,0 +17,0 @@ require = fn;

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