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.3.0 to 1.4.0

dist/typings/util/version.d.ts

79

dist/index.es.js

@@ -40,10 +40,10 @@ import debug from 'debug';

};
var BaseCommand = (function () {
function BaseCommand() {
var Command = (function () {
function Command() {
this.args = processArgs();
cmdDebug('Processed args: %O', this.args);
}
return BaseCommand;
return Command;
}());
exports["default"] = BaseCommand;
exports["default"] = Command;
});

@@ -54,6 +54,8 @@ unwrapExports(baseCommand);

exports.__esModule = true;
var log = console.log;
exports["default"] = {
info: function (msg) {
console.log(msg);
},
help: function (msg) {
log(msg);
console.log(msg);
}

@@ -92,2 +94,43 @@ };

var version = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
exports["default"] = (function () {
var version = '0.0.0';
try {
version = readPkg.sync(process.cwd()).version;
}
catch (e) { }
return version;
});
});
unwrapExports(version);
var versionCommand = createCommonjsModule(function (module, exports) {
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
var Version = (function (_super) {
__extends(Version, _super);
function Version() {
var _this = _super.call(this) || this;
_this.name = 'versioncommand';
return _this;
}
Version.prototype.run = function () {
logger["default"].info(version["default"]());
};
return Version;
}(baseCommand["default"]));
exports["default"] = Version;
});
unwrapExports(versionCommand);
var src = createCommonjsModule(function (module, exports) {

@@ -104,12 +147,13 @@ exports.__esModule = true;

cmds.push(helpCommand["default"]);
cmds.push(versionCommand["default"]);
var arr = new Array();
arr.slice.call(cmds).forEach(function (CMD) {
arr.slice.call(cmds).forEach(function (cmd) {
try {
var cmd = new CMD();
cliDebug('Constructing Command: %s', cmd.name);
returnCommands[cmd.name] = cmd;
var c = new cmd();
cliDebug('Constructing Command: %s', c.name);
returnCommands[c.name] = c;
}
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");
throw new Error("\n" + cmd + " is not a constructor function.\n\nPerhaps you meant to pass in a different argument\n\t\t\t");
}

@@ -138,3 +182,8 @@ });

CLI.prototype.run = function () {
var cmd = minimist(process.argv.slice(2))._[0];
var args = minimist(process.argv.slice(2));
var cmd = args._[0];
var version = args.version;
if (version) {
this.commands.defaultversion.run();
}
cliDebug('Attempting to run command: %s', cmd);

@@ -155,8 +204,8 @@ var commandNames = Object.keys(this.commands);

exports["default"] = CLI;
exports.BaseCommand = baseCommand["default"];
exports.Command = baseCommand["default"];
});
var index = unwrapExports(src);
var src_1 = src.BaseCommand;
var src_1 = src.Command;
export default index;
export { src_1 as BaseCommand };
export { src_1 as Command };

@@ -46,10 +46,10 @@ 'use strict';

};
var BaseCommand = (function () {
function BaseCommand() {
var Command = (function () {
function Command() {
this.args = processArgs();
cmdDebug('Processed args: %O', this.args);
}
return BaseCommand;
return Command;
}());
exports["default"] = BaseCommand;
exports["default"] = Command;
});

@@ -60,6 +60,8 @@ unwrapExports(baseCommand);

exports.__esModule = true;
var log = console.log;
exports["default"] = {
info: function (msg) {
console.log(msg);
},
help: function (msg) {
log(msg);
console.log(msg);
}

@@ -98,2 +100,43 @@ };

var version = createCommonjsModule(function (module, exports) {
exports.__esModule = true;
exports["default"] = (function () {
var version = '0.0.0';
try {
version = readPkg.sync(process.cwd()).version;
}
catch (e) { }
return version;
});
});
unwrapExports(version);
var versionCommand = createCommonjsModule(function (module, exports) {
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.__esModule = true;
var Version = (function (_super) {
__extends(Version, _super);
function Version() {
var _this = _super.call(this) || this;
_this.name = 'versioncommand';
return _this;
}
Version.prototype.run = function () {
logger["default"].info(version["default"]());
};
return Version;
}(baseCommand["default"]));
exports["default"] = Version;
});
unwrapExports(versionCommand);
var src = createCommonjsModule(function (module, exports) {

@@ -110,12 +153,13 @@ exports.__esModule = true;

cmds.push(helpCommand["default"]);
cmds.push(versionCommand["default"]);
var arr = new Array();
arr.slice.call(cmds).forEach(function (CMD) {
arr.slice.call(cmds).forEach(function (cmd) {
try {
var cmd = new CMD();
cliDebug('Constructing Command: %s', cmd.name);
returnCommands[cmd.name] = cmd;
var c = new cmd();
cliDebug('Constructing Command: %s', c.name);
returnCommands[c.name] = c;
}
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");
throw new Error("\n" + cmd + " is not a constructor function.\n\nPerhaps you meant to pass in a different argument\n\t\t\t");
}

@@ -144,3 +188,8 @@ });

CLI.prototype.run = function () {
var cmd = minimist(process.argv.slice(2))._[0];
var args = minimist(process.argv.slice(2));
var cmd = args._[0];
var version = args.version;
if (version) {
this.commands.defaultversion.run();
}
cliDebug('Attempting to run command: %s', cmd);

@@ -161,8 +210,8 @@ var commandNames = Object.keys(this.commands);

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

2

dist/typings/baseCommand.d.ts
export interface CommandArgs {
[argName: string]: string | boolean | string[];
}
export default class BaseCommand {
export default class Command {
args: CommandArgs;

@@ -6,0 +6,0 @@ name: string;

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

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

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

@@ -13,3 +13,3 @@ name: string;

export interface Commands {
[commandName: string]: Command;
[commandName: string]: CMD;
}

@@ -20,5 +20,5 @@ export default class CLI {

options: CLIOptions;
constructor(cmds: Constructable<Command> | Array<Constructable<Command>>, opts?: CLIOptions);
constructor(cmds: Constructable<CMD> | Array<Constructable<CMD>>, opts?: CLIOptions);
run(): void;
}
export { default as BaseCommand } from './baseCommand';
export { default as Command } from './baseCommand';
declare const _default: {
info(msg: string): void;
help(msg: string): void;
};
export default _default;
{
"name": "storbi",
"description": "An opinionated CLI application framework",
"version": "1.3.0",
"version": "1.4.0",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "module": "dist/index.es.js",

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

export const run = jest.fn()
export const hrun = jest.fn()
export default jest.fn().mockImplementation(() => ({
name: 'defaulthelp',
run,
run: hrun,
}))

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

import BaseCommand from '../baseCommand'
import Command from '../baseCommand'

@@ -6,84 +6,84 @@ let subject

describe('BaseCommand', () => {
describe('new', () => {
it('sets the arguments', () => {
process.argv = ['', '', 'foo']
subject = new BaseCommand()
expect(subject.args).toEqual({ command: 'foo' })
})
describe('new', () => {
it('sets the arguments', () => {
process.argv = ['', '', 'foo']
subject = new Command()
expect(subject.args).toEqual({ command: 'foo' })
})
it('processes second argument as a second command', () => {
process.argv = ['', '', 'foo', 'bar']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
subcommand: 'bar',
})
})
it('processes second argument as a second command', () => {
process.argv = ['', '', 'foo', 'bar']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
subcommand: 'bar',
})
})
it('puts anything else in rest', () => {
process.argv = ['', '', 'foo', 'bar', 'baz', 'qux']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
subcommand: 'bar',
rest: ['baz', 'qux'],
})
})
it('puts anything else in rest', () => {
process.argv = ['', '', 'foo', 'bar', 'baz', 'qux']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
rest: ['baz', 'qux'],
subcommand: 'bar',
})
})
it('parses flags', () => {
process.argv = ['', '', 'foo', '-i']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
i: true,
})
})
it('parses flags', () => {
process.argv = ['', '', 'foo', '-i']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
i: true,
})
})
it('parses globbed flags', () => {
process.argv = ['', '', 'foo', '-id']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
i: true,
d: true,
})
})
it('parses globbed flags', () => {
process.argv = ['', '', 'foo', '-id']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
d: true,
i: true,
})
})
it('parses short flags with value', () => {
process.argv = ['', '', 'foo', '-f=file.js']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
f: 'file.js',
})
})
it('parses short flags with value', () => {
process.argv = ['', '', 'foo', '-f=file.js']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
f: 'file.js',
})
})
it('parses long flags', () => {
process.argv = ['', '', 'foo', '--force']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
force: true,
})
})
it('parses long flags', () => {
process.argv = ['', '', 'foo', '--force']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
force: true,
})
})
it('parses long flags with value', () => {
process.argv = ['', '', 'foo', '--file=file.js']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
file: 'file.js',
})
})
it('parses long flags with value', () => {
process.argv = ['', '', 'foo', '--file=file.js']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
file: 'file.js',
})
})
it('parses a mix of long and short flags', () => {
process.argv = ['', '', 'foo', '--force', '-i']
subject = new BaseCommand()
expect(subject.args).toEqual({
command: 'foo',
force: true,
i: true,
})
})
})
it('parses a mix of long and short flags', () => {
process.argv = ['', '', 'foo', '--force', '-i']
subject = new Command()
expect(subject.args).toEqual({
command: 'foo',
force: true,
i: true,
})
})
})
})
/* tslint:disable */
import CLI, { Command } from '../'
import Help, { run } from '../helpCommand'
import Help, { hrun } from '../helpCommand'
import Version, { vrun} from '../versionCommand'
import * as path from 'path'
jest.mock('../helpCommand')
jest.mock('../versionCommand')

