Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

boilerplate

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

boilerplate - npm Package Compare versions

Comparing version
0.5.1
to
0.5.2
+23
utils.js
'use strict';
var utils = require('lazy-cache')(require);
var fn = require;
require = utils;
/**
* Lazily required module dependencies
*/
require('base-plugins', 'plugins');
require('define-property', 'define');
require('expand-target', 'Target');
require('is-scaffold');
require('mixin-deep', 'merge');
require('scaffold', 'Scaffold');
require = fn;
/**
* Expose `utils` modules
*/
module.exports = utils;
+121
-47
'use strict';
var utils = require('expand-utils');
var define = require('define-property');
var Target = require('expand-target');
var plugins = require('base-plugins');
var Scaffold = require('scaffold');
var Base = require('base');
var util = require('expand-utils');
var utils = require('./utils');

@@ -34,11 +31,15 @@ /**

Base.call(this, {}, options);
this.is('Boilerplate');
this.use(plugins());
this.is('boilerplate');
this.use(utils.plugins());
define(this, 'count', 0);
this.options = options || {};
emit('scaffold', this, Boilerplate);
emit('target', this, Boilerplate);
emit('files', this, Boilerplate);
emit('file', this, Boilerplate);
utils.define(this, 'count', 0);
this.scaffolds = {};
this.targets = {};
if (utils.isConfig(options)) {
if (util.isConfig(options)) {
this.options = {};

@@ -57,8 +58,7 @@ this.expand(options);

/**
* Static method, returns `true` if the given value is an
* instance of `Boilerplate` or appears to be a valid `boilerplate`
* configuration object.
* Returns `true` if the given value is an instance of `Boilerplate` or appears to be a
* valid `boilerplate` configuration object.
*
* ```js
* Boilerplate.isBoilerplate({});
* boilerplate.isBoilerplate({});
* //=> false

@@ -71,6 +71,5 @@ *

* });
* Boilerplate.isBoilerplate(h5bp);
* boilerplate.isBoilerplate(h5bp);
* //=> true
* ```
* @static
* @param {Object} `config` The value to check

@@ -81,15 +80,4 @@ * @return {Boolean}

Boilerplate.isBoilerplate = function(config) {
if (!utils.isObject(config)) {
return false;
}
if (config.isBoilerplate) {
return true;
}
for (var key in config) {
if (Scaffold.isScaffold(config[key])) {
return true;
}
}
return false;
Boilerplate.prototype.isBoilerplate = function(config) {
return Boilerplate.isBoilerplate(config);
};

@@ -135,3 +123,3 @@

// support anonymous targets
if (utils.isTarget(boilerplate)) {
if (util.isTarget(boilerplate)) {
this.addTarget('target' + (this.count++), boilerplate);

@@ -145,6 +133,6 @@ return this;

if (Scaffold.isScaffold(val)) {
if (this.Scaffold.isScaffold(val)) {
this.addScaffold(key, val);
} else if (utils.isTarget(val)) {
} else if (util.isTarget(val)) {
this.addTarget(key, val);

@@ -169,4 +157,5 @@

* ```
* @emits `scaffold`
* @param {String} `name` the scaffold's name
* @param {Object} `boilerplate` Scaffold object where each key is a target or `options`.
* @param {Object} `config` Scaffold configuration object, where each key is a target or `options`.
* @return {Object}

@@ -176,3 +165,3 @@ * @api public

Boilerplate.prototype.addScaffold = function(name, boilerplate) {
Boilerplate.prototype.addScaffold = function(name, config) {
if (typeof name !== 'string') {

@@ -182,11 +171,16 @@ throw new TypeError('expected a string');

var Scaffold = this.get('Scaffold');
var scaffold = new Scaffold(this.options);
define(scaffold, 'name', name);
utils.define(scaffold, 'name', name);
scaffold.on('target', this.emit.bind(this, 'target'));
scaffold.on('files', this.emit.bind(this, 'files'));
scaffold.on('file', this.emit.bind(this, 'file'));
scaffold.options = utils.merge({}, this.options, scaffold.options, config.options);
scaffold.define('parent', this);
this.emit('scaffold', scaffold);
emit('target', scaffold, this);
emit('files', scaffold, this);
emit('file', scaffold, this);
this.run(scaffold);
scaffold.addTargets(boilerplate);
scaffold.addTargets(config);
this.scaffolds[name] = scaffold;

@@ -203,4 +197,5 @@ return scaffold;

* ```
* @emits `target`
* @param {String} `name` The target's name
* @param {Object} `target` Target object with a `files` property, or `src` and optionally a `dest` property.
* @param {Object} `target` Target configuration object with either a `files` or`src` property, and optionally a `dest` property.
* @return {Object}

@@ -210,18 +205,23 @@ * @api public

Boilerplate.prototype.addTarget = function(name, boilerplate) {
Boilerplate.prototype.addTarget = function(name, config) {
if (typeof name !== 'string') {
throw new TypeError('expected a string');
}
if (!utils.isObject(boilerplate)) {
if (!util.isObject(config)) {
throw new TypeError('expected an object');
}
var Target = this.get('Target');
var target = new Target(this.options);
define(target, 'name', name);
utils.define(target, 'name', name);
target.on('files', this.emit.bind(this, 'files'));
target.on('file', this.emit.bind(this, 'file'));
utils.run(this, 'target', target);
target.options = utils.merge({}, this.options, target.options, config.options);
target.define('parent', this);
target.addFiles(boilerplate);
this.emit('target', target);
emit('files', target, this);
emit('file', target, this);
util.run(this, 'target', target);
target.addFiles(config);
this.targets[name] = target;

@@ -232,2 +232,76 @@ return target;

/**
* Get or set the `Target` constructor to use for creating new targets.
*/
Object.defineProperty(Boilerplate.prototype, 'Target', {
configurable: true,
set: function(Target) {
utils.define(this, '_Target', Target);
},
get: function() {
return this._Target || this.options.Target || utils.Target;
}
});
/**
* Get or set the `Scaffold` constructor to use for creating new scaffolds.
*/
Object.defineProperty(Boilerplate.prototype, 'Scaffold', {
configurable: true,
set: function(Scaffold) {
utils.define(this, '_Scaffold', Scaffold);
},
get: function() {
return this._Scaffold || this.options.Scaffold || utils.Scaffold;
}
});
/**
* Static method, returns `true` if the given value is an
* instance of `Boilerplate` or appears to be a valid `boilerplate`
* configuration object.
*
* ```js
* Boilerplate.isBoilerplate({});
* //=> false
*
* var h5bp = new Boilerplate({
* options: {cwd: 'vendor/h5bp/dist'},
* root: {src: ['{.*,*.*}'], dest: 'src/'},
* // ...
* });
* Boilerplate.isBoilerplate(h5bp);
* //=> true
* ```
* @static
* @param {Object} `config` The value to check
* @return {Boolean}
* @api public
*/
Boilerplate.isBoilerplate = function(config) {
if (!util.isObject(config)) {
return false;
}
if (config.isBoilerplate) {
return true;
}
for (var key in config) {
if (utils.Scaffold.isScaffold(config[key])) {
return true;
}
}
return false;
};
/**
* Forward events
*/
function emit(name, a, b) {
a.on(name, b.emit.bind(b, name));
}
/**
* Expose `Boilerplate`

@@ -234,0 +308,0 @@ */

