New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

storbi

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

storbi - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

CODE_OF_CONDUCT.md

34

dist/index.es.js

@@ -51,2 +51,13 @@ import debug from 'debug';

var logger = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var log = console.log;
exports["default"] = {
help: function (msg) {
log(msg);
}
};
});
unwrapExports(logger);
var helpCommand = createCommonjsModule(function (module, exports) {

@@ -71,3 +82,5 @@ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {

}
Help.prototype.run = function () { };
Help.prototype.run = function (opts, commands) {
logger["default"].help("\n" + opts.name + "\n\nUsage:\n\n\t" + opts.name + " [command]\n\n\nAvailable Commands:\n\n" + commands.map(function (cmd) { return "\t" + cmd + "\n"; }).join('') + "\n\nUse " + opts.name + " [command] --help for more information about a command.");
};
return Help;

@@ -82,2 +95,3 @@ }(baseCommand["default"]));

var cliDebug = debug('storbi:cli');
var errorDebug = debug('storbi:error');
var parseCommands = function (cmds) {

@@ -92,5 +106,11 @@ var returnCommands = {};

arr.slice.call(cmds).forEach(function (CMD) {
var cmd = new CMD();
cliDebug('Constructing Command: %s', cmd.name);
returnCommands[cmd.name] = cmd;
try {
var cmd = new CMD();
cliDebug('Constructing Command: %s', cmd.name);
returnCommands[cmd.name] = cmd;
}
catch (error) {
errorDebug('ERROR %s', error);
throw new Error("\n" + CMD + " is not a constructor function.\n\nPerhaps you meant to pass in a different argument\n\t\t\t");
}
});

@@ -103,2 +123,3 @@ return returnCommands;

this.commands = parseCommands(cmds);
this.options = opts;
try {

@@ -108,3 +129,3 @@ this.name = opts.name || readPkg.sync(process.cwd()).name;

catch (error) {
cliDebug('ERROR %s', error);
errorDebug('ERROR %s', error);
throw new Error("\nUnable to set name for CLI application.\n\nThis is either because you did not pass a name option.\nOr the package.json file for your application could not be found.\n\nTry setting the name option like so:\n\nnew CLI(commands, { name: 'foo' })\n\t\t");

@@ -121,2 +142,3 @@ }

cliDebug('Attempting to run command: %s', cmd);
var commandNames = Object.keys(this.commands);
try {

@@ -129,3 +151,3 @@ var command = this.commands[cmd];

cliDebug('Did not find command %s, running help', cmd);
this.commands.defaulthelp.run();
this.commands.defaulthelp.run(this.options, commandNames);
}

@@ -132,0 +154,0 @@ };

@@ -57,2 +57,13 @@ 'use strict';

var logger = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var log = console.log;
exports["default"] = {
help: function (msg) {
log(msg);
}
};
});
unwrapExports(logger);
var helpCommand = createCommonjsModule(function (module, exports) {

@@ -77,3 +88,5 @@ var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {

}
Help.prototype.run = function () { };
Help.prototype.run = function (opts, commands) {
logger["default"].help("\n" + opts.name + "\n\nUsage:\n\n\t" + opts.name + " [command]\n\n\nAvailable Commands:\n\n" + commands.map(function (cmd) { return "\t" + cmd + "\n"; }).join('') + "\n\nUse " + opts.name + " [command] --help for more information about a command.");
};
return Help;

@@ -88,2 +101,3 @@ }(baseCommand["default"]));

