base-cli-process
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -15,4 +15,3 @@ 'use strict'; | ||
return function(app, base) { | ||
if (!this.isApp) return; | ||
if (this.isRegistered('base-cli-process')) return; | ||
if (!this.isApp || this.isRegistered('base-cli-process')) return; | ||
debug('initializing <%s>, called from <%s>', __filename, module.parent.id); | ||
@@ -66,2 +65,4 @@ | ||
function initPlugins(app, options) { | ||
app.use(utils.cwd()); | ||
if (typeof app.option === 'undefined') { | ||
@@ -68,0 +69,0 @@ app.use(utils.option(options)); |
@@ -6,9 +6,5 @@ 'use strict'; | ||
module.exports = function(prop) { | ||
return debug('base:cli:process:' + prop); | ||
}; | ||
module.exports.field = function(key, val) { | ||
base('field')('normalizing ' + key + ', ' + val); | ||
field('normalizing ' + key + ', ' + val); | ||
}; | ||
@@ -41,3 +41,3 @@ 'use strict'; | ||
if (utils.isString(val)) { | ||
val = utils.stripQuotes(val); | ||
val = [utils.stripQuotes(val)]; | ||
} | ||
@@ -44,0 +44,0 @@ app.config.process({asyncHelpers: val}, next); |
'use strict'; | ||
var path = require('path'); | ||
var merge = require('merge-deep'); | ||
var normalize = require('../normalize'); | ||
var utils = require('../utils'); | ||
@@ -43,15 +43,24 @@ | ||
var keys = Object.keys(val); | ||
var orig = app.pkg.get(name) || {}; | ||
var pkgPath = path.resolve(app.cwd, 'package.json'); | ||
var pkg = {}; | ||
// temporarily remove the config object from package.json | ||
if (utils.exists(pkgPath)) { | ||
pkg = require(pkgPath); | ||
} | ||
pkg = merge({}, app.pkg.data, pkg); | ||
app.pkg.del(name); | ||
var orig = pkg[name] || {}; | ||
// normalize both the old and new values befor merging, using | ||
// a schema that is specifically used for normalizing values to | ||
// be written back to package.json | ||
orig = normalize(app, orig); | ||
val = normalize(app, val); | ||
orig = app.cli.schema.normalize(orig); | ||
// merge the normalized values | ||
var merged = merge({}, orig, val); | ||
var merged = val; | ||
if (utils.isObject(val) && utils.isObject(orig)) { | ||
merged = merge({}, orig, val); | ||
} | ||
@@ -63,3 +72,2 @@ // show the new value in the console | ||
// update options and `cache.config` | ||
app.option(merged); | ||
app.set('cache.config', merged); | ||
@@ -74,4 +82,5 @@ app.emit('config', merged); | ||
app.pkg.save(); | ||
next(); | ||
app.cli.process(merged, next); | ||
}; | ||
}; |
@@ -23,3 +23,3 @@ 'use strict'; | ||
module.exports = function(app) { | ||
module.exports = function(app, base) { | ||
return function(val, key, config, next) { | ||
@@ -38,4 +38,4 @@ app.debug('command > %s: "%j"', key, val); | ||
} else { | ||
for (var key in val) { | ||
app.emit('data', key, val[key]); | ||
for (var prop in val) { | ||
app.emit('data', prop, val[prop]); | ||
} | ||
@@ -45,2 +45,3 @@ app.cache.data = utils.merge({}, app.cache.data, val); | ||
} | ||
config[key] = val; | ||
@@ -47,0 +48,0 @@ next(); |
'use strict'; | ||
var util = require('util'); | ||
var utils = require('../utils'); | ||
@@ -42,3 +41,3 @@ | ||
if (utils.isString(val)) { | ||
val = utils.stripQuotes(val); | ||
val = config[key] = [utils.stripQuotes(val)]; | ||
} | ||
@@ -45,0 +44,0 @@ app.config.process({helpers: val}, next); |
'use strict'; | ||
var utils = require('../utils'); | ||
/** | ||
@@ -6,0 +4,0 @@ * Merge options onto the `app.options` object. If the [base-option][] plugin |
@@ -5,4 +5,5 @@ 'use strict'; | ||
return function(val, key, config, next) { | ||
if (!val) return next(); | ||
app.config.process({use: val}, next); | ||
}; | ||
}; |
@@ -16,2 +16,3 @@ 'use strict'; | ||
require('base-cli-schema', 'schema'); | ||
require('base-cwd', 'cwd'); | ||
require('base-config-process', 'config'); | ||
@@ -24,6 +25,6 @@ require('base-option', 'option'); | ||
require('arr-union'); | ||
require('fs-exists-sync', 'exists'); | ||
require('kind-of', 'typeOf'); | ||
require('log-utils', 'log'); | ||
require('mixin-deep', 'merge'); | ||
require('map-schema', 'Schema'); | ||
require('object.pick', 'pick'); | ||
@@ -30,0 +31,0 @@ require('os-homedir', 'home'); |
{ | ||
"name": "base-cli-process", | ||
"description": "Commonly used config mappings for the base-cli plugin. Also pre-processes the given object with base-cli-schema before calling `.process()`", | ||
"version": "0.1.0", | ||
"description": "Normalizers for common argv commands handled by the base-cli plugin. Also pre-processes the given object with base-cli-schema before calling `.process()`", | ||
"version": "0.1.1", | ||
"homepage": "https://github.com/jonschlinkert/base-cli-process", | ||
@@ -26,5 +26,6 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"arrayify-compact": "^0.2.0", | ||
"base-cli": "^0.4.26", | ||
"base-cli-schema": "^0.1.3", | ||
"base-config-process": "^0.1.0", | ||
"base-cli": "^0.5.0", | ||
"base-cli-schema": "^0.1.7", | ||
"base-config-process": "^0.1.1", | ||
"base-cwd": "^0.1.6", | ||
"base-option": "^0.7.0", | ||
@@ -34,6 +35,7 @@ "base-pkg": "^0.2.0", | ||
"export-files": "^2.1.1", | ||
"fs-exists-sync": "^0.1.0", | ||
"kind-of": "^3.0.2", | ||
"lazy-cache": "^1.0.3", | ||
"log-utils": "^0.1.0", | ||
"merge-deep": "^2.0.2", | ||
"merge-deep": "^3.0.0", | ||
"mixin-deep": "^1.1.3", | ||
@@ -65,5 +67,5 @@ "object.pick": "^1.1.2", | ||
"baseplugin", | ||
"commands", | ||
"cli", | ||
"command-line", | ||
"cli" | ||
"commands" | ||
], | ||
@@ -88,5 +90,5 @@ "verb": { | ||
"reflinks": [ | ||
"verb", | ||
"base-cli", | ||
"base-cli-schema", | ||
"base-cli" | ||
"verb" | ||
], | ||
@@ -96,3 +98,6 @@ "lint": { | ||
} | ||
}, | ||
"base": { | ||
"toc": true | ||
} | ||
} |
# base-cli-process [](https://www.npmjs.com/package/base-cli-process) [](https://npmjs.org/package/base-cli-process) [](https://travis-ci.org/jonschlinkert/base-cli-process) | ||
> Commonly used config mappings for the base-cli plugin. Also pre-processes the given object with base-cli-schema before calling `.process()` | ||
> Normalizers for common argv commands handled by the base-cli plugin. Also pre-processes the given object with base-cli-schema before calling `.process()` | ||
@@ -19,10 +19,10 @@ ## Install | ||
var Base = require('base'); | ||
var config = require('base-cli-process'); | ||
var cli = require('base-cli-process'); | ||
var app = new Base(); | ||
app.use(config()); | ||
app.use(cli()); | ||
var pkg = require('./package'); | ||
app.config.process(pkg, function(err) { | ||
app.cli.process(pkg, function(err) { | ||
if (err) throw err; | ||
@@ -36,5 +36,5 @@ }); | ||
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://www.npmjs.com/package/base) | [homepage](https://github.com/node-base/base) | ||
* [base-cli](https://www.npmjs.com/package/base-cli): Plugin for base-methods that maps built-in methods to CLI args (also supports methods from a… [more](https://www.npmjs.com/package/base-cli) | [homepage](https://github.com/node-base/base-cli) | ||
* [base-config](https://www.npmjs.com/package/base-config): base-methods plugin that adds a `config` method for mapping declarative configuration values to other 'base'… [more](https://www.npmjs.com/package/base-config) | [homepage](https://github.com/node-base/base-config) | ||
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://www.npmjs.com/package/base) | [homepage](https://github.com/node-base/base) | ||
@@ -81,2 +81,2 @@ ## Contributing | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 11, 2016._ | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 15, 2016._ |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
18934
19
21
537
4
+ Addedbase-cwd@^0.1.6
+ Addedfs-exists-sync@^0.1.0
+ Addedbase-cli@0.5.0(transitive)
+ Addedbase-cwd@0.1.8(transitive)
- Removedaffirmative@0.1.1(transitive)
- Removedansi-escapes@1.4.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedarr-map@2.0.2(transitive)
- Removedarr-pluck@0.1.0(transitive)
- Removedasync-each-series@1.1.0(transitive)
- Removedbase-cli@0.4.26(transitive)
- Removedbase-questions@0.5.6(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcli-cursor@1.0.2(transitive)
- Removedcli-width@1.1.1(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedcolor-support@1.1.3(transitive)
- Removeddata-store@0.15.5(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedexit-hook@1.1.1(transitive)
- Removedfancy-log@1.3.3(transitive)
- Removedfigures@1.7.0(transitive)
- Removedgenerator-util@0.2.9(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-own-deep@0.1.4(transitive)
- Removedinquirer2@0.1.1(transitive)
- Removedis-affirmative@0.1.0(transitive)
- Removedis-answer@0.1.1(transitive)
- Removedis-date-object@1.1.0(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedlodash._arrayfilter@3.0.0(transitive)
- Removedlodash._basecallback@3.3.1(transitive)
- Removedlodash._baseeach@3.0.4(transitive)
- Removedlodash._basefilter@3.0.0(transitive)
- Removedlodash._baseisequal@3.0.7(transitive)
- Removedlodash._baseismatch@3.1.3(transitive)
- Removedlodash._basematches@3.2.0(transitive)
- Removedlodash._bindcallback@3.0.1(transitive)
- Removedlodash._getnative@3.9.1(transitive)
- Removedlodash.isarguments@3.1.0(transitive)
- Removedlodash.isarray@3.0.4(transitive)
- Removedlodash.istypedarray@3.0.6(transitive)
- Removedlodash.keys@3.1.2(transitive)
- Removedlodash.pairs@3.0.1(transitive)
- Removedlodash.where@3.1.0(transitive)
- Removedmake-iterator@1.0.1(transitive)
- Removedmap-schema@0.1.4(transitive)
- Removedmerge-deep@2.0.2(transitive)
- Removedmute-stream@0.0.5(transitive)
- Removednamify@0.1.3(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedomit-empty@0.3.6(transitive)
- Removedonetime@1.1.0(transitive)
- Removedopn@4.0.2(transitive)
- Removedparse-node-version@1.0.1(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
- Removedquestion-match@0.1.2(transitive)
- Removedquestion-store@0.8.8(transitive)
- Removedreadline2@1.0.1(transitive)
- Removedreserved@0.1.2(transitive)
- Removedrestore-cursor@1.0.1(transitive)
- Removedrimraf@2.7.1(transitive)
- Removedrun-async@0.1.0(transitive)
- Removedrx-lite@4.0.8(transitive)
- Removedspawn-commands@0.3.1(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedstrip-color@0.1.0(transitive)
- Removedsupports-color@2.0.0(transitive)
- Removedto-choices@0.2.0(transitive)
- Removedtry-open@0.1.3(transitive)
- Removeduse@1.1.2(transitive)
Updatedbase-cli@^0.5.0
Updatedbase-cli-schema@^0.1.7
Updatedbase-config-process@^0.1.1
Updatedmerge-deep@^3.0.0