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

@boost/cli

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boost/cli - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

lib/Command.d.ts

@@ -58,4 +58,4 @@ import React from 'react';

*/
protected handleBeforeRegister: (subPath: string) => void;
private handleBeforeRegister;
}
//# sourceMappingURL=Command.d.ts.map

@@ -8,6 +8,8 @@ /// <reference types="node" />

protected listener?: BufferListener;
protected stream: NodeJS.WriteStream;
protected timer?: NodeJS.Timeout;
protected type: StreamType;
protected unwrappers: UnwrapHandler[];
constructor(type: StreamType);
protected wrapped: boolean;
constructor(type: StreamType, stream: NodeJS.WriteStream);
flush: () => void;

@@ -19,4 +21,5 @@ off(): void;

write: (message: string) => void;
protected writeToStream: (message: string) => void;
}
export {};
//# sourceMappingURL=LogBuffer.d.ts.map
"use strict";
/* eslint-disable no-console */
Object.defineProperty(exports, "__esModule", { value: true });
const NOTIFY_DELAY = 250;
const NOTIFY_DELAY = 150;
const CONSOLE_METHODS = {

@@ -18,5 +18,6 @@ stderr: [],

class LogBuffer {
constructor(type) {
constructor(type, stream) {
this.logs = [];
this.unwrappers = [];
this.wrapped = false;
this.flush = () => {

@@ -28,10 +29,3 @@ if (this.logs.length > 0) {

else {
this.logs.forEach(log => {
if (this.type === 'stderr') {
console.error(log);
}
else {
console.log(log);
}
});
this.logs.forEach(this.writeToStream);
}

@@ -46,5 +40,13 @@ this.logs = [];

this.write = (message) => {
// `Static` will render each item in the array as a new line,
// so trim surrounding new lines here
const msg = message.trim();
// If not wrapping the console, just output immediately
if (!this.wrapped) {
this.writeToStream(msg);
return;
}
// Static component will render each item in the array as a new line,
// so trim surrounding new lines here
this.logs.push(message.trim());
this.logs.push(msg);
// Place in a short timeout so that we can batch

@@ -55,3 +57,7 @@ if (!this.timer) {

};
this.writeToStream = (message) => {
this.stream.write(`${message}\n`);
};
this.type = type;
this.stream = stream;
}

@@ -70,2 +76,3 @@ off() {

});
this.wrapped = false;
}

@@ -80,4 +87,5 @@ wrap() {

});
this.wrapped = true;
}
}
exports.default = LogBuffer;

@@ -52,7 +52,15 @@ import React from 'react';

/**
* Run the program by parsing argv into an object of options and parameters,
* while executing the found command.
* Run the program in the following steps:
* - Apply middleware to argv list.
* - Parse argv into an args object (of options, params, etc).
* - Determine command to run, or fail.
* - Run command and render output.
* - Return exit code.
*/
run(argv: Argv): Promise<ExitCode>;
/**
* Run the program and also set the process exit code.
*/
runAndExit(argv: Argv): Promise<ExitCode>;
/**
* Render the index screen when no args are passed.

@@ -63,7 +71,2 @@ * Should include banner, header, footer, and command (if applicable).

/**
* Internal run that does all the heavy lifting and parsing,
* while the public run exists to catch any unexpected errors.
*/
protected doRun(argv: Argv): Promise<ExitCode>;
/**
* Loop through all middleware to modify the argv list

@@ -85,10 +88,15 @@ * and resulting args object.

/**
* Internal run that does all the heavy lifting and parsing,
* while the public run exists to catch any unexpected errors.
*/
protected runAndRender(argv: Argv): Promise<ExitCode>;
/**
* Deeply register all commands so that we can easily access it during parse.
*/
protected handleAfterRegister: (_path: string, command: Commandable<any, any[]>) => void;
private handleAfterRegister;
/**
* Check for default and non-default command mixing.
*/
protected handleBeforeRegister: () => void;
private handleBeforeRegister;
}
//# sourceMappingURL=Program.d.ts.map

@@ -81,4 +81,4 @@ "use strict";

Object.assign(this.streams, streams);
this.errBuffer = new LogBuffer_1.default('stderr');
this.outBuffer = new LogBuffer_1.default('stdout');
this.errBuffer = new LogBuffer_1.default('stderr', this.streams.stderr);
this.outBuffer = new LogBuffer_1.default('stdout', this.streams.stdout);
this.logger = log_1.createLogger({

@@ -155,4 +155,8 @@ // Use outBuffer until ink supports stderr

/**
* Run the program by parsing argv into an object of options and parameters,
* while executing the found command.
* Run the program in the following steps:
* - Apply middleware to argv list.
* - Parse argv into an args object (of options, params, etc).
* - Determine command to run, or fail.
* - Run command and render output.
* - Return exit code.
*/

@@ -164,3 +168,3 @@ run(argv) {

try {
exitCode = yield this.doRun(argv);
exitCode = yield this.runAndRender(argv);
this.onAfterRun.emit([]);

@@ -172,6 +176,2 @@ }

}
// istanbul ignore next
if (process.env.NODE_ENV !== 'test') {
process.exitCode = exitCode;
}
return exitCode;

@@ -181,2 +181,13 @@ });

