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

autocmdr

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

autocmdr - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

gruntfile.js

26

lib/completion.js
/* commander/autocmdr component
* This component uses node-tabtab to add auto-completion support to your commander or autocmdr program.
* To use add require('autocmdr/lib/completion.js')(program) just before program.parse(argv).
*
* To use add require('autocmdr/lib/completion.js')(program) just before program.parse(argv).
*
* You will then need to do one of the following to enable auto-completion in your shell.
*
*
* - Add completion helper to ~/.bashrc (or ~/.zshrc) pkgname completion >> ~/.bashrc

@@ -11,19 +11,17 @@ * - Add completion to current shell . <(pkgname completion)

'use strict';
module.exports = function (program, opts) {
'use strict';
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
program // Needed to avoid unknown command trigger, should be hidden
.command('completion')
.description('Print command completion script')
.action(function(opts) {
program // Needed to avoid unknown command trigger, should be hidden
.command('completion')
.description('Print command completion script')
.action(function(opts) {
});
});
require('commander-tabtab').init(program, opts.name);
require('commander-tabtab').init(program, opts.name);
};

@@ -6,46 +6,46 @@ /* commander/autocmdr component

'use strict';
module.exports = function (program, opts) {
var path = require('path');
'use strict';
opts = opts || {};
opts.name = opts.name || program._name || path.basename(process.mainModule.filename);
opts.path = opts.path || path.join(process.mainModule.filename, '../../.'+opts.name);
var path = require('path');
var nconf = require('nconf');
opts = opts || {};
opts.name = opts.name || program._name || path.basename(process.mainModule.filename);
opts.path = opts.path || path.join(process.mainModule.filename, '../../.'+opts.name);
program.log.debug('Loading config from ', opts.path);
var nconf = require('nconf');
var store = nconf.file({ 'file': opts.path }).load();
program.log.debug('Loading config from ', opts.path);
function _config(key, value){
if (key && value !== null) {
var store = nconf.file({ 'file': opts.path }).load();
if (value === "") {
program.log.debug('Clearing key',key);
nconf.clear(key);
} else {
program.log.debug('Setting key',key,'to',value);
nconf.set(key, value);
}
nconf.save();
console.log(nconf.save());
} else if (key) {
program.log.debug('Retrieving key',key);
console.log(nconf.get(key));
} else {
program.log.debug('Listing all kay-values');
console.log(nconf.load());
}
function _config(key, value){
if (key && value !== null) {
}
if (value === "") {
program.log.debug('Clearing key',key);
nconf.clear(key);
} else {
program.log.debug('Setting key',key,'to',value);
nconf.set(key, value);
}
nconf.save();
console.log(nconf.save());
} else if (key) {
program.log.debug('Retrieving key',key);
console.log(nconf.get(key));
} else {
program.log.debug('Listing all kay-values');
console.log(nconf.load());
}
program
.command('config [key] [value]')
.description('Get and set options')
.action(_config);
}
program.config = nconf;
program
.command('config [key] [value]')
.description('Get and set options')
.action(_config);
program.config = nconf;
};

@@ -6,25 +6,23 @@ /* commander/autocmdr component

'use strict';
module.exports = function (program, opts) {
'use strict';
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
var didYouMean = require('didyoumean');
var didYouMean = require('didyoumean');
program
.on('*', function(name) {
program.log.error('\''+name+'\' is not a known command. See \''+opts.name+' --help\'.');
program
.on('*', function(name) {
program.log.error('\''+name+'\' is not a known command. See \''+opts.name+' --help\'.');
var d = didYouMean(name.toString(), program.commands, "_name");
var d = didYouMean(name.toString(), program.commands, "_name");
if (d)
program.log.info('Did you mean:', d, '?');
if (d)
program.log.info('Did you mean:', d, '?');
process.exit(1);
process.exit(1);
});
});
};

@@ -6,52 +6,51 @@ /* commander/autocmdr component

'use strict';
module.exports = function (program, opts) {
'use strict';
// Node.js
var path = require('path');
var fs = require('fs');
// Node.js
var path = require('path');
var fs = require('fs');
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
opts.path = opts.path || require('path').join(process.mainModule.filename, '../../cmds/');
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
opts.path = opts.path || require('path').join(process.mainModule.filename, '../../cmds/');
function _require(filepath) { // TODO: Prevent loading twice
function _require(filepath) { // TODO: Prevent loading twice
if(typeof filepath == "string") { // TODO: Don't load same command twice?
program.log.debug('Loading ',filepath);
if(typeof filepath == "string") { // TODO: Don't load same command twice?
program.log.debug('Loading ',filepath);
var _f = require(filepath);
if (typeof _f == "function")
_f(program); // This adds the command to this program
}
var _f = require(filepath);
if (typeof _f == "function")
_f(program); // This adds the command to this program
}
return program;
}
return program;
}
// Load tasks in a given folder.
function _loadCmds(dirpath) {
// Load tasks in a given folder.
function _loadCmds(dirpath) {
if (fs.existsSync(dirpath) && fs.statSync(dirpath).isDirectory()) {
program.log.debug('Loading commands from '+dirpath);
fs.readdirSync(dirpath).forEach(function(filename) {
var filepath = path.join(dirpath,filename);
_require(filepath);
});
} else {
program.log.debug('Directory not found '+dirpath);
}
if (fs.existsSync(dirpath) && fs.statSync(dirpath).isDirectory()) {
program.log.debug('Loading commands from '+dirpath);
fs.readdirSync(dirpath).forEach(function(filename) {
var filepath = path.join(dirpath,filename);
_require(filepath);
});
} else {
program.log.debug('Directory not found '+dirpath);
}
return program;
}
return program;
}
if (opts.path) {
_loadCmds(opts.path);
if (opts.path) {
_loadCmds(opts.path);
var _lib = path.join(opts.path, '../'+opts.name+'.js');
var _lib = path.join(opts.path, '../'+opts.name+'.js');
if (fs.existsSync(_lib))
_require(path.join(opts.path, '../'+opts.name+'.js')); // TODO: make filename an option?
}
if (fs.existsSync(_lib))
_require(path.join(opts.path, '../'+opts.name+'.js')); // TODO: make filename an option?
}
};
};

@@ -6,22 +6,22 @@ /* commander/autocmdr component

'use strict';
module.exports = function (program) {
var winston = require('winston');
'use strict';
program.option('-d, --debug', "enable debugger");
// TODO: --no-color
var winston = require('winston');
var argv = program.normalize(process.argv);
program.debug = argv.indexOf('-d') > -1 || argv.indexOf('--debug') > -1; // Need this early
program.option('-d, --debug', "enable debugger");
// TODO: --no-color
winston.cli();
winston.level = (program.debug) ? 'debug' : 'info';
var argv = program.normalize(process.argv);
program.debug = argv.indexOf('-d') > -1 || argv.indexOf('--debug') > -1; // Need this early
program.log = winston;
winston.cli();
winston.level = (program.debug) ? 'debug' : 'info';
if (program.debug) {
program.log.debug('Debug logging is on');
}
program.log = winston;
if (program.debug) {
program.log.debug('Debug logging is on');
}
};

@@ -7,35 +7,35 @@ /* commander/autocmdr component

'use strict';
module.exports = function (program, opts) {
var path = require('path');
var fs = require('fs');
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
opts.path = opts.path || path.join(process.mainModule.filename, '../../package.json');
if (!fs.existsSync(opts.path)) {
program.log.debug('Package not found at', opts.path);
return;
}
'use strict';
program.log.debug('Loading package from ', opts.path);
var path = require('path');
var fs = require('fs');
var pkg = require(opts.path);
program._name = opts.name;
opts = opts || {};
opts.name = opts.name || program._name || require('path').basename(process.mainModule.filename);
opts.path = opts.path || path.join(process.mainModule.filename, '../../package.json');
program
.version(pkg.version)
.description(pkg.description);
if (!fs.existsSync(opts.path)) {
program.log.debug('Package not found at', opts.path);
return;
}
if (pkg.bugs && pkg.bugs.url) {
program
.on('--help', function(){
console.log(' Bug reports, suggestions, updates:');
console.log(' ', pkg.bugs.url);
});
}
program.log.debug('Loading package from ', opts.path);
};
var pkg = require(opts.path);
program._name = opts.name;
program
.version(pkg.version)
.description(pkg.description);
if (pkg.bugs && pkg.bugs.url) {
program
.on('--help', function(){
console.log(' Bug reports, suggestions, updates:');
console.log(' ', pkg.bugs.url);
});
}
};
/* commander/autocmdr component
* This component uses eco to render template files.
* To use add require('autocmdr/lib/prompt.js')(program) .
*
* To use add require('autocmdr/lib/prompt.js')(program) .
*
*/
'use strict';
module.exports = function (program) {
'use strict';
var prompt = require('prompt');
var prompt = require('prompt');
prompt.message = program._name.green;
prompt.message = program._name.green;
return prompt;
return prompt;
};
};

