Initial commit
This commit is contained in:
21
node_modules/serve/LICENSE
generated
vendored
Normal file
21
node_modules/serve/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2018 ZEIT, Inc.
|
||||
|
||||
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.
|
||||
87
node_modules/serve/README.md
generated
vendored
Normal file
87
node_modules/serve/README.md
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||

|
||||
|
||||
<a aria-label="Vercel logo" href="https://vercel.com">
|
||||
<img src="https://img.shields.io/badge/MADE%20BY%20Vercel-000000.svg?style=for-the-badge&logo=ZEIT&labelColor=000000&logoWidth=20">
|
||||
</a>
|
||||
|
||||
[](https://circleci.com/gh/vercel/serve)
|
||||
[](https://packagephobia.now.sh/result?p=serve)
|
||||
|
||||
Assuming you would like to serve a static site, single page application or just a static file (no matter if on your device or on the local network), this package is just the right choice for you.
|
||||
|
||||
Once it's time to push your site to production, we recommend using [Vercel](https://vercel.com).
|
||||
|
||||
In general, `serve` also provides a neat interface for listing the directory's contents:
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
The quickest way to get started is to just run `npx serve` in your project's directory.
|
||||
|
||||
If you prefer, you can also install the package globally using [Yarn](https://yarnpkg.com/en/) (you'll need at least [Node.js LTS](https://nodejs.org/en/)):
|
||||
|
||||
```bash
|
||||
yarn global add serve
|
||||
```
|
||||
|
||||
Once that's done, you can run this command inside your project's directory...
|
||||
|
||||
```bash
|
||||
serve
|
||||
```
|
||||
|
||||
...or specify which folder you want to serve:
|
||||
|
||||
```bash
|
||||
serve folder_name
|
||||
```
|
||||
|
||||
Finally, run this command to see a list of all available options:
|
||||
|
||||
```bash
|
||||
serve --help
|
||||
```
|
||||
|
||||
Now you understand how the package works! :tada:
|
||||
|
||||
## Configuration
|
||||
|
||||
To customize `serve`'s behavior, create a `serve.json` file in the public folder and insert any of [these properties](https://github.com/vercel/serve-handler#options).
|
||||
|
||||
## API
|
||||
|
||||
The core of `serve` is [serve-handler](https://github.com/vercel/serve-handler), which can be used as middleware in existing HTTP servers:
|
||||
|
||||
```js
|
||||
const handler = require('serve-handler');
|
||||
const http = require('http');
|
||||
|
||||
const server = http.createServer((request, response) => {
|
||||
// You pass two more arguments for config and middleware
|
||||
// More details here: https://github.com/vercel/serve-handler#options
|
||||
return handler(request, response);
|
||||
})
|
||||
|
||||
server.listen(3000, () => {
|
||||
console.log('Running at http://localhost:3000');
|
||||
});
|
||||
```
|
||||
|
||||
**NOTE:** You can also replace `http.createServer` with [micro](https://github.com/vercel/micro), if you want.
|
||||
|
||||
## Contributing
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local device
|
||||
2. Uninstall `serve` if it's already installed: `npm uninstall -g serve`
|
||||
3. Link it to the global module directory: `npm link`
|
||||
|
||||
After that, you can use the `serve` command everywhere. [Here](https://github.com/vercel/serve/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+for+beginners%22)'s a list of issues that are great for beginners.
|
||||
|
||||
## Credits
|
||||
|
||||
This project used to be called "list" and "micro-list". But thanks to [TJ Holowaychuk](https://github.com/tj) handing us the new name, it's now called "serve" (which is much more definite).
|
||||
|
||||
## Author
|
||||
|
||||
Leo Lamprecht ([@notquiteleo](https://twitter.com/notquiteleo)) - [Vercel](https://vercel.com)
|
||||
456
node_modules/serve/bin/serve.js
generated
vendored
Executable file
456
node_modules/serve/bin/serve.js
generated
vendored
Executable file
@@ -0,0 +1,456 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Native
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {promisify} = require('util');
|
||||
const {parse} = require('url');
|
||||
const os = require('os');
|
||||
|
||||
// Packages
|
||||
const Ajv = require('ajv');
|
||||
const checkForUpdate = require('update-check');
|
||||
const chalk = require('chalk');
|
||||
const arg = require('arg');
|
||||
const {write: copy} = require('clipboardy');
|
||||
const handler = require('serve-handler');
|
||||
const schema = require('@zeit/schemas/deployment/config-static');
|
||||
const boxen = require('boxen');
|
||||
const compression = require('compression');
|
||||
|
||||
// Utilities
|
||||
const pkg = require('../package');
|
||||
|
||||
const readFile = promisify(fs.readFile);
|
||||
const compressionHandler = promisify(compression());
|
||||
|
||||
const interfaces = os.networkInterfaces();
|
||||
|
||||
const warning = (message) => chalk`{yellow WARNING:} ${message}`;
|
||||
const info = (message) => chalk`{magenta INFO:} ${message}`;
|
||||
const error = (message) => chalk`{red ERROR:} ${message}`;
|
||||
|
||||
const updateCheck = async (isDebugging) => {
|
||||
let update = null;
|
||||
|
||||
try {
|
||||
update = await checkForUpdate(pkg);
|
||||
} catch (err) {
|
||||
const suffix = isDebugging ? ':' : ' (use `--debug` to see full error)';
|
||||
console.error(warning(`Checking for updates failed${suffix}`));
|
||||
|
||||
if (isDebugging) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
if (!update) {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`${chalk.bgRed('UPDATE AVAILABLE')} The latest version of \`serve\` is ${update.latest}`);
|
||||
};
|
||||
|
||||
const getHelp = () => chalk`
|
||||
{bold.cyan serve} - Static file serving and directory listing
|
||||
|
||||
{bold USAGE}
|
||||
|
||||
{bold $} {cyan serve} --help
|
||||
{bold $} {cyan serve} --version
|
||||
{bold $} {cyan serve} folder_name
|
||||
{bold $} {cyan serve} [-l {underline listen_uri} [-l ...]] [{underline directory}]
|
||||
|
||||
By default, {cyan serve} will listen on {bold 0.0.0.0:5000} and serve the
|
||||
current working directory on that address.
|
||||
|
||||
Specifying a single {bold --listen} argument will overwrite the default, not supplement it.
|
||||
|
||||
{bold OPTIONS}
|
||||
|
||||
--help Shows this help message
|
||||
|
||||
-v, --version Displays the current version of serve
|
||||
|
||||
-l, --listen {underline listen_uri} Specify a URI endpoint on which to listen (see below) -
|
||||
more than one may be specified to listen in multiple places
|
||||
|
||||
-p Specify custom port
|
||||
|
||||
-d, --debug Show debugging information
|
||||
|
||||
-s, --single Rewrite all not-found requests to \`index.html\`
|
||||
|
||||
-c, --config Specify custom path to \`serve.json\`
|
||||
|
||||
-C, --cors Enable CORS, sets \`Access-Control-Allow-Origin\` to \`*\`
|
||||
|
||||
-n, --no-clipboard Do not copy the local address to the clipboard
|
||||
|
||||
-u, --no-compression Do not compress files
|
||||
|
||||
--no-etag Send \`Last-Modified\` header instead of \`ETag\`
|
||||
|
||||
-S, --symlinks Resolve symlinks instead of showing 404 errors
|
||||
|
||||
--ssl-cert Optional path to an SSL/TLS certificate to serve with HTTPS
|
||||
|
||||
--ssl-key Optional path to the SSL/TLS certificate\'s private key
|
||||
|
||||
--no-port-switching Do not open a port other than the one specified when it\'s taken.
|
||||
|
||||
{bold ENDPOINTS}
|
||||
|
||||
Listen endpoints (specified by the {bold --listen} or {bold -l} options above) instruct {cyan serve}
|
||||
to listen on one or more interfaces/ports, UNIX domain sockets, or Windows named pipes.
|
||||
|
||||
For TCP ports on hostname "localhost":
|
||||
|
||||
{bold $} {cyan serve} -l {underline 1234}
|
||||
|
||||
For TCP (traditional host/port) endpoints:
|
||||
|
||||
{bold $} {cyan serve} -l tcp://{underline hostname}:{underline 1234}
|
||||
|
||||
For UNIX domain socket endpoints:
|
||||
|
||||
{bold $} {cyan serve} -l unix:{underline /path/to/socket.sock}
|
||||
|
||||
For Windows named pipe endpoints:
|
||||
|
||||
{bold $} {cyan serve} -l pipe:\\\\.\\pipe\\{underline PipeName}
|
||||
`;
|
||||
|
||||
const parseEndpoint = (str) => {
|
||||
if (!isNaN(str)) {
|
||||
return [str];
|
||||
}
|
||||
|
||||
// We cannot use `new URL` here, otherwise it will not
|
||||
// parse the host properly and it would drop support for IPv6.
|
||||
const url = parse(str);
|
||||
|
||||
switch (url.protocol) {
|
||||
case 'pipe:': {
|
||||
// some special handling
|
||||
const cutStr = str.replace(/^pipe:/, '');
|
||||
|
||||
if (cutStr.slice(0, 4) !== '\\\\.\\') {
|
||||
throw new Error(`Invalid Windows named pipe endpoint: ${str}`);
|
||||
}
|
||||
|
||||
return [cutStr];
|
||||
}
|
||||
case 'unix:':
|
||||
if (!url.pathname) {
|
||||
throw new Error(`Invalid UNIX domain socket endpoint: ${str}`);
|
||||
}
|
||||
|
||||
return [url.pathname];
|
||||
case 'tcp:':
|
||||
url.port = url.port || '5000';
|
||||
return [parseInt(url.port, 10), url.hostname];
|
||||
default:
|
||||
throw new Error(`Unknown --listen endpoint scheme (protocol): ${url.protocol}`);
|
||||
}
|
||||
};
|
||||
|
||||
const registerShutdown = (fn) => {
|
||||
let run = false;
|
||||
|
||||
const wrapper = () => {
|
||||
if (!run) {
|
||||
run = true;
|
||||
fn();
|
||||
}
|
||||
};
|
||||
|
||||
process.on('SIGINT', wrapper);
|
||||
process.on('SIGTERM', wrapper);
|
||||
process.on('exit', wrapper);
|
||||
};
|
||||
|
||||
const getNetworkAddress = () => {
|
||||
for (const name of Object.keys(interfaces)) {
|
||||
for (const interface of interfaces[name]) {
|
||||
const {address, family, internal} = interface;
|
||||
if (family === 'IPv4' && !internal) {
|
||||
return address;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const startEndpoint = (endpoint, config, args, previous) => {
|
||||
const {isTTY} = process.stdout;
|
||||
const clipboard = args['--no-clipboard'] !== true;
|
||||
const compress = args['--no-compression'] !== true;
|
||||
const httpMode = args['--ssl-cert'] && args['--ssl-key'] ? 'https' : 'http';
|
||||
|
||||
const serverHandler = async (request, response) => {
|
||||
if (args['--cors']) {
|
||||
response.setHeader('Access-Control-Allow-Origin', '*');
|
||||
}
|
||||
if (compress) {
|
||||
await compressionHandler(request, response);
|
||||
}
|
||||
|
||||
return handler(request, response, config);
|
||||
};
|
||||
|
||||
const server = httpMode === 'https'
|
||||
? https.createServer({
|
||||
key: fs.readFileSync(args['--ssl-key']),
|
||||
cert: fs.readFileSync(args['--ssl-cert'])
|
||||
}, serverHandler)
|
||||
: http.createServer(serverHandler);
|
||||
|
||||
server.on('error', (err) => {
|
||||
if (err.code === 'EADDRINUSE' && endpoint.length === 1 && !isNaN(endpoint[0]) && args['--no-port-switching'] !== true) {
|
||||
startEndpoint([0], config, args, endpoint[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
console.error(error(`Failed to serve: ${err.stack}`));
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
server.listen(...endpoint, async () => {
|
||||
const details = server.address();
|
||||
registerShutdown(() => server.close());
|
||||
|
||||
let localAddress = null;
|
||||
let networkAddress = null;
|
||||
|
||||
if (typeof details === 'string') {
|
||||
localAddress = details;
|
||||
} else if (typeof details === 'object' && details.port) {
|
||||
const address = details.address === '::' ? 'localhost' : details.address;
|
||||
const ip = getNetworkAddress();
|
||||
|
||||
localAddress = `${httpMode}://${address}:${details.port}`;
|
||||
networkAddress = networkAddress ? `${httpMode}://${ip}:${details.port}` : null;
|
||||
}
|
||||
|
||||
if (isTTY && process.env.NODE_ENV !== 'production') {
|
||||
let message = chalk.green('Serving!');
|
||||
|
||||
if (localAddress) {
|
||||
const prefix = networkAddress ? '- ' : '';
|
||||
const space = networkAddress ? ' ' : ' ';
|
||||
|
||||
message += `\n\n${chalk.bold(`${prefix}Local:`)}${space}${localAddress}`;
|
||||
}
|
||||
|
||||
if (networkAddress) {
|
||||
message += `\n${chalk.bold('- On Your Network:')} ${networkAddress}`;
|
||||
}
|
||||
|
||||
if (previous) {
|
||||
message += chalk.red(`\n\nThis port was picked because ${chalk.underline(previous)} is in use.`);
|
||||
}
|
||||
|
||||
if (clipboard) {
|
||||
try {
|
||||
await copy(localAddress);
|
||||
message += `\n\n${chalk.grey('Copied local address to clipboard!')}`;
|
||||
} catch (err) {
|
||||
console.error(error(`Cannot copy to clipboard: ${err.message}`));
|
||||
}
|
||||
}
|
||||
|
||||
console.log(boxen(message, {
|
||||
padding: 1,
|
||||
borderColor: 'green',
|
||||
margin: 1
|
||||
}));
|
||||
} else {
|
||||
const suffix = localAddress ? ` at ${localAddress}` : '';
|
||||
console.log(info(`Accepting connections${suffix}`));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const loadConfig = async (cwd, entry, args) => {
|
||||
const files = [
|
||||
'serve.json',
|
||||
'now.json',
|
||||
'package.json'
|
||||
];
|
||||
|
||||
if (args['--config']) {
|
||||
files.unshift(args['--config']);
|
||||
}
|
||||
|
||||
const config = {};
|
||||
|
||||
for (const file of files) {
|
||||
const location = path.resolve(entry, file);
|
||||
let content = null;
|
||||
|
||||
try {
|
||||
content = await readFile(location, 'utf8');
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
continue;
|
||||
}
|
||||
|
||||
console.error(error(`Not able to read ${location}: ${err.message}`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
content = JSON.parse(content);
|
||||
} catch (err) {
|
||||
console.error(error(`Could not parse ${location} as JSON: ${err.message}`));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (typeof content !== 'object') {
|
||||
console.error(warning(`Didn't find a valid object in ${location}. Skipping...`));
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
switch (file) {
|
||||
case 'now.json':
|
||||
content = content.static;
|
||||
break;
|
||||
case 'package.json':
|
||||
content = content.now.static;
|
||||
break;
|
||||
}
|
||||
} catch (err) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Object.assign(config, content);
|
||||
console.log(info(`Discovered configuration in \`${file}\``));
|
||||
|
||||
if (file === 'now.json' || file === 'package.json') {
|
||||
console.error(warning('The config files `now.json` and `package.json` are deprecated. Please use `serve.json`.'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (entry) {
|
||||
const {public} = config;
|
||||
config.public = path.relative(cwd, (public ? path.resolve(entry, public) : entry));
|
||||
}
|
||||
|
||||
if (Object.keys(config).length !== 0) {
|
||||
const ajv = new Ajv();
|
||||
const validateSchema = ajv.compile(schema);
|
||||
|
||||
if (!validateSchema(config)) {
|
||||
const defaultMessage = error('The configuration you provided is wrong:');
|
||||
const {message, params} = validateSchema.errors[0];
|
||||
|
||||
console.error(`${defaultMessage}\n${message}\n${JSON.stringify(params)}`);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// "ETag" headers are enabled by default unless `--no-etag` is provided
|
||||
config.etag = !args['--no-etag'];
|
||||
|
||||
return config;
|
||||
};
|
||||
|
||||
(async () => {
|
||||
let args = null;
|
||||
|
||||
try {
|
||||
args = arg({
|
||||
'--help': Boolean,
|
||||
'--version': Boolean,
|
||||
'--listen': [parseEndpoint],
|
||||
'--single': Boolean,
|
||||
'--debug': Boolean,
|
||||
'--config': String,
|
||||
'--no-clipboard': Boolean,
|
||||
'--no-compression': Boolean,
|
||||
'--no-etag': Boolean,
|
||||
'--symlinks': Boolean,
|
||||
'--cors': Boolean,
|
||||
'--no-port-switching': Boolean,
|
||||
'--ssl-cert': String,
|
||||
'--ssl-key': String,
|
||||
'-h': '--help',
|
||||
'-v': '--version',
|
||||
'-l': '--listen',
|
||||
'-s': '--single',
|
||||
'-d': '--debug',
|
||||
'-c': '--config',
|
||||
'-n': '--no-clipboard',
|
||||
'-u': '--no-compression',
|
||||
'-S': '--symlinks',
|
||||
'-C': '--cors',
|
||||
// This is deprecated and only for backwards-compatibility.
|
||||
'-p': '--listen'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(error(err.message));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (process.env.NO_UPDATE_CHECK !== '1') {
|
||||
await updateCheck(args['--debug']);
|
||||
}
|
||||
|
||||
if (args['--version']) {
|
||||
console.log(pkg.version);
|
||||
return;
|
||||
}
|
||||
|
||||
if (args['--help']) {
|
||||
console.log(getHelp());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args['--listen']) {
|
||||
// Default endpoint
|
||||
args['--listen'] = [[process.env.PORT || 5000]];
|
||||
}
|
||||
|
||||
if (args._.length > 1) {
|
||||
console.error(error('Please provide one path argument at maximum'));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const cwd = process.cwd();
|
||||
const entry = args._.length > 0 ? path.resolve(args._[0]) : cwd;
|
||||
|
||||
const config = await loadConfig(cwd, entry, args);
|
||||
|
||||
if (args['--single']) {
|
||||
const {rewrites} = config;
|
||||
const existingRewrites = Array.isArray(rewrites) ? rewrites : [];
|
||||
|
||||
// As the first rewrite rule, make `--single` work
|
||||
config.rewrites = [{
|
||||
source: '**',
|
||||
destination: '/index.html'
|
||||
}, ...existingRewrites];
|
||||
}
|
||||
|
||||
if (args['--symlinks']) {
|
||||
config.symlinks = true;
|
||||
}
|
||||
|
||||
for (const endpoint of args['--listen']) {
|
||||
startEndpoint(endpoint, config, args);
|
||||
}
|
||||
|
||||
registerShutdown(() => {
|
||||
console.log(`\n${info('Gracefully shutting down. Please wait...')}`);
|
||||
|
||||
process.on('SIGINT', () => {
|
||||
console.log(`\n${warning('Force-closing all open sockets...')}`);
|
||||
process.exit(0);
|
||||
});
|
||||
});
|
||||
})();
|
||||
228
node_modules/serve/node_modules/chalk/index.js
generated
vendored
Normal file
228
node_modules/serve/node_modules/chalk/index.js
generated
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
'use strict';
|
||||
const escapeStringRegexp = require('escape-string-regexp');
|
||||
const ansiStyles = require('ansi-styles');
|
||||
const stdoutColor = require('supports-color').stdout;
|
||||
|
||||
const template = require('./templates.js');
|
||||
|
||||
const isSimpleWindowsTerm = process.platform === 'win32' && !(process.env.TERM || '').toLowerCase().startsWith('xterm');
|
||||
|
||||
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
||||
const levelMapping = ['ansi', 'ansi', 'ansi256', 'ansi16m'];
|
||||
|
||||
// `color-convert` models to exclude from the Chalk API due to conflicts and such
|
||||
const skipModels = new Set(['gray']);
|
||||
|
||||
const styles = Object.create(null);
|
||||
|
||||
function applyOptions(obj, options) {
|
||||
options = options || {};
|
||||
|
||||
// Detect level if not set manually
|
||||
const scLevel = stdoutColor ? stdoutColor.level : 0;
|
||||
obj.level = options.level === undefined ? scLevel : options.level;
|
||||
obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
|
||||
}
|
||||
|
||||
function Chalk(options) {
|
||||
// We check for this.template here since calling `chalk.constructor()`
|
||||
// by itself will have a `this` of a previously constructed chalk object
|
||||
if (!this || !(this instanceof Chalk) || this.template) {
|
||||
const chalk = {};
|
||||
applyOptions(chalk, options);
|
||||
|
||||
chalk.template = function () {
|
||||
const args = [].slice.call(arguments);
|
||||
return chalkTag.apply(null, [chalk.template].concat(args));
|
||||
};
|
||||
|
||||
Object.setPrototypeOf(chalk, Chalk.prototype);
|
||||
Object.setPrototypeOf(chalk.template, chalk);
|
||||
|
||||
chalk.template.constructor = Chalk;
|
||||
|
||||
return chalk.template;
|
||||
}
|
||||
|
||||
applyOptions(this, options);
|
||||
}
|
||||
|
||||
// Use bright blue on Windows as the normal blue color is illegible
|
||||
if (isSimpleWindowsTerm) {
|
||||
ansiStyles.blue.open = '\u001B[94m';
|
||||
}
|
||||
|
||||
for (const key of Object.keys(ansiStyles)) {
|
||||
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
|
||||
|
||||
styles[key] = {
|
||||
get() {
|
||||
const codes = ansiStyles[key];
|
||||
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
styles.visible = {
|
||||
get() {
|
||||
return build.call(this, this._styles || [], true, 'visible');
|
||||
}
|
||||
};
|
||||
|
||||
ansiStyles.color.closeRe = new RegExp(escapeStringRegexp(ansiStyles.color.close), 'g');
|
||||
for (const model of Object.keys(ansiStyles.color.ansi)) {
|
||||
if (skipModels.has(model)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
styles[model] = {
|
||||
get() {
|
||||
const level = this.level;
|
||||
return function () {
|
||||
const open = ansiStyles.color[levelMapping[level]][model].apply(null, arguments);
|
||||
const codes = {
|
||||
open,
|
||||
close: ansiStyles.color.close,
|
||||
closeRe: ansiStyles.color.closeRe
|
||||
};
|
||||
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ansiStyles.bgColor.closeRe = new RegExp(escapeStringRegexp(ansiStyles.bgColor.close), 'g');
|
||||
for (const model of Object.keys(ansiStyles.bgColor.ansi)) {
|
||||
if (skipModels.has(model)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
||||
styles[bgModel] = {
|
||||
get() {
|
||||
const level = this.level;
|
||||
return function () {
|
||||
const open = ansiStyles.bgColor[levelMapping[level]][model].apply(null, arguments);
|
||||
const codes = {
|
||||
open,
|
||||
close: ansiStyles.bgColor.close,
|
||||
closeRe: ansiStyles.bgColor.closeRe
|
||||
};
|
||||
return build.call(this, this._styles ? this._styles.concat(codes) : [codes], this._empty, model);
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const proto = Object.defineProperties(() => {}, styles);
|
||||
|
||||
function build(_styles, _empty, key) {
|
||||
const builder = function () {
|
||||
return applyStyle.apply(builder, arguments);
|
||||
};
|
||||
|
||||
builder._styles = _styles;
|
||||
builder._empty = _empty;
|
||||
|
||||
const self = this;
|
||||
|
||||
Object.defineProperty(builder, 'level', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return self.level;
|
||||
},
|
||||
set(level) {
|
||||
self.level = level;
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(builder, 'enabled', {
|
||||
enumerable: true,
|
||||
get() {
|
||||
return self.enabled;
|
||||
},
|
||||
set(enabled) {
|
||||
self.enabled = enabled;
|
||||
}
|
||||
});
|
||||
|
||||
// See below for fix regarding invisible grey/dim combination on Windows
|
||||
builder.hasGrey = this.hasGrey || key === 'gray' || key === 'grey';
|
||||
|
||||
// `__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; // eslint-disable-line no-proto
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
function applyStyle() {
|
||||
// Support varags, but simply cast to string in case there's only one arg
|
||||
const args = arguments;
|
||||
const argsLen = args.length;
|
||||
let str = String(arguments[0]);
|
||||
|
||||
if (argsLen === 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (argsLen > 1) {
|
||||
// Don't slice `arguments`, it prevents V8 optimizations
|
||||
for (let a = 1; a < argsLen; a++) {
|
||||
str += ' ' + args[a];
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.enabled || this.level <= 0 || !str) {
|
||||
return this._empty ? '' : str;
|
||||
}
|
||||
|
||||
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
|
||||
// see https://github.com/chalk/chalk/issues/58
|
||||
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
|
||||
const originalDim = ansiStyles.dim.open;
|
||||
if (isSimpleWindowsTerm && this.hasGrey) {
|
||||
ansiStyles.dim.open = '';
|
||||
}
|
||||
|
||||
for (const code of this._styles.slice().reverse()) {
|
||||
// Replace any instances already present with a re-opening code
|
||||
// otherwise only the part of the string until said closing code
|
||||
// will be colored, and the rest will simply be 'plain'.
|
||||
str = code.open + str.replace(code.closeRe, code.open) + code.close;
|
||||
|
||||
// Close the styling before a linebreak and reopen
|
||||
// after next line to fix a bleed issue on macOS
|
||||
// https://github.com/chalk/chalk/pull/92
|
||||
str = str.replace(/\r?\n/g, `${code.close}$&${code.open}`);
|
||||
}
|
||||
|
||||
// Reset the original `dim` if we changed it to work around the Windows dimmed gray issue
|
||||
ansiStyles.dim.open = originalDim;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
function chalkTag(chalk, strings) {
|
||||
if (!Array.isArray(strings)) {
|
||||
// If chalk() was called by itself or with a string,
|
||||
// return the string itself as a string.
|
||||
return [].slice.call(arguments, 1).join(' ');
|
||||
}
|
||||
|
||||
const args = [].slice.call(arguments, 2);
|
||||
const parts = [strings.raw[0]];
|
||||
|
||||
for (let i = 1; i < strings.length; i++) {
|
||||
parts.push(String(args[i - 1]).replace(/[{}\\]/g, '\\$&'));
|
||||
parts.push(String(strings.raw[i]));
|
||||
}
|
||||
|
||||
return template(chalk, parts.join(''));
|
||||
}
|
||||
|
||||
Object.defineProperties(Chalk.prototype, styles);
|
||||
|
||||
module.exports = Chalk(); // eslint-disable-line new-cap
|
||||
module.exports.supportsColor = stdoutColor;
|
||||
module.exports.default = module.exports; // For TypeScript
|
||||
93
node_modules/serve/node_modules/chalk/index.js.flow
generated
vendored
Normal file
93
node_modules/serve/node_modules/chalk/index.js.flow
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
// @flow
|
||||
|
||||
type TemplateStringsArray = $ReadOnlyArray<string>;
|
||||
|
||||
export type Level = $Values<{
|
||||
None: 0,
|
||||
Basic: 1,
|
||||
Ansi256: 2,
|
||||
TrueColor: 3
|
||||
}>;
|
||||
|
||||
export type ChalkOptions = {|
|
||||
enabled?: boolean,
|
||||
level?: Level
|
||||
|};
|
||||
|
||||
export type ColorSupport = {|
|
||||
level: Level,
|
||||
hasBasic: boolean,
|
||||
has256: boolean,
|
||||
has16m: boolean
|
||||
|};
|
||||
|
||||
export interface Chalk {
|
||||
(...text: string[]): string,
|
||||
(text: TemplateStringsArray, ...placeholders: string[]): string,
|
||||
constructor(options?: ChalkOptions): Chalk,
|
||||
enabled: boolean,
|
||||
level: Level,
|
||||
rgb(r: number, g: number, b: number): Chalk,
|
||||
hsl(h: number, s: number, l: number): Chalk,
|
||||
hsv(h: number, s: number, v: number): Chalk,
|
||||
hwb(h: number, w: number, b: number): Chalk,
|
||||
bgHex(color: string): Chalk,
|
||||
bgKeyword(color: string): Chalk,
|
||||
bgRgb(r: number, g: number, b: number): Chalk,
|
||||
bgHsl(h: number, s: number, l: number): Chalk,
|
||||
bgHsv(h: number, s: number, v: number): Chalk,
|
||||
bgHwb(h: number, w: number, b: number): Chalk,
|
||||
hex(color: string): Chalk,
|
||||
keyword(color: string): Chalk,
|
||||
|
||||
+reset: Chalk,
|
||||
+bold: Chalk,
|
||||
+dim: Chalk,
|
||||
+italic: Chalk,
|
||||
+underline: Chalk,
|
||||
+inverse: Chalk,
|
||||
+hidden: Chalk,
|
||||
+strikethrough: Chalk,
|
||||
|
||||
+visible: Chalk,
|
||||
|
||||
+black: Chalk,
|
||||
+red: Chalk,
|
||||
+green: Chalk,
|
||||
+yellow: Chalk,
|
||||
+blue: Chalk,
|
||||
+magenta: Chalk,
|
||||
+cyan: Chalk,
|
||||
+white: Chalk,
|
||||
+gray: Chalk,
|
||||
+grey: Chalk,
|
||||
+blackBright: Chalk,
|
||||
+redBright: Chalk,
|
||||
+greenBright: Chalk,
|
||||
+yellowBright: Chalk,
|
||||
+blueBright: Chalk,
|
||||
+magentaBright: Chalk,
|
||||
+cyanBright: Chalk,
|
||||
+whiteBright: Chalk,
|
||||
|
||||
+bgBlack: Chalk,
|
||||
+bgRed: Chalk,
|
||||
+bgGreen: Chalk,
|
||||
+bgYellow: Chalk,
|
||||
+bgBlue: Chalk,
|
||||
+bgMagenta: Chalk,
|
||||
+bgCyan: Chalk,
|
||||
+bgWhite: Chalk,
|
||||
+bgBlackBright: Chalk,
|
||||
+bgRedBright: Chalk,
|
||||
+bgGreenBright: Chalk,
|
||||
+bgYellowBright: Chalk,
|
||||
+bgBlueBright: Chalk,
|
||||
+bgMagentaBright: Chalk,
|
||||
+bgCyanBright: Chalk,
|
||||
+bgWhiteBrigh: Chalk,
|
||||
|
||||
supportsColor: ColorSupport
|
||||
};
|
||||
|
||||
declare module.exports: Chalk;
|
||||
9
node_modules/serve/node_modules/chalk/license
generated
vendored
Normal file
9
node_modules/serve/node_modules/chalk/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (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.
|
||||
71
node_modules/serve/node_modules/chalk/package.json
generated
vendored
Normal file
71
node_modules/serve/node_modules/chalk/package.json
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "chalk",
|
||||
"version": "2.4.1",
|
||||
"description": "Terminal string styling done right",
|
||||
"license": "MIT",
|
||||
"repository": "chalk/chalk",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && tsc --project types && flow --max-warnings=0 && nyc ava",
|
||||
"bench": "matcha benchmark.js",
|
||||
"coveralls": "nyc report --reporter=text-lcov | coveralls"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"templates.js",
|
||||
"types/index.d.ts",
|
||||
"index.js.flow"
|
||||
],
|
||||
"keywords": [
|
||||
"color",
|
||||
"colour",
|
||||
"colors",
|
||||
"terminal",
|
||||
"console",
|
||||
"cli",
|
||||
"string",
|
||||
"str",
|
||||
"ansi",
|
||||
"style",
|
||||
"styles",
|
||||
"tty",
|
||||
"formatting",
|
||||
"rgb",
|
||||
"256",
|
||||
"shell",
|
||||
"xterm",
|
||||
"log",
|
||||
"logging",
|
||||
"command-line",
|
||||
"text"
|
||||
],
|
||||
"dependencies": {
|
||||
"ansi-styles": "^3.2.1",
|
||||
"escape-string-regexp": "^1.0.5",
|
||||
"supports-color": "^5.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "*",
|
||||
"coveralls": "^3.0.0",
|
||||
"execa": "^0.9.0",
|
||||
"flow-bin": "^0.68.0",
|
||||
"import-fresh": "^2.0.0",
|
||||
"matcha": "^0.7.0",
|
||||
"nyc": "^11.0.2",
|
||||
"resolve-from": "^4.0.0",
|
||||
"typescript": "^2.5.3",
|
||||
"xo": "*"
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"xo": {
|
||||
"envs": [
|
||||
"node",
|
||||
"mocha"
|
||||
],
|
||||
"ignores": [
|
||||
"test/_flow.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
314
node_modules/serve/node_modules/chalk/readme.md
generated
vendored
Normal file
314
node_modules/serve/node_modules/chalk/readme.md
generated
vendored
Normal file
@@ -0,0 +1,314 @@
|
||||
<h1 align="center">
|
||||
<br>
|
||||
<br>
|
||||
<img width="320" src="media/logo.svg" alt="Chalk">
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</h1>
|
||||
|
||||
> Terminal string styling done right
|
||||
|
||||
[](https://travis-ci.org/chalk/chalk) [](https://coveralls.io/github/chalk/chalk?branch=master) [](https://www.youtube.com/watch?v=9auOCbH5Ns4) [](https://github.com/xojs/xo) [](https://github.com/sindresorhus/awesome-nodejs)
|
||||
|
||||
### [See what's new in Chalk 2](https://github.com/chalk/chalk/releases/tag/v2.0.0)
|
||||
|
||||
<img src="https://cdn.rawgit.com/chalk/ansi-styles/8261697c95bf34b6c7767e2cbe9941a851d59385/screenshot.svg" alt="" width="900">
|
||||
|
||||
|
||||
## Highlights
|
||||
|
||||
- Expressive API
|
||||
- Highly performant
|
||||
- Ability to nest styles
|
||||
- [256/Truecolor color support](#256-and-truecolor-color-support)
|
||||
- Auto-detects color support
|
||||
- Doesn't extend `String.prototype`
|
||||
- Clean and focused
|
||||
- Actively maintained
|
||||
- [Used by ~23,000 packages](https://www.npmjs.com/browse/depended/chalk) as of December 31, 2017
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```console
|
||||
$ npm install chalk
|
||||
```
|
||||
|
||||
<a href="https://www.patreon.com/sindresorhus">
|
||||
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
|
||||
</a>
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
console.log(chalk.blue('Hello world!'));
|
||||
```
|
||||
|
||||
Chalk comes with an easy to use composable API where you just chain and nest the styles you want.
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
const log = console.log;
|
||||
|
||||
// Combine styled and normal strings
|
||||
log(chalk.blue('Hello') + ' World' + chalk.red('!'));
|
||||
|
||||
// Compose multiple styles using the chainable API
|
||||
log(chalk.blue.bgRed.bold('Hello world!'));
|
||||
|
||||
// Pass in multiple arguments
|
||||
log(chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'));
|
||||
|
||||
// Nest styles
|
||||
log(chalk.red('Hello', chalk.underline.bgBlue('world') + '!'));
|
||||
|
||||
// Nest styles of the same type even (color, underline, background)
|
||||
log(chalk.green(
|
||||
'I am a green line ' +
|
||||
chalk.blue.underline.bold('with a blue substring') +
|
||||
' that becomes green again!'
|
||||
));
|
||||
|
||||
// ES2015 template literal
|
||||
log(`
|
||||
CPU: ${chalk.red('90%')}
|
||||
RAM: ${chalk.green('40%')}
|
||||
DISK: ${chalk.yellow('70%')}
|
||||
`);
|
||||
|
||||
// ES2015 tagged template literal
|
||||
log(chalk`
|
||||
CPU: {red ${cpu.totalPercent}%}
|
||||
RAM: {green ${ram.used / ram.total * 100}%}
|
||||
DISK: {rgb(255,131,0) ${disk.used / disk.total * 100}%}
|
||||
`);
|
||||
|
||||
// Use RGB colors in terminal emulators that support it.
|
||||
log(chalk.keyword('orange')('Yay for orange colored text!'));
|
||||
log(chalk.rgb(123, 45, 67).underline('Underlined reddish color'));
|
||||
log(chalk.hex('#DEADED').bold('Bold gray!'));
|
||||
```
|
||||
|
||||
Easily define your own themes:
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
const error = chalk.bold.red;
|
||||
const warning = chalk.keyword('orange');
|
||||
|
||||
console.log(error('Error!'));
|
||||
console.log(warning('Warning!'));
|
||||
```
|
||||
|
||||
Take advantage of console.log [string substitution](https://nodejs.org/docs/latest/api/console.html#console_console_log_data_args):
|
||||
|
||||
```js
|
||||
const name = 'Sindre';
|
||||
console.log(chalk.green('Hello %s'), name);
|
||||
//=> 'Hello Sindre'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### chalk.`<style>[.<style>...](string, [string...])`
|
||||
|
||||
Example: `chalk.red.bold.underline('Hello', 'world');`
|
||||
|
||||
Chain [styles](#styles) and call the last one as a method with a string argument. Order doesn't matter, and later styles take precedent in case of a conflict. This simply means that `chalk.red.yellow.green` is equivalent to `chalk.green`.
|
||||
|
||||
Multiple arguments will be separated by space.
|
||||
|
||||
### chalk.enabled
|
||||
|
||||
Color support is automatically detected, as is the level (see `chalk.level`). However, if you'd like to simply enable/disable Chalk, you can do so via the `.enabled` property.
|
||||
|
||||
Chalk is enabled by default unless explicitly disabled via the constructor or `chalk.level` is `0`.
|
||||
|
||||
If you need to change this in a reusable module, create a new instance:
|
||||
|
||||
```js
|
||||
const ctx = new chalk.constructor({enabled: false});
|
||||
```
|
||||
|
||||
### chalk.level
|
||||
|
||||
Color support is automatically detected, but you can override it by setting the `level` property. You should however only do this in your own code as it applies globally to all Chalk consumers.
|
||||
|
||||
If you need to change this in a reusable module, create a new instance:
|
||||
|
||||
```js
|
||||
const ctx = new chalk.constructor({level: 0});
|
||||
```
|
||||
|
||||
Levels are as follows:
|
||||
|
||||
0. All colors disabled
|
||||
1. Basic color support (16 colors)
|
||||
2. 256 color support
|
||||
3. Truecolor support (16 million colors)
|
||||
|
||||
### chalk.supportsColor
|
||||
|
||||
Detect whether the terminal [supports color](https://github.com/chalk/supports-color). Used internally and handled for you, but exposed for convenience.
|
||||
|
||||
Can be overridden by the user with the flags `--color` and `--no-color`. For situations where using `--color` is not possible, add the environment variable `FORCE_COLOR=1` to forcefully enable color or `FORCE_COLOR=0` to forcefully disable. The use of `FORCE_COLOR` overrides all other color support checks.
|
||||
|
||||
Explicit 256/Truecolor mode can be enabled using the `--color=256` and `--color=16m` flags, respectively.
|
||||
|
||||
|
||||
## Styles
|
||||
|
||||
### Modifiers
|
||||
|
||||
- `reset`
|
||||
- `bold`
|
||||
- `dim`
|
||||
- `italic` *(Not widely supported)*
|
||||
- `underline`
|
||||
- `inverse`
|
||||
- `hidden`
|
||||
- `strikethrough` *(Not widely supported)*
|
||||
- `visible` (Text is emitted only if enabled)
|
||||
|
||||
### Colors
|
||||
|
||||
- `black`
|
||||
- `red`
|
||||
- `green`
|
||||
- `yellow`
|
||||
- `blue` *(On Windows the bright version is used since normal blue is illegible)*
|
||||
- `magenta`
|
||||
- `cyan`
|
||||
- `white`
|
||||
- `gray` ("bright black")
|
||||
- `redBright`
|
||||
- `greenBright`
|
||||
- `yellowBright`
|
||||
- `blueBright`
|
||||
- `magentaBright`
|
||||
- `cyanBright`
|
||||
- `whiteBright`
|
||||
|
||||
### Background colors
|
||||
|
||||
- `bgBlack`
|
||||
- `bgRed`
|
||||
- `bgGreen`
|
||||
- `bgYellow`
|
||||
- `bgBlue`
|
||||
- `bgMagenta`
|
||||
- `bgCyan`
|
||||
- `bgWhite`
|
||||
- `bgBlackBright`
|
||||
- `bgRedBright`
|
||||
- `bgGreenBright`
|
||||
- `bgYellowBright`
|
||||
- `bgBlueBright`
|
||||
- `bgMagentaBright`
|
||||
- `bgCyanBright`
|
||||
- `bgWhiteBright`
|
||||
|
||||
|
||||
## Tagged template literal
|
||||
|
||||
Chalk can be used as a [tagged template literal](http://exploringjs.com/es6/ch_template-literals.html#_tagged-template-literals).
|
||||
|
||||
```js
|
||||
const chalk = require('chalk');
|
||||
|
||||
const miles = 18;
|
||||
const calculateFeet = miles => miles * 5280;
|
||||
|
||||
console.log(chalk`
|
||||
There are {bold 5280 feet} in a mile.
|
||||
In {bold ${miles} miles}, there are {green.bold ${calculateFeet(miles)} feet}.
|
||||
`);
|
||||
```
|
||||
|
||||
Blocks are delimited by an opening curly brace (`{`), a style, some content, and a closing curly brace (`}`).
|
||||
|
||||
Template styles are chained exactly like normal Chalk styles. The following two statements are equivalent:
|
||||
|
||||
```js
|
||||
console.log(chalk.bold.rgb(10, 100, 200)('Hello!'));
|
||||
console.log(chalk`{bold.rgb(10,100,200) Hello!}`);
|
||||
```
|
||||
|
||||
Note that function styles (`rgb()`, `hsl()`, `keyword()`, etc.) may not contain spaces between parameters.
|
||||
|
||||
All interpolated values (`` chalk`${foo}` ``) are converted to strings via the `.toString()` method. All curly braces (`{` and `}`) in interpolated value strings are escaped.
|
||||
|
||||
|
||||
## 256 and Truecolor color support
|
||||
|
||||
Chalk supports 256 colors and [Truecolor](https://gist.github.com/XVilka/8346728) (16 million colors) on supported terminal apps.
|
||||
|
||||
Colors are downsampled from 16 million RGB values to an ANSI color format that is supported by the terminal emulator (or by specifying `{level: n}` as a Chalk option). For example, Chalk configured to run at level 1 (basic color support) will downsample an RGB value of #FF0000 (red) to 31 (ANSI escape for red).
|
||||
|
||||
Examples:
|
||||
|
||||
- `chalk.hex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.keyword('orange')('Some orange text')`
|
||||
- `chalk.rgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
Background versions of these models are prefixed with `bg` and the first level of the module capitalized (e.g. `keyword` for foreground colors and `bgKeyword` for background colors).
|
||||
|
||||
- `chalk.bgHex('#DEADED').underline('Hello, world!')`
|
||||
- `chalk.bgKeyword('orange')('Some orange text')`
|
||||
- `chalk.bgRgb(15, 100, 204).inverse('Hello!')`
|
||||
|
||||
The following color models can be used:
|
||||
|
||||
- [`rgb`](https://en.wikipedia.org/wiki/RGB_color_model) - Example: `chalk.rgb(255, 136, 0).bold('Orange!')`
|
||||
- [`hex`](https://en.wikipedia.org/wiki/Web_colors#Hex_triplet) - Example: `chalk.hex('#FF8800').bold('Orange!')`
|
||||
- [`keyword`](https://www.w3.org/wiki/CSS/Properties/color/keywords) (CSS keywords) - Example: `chalk.keyword('orange').bold('Orange!')`
|
||||
- [`hsl`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsl(32, 100, 50).bold('Orange!')`
|
||||
- [`hsv`](https://en.wikipedia.org/wiki/HSL_and_HSV) - Example: `chalk.hsv(32, 100, 100).bold('Orange!')`
|
||||
- [`hwb`](https://en.wikipedia.org/wiki/HWB_color_model) - Example: `chalk.hwb(32, 0, 50).bold('Orange!')`
|
||||
- `ansi16`
|
||||
- `ansi256`
|
||||
|
||||
|
||||
## Windows
|
||||
|
||||
If you're on Windows, do yourself a favor and use [`cmder`](http://cmder.net/) instead of `cmd.exe`.
|
||||
|
||||
|
||||
## Origin story
|
||||
|
||||
[colors.js](https://github.com/Marak/colors.js) used to be the most popular string styling module, but it has serious deficiencies like extending `String.prototype` which causes all kinds of [problems](https://github.com/yeoman/yo/issues/68) and the package is unmaintained. Although there are other packages, they either do too much or not enough. Chalk is a clean and focused alternative.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [chalk-cli](https://github.com/chalk/chalk-cli) - CLI for this module
|
||||
- [ansi-styles](https://github.com/chalk/ansi-styles) - ANSI escape codes for styling strings in the terminal
|
||||
- [supports-color](https://github.com/chalk/supports-color) - Detect whether a terminal supports color
|
||||
- [strip-ansi](https://github.com/chalk/strip-ansi) - Strip ANSI escape codes
|
||||
- [strip-ansi-stream](https://github.com/chalk/strip-ansi-stream) - Strip ANSI escape codes from a stream
|
||||
- [has-ansi](https://github.com/chalk/has-ansi) - Check if a string has ANSI escape codes
|
||||
- [ansi-regex](https://github.com/chalk/ansi-regex) - Regular expression for matching ANSI escape codes
|
||||
- [wrap-ansi](https://github.com/chalk/wrap-ansi) - Wordwrap a string with ANSI escape codes
|
||||
- [slice-ansi](https://github.com/chalk/slice-ansi) - Slice a string with ANSI escape codes
|
||||
- [color-convert](https://github.com/qix-/color-convert) - Converts colors between different models
|
||||
- [chalk-animation](https://github.com/bokub/chalk-animation) - Animate strings in the terminal
|
||||
- [gradient-string](https://github.com/bokub/gradient-string) - Apply color gradients to strings
|
||||
- [chalk-pipe](https://github.com/LitoMore/chalk-pipe) - Create chalk style schemes with simpler style strings
|
||||
- [terminal-link](https://github.com/sindresorhus/terminal-link) - Create clickable links in the terminal
|
||||
|
||||
|
||||
## Maintainers
|
||||
|
||||
- [Sindre Sorhus](https://github.com/sindresorhus)
|
||||
- [Josh Junon](https://github.com/qix-)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
128
node_modules/serve/node_modules/chalk/templates.js
generated
vendored
Normal file
128
node_modules/serve/node_modules/chalk/templates.js
generated
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
'use strict';
|
||||
const TEMPLATE_REGEX = /(?:\\(u[a-f\d]{4}|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
|
||||
const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
|
||||
const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
|
||||
const ESCAPE_REGEX = /\\(u[a-f\d]{4}|x[a-f\d]{2}|.)|([^\\])/gi;
|
||||
|
||||
const ESCAPES = new Map([
|
||||
['n', '\n'],
|
||||
['r', '\r'],
|
||||
['t', '\t'],
|
||||
['b', '\b'],
|
||||
['f', '\f'],
|
||||
['v', '\v'],
|
||||
['0', '\0'],
|
||||
['\\', '\\'],
|
||||
['e', '\u001B'],
|
||||
['a', '\u0007']
|
||||
]);
|
||||
|
||||
function unescape(c) {
|
||||
if ((c[0] === 'u' && c.length === 5) || (c[0] === 'x' && c.length === 3)) {
|
||||
return String.fromCharCode(parseInt(c.slice(1), 16));
|
||||
}
|
||||
|
||||
return ESCAPES.get(c) || c;
|
||||
}
|
||||
|
||||
function parseArguments(name, args) {
|
||||
const results = [];
|
||||
const chunks = args.trim().split(/\s*,\s*/g);
|
||||
let matches;
|
||||
|
||||
for (const chunk of chunks) {
|
||||
if (!isNaN(chunk)) {
|
||||
results.push(Number(chunk));
|
||||
} else if ((matches = chunk.match(STRING_REGEX))) {
|
||||
results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, chr) => escape ? unescape(escape) : chr));
|
||||
} else {
|
||||
throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function parseStyle(style) {
|
||||
STYLE_REGEX.lastIndex = 0;
|
||||
|
||||
const results = [];
|
||||
let matches;
|
||||
|
||||
while ((matches = STYLE_REGEX.exec(style)) !== null) {
|
||||
const name = matches[1];
|
||||
|
||||
if (matches[2]) {
|
||||
const args = parseArguments(name, matches[2]);
|
||||
results.push([name].concat(args));
|
||||
} else {
|
||||
results.push([name]);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
function buildStyle(chalk, styles) {
|
||||
const enabled = {};
|
||||
|
||||
for (const layer of styles) {
|
||||
for (const style of layer.styles) {
|
||||
enabled[style[0]] = layer.inverse ? null : style.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
let current = chalk;
|
||||
for (const styleName of Object.keys(enabled)) {
|
||||
if (Array.isArray(enabled[styleName])) {
|
||||
if (!(styleName in current)) {
|
||||
throw new Error(`Unknown Chalk style: ${styleName}`);
|
||||
}
|
||||
|
||||
if (enabled[styleName].length > 0) {
|
||||
current = current[styleName].apply(current, enabled[styleName]);
|
||||
} else {
|
||||
current = current[styleName];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return current;
|
||||
}
|
||||
|
||||
module.exports = (chalk, tmp) => {
|
||||
const styles = [];
|
||||
const chunks = [];
|
||||
let chunk = [];
|
||||
|
||||
// eslint-disable-next-line max-params
|
||||
tmp.replace(TEMPLATE_REGEX, (m, escapeChar, inverse, style, close, chr) => {
|
||||
if (escapeChar) {
|
||||
chunk.push(unescape(escapeChar));
|
||||
} else if (style) {
|
||||
const str = chunk.join('');
|
||||
chunk = [];
|
||||
chunks.push(styles.length === 0 ? str : buildStyle(chalk, styles)(str));
|
||||
styles.push({inverse, styles: parseStyle(style)});
|
||||
} else if (close) {
|
||||
if (styles.length === 0) {
|
||||
throw new Error('Found extraneous } in Chalk template literal');
|
||||
}
|
||||
|
||||
chunks.push(buildStyle(chalk, styles)(chunk.join('')));
|
||||
chunk = [];
|
||||
styles.pop();
|
||||
} else {
|
||||
chunk.push(chr);
|
||||
}
|
||||
});
|
||||
|
||||
chunks.push(chunk.join(''));
|
||||
|
||||
if (styles.length > 0) {
|
||||
const errMsg = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`;
|
||||
throw new Error(errMsg);
|
||||
}
|
||||
|
||||
return chunks.join('');
|
||||
};
|
||||
97
node_modules/serve/node_modules/chalk/types/index.d.ts
generated
vendored
Normal file
97
node_modules/serve/node_modules/chalk/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// Type definitions for Chalk
|
||||
// Definitions by: Thomas Sauer <https://github.com/t-sauer>
|
||||
|
||||
export const enum Level {
|
||||
None = 0,
|
||||
Basic = 1,
|
||||
Ansi256 = 2,
|
||||
TrueColor = 3
|
||||
}
|
||||
|
||||
export interface ChalkOptions {
|
||||
enabled?: boolean;
|
||||
level?: Level;
|
||||
}
|
||||
|
||||
export interface ChalkConstructor {
|
||||
new (options?: ChalkOptions): Chalk;
|
||||
(options?: ChalkOptions): Chalk;
|
||||
}
|
||||
|
||||
export interface ColorSupport {
|
||||
level: Level;
|
||||
hasBasic: boolean;
|
||||
has256: boolean;
|
||||
has16m: boolean;
|
||||
}
|
||||
|
||||
export interface Chalk {
|
||||
(...text: string[]): string;
|
||||
(text: TemplateStringsArray, ...placeholders: string[]): string;
|
||||
constructor: ChalkConstructor;
|
||||
enabled: boolean;
|
||||
level: Level;
|
||||
rgb(r: number, g: number, b: number): this;
|
||||
hsl(h: number, s: number, l: number): this;
|
||||
hsv(h: number, s: number, v: number): this;
|
||||
hwb(h: number, w: number, b: number): this;
|
||||
bgHex(color: string): this;
|
||||
bgKeyword(color: string): this;
|
||||
bgRgb(r: number, g: number, b: number): this;
|
||||
bgHsl(h: number, s: number, l: number): this;
|
||||
bgHsv(h: number, s: number, v: number): this;
|
||||
bgHwb(h: number, w: number, b: number): this;
|
||||
hex(color: string): this;
|
||||
keyword(color: string): this;
|
||||
|
||||
readonly reset: this;
|
||||
readonly bold: this;
|
||||
readonly dim: this;
|
||||
readonly italic: this;
|
||||
readonly underline: this;
|
||||
readonly inverse: this;
|
||||
readonly hidden: this;
|
||||
readonly strikethrough: this;
|
||||
|
||||
readonly visible: this;
|
||||
|
||||
readonly black: this;
|
||||
readonly red: this;
|
||||
readonly green: this;
|
||||
readonly yellow: this;
|
||||
readonly blue: this;
|
||||
readonly magenta: this;
|
||||
readonly cyan: this;
|
||||
readonly white: this;
|
||||
readonly gray: this;
|
||||
readonly grey: this;
|
||||
readonly blackBright: this;
|
||||
readonly redBright: this;
|
||||
readonly greenBright: this;
|
||||
readonly yellowBright: this;
|
||||
readonly blueBright: this;
|
||||
readonly magentaBright: this;
|
||||
readonly cyanBright: this;
|
||||
readonly whiteBright: this;
|
||||
|
||||
readonly bgBlack: this;
|
||||
readonly bgRed: this;
|
||||
readonly bgGreen: this;
|
||||
readonly bgYellow: this;
|
||||
readonly bgBlue: this;
|
||||
readonly bgMagenta: this;
|
||||
readonly bgCyan: this;
|
||||
readonly bgWhite: this;
|
||||
readonly bgBlackBright: this;
|
||||
readonly bgRedBright: this;
|
||||
readonly bgGreenBright: this;
|
||||
readonly bgYellowBright: this;
|
||||
readonly bgBlueBright: this;
|
||||
readonly bgMagentaBright: this;
|
||||
readonly bgCyanBright: this;
|
||||
readonly bgWhiteBright: this;
|
||||
}
|
||||
|
||||
declare const chalk: Chalk & { supportsColor: ColorSupport };
|
||||
|
||||
export default chalk
|
||||
49
node_modules/serve/package.json
generated
vendored
Normal file
49
node_modules/serve/package.json
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"name": "serve",
|
||||
"version": "12.0.0",
|
||||
"description": "Static file serving and directory listing",
|
||||
"scripts": {
|
||||
"test": "yarn lint",
|
||||
"lint": "zeit-eslint --ext .jsx,.js .",
|
||||
"lint-staged": "git diff --diff-filter=ACMRT --cached --name-only '*.js' '*.jsx' | xargs zeit-eslint"
|
||||
},
|
||||
"files": [
|
||||
"bin"
|
||||
],
|
||||
"repository": "vercel/serve",
|
||||
"bin": {
|
||||
"serve": "./bin/serve.js"
|
||||
},
|
||||
"keywords": [
|
||||
"now",
|
||||
"serve",
|
||||
"micro",
|
||||
"http-server"
|
||||
],
|
||||
"author": "leo",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@zeit/eslint-config-node": "0.3.0",
|
||||
"@zeit/git-hooks": "0.1.4",
|
||||
"eslint": "5.4.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
"@zeit/eslint-config-node"
|
||||
]
|
||||
},
|
||||
"git": {
|
||||
"pre-commit": "lint-staged"
|
||||
},
|
||||
"dependencies": {
|
||||
"@zeit/schemas": "2.6.0",
|
||||
"ajv": "6.12.6",
|
||||
"arg": "2.0.0",
|
||||
"boxen": "1.3.0",
|
||||
"chalk": "2.4.1",
|
||||
"clipboardy": "2.3.0",
|
||||
"compression": "1.7.3",
|
||||
"serve-handler": "6.1.3",
|
||||
"update-check": "1.5.2"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user