├── README.md ├── bin └── sl.js ├── lib └── index.js ├── node_modules ├── .yarn-integrity ├── ansi-styles │ ├── index.js │ ├── license │ ├── package.json │ └── readme.md ├── chalk │ ├── index.js │ ├── index.js.flow │ ├── license │ ├── package.json │ ├── readme.md │ ├── templates.js │ └── types │ │ └── index.d.ts ├── color-convert │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── conversions.js │ ├── index.js │ ├── package.json │ └── route.js ├── color-name │ ├── .eslintrc.json │ ├── .npmignore │ ├── LICENSE │ ├── README.md │ ├── index.js │ ├── package.json │ └── test.js ├── commander │ ├── CHANGELOG.md │ ├── LICENSE │ ├── Readme.md │ ├── index.js │ ├── package.json │ └── typings │ │ └── index.d.ts ├── escape-string-regexp │ ├── index.js │ ├── license │ ├── package.json │ └── readme.md ├── has-flag │ ├── index.js │ ├── license │ ├── package.json │ └── readme.md ├── source-map │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── dist │ │ └── source-map.js │ ├── lib │ │ ├── array-set.js │ │ ├── base64-vlq.js │ │ ├── base64.js │ │ ├── binary-search.js │ │ ├── mapping-list.js │ │ ├── mappings.wasm │ │ ├── read-wasm.js │ │ ├── source-map-consumer.js │ │ ├── source-map-generator.js │ │ ├── source-node.js │ │ ├── util.js │ │ └── wasm.js │ ├── package.json │ ├── source-map.d.ts │ └── source-map.js └── supports-color │ ├── browser.js │ ├── index.js │ ├── license │ ├── package.json │ └── readme.md ├── package-lock.json ├── package.json └── yarn.lock /README.md: -------------------------------------------------------------------------------- 1 | # Source-location 2 | > This is a cli to get location of original source code. 3 | 4 | ## Why use 5 | Since the production environment code is compiled code, the rows and columns that collect the error information cannot correspond in the source code. Source-location is a command-line widget used to locate the source code to help locate the source location quickly and improve efficiency. Before using this cli, you need to compile a map file of the production environment yourself. 6 | 7 | ## Install 8 | Install the source-location command line utility globally with npm. Elevated privileges might be needed via sudo, depending on the platform. In most cases just: 9 | ```bash 10 | npm install --global source-location 11 | ``` 12 | ## Command line options 13 | The output of source-location --help pretty much covers all the options: 14 | ```bash 15 | Usage: sl [options] 16 | 17 | Options: 18 | -v, --version output the version number 19 | -p, --source-flie-path The generated source file 20 | -l, --ine The line number in the generated source 21 | -c, --column The column number in the generated source 22 | -h, --help output usage information 23 | ``` 24 | 25 | ## Testing 26 | use the following commands 27 | ```bash 28 | sl -p dist/1.f47efcb58028826c7c05.js.map -l 1 -c 34 29 | ``` 30 | output: 31 | ```bash 32 | sourcecode info: 33 | sourceCodePath: webpack:///src/pages/common/403.vue // 34 | line: 4 35 | column: 15 36 | name: export 37 | ``` 38 | 39 | ## Output properties 40 | sourceCodePath: The original source file, or null if this information is not available. 41 | line: The line number in the original source, or null if this information is not available. The line number is 1-based. 42 | column: The column number in the original source, or null if this information is not available. The column number is 0-based. 43 | name: The original identifier, or null if this information is not available. 44 | -------------------------------------------------------------------------------- /bin/sl.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const searchSource = require ('../lib/index.js') 4 | const chalk = require('chalk'); 5 | const pkg = require('../package.json'); 6 | const log = console.log 7 | var program = require('commander'); 8 | program 9 | .version(pkg.version, '-v, --version') 10 | .option('-p, --source-flie-path', 'The generated source file') 11 | .option('-l, --ine', 'The line number in the generated source') 12 | .option('-c, --column', 'The column number in the generated source') 13 | .parse(process.argv); 14 | 15 | let optionsLen = program.args.length 16 | if(optionsLen != 3){ 17 | log(chalk.red('Please check the options')) 18 | program.help() 19 | return 20 | } 21 | 22 | const line = Number(program.args[1]) 23 | const column = Number(program.args[2]) 24 | const filePath = program.args[0] 25 | 26 | searchSource(filePath, line, column) 27 | .then(({source, line, column, name}) => { 28 | log(chalk.yellow('sourcecode info:')); 29 | log(chalk.blue('sourceCodePath') + ': ' + chalk.green(source)); 30 | log(chalk.blue('line') + ': ' + chalk.green(line)); 31 | log(chalk.blue('column') + ': ' + chalk.green(column)); 32 | log(chalk.blue('name') + ': ' + chalk.green(name)); 33 | }) 34 | .catch((err) => { 35 | log(chalk.red(err)) 36 | program.help() 37 | }) 38 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | // Get file content 4 | const sourceMap = require('source-map'); 5 | const readFile = function (filePath) { 6 | return new Promise(function (resolve, reject) { 7 | fs.readFile(filePath, {encoding:'utf-8'}, function(error, data) { 8 | if (error) { 9 | console.log(error) 10 | return reject(error); 11 | } 12 | resolve(JSON.parse(data)); 13 | }); 14 | }); 15 | }; 16 | 17 | // Find the source location 18 | async function searchSource(filePath, line, column) { 19 | const rawSourceMap = await readFile(filePath) 20 | const consumer = await new sourceMap.SourceMapConsumer(rawSourceMap); 21 | const res = consumer.originalPositionFor({ 22 | 'line' : line, 23 | 'column' : column 24 | }); 25 | consumer.destroy() 26 | return res 27 | } 28 | 29 | 30 | module.exports = searchSource 31 | -------------------------------------------------------------------------------- /node_modules/.yarn-integrity: -------------------------------------------------------------------------------- 1 | { 2 | "systemParams": "darwin-x64-64", 3 | "modulesFolders": [ 4 | "node_modules" 5 | ], 6 | "flags": [], 7 | "linkedModules": [], 8 | "topLevelPatterns": [ 9 | "chalk@^2.4.2", 10 | "commander@^2.19.0", 11 | "source-map@^0.7.3" 12 | ], 13 | "lockfileEntries": { 14 | "ansi-styles@^3.2.1": "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d", 15 | "chalk@^2.4.2": "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424", 16 | "color-convert@^1.9.0": "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8", 17 | "color-name@1.1.3": "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25", 18 | "commander@^2.19.0": "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a", 19 | "escape-string-regexp@^1.0.5": "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4", 20 | "has-flag@^3.0.0": "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd", 21 | "source-map@^0.7.3": "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383", 22 | "supports-color@^5.3.0": "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" 23 | }, 24 | "files": [], 25 | "artifacts": {} 26 | } -------------------------------------------------------------------------------- /node_modules/ansi-styles/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const colorConvert = require('color-convert'); 3 | 4 | const wrapAnsi16 = (fn, offset) => function () { 5 | const code = fn.apply(colorConvert, arguments); 6 | return `\u001B[${code + offset}m`; 7 | }; 8 | 9 | const wrapAnsi256 = (fn, offset) => function () { 10 | const code = fn.apply(colorConvert, arguments); 11 | return `\u001B[${38 + offset};5;${code}m`; 12 | }; 13 | 14 | const wrapAnsi16m = (fn, offset) => function () { 15 | const rgb = fn.apply(colorConvert, arguments); 16 | return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; 17 | }; 18 | 19 | function assembleStyles() { 20 | const codes = new Map(); 21 | const styles = { 22 | modifier: { 23 | reset: [0, 0], 24 | // 21 isn't widely supported and 22 does the same thing 25 | bold: [1, 22], 26 | dim: [2, 22], 27 | italic: [3, 23], 28 | underline: [4, 24], 29 | inverse: [7, 27], 30 | hidden: [8, 28], 31 | strikethrough: [9, 29] 32 | }, 33 | color: { 34 | black: [30, 39], 35 | red: [31, 39], 36 | green: [32, 39], 37 | yellow: [33, 39], 38 | blue: [34, 39], 39 | magenta: [35, 39], 40 | cyan: [36, 39], 41 | white: [37, 39], 42 | gray: [90, 39], 43 | 44 | // Bright color 45 | redBright: [91, 39], 46 | greenBright: [92, 39], 47 | yellowBright: [93, 39], 48 | blueBright: [94, 39], 49 | magentaBright: [95, 39], 50 | cyanBright: [96, 39], 51 | whiteBright: [97, 39] 52 | }, 53 | bgColor: { 54 | bgBlack: [40, 49], 55 | bgRed: [41, 49], 56 | bgGreen: [42, 49], 57 | bgYellow: [43, 49], 58 | bgBlue: [44, 49], 59 | bgMagenta: [45, 49], 60 | bgCyan: [46, 49], 61 | bgWhite: [47, 49], 62 | 63 | // Bright color 64 | bgBlackBright: [100, 49], 65 | bgRedBright: [101, 49], 66 | bgGreenBright: [102, 49], 67 | bgYellowBright: [103, 49], 68 | bgBlueBright: [104, 49], 69 | bgMagentaBright: [105, 49], 70 | bgCyanBright: [106, 49], 71 | bgWhiteBright: [107, 49] 72 | } 73 | }; 74 | 75 | // Fix humans 76 | styles.color.grey = styles.color.gray; 77 | 78 | for (const groupName of Object.keys(styles)) { 79 | const group = styles[groupName]; 80 | 81 | for (const styleName of Object.keys(group)) { 82 | const style = group[styleName]; 83 | 84 | styles[styleName] = { 85 | open: `\u001B[${style[0]}m`, 86 | close: `\u001B[${style[1]}m` 87 | }; 88 | 89 | group[styleName] = styles[styleName]; 90 | 91 | codes.set(style[0], style[1]); 92 | } 93 | 94 | Object.defineProperty(styles, groupName, { 95 | value: group, 96 | enumerable: false 97 | }); 98 | 99 | Object.defineProperty(styles, 'codes', { 100 | value: codes, 101 | enumerable: false 102 | }); 103 | } 104 | 105 | const ansi2ansi = n => n; 106 | const rgb2rgb = (r, g, b) => [r, g, b]; 107 | 108 | styles.color.close = '\u001B[39m'; 109 | styles.bgColor.close = '\u001B[49m'; 110 | 111 | styles.color.ansi = { 112 | ansi: wrapAnsi16(ansi2ansi, 0) 113 | }; 114 | styles.color.ansi256 = { 115 | ansi256: wrapAnsi256(ansi2ansi, 0) 116 | }; 117 | styles.color.ansi16m = { 118 | rgb: wrapAnsi16m(rgb2rgb, 0) 119 | }; 120 | 121 | styles.bgColor.ansi = { 122 | ansi: wrapAnsi16(ansi2ansi, 10) 123 | }; 124 | styles.bgColor.ansi256 = { 125 | ansi256: wrapAnsi256(ansi2ansi, 10) 126 | }; 127 | styles.bgColor.ansi16m = { 128 | rgb: wrapAnsi16m(rgb2rgb, 10) 129 | }; 130 | 131 | for (let key of Object.keys(colorConvert)) { 132 | if (typeof colorConvert[key] !== 'object') { 133 | continue; 134 | } 135 | 136 | const suite = colorConvert[key]; 137 | 138 | if (key === 'ansi16') { 139 | key = 'ansi'; 140 | } 141 | 142 | if ('ansi16' in suite) { 143 | styles.color.ansi[key] = wrapAnsi16(suite.ansi16, 0); 144 | styles.bgColor.ansi[key] = wrapAnsi16(suite.ansi16, 10); 145 | } 146 | 147 | if ('ansi256' in suite) { 148 | styles.color.ansi256[key] = wrapAnsi256(suite.ansi256, 0); 149 | styles.bgColor.ansi256[key] = wrapAnsi256(suite.ansi256, 10); 150 | } 151 | 152 | if ('rgb' in suite) { 153 | styles.color.ansi16m[key] = wrapAnsi16m(suite.rgb, 0); 154 | styles.bgColor.ansi16m[key] = wrapAnsi16m(suite.rgb, 10); 155 | } 156 | } 157 | 158 | return styles; 159 | } 160 | 161 | // Make the export immutable 162 | Object.defineProperty(module, 'exports', { 163 | enumerable: true, 164 | get: assembleStyles 165 | }); 166 | -------------------------------------------------------------------------------- /node_modules/ansi-styles/license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (sindresorhus.com) 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /node_modules/ansi-styles/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "ansi-styles@^3.2.1", 3 | "_id": "ansi-styles@3.2.1", 4 | "_inBundle": false, 5 | "_integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", 6 | "_location": "/ansi-styles", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "ansi-styles@^3.2.1", 12 | "name": "ansi-styles", 13 | "escapedName": "ansi-styles", 14 | "rawSpec": "^3.2.1", 15 | "saveSpec": null, 16 | "fetchSpec": "^3.2.1" 17 | }, 18 | "_requiredBy": [ 19 | "/chalk" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", 22 | "_shasum": "41fbb20243e50b12be0f04b8dedbf07520ce841d", 23 | "_spec": "ansi-styles@^3.2.1", 24 | "_where": "/Users/yuqing/Documents/source-location/node_modules/chalk", 25 | "author": { 26 | "name": "Sindre Sorhus", 27 | "email": "sindresorhus@gmail.com", 28 | "url": "sindresorhus.com" 29 | }, 30 | "ava": { 31 | "require": "babel-polyfill" 32 | }, 33 | "bugs": { 34 | "url": "https://github.com/chalk/ansi-styles/issues" 35 | }, 36 | "bundleDependencies": false, 37 | "dependencies": { 38 | "color-convert": "^1.9.0" 39 | }, 40 | "deprecated": false, 41 | "description": "ANSI escape codes for styling strings in the terminal", 42 | "devDependencies": { 43 | "ava": "*", 44 | "babel-polyfill": "^6.23.0", 45 | "svg-term-cli": "^2.1.1", 46 | "xo": "*" 47 | }, 48 | "engines": { 49 | "node": ">=4" 50 | }, 51 | "files": [ 52 | "index.js" 53 | ], 54 | "homepage": "https://github.com/chalk/ansi-styles#readme", 55 | "keywords": [ 56 | "ansi", 57 | "styles", 58 | "color", 59 | "colour", 60 | "colors", 61 | "terminal", 62 | "console", 63 | "cli", 64 | "string", 65 | "tty", 66 | "escape", 67 | "formatting", 68 | "rgb", 69 | "256", 70 | "shell", 71 | "xterm", 72 | "log", 73 | "logging", 74 | "command-line", 75 | "text" 76 | ], 77 | "license": "MIT", 78 | "name": "ansi-styles", 79 | "repository": { 80 | "type": "git", 81 | "url": "git+https://github.com/chalk/ansi-styles.git" 82 | }, 83 | "scripts": { 84 | "screenshot": "svg-term --command='node screenshot' --out=screenshot.svg --padding=3 --width=55 --height=3 --at=1000 --no-cursor", 85 | "test": "xo && ava" 86 | }, 87 | "version": "3.2.1" 88 | } 89 | -------------------------------------------------------------------------------- /node_modules/ansi-styles/readme.md: -------------------------------------------------------------------------------- 1 | # ansi-styles [![Build Status](https://travis-ci.org/chalk/ansi-styles.svg?branch=master)](https://travis-ci.org/chalk/ansi-styles) 2 | 3 | > [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code#Colors_and_Styles) for styling strings in the terminal 4 | 5 | You probably want the higher-level [chalk](https://github.com/chalk/chalk) module for styling your strings. 6 | 7 | 8 | 9 | 10 | ## Install 11 | 12 | ``` 13 | $ npm install ansi-styles 14 | ``` 15 | 16 | 17 | ## Usage 18 | 19 | ```js 20 | const style = require('ansi-styles'); 21 | 22 | console.log(`${style.green.open}Hello world!${style.green.close}`); 23 | 24 | 25 | // Color conversion between 16/256/truecolor 26 | // NOTE: If conversion goes to 16 colors or 256 colors, the original color 27 | // may be degraded to fit that color palette. This means terminals 28 | // that do not support 16 million colors will best-match the 29 | // original color. 30 | console.log(style.bgColor.ansi.hsl(120, 80, 72) + 'Hello world!' + style.bgColor.close); 31 | console.log(style.color.ansi256.rgb(199, 20, 250) + 'Hello world!' + style.color.close); 32 | console.log(style.color.ansi16m.hex('#ABCDEF') + 'Hello world!' + style.color.close); 33 | ``` 34 | 35 | ## API 36 | 37 | Each style has an `open` and `close` property. 38 | 39 | 40 | ## Styles 41 | 42 | ### Modifiers 43 | 44 | - `reset` 45 | - `bold` 46 | - `dim` 47 | - `italic` *(Not widely supported)* 48 | - `underline` 49 | - `inverse` 50 | - `hidden` 51 | - `strikethrough` *(Not widely supported)* 52 | 53 | ### Colors 54 | 55 | - `black` 56 | - `red` 57 | - `green` 58 | - `yellow` 59 | - `blue` 60 | - `magenta` 61 | - `cyan` 62 | - `white` 63 | - `gray` ("bright black") 64 | - `redBright` 65 | - `greenBright` 66 | - `yellowBright` 67 | - `blueBright` 68 | - `magentaBright` 69 | - `cyanBright` 70 | - `whiteBright` 71 | 72 | ### Background colors 73 | 74 | - `bgBlack` 75 | - `bgRed` 76 | - `bgGreen` 77 | - `bgYellow` 78 | - `bgBlue` 79 | - `bgMagenta` 80 | - `bgCyan` 81 | - `bgWhite` 82 | - `bgBlackBright` 83 | - `bgRedBright` 84 | - `bgGreenBright` 85 | - `bgYellowBright` 86 | - `bgBlueBright` 87 | - `bgMagentaBright` 88 | - `bgCyanBright` 89 | - `bgWhiteBright` 90 | 91 | 92 | ## Advanced usage 93 | 94 | By default, you get a map of styles, but the styles are also available as groups. They are non-enumerable so they don't show up unless you access them explicitly. This makes it easier to expose only a subset in a higher-level module. 95 | 96 | - `style.modifier` 97 | - `style.color` 98 | - `style.bgColor` 99 | 100 | ###### Example 101 | 102 | ```js 103 | console.log(style.color.green.open); 104 | ``` 105 | 106 | Raw escape codes (i.e. without the CSI escape prefix `\u001B[` and render mode postfix `m`) are available under `style.codes`, which returns a `Map` with the open codes as keys and close codes as values. 107 | 108 | ###### Example 109 | 110 | ```js 111 | console.log(style.codes.get(36)); 112 | //=> 39 113 | ``` 114 | 115 | 116 | ## [256 / 16 million (TrueColor) support](https://gist.github.com/XVilka/8346728) 117 | 118 | `ansi-styles` uses the [`color-convert`](https://github.com/Qix-/color-convert) package to allow for converting between various colors and ANSI escapes, with support for 256 and 16 million colors. 119 | 120 | To use these, call the associated conversion function with the intended output, for example: 121 | 122 | ```js 123 | style.color.ansi.rgb(100, 200, 15); // RGB to 16 color ansi foreground code 124 | style.bgColor.ansi.rgb(100, 200, 15); // RGB to 16 color ansi background code 125 | 126 | style.color.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code 127 | style.bgColor.ansi256.hsl(120, 100, 60); // HSL to 256 color ansi foreground code 128 | 129 | style.color.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color foreground code 130 | style.bgColor.ansi16m.hex('#C0FFEE'); // Hex (RGB) to 16 million color background code 131 | ``` 132 | 133 | 134 | ## Related 135 | 136 | - [ansi-escapes](https://github.com/sindresorhus/ansi-escapes) - ANSI escape codes for manipulating the terminal 137 | 138 | 139 | ## Maintainers 140 | 141 | - [Sindre Sorhus](https://github.com/sindresorhus) 142 | - [Josh Junon](https://github.com/qix-) 143 | 144 | 145 | ## License 146 | 147 | MIT 148 | -------------------------------------------------------------------------------- /node_modules/chalk/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const escapeStringRegexp = require('escape-string-regexp'); 3 | const ansiStyles = require('ansi-styles'); 4 | const stdoutColor = require('supports-color').stdout; 5 | 6 | const template = require('./templates.js'); 7 | 8 | const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm'); 9 | 10 | // `supportsColor.level` → `ansiStyles.color[name]` mapping 11 | const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m']; 12 | 13 | // `color-convert` models to exclude from the Chalk API due to conflicts and such 14 | const skipModels = new Set(['gray']); 15 | 16 | const styles = Object.create(null); 17 | 18 | function applyOptions(obj, options) { 19 | options = options || {}; 20 | 21 | // Detect level if not set manually 22 | const scLevel = stdoutColor ? stdoutColor.level : 0; 23 | obj.level = options.level === undefined ? scLevel : options.level; 24 | obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0; 25 | } 26 | 27 | function Chalk(options) { 28 | // We check for this.template here since calling `chalk.constructor()` 29 | // by itself will have a `this` of a previously constructed chalk object 30 | if (!this || !(this instanceof Chalk) || this.template) { 31 | const chalk = {}; 32 | applyOptions(chalk, options); 33 | 34 | chalk.template = function () { 35 | const args = [].slice.call(arguments); 36 | return chalkTag.apply(null, [chalk.template].concat(args)); 37 | }; 38 | 39 | Object.setPrototypeOf(chalk, Chalk.prototype); 40 | Object.setPrototypeOf(chalk.template, chalk); 41 | 42 | chalk.template.constructor = Chalk; 43 | 44 | return chalk.template; 45 | } 46 | 47 | applyOptions(this, options); 48 | } 49 | 50 | // Use bright blue on Windows as the normal blue color is illegible 51 | if (isSimpleWindowsTerm) { 52 | ansiStyles.blue.open = '\u001B[94m'; 53 | } 54 | 55 | for (const key of Object.keys(ansiStyles)) { 56 | ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g'); 57 | 58 | styles[key] = { 59 | get() { 60 | const codes = ansiStyles[key]; 61 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key); 62 | } 63 | }; 64 | } 65 | 66 | styles.visible = { 67 | get() { 68 | return build.call(this, this._styles || [], true, 'visible'); 69 | } 70 | }; 71 | 72 | ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g'); 73 | for (const model of Object.keys(ansiStyles.color.ansi)) { 74 | if (skipModels.has(model)) { 75 | continue; 76 | } 77 | 78 | styles[model] = { 79 | get() { 80 | const level = this.level; 81 | return function () { 82 | const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments); 83 | const codes = { 84 | open, 85 | close: ansiStyles.color.close, 86 | closeRe: ansiStyles.color.closeRe 87 | }; 88 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); 89 | }; 90 | } 91 | }; 92 | } 93 | 94 | ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g'); 95 | for (const model of Object.keys(ansiStyles.bgColor.ansi)) { 96 | if (skipModels.has(model)) { 97 | continue; 98 | } 99 | 100 | const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); 101 | styles[bgModel] = { 102 | get() { 103 | const level = this.level; 104 | return function () { 105 | const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments); 106 | const codes = { 107 | open, 108 | close: ansiStyles.bgColor.close, 109 | closeRe: ansiStyles.bgColor.closeRe 110 | }; 111 | return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model); 112 | }; 113 | } 114 | }; 115 | } 116 | 117 | const proto = Object.defineProperties(() => {}, styles); 118 | 119 | function build(_styles, _empty, key) { 120 | const builder = function () { 121 | return applyStyle.apply(builder, arguments); 122 | }; 123 | 124 | builder._styles = _styles; 125 | builder._empty = _empty; 126 | 127 | const self = this; 128 | 129 | Object.defineProperty(builder, 'level', { 130 | enumerable: true, 131 | get() { 132 | return self.level; 133 | }, 134 | set(level) { 135 | self.level = level; 136 | } 137 | }); 138 | 139 | Object.defineProperty(builder, 'enabled', { 140 | enumerable: true, 141 | get() { 142 | return self.enabled; 143 | }, 144 | set(enabled) { 145 | self.enabled = enabled; 146 | } 147 | }); 148 | 149 | // See below for fix regarding invisible grey/dim combination on Windows 150 | builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey'; 151 | 152 | // `__proto__` is used because we must return a function, but there is 153 | // no way to create a function with a different prototype 154 | builder.__proto__ = proto; // eslint-disable-line no-proto 155 | 156 | return builder; 157 | } 158 | 159 | function applyStyle() { 160 | // Support varags, but simply cast to string in case there's only one arg 161 | const args = arguments; 162 | const argsLen = args.length; 163 | let str = String(arguments[0]); 164 | 165 | if (argsLen === 0) { 166 | return ''; 167 | } 168 | 169 | if (argsLen > 1) { 170 | // Don't slice `arguments`, it prevents V8 optimizations 171 | for (let a = 1; a < argsLen; a++) { 172 | str += ' ' + args[a]; 173 | } 174 | } 175 | 176 | if (!this.enabled || this.level <= 0 || !str) { 177 | return this._empty ? '' : str; 178 | } 179 | 180 | // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, 181 | // see https://github.com/chalk/chalk/issues/58 182 | // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. 183 | const originalDim = ansiStyles.dim.open; 184 | if (isSimpleWindowsTerm && this.hasGrey) { 185 | ansiStyles.dim.open = ''; 186 | } 187 | 188 | for (const code of this._styles.slice().reverse()) { 189 | // Replace any instances already present with a re-opening code 190 | // otherwise only the part of the string until said closing code 191 | // will be colored, and the rest will simply be 'plain'. 192 | str = code.open + str.replace(code.closeRe, code.open) + code.close; 193 | 194 | // Close the styling before a linebreak and reopen 195 | // after next line to fix a bleed issue on macOS 196 | // https://github.com/chalk/chalk/pull/92 197 | str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`); 198 | } 199 | 200 | // Reset the original `dim` if we changed it to work around the Windows dimmed gray issue 201 | ansiStyles.dim.open = originalDim; 202 | 203 | return str; 204 | } 205 | 206 | function chalkTag(chalk, strings) { 207 | if (!Array.isArray(strings)) { 208 | // If chalk() was called by itself or with a string, 209 | // return the string itself as a string. 210 | return [].slice.call(arguments, 1).join(' '); 211 | } 212 | 213 | const args = [].slice.call(arguments, 2); 214 | const parts = [strings.raw[0]]; 215 | 216 | for (let i = 1; i < strings.length; i++) { 217 | parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&')); 218 | parts.push(String(strings.raw[i])); 219 | } 220 | 221 | return template(chalk, parts.join('')); 222 | } 223 | 224 | Object.defineProperties(Chalk.prototype, styles); 225 | 226 | module.exports = Chalk(); // eslint-disable-line new-cap 227 | module.exports.supportsColor = stdoutColor; 228 | module.exports.default = module.exports; // For TypeScript 229 | -------------------------------------------------------------------------------- /node_modules/chalk/index.js.flow: -------------------------------------------------------------------------------- 1 | // @flow strict 2 | 3 | type TemplateStringsArray = $ReadOnlyArray; 4 | 5 | export type Level = $Values<{ 6 | None: 0, 7 | Basic: 1, 8 | Ansi256: 2, 9 | TrueColor: 3 10 | }>; 11 | 12 | export type ChalkOptions = {| 13 | enabled?: boolean, 14 | level?: Level 15 | |}; 16 | 17 | export type ColorSupport = {| 18 | level: Level, 19 | hasBasic: boolean, 20 | has256: boolean, 21 | has16m: boolean 22 | |}; 23 | 24 | export interface Chalk { 25 | (...text: string[]): string, 26 | (text: TemplateStringsArray, ...placeholders: string[]): string, 27 | constructor(options?: ChalkOptions): Chalk, 28 | enabled: boolean, 29 | level: Level, 30 | rgb(r: number, g: number, b: number): Chalk, 31 | hsl(h: number, s: number, l: number): Chalk, 32 | hsv(h: number, s: number, v: number): Chalk, 33 | hwb(h: number, w: number, b: number): Chalk, 34 | bgHex(color: string): Chalk, 35 | bgKeyword(color: string): Chalk, 36 | bgRgb(r: number, g: number, b: number): Chalk, 37 | bgHsl(h: number, s: number, l: number): Chalk, 38 | bgHsv(h: number, s: number, v: number): Chalk, 39 | bgHwb(h: number, w: number, b: number): Chalk, 40 | hex(color: string): Chalk, 41 | keyword(color: string): Chalk, 42 | 43 | +reset: Chalk, 44 | +bold: Chalk, 45 | +dim: Chalk, 46 | +italic: Chalk, 47 | +underline: Chalk, 48 | +inverse: Chalk, 49 | +hidden: Chalk, 50 | +strikethrough: Chalk, 51 | 52 | +visible: Chalk, 53 | 54 | +black: Chalk, 55 | +red: Chalk, 56 | +green: Chalk, 57 | +yellow: Chalk, 58 | +blue: Chalk, 59 | +magenta: Chalk, 60 | +cyan: Chalk, 61 | +white: Chalk, 62 | +gray: Chalk, 63 | +grey: Chalk, 64 | +blackBright: Chalk, 65 | +redBright: Chalk, 66 | +greenBright: Chalk, 67 | +yellowBright: Chalk, 68 | +blueBright: Chalk, 69 | +magentaBright: Chalk, 70 | +cyanBright: Chalk, 71 | +whiteBright: Chalk, 72 | 73 | +bgBlack: Chalk, 74 | +bgRed: Chalk, 75 | +bgGreen: Chalk, 76 | +bgYellow: Chalk, 77 | +bgBlue: Chalk, 78 | +bgMagenta: Chalk, 79 | +bgCyan: Chalk, 80 | +bgWhite: Chalk, 81 | +bgBlackBright: Chalk, 82 | +bgRedBright: Chalk, 83 | +bgGreenBright: Chalk, 84 | +bgYellowBright: Chalk, 85 | +bgBlueBright: Chalk, 86 | +bgMagentaBright: Chalk, 87 | +bgCyanBright: Chalk, 88 | +bgWhiteBrigh: Chalk, 89 | 90 | supportsColor: ColorSupport 91 | }; 92 | 93 | declare module.exports: Chalk; 94 | -------------------------------------------------------------------------------- /node_modules/chalk/license: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Sindre Sorhus (sindresorhus.com) 4 | 5 | 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: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | 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. 10 | -------------------------------------------------------------------------------- /node_modules/chalk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "_from": "chalk@^2.4.2", 3 | "_id": "chalk@2.4.2", 4 | "_inBundle": false, 5 | "_integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", 6 | "_location": "/chalk", 7 | "_phantomChildren": {}, 8 | "_requested": { 9 | "type": "range", 10 | "registry": true, 11 | "raw": "chalk@^2.4.2", 12 | "name": "chalk", 13 | "escapedName": "chalk", 14 | "rawSpec": "^2.4.2", 15 | "saveSpec": null, 16 | "fetchSpec": "^2.4.2" 17 | }, 18 | "_requiredBy": [ 19 | "/" 20 | ], 21 | "_resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", 22 | "_shasum": "cd42541677a54333cf541a49108c1432b44c9424", 23 | "_spec": "chalk@^2.4.2", 24 | "_where": "/Users/yuqing/Documents/source-location", 25 | "bugs": { 26 | "url": "https://github.com/chalk/chalk/issues" 27 | }, 28 | "bundleDependencies": false, 29 | "dependencies": { 30 | "ansi-styles": "^3.2.1", 31 | "escape-string-regexp": "^1.0.5", 32 | "supports-color": "^5.3.0" 33 | }, 34 | "deprecated": false, 35 | "description": "Terminal string styling done right", 36 | "devDependencies": { 37 | "ava": "*", 38 | "coveralls": "^3.0.0", 39 | "execa": "^0.9.0", 40 | "flow-bin": "^0.68.0", 41 | "import-fresh": "^2.0.0", 42 | "matcha": "^0.7.0", 43 | "nyc": "^11.0.2", 44 | "resolve-from": "^4.0.0", 45 | "typescript": "^2.5.3", 46 | "xo": "*" 47 | }, 48 | "engines": { 49 | "node": ">=4" 50 | }, 51 | "files": [ 52 | "index.js", 53 | "templates.js", 54 | "types/index.d.ts", 55 | "index.js.flow" 56 | ], 57 | "homepage": "https://github.com/chalk/chalk#readme", 58 | "keywords": [ 59 | "color", 60 | "colour", 61 | "colors", 62 | "terminal", 63 | "console", 64 | "cli", 65 | "string", 66 | "str", 67 | "ansi", 68 | "style", 69 | "styles", 70 | "tty", 71 | "formatting", 72 | "rgb", 73 | "256", 74 | "shell", 75 | "xterm", 76 | "log", 77 | "logging", 78 | "command-line", 79 | "text" 80 | ], 81 | "license": "MIT", 82 | "name": "chalk", 83 | "repository": { 84 | "type": "git", 85 | "url": "git+https://github.com/chalk/chalk.git" 86 | }, 87 | "scripts": { 88 | "bench": "matcha benchmark.js", 89 | "coveralls": "nyc report --reporter=text-lcov | coveralls", 90 | "test": "xo && tsc --project types && flow --max-warnings=0 && nyc ava" 91 | }, 92 | "types": "types/index.d.ts", 93 | "version": "2.4.2", 94 | "xo": { 95 | "envs": [ 96 | "node", 97 | "mocha" 98 | ], 99 | "ignores": [ 100 | "test/_flow.js" 101 | ] 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /node_modules/chalk/readme.md: -------------------------------------------------------------------------------- 1 |