@@ -22,3 +24,5 @@ const Command = jest.fn().mockImplementation(() => ({

Help.mockClear()
run.mockClear()
Version.mockClear()
hrun.mockClear()
vrun.mockClear()
})

@@ -82,3 +86,3 @@

expect(cli.commands.command.run).not.toHaveBeenCalled()
expect(run).toHaveBeenCalled()
expect(hrun).toHaveBeenCalled()
})

@@ -91,3 +95,3 @@

expect(cli.commands.command.run).not.toHaveBeenCalled()
expect(run).toHaveBeenCalled()
expect(hrun).toHaveBeenCalled()
})

@@ -100,3 +104,3 @@

expect(cli.commands.command.run).not.toHaveBeenCalled()
expect(run).toHaveBeenCalled()
expect(hrun).toHaveBeenCalled()
})

@@ -109,5 +113,13 @@

expect(cli.commands.command.run).not.toHaveBeenCalled()
expect(run).toHaveBeenCalled()
expect(hrun).toHaveBeenCalled()
})
it('calls version with the --version flag', () => {
process.argv = ['', '', '--version']
const cli = new CLI(Command)
cli.run()
expect(cli.commands.command.run).not.toHaveBeenCalled()
expect(vrun).toHaveBeenCalled()
})
})
})

