Removed GopherJS, basic frontend completed, need backend changes for

torrent storage
This commit is contained in:
2017-11-30 18:12:11 -05:00
parent 67fdef16b1
commit e98ad2cc88
69321 changed files with 5498914 additions and 337 deletions

View File

@@ -0,0 +1,48 @@
module.exports = function(optimist) {
optimist
.boolean("help").alias("help", "h").alias("help", "?").describe("help")
.string("config").describe("config", "Path to the config file")
.string("config-name").describe("config-name", "Name of the config to use")
.string("env").describe("env", "Environment passed to the config, when it is a function")
.string("context").describe("context", "The root directory for resolving entry point and stats")
.string("entry").describe("entry", "The entry point")
.string("module-bind").describe("module-bind", "Bind an extension to a loader")
.string("module-bind-post").describe("module-bind-post")
.string("module-bind-pre").describe("module-bind-pre")
.string("output-path").describe("output-path", "The output path for compilation assets")
.string("output-filename").describe("output-filename", "The output filename of the bundle")
.string("output-chunk-filename").describe("output-chunk-filename", "The output filename for additional chunks")
.string("output-source-map-filename").describe("output-source-map-filename", "The output filename for the SourceMap")
.string("output-public-path").describe("output-public-path", "The public path for the assets")
.string("output-jsonp-function").describe("output-jsonp-function", "The name of the jsonp function used for chunk loading")
.boolean("output-pathinfo").describe("output-pathinfo", "Include a comment with the request for every dependency")
.string("output-library").describe("output-library", "Expose the exports of the entry point as library")
.string("output-library-target").describe("output-library-target", "The type for exposing the exports of the entry point as library")
.string("records-input-path").describe("records-input-path", "Path to the records file (reading)")
.string("records-output-path").describe("records-output-path", "Path to the records file (writing)")
.string("records-path").describe("records-path", "Path to the records file")
.string("define").describe("define", "Define any free var in the bundle")
.string("target").describe("target", "The targeted execution environment")
.boolean("cache").describe("cache", "Enable in memory caching").default("cache", true)
.boolean("watch").alias("watch", "w").describe("watch", "Watch the filesystem for changes")
.boolean("watch-stdin").alias("watch-stdin", "stdin").describe("Exit the process when stdin is closed")
.describe("watch-aggregate-timeout", "Timeout for gathering changes while watching")
.describe("watch-poll", "The polling interval for watching (also enable polling)")
.boolean("hot").describe("hot", "Enables Hot Module Replacement")
.boolean("debug").describe("debug", "Switch loaders to debug mode")
.string("devtool").describe("devtool", "Enable devtool for better debugging experience")
.boolean("progress").describe("progress", "Print compilation progress in percentage")
.string("resolve-alias").describe("resolve-alias", "Setup a module alias for resolving")
.string("resolve-extensions").describe("resolve-extensions", "Setup extensions that should be used to resolve modules")
.string("resolve-loader-alias").describe("resolve-loader-alias", "Setup a loader alias for resolving")
.describe("optimize-max-chunks", "Try to keep the chunk count below a limit")
.describe("optimize-min-chunk-size", "Try to keep the chunk size above a limit")
.boolean("optimize-minimize").describe("optimize-minimize", "Minimize javascript and switches loaders to minimizing")
.string("prefetch").describe("prefetch", "Prefetch this request")
.string("provide").describe("provide", "Provide these modules as free vars in all modules")
.string("plugin").describe("plugin", "Load this plugin")
.boolean("bail").describe("bail", "Abort the compilation on first error")
.boolean("profile").describe("profile", "Profile the compilation and include information in stats")
.boolean("d").describe("d", "shortcut for --debug --devtool eval-check-module-source-map --output-pathinfo")
.boolean("p").describe("p", "shortcut for --optimize-minimize --define process.env.NODE_ENV=\"production\"");
};

View File