@@ -7,66 +7,64 @@ /* commander/autocmdr component

'use strict';
module.exports = function (program) {
'use strict';
var fs = require('fs');
var eco = require('eco');
var path = require('path');
var mkdirp = require("mkdirp");
var async = require("async");
var fs = require('fs');
var eco = require('eco');
var path = require('path');
var mkdirp = require("mkdirp");
var async = require("async");
function _render(src, dst, context, done) {
function _render(src, dst, context, done) {
done = done || function(err) {
if (err)
program.log.error(err);
};
done = done || function(err) {
if (err)
program.log.error(err);
};
if (!src || !dst)
return done('err');
if (!src || !dst)
return done('err');
context = context || {};
context = context || {};
program.log.debug('Eco\'ing file ' + src + ' to ' + dst);
program.log.debug('Eco\'ing file ' + src + ' to ' + dst);
var data = "";
async.series([
function(cb){
program.log.debug('Reading',src.blue);
fs.readFile(src, "utf-8", function(err, _data) {
program.log.debug('Render');
data = eco.render(_data, context);
return cb(null);
});
},
function(cb){
var dirname = path.dirname(dst);
program.log.debug('Making path',dirname.blue);
mkdirp(dirname, cb);
},
function(cb){
program.log.debug('Writing',dst.blue);
fs.writeFile(dst, data, cb);
}], done);
var data = "";
async.series([
function(cb){
program.log.debug('Reading',src.blue);
fs.readFile(src, "utf-8", function(err, _data) {
program.log.debug('Render');
data = eco.render(_data, context);
return cb(null);
});
},
function(cb){
var dirname = path.dirname(dst);
program.log.debug('Making path',dirname.blue);
mkdirp(dirname, cb);
},
function(cb){
program.log.debug('Writing',dst.blue);
fs.writeFile(dst, data, cb);
}], done);
/* fs.readFile(src, "utf-8", function (err, data) {
if (err) return done(err);
/* fs.readFile(src, "utf-8", function (err, data) {
if (err) return done(err);
data = eco.render(data, context);
data = eco.render(data, context);
mkdirp(path.dirname(dst), function (err) {
if (err) return done(err);
mkdirp(path.dirname(dst), function (err) {
if (err) return done(err);
fs.writeFile(dst, data, done);
fs.writeFile(dst, data, done);
});
});
}); */
}); */
}
}
return _render;
return _render;
};
{
"name": "autocmdr",
"version": "0.0.6",
"version": "0.0.7",
"description": "autocmdr",

@@ -15,4 +15,4 @@ "main": "index.js",

"dependencies": {
"commander": "~2.0.0",
"winston": "~0.7.2",
"commander": "^2.2.0",
"winston": "~0.7.3",
"nconf": "~0.6.7",

@@ -30,4 +30,11 @@ "didyoumean": "~1.1.0",

"devDependencies": {
"mocha": "~1.12.1"
"mocha": "~1.12.1",
"load-grunt-tasks": "^0.4.0",
"grunt-mocha-test": "^0.10.2",
"grunt": "^0.4.5",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-jshint": "^0.10.0",
"nixt": "^0.3.0",
"grunt-release": "^0.7.0"
}
}

@@ -1,4 +0,6 @@

autocmdr [![Build Status](https://secure.travis-ci.org/Hypercubed/autocmdr.png?branch=master)](https://travis-ci.org/Hypercubed/autocmdr) [![NPM version](https://badge.fury.io/js/autocmdr.png)](http://badge.fury.io/js/autocmdr)
autocmdr [![Build Status](https://secure.travis-ci.org/Hypercubed/autocmdr.png?branch=master)](https://travis-ci.org/Hypercubed/autocmdr) [![NPM version](https://badge.fury.io/js/autocmdr.png)](http://badge.fury.io/js/autocmdr) [![Code Climate](https://codeclimate.com/github/Hypercubed/autocmdr.png)](https://codeclimate.com/github/Hypercubed/autocmdr)
=============
[![NPM](https://nodei.co/npm/autocmdr.png?downloads=true)](https://nodei.co/npm/autocmdr/)
autocmdr is a both a command line interface for running tasks and a set of components for building CLIs. autocmdr is designed to work with [generator-commander](https://github.com/Hypercubed/generator-commander) to enable easily building of commander.js command line apps.

@@ -5,0 +7,0 @@

@@ -66,1 +66,5 @@ # Todo list for [autocmdr](https://github.com/Hypercubed/autocmdr)

- [-] Take a look at render plugin.
- [ ] Update commnder.js (2.0.0 -> 2.2.0)
- [ ] Add grunt {_test_,_watch_,publish}
- [ ] Use nixt for testing
- [ ] Tabs -> spaces

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