{
"name": "boilerplate",
"description": "Tools and conventions for authoring and publishing boilerplates that can be generated by any build system or generator.",
"version": "0.5.1",
"version": "0.5.2",
"homepage": "https://github.com/jonschlinkert/boilerplate",

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

"files": [
"index.js"
"index.js",
"utils.js"
],

@@ -24,17 +25,20 @@ "main": "index.js",

"dependencies": {
"base": "^0.11.0",
"base": "^0.11.1",
"base-plugins": "^0.4.13",
"define-property": "^0.2.5",
"expand-target": "^0.6.3",
"expand-target": "^0.6.4",
"expand-utils": "^0.2.1",
"scaffold": "^0.2.7"
"is-scaffold": "^0.1.1",
"lazy-cache": "^2.0.1",
"mixin-deep": "^1.1.3",
"scaffold": "^0.2.8"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-eslint": "^1.1.1",
"gulp": "^3.9.1",
"gulp-eslint": "^2.0.0",
"gulp-format-md": "^0.1.9",
"gulp-istanbul": "^0.10.3",
"gulp-istanbul": "^1.0.0",
"gulp-mocha": "^2.2.0",
"mocha": "^2.4.5",
"should": "^8.3.1"
"mocha": "^2.5.3",
"should": "^9.0.2"
},

@@ -101,4 +105,4 @@ "keywords": [

"verb",
"yeoman",
"verb-readme-generator"
"verb-readme-generator",
"yeoman"
],

@@ -105,0 +109,0 @@ "lint": {