@@ -0,0 +1,274 @@
var CONFIG_GROUP = "Config options:";
var BASIC_GROUP = "Basic options:";
var MODULE_GROUP = "Module options:";
var OUTPUT_GROUP = "Output options:";
var ADVANCED_GROUP = "Advanced options:";
var RESOLVE_GROUP = "Resolving options:";
var OPTIMIZE_GROUP = "Optimizing options:";
module.exports = function(yargs) {
yargs
.help("help")
.alias("help", "h")
.version()
.alias("version", "v")
.options({
"config": {
type: "string",
describe: "Path to the config file",
group: CONFIG_GROUP,
defaultDescription: "webpack.config.js or webpackfile.js",
requiresArg: true
},
"config-name": {
type: "string",
describe: "Name of the config to use",
group: CONFIG_GROUP,
requiresArg: true
},
"env": {
describe: "Environment passed to the config, when it is a function",
group: CONFIG_GROUP
},
"context": {
type: "string",
describe: "The root directory for resolving entry point and stats",
group: BASIC_GROUP,
defaultDescription: "The current directory",
requiresArg: true
},
"entry": {
type: "string",
describe: "The entry point",
group: BASIC_GROUP,
requiresArg: true
},
"module-bind": {
type: "string",
describe: "Bind an extension to a loader",
group: MODULE_GROUP,
requiresArg: true
},
"module-bind-post": {
type: "string",
describe: "",
group: MODULE_GROUP,
requiresArg: true
},
"module-bind-pre": {
type: "string",
describe: "",
group: MODULE_GROUP,
requiresArg: true
},
"output-path": {
type: "string",
describe: "The output path for compilation assets",
group: OUTPUT_GROUP,
defaultDescription: "The current directory",
requiresArg: true
},
"output-filename": {
type: "string",
describe: "The output filename of the bundle",
group: OUTPUT_GROUP,
defaultDescription: "[name].js",
requiresArg: true
},
"output-chunk-filename": {
type: "string",
describe: "The output filename for additional chunks",
group: OUTPUT_GROUP,
defaultDescription: "filename with [id] instead of [name] or [id] prefixed",
requiresArg: true
},
"output-source-map-filename": {
type: "string",
describe: "The output filename for the SourceMap",
group: OUTPUT_GROUP,
requiresArg: true
},
"output-public-path": {
type: "string",
describe: "The public path for the assets",
group: OUTPUT_GROUP,
requiresArg: true
},
"output-jsonp-function": {
type: "string",
describe: "The name of the jsonp function used for chunk loading",
group: OUTPUT_GROUP,
requiresArg: true
},
"output-pathinfo": {
type: "boolean",
describe: "Include a comment with the request for every dependency (require, import, etc.)",
group: OUTPUT_GROUP
},
"output-library": {
type: "string",
describe: "Expose the exports of the entry point as library",
group: OUTPUT_GROUP,
requiresArg: true
},
"output-library-target": {
type: "string",
describe: "The type for exposing the exports of the entry point as library",
group: OUTPUT_GROUP,
requiresArg: true
},
"records-input-path": {
type: "string",
describe: "Path to the records file (reading)",
group: ADVANCED_GROUP,
requiresArg: true
},
"records-output-path": {
type: "string",
describe: "Path to the records file (writing)",
group: ADVANCED_GROUP,
requiresArg: true
},
"records-path": {
type: "string",
describe: "Path to the records file",
group: ADVANCED_GROUP,
requiresArg: true
},
"define": {
type: "string",
describe: "Define any free var in the bundle",
group: ADVANCED_GROUP,
requiresArg: true
},
"target": {
type: "string",
describe: "The targeted execution environment",
group: ADVANCED_GROUP,
requiresArg: true
},
"cache": {
type: "boolean",
describe: "Enable in memory caching",
default: null,
group: ADVANCED_GROUP,
defaultDescription: "It's enabled by default when watching"
},
"watch": {
type: "boolean",
alias: "w",
describe: "Watch the filesystem for changes",
group: BASIC_GROUP
},
"watch-stdin": {
type: "boolean",
alias: "stdin",
describe: "Exit the process when stdin is closed",
group: ADVANCED_GROUP
},
"watch-aggregate-timeout": {
describe: "Timeout for gathering changes while watching",
group: ADVANCED_GROUP,
requiresArg: true
},
"watch-poll": {
type: "string",
describe: "The polling interval for watching (also enable polling)",
group: ADVANCED_GROUP
},
"hot": {
type: "boolean",
describe: "Enables Hot Module Replacement",
group: ADVANCED_GROUP
},
"debug": {
type: "boolean",
describe: "Switch loaders to debug mode",
group: BASIC_GROUP
},
"devtool": {
type: "string",
describe: "Enable devtool for better debugging experience (Example: --devtool eval-cheap-module-source-map)",
group: BASIC_GROUP,
requiresArg: true
},
"resolve-alias": {
type: "string",
describe: "Setup a module alias for resolving (Example: jquery-plugin=jquery.plugin)",
group: RESOLVE_GROUP,
requiresArg: true
},
"resolve-extensions": {
"type": "array",
describe: "Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6,.js)",
group: RESOLVE_GROUP,
requiresArg: true
},
"resolve-loader-alias": {
type: "string",
describe: "Setup a loader alias for resolving",
group: RESOLVE_GROUP,
requiresArg: true
},
"optimize-max-chunks": {
describe: "Try to keep the chunk count below a limit",
group: OPTIMIZE_GROUP,
requiresArg: true
},
"optimize-min-chunk-size": {
describe: "Try to keep the chunk size above a limit",
group: OPTIMIZE_GROUP,
requiresArg: true
},
"optimize-minimize": {
type: "boolean",
describe: "Minimize javascript and switches loaders to minimizing",
group: OPTIMIZE_GROUP
},
"prefetch": {
type: "string",
describe: "Prefetch this request (Example: --prefetch ./file.js)",
group: ADVANCED_GROUP,
requiresArg: true
},
"provide": {
type: "string",
describe: "Provide these modules as free vars in all modules (Example: --provide jQuery=jquery)",
group: ADVANCED_GROUP,
requiresArg: true
},
"labeled-modules": {
type: "boolean",
describe: "Enables labeled modules",
group: ADVANCED_GROUP
},
"plugin": {
type: "string",
describe: "Load this plugin",
group: ADVANCED_GROUP,
requiresArg: true
},
"bail": {
type: "boolean",
describe: "Abort the compilation on first error",
group: ADVANCED_GROUP,
default: null
},
"profile": {
type: "boolean",
describe: "Profile the compilation and include information in stats",
group: ADVANCED_GROUP,
default: null
},
"d": {
type: "boolean",
describe: "shortcut for --debug --devtool eval-cheap-module-source-map --output-pathinfo",
group: BASIC_GROUP
},
"p": {
type: "boolean",
describe: "shortcut for --optimize-minimize --define process.env.NODE_ENV=\"production\"",
group: BASIC_GROUP
}
}).strict();
};