/**
* Run the program and also set the process exit code.
*/
// istanbul ignore next
runAndExit(argv) {
return __awaiter(this, void 0, void 0, function* () {
const exitCode = yield this.run(argv);
process.exitCode = exitCode;
return exitCode;
});
}
/**
* Render the index screen when no args are passed.

@@ -190,45 +201,2 @@ * Should include banner, header, footer, and command (if applicable).

/**
* Internal run that does all the heavy lifting and parsing,
* while the public run exists to catch any unexpected errors.
*/
doRun(argv) {
return __awaiter(this, void 0, void 0, function* () {
const showVersion = argv.some(arg => arg === '-v' || arg === '--version');
const showHelp = argv.some(arg => arg === '-h' || arg === '--help');
// Display index help
if ((!this.standAlone && argv.length === 0) || (argv.length === 1 && showHelp)) {
this.onHelp.emit([]);
return this.render(this.createIndex());
}
// Display version
if (showVersion) {
return this.render(this.options.version);
}
// Parse the arguments
const { command: paths, errors, options, params, rest, unknown, } = yield this.applyMiddlewareAndParseArgs(argv);
const path = paths.join(':') || this.standAlone;
const command = this.getCommand(path);
this.onCommandFound.emit([argv, path, command]);
// Display command help
if (options.help) {
this.onHelp.emit([path]);
return this.render(command.renderHelp());
}
// Display errors
if (errors.length > 0) {
return this.renderErrors(errors);
}
// Apply arguments to command properties
Object.assign(command, options);
command.rest = rest;
command.unknown = unknown;
command.exit = this.exit;
command.log = this.logger;
command[constants_1.CACHE_OPTIONS] = options;
command[constants_1.CACHE_PARAMS] = params;
command.bootstrap();
return this.render(yield command.run(...params), constants_1.EXIT_PASS);
});
}
/**
* Loop through all middleware to modify the argv list

@@ -262,4 +230,2 @@ * and resulting args object.

if (typeof result === 'string') {
this.errBuffer.flush();
this.outBuffer.flush();
stdout.write(result);

@@ -274,2 +240,3 @@ return exitCode;

debug: process.env.NODE_ENV === 'test',
exitOnCtrlC: true,
experimental: true,

@@ -304,3 +271,46 @@ stdin,

}
/**
* Internal run that does all the heavy lifting and parsing,
* while the public run exists to catch any unexpected errors.
*/
runAndRender(argv) {
return __awaiter(this, void 0, void 0, function* () {
const showVersion = argv.some(arg => arg === '-v' || arg === '--version');
const showHelp = argv.some(arg => arg === '-h' || arg === '--help');
// Display index help
if ((!this.standAlone && argv.length === 0) || (argv.length === 1 && showHelp)) {
this.onHelp.emit([]);
return this.render(this.createIndex());
}
// Display version
if (showVersion) {
return this.render(this.options.version);
}
// Parse the arguments
const { command: paths, errors, options, params, rest, unknown, } = yield this.applyMiddlewareAndParseArgs(argv);
const path = paths.join(':') || this.standAlone;
const command = this.getCommand(path);
this.onCommandFound.emit([argv, path, command]);
// Display command help
if (options.help) {
this.onHelp.emit([path]);
return this.render(command.renderHelp());
}
// Display errors
if (errors.length > 0) {
return this.renderErrors(errors);
}
// Apply arguments to command properties
Object.assign(command, options);
command.rest = rest;
command.unknown = unknown;
command.exit = this.exit;
command.log = this.logger;
command[constants_1.CACHE_OPTIONS] = options;
command[constants_1.CACHE_PARAMS] = params;
command.bootstrap();
return this.render(yield command.run(...params), constants_1.EXIT_PASS);
});
}
}
exports.default = Program;
{
"name": "@boost/cli",
"version": "0.0.2",
"version": "0.0.3",
"description": "A type-safe and powerful command line interface, built on React and Ink.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -23,3 +23,3 @@ # Boost CLI

await program.run(process.argv);
await program.runAndExit(process.argv);
```

@@ -49,4 +49,4 @@

[args]: https://github.com/milesj/boost/tree/master/packages/args
[args]: https://www.npmjs.com/package/@boost/args
[ink]: https://github.com/vadimdemedes/ink
[react]: https://reactjs.org/

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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