node_modules

This commit is contained in:
saeid
2019-07-15 13:07:31 +04:30
parent d3735c6d30
commit ce1a3ebf9c
35713 changed files with 3639219 additions and 1 deletions
+1035
View File
File diff suppressed because it is too large Load Diff
+370
View File
@@ -0,0 +1,370 @@
{
"type": "object",
"properties": {
"serveIndex": {
"type": "boolean"
},
"hot": {
"type": "boolean"
},
"hotOnly": {
"type": "boolean"
},
"lazy": {
"type": "boolean"
},
"bonjour": {
"type": "boolean"
},
"host": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"port": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
},
{
"type": "null"
}
]
},
"allowedHosts": {
"type": "array",
"items": {
"type": "string"
}
},
"filename": {
"anyOf": [
{
"type": "string"
},
{
"instanceof": "RegExp"
},
{
"instanceof": "Function"
}
]
},
"publicPath": {
"type": "string"
},
"socket": {
"type": "string"
},
"sockPath": {
"type": "string"
},
"watchOptions": {
"type": "object"
},
"writeToDisk": {
"anyOf": [
{
"type": "boolean"
},
{
"instanceof": "Function"
}
]
},
"headers": {
"type": "object"
},
"logLevel": {
"enum": ["info", "warn", "error", "debug", "trace", "silent"]
},
"clientLogLevel": {
"enum": ["none", "info", "error", "warning"]
},
"overlay": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "object",
"properties": {
"errors": {
"type": "boolean"
},
"warnings": {
"type": "boolean"
}
}
}
]
},
"progress": {
"type": "boolean"
},
"key": {
"anyOf": [
{
"type": "string"
},
{
"instanceof": "Buffer"
}
]
},
"cert": {
"anyOf": [
{
"type": "string"
},
{
"instanceof": "Buffer"
}
]
},
"ca": {
"anyOf": [
{
"type": "string"
},
{
"instanceof": "Buffer"
}
]
},
"pfx": {
"anyOf": [
{
"type": "string"
},
{
"instanceof": "Buffer"
}
]
},
"pfxPassphrase": {
"type": "string"
},
"requestCert": {
"type": "boolean"
},
"inline": {
"type": "boolean"
},
"disableHostCheck": {
"type": "boolean"
},
"public": {
"type": "string"
},
"https": {
"anyOf": [
{
"type": "object"
},
{
"type": "boolean"
}
]
},
"http2": {
"type": "boolean"
},
"contentBase": {
"anyOf": [
{
"enum": [false]
},
{
"type": "number"
},
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
]
},
"watchContentBase": {
"type": "boolean"
},
"open": {
"anyOf": [
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"useLocalIp": {
"type": "boolean"
},
"openPage": {
"type": "string"
},
"features": {
"type": "array",
"items": {
"type": "string"
}
},
"compress": {
"type": "boolean"
},
"proxy": {
"anyOf": [
{
"type": "object"
},
{
"type": "array",
"items": {
"anyOf": [
{
"type": "object"
},
{
"instanceof": "Function"
}
]
},
"minItems": 1
}
]
},
"historyApiFallback": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "object"
}
]
},
"staticOptions": {
"type": "object"
},
"setup": {
"instanceof": "Function"
},
"before": {
"instanceof": "Function"
},
"after": {
"instanceof": "Function"
},
"stats": {
"anyOf": [
{
"type": "object"
},
{
"type": "boolean"
},
{
"enum": ["none", "errors-only", "minimal", "normal", "verbose"]
}
]
},
"reporter": {
"instanceof": "Function"
},
"logTime": {
"type": "boolean"
},
"noInfo": {
"type": "boolean"
},
"mimeTypes": {
"type": "object"
},
"quiet": {
"type": "boolean"
},
"serverSideRender": {
"type": "boolean"
},
"index": {
"type": "string"
},
"log": {
"instanceof": "Function"
},
"warn": {
"instanceof": "Function"
}
},
"errorMessage": {
"properties": {
"hot": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-hot)",
"hotOnly": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-hotonly)",
"lazy": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-lazy-)",
"bonjour": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-bonjour)",
"publicPath": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-publicpath-)",
"host": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-host)",
"allowedHosts": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserver-allowedhosts)",
"logLevel": "should be {String} and equal to one of the allowed values\n\n [ 'trace', 'debug', 'info', 'warn', 'error', 'silent' ]\n\n(https://webpack.js.org/configuration/dev-server/#devserver-loglevel)",
"filename": "should be {String|RegExp|Function} (https://webpack.js.org/configuration/dev-server/#devserver-filename-)",
"port": "should be {String|Number} (https://webpack.js.org/configuration/dev-server/#devserver-port)",
"socket": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-socket)",
"sockPath": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-sockPath)",
"watchOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserver-watchoptions)",
"writeToDisk": "should be {Boolean|Function} (https://github.com/webpack/webpack-dev-middleware#writetodisk)",
"headers": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserver-headers-)",
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'trace', 'debug', 'info', 'warn', 'error', 'silent' ]\n\n(https://webpack.js.org/configuration/dev-server/#devserver-clientloglevel)",
"overlay": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-overlay)",
"progress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-progress-cli-only)",
"key": "should be {String|Buffer} (https://webpack.js.org/configuration/dev-server/#devserver-key)",
"cert": "should be {String|Buffer} (https://webpack.js.org/configuration/dev-server/#devserver-cert)",
"ca": "should be {String|Buffer} (https://webpack.js.org/configuration/dev-server/#devserver-ca)",
"pfx": "should be {String|Buffer} (https://webpack.js.org/configuration/dev-server/#devserver-pfx)",
"pfxPassphrase": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-pfxpassphrase)",
"requestCert": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-requestcert)",
"inline": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-inline)",
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-disablehostcheck)",
"public": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-public)",
"https": "should be {Object|Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-https)",
"http2": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-http2)",
"contentBase": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserver-contentbase)",
"watchContentBase": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-watchcontentbase)",
"open": "should be {String|Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-open)",
"useLocalIp": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-uselocalip)",
"openPage": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-openpage)",
"features": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserver-features)",
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-compress)",
"proxy": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-hot)",
"historyApiFallback": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-historyapifallback)",
"staticOptions": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-staticOptions)",
"setup": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserver-setup)",
"before": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserver-before)",
"after": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserver-after)",
"stats": "should be {Boolean|Object|String} (https://webpack.js.org/configuration/dev-server/#devserver-stats-)",
"reporter": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserver-reporter)",
"logTime": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-logtime)",
"noInfo": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-noinfo-)",
"mimeTypes": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devservermimetypes-)",
"quiet": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-quiet-)",
"serverSideRender": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-serversiderender)",
"index": "should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-index)",
"log": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserver-log)",
"warn": "should be {Function} (https://webpack.js.org/configuration/dev-server/#devserver-warn)"
}
},
"additionalProperties": false
}
+76
View File
@@ -0,0 +1,76 @@
'use strict';
const webpack = require('webpack');
const createDomain = require('./createDomain');
function addEntries(config, options, server) {
if (options.inline !== false) {
// we're stubbing the app in this method as it's static and doesn't require
// a server to be supplied. createDomain requires an app with the
// address() signature.
const app = server || {
address() {
return { port: options.port };
},
};
const domain = createDomain(options, app);
const sockPath = options.sockPath ? `&sockPath=${options.sockPath}` : '';
const entries = [
`${require.resolve('../../client/')}?${domain}${sockPath}`,
];
if (options.hotOnly) {
entries.push(require.resolve('webpack/hot/only-dev-server'));
} else if (options.hot) {
entries.push(require.resolve('webpack/hot/dev-server'));
}
const prependEntry = (entry) => {
if (typeof entry === 'function') {
return () => Promise.resolve(entry()).then(prependEntry);
}
if (typeof entry === 'object' && !Array.isArray(entry)) {
const clone = {};
Object.keys(entry).forEach((key) => {
// entry[key] should be a string here
clone[key] = prependEntry(entry[key]);
});
return clone;
}
// in this case, entry is a string or an array.
// make sure that we do not add duplicates.
const entriesClone = entries.slice(0);
[].concat(entry).forEach((newEntry) => {
if (!entriesClone.includes(newEntry)) {
entriesClone.push(newEntry);
}
});
return entriesClone;
};
// eslint-disable-next-line no-shadow
[].concat(config).forEach((config) => {
config.entry = prependEntry(config.entry || './src');
if (options.hot || options.hotOnly) {
config.plugins = config.plugins || [];
if (
!config.plugins.find(
(plugin) =>
plugin.constructor === webpack.HotModuleReplacementPlugin
)
) {
config.plugins.push(new webpack.HotModuleReplacementPlugin());
}
}
});
}
}
module.exports = addEntries;
+22
View File
@@ -0,0 +1,22 @@
'use strict';
const colors = {
info(useColor, msg) {
if (useColor) {
// Make text blue and bold, so it *pops*
return `\u001b[1m\u001b[34m${msg}\u001b[39m\u001b[22m`;
}
return msg;
},
error(useColor, msg) {
if (useColor) {
// Make text red and bold, so it *pops*
return `\u001b[1m\u001b[31m${msg}\u001b[39m\u001b[22m`;
}
return msg;
},
};
module.exports = colors;
+62
View File
@@ -0,0 +1,62 @@
'use strict';
const selfsigned = require('selfsigned');
function createCertificate(attrs) {
return selfsigned.generate(attrs, {
algorithm: 'sha256',
days: 30,
keySize: 2048,
extensions: [
{
name: 'basicConstraints',
cA: true,
},
{
name: 'keyUsage',
keyCertSign: true,
digitalSignature: true,
nonRepudiation: true,
keyEncipherment: true,
dataEncipherment: true,
},
{
name: 'subjectAltName',
altNames: [
{
// type 2 is DNS
type: 2,
value: 'localhost',
},
{
type: 2,
value: 'localhost.localdomain',
},
{
type: 2,
value: 'lvh.me',
},
{
type: 2,
value: '*.lvh.me',
},
{
type: 2,
value: '[::1]',
},
{
// type 7 is IP
type: 7,
ip: '127.0.0.1',
},
{
type: 7,
ip: 'fe80::1',
},
],
},
],
});
}
module.exports = createCertificate;
+208
View File
@@ -0,0 +1,208 @@
'use strict';
const path = require('path');
const defaultTo = require('./defaultTo');
function createConfig(config, argv, { port }) {
const firstWpOpt = Array.isArray(config) ? config[0] : config;
const options = firstWpOpt.devServer || {};
// This updates both config and firstWpOpt
firstWpOpt.mode = defaultTo(firstWpOpt.mode, 'development');
if (argv.bonjour) {
options.bonjour = true;
}
if (argv.host && (argv.host !== 'localhost' || !options.host)) {
options.host = argv.host;
}
if (argv.allowedHosts) {
options.allowedHosts = argv.allowedHosts.split(',');
}
if (argv.public) {
options.public = argv.public;
}
if (argv.socket) {
options.socket = argv.socket;
}
if (argv.progress) {
options.progress = argv.progress;
}
if (!options.publicPath) {
// eslint-disable-next-line
options.publicPath =
(firstWpOpt.output && firstWpOpt.output.publicPath) || '';
if (
!/^(https?:)?\/\//.test(options.publicPath) &&
options.publicPath[0] !== '/'
) {
options.publicPath = `/${options.publicPath}`;
}
}
if (!options.filename && firstWpOpt.output && firstWpOpt.output.filename) {
options.filename = firstWpOpt.output && firstWpOpt.output.filename;
}
if (!options.watchOptions && firstWpOpt.watchOptions) {
options.watchOptions = firstWpOpt.watchOptions;
}
if (argv.stdin) {
process.stdin.on('end', () => {
// eslint-disable-next-line no-process-exit
process.exit(0);
});
process.stdin.resume();
}
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
// We should prefer CLI arg under config, now we always prefer `hot` from `devServer`
if (!options.hot) {
options.hot = argv.hot;
}
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
// We should prefer CLI arg under config, now we always prefer `hotOnly` from `devServer`
if (!options.hotOnly) {
options.hotOnly = argv.hotOnly;
}
// TODO https://github.com/webpack/webpack-dev-server/issues/616 (v4)
// We should prefer CLI arg under config, now we always prefer `clientLogLevel` from `devServer`
if (!options.clientLogLevel && argv.clientLogLevel) {
options.clientLogLevel = argv.clientLogLevel;
}
if (argv.contentBase) {
options.contentBase = argv.contentBase;
if (Array.isArray(options.contentBase)) {
options.contentBase = options.contentBase.map((p) => path.resolve(p));
} else if (/^[0-9]$/.test(options.contentBase)) {
options.contentBase = +options.contentBase;
} else if (!/^(https?:)?\/\//.test(options.contentBase)) {
options.contentBase = path.resolve(options.contentBase);
}
}
// It is possible to disable the contentBase by using
// `--no-content-base`, which results in arg["content-base"] = false
else if (argv.contentBase === false) {
options.contentBase = false;
}
if (argv.watchContentBase) {
options.watchContentBase = true;
}
if (!options.stats) {
options.stats = defaultTo(firstWpOpt.stats, {
cached: false,
cachedAssets: false,
});
}
if (
typeof options.stats === 'object' &&
typeof options.stats.colors === 'undefined' &&
argv.color
) {
options.stats = Object.assign({}, options.stats, { colors: argv.color });
}
if (argv.lazy) {
options.lazy = true;
}
// TODO remove in `v4`
if (!argv.info) {
options.noInfo = true;
}
// TODO remove in `v4`
if (argv.quiet) {
options.quiet = true;
}
if (argv.https) {
options.https = true;
}
if (argv.http2) {
options.http2 = true;
}
if (argv.key) {
options.key = argv.key;
}
if (argv.cert) {
options.cert = argv.cert;
}
if (argv.cacert) {
options.ca = argv.cacert;
}
if (argv.pfx) {
options.pfx = argv.pfx;
}
if (argv.pfxPassphrase) {
options.pfxPassphrase = argv.pfxPassphrase;
}
if (argv.inline === false) {
options.inline = false;
}
if (argv.historyApiFallback) {
options.historyApiFallback = true;
}
if (argv.compress) {
options.compress = true;
}
if (argv.disableHostCheck) {
options.disableHostCheck = true;
}
if (argv.openPage) {
options.open = true;
options.openPage = argv.openPage;
}
if (typeof argv.open !== 'undefined') {
options.open = argv.open !== '' ? argv.open : true;
}
if (options.open && !options.openPage) {
options.openPage = '';
}
if (argv.useLocalIp) {
options.useLocalIp = true;
}
// Kind of weird, but ensures prior behavior isn't broken in cases
// that wouldn't throw errors. E.g. both argv.port and options.port
// were specified, but since argv.port is 8080, options.port will be
// tried first instead.
options.port =
argv.port === port
? defaultTo(options.port, argv.port)
: defaultTo(argv.port, options.port);
return options;
}
module.exports = createConfig;
+29
View File
@@ -0,0 +1,29 @@
'use strict';
const url = require('url');
const ip = require('internal-ip');
function createDomain(options, server) {
const protocol = options.https ? 'https' : 'http';
const hostname = options.useLocalIp
? ip.v4.sync() || 'localhost'
: options.host || 'localhost';
// eslint-disable-next-line no-nested-ternary
const port = options.socket ? 0 : server ? server.address().port : 0;
// use explicitly defined public url
// (prefix with protocol if not explicitly given)
if (options.public) {
return /^[a-zA-Z]+:\/\//.test(options.public)
? `${options.public}`
: `${protocol}://${options.public}`;
}
// the formatted domain (url without path) of the webpack server
return url.format({
protocol,
hostname,
port,
});
}
module.exports = createDomain;
+23
View File
@@ -0,0 +1,23 @@
'use strict';
const log = require('webpack-log');
function createLogger(options) {
let level = options.logLevel || 'info';
if (options.noInfo === true) {
level = 'warn';
}
if (options.quiet === true) {
level = 'silent';
}
return log({
name: 'wds',
level,
timestamp: options.logTime,
});
}
module.exports = createLogger;
+7
View File
@@ -0,0 +1,7 @@
'use strict';
function defaultTo(value, def) {
return value == null ? def : value;
}
module.exports = defaultTo;
+35
View File
@@ -0,0 +1,35 @@
'use strict';
const portfinder = require('portfinder');
function runPortFinder(defaultPort, cb) {
portfinder.basePort = defaultPort;
portfinder.getPort((err, port) => {
cb(err, port);
});
}
function findPort(server, defaultPort, defaultPortRetry, fn) {
let tryCount = 0;
const portFinderRunCb = (err, port) => {
tryCount += 1;
fn(err, port);
};
server.listeningApp.on('error', (err) => {
if (err && err.code !== 'EADDRINUSE') {
throw err;
}
if (tryCount >= defaultPortRetry) {
fn(err);
return;
}
runPortFinder(defaultPort, portFinderRunCb);
});
runPortFinder(defaultPort, portFinderRunCb);
}
module.exports = findPort;
+12
View File
@@ -0,0 +1,12 @@
'use strict';
/* eslint-disable global-require */
function getVersions() {
return (
`webpack-dev-server ${require('../../package.json').version}\n` +
`webpack ${require('webpack/package.json').version}`
);
}
module.exports = getVersions;
+21
View File
@@ -0,0 +1,21 @@
'use strict';
function runBonjour(options) {
// eslint-disable-next-line global-require
const bonjour = require('bonjour')();
bonjour.publish({
name: 'Webpack Dev Server',
port: options.port,
type: 'http',
subtypes: ['webpack'],
});
process.on('exit', () => {
bonjour.unpublishAll(() => {
bonjour.destroy();
});
});
}
module.exports = runBonjour;
+62
View File
@@ -0,0 +1,62 @@
'use strict';
const open = require('opn');
const colors = require('./colors');
function status(uri, options, log, useColor) {
const contentBase = Array.isArray(options.contentBase)
? options.contentBase.join(', ')
: options.contentBase;
if (options.socket) {
log.info(`Listening to socket at ${colors.info(useColor, options.socket)}`);
} else {
log.info(`Project is running at ${colors.info(useColor, uri)}`);
}
log.info(
`webpack output is served from ${colors.info(useColor, options.publicPath)}`
);
if (contentBase) {
log.info(
`Content not from webpack is served from ${colors.info(
useColor,
contentBase
)}`
);
}
if (options.historyApiFallback) {
log.info(
`404s will fallback to ${colors.info(
useColor,
options.historyApiFallback.index || '/index.html'
)}`
);
}
if (options.bonjour) {
log.info(
'Broadcasting "http" with subtype of "webpack" via ZeroConf DNS (Bonjour)'
);
}
if (options.open) {
let openOptions = {};
let openMessage = 'Unable to open browser';
if (typeof options.open === 'string') {
openOptions = { app: options.open };
openMessage += `: ${options.open}`;
}
open(uri + (options.openPage || ''), openOptions).catch(() => {
log.warn(
`${openMessage}. If you are running in a headless environment, please do not use the --open flag`
);
});
}
}
module.exports = status;
+11
View File
@@ -0,0 +1,11 @@
'use strict';
function tryParseInt(input) {
const output = parseInt(input, 10);
if (Number.isNaN(output)) {
return null;
}
return output;
}
module.exports = tryParseInt;
+67
View File
@@ -0,0 +1,67 @@
'use strict';
/* eslint-disable
no-shadow,
no-undefined
*/
const webpack = require('webpack');
const addEntries = require('./addEntries');
function updateCompiler(compiler, options) {
if (options.inline !== false) {
const findHMRPlugin = (config) => {
if (!config.plugins) {
return undefined;
}
return config.plugins.find(
(plugin) => plugin.constructor === webpack.HotModuleReplacementPlugin
);
};
const compilers = [];
const compilersWithoutHMR = [];
let webpackConfig;
if (compiler.compilers) {
webpackConfig = [];
compiler.compilers.forEach((compiler) => {
webpackConfig.push(compiler.options);
compilers.push(compiler);
if (!findHMRPlugin(compiler.options)) {
compilersWithoutHMR.push(compiler);
}
});
} else {
webpackConfig = compiler.options;
compilers.push(compiler);
if (!findHMRPlugin(compiler.options)) {
compilersWithoutHMR.push(compiler);
}
}
// it's possible that we should clone the config before doing
// this, but it seems safe not to since it actually reflects
// the changes we are making to the compiler
// important: this relies on the fact that addEntries now
// prevents duplicate new entries.
addEntries(webpackConfig, options);
compilers.forEach((compiler) => {
const config = compiler.options;
compiler.hooks.entryOption.call(config.context, config.entry);
});
// do not apply the plugin unless it didn't exist before.
if (options.hot || options.hotOnly) {
compilersWithoutHMR.forEach((compiler) => {
// addDevServerEntrypoints above should have added the plugin
// to the compiler options
const plugin = findHMRPlugin(compiler.options);
if (plugin) {
plugin.apply(compiler);
}
});
}
}
}
module.exports = updateCompiler;