View File

@@ -0,0 +1,562 @@
var path = require("path");
var fs = require("fs");
fs.existsSync = fs.existsSync || path.existsSync;
var interpret = require("interpret");
var prepareOptions = require("../lib/prepareOptions");
module.exports = function(yargs, argv, convertOptions) {
var options = [];
// Shortcuts
if(argv.d) {
argv.debug = true;
argv["output-pathinfo"] = true;
if(!argv.devtool) {
argv.devtool = "eval-cheap-module-source-map";
}
}
if(argv.p) {
argv["optimize-minimize"] = true;
argv["define"] = [].concat(argv["define"] || []).concat("process.env.NODE_ENV=\"production\"");
}
var configFileLoaded = false;
var configFiles = [];
var extensions = Object.keys(interpret.extensions).sort(function(a, b) {
return a === ".js" ? -1 : b === ".js" ? 1 : a.length - b.length;
});
var defaultConfigFiles = ["webpack.config", "webpackfile"].map(function(filename) {
return extensions.map(function(ext) {
return {
path: path.resolve(filename + ext),
ext: ext
};
});
}).reduce(function(a, i) {
return a.concat(i);
}, []);
var i;
if(argv.config) {
var getConfigExtension = function getConfigExtension(configPath) {
for(i = extensions.length - 1; i >= 0; i--) {
var tmpExt = extensions[i];
if(configPath.indexOf(tmpExt, configPath.length - tmpExt.length) > -1) {
return tmpExt;
}
}
return path.extname(configPath);
};
var mapConfigArg = function mapConfigArg(configArg) {
var resolvedPath = path.resolve(configArg);
var extension = getConfigExtension(resolvedPath);
return {
path: resolvedPath,
ext: extension
};
};
var configArgList = Array.isArray(argv.config) ? argv.config : [argv.config];
configFiles = configArgList.map(mapConfigArg);
} else {
for(i = 0; i < defaultConfigFiles.length; i++) {
var webpackConfig = defaultConfigFiles[i].path;
if(fs.existsSync(webpackConfig)) {
configFiles.push({
path: webpackConfig,
ext: defaultConfigFiles[i].ext
});
break;
}
}
}
if(configFiles.length > 0) {
var registerCompiler = function registerCompiler(moduleDescriptor) {
if(moduleDescriptor) {
if(typeof moduleDescriptor === "string") {
require(moduleDescriptor);
} else if(!Array.isArray(moduleDescriptor)) {
moduleDescriptor.register(require(moduleDescriptor.module));
} else {
for(var i = 0; i < moduleDescriptor.length; i++) {
try {
registerCompiler(moduleDescriptor[i]);
break;
} catch(e) {
// do nothing
}
}
}
}
};
var requireConfig = function requireConfig(configPath) {
var options = require(configPath);
options = prepareOptions(options, argv);
return options;
};
configFiles.forEach(function(file) {
registerCompiler(interpret.extensions[file.ext]);
options.push(requireConfig(file.path));
});
configFileLoaded = true;
}
if(!configFileLoaded) {
return processConfiguredOptions({});
} else if(options.length === 1) {
return processConfiguredOptions(options[0]);
} else {
return processConfiguredOptions(options);
}
function processConfiguredOptions(options) {
if(options === null || typeof options !== "object") {
console.error("Config did not export an object or a function returning an object.");
process.exit(-1); // eslint-disable-line
}
// process Promise
if(typeof options.then === "function") {
return options.then(processConfiguredOptions);
}
// process ES6 default
if(typeof options === "object" && typeof options.default === "object") {
return processConfiguredOptions(options.default);
}
// filter multi-config by name
if(Array.isArray(options) && argv["config-name"]) {
var namedOptions = options.filter(function(opt) {
return opt.name === argv["config-name"];
});
if(namedOptions.length === 0) {
console.error("Configuration with name '" + argv["config-name"] + "' was not found.");
process.exit(-1); // eslint-disable-line
} else if(namedOptions.length === 1) {
return processConfiguredOptions(namedOptions[0]);
}
options = namedOptions;
}
if(Array.isArray(options)) {
options.forEach(processOptions);
} else {
processOptions(options);
}
if(argv.context) {
options.context = path.resolve(argv.context);
}
if(!options.context) {
options.context = process.cwd();
}
if(argv.watch) {
options.watch = true;
}
if(argv["watch-aggregate-timeout"]) {
options.watchOptions = options.watchOptions || {};
options.watchOptions.aggregateTimeout = +argv["watch-aggregate-timeout"];
}
if(typeof argv["watch-poll"] !== "undefined") {
options.watchOptions = options.watchOptions || {};
if(argv["watch-poll"] === "true" || argv["watch-poll"] === "")
options.watchOptions.poll = true;
else if(!isNaN(argv["watch-poll"]))
options.watchOptions.poll = +argv["watch-poll"];
}
if(argv["watch-stdin"]) {
options.watchOptions = options.watchOptions || {};
options.watchOptions.stdin = true;
options.watch = true;
}
return options;
}
function processOptions(options) {
var noOutputFilenameDefined = !options.output || !options.output.filename;
function ifArg(name, fn, init, finalize) {
if(Array.isArray(argv[name])) {
if(init) {
init();
}
argv[name].forEach(fn);
if(finalize) {
finalize();
}
} else if(typeof argv[name] !== "undefined" && argv[name] !== null) {
if(init) {
init();
}
fn(argv[name], -1);
if(finalize) {
finalize();
}
}
}
function ifArgPair(name, fn, init, finalize) {
ifArg(name, function(content, idx) {
var i = content.indexOf("=");
if(i < 0) {
return fn(null, content, idx);
} else {
return fn(content.substr(0, i), content.substr(i + 1), idx);
}
}, init, finalize);
}
function ifBooleanArg(name, fn) {
ifArg(name, function(bool) {
if(bool) {
fn();
}
});
}
function mapArgToBoolean(name, optionName) {
ifArg(name, function(bool) {
if(bool === true)
options[optionName || name] = true;
else if(bool === false)
options[optionName || name] = false;
});
}
function loadPlugin(name) {
var loadUtils = require("loader-utils");
var args;
try {
var p = name && name.indexOf("?");
if(p > -1) {
args = loadUtils.parseQuery(name.substring(p));
name = name.substring(0, p);
}
} catch(e) {
console.log("Invalid plugin arguments " + name + " (" + e + ").");
process.exit(-1); // eslint-disable-line
}
var path;
try {
var resolve = require("enhanced-resolve");
path = resolve.sync(process.cwd(), name);
} catch(e) {
console.log("Cannot resolve plugin " + name + ".");
process.exit(-1); // eslint-disable-line
}
var Plugin;
try {
Plugin = require(path);
} catch(e) {
console.log("Cannot load plugin " + name + ". (" + path + ")");
throw e;
}
try {
return new Plugin(args);
} catch(e) {
console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
throw e;
}
}
function ensureObject(parent, name) {
if(typeof parent[name] !== "object" || parent[name] === null) {
parent[name] = {};
}
}
function ensureArray(parent, name) {
if(!Array.isArray(parent[name])) {
parent[name] = [];
}
}
ifArgPair("entry", function(name, entry) {
if(typeof options.entry[name] !== "undefined" && options.entry[name] !== null) {
options.entry[name] = [].concat(options.entry[name]).concat(entry);
} else {
options.entry[name] = entry;
}
}, function() {
ensureObject(options, "entry");
});
function bindRules(arg) {
ifArgPair(arg, function(name, binding) {
if(name === null) {
name = binding;
binding += "-loader";
}
var rule = {
test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"), // eslint-disable-line no-useless-escape
loader: binding
};
if(arg === "module-bind-pre") {
rule.enforce = "pre";
} else if(arg === "module-bind-post") {
rule.enforce = "post";
}
options.module.rules.push(rule);
}, function() {
ensureObject(options, "module");
ensureArray(options.module, "rules");
});
}
bindRules("module-bind");
bindRules("module-bind-pre");
bindRules("module-bind-post");
var defineObject;
ifArgPair("define", function(name, value) {
if(name === null) {
name = value;
value = true;
}
defineObject[name] = value;
}, function() {
defineObject = {};
}, function() {
ensureArray(options, "plugins");
var DefinePlugin = require("../lib/DefinePlugin");
options.plugins.push(new DefinePlugin(defineObject));
});
ifArg("output-path", function(value) {
ensureObject(options, "output");
options.output.path = path.resolve(value);
});
ifArg("output-filename", function(value) {
ensureObject(options, "output");
options.output.filename = value;
noOutputFilenameDefined = false;
});
ifArg("output-chunk-filename", function(value) {
ensureObject(options, "output");
options.output.chunkFilename = value;
});
ifArg("output-source-map-filename", function(value) {
ensureObject(options, "output");
options.output.sourceMapFilename = value;
});
ifArg("output-public-path", function(value) {
ensureObject(options, "output");
options.output.publicPath = value;
});
ifArg("output-jsonp-function", function(value) {
ensureObject(options, "output");
options.output.jsonpFunction = value;
});
ifBooleanArg("output-pathinfo", function() {
ensureObject(options, "output");
options.output.pathinfo = true;
});
ifArg("output-library", function(value) {
ensureObject(options, "output");
options.output.library = value;
});
ifArg("output-library-target", function(value) {
ensureObject(options, "output");
options.output.libraryTarget = value;
});
ifArg("records-input-path", function(value) {
options.recordsInputPath = path.resolve(value);
});
ifArg("records-output-path", function(value) {
options.recordsOutputPath = path.resolve(value);
});
ifArg("records-path", function(value) {
options.recordsPath = path.resolve(value);
});
ifArg("target", function(value) {
options.target = value;
});
mapArgToBoolean("cache");
ifBooleanArg("hot", function() {
ensureArray(options, "plugins");
var HotModuleReplacementPlugin = require("../lib/HotModuleReplacementPlugin");
options.plugins.push(new HotModuleReplacementPlugin());
});
ifBooleanArg("debug", function() {
ensureArray(options, "plugins");
var LoaderOptionsPlugin = require("../lib/LoaderOptionsPlugin");
options.plugins.push(new LoaderOptionsPlugin({
debug: true
}));
});
ifArg("devtool", function(value) {
options.devtool = value;
});
function processResolveAlias(arg, key) {
ifArgPair(arg, function(name, value) {
if(!name) {
throw new Error("--" + arg + " <string>=<string>");
}
ensureObject(options, key);
ensureObject(options[key], "alias");
options[key].alias[name] = value;
});
}
processResolveAlias("resolve-alias", "resolve");
processResolveAlias("resolve-loader-alias", "resolveLoader");
ifArg("resolve-extensions", function(value) {
ensureObject(options, "resolve");
if(Array.isArray(value)) {
options.resolve.extensions = value;
} else {
options.resolve.extensions = value.split(/,\s*/);
}
});
ifArg("optimize-max-chunks", function(value) {
ensureArray(options, "plugins");
var LimitChunkCountPlugin = require("../lib/optimize/LimitChunkCountPlugin");
options.plugins.push(new LimitChunkCountPlugin({
maxChunks: parseInt(value, 10)
}));
});
ifArg("optimize-min-chunk-size", function(value) {
ensureArray(options, "plugins");
var MinChunkSizePlugin = require("../lib/optimize/MinChunkSizePlugin");
options.plugins.push(new MinChunkSizePlugin({
minChunkSize: parseInt(value, 10)
}));
});
ifBooleanArg("optimize-minimize", function() {
ensureArray(options, "plugins");
var UglifyJsPlugin = require("../lib/optimize/UglifyJsPlugin");
var LoaderOptionsPlugin = require("../lib/LoaderOptionsPlugin");
options.plugins.push(new UglifyJsPlugin({
sourceMap: options.devtool && (options.devtool.indexOf("sourcemap") >= 0 || options.devtool.indexOf("source-map") >= 0)
}));
options.plugins.push(new LoaderOptionsPlugin({
minimize: true
}));
});
ifArg("prefetch", function(request) {
ensureArray(options, "plugins");
var PrefetchPlugin = require("../lib/PrefetchPlugin");
options.plugins.push(new PrefetchPlugin(request));
});
ifArg("provide", function(value) {
ensureArray(options, "plugins");
var idx = value.indexOf("=");
var name;
if(idx >= 0) {
name = value.substr(0, idx);
value = value.substr(idx + 1);
} else {
name = value;
}
var ProvidePlugin = require("../lib/ProvidePlugin");
options.plugins.push(new ProvidePlugin(name, value));
});
ifArg("plugin", function(value) {
ensureArray(options, "plugins");
options.plugins.push(loadPlugin(value));
});
mapArgToBoolean("bail");
mapArgToBoolean("profile");
if(noOutputFilenameDefined) {
ensureObject(options, "output");
if(convertOptions && convertOptions.outputFilename) {
options.output.path = path.resolve(path.dirname(convertOptions.outputFilename));
options.output.filename = path.basename(convertOptions.outputFilename);
} else if(argv._.length > 0) {
options.output.filename = argv._.pop();
options.output.path = path.resolve(path.dirname(options.output.filename));
options.output.filename = path.basename(options.output.filename);
} else if(configFileLoaded) {
throw new Error("'output.filename' is required, either in config file or as --output-filename");
} else {
console.error("No configuration file found and no output filename configured via CLI option.");
console.error("A configuration file could be named 'webpack.config.js' in the current directory.");
console.error("Use --help to display the CLI options.");
process.exit(-1); // eslint-disable-line
}
}
if(argv._.length > 0) {
if(Array.isArray(options.entry) || typeof options.entry === "string") {
options.entry = {
main: options.entry
};
}
ensureObject(options, "entry");
var addTo = function addTo(name, entry) {
if(options.entry[name]) {
if(!Array.isArray(options.entry[name])) {
options.entry[name] = [options.entry[name]];
}
options.entry[name].push(entry);
} else {
options.entry[name] = entry;
}
};
argv._.forEach(function(content) {
var i = content.indexOf("=");
var j = content.indexOf("?");
if(i < 0 || (j >= 0 && j < i)) {
var resolved = path.resolve(content);
if(fs.existsSync(resolved)) {
addTo("main", `${resolved}${fs.statSync(resolved).isDirectory() ? path.sep : ""}`);
} else {
addTo("main", content);
}
} else {
addTo(content.substr(0, i), content.substr(i + 1));
}
});
}
if(!options.entry) {
if(configFileLoaded) {
console.error("Configuration file found but no entry configured.");
} else {
console.error("No configuration file found and no entry configured via CLI option.");
console.error("When using the CLI you need to provide at least two arguments: entry and output.");
console.error("A configuration file could be named 'webpack.config.js' in the current directory.");
}
console.error("Use --help to display the CLI options.");
process.exit(-1); // eslint-disable-line
}
}
};