var cliDebug = debug('storbi:cli');
var errorDebug = debug('storbi:error');
var parseCommands = function (cmds) {

@@ -98,5 +112,11 @@ var returnCommands = {};

arr.slice.call(cmds).forEach(function (CMD) {
var cmd = new CMD();
cliDebug('Constructing Command: %s', cmd.name);
returnCommands[cmd.name] = cmd;
try {
var cmd = new CMD();
cliDebug('Constructing Command: %s', cmd.name);
returnCommands[cmd.name] = cmd;
}
catch (error) {
errorDebug('ERROR %s', error);
throw new Error("\n" + CMD + " is not a constructor function.\n\nPerhaps you meant to pass in a different argument\n\t\t\t");
}
});

@@ -109,2 +129,3 @@ return returnCommands;

this.commands = parseCommands(cmds);
this.options = opts;
try {

@@ -114,3 +135,3 @@ this.name = opts.name || readPkg.sync(process.cwd()).name;

catch (error) {
cliDebug('ERROR %s', error);
errorDebug('ERROR %s', error);
throw new Error("\nUnable to set name for CLI application.\n\nThis is either because you did not pass a name option.\nOr the package.json file for your application could not be found.\n\nTry setting the name option like so:\n\nnew CLI(commands, { name: 'foo' })\n\t\t");

@@ -127,2 +148,3 @@ }

cliDebug('Attempting to run command: %s', cmd);
var commandNames = Object.keys(this.commands);
try {

@@ -135,3 +157,3 @@ var command = this.commands[cmd];

cliDebug('Did not find command %s, running help', cmd);
this.commands.defaulthelp.run();
this.commands.defaulthelp.run(this.options, commandNames);
}

@@ -138,0 +160,0 @@ };

3

dist/typings/helpCommand.d.ts

@@ -0,5 +1,6 @@

import { CLIOptions } from './';
import BaseCommand from './baseCommand';
export default class Help extends BaseCommand {
constructor();
run(): void;
run(opts: CLIOptions, commands: string[]): void;
}

@@ -8,3 +8,3 @@ export interface CLIOptions {

export interface Command {
run: () => void;
run: (opts?: CLIOptions, commands?: string[]) => void;
name: string;

@@ -18,2 +18,3 @@ }

name: string;
options: CLIOptions;
constructor(cmds: Constructable<Command> | Array<Constructable<Command>>, opts?: CLIOptions);

@@ -20,0 +21,0 @@ run(): void;

{
"name": "storbi",
"description": "An opinionated CLI application framework",
"version": "1.2.0",
"version": "1.3.0",
"main": "dist/index.js",

@@ -21,2 +21,3 @@ "module": "dist/index.es.js",

"scripts": {
"lint": "tslint src/**/*.ts",
"prebuild": "npx rimraf dist",

@@ -23,0 +24,0 @@ "build": "tsc src/index.ts && rollup -c && tsc -p tsconfig.types.json",

# storbi
[![npm version](https://badge.fury.io/js/storbi.svg)](https://badge.fury.io/js/storbi)
[![Build Status](https://travis-ci.org/janders223/storbi.svg?branch=master)](https://travis-ci.org/janders223/storbi)

@@ -4,0 +5,0 @@ [![Maintainability](https://api.codeclimate.com/v1/badges/b52b281f8421bc30da65/maintainability)](https://codeclimate.com/github/janders223/storbi/maintainability)

@@ -43,2 +43,6 @@ /* tslint:disable */

it('throws a polite error if the cmd is not a constructor', () => {
expect(() => {new CLI({foo: 'bar'})}).toThrow()
})
it('creates commands', () => {

@@ -45,0 +49,0 @@ const cli = new CLI(Command)

@@ -0,2 +1,4 @@

import { CLIOptions } from './'
import BaseCommand from './baseCommand'
import logger from './util/logger'

@@ -9,3 +11,11 @@ export default class Help extends BaseCommand {

public run() {}
public run(opts: CLIOptions, commands: string[]) {
logger.help(`
${opts.name}\n
Usage:\n
\t${opts.name} [command]\n\n
Available Commands:\n
${commands.map(cmd => `\t${cmd}\n`).join('')}\n
Use ${opts.name} [command] --help for more information about a command.`)
}
}

@@ -7,2 +7,3 @@ import * as debug from 'debug'

const cliDebug = debug('storbi:cli')
const errorDebug = debug('storbi:error')

@@ -18,3 +19,3 @@ export interface CLIOptions {

export interface Command {
run: () => void
run: (opts?: CLIOptions, commands?: string[]) => void
name: string

@@ -43,5 +44,14 @@ }

arr.slice.call(cmds).forEach((CMD: Constructable<Command>) => {
const cmd = new CMD()
cliDebug('Constructing Command: %s', cmd.name)
returnCommands[cmd.name] = cmd
try {
const cmd = new CMD()
cliDebug('Constructing Command: %s', cmd.name)
returnCommands[cmd.name] = cmd
} catch (error) {
errorDebug('ERROR %s', error)
throw new Error(`
${CMD} is not a constructor function.
Perhaps you meant to pass in a different argument
`)
}
})

@@ -55,2 +65,3 @@

public name: string
public options: CLIOptions

@@ -62,2 +73,3 @@ constructor(

this.commands = parseCommands(cmds)
this.options = opts

@@ -67,3 +79,3 @@ try {

} catch (error) {
cliDebug('ERROR %s', error)
errorDebug('ERROR %s', error)
throw new Error(`

@@ -93,2 +105,4 @@ Unable to set name for CLI application.

const commandNames = Object.keys(this.commands)
try {

@@ -100,3 +114,3 @@ const command = this.commands[cmd]

cliDebug('Did not find command %s, running help', cmd)
this.commands.defaulthelp.run()
this.commands.defaulthelp.run(this.options, commandNames)
}

@@ -103,0 +117,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