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

consultant

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consultant - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

lib/Page.js

12

lib/index.js

@@ -13,2 +13,6 @@ /**

var _Page = require('./Page.js');
var _Page2 = _interopRequireDefault(_Page);
var _RuleCollection = require('./RuleCollection.js');

@@ -31,4 +35,10 @@

class Consultant {
constructor() {}
constructor() {
this.sections = {};
}
createPage(title, rules) {
return new _Page2.default(title, rules);
}
createRuleCollection(rules) {

@@ -35,0 +45,0 @@ return new _RuleCollection2.default(rules);

44

lib/RuleCollection.js

@@ -31,5 +31,5 @@ /**

constructor() {
let sections = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
let rules = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
this.sections = sections;
this.rules = rules;
}

@@ -99,3 +99,3 @@

validate(sectionKey, argv) {
validate(argv) {
// TODO check redundant keys

@@ -105,11 +105,5 @@

if (!(sectionKey in this.sections)) {
throw new Error(`${ sectionKey } is not defined in sections.`);
}
for (const ruleKey in this.rules) {
const rule = this.rules[ruleKey];
const section = this.sections[sectionKey];
for (const ruleKey in section.rules) {
const rule = section.rules[ruleKey];
const item = {

@@ -142,3 +136,3 @@ validationErrors: [],

inquiry(sectionKey) {
inquiry() {
var _this = this;

@@ -149,11 +143,5 @@

if (!(sectionKey in _this.sections)) {
throw new Error(`${ sectionKey } is not defined in sections.`);
}
for (const ruleKey in _this.rules) {
const rule = _this.rules[ruleKey];
const section = _this.sections[sectionKey];
for (const ruleKey in section.rules) {
const rule = section.rules[ruleKey];
if (rule.uiHidden !== undefined && rule.uiHidden) {

@@ -200,16 +188,10 @@ continue;

help(sectionKey, output) {
let tabstops = arguments.length <= 2 || arguments[2] === undefined ? [0, 35] : arguments[2];
help(output) {
let tabstops = arguments.length <= 1 || arguments[1] === undefined ? [0, 35] : arguments[1];
if (!(sectionKey in this.sections)) {
throw new Error(`${ sectionKey } is not defined in sections.`);
}
const section = this.sections[sectionKey];
if (Object.keys(section.rules).length > 0) {
if (Object.keys(this.rules).length > 0) {
output.push('Parameters:');
for (const ruleKey in section.rules) {
const rule = section.rules[ruleKey];
for (const ruleKey in this.rules) {
const rule = this.rules[ruleKey];

@@ -216,0 +198,0 @@ let lineOutput = `${ ruleKey.length > 1 ? '--' : '-' }${ ruleKey }`;

@@ -19,3 +19,3 @@ {

],
"version": "0.1.5",
"version": "0.1.6",
"homepage": "",

@@ -22,0 +22,0 @@ "author": "Eser Ozvataf <eser@ozvataf.com>",

@@ -28,71 +28,65 @@ # [consultant](https://github.com/eserozvataf/consultant)

const rules = {
main: {
rules: {
makefile: {
type: String,
aliases: [ 'f' ],
label: 'Makefile',
description: 'Load tasks from FILE',
parameter: 'FILE',
'default': [ 'makefile.js' ],
uiHidden: false,
min: 0,
max: undefined,
validate: function (value) {
return value.length >= 3 || 'minimum 3 chars required';
}
},
tasks: {
type: Boolean,
aliases: [ 't' ],
label: 'Tasks',
description: 'Lists defined tasks',
'default': false,
uiHidden: true,
min: 0,
max: 1
},
verbosity: {
type: String,
label: 'Verbosity',
description: 'Sets verbosity of log messages [debug, warn, info, error]',
'default': 'info',
values: [ 'debug', 'warn', 'info', 'error' ],
uiHidden: true,
min: 0,
max: 1
},
version: {
type: Boolean,
aliases: [ 'v' ],
label: 'Version',
description: 'Displays the jsmake version',
'default': false,
uiHidden: true,
min: 0,
max: 1
},
help: {
type: Boolean,
aliases: [ 'h', '?' ],
label: 'Help',
description: 'Displays this help message',
'default': false,
uiHidden: true,
min: 0,
max: 1
}
const page = consultant.createPage('Homepage', {
makefile: {
type: String,
aliases: [ 'f' ],
label: 'Makefile',
description: 'Load tasks from FILE',
parameter: 'FILE',
'default': [ 'makefile.js' ],
uiHidden: false,
min: 0,
max: undefined,
validate: function (value) {
return value.length >= 3 || 'minimum 3 chars required';
}
},
tasks: {
type: Boolean,
aliases: [ 't' ],
label: 'Tasks',
description: 'Lists defined tasks',
'default': false,
uiHidden: true,
min: 0,
max: 1
},
verbosity: {
type: String,
label: 'Verbosity',
description: 'Sets verbosity of log messages [debug, warn, info, error]',
'default': 'info',
values: [ 'debug', 'warn', 'info', 'error' ],
uiHidden: true,
min: 0,
max: 1
},
version: {
type: Boolean,
aliases: [ 'v' ],
label: 'Version',
description: 'Displays the jsmake version',
'default': false,
uiHidden: true,
min: 0,
max: 1
},
help: {
type: Boolean,
aliases: [ 'h', '?' ],
label: 'Help',
description: 'Displays this help message',
'default': false,
uiHidden: true,
min: 0,
max: 1
}
};
});
const ruleCollection = consultant.createRuleCollection(rules);
// command line parsing
const argv = consultant.parse(process.argv.slice(2));
console.log(ruleCollection.validate('main', argv));
console.log(page.validate('main', argv));
// command line user interface
ruleCollection.inquiry('main')
page.inquiry('main')
.then((answers) => {

@@ -104,3 +98,3 @@ console.log(answers);

const help = [];
ruleCollection.help('main', help);
page.help('main', help);
console.log(help);

@@ -107,0 +101,0 @@ ```

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