@@ -28,9 +28,9 @@ "use strict";

};
var BaseCommand = /** @class */ (function () {
function BaseCommand() {
var Command = /** @class */ (function () {
function Command() {
this.args = processArgs();
cmdDebug('Processed args: %O', this.args);
}
return BaseCommand;
return Command;
}());
exports["default"] = BaseCommand;
exports["default"] = Command;

@@ -30,3 +30,3 @@ import * as debug from 'debug'

export default class BaseCommand {
export default class Command {
public args: CommandArgs

@@ -33,0 +33,0 @@ public name: string

import { CLIOptions } from './'
import BaseCommand from './baseCommand'
import Command from './baseCommand'
import logger from './util/logger'
export default class Help extends BaseCommand {
export default class Help extends Command {
constructor() {

@@ -7,0 +7,0 @@ super()

@@ -7,2 +7,3 @@ "use strict";

var helpCommand_1 = require("./helpCommand");
var versionCommand_1 = require("./versionCommand");
var cliDebug = debug('storbi:cli');

@@ -17,12 +18,13 @@ var errorDebug = debug('storbi:error');

cmds.push(helpCommand_1["default"]);
cmds.push(versionCommand_1["default"]);
var arr = new Array();
arr.slice.call(cmds).forEach(function (CMD) {
arr.slice.call(cmds).forEach(function (cmd) {
try {
var cmd = new CMD();
cliDebug('Constructing Command: %s', cmd.name);
returnCommands[cmd.name] = cmd;
var c = new cmd();
cliDebug('Constructing Command: %s', c.name);
returnCommands[c.name] = c;
}
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");
throw new Error("\n" + cmd + " is not a constructor function.\n\nPerhaps you meant to pass in a different argument\n\t\t\t");
}

@@ -51,3 +53,8 @@ });

CLI.prototype.run = function () {
var cmd = minimist(process.argv.slice(2))._[0];
var args = minimist(process.argv.slice(2));
var cmd = args._[0];
var version = args.version;
if (version) {
this.commands.defaultversion.run();
}
cliDebug('Attempting to run command: %s', cmd);

@@ -69,2 +76,2 @@ var commandNames = Object.keys(this.commands);

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

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

import Help from './helpCommand'
import Version from './versionCommand'

@@ -18,3 +19,3 @@ const cliDebug = debug('storbi:cli')

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

@@ -25,7 +26,7 @@ name: string

export interface Commands {
[commandName: string]: Command
[commandName: string]: CMD
}
const parseCommands = (
cmds: Constructable<Command> | Array<Constructable<Command>>
cmds: Constructable<CMD> | Array<Constructable<CMD>>
): Commands => {

@@ -41,14 +42,15 @@ const returnCommands: Commands = {}

cmds.push(Help)
cmds.push(Version)
const arr = new Array()
arr.slice.call(cmds).forEach((CMD: Constructable<Command>) => {
arr.slice.call(cmds).forEach((cmd: Constructable<CMD>) => {
try {
const cmd = new CMD()
cliDebug('Constructing Command: %s', cmd.name)
returnCommands[cmd.name] = cmd
const c = new cmd()
cliDebug('Constructing Command: %s', c.name)
returnCommands[c.name] = c
} catch (error) {
errorDebug('ERROR %s', error)
throw new Error(`
${CMD} is not a constructor function.
${cmd} is not a constructor function.

@@ -69,3 +71,3 @@ Perhaps you meant to pass in a different argument

constructor(
cmds: Constructable<Command> | Array<Constructable<Command>>,
cmds: Constructable<CMD> | Array<Constructable<CMD>>,
opts: CLIOptions = {}

@@ -100,4 +102,10 @@ ) {

public run() {
const cmd = minimist(process.argv.slice(2))._[0]
const args = minimist(process.argv.slice(2))
const cmd = args._[0]
const { version } = args
if (version) {
this.commands.defaultversion.run()
}
cliDebug('Attempting to run command: %s', cmd)

@@ -118,2 +126,2 @@

export { default as BaseCommand } from './baseCommand'
export { default as Command } from './baseCommand'

@@ -1,7 +0,10 @@

const { log } = console
/* tslint:disable no-console */
export default {
info(msg: string) {
console.log(msg)
},
help(msg: string) {
log(msg)
console.log(msg)
},
}
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