395
torrent-project/node_modules/webpack/bin/webpack.js generated vendored Normal file
View File

@@ -0,0 +1,395 @@
#!/usr/bin/env node
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var path = require("path");
// Local version replace global one
try {
var localWebpack = require.resolve(path.join(process.cwd(), "node_modules", "webpack", "bin", "webpack.js"));
if(__filename !== localWebpack) {
return require(localWebpack);
}
} catch(e) {}
var yargs = require("yargs")
.usage("webpack " + require("../package.json").version + "\n" +
"Usage: https://webpack.js.org/api/cli/\n" +
"Usage without config file: webpack <entry> [<entry>] <output>\n" +
"Usage with config file: webpack");
require("./config-yargs")(yargs);
var DISPLAY_GROUP = "Stats options:";
var BASIC_GROUP = "Basic options:";
yargs.options({
"json": {
type: "boolean",
alias: "j",
describe: "Prints the result as JSON."
},
"progress": {
type: "boolean",
describe: "Print compilation progress in percentage",
group: BASIC_GROUP
},
"color": {
type: "boolean",
alias: "colors",
default: function supportsColor() {
return require("supports-color");
},
group: DISPLAY_GROUP,
describe: "Enables/Disables colors on the console"
},
"sort-modules-by": {
type: "string",
group: DISPLAY_GROUP,
describe: "Sorts the modules list by property in module"
},
"sort-chunks-by": {
type: "string",
group: DISPLAY_GROUP,
describe: "Sorts the chunks list by property in chunk"
},
"sort-assets-by": {
type: "string",
group: DISPLAY_GROUP,
describe: "Sorts the assets list by property in asset"
},
"hide-modules": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Hides info about modules"
},
"display-exclude": {
type: "string",
group: DISPLAY_GROUP,
describe: "Exclude modules in the output"
},
"display-modules": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display even excluded modules in the output"
},
"display-max-modules": {
type: "number",
group: DISPLAY_GROUP,
describe: "Sets the maximum number of visible modules in output"
},
"display-chunks": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display chunks in the output"
},
"display-entrypoints": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display entry points in the output"
},
"display-origins": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display origins of chunks in the output"
},
"display-cached": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display also cached modules in the output"
},
"display-cached-assets": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display also cached assets in the output"
},
"display-reasons": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display reasons about module inclusion in the output"
},
"display-depth": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display distance from entry point for each module"
},
"display-used-exports": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display information about used exports in modules (Tree Shaking)"
},
"display-provided-exports": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display information about exports provided from modules"
},
"display-optimization-bailout": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display information about why optimization bailed out for modules"
},
"display-error-details": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Display details about errors"
},
"display": {
type: "string",
group: DISPLAY_GROUP,
describe: "Select display preset (verbose, detailed, normal, minimal, errors-only, none)"
},
"verbose": {
type: "boolean",
group: DISPLAY_GROUP,
describe: "Show more details"
}
});
// yargs will terminate the process early when the user uses help or version.
// This causes large help outputs to be cut short (https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process).
// To prevent this we use the yargs.parse API and exit the process normally
yargs.parse(process.argv.slice(2), (err, argv, output) => {
// arguments validation failed
if(err && output) {
console.error(output);
process.exitCode = 1;
return;
}
// help or version info
if(output) {
console.log(output);
return;
}
if(argv.verbose) {
argv["display"] = "verbose";
}
var options = require("./convert-argv")(yargs, argv);
function ifArg(name, fn, init) {
if(Array.isArray(argv[name])) {
if(init) init();
argv[name].forEach(fn);
} else if(typeof argv[name] !== "undefined") {
if(init) init();
fn(argv[name], -1);
}
}
function processOptions(options) {
// process Promise
if(typeof options.then === "function") {
options.then(processOptions).catch(function(err) {
console.error(err.stack || err);
process.exit(1); // eslint-disable-line
});
return;
}
var firstOptions = [].concat(options)[0];
var statsPresetToOptions = require("../lib/Stats.js").presetToOptions;
var outputOptions = options.stats;
if(typeof outputOptions === "boolean" || typeof outputOptions === "string") {
outputOptions = statsPresetToOptions(outputOptions);
} else if(!outputOptions) {
outputOptions = {};
}
ifArg("display", function(preset) {
outputOptions = statsPresetToOptions(preset);
});
outputOptions = Object.create(outputOptions);
if(Array.isArray(options) && !outputOptions.children) {
outputOptions.children = options.map(o => o.stats);
}
if(typeof outputOptions.context === "undefined")
outputOptions.context = firstOptions.context;
ifArg("env", function(value) {
if(outputOptions.env) {
outputOptions._env = value;
}
});
ifArg("json", function(bool) {
if(bool)
outputOptions.json = bool;
});
if(typeof outputOptions.colors === "undefined")
outputOptions.colors = require("supports-color");
ifArg("sort-modules-by", function(value) {
outputOptions.modulesSort = value;
});
ifArg("sort-chunks-by", function(value) {
outputOptions.chunksSort = value;
});
ifArg("sort-assets-by", function(value) {
outputOptions.assetsSort = value;
});
ifArg("display-exclude", function(value) {
outputOptions.exclude = value;
});
if(!outputOptions.json) {
if(typeof outputOptions.cached === "undefined")
outputOptions.cached = false;
if(typeof outputOptions.cachedAssets === "undefined")
outputOptions.cachedAssets = false;
ifArg("display-chunks", function(bool) {
if(bool) {
outputOptions.modules = false;
outputOptions.chunks = true;
outputOptions.chunkModules = true;
}
});
ifArg("display-entrypoints", function(bool) {
if(bool)
outputOptions.entrypoints = true;
});
ifArg("display-reasons", function(bool) {
if(bool)
outputOptions.reasons = true;
});
ifArg("display-depth", function(bool) {
if(bool)
outputOptions.depth = true;
});
ifArg("display-used-exports", function(bool) {
if(bool)
outputOptions.usedExports = true;
});
ifArg("display-provided-exports", function(bool) {
if(bool)
outputOptions.providedExports = true;
});
ifArg("display-optimization-bailout", function(bool) {
if(bool)
outputOptions.optimizationBailout = bool;
});
ifArg("display-error-details", function(bool) {
if(bool)
outputOptions.errorDetails = true;
});
ifArg("display-origins", function(bool) {
if(bool)
outputOptions.chunkOrigins = true;
});
ifArg("display-max-modules", function(value) {
outputOptions.maxModules = +value;
});
ifArg("display-cached", function(bool) {
if(bool)
outputOptions.cached = true;
});
ifArg("display-cached-assets", function(bool) {
if(bool)
outputOptions.cachedAssets = true;
});
if(!outputOptions.exclude)
outputOptions.exclude = ["node_modules", "bower_components", "components"];
if(argv["display-modules"]) {
outputOptions.maxModules = Infinity;
outputOptions.exclude = undefined;
outputOptions.modules = true;
}
}
ifArg("hide-modules", function(bool) {
if(bool) {
outputOptions.modules = false;
outputOptions.chunkModules = false;
}
});
var webpack = require("../lib/webpack.js");
Error.stackTraceLimit = 30;
var lastHash = null;
var compiler;
try {
compiler = webpack(options);
} catch(e) {
var WebpackOptionsValidationError = require("../lib/WebpackOptionsValidationError");
if(e instanceof WebpackOptionsValidationError) {
if(argv.color)
console.error("\u001b[1m\u001b[31m" + e.message + "\u001b[39m\u001b[22m");
else
console.error(e.message);
process.exit(1); // eslint-disable-line no-process-exit
}
throw e;
}
if(argv.progress) {
var ProgressPlugin = require("../lib/ProgressPlugin");
compiler.apply(new ProgressPlugin({
profile: argv.profile
}));
}
function compilerCallback(err, stats) {
if(!options.watch || err) {
// Do not keep cache anymore
compiler.purgeInputFileSystem();
}
if(err) {
lastHash = null;
console.error(err.stack || err);
if(err.details) console.error(err.details);
process.exit(1); // eslint-disable-line
}
if(outputOptions.json) {
process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
} else if(stats.hash !== lastHash) {
lastHash = stats.hash;
var statsString = stats.toString(outputOptions);
if(statsString)
process.stdout.write(statsString + "\n");
}
if(!options.watch && stats.hasErrors()) {
process.exitCode = 2;
}
}
if(firstOptions.watch || options.watch) {
var watchOptions = firstOptions.watchOptions || firstOptions.watch || options.watch || {};
if(watchOptions.stdin) {
process.stdin.on("end", function() {
process.exit(); // eslint-disable-line
});
process.stdin.resume();
}
compiler.watch(watchOptions, compilerCallback);
console.log("\nWebpack is watching the files…\n");
} else
compiler.run(compilerCallback);
}
processOptions(options);
});