Comparing version 1.1.7 to 1.1.8
@@ -5,11 +5,27 @@ /// <reference types="chalk" /> | ||
import * as moment from 'moment'; | ||
import fs = require('fs-extra'); | ||
import { IBaseOptions } from './base'; | ||
import { SpinnerAction } from './action/spinner'; | ||
import { SimpleAction } from './action/simple'; | ||
import { Errors } from './errors'; | ||
import { Prompt } from './prompt'; | ||
import { StreamOutput } from './stream'; | ||
import { TableOptions } from './table'; | ||
export declare const deps: { | ||
readonly ansiEscapes: any; | ||
readonly ansiStyles: typeof ansiStyles; | ||
readonly ansiEscapes: any; | ||
readonly chalk: typeof chalk; | ||
readonly fs: typeof fs; | ||
readonly linewrap: any; | ||
readonly moment: typeof moment; | ||
readonly passwordPrompt: any; | ||
readonly stripAnsi: (str: string) => string; | ||
readonly supportsColor: any; | ||
readonly passwordPrompt: any; | ||
readonly shouldDisplaySpinner: (options: IBaseOptions) => boolean; | ||
readonly SpinnerAction: typeof SpinnerAction; | ||
readonly SimpleAction: typeof SimpleAction; | ||
readonly Errors: typeof Errors; | ||
readonly Prompt: typeof Prompt; | ||
readonly StreamOutput: typeof StreamOutput; | ||
readonly table: (stream: StreamOutput, data: any[], inputOptions?: Partial<TableOptions>) => void; | ||
}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deps = { | ||
get ansiStyles() { | ||
return fetch('ansi-styles'); | ||
}, | ||
get ansiEscapes() { | ||
return fetch('ansi-escapes'); | ||
}, | ||
get chalk() { | ||
return fetch('chalk'); | ||
}, | ||
get linewrap() { | ||
return fetch('@heroku/linewrap'); | ||
}, | ||
get moment() { | ||
return fetch('moment'); | ||
}, | ||
get stripAnsi() { | ||
return fetch('strip-ansi'); | ||
}, | ||
get supportsColor() { | ||
return fetch('supports-color'); | ||
}, | ||
get passwordPrompt() { | ||
return fetch('password-prompt'); | ||
}, | ||
// remote | ||
get ansiEscapes() { return fetch('ansi-escapes'); }, | ||
get ansiStyles() { return fetch('ansi-styles'); }, | ||
get chalk() { return fetch('chalk'); }, | ||
get fs() { return fetch('fs-extra'); }, | ||
get linewrap() { return fetch('@heroku/linewrap'); }, | ||
get moment() { return fetch('moment'); }, | ||
get passwordPrompt() { return fetch('password-prompt'); }, | ||
get stripAnsi() { return fetch('strip-ansi'); }, | ||
get supportsColor() { return fetch('supports-color'); }, | ||
// local | ||
get shouldDisplaySpinner() { return fetch('./action/base').shouldDisplaySpinner; }, | ||
get SpinnerAction() { return fetch('./action/spinner').SpinnerAction; }, | ||
get SimpleAction() { return fetch('./action/simple').SimpleAction; }, | ||
get Errors() { return fetch('./errors').Errors; }, | ||
get Prompt() { return fetch('./prompt').Prompt; }, | ||
get StreamOutput() { return fetch('./stream').StreamOutput; }, | ||
get table() { return fetch('./table').table; }, | ||
}; | ||
@@ -29,0 +23,0 @@ const cache = {}; |
@@ -0,5 +1,5 @@ | ||
import { StreamOutput } from './stream'; | ||
import { Prompt, IPromptOptions } from './prompt'; | ||
import { Errors, IErrorOptions } from './errors'; | ||
import { ActionBase } from './action/base'; | ||
import { IErrorOptions } from './errors'; | ||
import { IPromptOptions } from './prompt'; | ||
import { StreamOutput } from './stream'; | ||
import { TableOptions } from './table'; | ||
@@ -10,11 +10,15 @@ export interface IOptions { | ||
debug?: boolean; | ||
action?: ActionBase; | ||
} | ||
export declare class CLI { | ||
readonly options: IOptions; | ||
action: ActionBase; | ||
stdout: StreamOutput; | ||
stderr: StreamOutput; | ||
constructor(options?: IOptions); | ||
private _prompt; | ||
readonly Prompt: Prompt; | ||
private _errors; | ||
private _prompt; | ||
constructor(options?: IOptions); | ||
readonly Errors: Errors; | ||
private _action; | ||
readonly action: ActionBase; | ||
prompt(name: string, options?: IPromptOptions): Promise<any>; | ||
@@ -37,3 +41,4 @@ log(data?: string, ...args: any[]): void; | ||
done(): void; | ||
private readonly _depOpts; | ||
} | ||
export declare const cli: CLI; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const base_1 = require("./action/base"); | ||
const spinner_1 = require("./action/spinner"); | ||
const simple_1 = require("./action/simple"); | ||
const errors_1 = require("./errors"); | ||
const prompt_1 = require("./prompt"); | ||
const stream_1 = require("./stream"); | ||
const deps_1 = require("./deps"); | ||
@@ -14,19 +8,30 @@ const debug = require('debug')('cli-ux'); | ||
this.options = options; | ||
this.stdout = new stream_1.StreamOutput(this.options.mock ? undefined : process.stdout); | ||
this.stderr = new stream_1.StreamOutput(this.options.mock ? undefined : process.stderr); | ||
const depOpts = { | ||
debug: options.debug || (options.debug === undefined && debug.enabled), | ||
mock: !!options.mock, | ||
stderr: this.stderr, | ||
stdout: this.stdout, | ||
}; | ||
this._errors = new errors_1.Errors(depOpts); | ||
this._prompt = new prompt_1.Prompt(depOpts); | ||
this.action = base_1.shouldDisplaySpinner(depOpts) ? new spinner_1.SpinnerAction(depOpts) : new simple_1.SimpleAction(depOpts); | ||
if (this.options.mock || !process.stderr.isTTY || !process.stdout.isTTY) | ||
this.stdout = new deps_1.deps.StreamOutput(this.options.mock ? undefined : process.stdout); | ||
this.stderr = new deps_1.deps.StreamOutput(this.options.mock ? undefined : process.stderr); | ||
if (this.options.mock) | ||
deps_1.deps.chalk.enabled = false; | ||
} | ||
get Prompt() { | ||
if (!this._prompt) { | ||
this._prompt = new deps_1.deps.Prompt(this._depOpts); | ||
} | ||
return this._prompt; | ||
} | ||
get Errors() { | ||
if (!this._errors) { | ||
this._errors = new deps_1.deps.Errors(this._depOpts); | ||
} | ||
return this._errors; | ||
} | ||
get action() { | ||
if (!this._action) { | ||
this._action = deps_1.deps.shouldDisplaySpinner(this._depOpts) | ||
? new deps_1.deps.SpinnerAction(this._depOpts) | ||
: new deps_1.deps.SimpleAction(this._depOpts); | ||
} | ||
return this._action; | ||
} | ||
prompt(name, options = {}) { | ||
return this.action.pauseAsync(() => { | ||
return this._prompt.prompt(name, options); | ||
return this.Prompt.prompt(name, options); | ||
}, deps_1.deps.chalk.cyan('?')); | ||
@@ -41,3 +46,3 @@ } | ||
this.action.pause(() => { | ||
return this._errors.warn(err, options); | ||
return this.Errors.warn(err, options); | ||
}, deps_1.deps.chalk.bold.yellow('!')); | ||
@@ -47,7 +52,7 @@ } | ||
this.action.pause(() => { | ||
return this._errors.error(err, options); | ||
return this.Errors.error(err, options); | ||
}, deps_1.deps.chalk.bold.red('!')); | ||
} | ||
exit(code = 1) { | ||
this._errors.exit(code); | ||
this.Errors.exit(code); | ||
} | ||
@@ -111,3 +116,3 @@ table(data, options) { | ||
handleUnhandleds() { | ||
this._errors.handleUnhandleds(); | ||
this.Errors.handleUnhandleds(); | ||
} | ||
@@ -120,4 +125,12 @@ /** | ||
} | ||
get _depOpts() { | ||
return { | ||
debug: this.options.debug || (this.options.debug === undefined && debug.enabled), | ||
mock: !!this.options.mock, | ||
stderr: this.stderr, | ||
stdout: this.stdout, | ||
}; | ||
} | ||
} | ||
exports.CLI = CLI; | ||
exports.cli = new CLI(); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs = require("fs-extra"); | ||
const path = require("path"); | ||
@@ -15,4 +14,4 @@ const util = require("util"); | ||
try { | ||
fs.mkdirpSync(path.dirname(logfile)); | ||
fs.appendFileSync(logfile, deps_1.deps.stripAnsi(msg)); | ||
deps_1.deps.fs.mkdirpSync(path.dirname(logfile)); | ||
deps_1.deps.fs.appendFileSync(logfile, deps_1.deps.stripAnsi(msg)); | ||
} | ||
@@ -19,0 +18,0 @@ catch (err) { |
{ | ||
"name": "cli-ux", | ||
"description": "set of CLI output utilities", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"author": "Jeff Dickey", | ||
@@ -19,3 +19,3 @@ "bugs": "https://github.com/jdxcode/cli-ux/issues", | ||
"supports-color": "^4.4.0", | ||
"ts-lodash": "^4.0.4" | ||
"ts-lodash": "^4.0.5" | ||
}, | ||
@@ -31,11 +31,12 @@ "devDependencies": { | ||
"@types/supports-color": "^3.1.0", | ||
"babel-core": "^6.26.0", | ||
"del-cli": "^1.1.0", | ||
"husky": "^0.14.3", | ||
"jest": "^21.0.2", | ||
"lint-staged": "^4.1.3", | ||
"prettier": "^1.6.1", | ||
"jest": "^21.1.0", | ||
"lint-staged": "^4.2.1", | ||
"prettier": "^1.7.0", | ||
"remap-istanbul": "^0.9.5", | ||
"rimraf": "^2.6.2", | ||
"std-mocks": "^1.0.1", | ||
"ts-jest": "^21.0.0", | ||
"ts-jest": "^21.0.1", | ||
"ts-node": "^3.3.0", | ||
@@ -42,0 +43,0 @@ "typescript": "^2.5.2" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
47552
1425
7
20
16
Updatedts-lodash@^4.0.5