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 2.0.0 to 2.0.1

examples/git_style/index.js

88

dist/index.es.js

@@ -31,2 +31,44 @@ import chalk from 'chalk';

var parseCommands = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var isConstructable = function (cmd) {
return cmd.run === undefined;
};
exports["default"] = (function (cmds) {
var returnCommands = {};
if (!(cmds instanceof Array)) {
cmds = [cmds];
}
var arr = new Array();
arr.slice.call(cmds).forEach(function (cmd) {
if (isConstructable(cmd)) {
var c = new cmd();
returnCommands[c.name] = c;
}
else {
var c = cmd;
returnCommands[c.name] = c;
}
});
return returnCommands;
});
});
unwrapExports(parseCommands);
var baseCommand = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var Base = (function () {
function Base(cmds) {
this.name = '';
this.commands = parseCommands["default"](cmds);
}
Base.prototype.run = function () {
logger["default"].error('Base Command run() should not be called directly.\n Instead extend Base in your own command');
};
return Base;
}());
exports["default"] = Base;
});
unwrapExports(baseCommand);
var helpCommand = createCommonjsModule(function (module, exports) {

@@ -83,28 +125,2 @@ exports.__esModule = true;

var parseCommands = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var isConstructable = function (cmd) {
return cmd.run === undefined;
};
exports["default"] = (function (cmds) {
var returnCommands = {};
if (!(cmds instanceof Array)) {
cmds = [cmds];
}
var arr = new Array();
arr.slice.call(cmds).forEach(function (cmd) {
if (isConstructable(cmd)) {
var c = new cmd();
returnCommands[c.name] = c;
}
else {
var c = cmd;
returnCommands[c.name] = c;
}
});
return returnCommands;
});
});
unwrapExports(parseCommands);
var version = createCommonjsModule(function (module, exports) {

@@ -139,18 +155,2 @@ exports.__esModule = true;

var baseCommand = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var Base = (function () {
function Base(cmds) {
this.name = '';
this.commands = parseCommands["default"](cmds);
}
Base.prototype.run = function () {
logger["default"].error('Base Command run() should not be called directly.\n Instead extend Base in your own command');
};
return Base;
}());
exports["default"] = Base;
});
unwrapExports(baseCommand);
var src = createCommonjsModule(function (module, exports) {

@@ -191,11 +191,9 @@ exports.__esModule = true;

};
CLI.Command = baseCommand["default"];
return CLI;
}());
exports["default"] = CLI;
exports.Command = baseCommand["default"];
});
var index = unwrapExports(src);
var src_1 = src.Command;
export default index;
export { src_1 as Command };
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

@@ -37,2 +35,44 @@

var parseCommands = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var isConstructable = function (cmd) {
return cmd.run === undefined;
};
exports["default"] = (function (cmds) {
var returnCommands = {};
if (!(cmds instanceof Array)) {
cmds = [cmds];
}
var arr = new Array();
arr.slice.call(cmds).forEach(function (cmd) {
if (isConstructable(cmd)) {
var c = new cmd();
returnCommands[c.name] = c;
}
else {
var c = cmd;
returnCommands[c.name] = c;
}
});
return returnCommands;
});
});
unwrapExports(parseCommands);
var baseCommand = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var Base = (function () {
function Base(cmds) {
this.name = '';
this.commands = parseCommands["default"](cmds);
}
Base.prototype.run = function () {
logger["default"].error('Base Command run() should not be called directly.\n Instead extend Base in your own command');
};
return Base;
}());
exports["default"] = Base;
});
unwrapExports(baseCommand);
var helpCommand = createCommonjsModule(function (module, exports) {

@@ -89,28 +129,2 @@ exports.__esModule = true;

var parseCommands = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var isConstructable = function (cmd) {
return cmd.run === undefined;
};
exports["default"] = (function (cmds) {
var returnCommands = {};
if (!(cmds instanceof Array)) {
cmds = [cmds];
}
var arr = new Array();
arr.slice.call(cmds).forEach(function (cmd) {
if (isConstructable(cmd)) {
var c = new cmd();
returnCommands[c.name] = c;
}
else {
var c = cmd;
returnCommands[c.name] = c;
}
});
return returnCommands;
});
});
unwrapExports(parseCommands);
var version = createCommonjsModule(function (module, exports) {

@@ -145,18 +159,2 @@ exports.__esModule = true;

var baseCommand = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
var Base = (function () {
function Base(cmds) {
this.name = '';
this.commands = parseCommands["default"](cmds);
}
Base.prototype.run = function () {
logger["default"].error('Base Command run() should not be called directly.\n Instead extend Base in your own command');
};
return Base;
}());
exports["default"] = Base;
});
unwrapExports(baseCommand);
var src = createCommonjsModule(function (module, exports) {

@@ -197,11 +195,9 @@ exports.__esModule = true;

};
CLI.Command = baseCommand["default"];
return CLI;
}());
exports["default"] = CLI;
exports.Command = baseCommand["default"];
});
var index = unwrapExports(src);
var src_1 = src.Command;
exports.default = index;
exports.Command = src_1;
module.exports = index;

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

