diff --git a/doc/cli/npm-mp.md b/doc/cli/npm-mp.md new file mode 100644 index 0000000000000..99196f5a17cc6 --- /dev/null +++ b/doc/cli/npm-mp.md @@ -0,0 +1,55 @@ +npm-mp(1) -- Find and install required packages in a file or directory +====================================================================== + +## SYNOPSIS + + npm mp + npm mp + + common options: [i|install|c|check] + +## DESCRIPTION + +Missing-packages (mp) is a tool you will love to use whenever +you create a NodeJS package or work in team. It is used to check that all packages +used in a file or directory are well installed in the 'node_modules' directory. + +The packages to install are read in from prompts. + +It can be used when passing a folder from one person to another +and automatically detect what dependencies are required for the files in the folder +to work properly. + +## CONFIGURATION + +### check + +Default: none + +`check` is used whenever the purpose is only to know what dependency should be installed. + +e.g. + ``` + npm mp check ./folder1 + ``` + +### install + +Default: true + +`install` is used whenever the purpose is to install all dependencies used in +a file or folder that are missing in the `package.json`. + +e.g. + ``` + npm mp i ./file42.js + ``` + +## SEE ALSO + +* npm-registry(7) +* npm-config(1) +* npm-config(7) +* npmrc(5) +* npm-owner(1) +* npm-whoami(1) diff --git a/lib/config/cmd-list.js b/lib/config/cmd-list.js index 2069b5ea33ec7..8317eaff2dc72 100644 --- a/lib/config/cmd-list.js +++ b/lib/config/cmd-list.js @@ -60,6 +60,7 @@ var cmdList = [ 'config', 'set', 'get', + 'mp', 'update', 'outdated', 'prune', diff --git a/lib/mp.js b/lib/mp.js new file mode 100644 index 0000000000000..77a6320e57305 --- /dev/null +++ b/lib/mp.js @@ -0,0 +1,228 @@ + +/* + * mp - missing packages + * + * Shows what packages do not appear as dependencies in package.json + * within a file or a folder (multiple files) and prompts the user + * to install those relevant + */ + +module.exports = mp + +const usage = require("./utils/usage") +const output = require("./utils/output.js") +const log = require("npmlog") +const uniq = require("lodash.uniq") +const fs = require("graceful-fs") +const Bluebird = require("bluebird") +const readAsync = Bluebird.promisify(require("read")) +const npmInstall = require("./install") + +mp.usage = usage( + "mp", + "\nnpm mp " + + "\nnpm mp install " + + "npm mp i " + + "\nnpm mp check " + + "\nnpm mp c " +) + +function mp(args, cb) { + const firstParam = args.shift() + const secondParam = args.shift() + const packagesInstalled = getPackagesInstalled(cb) + + if ((firstParam === "i" || firstParam === "install") && fs.existsSync(`${process.cwd()}/${secondParam}`)) { + const filePath = `${process.cwd()}/${secondParam}` + const packagesToInstall = check(filePath) + + installPackages(packagesToInstall, packagesInstalled, cb) + } else if (firstParam === "c" || firstParam === "check" && fs.existsSync(`${process.cwd()}/${secondParam}`)) { + const filePath = `${process.cwd()}/${secondParam}` + const packagesToInstall = check(filePath) + + displayPackages(packagesToInstall, packagesInstalled, cb) + } else if (fs.existsSync(`${process.cwd()}/${firstParam}`)) { + const filePath = `${process.cwd()}/${firstParam}` + const packagesToInstall = check(filePath) + + installPackages(packagesToInstall, packagesInstalled, cb) + } else { + misuse(cb) + } +} + +// Installs packages +function installPackagesString(packagesString, cb) { + npmInstall([packagesString], (err) => { + output(" ✅ Packages installed !") + cb() + }) +} + +function installFromQuestions(toInstallQuestions, cpt, cb) { + readAnswer(toInstallQuestions[cpt].message, toInstallQuestions[cpt].answer).then((answer) => { + toInstallQuestions[cpt].answer = answer + + if(cpt === toInstallQuestions.length-1) { + cb(toInstallQuestions) + } else { + cpt++ + return installFromQuestions(toInstallQuestions, cpt, cb) + } + }) +} + +// Prompts the user before installing missing packages +function installPackages(packages, installed, cb) { + const toInstallQuestions = packages + .filter((pack) => !installed.includes(pack)) + .map((pack) => { + return { + message: `Install package \x1b[32m${pack}\x1b[0m ? (y/n)`, + answer: null, + name: pack, + } + }) + + let initialCpt = 0 + + installFromQuestions(toInstallQuestions, initialCpt, (packagesToInstall) => { + const mappedPackages = packagesToInstall + .filter(({ answer }) => answer === "y") + .map(package => package.name) + + installPackagesString(mappedPackages.join(" "), cb) + }) +} + +// Compare packages given in parameters and shows those to install +function displayPackages(packagesToShow, installed, cb) { + const display = packagesToShow + .filter((pack) => !installed.includes(pack)) + + const message = display.length ? + ` ⚡️ Package(s) to install: ${display.toString()}` : " ❌ No package to install" + + output(message) + cb() +} + +// Checks a file before deciding weither to install or display +function checkFile(filePath, knownPackages) { + const file = fs.readFileSync(filePath, "utf8") + const packages = extractPackagesToInstall(file) + + if (packages) { + packages.forEach((pack) => { + if (!knownPackages.includes(pack)) { + knownPackages.push(pack) + } + }) + } + + return packages +} + +function checkDirectoryRecursive(path, knownPackages) { + let localPackages = [] + + fs.readdirSync(path).forEach((file) => { + const filePath = `${path}/${file}` + + if (fs.lstatSync(filePath).isDirectory() + && file !== "node_modules") { + localPackages = localPackages.concat(checkDirectoryRecursive(`${path}/${file}`, knownPackages)) + } else if (file.match(/\.js/gu) && !file.match(/\.json/gu)) { + localPackages = localPackages.concat(checkFile(filePath, knownPackages)) + } + }) + + knownPackages = knownPackages.concat(localPackages) + + return uniq(knownPackages) +} + +// Checks all for packages in file(s) +function check(path) { + let packages = [] + const isDir = fs.lstatSync(path).isDirectory() + + // Passing an empty array to initiate recursivity or search one file + packages = isDir ? checkDirectoryRecursive(path, packages) : checkFile(path, packages) + + return packages +} + +function getPackageJsonRecursive(packagePath, cpt) { + try { + const file = fs.readFileSync(`${process.cwd()}/${packagePath}`, "utf8") + + return file + } catch (err) { + cpt++ + // Loop recursively only 5 times then abort + if (cpt < 5) { + return getPackageJsonRecursive(`../${packagePath}`, cpt) + } + + return null + } +} + +// Tries to find a package.json +function getPackageJson() { + let cpt = 0 + const packageJson = getPackageJsonRecursive("package.json", cpt) + + return packageJson +} + +function getPackagesInstalled(cb) { + const packageJson = getPackageJson() + + if (!packageJson) { + cb(new Error(" ❌ No package.json found")) + } + + const installedPackagesObject = JSON.parse(packageJson).dependencies || {} + const installedPackagesArray = Object.keys(installedPackagesObject) + + return installedPackagesArray +} + +// Finds all packages to install in a file +function extractPackagesToInstall(fileContent) { + const packages = fileContent.match(/require\(["'][A-Za-z0-9_-]+['"]\)/giu) + + if (!packages) { + return [] + } + + // removes "require(" and ")" + const mappedPackages = packages.map((pack) => pack.substr(9, pack.length - 11)) + + return mappedPackages +} + +function misuse(cb) { + cb(`Usage: \n${mp.usage}`); +} + +function read (opts) { + return Bluebird.try(() => { + log.clearProgress() + return readAsync(opts) + }).finally(() => { + log.showProgress() + }) +} + +function readAnswer (msg, answer, opts, isRetry) { + if (isRetry && (answer === "y" || answer === "n")) { + return Promise.resolve(answer.trim()) + } + + return read({prompt: msg, default: answer ? `Entered: ${answer}` : ''}) + .then((answer) => readAnswer(msg, answer, opts, true)) +} \ No newline at end of file diff --git a/node_modules/npm-audit-report/CHANGELOG.md b/node_modules/npm-audit-report/CHANGELOG.md index 428659ba0d6ed..941a18741b600 100644 --- a/node_modules/npm-audit-report/CHANGELOG.md +++ b/node_modules/npm-audit-report/CHANGELOG.md @@ -2,6 +2,40 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. + +## [1.3.2](https://github.com/npm/npm-audit-report/compare/v1.3.1...v1.3.2) (2018-12-18) + + +### Bug Fixes + +* **parseable:** add support for critical vulns and more resolves on update/install action ([#28](https://github.com/npm/npm-audit-report/issues/28)) ([5e27893](https://github.com/npm/npm-audit-report/commit/5e27893)) +* **security:** audit fix ([ff9faf3](https://github.com/npm/npm-audit-report/commit/ff9faf3)) +* **urls:** Replace hardcoded URL to advisory with a URL from audit response ([#34](https://github.com/npm/npm-audit-report/issues/34)) ([e2fe95b](https://github.com/npm/npm-audit-report/commit/e2fe95b)) + + + + +## [1.3.1](https://github.com/npm/npm-audit-report/compare/v1.3.0...v1.3.1) (2018-07-10) + + + + +# [1.3.0](https://github.com/npm/npm-audit-report/compare/v1.2.1...v1.3.0) (2018-07-09) + + +### Bug Fixes + +* **deps:** remove object.values dependency ([2c5374a](https://github.com/npm/npm-audit-report/commit/2c5374a)) +* **detail:** Fix info-level severity ([#18](https://github.com/npm/npm-audit-report/issues/18)) ([807db5a](https://github.com/npm/npm-audit-report/commit/807db5a)) +* **tests:** a test should not cause side-effects in other tests ([#23](https://github.com/npm/npm-audit-report/issues/23)) ([a94449f](https://github.com/npm/npm-audit-report/commit/a94449f)) + + +### Features + +* **output:** add `parseable` tabular output format support ([#21](https://github.com/npm/npm-audit-report/issues/21)) ([1c9aaf4](https://github.com/npm/npm-audit-report/commit/1c9aaf4)) + + + ## [1.2.1](https://github.com/npm/npm-audit-report/compare/v1.2.0...v1.2.1) (2018-05-17) diff --git a/node_modules/npm-audit-report/README.md b/node_modules/npm-audit-report/README.md index 69a9c28e89131..1d1697f4f5205 100644 --- a/node_modules/npm-audit-report/README.md +++ b/node_modules/npm-audit-report/README.md @@ -20,6 +20,9 @@ The response is an object that contains an output string (the report) and a sugg ``` 'use strict' const Report = require('npm-audit-report') +const options = { + reporter: 'json' +} Report(response, options, (result) => { console.log(result.report) @@ -30,16 +33,8 @@ Report(response, options, (result) => { ## options -reporter: - specify which output format you want to use (install, detail, json) - -withColor: - true || false indicates if some report elements should use colors or not - -withUnicode: - true || false indicates if unicode characters should be used or not. - - - - - +| option | values | default | description | +| :--- | :--- | :--- |:--- | +| reporter     | `install`, `detail`, `json`, `quiet` | `install` | specify which output format you want to use | +| withColor     | `true`, `false`   | `true`   | indicates if some report elements should use colors | +| withUnicode   | `true`, `false`                  | `true` | indicates if unicode characters should be used| \ No newline at end of file diff --git a/node_modules/npm-audit-report/index.js b/node_modules/npm-audit-report/index.js index 2e0f21abb783f..4f9f5d677b9b0 100644 --- a/node_modules/npm-audit-report/index.js +++ b/node_modules/npm-audit-report/index.js @@ -2,6 +2,7 @@ const reporters = { install: require('./reporters/install'), + parseable: require('./reporters/parseable'), detail: require('./reporters/detail'), json: require('./reporters/json'), quiet: require('./reporters/quiet') @@ -15,7 +16,7 @@ const report = function (data, options) { } const config = Object.assign({}, defaults, options) - return new Promise((resolve, reject) => { + return new Promise((resolve) => { const result = reporters[config.reporter](data, config) return resolve(result) }) diff --git a/node_modules/npm-audit-report/lib/utils.js b/node_modules/npm-audit-report/lib/utils.js index 069ebac8a0917..3b521a5f3bd96 100644 --- a/node_modules/npm-audit-report/lib/utils.js +++ b/node_modules/npm-audit-report/lib/utils.js @@ -2,6 +2,8 @@ exports.severityLabel = severityLabel exports.color = color +exports.totalVulnCount = totalVulnCount +exports.severities = severities const ccs = require('console-control-strings') @@ -21,6 +23,10 @@ const severityColors = { low: { color: 'bold', label: 'Low' + }, + info: { + color: '', + label: 'Info' } } @@ -29,7 +35,26 @@ function color (value, colorName, withColor) { } function severityLabel (sev, withColor, bold) { + if (!(sev in severityColors)) return sev.charAt(0).toUpperCase() + sev.substr(1).toLowerCase() let colorName = severityColors[sev].color if (bold) colorName = [colorName, 'bold'] return color(severityColors[sev].label, colorName, withColor) } + +function totalVulnCount (vulns) { + return Object.keys(vulns).reduce((accumulator, key) => { + const vulnCount = vulns[key] + accumulator += vulnCount + + return accumulator + }, 0) +} + +function severities (vulns) { + return Object.keys(vulns).reduce((accumulator, severity) => { + const vulnCount = vulns[severity] + if (vulnCount > 0) accumulator.push([severity, vulnCount]) + + return accumulator + }, []) +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/CHANGELOG.md b/node_modules/npm-audit-report/node_modules/cli-table3/CHANGELOG.md new file mode 100644 index 0000000000000..3f6ba35f8393e --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/CHANGELOG.md @@ -0,0 +1,56 @@ +# Changelog + +## v0.5.1 (2018-07-19) + +#### :rocket: Enhancement +* [#21](https://github.com/cli-table/cli-table3/pull/21) Import type definition from `@types/cli-table2` ([@Turbo87](https://github.com/Turbo87)) + +#### Committers: 1 +- Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) + + +## v0.5.0 (2018-06-11) + +#### :boom: Breaking Change +* [#2](https://github.com/cli-table/cli-table3/pull/2) Update Node version requirements. ([@Turbo87](https://github.com/Turbo87)) + +#### :memo: Documentation +* [#11](https://github.com/cli-table/cli-table3/pull/11) Update Documentation. ([@Turbo87](https://github.com/Turbo87)) + +#### :house: Internal +* [#16](https://github.com/cli-table/cli-table3/pull/16) Replace `kind-of` dependency with `typeof` and `Array.isArray()`. ([@Turbo87](https://github.com/Turbo87)) +* [#15](https://github.com/cli-table/cli-table3/pull/15) Remove Gulp. ([@Turbo87](https://github.com/Turbo87)) +* [#13](https://github.com/cli-table/cli-table3/pull/13) Use ES6 class syntax and `let/const`. ([@Turbo87](https://github.com/Turbo87)) +* [#12](https://github.com/cli-table/cli-table3/pull/12) Add ESLint and Prettier. ([@Turbo87](https://github.com/Turbo87)) +* [#10](https://github.com/cli-table/cli-table3/pull/10) chore: use yarn cache. ([@DanielRuf](https://github.com/DanielRuf)) +* [#9](https://github.com/cli-table/cli-table3/pull/9) Use Jest for testing. ([@Turbo87](https://github.com/Turbo87)) +* [#3](https://github.com/cli-table/cli-table3/pull/3) Add `yarn.lock` file. ([@Turbo87](https://github.com/Turbo87)) +* [#1](https://github.com/cli-table/cli-table3/pull/1) Skip broken test. ([@Turbo87](https://github.com/Turbo87)) + +#### Committers: 2 +- Daniel Ruf ([DanielRuf](https://github.com/DanielRuf)) +- Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) + + +## v0.4.0 (2018-06-10) + +First official release as `cli-table3`. Changes compares to `cli-table2` v0.2.0: + +#### :rocket: Enhancement +* [#27](https://github.com/jamestalmage/cli-table2/pull/27) Remove "lodash" dependency. ([@Turbo87](https://github.com/Turbo87)) + +#### :bug: Bug Fix +* [#29](https://github.com/jamestalmage/cli-table2/pull/29) Fix wordWrap with colSpan. ([@mmurphy](https://github.com/mmurphy)) +* [#24](https://github.com/jamestalmage/cli-table2/pull/24) Fixing the runtime error when content is truncated. ([@sthadeshwar](https://github.com/sthadeshwar)) + +#### :memo: Documentation +* [#41](https://github.com/jamestalmage/cli-table2/pull/41) Create LICENSE. ([@GantMan](https://github.com/GantMan)) + +#### :house: Internal +* [#26](https://github.com/jamestalmage/cli-table2/pull/26) package.json: Whitelist JS files ([@Turbo87](https://github.com/Turbo87)) + +#### Committers: 4 +- Gant Laborde ([GantMan](https://github.com/GantMan)) +- Martin Murphy ([mmurphy](https://github.com/mmurphy)) +- Satyajit Thadeshwar ([sthadeshwar](https://github.com/sthadeshwar)) +- Tobias Bieniek ([Turbo87](https://github.com/Turbo87)) diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/LICENSE b/node_modules/npm-audit-report/node_modules/cli-table3/LICENSE new file mode 100644 index 0000000000000..a09b7de012ac8 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2014 James Talmage + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/README.md b/node_modules/npm-audit-report/node_modules/cli-table3/README.md new file mode 100644 index 0000000000000..693b544821728 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/README.md @@ -0,0 +1,218 @@ +cli-table3 +=============================================================================== + +[![npm version](https://img.shields.io/npm/v/cli-table3.svg)](https://www.npmjs.com/package/cli-table3) +[![Build Status](https://travis-ci.com/cli-table/cli-table3.svg?branch=master)](https://travis-ci.com/cli-table/cli-table3) + +This utility allows you to render unicode-aided tables on the command line from +your node.js scripts. + +`cli-table3` is based on (and api compatible with) the original [cli-table](https://github.com/Automattic/cli-table), +and [cli-table2](https://github.com/jamestalmage/cli-table2), which are both +unmaintained. `cli-table3` includes all the additional features from +`cli-table2`. + +![Screenshot](http://i.imgur.com/sYq4T.png) + +## Features not in the original cli-table + +- Ability to make cells span columns and/or rows. +- Ability to set custom styles per cell (border characters/colors, padding, etc). +- Vertical alignment (top, bottom, center). +- Automatic word wrapping. +- More robust truncation of cell text that contains ansi color characters. +- Better handling of text color that spans multiple lines. +- API compatible with the original cli-table. +- Exhaustive test suite including the entire original cli-table test suite. +- Lots of examples auto-generated from the tests ([basic](https://github.com/cli-table/cli-table3/blob/master/basic-usage.md), [advanced](https://github.com/cli-table/cli-table3/blob/master/advanced-usage.md)). + +## Features + +- Customizable characters that constitute the table. +- Color/background styling in the header through + [colors.js](http://github.com/marak/colors.js) +- Column width customization +- Text truncation based on predefined widths +- Text alignment (left, right, center) +- Padding (left, right) +- Easy-to-use API + +## Installation + +```bash +npm install cli-table3 +``` + +## How to use + +A portion of the unit test suite is used to generate examples: +- [basic-usage](https://github.com/cli-table/cli-table3/blob/master/basic-usage.md) - covers basic uses. +- [advanced](https://github.com/cli-table/cli-table3/blob/master/advanced-usage.md) - covers using the new column and row span features. + +This package is api compatible with the original [cli-table](https://github.com/Automattic/cli-table). +So all the original documentation still applies (copied below). + +### Horizontal Tables +```javascript +var Table = require('cli-table3'); + +// instantiate +var table = new Table({ + head: ['TH 1 label', 'TH 2 label'] + , colWidths: [100, 200] +}); + +// table is an Array, so you can `push`, `unshift`, `splice` and friends +table.push( + ['First value', 'Second value'] + , ['First value', 'Second value'] +); + +console.log(table.toString()); +``` + +### Vertical Tables +```javascript +var Table = require('cli-table3'); +var table = new Table(); + +table.push( + { 'Some key': 'Some value' } + , { 'Another key': 'Another value' } +); + +console.log(table.toString()); +``` +### Cross Tables +Cross tables are very similar to vertical tables, with two key differences: + +1. They require a `head` setting when instantiated that has an empty string as the first header +2. The individual rows take the general form of { "Header": ["Row", "Values"] } + +```javascript +var Table = require('cli-table3'); +var table = new Table({ head: ["", "Top Header 1", "Top Header 2"] }); + +table.push( + { 'Left Header 1': ['Value Row 1 Col 1', 'Value Row 1 Col 2'] } + , { 'Left Header 2': ['Value Row 2 Col 1', 'Value Row 2 Col 2'] } +); + +console.log(table.toString()); +``` + +### Custom styles +The ```chars``` property controls how the table is drawn: +```javascript +var table = new Table({ + chars: { 'top': '═' , 'top-mid': '╤' , 'top-left': '╔' , 'top-right': '╗' + , 'bottom': '═' , 'bottom-mid': '╧' , 'bottom-left': '╚' , 'bottom-right': '╝' + , 'left': '║' , 'left-mid': '╟' , 'mid': '─' , 'mid-mid': '┼' + , 'right': '║' , 'right-mid': '╢' , 'middle': '│' } +}); + +table.push( + ['foo', 'bar', 'baz'] + , ['frob', 'bar', 'quuz'] +); + +console.log(table.toString()); +// Outputs: +// +//╔══════╤═════╤══════╗ +//║ foo │ bar │ baz ║ +//╟──────┼─────┼──────╢ +//║ frob │ bar │ quuz ║ +//╚══════╧═════╧══════╝ +``` + +Empty decoration lines will be skipped, to avoid vertical separator rows just +set the 'mid', 'left-mid', 'mid-mid', 'right-mid' to the empty string: +```javascript +var table = new Table({ chars: {'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': ''} }); +table.push( + ['foo', 'bar', 'baz'] + , ['frobnicate', 'bar', 'quuz'] +); + +console.log(table.toString()); +// Outputs: (note the lack of the horizontal line between rows) +//┌────────────┬─────┬──────┐ +//│ foo │ bar │ baz │ +//│ frobnicate │ bar │ quuz │ +//└────────────┴─────┴──────┘ +``` + +By setting all chars to empty with the exception of 'middle' being set to a +single space and by setting padding to zero, it's possible to get the most +compact layout with no decorations: +```javascript +var table = new Table({ + chars: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '' + , 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '' + , 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '' + , 'right': '' , 'right-mid': '' , 'middle': ' ' }, + style: { 'padding-left': 0, 'padding-right': 0 } +}); + +table.push( + ['foo', 'bar', 'baz'] + , ['frobnicate', 'bar', 'quuz'] +); + +console.log(table.toString()); +// Outputs: +//foo bar baz +//frobnicate bar quuz +``` + +## Build Targets + +Clone the repository and run `yarn install` to install all its submodules, then run one of the following commands: + +###### Run the tests with coverage reports. +```bash +$ yarn test:coverage +``` + +###### Run the tests every time a file changes. +```bash +$ yarn test:watch +``` + +###### Update the documentation. +```bash +$ yarn docs +``` + +## Credits + +- James Talmage - author <james.talmage@jrtechnical.com> ([jamestalmage](http://github.com/jamestalmage)) +- Guillermo Rauch - author of the original cli-table <guillermo@learnboost.com> ([Guille](http://github.com/guille)) + +## License + +(The MIT License) + +Copyright (c) 2014 James Talmage <james.talmage@jrtechnical.com> + +Original cli-table code/documentation: Copyright (c) 2010 LearnBoost <dev@learnboost.com> + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/index.d.ts b/node_modules/npm-audit-report/node_modules/cli-table3/index.d.ts new file mode 100644 index 0000000000000..bdf17e270ea84 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/index.d.ts @@ -0,0 +1,95 @@ +declare namespace CliTable3 { + type CharName = + "top" | + "top-mid" | + "top-left" | + "top-right" | + "bottom" | + "bottom-mid" | + "bottom-left" | + "bottom-right" | + "left" | + "left-mid" | + "mid" | + "mid-mid" | + "right" | + "right-mid" | + "middle"; + + type HorizontalAlignment = "left" | "center" | "right"; + type VerticalAlignment = "top" | "center" | "bottom"; + + interface TableOptions { + truncate: string; + colWidths: Array; + rowHeights: Array; + colAligns: HorizontalAlignment[]; + rowAligns: VerticalAlignment[]; + head: string[]; + wordWrap: boolean; + } + + interface TableInstanceOptions extends TableOptions { + chars: Record; + style: { + "padding-left": number; + "padding-right": number; + head: string[]; + border: string[]; + compact: boolean; + }; + } + + interface TableConstructorOptions extends Partial { + chars?: Partial>; + style?: Partial; + } + + type CellValue = boolean | number | string | null | undefined; + + interface CellOptions { + content: CellValue; + chars?: Partial>; + truncate?: string; + colSpan?: number; + rowSpan?: number; + hAlign?: HorizontalAlignment; + vAlign?: VerticalAlignment; + style?: { + "padding-left"?: number; + "padding-right"?: number; + head?: string[]; + border?: string[]; + }; + } + + interface GenericTable extends Array { + options: TableInstanceOptions; + readonly width: number; + } + + type Table = HorizontalTable | VerticalTable | CrossTable; + type Cell = CellValue | CellOptions; + + type HorizontalTable = GenericTable; + type HorizontalTableRow = Cell[]; + + type VerticalTable = GenericTable; + interface VerticalTableRow { + [name: string]: Cell; + } + + type CrossTable = GenericTable; + interface CrossTableRow { + [name: string]: Cell[]; + } +} + +interface CliTable3 { + new (options?: CliTable3.TableConstructorOptions): CliTable3.Table; + readonly prototype: CliTable3.Table; +} + +declare const CliTable3: CliTable3; + +export = CliTable3; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/index.js b/node_modules/npm-audit-report/node_modules/cli-table3/index.js new file mode 100644 index 0000000000000..b49d920dd3ef6 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/index.js @@ -0,0 +1 @@ +module.exports = require('./src/table'); \ No newline at end of file diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/LICENSE b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/LICENSE new file mode 100644 index 0000000000000..17880ff02972b --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/LICENSE @@ -0,0 +1,25 @@ +MIT License + +Original Library + - Copyright (c) Marak Squires + +Additional Functionality + - Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/README.md b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/README.md new file mode 100644 index 0000000000000..4bebb6c92b073 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/README.md @@ -0,0 +1,184 @@ +# colors.js +[![Build Status](https://travis-ci.org/Marak/colors.js.svg?branch=master)](https://travis-ci.org/Marak/colors.js) +[![version](https://img.shields.io/npm/v/colors.svg)](https://www.npmjs.org/package/colors) +[![dependencies](https://david-dm.org/Marak/colors.js.svg)](https://david-dm.org/Marak/colors.js) +[![devDependencies](https://david-dm.org/Marak/colors.js/dev-status.svg)](https://david-dm.org/Marak/colors.js#info=devDependencies) + +Please check out the [roadmap](ROADMAP.md) for upcoming features and releases. Please open Issues to provide feedback, and check the `develop` branch for the latest bleeding-edge updates. + +## get color and style in your node.js console + +![Demo](https://raw.githubusercontent.com/Marak/colors.js/master/screenshots/colors.png) + +## Installation + + npm install colors + +## colors and styles! + +### text colors + + - black + - red + - green + - yellow + - blue + - magenta + - cyan + - white + - gray + - grey + +### background colors + + - bgBlack + - bgRed + - bgGreen + - bgYellow + - bgBlue + - bgMagenta + - bgCyan + - bgWhite + +### styles + + - reset + - bold + - dim + - italic + - underline + - inverse + - hidden + - strikethrough + +### extras + + - rainbow + - zebra + - america + - trap + - random + + +## Usage + +By popular demand, `colors` now ships with two types of usages! + +The super nifty way + +```js +var colors = require('colors'); + +console.log('hello'.green); // outputs green text +console.log('i like cake and pies'.underline.red) // outputs red underlined text +console.log('inverse the color'.inverse); // inverses the color +console.log('OMG Rainbows!'.rainbow); // rainbow +console.log('Run the trap'.trap); // Drops the bass + +``` + +or a slightly less nifty way which doesn't extend `String.prototype` + +```js +var colors = require('colors/safe'); + +console.log(colors.green('hello')); // outputs green text +console.log(colors.red.underline('i like cake and pies')) // outputs red underlined text +console.log(colors.inverse('inverse the color')); // inverses the color +console.log(colors.rainbow('OMG Rainbows!')); // rainbow +console.log(colors.trap('Run the trap')); // Drops the bass + +``` + +I prefer the first way. Some people seem to be afraid of extending `String.prototype` and prefer the second way. + +If you are writing good code you will never have an issue with the first approach. If you really don't want to touch `String.prototype`, the second usage will not touch `String` native object. + +## Disabling Colors + +To disable colors you can pass the following arguments in the command line to your application: + +```bash +node myapp.js --no-color +``` + +## Console.log [string substitution](http://nodejs.org/docs/latest/api/console.html#console_console_log_data) + +```js +var name = 'Marak'; +console.log(colors.green('Hello %s'), name); +// outputs -> 'Hello Marak' +``` + +## Custom themes + +### Using standard API + +```js + +var colors = require('colors'); + +colors.setTheme({ + silly: 'rainbow', + input: 'grey', + verbose: 'cyan', + prompt: 'grey', + info: 'green', + data: 'grey', + help: 'cyan', + warn: 'yellow', + debug: 'blue', + error: 'red' +}); + +// outputs red text +console.log("this is an error".error); + +// outputs yellow text +console.log("this is a warning".warn); +``` + +### Using string safe API + +```js +var colors = require('colors/safe'); + +// set single property +var error = colors.red; +error('this is red'); + +// set theme +colors.setTheme({ + silly: 'rainbow', + input: 'grey', + verbose: 'cyan', + prompt: 'grey', + info: 'green', + data: 'grey', + help: 'cyan', + warn: 'yellow', + debug: 'blue', + error: 'red' +}); + +// outputs red text +console.log(colors.error("this is an error")); + +// outputs yellow text +console.log(colors.warn("this is a warning")); + +``` + +### Combining Colors + +```javascript +var colors = require('colors'); + +colors.setTheme({ + custom: ['red', 'underline'] +}); + +console.log('test'.custom); +``` + +*Protip: There is a secret undocumented style in `colors`. If you find the style you can summon him.* diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/examples/normal-usage.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/examples/normal-usage.js new file mode 100644 index 0000000000000..cc8d05ff4f23a --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/examples/normal-usage.js @@ -0,0 +1,81 @@ +var colors = require('../lib/index'); + +console.log('First some yellow text'.yellow); + +console.log('Underline that text'.yellow.underline); + +console.log('Make it bold and red'.red.bold); + +console.log(('Double Raindows All Day Long').rainbow); + +console.log('Drop the bass'.trap); + +console.log('DROP THE RAINBOW BASS'.trap.rainbow); + +// styles not widely supported +console.log('Chains are also cool.'.bold.italic.underline.red); + +// styles not widely supported +console.log('So '.green + 'are'.underline + ' ' + 'inverse'.inverse + + ' styles! '.yellow.bold); +console.log('Zebras are so fun!'.zebra); + +// +// Remark: .strikethrough may not work with Mac OS Terminal App +// +console.log('This is ' + 'not'.strikethrough + ' fun.'); + +console.log('Background color attack!'.black.bgWhite); +console.log('Use random styles on everything!'.random); +console.log('America, Heck Yeah!'.america); + + +console.log('Setting themes is useful'); + +// +// Custom themes +// +console.log('Generic logging theme as JSON'.green.bold.underline); +// Load theme with JSON literal +colors.setTheme({ + silly: 'rainbow', + input: 'grey', + verbose: 'cyan', + prompt: 'grey', + info: 'green', + data: 'grey', + help: 'cyan', + warn: 'yellow', + debug: 'blue', + error: 'red', +}); + +// outputs red text +console.log('this is an error'.error); + +// outputs yellow text +console.log('this is a warning'.warn); + +// outputs grey text +console.log('this is an input'.input); + +console.log('Generic logging theme as file'.green.bold.underline); + +// Load a theme from file +try { + colors.setTheme(require(__dirname + '/../themes/generic-logging.js')); +} catch (err) { + console.log(err); +} + +// outputs red text +console.log('this is an error'.error); + +// outputs yellow text +console.log('this is a warning'.warn); + +// outputs grey text +console.log('this is an input'.input); + +// console.log("Don't summon".zalgo) + diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/examples/safe-string.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/examples/safe-string.js new file mode 100644 index 0000000000000..98994873520ff --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/examples/safe-string.js @@ -0,0 +1,77 @@ +var colors = require('../safe'); + +console.log(colors.yellow('First some yellow text')); + +console.log(colors.yellow.underline('Underline that text')); + +console.log(colors.red.bold('Make it bold and red')); + +console.log(colors.rainbow('Double Raindows All Day Long')); + +console.log(colors.trap('Drop the bass')); + +console.log(colors.rainbow(colors.trap('DROP THE RAINBOW BASS'))); + +// styles not widely supported +console.log(colors.bold.italic.underline.red('Chains are also cool.')); + +// styles not widely supported +console.log(colors.green('So ') + colors.underline('are') + ' ' + + colors.inverse('inverse') + colors.yellow.bold(' styles! ')); + +console.log(colors.zebra('Zebras are so fun!')); + +console.log('This is ' + colors.strikethrough('not') + ' fun.'); + + +console.log(colors.black.bgWhite('Background color attack!')); +console.log(colors.random('Use random styles on everything!')); +console.log(colors.america('America, Heck Yeah!')); + +console.log('Setting themes is useful'); + +// +// Custom themes +// +// console.log('Generic logging theme as JSON'.green.bold.underline); +// Load theme with JSON literal +colors.setTheme({ + silly: 'rainbow', + input: 'blue', + verbose: 'cyan', + prompt: 'grey', + info: 'green', + data: 'grey', + help: 'cyan', + warn: 'yellow', + debug: 'blue', + error: 'red', +}); + +// outputs red text +console.log(colors.error('this is an error')); + +// outputs yellow text +console.log(colors.warn('this is a warning')); + +// outputs blue text +console.log(colors.input('this is an input')); + + +// console.log('Generic logging theme as file'.green.bold.underline); + +// Load a theme from file +colors.setTheme(require(__dirname + '/../themes/generic-logging.js')); + +// outputs red text +console.log(colors.error('this is an error')); + +// outputs yellow text +console.log(colors.warn('this is a warning')); + +// outputs grey text +console.log(colors.input('this is an input')); + +// console.log(colors.zalgo("Don't summon him")) + + diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/index.d.ts b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/index.d.ts new file mode 100644 index 0000000000000..baa70686535a7 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/index.d.ts @@ -0,0 +1,136 @@ +// Type definitions for Colors.js 1.2 +// Project: https://github.com/Marak/colors.js +// Definitions by: Bart van der Schoor , Staffan Eketorp +// Definitions: https://github.com/Marak/colors.js + +export interface Color { + (text: string): string; + + strip: Color; + stripColors: Color; + + black: Color; + red: Color; + green: Color; + yellow: Color; + blue: Color; + magenta: Color; + cyan: Color; + white: Color; + gray: Color; + grey: Color; + + bgBlack: Color; + bgRed: Color; + bgGreen: Color; + bgYellow: Color; + bgBlue: Color; + bgMagenta: Color; + bgCyan: Color; + bgWhite: Color; + + reset: Color; + bold: Color; + dim: Color; + italic: Color; + underline: Color; + inverse: Color; + hidden: Color; + strikethrough: Color; + + rainbow: Color; + zebra: Color; + america: Color; + trap: Color; + random: Color; + zalgo: Color; +} + +export function enable(): void; +export function disable(): void; +export function setTheme(theme: any): void; + +export let enabled: boolean; + +export const strip: Color; +export const stripColors: Color; + +export const black: Color; +export const red: Color; +export const green: Color; +export const yellow: Color; +export const blue: Color; +export const magenta: Color; +export const cyan: Color; +export const white: Color; +export const gray: Color; +export const grey: Color; + +export const bgBlack: Color; +export const bgRed: Color; +export const bgGreen: Color; +export const bgYellow: Color; +export const bgBlue: Color; +export const bgMagenta: Color; +export const bgCyan: Color; +export const bgWhite: Color; + +export const reset: Color; +export const bold: Color; +export const dim: Color; +export const italic: Color; +export const underline: Color; +export const inverse: Color; +export const hidden: Color; +export const strikethrough: Color; + +export const rainbow: Color; +export const zebra: Color; +export const america: Color; +export const trap: Color; +export const random: Color; +export const zalgo: Color; + +declare global { + interface String { + strip: string; + stripColors: string; + + black: string; + red: string; + green: string; + yellow: string; + blue: string; + magenta: string; + cyan: string; + white: string; + gray: string; + grey: string; + + bgBlack: string; + bgRed: string; + bgGreen: string; + bgYellow: string; + bgBlue: string; + bgMagenta: string; + bgCyan: string; + bgWhite: string; + + reset: string; + // @ts-ignore + bold: string; + dim: string; + italic: string; + underline: string; + inverse: string; + hidden: string; + strikethrough: string; + + rainbow: string; + zebra: string; + america: string; + trap: string; + random: string; + zalgo: string; + } +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/colors.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/colors.js new file mode 100644 index 0000000000000..7ca90fa903616 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/colors.js @@ -0,0 +1,201 @@ +/* + +The MIT License (MIT) + +Original Library + - Copyright (c) Marak Squires + +Additional functionality + - Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +var colors = {}; +module['exports'] = colors; + +colors.themes = {}; + +var util = require('util'); +var ansiStyles = colors.styles = require('./styles'); +var defineProps = Object.defineProperties; +var newLineRegex = new RegExp(/[\r\n]+/g); + +colors.supportsColor = require('./system/supports-colors').supportsColor; + +if (typeof colors.enabled === 'undefined') { + colors.enabled = colors.supportsColor() !== false; +} + +colors.enable = function() { + colors.enabled = true; +}; + +colors.disable = function() { + colors.enabled = false; +}; + +colors.stripColors = colors.strip = function(str) { + return ('' + str).replace(/\x1B\[\d+m/g, ''); +}; + +// eslint-disable-next-line no-unused-vars +var stylize = colors.stylize = function stylize(str, style) { + if (!colors.enabled) { + return str+''; + } + + return ansiStyles[style].open + str + ansiStyles[style].close; +}; + +var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g; +var escapeStringRegexp = function(str) { + if (typeof str !== 'string') { + throw new TypeError('Expected a string'); + } + return str.replace(matchOperatorsRe, '\\$&'); +}; + +function build(_styles) { + var builder = function builder() { + return applyStyle.apply(builder, arguments); + }; + builder._styles = _styles; + // __proto__ is used because we must return a function, but there is + // no way to create a function with a different prototype. + builder.__proto__ = proto; + return builder; +} + +var styles = (function() { + var ret = {}; + ansiStyles.grey = ansiStyles.gray; + Object.keys(ansiStyles).forEach(function(key) { + ansiStyles[key].closeRe = + new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); + ret[key] = { + get: function() { + return build(this._styles.concat(key)); + }, + }; + }); + return ret; +})(); + +var proto = defineProps(function colors() {}, styles); + +function applyStyle() { + var args = Array.prototype.slice.call(arguments); + + var str = args.map(function(arg) { + if (arg !== undefined && arg.constructor === String) { + return arg; + } else { + return util.inspect(arg); + } + }).join(' '); + + if (!colors.enabled || !str) { + return str; + } + + var newLinesPresent = str.indexOf('\n') != -1; + + var nestedStyles = this._styles; + + var i = nestedStyles.length; + while (i--) { + var code = ansiStyles[nestedStyles[i]]; + str = code.open + str.replace(code.closeRe, code.open) + code.close; + if (newLinesPresent) { + str = str.replace(newLineRegex, function(match) { + return code.close + match + code.open; + }); + } + } + + return str; +} + +colors.setTheme = function(theme) { + if (typeof theme === 'string') { + console.log('colors.setTheme now only accepts an object, not a string. ' + + 'If you are trying to set a theme from a file, it is now your (the ' + + 'caller\'s) responsibility to require the file. The old syntax ' + + 'looked like colors.setTheme(__dirname + ' + + '\'/../themes/generic-logging.js\'); The new syntax looks like '+ + 'colors.setTheme(require(__dirname + ' + + '\'/../themes/generic-logging.js\'));'); + return; + } + for (var style in theme) { + (function(style) { + colors[style] = function(str) { + if (typeof theme[style] === 'object') { + var out = str; + for (var i in theme[style]) { + out = colors[theme[style][i]](out); + } + return out; + } + return colors[theme[style]](str); + }; + })(style); + } +}; + +function init() { + var ret = {}; + Object.keys(styles).forEach(function(name) { + ret[name] = { + get: function() { + return build([name]); + }, + }; + }); + return ret; +} + +var sequencer = function sequencer(map, str) { + var exploded = str.split(''); + exploded = exploded.map(map); + return exploded.join(''); +}; + +// custom formatter methods +colors.trap = require('./custom/trap'); +colors.zalgo = require('./custom/zalgo'); + +// maps +colors.maps = {}; +colors.maps.america = require('./maps/america')(colors); +colors.maps.zebra = require('./maps/zebra')(colors); +colors.maps.rainbow = require('./maps/rainbow')(colors); +colors.maps.random = require('./maps/random')(colors); + +for (var map in colors.maps) { + (function(map) { + colors[map] = function(str) { + return sequencer(colors.maps[map], str); + }; + })(map); +} + +defineProps(colors, init()); diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/custom/trap.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/custom/trap.js new file mode 100644 index 0000000000000..fbccf88dede0b --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/custom/trap.js @@ -0,0 +1,46 @@ +module['exports'] = function runTheTrap(text, options) { + var result = ''; + text = text || 'Run the trap, drop the bass'; + text = text.split(''); + var trap = { + a: ['\u0040', '\u0104', '\u023a', '\u0245', '\u0394', '\u039b', '\u0414'], + b: ['\u00df', '\u0181', '\u0243', '\u026e', '\u03b2', '\u0e3f'], + c: ['\u00a9', '\u023b', '\u03fe'], + d: ['\u00d0', '\u018a', '\u0500', '\u0501', '\u0502', '\u0503'], + e: ['\u00cb', '\u0115', '\u018e', '\u0258', '\u03a3', '\u03be', '\u04bc', + '\u0a6c'], + f: ['\u04fa'], + g: ['\u0262'], + h: ['\u0126', '\u0195', '\u04a2', '\u04ba', '\u04c7', '\u050a'], + i: ['\u0f0f'], + j: ['\u0134'], + k: ['\u0138', '\u04a0', '\u04c3', '\u051e'], + l: ['\u0139'], + m: ['\u028d', '\u04cd', '\u04ce', '\u0520', '\u0521', '\u0d69'], + n: ['\u00d1', '\u014b', '\u019d', '\u0376', '\u03a0', '\u048a'], + o: ['\u00d8', '\u00f5', '\u00f8', '\u01fe', '\u0298', '\u047a', '\u05dd', + '\u06dd', '\u0e4f'], + p: ['\u01f7', '\u048e'], + q: ['\u09cd'], + r: ['\u00ae', '\u01a6', '\u0210', '\u024c', '\u0280', '\u042f'], + s: ['\u00a7', '\u03de', '\u03df', '\u03e8'], + t: ['\u0141', '\u0166', '\u0373'], + u: ['\u01b1', '\u054d'], + v: ['\u05d8'], + w: ['\u0428', '\u0460', '\u047c', '\u0d70'], + x: ['\u04b2', '\u04fe', '\u04fc', '\u04fd'], + y: ['\u00a5', '\u04b0', '\u04cb'], + z: ['\u01b5', '\u0240'], + }; + text.forEach(function(c) { + c = c.toLowerCase(); + var chars = trap[c] || [' ']; + var rand = Math.floor(Math.random() * chars.length); + if (typeof trap[c] !== 'undefined') { + result += trap[c][rand]; + } else { + result += c; + } + }); + return result; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/custom/zalgo.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/custom/zalgo.js new file mode 100644 index 0000000000000..0ef2b01195635 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/custom/zalgo.js @@ -0,0 +1,110 @@ +// please no +module['exports'] = function zalgo(text, options) { + text = text || ' he is here '; + var soul = { + 'up': [ + '̍', '̎', '̄', '̅', + '̿', '̑', '̆', '̐', + '͒', '͗', '͑', '̇', + '̈', '̊', '͂', '̓', + '̈', '͊', '͋', '͌', + '̃', '̂', '̌', '͐', + '̀', '́', '̋', '̏', + '̒', '̓', '̔', '̽', + '̉', 'ͣ', 'ͤ', 'ͥ', + 'ͦ', 'ͧ', 'ͨ', 'ͩ', + 'ͪ', 'ͫ', 'ͬ', 'ͭ', + 'ͮ', 'ͯ', '̾', '͛', + '͆', '̚', + ], + 'down': [ + '̖', '̗', '̘', '̙', + '̜', '̝', '̞', '̟', + '̠', '̤', '̥', '̦', + '̩', '̪', '̫', '̬', + '̭', '̮', '̯', '̰', + '̱', '̲', '̳', '̹', + '̺', '̻', '̼', 'ͅ', + '͇', '͈', '͉', '͍', + '͎', '͓', '͔', '͕', + '͖', '͙', '͚', '̣', + ], + 'mid': [ + '̕', '̛', '̀', '́', + '͘', '̡', '̢', '̧', + '̨', '̴', '̵', '̶', + '͜', '͝', '͞', + '͟', '͠', '͢', '̸', + '̷', '͡', ' ҉', + ], + }; + var all = [].concat(soul.up, soul.down, soul.mid); + + function randomNumber(range) { + var r = Math.floor(Math.random() * range); + return r; + } + + function isChar(character) { + var bool = false; + all.filter(function(i) { + bool = (i === character); + }); + return bool; + } + + + function heComes(text, options) { + var result = ''; + var counts; + var l; + options = options || {}; + options['up'] = + typeof options['up'] !== 'undefined' ? options['up'] : true; + options['mid'] = + typeof options['mid'] !== 'undefined' ? options['mid'] : true; + options['down'] = + typeof options['down'] !== 'undefined' ? options['down'] : true; + options['size'] = + typeof options['size'] !== 'undefined' ? options['size'] : 'maxi'; + text = text.split(''); + for (l in text) { + if (isChar(l)) { + continue; + } + result = result + text[l]; + counts = {'up': 0, 'down': 0, 'mid': 0}; + switch (options.size) { + case 'mini': + counts.up = randomNumber(8); + counts.mid = randomNumber(2); + counts.down = randomNumber(8); + break; + case 'maxi': + counts.up = randomNumber(16) + 3; + counts.mid = randomNumber(4) + 1; + counts.down = randomNumber(64) + 3; + break; + default: + counts.up = randomNumber(8) + 1; + counts.mid = randomNumber(6) / 2; + counts.down = randomNumber(8) + 1; + break; + } + + var arr = ['up', 'mid', 'down']; + for (var d in arr) { + var index = arr[d]; + for (var i = 0; i <= counts[index]; i++) { + if (options[index]) { + result = result + soul[index][randomNumber(soul[index].length)]; + } + } + } + } + return result; + } + // don't summon him + return heComes(text, options); +}; + diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/extendStringPrototype.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/extendStringPrototype.js new file mode 100644 index 0000000000000..46fd386a915a6 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/extendStringPrototype.js @@ -0,0 +1,110 @@ +var colors = require('./colors'); + +module['exports'] = function() { + // + // Extends prototype of native string object to allow for "foo".red syntax + // + var addProperty = function(color, func) { + String.prototype.__defineGetter__(color, func); + }; + + addProperty('strip', function() { + return colors.strip(this); + }); + + addProperty('stripColors', function() { + return colors.strip(this); + }); + + addProperty('trap', function() { + return colors.trap(this); + }); + + addProperty('zalgo', function() { + return colors.zalgo(this); + }); + + addProperty('zebra', function() { + return colors.zebra(this); + }); + + addProperty('rainbow', function() { + return colors.rainbow(this); + }); + + addProperty('random', function() { + return colors.random(this); + }); + + addProperty('america', function() { + return colors.america(this); + }); + + // + // Iterate through all default styles and colors + // + var x = Object.keys(colors.styles); + x.forEach(function(style) { + addProperty(style, function() { + return colors.stylize(this, style); + }); + }); + + function applyTheme(theme) { + // + // Remark: This is a list of methods that exist + // on String that you should not overwrite. + // + var stringPrototypeBlacklist = [ + '__defineGetter__', '__defineSetter__', '__lookupGetter__', + '__lookupSetter__', 'charAt', 'constructor', 'hasOwnProperty', + 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', + 'valueOf', 'charCodeAt', 'indexOf', 'lastIndexOf', 'length', + 'localeCompare', 'match', 'repeat', 'replace', 'search', 'slice', + 'split', 'substring', 'toLocaleLowerCase', 'toLocaleUpperCase', + 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight', + ]; + + Object.keys(theme).forEach(function(prop) { + if (stringPrototypeBlacklist.indexOf(prop) !== -1) { + console.log('warn: '.red + ('String.prototype' + prop).magenta + + ' is probably something you don\'t want to override. ' + + 'Ignoring style name'); + } else { + if (typeof(theme[prop]) === 'string') { + colors[prop] = colors[theme[prop]]; + addProperty(prop, function() { + return colors[prop](this); + }); + } else { + var themePropApplicator = function(str) { + var ret = str || this; + for (var t = 0; t < theme[prop].length; t++) { + ret = colors[theme[prop][t]](ret); + } + return ret; + }; + addProperty(prop, themePropApplicator); + colors[prop] = function(str) { + return themePropApplicator(str); + }; + } + } + }); + } + + colors.setTheme = function(theme) { + if (typeof theme === 'string') { + console.log('colors.setTheme now only accepts an object, not a string. ' + + 'If you are trying to set a theme from a file, it is now your (the ' + + 'caller\'s) responsibility to require the file. The old syntax ' + + 'looked like colors.setTheme(__dirname + ' + + '\'/../themes/generic-logging.js\'); The new syntax looks like '+ + 'colors.setTheme(require(__dirname + ' + + '\'/../themes/generic-logging.js\'));'); + return; + } else { + applyTheme(theme); + } + }; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/index.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/index.js new file mode 100644 index 0000000000000..9df5ab7df3077 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/index.js @@ -0,0 +1,13 @@ +var colors = require('./colors'); +module['exports'] = colors; + +// Remark: By default, colors will add style properties to String.prototype. +// +// If you don't wish to extend String.prototype, you can do this instead and +// native String will not be touched: +// +// var colors = require('colors/safe); +// colors.red("foo") +// +// +require('./extendStringPrototype')(); diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/america.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/america.js new file mode 100644 index 0000000000000..dc96903328989 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/america.js @@ -0,0 +1,10 @@ +module['exports'] = function(colors) { + return function(letter, i, exploded) { + if (letter === ' ') return letter; + switch (i%3) { + case 0: return colors.red(letter); + case 1: return colors.white(letter); + case 2: return colors.blue(letter); + } + }; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/rainbow.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/rainbow.js new file mode 100644 index 0000000000000..2b00ac0ac998e --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/rainbow.js @@ -0,0 +1,12 @@ +module['exports'] = function(colors) { + // RoY G BiV + var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; + return function(letter, i, exploded) { + if (letter === ' ') { + return letter; + } else { + return colors[rainbowColors[i++ % rainbowColors.length]](letter); + } + }; +}; + diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/random.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/random.js new file mode 100644 index 0000000000000..6f8f2f8e1e416 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/random.js @@ -0,0 +1,10 @@ +module['exports'] = function(colors) { + var available = ['underline', 'inverse', 'grey', 'yellow', 'red', 'green', + 'blue', 'white', 'cyan', 'magenta']; + return function(letter, i, exploded) { + return letter === ' ' ? letter : + colors[ + available[Math.round(Math.random() * (available.length - 2))] + ](letter); + }; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/zebra.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/zebra.js new file mode 100644 index 0000000000000..fa73623544a82 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/maps/zebra.js @@ -0,0 +1,5 @@ +module['exports'] = function(colors) { + return function(letter, i, exploded) { + return i % 2 === 0 ? letter : colors.inverse(letter); + }; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/styles.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/styles.js new file mode 100644 index 0000000000000..02db9acf7c7db --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/styles.js @@ -0,0 +1,77 @@ +/* +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +var styles = {}; +module['exports'] = styles; + +var codes = { + reset: [0, 0], + + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29], + + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + gray: [90, 39], + grey: [90, 39], + + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], + + // legacy styles for colors pre v1.0.0 + blackBG: [40, 49], + redBG: [41, 49], + greenBG: [42, 49], + yellowBG: [43, 49], + blueBG: [44, 49], + magentaBG: [45, 49], + cyanBG: [46, 49], + whiteBG: [47, 49], + +}; + +Object.keys(codes).forEach(function(key) { + var val = codes[key]; + var style = styles[key] = []; + style.open = '\u001b[' + val[0] + 'm'; + style.close = '\u001b[' + val[1] + 'm'; +}); diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/system/has-flag.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/system/has-flag.js new file mode 100644 index 0000000000000..a347dd4d7a697 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/system/has-flag.js @@ -0,0 +1,35 @@ +/* +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +'use strict'; + +module.exports = function(flag, argv) { + argv = argv || process.argv; + + var terminatorPos = argv.indexOf('--'); + var prefix = /^-{1,2}/.test(flag) ? '' : '--'; + var pos = argv.indexOf(prefix + flag); + + return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos); +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/system/supports-colors.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/system/supports-colors.js new file mode 100644 index 0000000000000..f1f9c8ff3da28 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/lib/system/supports-colors.js @@ -0,0 +1,151 @@ +/* +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +'use strict'; + +var os = require('os'); +var hasFlag = require('./has-flag.js'); + +var env = process.env; + +var forceColor = void 0; +if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) { + forceColor = false; +} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') + || hasFlag('color=always')) { + forceColor = true; +} +if ('FORCE_COLOR' in env) { + forceColor = env.FORCE_COLOR.length === 0 + || parseInt(env.FORCE_COLOR, 10) !== 0; +} + +function translateLevel(level) { + if (level === 0) { + return false; + } + + return { + level: level, + hasBasic: true, + has256: level >= 2, + has16m: level >= 3, + }; +} + +function supportsColor(stream) { + if (forceColor === false) { + return 0; + } + + if (hasFlag('color=16m') || hasFlag('color=full') + || hasFlag('color=truecolor')) { + return 3; + } + + if (hasFlag('color=256')) { + return 2; + } + + if (stream && !stream.isTTY && forceColor !== true) { + return 0; + } + + var min = forceColor ? 1 : 0; + + if (process.platform === 'win32') { + // Node.js 7.5.0 is the first version of Node.js to include a patch to + // libuv that enables 256 color output on Windows. Anything earlier and it + // won't work. However, here we target Node.js 8 at minimum as it is an LTS + // release, and Node.js 7 is not. Windows 10 build 10586 is the first + // Windows release that supports 256 colors. Windows 10 build 14931 is the + // first release that supports 16m/TrueColor. + var osRelease = os.release().split('.'); + if (Number(process.versions.node.split('.')[0]) >= 8 + && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { + return Number(osRelease[2]) >= 14931 ? 3 : 2; + } + + return 1; + } + + if ('CI' in env) { + if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function(sign) { + return sign in env; + }) || env.CI_NAME === 'codeship') { + return 1; + } + + return min; + } + + if ('TEAMCITY_VERSION' in env) { + return (/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0 + ); + } + + if ('TERM_PROGRAM' in env) { + var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); + + switch (env.TERM_PROGRAM) { + case 'iTerm.app': + return version >= 3 ? 3 : 2; + case 'Hyper': + return 3; + case 'Apple_Terminal': + return 2; + // No default + } + } + + if (/-256(color)?$/i.test(env.TERM)) { + return 2; + } + + if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { + return 1; + } + + if ('COLORTERM' in env) { + return 1; + } + + if (env.TERM === 'dumb') { + return min; + } + + return min; +} + +function getSupportLevel(stream) { + var level = supportsColor(stream); + return translateLevel(level); +} + +module.exports = { + supportsColor: getSupportLevel, + stdout: getSupportLevel(process.stdout), + stderr: getSupportLevel(process.stderr), +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/package.json b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/package.json new file mode 100644 index 0000000000000..8a1ddfebd41cb --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/package.json @@ -0,0 +1,74 @@ +{ + "_from": "colors@^1.1.2", + "_id": "colors@1.3.3", + "_inBundle": false, + "_integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", + "_location": "/npm-audit-report/cli-table3/colors", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "colors@^1.1.2", + "name": "colors", + "escapedName": "colors", + "rawSpec": "^1.1.2", + "saveSpec": null, + "fetchSpec": "^1.1.2" + }, + "_requiredBy": [ + "/npm-audit-report/cli-table3" + ], + "_resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "_shasum": "39e005d546afe01e01f9c4ca8fa50f686a01205d", + "_spec": "colors@^1.1.2", + "_where": "/Users/tanohzana/Documents/projets/cli/node_modules/npm-audit-report/node_modules/cli-table3", + "author": { + "name": "Marak Squires" + }, + "bugs": { + "url": "https://github.com/Marak/colors.js/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "DABH", + "url": "https://github.com/DABH" + } + ], + "deprecated": false, + "description": "get colors in your node.js console", + "devDependencies": { + "eslint": "^5.2.0", + "eslint-config-google": "^0.11.0" + }, + "engines": { + "node": ">=0.1.90" + }, + "files": [ + "examples", + "lib", + "LICENSE", + "safe.js", + "themes", + "index.d.ts", + "safe.d.ts" + ], + "homepage": "https://github.com/Marak/colors.js", + "keywords": [ + "ansi", + "terminal", + "colors" + ], + "license": "MIT", + "main": "lib/index.js", + "name": "colors", + "repository": { + "type": "git", + "url": "git+ssh://git@github.com/Marak/colors.js.git" + }, + "scripts": { + "lint": "eslint . --fix", + "test": "node tests/basic-test.js && node tests/safe-test.js" + }, + "version": "1.3.3" +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/safe.d.ts b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/safe.d.ts new file mode 100644 index 0000000000000..2bafc27984e0e --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/safe.d.ts @@ -0,0 +1,48 @@ +// Type definitions for Colors.js 1.2 +// Project: https://github.com/Marak/colors.js +// Definitions by: Bart van der Schoor , Staffan Eketorp +// Definitions: https://github.com/Marak/colors.js + +export const enabled: boolean; +export function enable(): void; +export function disable(): void; +export function setTheme(theme: any): void; + +export function strip(str: string): string; +export function stripColors(str: string): string; + +export function black(str: string): string; +export function red(str: string): string; +export function green(str: string): string; +export function yellow(str: string): string; +export function blue(str: string): string; +export function magenta(str: string): string; +export function cyan(str: string): string; +export function white(str: string): string; +export function gray(str: string): string; +export function grey(str: string): string; + +export function bgBlack(str: string): string; +export function bgRed(str: string): string; +export function bgGreen(str: string): string; +export function bgYellow(str: string): string; +export function bgBlue(str: string): string; +export function bgMagenta(str: string): string; +export function bgCyan(str: string): string; +export function bgWhite(str: string): string; + +export function reset(str: string): string; +export function bold(str: string): string; +export function dim(str: string): string; +export function italic(str: string): string; +export function underline(str: string): string; +export function inverse(str: string): string; +export function hidden(str: string): string; +export function strikethrough(str: string): string; + +export function rainbow(str: string): string; +export function zebra(str: string): string; +export function america(str: string): string; +export function trap(str: string): string; +export function random(str: string): string; +export function zalgo(str: string): string; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/safe.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/safe.js new file mode 100644 index 0000000000000..a013d54246485 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/safe.js @@ -0,0 +1,10 @@ +// +// Remark: Requiring this file will use the "safe" colors API, +// which will not touch String.prototype. +// +// var colors = require('colors/safe'); +// colors.red("foo") +// +// +var colors = require('./lib/colors'); +module['exports'] = colors; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/themes/generic-logging.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/themes/generic-logging.js new file mode 100644 index 0000000000000..63adfe4ac31f9 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/colors/themes/generic-logging.js @@ -0,0 +1,12 @@ +module['exports'] = { + silly: 'rainbow', + input: 'grey', + verbose: 'cyan', + prompt: 'grey', + info: 'green', + data: 'grey', + help: 'cyan', + warn: 'yellow', + debug: 'blue', + error: 'red', +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/index.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/index.js new file mode 100644 index 0000000000000..0930cf8890b9a --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/index.js @@ -0,0 +1,90 @@ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ + +'use strict'; +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; + +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); + } + + return Object(val); +} + +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } + + // Detect buggy property enumeration order in older V8 versions. + + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } + + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } + + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; + } +} + +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; + + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); + + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } + + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } + } + + return to; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/license b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/license new file mode 100644 index 0000000000000..654d0bfe94343 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/package.json b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/package.json new file mode 100644 index 0000000000000..2fdc052eeddd0 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/package.json @@ -0,0 +1,74 @@ +{ + "_from": "object-assign@^4.1.0", + "_id": "object-assign@4.1.1", + "_inBundle": false, + "_integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "_location": "/npm-audit-report/cli-table3/object-assign", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "object-assign@^4.1.0", + "name": "object-assign", + "escapedName": "object-assign", + "rawSpec": "^4.1.0", + "saveSpec": null, + "fetchSpec": "^4.1.0" + }, + "_requiredBy": [ + "/npm-audit-report/cli-table3" + ], + "_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "_shasum": "2109adc7965887cfc05cbbd442cac8bfbb360863", + "_spec": "object-assign@^4.1.0", + "_where": "/Users/tanohzana/Documents/projets/cli/node_modules/npm-audit-report/node_modules/cli-table3", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/object-assign/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "ES2015 `Object.assign()` ponyfill", + "devDependencies": { + "ava": "^0.16.0", + "lodash": "^4.16.4", + "matcha": "^0.7.0", + "xo": "^0.16.0" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/object-assign#readme", + "keywords": [ + "object", + "assign", + "extend", + "properties", + "es2015", + "ecmascript", + "harmony", + "ponyfill", + "prollyfill", + "polyfill", + "shim", + "browser" + ], + "license": "MIT", + "name": "object-assign", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/object-assign.git" + }, + "scripts": { + "bench": "matcha bench.js", + "test": "xo && ava" + }, + "version": "4.1.1" +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/readme.md b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/readme.md new file mode 100644 index 0000000000000..1be09d35c776c --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/object-assign/readme.md @@ -0,0 +1,61 @@ +# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) + +> ES2015 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) [ponyfill](https://ponyfill.com) + + +## Use the built-in + +Node.js 4 and up, as well as every evergreen browser (Chrome, Edge, Firefox, Opera, Safari), +support `Object.assign()` :tada:. If you target only those environments, then by all +means, use `Object.assign()` instead of this package. + + +## Install + +``` +$ npm install --save object-assign +``` + + +## Usage + +```js +const objectAssign = require('object-assign'); + +objectAssign({foo: 0}, {bar: 1}); +//=> {foo: 0, bar: 1} + +// multiple sources +objectAssign({foo: 0}, {bar: 1}, {baz: 2}); +//=> {foo: 0, bar: 1, baz: 2} + +// overwrites equal keys +objectAssign({foo: 0}, {foo: 1}, {foo: 2}); +//=> {foo: 2} + +// ignores null and undefined sources +objectAssign({foo: 0}, null, {bar: 1}, undefined); +//=> {foo: 0, bar: 1} +``` + + +## API + +### objectAssign(target, [source, ...]) + +Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. + + +## Resources + +- [ES2015 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) + + +## Related + +- [deep-assign](https://github.com/sindresorhus/deep-assign) - Recursive `Object.assign()` + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/index.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/index.js new file mode 100644 index 0000000000000..bbc49d29b156c --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/index.js @@ -0,0 +1,36 @@ +'use strict'; +const stripAnsi = require('strip-ansi'); +const isFullwidthCodePoint = require('is-fullwidth-code-point'); + +module.exports = str => { + if (typeof str !== 'string' || str.length === 0) { + return 0; + } + + str = stripAnsi(str); + + let width = 0; + + for (let i = 0; i < str.length; i++) { + const code = str.codePointAt(i); + + // Ignore control characters + if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { + continue; + } + + // Ignore combining characters + if (code >= 0x300 && code <= 0x36F) { + continue; + } + + // Surrogates + if (code > 0xFFFF) { + i++; + } + + width += isFullwidthCodePoint(code) ? 2 : 1; + } + + return width; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/license b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/license new file mode 100644 index 0000000000000..e7af2f77107d7 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js new file mode 100644 index 0000000000000..d506327c3e557 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js @@ -0,0 +1,46 @@ +'use strict'; +/* eslint-disable yoda */ +module.exports = x => { + if (Number.isNaN(x)) { + return false; + } + + // code points are derived from: + // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt + if ( + x >= 0x1100 && ( + x <= 0x115f || // Hangul Jamo + x === 0x2329 || // LEFT-POINTING ANGLE BRACKET + x === 0x232a || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + (0x3250 <= x && x <= 0x4dbf) || + // CJK Unified Ideographs .. Yi Radicals + (0x4e00 <= x && x <= 0xa4c6) || + // Hangul Jamo Extended-A + (0xa960 <= x && x <= 0xa97c) || + // Hangul Syllables + (0xac00 <= x && x <= 0xd7a3) || + // CJK Compatibility Ideographs + (0xf900 <= x && x <= 0xfaff) || + // Vertical Forms + (0xfe10 <= x && x <= 0xfe19) || + // CJK Compatibility Forms .. Small Form Variants + (0xfe30 <= x && x <= 0xfe6b) || + // Halfwidth and Fullwidth Forms + (0xff01 <= x && x <= 0xff60) || + (0xffe0 <= x && x <= 0xffe6) || + // Kana Supplement + (0x1b000 <= x && x <= 0x1b001) || + // Enclosed Ideographic Supplement + (0x1f200 <= x && x <= 0x1f251) || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + (0x20000 <= x && x <= 0x3fffd) + ) + ) { + return true; + } + + return false; +}; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/license b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/license new file mode 100644 index 0000000000000..654d0bfe94343 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/license @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) Sindre Sorhus (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json new file mode 100644 index 0000000000000..3901f43dcfa81 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json @@ -0,0 +1,77 @@ +{ + "_from": "is-fullwidth-code-point@^2.0.0", + "_id": "is-fullwidth-code-point@2.0.0", + "_inBundle": false, + "_integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", + "_location": "/npm-audit-report/cli-table3/string-width/is-fullwidth-code-point", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "is-fullwidth-code-point@^2.0.0", + "name": "is-fullwidth-code-point", + "escapedName": "is-fullwidth-code-point", + "rawSpec": "^2.0.0", + "saveSpec": null, + "fetchSpec": "^2.0.0" + }, + "_requiredBy": [ + "/npm-audit-report/cli-table3/string-width" + ], + "_resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "_shasum": "a3b30a5c4f199183167aaab93beefae3ddfb654f", + "_spec": "is-fullwidth-code-point@^2.0.0", + "_where": "/Users/tanohzana/Documents/projets/cli/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/is-fullwidth-code-point/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Check if the character represented by a given Unicode code point is fullwidth", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/is-fullwidth-code-point#readme", + "keywords": [ + "fullwidth", + "full-width", + "full", + "width", + "unicode", + "character", + "char", + "string", + "str", + "codepoint", + "code", + "point", + "is", + "detect", + "check" + ], + "license": "MIT", + "name": "is-fullwidth-code-point", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/is-fullwidth-code-point.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "2.0.0", + "xo": { + "esnext": true + } +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md new file mode 100644 index 0000000000000..093b0281b2c46 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md @@ -0,0 +1,39 @@ +# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point) + +> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) + + +## Install + +``` +$ npm install --save is-fullwidth-code-point +``` + + +## Usage + +```js +const isFullwidthCodePoint = require('is-fullwidth-code-point'); + +isFullwidthCodePoint('谢'.codePointAt()); +//=> true + +isFullwidthCodePoint('a'.codePointAt()); +//=> false +``` + + +## API + +### isFullwidthCodePoint(input) + +#### input + +Type: `number` + +[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/package.json b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/package.json new file mode 100644 index 0000000000000..186303fdc8136 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/package.json @@ -0,0 +1,87 @@ +{ + "_from": "string-width@^2.1.1", + "_id": "string-width@2.1.1", + "_inBundle": false, + "_integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "_location": "/npm-audit-report/cli-table3/string-width", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "string-width@^2.1.1", + "name": "string-width", + "escapedName": "string-width", + "rawSpec": "^2.1.1", + "saveSpec": null, + "fetchSpec": "^2.1.1" + }, + "_requiredBy": [ + "/npm-audit-report/cli-table3" + ], + "_resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "_shasum": "ab93f27a8dc13d28cac815c462143a6d9012ae9e", + "_spec": "string-width@^2.1.1", + "_where": "/Users/tanohzana/Documents/projets/cli/node_modules/npm-audit-report/node_modules/cli-table3", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/string-width/issues" + }, + "bundleDependencies": false, + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "deprecated": false, + "description": "Get the visual width of a string - the number of columns required to display it", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/sindresorhus/string-width#readme", + "keywords": [ + "string", + "str", + "character", + "char", + "unicode", + "width", + "visual", + "column", + "columns", + "fullwidth", + "full-width", + "full", + "ansi", + "escape", + "codes", + "cli", + "command-line", + "terminal", + "console", + "cjk", + "chinese", + "japanese", + "korean", + "fixed-width" + ], + "license": "MIT", + "name": "string-width", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/string-width.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "2.1.1" +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/readme.md b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/readme.md new file mode 100644 index 0000000000000..df5b7199f9091 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/node_modules/string-width/readme.md @@ -0,0 +1,42 @@ +# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width) + +> Get the visual width of a string - the number of columns required to display it + +Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. + +Useful to be able to measure the actual width of command-line output. + + +## Install + +``` +$ npm install string-width +``` + + +## Usage + +```js +const stringWidth = require('string-width'); + +stringWidth('古'); +//=> 2 + +stringWidth('\u001b[1m古\u001b[22m'); +//=> 2 + +stringWidth('a'); +//=> 1 +``` + + +## Related + +- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module +- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string +- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/package.json b/node_modules/npm-audit-report/node_modules/cli-table3/package.json new file mode 100644 index 0000000000000..0d86d7d1bc8a8 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/package.json @@ -0,0 +1,131 @@ +{ + "_from": "cli-table3@^0.5.0", + "_id": "cli-table3@0.5.1", + "_inBundle": false, + "_integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", + "_location": "/npm-audit-report/cli-table3", + "_phantomChildren": { + "strip-ansi": "4.0.0" + }, + "_requested": { + "type": "range", + "registry": true, + "raw": "cli-table3@^0.5.0", + "name": "cli-table3", + "escapedName": "cli-table3", + "rawSpec": "^0.5.0", + "saveSpec": null, + "fetchSpec": "^0.5.0" + }, + "_requiredBy": [ + "/npm-audit-report" + ], + "_resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", + "_shasum": "0252372d94dfc40dbd8df06005f48f31f656f202", + "_spec": "cli-table3@^0.5.0", + "_where": "/Users/tanohzana/Documents/projets/cli/node_modules/npm-audit-report", + "author": { + "name": "James Talmage" + }, + "bugs": { + "url": "https://github.com/cli-table/cli-table3/issues" + }, + "bundleDependencies": false, + "changelog": { + "repo": "cli-table/cli-table3", + "labels": { + "breaking": ":boom: Breaking Change", + "enhancement": ":rocket: Enhancement", + "bug": ":bug: Bug Fix", + "documentation": ":memo: Documentation", + "internal": ":house: Internal" + } + }, + "dependencies": { + "colors": "^1.1.2", + "object-assign": "^4.1.0", + "string-width": "^2.1.1" + }, + "deprecated": false, + "description": "Pretty unicode tables for the command line. Based on the original cli-table.", + "devDependencies": { + "ansi-256-colors": "^1.1.0", + "cli-table": "^0.3.1", + "eslint-config-prettier": "^2.9.0", + "eslint-plugin-prettier": "^2.6.0", + "jest": "^23.1.0", + "jest-runner-eslint": "^0.6.0", + "lerna-changelog": "^0.8.0", + "prettier": "1.13.7" + }, + "directories": { + "test": "test" + }, + "engines": { + "node": ">=6" + }, + "files": [ + "src/", + "index.d.ts", + "index.js" + ], + "homepage": "https://github.com/cli-table/cli-table3", + "jest": { + "projects": [ + { + "displayName": "test", + "testMatch": [ + "**/test/**/*-test(s)?.js" + ] + }, + { + "runner": "jest-runner-eslint", + "displayName": "lint", + "testMatch": [ + "/examples/**/*.js", + "/lib/**/*.js", + "/scripts/**/*.js", + "/src/**/*.js", + "/test/**/*.js" + ] + } + ] + }, + "keywords": [ + "node", + "command", + "line", + "cli", + "table", + "tables", + "tabular", + "unicode", + "colors", + "grid" + ], + "license": "MIT", + "main": "index.js", + "name": "cli-table3", + "optionalDependencies": { + "colors": "^1.1.2" + }, + "prettier": { + "printWidth": 120, + "tabWidth": 2, + "singleQuote": true, + "trailingComma": "es5" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/cli-table/cli-table3.git" + }, + "scripts": { + "changelog": "lerna-changelog", + "docs": "node ./scripts/update-docs.js", + "prettier": "prettier --write '{examples,lib,scripts,src,test}/**/*.js'", + "test": "jest --color", + "test:watch": "jest --color --watchAll --notify" + }, + "types": "index.d.ts", + "version": "0.5.1" +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/src/cell.js b/node_modules/npm-audit-report/node_modules/cli-table3/src/cell.js new file mode 100644 index 0000000000000..2db7f74d72cb3 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/src/cell.js @@ -0,0 +1,371 @@ +const utils = require('./utils'); + +class Cell { + /** + * A representation of a cell within the table. + * Implementations must have `init` and `draw` methods, + * as well as `colSpan`, `rowSpan`, `desiredHeight` and `desiredWidth` properties. + * @param options + * @constructor + */ + constructor(options) { + this.setOptions(options); + + /** + * Each cell will have it's `x` and `y` values set by the `layout-manager` prior to + * `init` being called; + * @type {Number} + */ + this.x = null; + this.y = null; + } + + setOptions(options) { + if (['boolean', 'number', 'string'].indexOf(typeof options) !== -1) { + options = { content: '' + options }; + } + options = options || {}; + this.options = options; + let content = options.content; + if (['boolean', 'number', 'string'].indexOf(typeof content) !== -1) { + this.content = String(content); + } else if (!content) { + this.content = ''; + } else { + throw new Error('Content needs to be a primitive, got: ' + typeof content); + } + this.colSpan = options.colSpan || 1; + this.rowSpan = options.rowSpan || 1; + } + + mergeTableOptions(tableOptions, cells) { + this.cells = cells; + + let optionsChars = this.options.chars || {}; + let tableChars = tableOptions.chars; + let chars = (this.chars = {}); + CHAR_NAMES.forEach(function(name) { + setOption(optionsChars, tableChars, name, chars); + }); + + this.truncate = this.options.truncate || tableOptions.truncate; + + let style = (this.options.style = this.options.style || {}); + let tableStyle = tableOptions.style; + setOption(style, tableStyle, 'padding-left', this); + setOption(style, tableStyle, 'padding-right', this); + this.head = style.head || tableStyle.head; + this.border = style.border || tableStyle.border; + + let fixedWidth = tableOptions.colWidths[this.x]; + if (tableOptions.wordWrap && fixedWidth) { + fixedWidth -= this.paddingLeft + this.paddingRight; + if (this.colSpan) { + let i = 1; + while (i < this.colSpan) { + fixedWidth += tableOptions.colWidths[this.x + i]; + i++; + } + } + this.lines = utils.colorizeLines(utils.wordWrap(fixedWidth, this.content)); + } else { + this.lines = utils.colorizeLines(this.content.split('\n')); + } + + this.desiredWidth = utils.strlen(this.content) + this.paddingLeft + this.paddingRight; + this.desiredHeight = this.lines.length; + } + + /** + * Initializes the Cells data structure. + * + * @param tableOptions - A fully populated set of tableOptions. + * In addition to the standard default values, tableOptions must have fully populated the + * `colWidths` and `rowWidths` arrays. Those arrays must have lengths equal to the number + * of columns or rows (respectively) in this table, and each array item must be a Number. + * + */ + init(tableOptions) { + let x = this.x; + let y = this.y; + this.widths = tableOptions.colWidths.slice(x, x + this.colSpan); + this.heights = tableOptions.rowHeights.slice(y, y + this.rowSpan); + this.width = this.widths.reduce(sumPlusOne, -1); + this.height = this.heights.reduce(sumPlusOne, -1); + + this.hAlign = this.options.hAlign || tableOptions.colAligns[x]; + this.vAlign = this.options.vAlign || tableOptions.rowAligns[y]; + + this.drawRight = x + this.colSpan == tableOptions.colWidths.length; + } + + /** + * Draws the given line of the cell. + * This default implementation defers to methods `drawTop`, `drawBottom`, `drawLine` and `drawEmpty`. + * @param lineNum - can be `top`, `bottom` or a numerical line number. + * @param spanningCell - will be a number if being called from a RowSpanCell, and will represent how + * many rows below it's being called from. Otherwise it's undefined. + * @returns {String} The representation of this line. + */ + draw(lineNum, spanningCell) { + if (lineNum == 'top') return this.drawTop(this.drawRight); + if (lineNum == 'bottom') return this.drawBottom(this.drawRight); + let padLen = Math.max(this.height - this.lines.length, 0); + let padTop; + switch (this.vAlign) { + case 'center': + padTop = Math.ceil(padLen / 2); + break; + case 'bottom': + padTop = padLen; + break; + default: + padTop = 0; + } + if (lineNum < padTop || lineNum >= padTop + this.lines.length) { + return this.drawEmpty(this.drawRight, spanningCell); + } + let forceTruncation = this.lines.length > this.height && lineNum + 1 >= this.height; + return this.drawLine(lineNum - padTop, this.drawRight, forceTruncation, spanningCell); + } + + /** + * Renders the top line of the cell. + * @param drawRight - true if this method should render the right edge of the cell. + * @returns {String} + */ + drawTop(drawRight) { + let content = []; + if (this.cells) { + //TODO: cells should always exist - some tests don't fill it in though + this.widths.forEach(function(width, index) { + content.push(this._topLeftChar(index)); + content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], width)); + }, this); + } else { + content.push(this._topLeftChar(0)); + content.push(utils.repeat(this.chars[this.y == 0 ? 'top' : 'mid'], this.width)); + } + if (drawRight) { + content.push(this.chars[this.y == 0 ? 'topRight' : 'rightMid']); + } + return this.wrapWithStyleColors('border', content.join('')); + } + + _topLeftChar(offset) { + let x = this.x + offset; + let leftChar; + if (this.y == 0) { + leftChar = x == 0 ? 'topLeft' : offset == 0 ? 'topMid' : 'top'; + } else { + if (x == 0) { + leftChar = 'leftMid'; + } else { + leftChar = offset == 0 ? 'midMid' : 'bottomMid'; + if (this.cells) { + //TODO: cells should always exist - some tests don't fill it in though + let spanAbove = this.cells[this.y - 1][x] instanceof Cell.ColSpanCell; + if (spanAbove) { + leftChar = offset == 0 ? 'topMid' : 'mid'; + } + if (offset == 0) { + let i = 1; + while (this.cells[this.y][x - i] instanceof Cell.ColSpanCell) { + i++; + } + if (this.cells[this.y][x - i] instanceof Cell.RowSpanCell) { + leftChar = 'leftMid'; + } + } + } + } + } + return this.chars[leftChar]; + } + + wrapWithStyleColors(styleProperty, content) { + if (this[styleProperty] && this[styleProperty].length) { + try { + let colors = require('colors/safe'); + for (let i = this[styleProperty].length - 1; i >= 0; i--) { + colors = colors[this[styleProperty][i]]; + } + return colors(content); + } catch (e) { + return content; + } + } else { + return content; + } + } + + /** + * Renders a line of text. + * @param lineNum - Which line of text to render. This is not necessarily the line within the cell. + * There may be top-padding above the first line of text. + * @param drawRight - true if this method should render the right edge of the cell. + * @param forceTruncationSymbol - `true` if the rendered text should end with the truncation symbol even + * if the text fits. This is used when the cell is vertically truncated. If `false` the text should + * only include the truncation symbol if the text will not fit horizontally within the cell width. + * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined. + * @returns {String} + */ + drawLine(lineNum, drawRight, forceTruncationSymbol, spanningCell) { + let left = this.chars[this.x == 0 ? 'left' : 'middle']; + if (this.x && spanningCell && this.cells) { + let cellLeft = this.cells[this.y + spanningCell][this.x - 1]; + while (cellLeft instanceof ColSpanCell) { + cellLeft = this.cells[cellLeft.y][cellLeft.x - 1]; + } + if (!(cellLeft instanceof RowSpanCell)) { + left = this.chars['rightMid']; + } + } + let leftPadding = utils.repeat(' ', this.paddingLeft); + let right = drawRight ? this.chars['right'] : ''; + let rightPadding = utils.repeat(' ', this.paddingRight); + let line = this.lines[lineNum]; + let len = this.width - (this.paddingLeft + this.paddingRight); + if (forceTruncationSymbol) line += this.truncate || '…'; + let content = utils.truncate(line, len, this.truncate); + content = utils.pad(content, len, ' ', this.hAlign); + content = leftPadding + content + rightPadding; + return this.stylizeLine(left, content, right); + } + + stylizeLine(left, content, right) { + left = this.wrapWithStyleColors('border', left); + right = this.wrapWithStyleColors('border', right); + if (this.y === 0) { + content = this.wrapWithStyleColors('head', content); + } + return left + content + right; + } + + /** + * Renders the bottom line of the cell. + * @param drawRight - true if this method should render the right edge of the cell. + * @returns {String} + */ + drawBottom(drawRight) { + let left = this.chars[this.x == 0 ? 'bottomLeft' : 'bottomMid']; + let content = utils.repeat(this.chars.bottom, this.width); + let right = drawRight ? this.chars['bottomRight'] : ''; + return this.wrapWithStyleColors('border', left + content + right); + } + + /** + * Renders a blank line of text within the cell. Used for top and/or bottom padding. + * @param drawRight - true if this method should render the right edge of the cell. + * @param spanningCell - a number of if being called from a RowSpanCell. (how many rows below). otherwise undefined. + * @returns {String} + */ + drawEmpty(drawRight, spanningCell) { + let left = this.chars[this.x == 0 ? 'left' : 'middle']; + if (this.x && spanningCell && this.cells) { + let cellLeft = this.cells[this.y + spanningCell][this.x - 1]; + while (cellLeft instanceof ColSpanCell) { + cellLeft = this.cells[cellLeft.y][cellLeft.x - 1]; + } + if (!(cellLeft instanceof RowSpanCell)) { + left = this.chars['rightMid']; + } + } + let right = drawRight ? this.chars['right'] : ''; + let content = utils.repeat(' ', this.width); + return this.stylizeLine(left, content, right); + } +} + +class ColSpanCell { + /** + * A Cell that doesn't do anything. It just draws empty lines. + * Used as a placeholder in column spanning. + * @constructor + */ + constructor() {} + + draw() { + return ''; + } + + init() {} + + mergeTableOptions() {} +} + +class RowSpanCell { + /** + * A placeholder Cell for a Cell that spans multiple rows. + * It delegates rendering to the original cell, but adds the appropriate offset. + * @param originalCell + * @constructor + */ + constructor(originalCell) { + this.originalCell = originalCell; + } + + init(tableOptions) { + let y = this.y; + let originalY = this.originalCell.y; + this.cellOffset = y - originalY; + this.offset = findDimension(tableOptions.rowHeights, originalY, this.cellOffset); + } + + draw(lineNum) { + if (lineNum == 'top') { + return this.originalCell.draw(this.offset, this.cellOffset); + } + if (lineNum == 'bottom') { + return this.originalCell.draw('bottom'); + } + return this.originalCell.draw(this.offset + 1 + lineNum); + } + + mergeTableOptions() {} +} + +// HELPER FUNCTIONS +function setOption(objA, objB, nameB, targetObj) { + let nameA = nameB.split('-'); + if (nameA.length > 1) { + nameA[1] = nameA[1].charAt(0).toUpperCase() + nameA[1].substr(1); + nameA = nameA.join(''); + targetObj[nameA] = objA[nameA] || objA[nameB] || objB[nameA] || objB[nameB]; + } else { + targetObj[nameB] = objA[nameB] || objB[nameB]; + } +} + +function findDimension(dimensionTable, startingIndex, span) { + let ret = dimensionTable[startingIndex]; + for (let i = 1; i < span; i++) { + ret += 1 + dimensionTable[startingIndex + i]; + } + return ret; +} + +function sumPlusOne(a, b) { + return a + b + 1; +} + +let CHAR_NAMES = [ + 'top', + 'top-mid', + 'top-left', + 'top-right', + 'bottom', + 'bottom-mid', + 'bottom-left', + 'bottom-right', + 'left', + 'left-mid', + 'mid', + 'mid-mid', + 'right', + 'right-mid', + 'middle', +]; +module.exports = Cell; +module.exports.ColSpanCell = ColSpanCell; +module.exports.RowSpanCell = RowSpanCell; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/src/layout-manager.js b/node_modules/npm-audit-report/node_modules/cli-table3/src/layout-manager.js new file mode 100644 index 0000000000000..908040e7e5378 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/src/layout-manager.js @@ -0,0 +1,232 @@ +const objectAssign = require('object-assign'); +const Cell = require('./cell'); +const { ColSpanCell, RowSpanCell } = Cell; + +(function() { + function layoutTable(table) { + table.forEach(function(row, rowIndex) { + row.forEach(function(cell, columnIndex) { + cell.y = rowIndex; + cell.x = columnIndex; + for (let y = rowIndex; y >= 0; y--) { + let row2 = table[y]; + let xMax = y === rowIndex ? columnIndex : row2.length; + for (let x = 0; x < xMax; x++) { + let cell2 = row2[x]; + while (cellsConflict(cell, cell2)) { + cell.x++; + } + } + } + }); + }); + } + + function maxWidth(table) { + let mw = 0; + table.forEach(function(row) { + row.forEach(function(cell) { + mw = Math.max(mw, cell.x + (cell.colSpan || 1)); + }); + }); + return mw; + } + + function maxHeight(table) { + return table.length; + } + + function cellsConflict(cell1, cell2) { + let yMin1 = cell1.y; + let yMax1 = cell1.y - 1 + (cell1.rowSpan || 1); + let yMin2 = cell2.y; + let yMax2 = cell2.y - 1 + (cell2.rowSpan || 1); + let yConflict = !(yMin1 > yMax2 || yMin2 > yMax1); + + let xMin1 = cell1.x; + let xMax1 = cell1.x - 1 + (cell1.colSpan || 1); + let xMin2 = cell2.x; + let xMax2 = cell2.x - 1 + (cell2.colSpan || 1); + let xConflict = !(xMin1 > xMax2 || xMin2 > xMax1); + + return yConflict && xConflict; + } + + function conflictExists(rows, x, y) { + let i_max = Math.min(rows.length - 1, y); + let cell = { x: x, y: y }; + for (let i = 0; i <= i_max; i++) { + let row = rows[i]; + for (let j = 0; j < row.length; j++) { + if (cellsConflict(cell, row[j])) { + return true; + } + } + } + return false; + } + + function allBlank(rows, y, xMin, xMax) { + for (let x = xMin; x < xMax; x++) { + if (conflictExists(rows, x, y)) { + return false; + } + } + return true; + } + + function addRowSpanCells(table) { + table.forEach(function(row, rowIndex) { + row.forEach(function(cell) { + for (let i = 1; i < cell.rowSpan; i++) { + let rowSpanCell = new RowSpanCell(cell); + rowSpanCell.x = cell.x; + rowSpanCell.y = cell.y + i; + rowSpanCell.colSpan = cell.colSpan; + insertCell(rowSpanCell, table[rowIndex + i]); + } + }); + }); + } + + function addColSpanCells(cellRows) { + for (let rowIndex = cellRows.length - 1; rowIndex >= 0; rowIndex--) { + let cellColumns = cellRows[rowIndex]; + for (let columnIndex = 0; columnIndex < cellColumns.length; columnIndex++) { + let cell = cellColumns[columnIndex]; + for (let k = 1; k < cell.colSpan; k++) { + let colSpanCell = new ColSpanCell(); + colSpanCell.x = cell.x + k; + colSpanCell.y = cell.y; + cellColumns.splice(columnIndex + 1, 0, colSpanCell); + } + } + } + } + + function insertCell(cell, row) { + let x = 0; + while (x < row.length && row[x].x < cell.x) { + x++; + } + row.splice(x, 0, cell); + } + + function fillInTable(table) { + let h_max = maxHeight(table); + let w_max = maxWidth(table); + for (let y = 0; y < h_max; y++) { + for (let x = 0; x < w_max; x++) { + if (!conflictExists(table, x, y)) { + let opts = { x: x, y: y, colSpan: 1, rowSpan: 1 }; + x++; + while (x < w_max && !conflictExists(table, x, y)) { + opts.colSpan++; + x++; + } + let y2 = y + 1; + while (y2 < h_max && allBlank(table, y2, opts.x, opts.x + opts.colSpan)) { + opts.rowSpan++; + y2++; + } + + let cell = new Cell(opts); + cell.x = opts.x; + cell.y = opts.y; + insertCell(cell, table[y]); + } + } + } + } + + function generateCells(rows) { + return rows.map(function(row) { + if (!Array.isArray(row)) { + let key = Object.keys(row)[0]; + row = row[key]; + if (Array.isArray(row)) { + row = row.slice(); + row.unshift(key); + } else { + row = [key, row]; + } + } + return row.map(function(cell) { + return new Cell(cell); + }); + }); + } + + function makeTableLayout(rows) { + let cellRows = generateCells(rows); + layoutTable(cellRows); + fillInTable(cellRows); + addRowSpanCells(cellRows); + addColSpanCells(cellRows); + return cellRows; + } + + module.exports = { + makeTableLayout: makeTableLayout, + layoutTable: layoutTable, + addRowSpanCells: addRowSpanCells, + maxWidth: maxWidth, + fillInTable: fillInTable, + computeWidths: makeComputeWidths('colSpan', 'desiredWidth', 'x', 1), + computeHeights: makeComputeWidths('rowSpan', 'desiredHeight', 'y', 1), + }; +})(); + +function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) { + return function(vals, table) { + let result = []; + let spanners = []; + table.forEach(function(row) { + row.forEach(function(cell) { + if ((cell[colSpan] || 1) > 1) { + spanners.push(cell); + } else { + result[cell[x]] = Math.max(result[cell[x]] || 0, cell[desiredWidth] || 0, forcedMin); + } + }); + }); + + vals.forEach(function(val, index) { + if (typeof val === 'number') { + result[index] = val; + } + }); + + //spanners.forEach(function(cell){ + for (let k = spanners.length - 1; k >= 0; k--) { + let cell = spanners[k]; + let span = cell[colSpan]; + let col = cell[x]; + let existingWidth = result[col]; + let editableCols = typeof vals[col] === 'number' ? 0 : 1; + for (let i = 1; i < span; i++) { + existingWidth += 1 + result[col + i]; + if (typeof vals[col + i] !== 'number') { + editableCols++; + } + } + if (cell[desiredWidth] > existingWidth) { + let i = 0; + while (editableCols > 0 && cell[desiredWidth] > existingWidth) { + if (typeof vals[col + i] !== 'number') { + let dif = Math.round((cell[desiredWidth] - existingWidth) / editableCols); + existingWidth += dif; + result[col + i] += dif; + editableCols--; + } + i++; + } + } + } + + objectAssign(vals, result); + for (let j = 0; j < vals.length; j++) { + vals[j] = Math.max(forcedMin, vals[j] || 0); + } + }; +} diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/src/table.js b/node_modules/npm-audit-report/node_modules/cli-table3/src/table.js new file mode 100644 index 0000000000000..af4f146463462 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/src/table.js @@ -0,0 +1,77 @@ +const utils = require('./utils'); +const tableLayout = require('./layout-manager'); + +class Table extends Array { + constructor(options) { + super(); + + this.options = utils.mergeOptions(options); + } + + toString() { + let array = this; + let headersPresent = this.options.head && this.options.head.length; + if (headersPresent) { + array = [this.options.head]; + if (this.length) { + array.push.apply(array, this); + } + } else { + this.options.style.head = []; + } + + let cells = tableLayout.makeTableLayout(array); + + cells.forEach(function(row) { + row.forEach(function(cell) { + cell.mergeTableOptions(this.options, cells); + }, this); + }, this); + + tableLayout.computeWidths(this.options.colWidths, cells); + tableLayout.computeHeights(this.options.rowHeights, cells); + + cells.forEach(function(row) { + row.forEach(function(cell) { + cell.init(this.options); + }, this); + }, this); + + let result = []; + + for (let rowIndex = 0; rowIndex < cells.length; rowIndex++) { + let row = cells[rowIndex]; + let heightOfRow = this.options.rowHeights[rowIndex]; + + if (rowIndex === 0 || !this.options.style.compact || (rowIndex == 1 && headersPresent)) { + doDraw(row, 'top', result); + } + + for (let lineNum = 0; lineNum < heightOfRow; lineNum++) { + doDraw(row, lineNum, result); + } + + if (rowIndex + 1 == cells.length) { + doDraw(row, 'bottom', result); + } + } + + return result.join('\n'); + } + + get width() { + let str = this.toString().split('\n'); + return str[0].length; + } +} + +function doDraw(row, lineNum, result) { + let line = []; + row.forEach(function(cell) { + line.push(cell.draw(lineNum)); + }); + let str = line.join(''); + if (str.length) result.push(str); +} + +module.exports = Table; diff --git a/node_modules/npm-audit-report/node_modules/cli-table3/src/utils.js b/node_modules/npm-audit-report/node_modules/cli-table3/src/utils.js new file mode 100644 index 0000000000000..c9149558e24b9 --- /dev/null +++ b/node_modules/npm-audit-report/node_modules/cli-table3/src/utils.js @@ -0,0 +1,303 @@ +const objectAssign = require('object-assign'); +const stringWidth = require('string-width'); + +function codeRegex(capture) { + return capture ? /\u001b\[((?:\d*;){0,5}\d*)m/g : /\u001b\[(?:\d*;){0,5}\d*m/g; +} + +function strlen(str) { + let code = codeRegex(); + let stripped = ('' + str).replace(code, ''); + let split = stripped.split('\n'); + return split.reduce(function(memo, s) { + return stringWidth(s) > memo ? stringWidth(s) : memo; + }, 0); +} + +function repeat(str, times) { + return Array(times + 1).join(str); +} + +function pad(str, len, pad, dir) { + let length = strlen(str); + if (len + 1 >= length) { + let padlen = len - length; + switch (dir) { + case 'right': { + str = repeat(pad, padlen) + str; + break; + } + case 'center': { + let right = Math.ceil(padlen / 2); + let left = padlen - right; + str = repeat(pad, left) + str + repeat(pad, right); + break; + } + default: { + str = str + repeat(pad, padlen); + break; + } + } + } + return str; +} + +let codeCache = {}; + +function addToCodeCache(name, on, off) { + on = '\u001b[' + on + 'm'; + off = '\u001b[' + off + 'm'; + codeCache[on] = { set: name, to: true }; + codeCache[off] = { set: name, to: false }; + codeCache[name] = { on: on, off: off }; +} + +//https://github.com/Marak/colors.js/blob/master/lib/styles.js +addToCodeCache('bold', 1, 22); +addToCodeCache('italics', 3, 23); +addToCodeCache('underline', 4, 24); +addToCodeCache('inverse', 7, 27); +addToCodeCache('strikethrough', 9, 29); + +function updateState(state, controlChars) { + let controlCode = controlChars[1] ? parseInt(controlChars[1].split(';')[0]) : 0; + if ((controlCode >= 30 && controlCode <= 39) || (controlCode >= 90 && controlCode <= 97)) { + state.lastForegroundAdded = controlChars[0]; + return; + } + if ((controlCode >= 40 && controlCode <= 49) || (controlCode >= 100 && controlCode <= 107)) { + state.lastBackgroundAdded = controlChars[0]; + return; + } + if (controlCode === 0) { + for (let i in state) { + /* istanbul ignore else */ + if (state.hasOwnProperty(i)) { + delete state[i]; + } + } + return; + } + let info = codeCache[controlChars[0]]; + if (info) { + state[info.set] = info.to; + } +} + +function readState(line) { + let code = codeRegex(true); + let controlChars = code.exec(line); + let state = {}; + while (controlChars !== null) { + updateState(state, controlChars); + controlChars = code.exec(line); + } + return state; +} + +function unwindState(state, ret) { + let lastBackgroundAdded = state.lastBackgroundAdded; + let lastForegroundAdded = state.lastForegroundAdded; + + delete state.lastBackgroundAdded; + delete state.lastForegroundAdded; + + Object.keys(state).forEach(function(key) { + if (state[key]) { + ret += codeCache[key].off; + } + }); + + if (lastBackgroundAdded && lastBackgroundAdded != '\u001b[49m') { + ret += '\u001b[49m'; + } + if (lastForegroundAdded && lastForegroundAdded != '\u001b[39m') { + ret += '\u001b[39m'; + } + + return ret; +} + +function rewindState(state, ret) { + let lastBackgroundAdded = state.lastBackgroundAdded; + let lastForegroundAdded = state.lastForegroundAdded; + + delete state.lastBackgroundAdded; + delete state.lastForegroundAdded; + + Object.keys(state).forEach(function(key) { + if (state[key]) { + ret = codeCache[key].on + ret; + } + }); + + if (lastBackgroundAdded && lastBackgroundAdded != '\u001b[49m') { + ret = lastBackgroundAdded + ret; + } + if (lastForegroundAdded && lastForegroundAdded != '\u001b[39m') { + ret = lastForegroundAdded + ret; + } + + return ret; +} + +function truncateWidth(str, desiredLength) { + if (str.length === strlen(str)) { + return str.substr(0, desiredLength); + } + + while (strlen(str) > desiredLength) { + str = str.slice(0, -1); + } + + return str; +} + +function truncateWidthWithAnsi(str, desiredLength) { + let code = codeRegex(true); + let split = str.split(codeRegex()); + let splitIndex = 0; + let retLen = 0; + let ret = ''; + let myArray; + let state = {}; + + while (retLen < desiredLength) { + myArray = code.exec(str); + let toAdd = split[splitIndex]; + splitIndex++; + if (retLen + strlen(toAdd) > desiredLength) { + toAdd = truncateWidth(toAdd, desiredLength - retLen); + } + ret += toAdd; + retLen += strlen(toAdd); + + if (retLen < desiredLength) { + if (!myArray) { + break; + } // full-width chars may cause a whitespace which cannot be filled + ret += myArray[0]; + updateState(state, myArray); + } + } + + return unwindState(state, ret); +} + +function truncate(str, desiredLength, truncateChar) { + truncateChar = truncateChar || '…'; + let lengthOfStr = strlen(str); + if (lengthOfStr <= desiredLength) { + return str; + } + desiredLength -= strlen(truncateChar); + + let ret = truncateWidthWithAnsi(str, desiredLength); + + return ret + truncateChar; +} + +function defaultOptions() { + return { + chars: { + top: '─', + 'top-mid': '┬', + 'top-left': '┌', + 'top-right': '┐', + bottom: '─', + 'bottom-mid': '┴', + 'bottom-left': '└', + 'bottom-right': '┘', + left: '│', + 'left-mid': '├', + mid: '─', + 'mid-mid': '┼', + right: '│', + 'right-mid': '┤', + middle: '│', + }, + truncate: '…', + colWidths: [], + rowHeights: [], + colAligns: [], + rowAligns: [], + style: { + 'padding-left': 1, + 'padding-right': 1, + head: ['red'], + border: ['grey'], + compact: false, + }, + head: [], + }; +} + +function mergeOptions(options, defaults) { + options = options || {}; + defaults = defaults || defaultOptions(); + let ret = objectAssign({}, defaults, options); + ret.chars = objectAssign({}, defaults.chars, options.chars); + ret.style = objectAssign({}, defaults.style, options.style); + return ret; +} + +function wordWrap(maxLength, input) { + let lines = []; + let split = input.split(/(\s+)/g); + let line = []; + let lineLength = 0; + let whitespace; + for (let i = 0; i < split.length; i += 2) { + let word = split[i]; + let newLength = lineLength + strlen(word); + if (lineLength > 0 && whitespace) { + newLength += whitespace.length; + } + if (newLength > maxLength) { + if (lineLength !== 0) { + lines.push(line.join('')); + } + line = [word]; + lineLength = strlen(word); + } else { + line.push(whitespace || '', word); + lineLength = newLength; + } + whitespace = split[i + 1]; + } + if (lineLength) { + lines.push(line.join('')); + } + return lines; +} + +function multiLineWordWrap(maxLength, input) { + let output = []; + input = input.split('\n'); + for (let i = 0; i < input.length; i++) { + output.push.apply(output, wordWrap(maxLength, input[i])); + } + return output; +} + +function colorizeLines(input) { + let state = {}; + let output = []; + for (let i = 0; i < input.length; i++) { + let line = rewindState(state, input[i]); + state = readState(line); + let temp = objectAssign({}, state); + output.push(unwindState(temp, line)); + } + return output; +} + +module.exports = { + strlen: strlen, + repeat: repeat, + pad: pad, + truncate: truncate, + mergeOptions: mergeOptions, + wordWrap: multiLineWordWrap, + colorizeLines: colorizeLines, +}; diff --git a/node_modules/npm-audit-report/package.json b/node_modules/npm-audit-report/package.json index 68d197b6f21fe..af57b319099b5 100644 --- a/node_modules/npm-audit-report/package.json +++ b/node_modules/npm-audit-report/package.json @@ -1,28 +1,30 @@ { - "_from": "npm-audit-report@latest", - "_id": "npm-audit-report@1.2.1", + "_from": "npm-audit-report@1.3.2", + "_id": "npm-audit-report@1.3.2", "_inBundle": false, - "_integrity": "sha512-1eh6z0FivYQkLIU5xYcal8ssiGAgn0817u56EcF751HJD0m1PbAxurM/mc9WmAm3vhNZGkExleU/55VN/WRjFw==", + "_integrity": "sha512-abeqS5ONyXNaZJPGAf6TOUMNdSe1Y6cpc9MLBRn+CuUoYbfdca6AxOyXVlfIv9OgKX+cacblbG5w7A6ccwoTPw==", "_location": "/npm-audit-report", - "_phantomChildren": {}, + "_phantomChildren": { + "strip-ansi": "4.0.0" + }, "_requested": { - "type": "tag", + "type": "version", "registry": true, - "raw": "npm-audit-report@latest", + "raw": "npm-audit-report@1.3.2", "name": "npm-audit-report", "escapedName": "npm-audit-report", - "rawSpec": "latest", + "rawSpec": "1.3.2", "saveSpec": null, - "fetchSpec": "latest" + "fetchSpec": "1.3.2" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/npm-audit-report/-/npm-audit-report-1.2.1.tgz", - "_shasum": "14813e9551f0f33088e7acc442e83ea6d627ef13", - "_spec": "npm-audit-report@latest", - "_where": "/Users/zkat/Documents/code/work/npm", + "_resolved": "https://registry.npmjs.org/npm-audit-report/-/npm-audit-report-1.3.2.tgz", + "_shasum": "303bc78cd9e4c226415076a4f7e528c89fc77018", + "_spec": "npm-audit-report@1.3.2", + "_where": "/Users/tanohzana/Documents/projets/cli", "author": { "name": "Adam Baldwin" }, @@ -31,7 +33,7 @@ }, "bundleDependencies": false, "dependencies": { - "cli-table2": "^0.2.0", + "cli-table3": "^0.5.0", "console-control-strings": "^1.1.0" }, "deprecated": false, @@ -76,5 +78,5 @@ "update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'", "update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'" }, - "version": "1.2.1" + "version": "1.3.2" } diff --git a/node_modules/npm-audit-report/reporters/detail.js b/node_modules/npm-audit-report/reporters/detail.js index f4f96b6771d02..f6e822eb7ae6f 100644 --- a/node_modules/npm-audit-report/reporters/detail.js +++ b/node_modules/npm-audit-report/reporters/detail.js @@ -1,7 +1,7 @@ 'use strict' const summary = require('./install.js').summary -const Table = require('cli-table2') +const Table = require('cli-table3') const Utils = require('../lib/utils') const report = function (data, options) { @@ -37,17 +37,8 @@ const report = function (data, options) { } const footer = function (data) { - let total = 0 - const sev = [] - - const keys = Object.keys(data.metadata.vulnerabilities) - for (let key of keys) { - const value = data.metadata.vulnerabilities[key] - total = total + value - if (value > 0) { - sev.push([key, value]) - } - } + const total = Utils.totalVulnCount(data.metadata.vulnerabilities) + if (total > 0) { exit = 1 } @@ -126,7 +117,7 @@ const report = function (data, options) { {'Package': advisory.module_name}, {'Dependency of': `${resolution.path.split('>')[0]} ${resolution.dev ? '[dev]' : ''}`}, {'Path': `${resolution.path.split('>').join(Utils.color(' > ', 'grey', config.withColor))}`}, - {'More info': `https://nodesecurity.io/advisories/${advisory.id}`} + {'More info': advisory.url || `https://www.npmjs.com/advisories/${advisory.id}`} ) log(table.toString() + '\n\n') @@ -169,7 +160,7 @@ const report = function (data, options) { {'Patched in': patchedIn}, {'Dependency of': `${resolution.path.split('>')[0]} ${resolution.dev ? '[dev]' : ''}`}, {'Path': `${resolution.path.split('>').join(Utils.color(' > ', 'grey', config.withColor))}`}, - {'More info': `https://nodesecurity.io/advisories/${advisory.id}`} + {'More info': advisory.url || `https://www.npmjs.com/advisories/${advisory.id}`} ) log(table.toString()) }) diff --git a/node_modules/npm-audit-report/reporters/install.js b/node_modules/npm-audit-report/reporters/install.js index 00d3583936b6d..96ea12bd814e4 100644 --- a/node_modules/npm-audit-report/reporters/install.js +++ b/node_modules/npm-audit-report/reporters/install.js @@ -43,17 +43,8 @@ function summary (data, options) { log(`${green('0')} vulnerabilities`) return output } else { - let total = 0 - const sev = [] - - const keys = Object.keys(data.metadata.vulnerabilities) - for (let key of keys) { - const value = data.metadata.vulnerabilities[key] - total = total + value - if (value > 0) { - sev.push([key, value]) - } - } + const total = Utils.totalVulnCount(data.metadata.vulnerabilities) + const sev = Utils.severities(data.metadata.vulnerabilities) if (sev.length > 1) { const severities = sev.map((value) => { diff --git a/node_modules/npm-audit-report/reporters/parseable.js b/node_modules/npm-audit-report/reporters/parseable.js new file mode 100644 index 0000000000000..1d46ef22716cd --- /dev/null +++ b/node_modules/npm-audit-report/reporters/parseable.js @@ -0,0 +1,99 @@ +'use strict' + +const report = function (data, options) { + const defaults = { + severityThreshold: 'info' + } + + const config = Object.assign({}, defaults, options) + + let exit = 0 + + const actions = function (data, config) { + let accumulator = { + critical: '', + high: '', + moderate: '', + low: '' + } + + if (Object.keys(data.advisories).length !== 0) { + data.actions.forEach((action) => { + let l = {} + // Start with install/update actions + if (action.action === 'update' || action.action === 'install') { + const recommendation = getRecommendation(action, config) + l.recommendation = recommendation.cmd + l.breaking = recommendation.isBreaking ? 'Y' : 'N' + + action.resolves.forEach((resolution) => { + const advisory = data.advisories[resolution.id] + + l.sevLevel = advisory.severity + l.severity = advisory.title + l.package = advisory.module_name + l.moreInfo = advisory.url || `https://www.npmjs.com/advisories/${advisory.id}` + l.path = resolution.path + + accumulator[advisory.severity] += [action.action, l.package, l.sevLevel, l.recommendation, l.severity, l.moreInfo, l.path, l.breaking] + .join('\t') + '\n' + }) // forEach resolves + } + + if (action.action === 'review') { + action.resolves.forEach((resolution) => { + const advisory = data.advisories[resolution.id] + + l.sevLevel = advisory.severity + l.severity = advisory.title + l.package = advisory.module_name + l.moreInfo = advisory.url || `https://www.npmjs.com/advisories/${advisory.id}` + l.patchedIn = advisory.patched_versions.replace(' ', '') === '<0.0.0' ? 'No patch available' : advisory.patched_versions + l.path = resolution.path + + accumulator[advisory.severity] += [action.action, l.package, l.sevLevel, l.patchedIn, l.severity, l.moreInfo, l.path].join('\t') + '\n' + }) // forEach resolves + } // is review + }) // forEach actions + } + return accumulator['critical'] + accumulator['high'] + accumulator['moderate'] + accumulator['low'] + } + + const exitCode = function (metadata) { + let total = 0 + const keys = Object.keys(metadata.vulnerabilities) + for (let key of keys) { + const value = metadata.vulnerabilities[key] + total = total + value + } + + if (total > 0) { + exit = 1 + } + } + + exitCode(data.metadata) + + return { + report: actions(data, config), + exitCode: exit + } +} + +const getRecommendation = function (action, config) { + if (action.action === 'install') { + const isDev = action.resolves[0].dev + + return { + cmd: `npm install ${isDev ? '--save-dev ' : ''}${action.module}@${action.target}`, + isBreaking: action.isMajor + } + } else { + return { + cmd: `npm update ${action.module} --depth ${action.depth}`, + isBreaking: false + } + } +} + +module.exports = report diff --git a/node_modules/npm-audit-report/reporters/quiet.js b/node_modules/npm-audit-report/reporters/quiet.js index 3a5fd5eb9bd36..d6f5c5846b98b 100644 --- a/node_modules/npm-audit-report/reporters/quiet.js +++ b/node_modules/npm-audit-report/reporters/quiet.js @@ -1,17 +1,13 @@ 'use strict' -const report = function (data, options) { - let total = 0 +const Utils = require('../lib/utils') - const keys = Object.keys(data.metadata.vulnerabilities) - for (let key of keys) { - const value = data.metadata.vulnerabilities[key] - total = total + value - } +const report = function (data) { + const totalVulnCount = Utils.totalVulnCount(data.metadata.vulnerabilities) return { report: '', - exitCode: total === 0 ? 0 : 1 + exitCode: totalVulnCount === 0 ? 0 : 1 } } diff --git a/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE b/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE index 4028ccd3fa674..84354d959e33b 100755 --- a/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE +++ b/node_modules/request/node_modules/hawk/node_modules/cryptiles/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2014-2017, Eran Hammer and Project contributors +Copyright (c) 2014-2018, Eran Hammer and Project contributors All rights reserved. Redistribution and use in source and binary forms, with or without @@ -22,7 +22,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - * * * - -The complete list of contributors can be found at: https://github.com/hueniverse/cryptiles/graphs/contributors diff --git a/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md b/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md index b3df9e67ff391..cf50bb10385a5 100755 --- a/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md +++ b/node_modules/request/node_modules/hawk/node_modules/cryptiles/README.md @@ -1,19 +1,19 @@ -cryptiles -========= - -General purpose crypto utilities - -[![Build Status](https://secure.travis-ci.org/hapijs/cryptiles.png)](http://travis-ci.org/hapijs/cryptiles) - -Lead Maintainer - [C J Silverio](https://github.com/ceejbot) - -## Methods - -### `randomString( size)` -Returns a cryptographically strong pseudo-random data string. Takes a size argument for the length of the string. - -### `randomDigits( size)` -Returns a cryptographically strong pseudo-random data string consisting of only numerical digits (0-9). Takes a size argument for the length of the string. - -### `fixedTimeComparison( a, b)` -Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match). Returns `true` if the strings match, `false` if they differ. +cryptiles +========= + +General purpose crypto utilities + +[![Build Status](https://secure.travis-ci.org/hapijs/cryptiles.png)](http://travis-ci.org/hapijs/cryptiles) + +Lead Maintainer - [C J Silverio](https://github.com/ceejbot) + +## Methods + +### `randomString( size)` +Returns a cryptographically strong pseudo-random data string. Takes a size argument for the length of the string. + +### `randomDigits( size)` +Returns a cryptographically strong pseudo-random data string consisting of only numerical digits (0-9). Takes a size argument for the length of the string. + +### `fixedTimeComparison( a, b)` +Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match). Returns `true` if the strings match, `false` if they differ. diff --git a/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js b/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js index 511eab66d409f..3f15fe770fa6d 100755 --- a/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js +++ b/node_modules/request/node_modules/hawk/node_modules/cryptiles/lib/index.js @@ -1,88 +1,101 @@ -'use strict'; - -// Load modules - -const Crypto = require('crypto'); -const Boom = require('boom'); - - -// Declare internals - -const internals = {}; - - -// Generate a cryptographically strong pseudo-random data - -exports.randomString = function (size) { - - const buffer = exports.randomBits((size + 1) * 6); - if (buffer instanceof Error) { - return buffer; - } - - const string = buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, ''); - return string.slice(0, size); -}; - - -// Return a random string of digits - -exports.randomDigits = function (size) { - - const buffer = exports.randomBits(size * 8); - if (buffer instanceof Error) { - return buffer; - } - - const digits = []; - for (let i = 0; i < buffer.length; ++i) { - digits.push(Math.floor(buffer[i] / 25.6)); - } - - return digits.join(''); -}; - - -// Generate a buffer of random bits - -exports.randomBits = function (bits) { - - if (!bits || - bits < 0) { - - return Boom.internal('Invalid random bits count'); - } - - const bytes = Math.ceil(bits / 8); - try { - return Crypto.randomBytes(bytes); - } - catch (err) { - return Boom.internal('Failed generating random bits: ' + err.message); - } -}; - - -// Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match) - -exports.fixedTimeComparison = function (a, b) { - - if (typeof a !== 'string' || - typeof b !== 'string') { - - return false; - } - - let mismatch = (a.length === b.length ? 0 : 1); - if (mismatch) { - b = a; - } - - for (let i = 0; i < a.length; ++i) { - const ac = a.charCodeAt(i); - const bc = b.charCodeAt(i); - mismatch |= (ac ^ bc); - } - - return (mismatch === 0); -}; +'use strict'; + +// Load modules + +const Crypto = require('crypto'); + +const Boom = require('boom'); + + +// Declare internals + +const internals = {}; + + +// Generate a cryptographically strong pseudo-random data + +exports.randomString = function (size) { + + const buffer = exports.randomBits((size + 1) * 6); + if (buffer instanceof Error) { + return buffer; + } + + const string = buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, ''); + return string.slice(0, size); +}; + + +// Return a random string of digits + +exports.randomDigits = function (size) { + + try { + const digits = []; + + let buffer = internals.random(size * 2); // Provision twice the amount of bytes needed to increase chance of single pass + let pos = 0; + + while (digits.length < size) { + if (pos >= buffer.length) { + buffer = internals.random(size * 2); + pos = 0; + } + + if (buffer[pos] < 250) { + digits.push(buffer[pos] % 10); + } + + ++pos; + } + + return digits.join(''); + } + catch (err) { + return err; + } +}; + + +// Generate a buffer of random bits + +exports.randomBits = function (bits) { + + if (!bits || + bits < 0) { + + return Boom.internal('Invalid random bits count'); + } + + const bytes = Math.ceil(bits / 8); + try { + return internals.random(bytes); + } + catch (err) { + return err; + } +}; + + +// Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match) + +exports.fixedTimeComparison = function (a, b) { + + try { + return Crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b)); + } + catch (err) { + return false; + } +}; + + +internals.random = function (bytes) { + + try { + return Crypto.randomBytes(bytes); + } + catch (err) { + throw Boom.internal('Failed generating random bits: ' + err.message); + } +}; diff --git a/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json b/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json index a78856528fcab..43082334c311f 100755 --- a/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json +++ b/node_modules/request/node_modules/hawk/node_modules/cryptiles/package.json @@ -1,29 +1,29 @@ { - "_from": "cryptiles@3.x.x", - "_id": "cryptiles@3.1.2", + "_from": "cryptiles@3.1.4", + "_id": "cryptiles@3.1.4", "_inBundle": false, - "_integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", + "_integrity": "sha512-8I1sgZHfVwcSOY6mSGpVU3lw/GSIZvusg8dD2+OGehCJpOhQRLNcH0qb9upQnOH4XhgxxFJSg6E2kx95deb1Tw==", "_location": "/request/hawk/cryptiles", "_phantomChildren": { - "hoek": "4.2.0" + "hoek": "4.2.1" }, "_requested": { - "type": "range", + "type": "version", "registry": true, - "raw": "cryptiles@3.x.x", + "raw": "cryptiles@3.1.4", "name": "cryptiles", "escapedName": "cryptiles", - "rawSpec": "3.x.x", + "rawSpec": "3.1.4", "saveSpec": null, - "fetchSpec": "3.x.x" + "fetchSpec": "3.1.4" }, "_requiredBy": [ "/request/hawk" ], - "_resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "_shasum": "a89fbb220f5ce25ec56e8c4aa8a4fd7b5b0d29fe", - "_spec": "cryptiles@3.x.x", - "_where": "/Users/rebecca/code/npm/node_modules/request/node_modules/hawk", + "_resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.4.tgz", + "_shasum": "769a68c95612b56faadfcebf57ac86479cbe8322", + "_spec": "cryptiles@3.1.4", + "_where": "/Users/tanohzana/Documents/projets/cli/node_modules/request/node_modules/hawk", "bugs": { "url": "https://github.com/hapijs/cryptiles/issues" }, @@ -37,9 +37,6 @@ "code": "4.x.x", "lab": "13.x.x" }, - "engines": { - "node": ">=4.0.0" - }, "homepage": "https://github.com/hapijs/cryptiles#readme", "keywords": [ "cryptography", @@ -54,8 +51,8 @@ "url": "git://github.com/hapijs/cryptiles.git" }, "scripts": { - "test": "lab -a code -t 100 -L", - "test-cov-html": "lab -a code -r html -o coverage.html" + "test": "lab -a code -t 100 -I SharedArrayBuffer,Atomics,BigUint64Array,BigInt64Array,BigInt,URL,URLSearchParams -m 30000", + "test-cov-html": "lab -a code -I SharedArrayBuffer,Atomics,BigUint64Array,BigInt64Array,BigInt,URL,URLSearchParams -m 30000 -r html -o coverage.html" }, - "version": "3.1.2" + "version": "3.1.4" } diff --git a/package-lock.json b/package-lock.json index c1bc6c6835062..93338237f5e26 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2448,14 +2448,53 @@ } }, "npm-audit-report": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/npm-audit-report/-/npm-audit-report-1.2.1.tgz", - "integrity": "sha512-1eh6z0FivYQkLIU5xYcal8ssiGAgn0817u56EcF751HJD0m1PbAxurM/mc9WmAm3vhNZGkExleU/55VN/WRjFw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/npm-audit-report/-/npm-audit-report-1.3.2.tgz", + "integrity": "sha512-abeqS5ONyXNaZJPGAf6TOUMNdSe1Y6cpc9MLBRn+CuUoYbfdca6AxOyXVlfIv9OgKX+cacblbG5w7A6ccwoTPw==", "requires": { - "cli-table2": "^0.2.0", + "cli-table3": "^0.5.0", "console-control-strings": "^1.1.0" }, "dependencies": { + "cli-table3": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/cli-table3/-/cli-table3-0.5.1.tgz", + "integrity": "sha512-7Qg2Jrep1S/+Q3EceiZtQcDPWxhAvBw+ERf1162v4sikJrvojMHFqXt8QIVha8UlH9rgU0BeWPytZ9/TzYqlUw==", + "requires": { + "colors": "^1.1.2", + "object-assign": "^4.1.0", + "string-width": "^2.1.1" + }, + "dependencies": { + "colors": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", + "optional": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "string-width": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", + "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "requires": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^4.0.0" + }, + "dependencies": { + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + } + } + } + } + }, "console-control-strings": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", @@ -3422,27 +3461,69 @@ } }, "nano": { - "version": "6.4.4", - "resolved": "https://registry.npmjs.org/nano/-/nano-6.4.4.tgz", - "integrity": "sha512-7sldMrZI1ZH8QE29PnzohxLfR67WNVzMKLa7EMl3x9Hr+0G+YpOUCq50qZ9G66APrjcb0Of2BTOZLNBCutZGag==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/nano/-/nano-8.0.0.tgz", + "integrity": "sha512-NpBzSEkfQ6Amc1n0ySa8OiOtz7Q6F/kT9YUARmcJFwSiX8scKU4V6riP8Q80lQR5A8VT5h3Mk2+YZJHQ65IfxA==", "dev": true, "requires": { - "cloudant-follow": "~0.17.0", + "@types/request": "^2.47.1", + "cloudant-follow": "^0.18.0", "debug": "^2.2.0", "errs": "^0.3.2", "lodash.isempty": "^4.4.0", "request": "^2.85.0" }, "dependencies": { + "@types/request": { + "version": "2.48.1", + "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.1.tgz", + "integrity": "sha512-ZgEZ1TiD+KGA9LiAAPPJL68Id2UWfeSO62ijSXZjFJArVV+2pKcsVHmrcu+1oiE3q6eDGiFiSolRc4JHoerBBg==", + "dev": true, + "requires": { + "@types/caseless": "*", + "@types/form-data": "*", + "@types/node": "*", + "@types/tough-cookie": "*" + }, + "dependencies": { + "@types/caseless": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/@types/caseless/-/caseless-0.12.1.tgz", + "integrity": "sha512-FhlMa34NHp9K5MY1Uz8yb+ZvuX0pnvn3jScRSNAb75KHGB8d3rEU6hqMs3Z2vjuytcMfRg6c5CHMc3wtYyD2/A==", + "dev": true + }, + "@types/form-data": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@types/form-data/-/form-data-2.2.1.tgz", + "integrity": "sha512-JAMFhOaHIciYVh8fb5/83nmuO/AHwmto+Hq7a9y8FzLDcC1KCU344XDOMEmahnrTFlHjgh4L0WJFczNIX2GxnQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==", + "dev": true + }, + "@types/tough-cookie": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-Set5ZdrAaKI/qHdFlVMgm/GsAv/wkXhSTuZFkJ+JI7HK+wIkIlOaUXSXieIvJ0+OvGIqtREFoE+NHJtEq0gtEw==", + "dev": true + } + } + }, "cloudant-follow": { - "version": "0.17.0", - "resolved": "https://registry.npmjs.org/cloudant-follow/-/cloudant-follow-0.17.0.tgz", - "integrity": "sha512-JQ1xvKAHh8rsnSVBjATLCjz/vQw1sWBGadxr2H69yFMwD7hShUGDwwEefdypaxroUJ/w6t1cSwilp/hRUxEW8w==", + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/cloudant-follow/-/cloudant-follow-0.18.0.tgz", + "integrity": "sha512-jsplCsI0EpJvTrlgeuuYFrmrKGxm8TlSkyKzOLZa6fc6p+FNT8UDPAwYeh0yaT8IdI+sxT5DTdCD2G45HWpSaw==", "dev": true, "requires": { "browser-request": "~0.3.0", - "debug": "^3.0.0", - "request": "^2.83.0" + "debug": "^4.0.1", + "request": "^2.88.0" }, "dependencies": { "browser-request": { @@ -3452,18 +3533,420 @@ "dev": true }, "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" }, "dependencies": { "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "request": { + "version": "2.88.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", + "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.0", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.4.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=", + "dev": true + }, + "aws4": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.8.0.tgz", + "integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==", + "dev": true + }, + "caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", + "dev": true + }, + "combined-stream": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz", + "integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==", + "dev": true, + "requires": { + "delayed-stream": "~1.0.0" + }, + "dependencies": { + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true + } + } + }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true + }, + "forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=", + "dev": true + }, + "form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "dependencies": { + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true + } + } + }, + "har-validator": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.3.tgz", + "integrity": "sha512-sNvOCzEQNr/qrvJgc3UG/kD4QtlHycrzwS+6mfTrrSq97BvaYcPZZI1ZSqGSPR73Cxn4LKTD4PttRwfU7jWq5g==", + "dev": true, + "requires": { + "ajv": "^6.5.5", + "har-schema": "^2.0.0" + }, + "dependencies": { + "ajv": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.6.2.tgz", + "integrity": "sha512-FBHEW6Jf5TB9MGBgUUA9XHkTbjXYfAUjY43ACMfmdMRHniyoMHjHjzD50OK8LGDWQwp4rWEsIq5kEqq7rvIM1g==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "dependencies": { + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "uri-js": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.2.2.tgz", + "integrity": "sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + }, + "dependencies": { + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + } + } + } + } + }, + "har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=", + "dev": true + } + } + }, + "http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + }, + "dependencies": { + "assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=", + "dev": true + }, + "jsprim": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", + "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", + "dev": true, + "requires": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.2.3", + "verror": "1.10.0" + }, + "dependencies": { + "extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=", + "dev": true + }, + "json-schema": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", + "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=", + "dev": true + }, + "verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + }, + "dependencies": { + "core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", + "dev": true + } + } + } + } + }, + "sshpk": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.16.0.tgz", + "integrity": "sha512-Zhev35/y7hRMcID/upReIvRse+I9SVhyVre/KTJSJQWMz3C3+G+HpO7m1wK/yckEtujKZ7dS4hkVxAnmHaIGVQ==", + "dev": true, + "requires": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + }, + "dependencies": { + "asn1": { + "version": "0.2.4", + "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", + "integrity": "sha512-jxwzQpLQjSmWXgwaCZE9Nz+glAG01yF1QnWgbhGwHI5A6FRIEY6IVqtHhIepHqI7/kyEyQEagBC5mBEFlIYvdg==", + "dev": true, + "requires": { + "safer-buffer": "~2.1.0" + } + }, + "bcrypt-pbkdf": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", + "integrity": "sha1-pDAdOJtqQ/m2f/PKEaP2Y342Dp4=", + "dev": true, + "requires": { + "tweetnacl": "^0.14.3" + } + }, + "dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha1-OoOpBOVDUyh4dMVkt1SThoSamMk=", + "dev": true, + "requires": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, + "getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", + "dev": true, + "requires": { + "assert-plus": "^1.0.0" + } + }, + "jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", + "dev": true + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==", + "dev": true + }, + "tweetnacl": { + "version": "0.14.5", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", + "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", + "dev": true + } + } + } + } + }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, + "isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=", + "dev": true + }, + "json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", + "dev": true + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "dev": true, + "requires": { + "mime-db": "~1.37.0" + }, + "dependencies": { + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==", + "dev": true + } + } + }, + "oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "dev": true + }, + "performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", + "dev": true + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true + }, + "tough-cookie": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", + "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, + "requires": { + "psl": "^1.1.24", + "punycode": "^1.4.1" + }, + "dependencies": { + "psl": { + "version": "1.1.31", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", + "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "dev": true + }, + "punycode": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", + "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=", + "dev": true + } + } + }, + "tunnel-agent": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", + "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", + "dev": true, + "requires": { + "safe-buffer": "^5.0.1" + } + }, + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", "dev": true } } @@ -4916,9 +5399,9 @@ } }, "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.4.tgz", + "integrity": "sha512-8I1sgZHfVwcSOY6mSGpVU3lw/GSIZvusg8dD2+OGehCJpOhQRLNcH0qb9upQnOH4XhgxxFJSg6E2kx95deb1Tw==", "requires": { "boom": "5.x.x" }, diff --git a/package.json b/package.json index cbbf382ee0abd..e0cc4b3523a39 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "node-gyp": "^3.6.2", "nopt": "~4.0.1", "normalize-package-data": "~2.4.0", - "npm-audit-report": "^1.2.1", + "npm-audit-report": "^1.3.2", "npm-cache-filename": "~1.0.2", "npm-install-checks": "~3.0.0", "npm-lifecycle": "^2.0.3", diff --git a/test/tap/mp.js b/test/tap/mp.js new file mode 100644 index 0000000000000..4022532d4a9ad --- /dev/null +++ b/test/tap/mp.js @@ -0,0 +1,216 @@ +"use strict" +const common = require("../common-tap.js") +const path = require("path") +const mr = require('npm-registry-mock') +const fs = require('graceful-fs') +const test = require("tap").test +const rimraf = require("rimraf") +const basePath = path.resolve(__dirname, path.basename(__filename, ".js")) +const fixturePath = path.resolve(basePath, "npm-test-files") +const testDirPath = path.resolve(fixturePath, "npm-test-mp") +const Tacks = require("tacks") +const File = Tacks.File +const Dir = Tacks.Dir + +const jsFile1 = "require('uninstalledDep1')" +const jsFile2 = "require('dep1'); require('dep2')" +const jsFile3 = "require('dep1'); require('dep3')" +const jsFile4 = "require('underscore')" + +let server + +test("setup", (t) => { + cleanup() + + mr({ port: common.port }, (err, s) => { + t.ifError(err) + server = s + t.end() + }) +}) + +test("mp check simple file", (t) => { + const fixture = new Tacks(Dir({ + "npm-test-mp": Dir({ + "package.json": File({ + name: "npm-test-mp", + version: "1.0.0", + dependencies: { + dep1: "installedDep1" + } + }), + "file1.js": File(jsFile1) + }) + })) + + withFixture(t, fixture, (done) => { + common.npm(["mp", "check", "./file1.js"], { + cwd: testDirPath + }, function(err, code, stdout, stderr) { + t.ifErr(err, "mp succeeded") + t.equal(0, code, "exit 0 on mp") + // Removes special characters and emojis + const message = stdout.trim().substr(3) + t.same(message, "Package(s) to install: uninstalledDep1") + done() + }) + }) +}) + +test("mp c (check) simple file", (t) => { + const fixture = new Tacks(Dir({ + "npm-test-mp": Dir({ + "package.json": File({ + name: "npm-test-mp", + version: "1.0.0", + dependencies: { + dep1: "installedDep1" + } + }), + "file1.js": File(jsFile1) + }) + })) + + withFixture(t, fixture, (done) => { + common.npm(["mp", "c", "./file1.js"], { + cwd: testDirPath + }, function(err, code, stdout, stderr) { + t.ifErr(err, "mp succeeded") + t.equal(0, code, "exit 0 on mp") + // Removes special characters and emojis + const message = stdout.trim().substr(3) + t.same(message, "Package(s) to install: uninstalledDep1") + done() + }) + }) +}) + +test("mp check folder", (t) => { + const fixture = new Tacks(Dir({ + "npm-test-mp": Dir({ + "package.json": File({ + name: "npm-test-mp", + version: "1.0.0", + dependencies: { + dep1: "installedDep1" + } + }), + "file2.js": File(jsFile2), + "file3.js": File(jsFile3) + }) + })) + + withFixture(t, fixture, (done) => { + common.npm(["mp", "check", "."], { + cwd: testDirPath + }, function(err, code, stdout, stderr) { + t.ifErr(err, "mp succeeded") + t.equal(0, code, "exit 0 on mp") + // Removes special characters and emojis + const message = stdout.trim().substr(3) + t.same(message, "Package(s) to install: dep2,dep3") + done() + }) + }) +}) + +test("mp check folder but all installed", (t) => { + const fixture = new Tacks(Dir({ + "npm-test-mp": Dir({ + "package.json": File({ + name: "npm-test-mp", + version: "1.0.0", + dependencies: { + dep1: "installedDep1", + dep2: "installedDep2", + dep3: "installedDep3" + } + }), + "file2.js": File(jsFile2), + "file3.js": File(jsFile3) + }) + })) + + withFixture(t, fixture, (done) => { + common.npm(["mp", "check", "."], { + cwd: testDirPath + }, function(err, code, stdout, stderr) { + t.ifErr(err, "mp succeeded") + t.equal(0, code, "exit 0 on mp") + // Removes special characters and emojis + const message = stdout.trim().substr(2) + t.same(message, "No package to install") + done() + }) + }) +}) + +test("mp install missing deps in file", (t) => { + let runner + + const fixture = new Tacks(Dir({ + "npm-test-mp": Dir({ + "package.json": File({ + name: "npm-test-mp", + version: "1.0.0", + dependencies: { + dep1: "installedDep1", + } + }), + "file4.js": File(jsFile4) + }) + })) + + withFixture(t, fixture, (done) => { + runner = common.npm(["mp", "install", "file4.js"], { + cwd: testDirPath + }, (err, code, stdout, stderr) => { + t.ifErr(err, "mp install succeeded") + t.equal(code, 0, "exit 0 on mp install") + const packageJsonPath = path.resolve(testDirPath, "package.json") + const installedDeps = JSON.parse(fs.readFileSync(packageJsonPath, "utf8")).dependencies + const expected = ["dep1", "underscore"] + + t.same(Object.keys(installedDeps), expected) + done() + }) + + let remaining = 3 + + runner.stdout.on("data", (chunk) => { + remaining-- + + if (remaining === 2) { + runner.stdin.write("y") + runner.stdin.end() + } else if(remaining === 0) { + // Removes special characters and emojis + const message = chunk.toString('utf8').trim().substr(2) + t.equal(message, "Packages installed !") + } + }) + }) +}) + +test("cleanup", (t) => { + server.close() + cleanup() + t.end() +}) + +function cleanup () { + rimraf.sync(basePath) +} + +function withFixture (t, fixture, tester) { + fixture.create(fixturePath) + + tester(removeAndDone) + + function removeAndDone (err) { + if (err) throw err + fixture.remove(fixturePath) + rimraf.sync(basePath) + t.end() + } +} \ No newline at end of file