2 |
3 |
4 | Chalk 5 |
6 |
7 |
8 |

9 | 10 | > Terminal string styling done right 11 | 12 | [![Build Status](https://travis-ci.org/chalk/chalk.svg?branch=master)](https://travis-ci.org/chalk/chalk) [![Coverage Status](https://coveralls.io/repos/github/chalk/chalk/badge.svg?branch=master)](https://coveralls.io/github/chalk/chalk?branch=master) [![](https://img.shields.io/badge/unicorn-approved-ff69b4.svg)](https://www.youtube.com/watch?v=9auOCbH5Ns4) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) [![Mentioned in Awesome Node.js](https://awesome.re/mentioned-badge.svg)](https://github.com/sindresorhus/awesome-nodejs) 13 | 14 | ### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0) 15 | 16 | 17 | 18 | 19 | ## Highlights 20 | 21 | - Expressive API 22 | - Highly performant 23 | - Ability to nest styles 24 | - [256/Truecolor color support](#256-and-truecolor-color-support) 25 | - Auto-detects color support 26 | - Doesn't extend `String.prototype` 27 | - Clean and focused 28 | - Actively maintained 29 | - [Used by ~23,000 packages](https://www.npmjs.com/browse/depended/chalk) as of December 31, 2017 30 | 31 | 32 | ## Install 33 | 34 | ```console 35 | $ npm install chalk 36 | ``` 37 | 38 | 39 | 40 | 41 | 42 | 43 | ## Usage 44 | 45 | ```js 46 | const chalk = require('chalk'); 47 | 48 | console.log(chalk.blue('Hello world!')); 49 | ``` 50 | 51 | Chalk comes with an easy to use composable API where you just chain and nest the styles you want. 52 | 53 | ```js 54 | const chalk = require('chalk'); 55 | const log = console.log; 56 | 57 | // Combine styled and normal strings 58 | log(chalk.blue('Hello') + ' World' + chalk.red('!')); 59 | 60 | // Compose multiple styles using the chainable API 61 | log(chalk.blue.bgRed.bold('Hello world!')); 62 | 63 | // Pass in multiple arguments 64 | log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz')); 65 | 66 | // Nest styles 67 | log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!')); 68 | 69 | // Nest styles of the same type even (color, underline, background) 70 | log(chalk.green( 71 | 'I am a green line ' + 72 | chalk.blue.underline.bold('with a blue substring') + 73 | ' that becomes green again!' 74 | )); 75 | 76 | // ES2015 template literal 77 | log(` 78 | CPU: ${chalk.red('90%')} 79 | RAM: ${chalk.green('40%')} 80 | DISK: ${chalk.yellow('70%')} 81 | `); 82 | 83 | // ES2015 tagged template literal 84 | log(chalk` 85 | CPU: {red ${cpu.totalPercent}%} 86 | RAM: {green ${ram.used / ram.total * 100}%} 87 | DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%} 88 | `); 89 | 90 | // Use RGB colors in terminal emulators that support it. 91 | log(chalk.keyword('orange')('Yay for orange colored text!')); 92 | log(chalk.rgb(123, 45, 67).underline('Underlined reddish color')); 93 | log(chalk.hex('#DEADED').bold('Bold gray!')); 94 | ``` 95 | 96 | Easily define your own themes: 97 | 98 | ```js 99 | const chalk = require('chalk'); 100 | 101 | const error = chalk.bold.red; 102 | const warning = chalk.keyword('orange'); 103 | 104 | console.log(error('Error!')); 105 | console.log(warning('Warning!')); 106 | ``` 107 | 108 | Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args): 109 | 110 | ```js 111 | const name = 'Sindre'; 112 | console.log(chalk.green('Hello %s'), name); 113 | //=> 'Hello Sindre' 114 | ``` 115 | 116 | 117 | ## API 118 | 119 | ### chalk.`