@boost/cli
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -6,2 +6,23 @@ # Change Log | ||
## 2.3.0 - 2020-10-15 | ||
#### 🚀 Updates | ||
- Add node requirement and package outdated middleware. ([891bfb3](https://github.com/milesj/boost/commit/891bfb3)) | ||
#### 🐞 Fixes | ||
- Pipe wrapped console methods through the CLI logger. ([deb854f](https://github.com/milesj/boost/commit/deb854f)) | ||
- **[Style]** Dont apply background color unless inverted. ([ad1e429](https://github.com/milesj/boost/commit/ad1e429)) | ||
#### 📦 Dependencies | ||
- Update to latest. ([2a9e503](https://github.com/milesj/boost/commit/2a9e503)) | ||
**Note:** Version bump only for package @boost/cli | ||
## 2.2.0 - 2020-10-09 | ||
@@ -8,0 +29,0 @@ |
@@ -18,2 +18,3 @@ /** | ||
export * from './helpers'; | ||
export * from './middleware'; | ||
export * from './types'; | ||
@@ -20,0 +21,0 @@ export { Command, Failure, Header, Help, IndexHelp, Program, ProgramContext, Style, CLIError }; |
@@ -17,2 +17,4 @@ 'use strict'; | ||
var levenary = require('levenary'); | ||
var semver = require('semver'); | ||
var https = require('https'); | ||
@@ -25,2 +27,4 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } | ||
var levenary__default = /*#__PURE__*/_interopDefaultLegacy(levenary); | ||
var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver); | ||
var https__default = /*#__PURE__*/_interopDefaultLegacy(https); | ||
@@ -434,12 +438,9 @@ /* eslint-disable security/detect-unsafe-regex */ | ||
const injectColor = (color, bg) => { | ||
props[bg ? 'backgroundColor' : 'color'] = color; | ||
}; | ||
if (type === 'default') { | ||
injectColor(theme.default, inverted); | ||
injectColor(theme.inverted, !inverted); | ||
} else if (type !== 'none') { | ||
injectColor(theme[type], inverted); | ||
injectColor(theme.inverted, !inverted); | ||
if (type !== 'none') { | ||
if (inverted) { | ||
props.backgroundColor = theme[type]; | ||
props.color = theme.inverted; | ||
} else { | ||
props.color = theme[type]; | ||
} | ||
} | ||
@@ -1208,3 +1209,3 @@ | ||
/* eslint-disable no-console, @typescript-eslint/no-unsafe-assignment */ | ||
/* eslint-disable no-console */ | ||
const NOTIFY_DELAY = 100; | ||
@@ -1281,6 +1282,6 @@ const CONSOLE_METHODS = { | ||
wrap() { | ||
wrap(logger) { | ||
CONSOLE_METHODS[this.type].forEach(method => { | ||
const original = console[method]; | ||
console[method] = this.write; | ||
console[method] = logger[method]; | ||
this.unwrappers.push(() => { | ||
@@ -1371,3 +1372,5 @@ console[method] = original; | ||
const middleware = (argv, parse) => parse(argv.length > 0 && argv[0].endsWith('/node') ? argv.slice(2) : argv); | ||
function removeProcessBin() { | ||
return (argv, parse) => parse(argv.length > 0 && argv[0].endsWith('/node') ? argv.slice(2) : argv); | ||
} | ||
@@ -1392,3 +1395,3 @@ class Program extends CommandManager { | ||
this.logger = void 0; | ||
this.middlewares = [middleware]; | ||
this.middlewares = [removeProcessBin()]; | ||
this.rendering = false; | ||
@@ -1659,4 +1662,4 @@ this.sharedCategories = { | ||
try { | ||
this.errBuffer.wrap(); | ||
this.outBuffer.wrap(); | ||
this.errBuffer.wrap(this.logger); | ||
this.outBuffer.wrap(this.logger); | ||
this.onBeforeRender.emit([result]); | ||
@@ -1674,2 +1677,4 @@ this.rendering = true; | ||
experimental: true, | ||
patchConsole: false, | ||
// We do this ourselves | ||
stderr, | ||
@@ -1869,2 +1874,57 @@ stdin, | ||
function checkNodeRequirement(range, throws = false) { | ||
return (argv, parse) => { | ||
const { | ||
version | ||
} = process; | ||
if (!semver__default['default'].satisfies(version, range)) { | ||
const message = `This tool requires a Node.js version compatible with ${range}, found ${version}.`; | ||
if (throws) { | ||
throw new Error(message); | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.error(message); | ||
} | ||
} | ||
return parse(argv); | ||
}; | ||
} | ||
function fetchPackageLatestVersion(name) { | ||
return new Promise(resolve => { | ||
https__default['default'].get(`https://registry.npmjs.org/${name}`, resp => { | ||
let data = ''; | ||
resp.on('data', chunk => { | ||
data += chunk; | ||
}); | ||
resp.on('end', () => { | ||
var _pkg$distTags; | ||
const pkg = common.json.parse(data); | ||
resolve((_pkg$distTags = pkg['dist-tags']) == null ? void 0 : _pkg$distTags.latest); | ||
}); | ||
resp.on('error', () => { | ||
// Instead of failing the process, return a fake response | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
} | ||
function checkPackageOutdated(name, version) { | ||
return async (argv, parse) => { | ||
const latestVersion = await fetchPackageLatestVersion(name); | ||
if (latestVersion && !semver__default['default'].satisfies(version, `>=${latestVersion}`)) { | ||
// eslint-disable-next-line no-console | ||
console.info(`Your version of ${name} is out of date.`, `Latest version is ${latestVersion}, while you're using ${version}.`); | ||
} | ||
return parse(argv); | ||
}; | ||
} | ||
Object.defineProperty(exports, 'ArgList', { | ||
@@ -2010,2 +2070,4 @@ enumerable: true, | ||
exports.applyStyle = applyStyle; | ||
exports.checkNodeRequirement = checkNodeRequirement; | ||
exports.checkPackageOutdated = checkPackageOutdated; | ||
exports.formatCommandCall = formatCommandCall; | ||
@@ -2012,0 +2074,0 @@ exports.formatDescription = formatDescription; |
/// <reference types="node" /> | ||
import { Loggable } from '@boost/log'; | ||
import { StreamType } from './types'; | ||
@@ -18,3 +19,3 @@ declare type BufferListener = (buffer: string[]) => void; | ||
unwrap(): void; | ||
wrap(): void; | ||
wrap(logger: Loggable): void; | ||
write: (message: unknown) => void; | ||
@@ -21,0 +22,0 @@ protected writeToStream: (message: string) => void; |
import { Middleware } from '../types'; | ||
declare const middleware: Middleware; | ||
export default middleware; | ||
export default function removeProcessBin(): Middleware; | ||
//# sourceMappingURL=removeProcessBin.d.ts.map |
{ | ||
"name": "@boost/cli", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"release": "1594765247526", | ||
@@ -29,10 +29,11 @@ "description": "An interactive command line program builder, powered by React and Ink.", | ||
"@boost/args": "^2.2.1", | ||
"@boost/common": "^2.2.2", | ||
"@boost/common": "^2.3.0", | ||
"@boost/event": "^2.2.0", | ||
"@boost/internal": "^2.1.1", | ||
"@boost/log": "^2.1.2", | ||
"@boost/log": "^2.1.3", | ||
"@boost/terminal": "^2.1.0", | ||
"@boost/translate": "^2.1.2", | ||
"@boost/translate": "^2.1.3", | ||
"execa": "^4.0.3", | ||
"levenary": "^1.1.1" | ||
"levenary": "^1.1.1", | ||
"semver": "^7.3.2" | ||
}, | ||
@@ -45,5 +46,5 @@ "peerDependencies": { | ||
"ink": "^3.0.7", | ||
"react": "^16.13.1" | ||
"react": "^16.14.0" | ||
}, | ||
"gitHead": "396874e92426ba538eace9f17543f1ffee9fb956" | ||
"gitHead": "d62e9f07d8ba7d6b195a9bfdc0945eb12d0222ed" | ||
} |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Network access
Supply chain riskThis module accesses the network.
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
132340
116
2542
12
1
+ Addedsemver@^7.3.2
+ Addedsemver@7.6.3(transitive)
Updated@boost/common@^2.3.0
Updated@boost/log@^2.1.3
Updated@boost/translate@^2.1.3