import baseCommand from './baseCommand';
import { CommandArgs } from './util/parseArgs';
import { CLIOptions, Command, Commands, Constructable } from './util/parseCommands';
export default class CLI {
static Command: typeof baseCommand;
commands: Commands;

@@ -12,2 +14,1 @@ name: string;

}
export { default as Command } from './baseCommand';
{
"name": "storbi",
"description": "An opinionated CLI application framework",
"version": "2.0.0",
"version": "2.0.1",
"main": "dist/index.js",

@@ -64,7 +64,2 @@ "module": "dist/index.es.js",

"jest": {
"globals": {
"ts-jest": {
"tsConfigFile": "tsconfig.jest.json"
}
},
"transform": {

@@ -71,0 +66,0 @@ "^.+\\.tsx?$": "ts-jest"

@@ -9,12 +9,12 @@ # storbi

storbi is a framework for creating command line applications in Node. Why not commander or vorpal or insert other framework here? Well, I tried building an app with those and it just didn't feel right. So I started building my app from scratch without a framework and realized that I had built a framework in my app. A little copy and pasta and tweaking some fiddly bits and storbi was born.
storbi is an opinionated framework for creating command line applications in Node. Why not commander or vorpal or insert other framework here? Well, I tried building an app with those and it just didn't feel right. So I started building my app from scratch without a framework and realized that I had built a framework in my app. A little copy and pasta and tweaking some fiddly bits and storbi was born.
## Example
## Simple Example
```javascript
import CLI, { BaseCommand } from 'storbi'
import CLI from 'storbi'
class MyAwesomeCommand extends BaseCommand {
class MyAwesomeCommand {
constructor() {
super()
this.name = 'command'
}

@@ -33,4 +33,86 @@

```bash
$> node index.js
$> node index.js command
I do awesome CLI stuff!
```
See the [examples][examples] directory for more ways to use storbi.
## Installation
`yarn add storbi`
## CLI
The cli constructor accepts two arguments. The list of commands and options.
```javascript
const cli = new CLI([Command1, Command2], { name: 'my-tool', version: '1.0.0' })
```
If the options are not passed in the CLI constructor options, storbi will attempt to infer them from your package.json.
You may also pass a single command to the constructor in lieu of an Array.
## Commands
A Command in storbi is any JavaScript class that has a name property and a method called run.
```javascript
class Command {
constructor() {
this.name = 'command'
}
run(args) {
// Perform your command actions here
}
}
```
Command arguments are passed to your run method from the CLI in the form of:
```javascript
{ command: '', subcommand: '', rest: ['', ''], flag: value }
```
A few examples
```bash
$> node index.js command --force
# { command: command, force: true }
$> node index.js config init -r=20
# { command: 'config', subcommand: 'init', r: '20' }
$> node index.js new test.js
# { command: 'new', rest: ['test.js'] }
```
### Sub-Commands
Sub-commands are created by passing a command class to the constructor of another command class. For the sub-command to work properly the parent command class needs to extend `CLI.Command` and pass it's commands to the `Command` class.
```javascript
const CLI = require('storbi')
class New {
constructor() {
this.name = 'new'
}
run(args) {
// Do new stuff
}
}
class Config extends CLI.Command {
constructor(cmds) {
super(cmds)
this.name = 'config'
}
}
```
You would then need to create an instance of the `Config` class to pass to the CLI constructor. Note the lack of a `run` method on the `Config` class. This run method will never be called and should be omitted.
[examples]: https://github.com/janders223/storbi/tree/master/examples/
"use strict";
exports.__esModule = true;
var baseCommand_1 = require("./baseCommand");
var helpCommand_1 = require("./helpCommand");

@@ -42,6 +43,5 @@ var name_1 = require("./util/name");

};
CLI.Command = baseCommand_1["default"];
return CLI;
}());
exports["default"] = CLI;
var baseCommand_1 = require("./baseCommand");
exports.Command = baseCommand_1["default"];

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

import baseCommand from './baseCommand'
import Help from './helpCommand'

@@ -14,2 +15,4 @@ import name from './util/name'

export default class CLI {
public static Command = baseCommand
public commands: Commands

@@ -58,3 +61,1 @@ public name: string

}
export { default as Command } from './baseCommand'
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