Template Upload

This commit is contained in:
SOUTHERNCO\x2mjbyrn
2017-05-17 13:45:25 -04:00
parent 415b9c25f3
commit 7efe7605b8
11476 changed files with 2170865 additions and 34 deletions

59
node_modules/browser-sync/lib/cli/cli-info.js generated vendored Normal file
View File

@ -0,0 +1,59 @@
"use strict";
var config = require("../config");
var logger = require("../logger").logger;
var fs = require("fs");
var _ = require("../../lodash.custom");
var path = require("path");
var info = {
/**
* Version info
* @param {Object} pjson
* @returns {String}
*/
getVersion: function (pjson) {
console.log(pjson.version);
return pjson.version;
},
/**
* Retrieve the config file
* @returns {*}
* @private
* @param filePath
*/
getConfigFile: function (filePath) {
return require(path.resolve(filePath));
},
/**
* Generate an example Config file.
*/
makeConfig: function (cwd, cb) {
var opts = require(path.join(__dirname, "..", config.configFile));
var userOpts = {};
var ignore = ["excludedFileTypes", "injectFileTypes", "snippetOptions"];
Object.keys(opts).forEach(function (key) {
if (!_.includes(ignore, key)) {
userOpts[key] = opts[key];
}
});
var file = fs.readFileSync(path.join(__dirname, config.template), "utf8");
file = file.replace("//OPTS", JSON.stringify(userOpts, null, 4));
fs.writeFile(path.resolve(cwd, config.userFile), file, function () {
logger.info("Config file created {magenta:%s}", config.userFile);
logger.info(
"To use it, in the same directory run: " +
"{cyan:browser-sync start --config bs-config.js}"
);
cb();
});
}
};
module.exports = info;

317
node_modules/browser-sync/lib/cli/cli-options.js generated vendored Normal file
View File

@ -0,0 +1,317 @@
"use strict";
var path = require("path");
var url = require("url");
var _ = require("../../lodash.custom");
var Immutable = require("immutable");
var isList = Immutable.List.isList;
var isMap = Immutable.Map.isMap;
var defaultConfig = require("../default-config");
var immDefs = Immutable.fromJS(defaultConfig);
var opts = exports;
/**
* @type {{wrapPattern: Function}}
*/
opts.utils = {
/**
* Transform a string arg such as "*.html, css/*.css" into array
* @param string
* @returns {Array}
*/
explodeFilesArg: function (string) {
return string.split(",").map(function (item) {
return item.trim();
});
},
/**
* @param pattern
* @returns {*|string}
* @private
*/
wrapPattern: function (pattern) {
var prefix = "!";
var suffix = "/**";
var lastChar = pattern.charAt(pattern.length - 1);
var extName = path.extname(pattern);
// If there's a file ext, don't append any suffix
if (extName.length) {
suffix = "";
} else {
if (lastChar === "/") {
suffix = "**";
}
if (lastChar === "*") {
suffix = "";
}
}
return [prefix, pattern, suffix].join("");
}
};
opts.callbacks = {
/**
* Merge server options
* @param {String|Boolean|Object} value
* @param [argv]
* @returns {*}
*/
server: function (value, argv) {
if (value === false) {
if (!argv || !argv.server) {
return false;
}
}
var obj = {
baseDir: "./"
};
if (_.isString(value) || isList(value)) {
obj.baseDir = value;
} else {
if (value && value !== true) {
if (value.get("baseDir")) {
return value;
}
}
}
if (argv) {
if (argv.index) {
obj.index = argv.index;
}
if (argv.directory) {
obj.directory = true;
}
}
return Immutable.fromJS(obj);
},
/**
* @param value
* @param argv
* @returns {*}
*/
proxy: function (value) {
var mw;
var target;
if (!value || value === true) {
return false;
}
if (typeof value !== "string") {
target = value.get("target");
mw = value.get("middleware");
} else {
target = value;
value = Immutable.Map({});
}
if (!target.match(/^(https?):\/\//)) {
target = "http://" + target;
}
var parsedUrl = url.parse(target);
if (!parsedUrl.port) {
parsedUrl.port = 80;
}
var out = {
target: parsedUrl.protocol + "//" + parsedUrl.host,
url: Immutable.Map(parsedUrl)
};
if (mw) {
out.middleware = mw;
}
return value.mergeDeep(out);
},
/**
* @param value
* @private
*/
ports: function (value) {
var segs;
var obj = {};
if (typeof value === "string") {
if (~value.indexOf(",")) {
segs = value.split(",");
obj.min = parseInt(segs[0], 10);
obj.max = parseInt(segs[1], 10);
} else {
obj.min = parseInt(value, 10);
obj.max = null;
}
} else {
obj.min = value.get("min");
obj.max = value.get("max") || null;
}
return Immutable.Map(obj);
},
/**
* @param value
* @param argv
* @returns {*}
*/
ghostMode: function (value, argv) {
var trueAll = {
clicks: true,
scroll: true,
forms: {
submit: true,
inputs: true,
toggles: true
}
};
var falseAll = {
clicks: false,
scroll: false,
forms: {
submit: false,
inputs: false,
toggles: false
}
};
if (value === false || value === "false" || argv && argv.ghost === false) {
return Immutable.fromJS(falseAll);
}
if (value === true || value === "true" || argv && argv.ghost === true) {
return Immutable.fromJS(trueAll);
}
if (value.get("forms") === false) {
return value.withMutations(function (map) {
map.set("forms", Immutable.fromJS({
submit: false,
inputs: false,
toggles: false
}));
});
}
if (value.get("forms") === true) {
return value.withMutations(function (map) {
map.set("forms", Immutable.fromJS({
submit: true,
inputs: true,
toggles: true
}));
});
}
return value;
},
/**
* @param value
* @returns {*}
*/
files: function (value) {
var namespaces = {core: {}};
namespaces.core.globs = [];
namespaces.core.objs = [];
var processed = opts.makeFilesArg(value);
if (processed.globs.length) {
namespaces.core.globs = processed.globs;
}
if (processed.objs.length) {
namespaces.core.objs = processed.objs;
}
return Immutable.fromJS(namespaces);
},
/**
* @param value
*/
extensions: function (value) {
if (_.isString(value)) {
var split = opts.utils.explodeFilesArg(value);
if (split.length) {
return Immutable.List(split);
}
}
if (Immutable.List.isList(value)) {
return value;
}
return value;
}
};
/**
* @param {Object} values
* @param {Object} [argv]
* @returns {Map}
*/
opts.merge = function (values, argv) {
return immDefs
.mergeDeep(values)
.withMutations(function (item) {
item.map(function (value, key) {
if (opts.callbacks[key]) {
item.set(key, opts.callbacks[key](value, argv));
}
});
});
};
/**
* @param value
* @returns {{globs: Array, objs: Array}}
*/
opts.makeFilesArg = function (value) {
var globs = [];
var objs = [];
if (_.isString(value)) {
globs = globs.concat(
opts.utils.explodeFilesArg(value)
);
}
if (isList(value) && value.size) {
value.forEach(function (value) {
if (_.isString(value)) {
globs.push(value);
} else {
if (isMap(value)) {
objs.push(value);
}
}
});
}
return {
globs: globs,
objs: objs
};
};

15
node_modules/browser-sync/lib/cli/cli-template.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
/*
|--------------------------------------------------------------------------
| Browser-sync config file
|--------------------------------------------------------------------------
|
| For up-to-date information about the options:
| http://www.browsersync.io/docs/options/
|
| There are more options than you see here, these are just the ones that are
| set internally. See the website for more info.
|
|
*/
module.exports = //OPTS;

15
node_modules/browser-sync/lib/cli/command.init.js generated vendored Normal file
View File

@ -0,0 +1,15 @@
"use strict";
var info = require("./cli-info");
/**
* $ browser-sync init
*
* This command will generate a configuration
* file in the current directory
*
* @param opts
*/
module.exports = function (opts) {
info.makeConfig(process.cwd(), opts.cb);
};

64
node_modules/browser-sync/lib/cli/command.recipe.js generated vendored Normal file
View File

@ -0,0 +1,64 @@
"use strict";
var logger = require("../logger").logger;
/**
* $ browser-sync recipe <name> <options>
*
* This command will copy a recipe into either the current directory
* or one given with the --output flag
*
* @param opts
* @returns {Function}
*/
module.exports = function (opts) {
var path = require("path");
var fs = require("fs-extra");
var input = opts.cli.input.slice(1);
var resolved = require.resolve("bs-recipes");
var dir = path.dirname(resolved);
var logRecipes = function () {
var dirs = fs.readdirSync(path.join(dir, "recipes"));
logger.info("Install one of the following with {cyan:browser-sync recipe <name>\n");
dirs.forEach(function (name) {
console.log(" " + name);
});
};
if (!input.length) {
logger.info("No recipe name provided!");
logRecipes();
return opts.cb();
}
if (opts.cli.input[1] === "ls") {
logRecipes();
return opts.cb();
}
input = input[0];
var flags = opts.cli.flags;
var output = flags.output ? path.resolve(flags.output) : path.join(process.cwd(), input);
var targetDir = path.join(dir, "recipes", input);
if (fs.existsSync(output)) {
return opts.cb(new Error("Target folder exists remove it first and then try again"));
}
if (fs.existsSync(targetDir)) {
fs.copy(targetDir, output, function (err) {
if (err) {
opts.cb(err);
} else {
logger.info("Recipe copied into {cyan:%s}", output);
logger.info("Next, inside that folder, run {cyan:npm i && npm start}");
opts.cb(null);
}
});
} else {
logger.info("Recipe {cyan:%s} not found. The following are available though", input);
logRecipes();
opts.cb();
}
};

44
node_modules/browser-sync/lib/cli/command.reload.js generated vendored Normal file
View File

@ -0,0 +1,44 @@
"use strict";
/**
* $ browser-sync reload <options>
*
* This commands starts the Browsersync servers
* & Optionally UI.
*
* @param opts
* @returns {Function}
*/
module.exports = function (opts) {
var flags = opts.cli.flags;
if (!flags.url) {
flags.url = "http://localhost:" + (flags.port || 3000);
}
var proto = require("../http-protocol");
var scheme = flags.url.match(/^https/) ? "https" : "http";
var args = {method: "reload"};
if (flags.files) {
args.args = flags.files;
}
var url = proto.getUrl(args, flags.url);
if (scheme === "https") {
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
}
require(scheme).get(url, function (res) {
res.on("data", function () {
if (res.statusCode === 200) {
opts.cb(null, res);
}
});
}).on("error", function (err) {
if (err.code === "ECONNREFUSED") {
err.message = "Browsersync not running at " + flags.url;
}
return opts.cb(err);
});
};

88
node_modules/browser-sync/lib/cli/command.start.js generated vendored Normal file
View File

@ -0,0 +1,88 @@
"use strict";
var path = require("path");
var fs = require("fs");
var _ = require("../../lodash.custom");
var utils = require("../utils");
var opts = require("./cli-options").utils;
/**
* $ browser-sync start <options>
*
* This commands starts the Browsersync servers
* & Optionally UI.
*
* @param opts
* @returns {Function}
*/
module.exports = function (opts) {
var flags = preprocessFlags(opts.cli.flags);
var maybepkg = path.resolve(process.cwd(), "package.json");
var input = flags;
if (flags.config) {
var maybeconf = path.resolve(process.cwd(), flags.config);
if (fs.existsSync(maybeconf)) {
var conf = require(maybeconf);
input = _.merge({}, conf, flags);
} else {
utils.fail(true, new Error("Configuration file '" + flags.config + "' not found"), opts.cb);
}
} else {
if (fs.existsSync(maybepkg)) {
var pkg = require(maybepkg);
if (pkg["browser-sync"]) {
console.log("> Configuration obtained from package.json");
input = _.merge({}, pkg["browser-sync"], flags);
}
}
}
return require("../../")
.create("cli")
.init(input, opts.cb);
};
/**
* @param flags
* @returns {*}
*/
function preprocessFlags (flags) {
return [
stripUndefined,
legacyFilesArgs
].reduce(function (flags, fn) {
return fn.call(null, flags);
}, flags);
}
/**
* Incoming undefined values are problematic as
* they interfere with Immutable.Map.mergeDeep
* @param subject
* @returns {*}
*/
function stripUndefined (subject) {
return Object.keys(subject).reduce(function (acc, key) {
var value = subject[key];
if (typeof value === "undefined") {
return acc;
}
acc[key] = value;
return acc;
}, {});
}
/**
* @param flags
* @returns {*}
*/
function legacyFilesArgs(flags) {
if (flags.files && flags.files.length) {
flags.files = flags.files.reduce(function (acc, item) {
return acc.concat(opts.explodeFilesArg(item));
}, []);
}
return flags;
}

11
node_modules/browser-sync/lib/cli/help.txt generated vendored Normal file
View File

@ -0,0 +1,11 @@
{cyan:Server Example:}
{gray:---------------}
Use current directory as root & watch CSS files
{gray:$} browser-sync start --server --files="css/*.css"
{cyan:Proxy Example:}
{gray:---------------}
Proxy `localhost:8080` & watch CSS/HTML files
{gray:$} browser-sync start --proxy="localhost:8080" --files="*.html, css/*.css"

1
node_modules/browser-sync/lib/cli/opts.init.json generated vendored Normal file
View File

@ -0,0 +1 @@
{}

6
node_modules/browser-sync/lib/cli/opts.recipe.json generated vendored Normal file
View File

@ -0,0 +1,6 @@
{
"output": {
"alias": "o",
"desc": "Specify an output directory"
}
}

16
node_modules/browser-sync/lib/cli/opts.reload.json generated vendored Normal file
View File

@ -0,0 +1,16 @@
{
"files": {
"desc": "File paths to reload",
"type": "array",
"alias": "f"
},
"port": {
"alias": "p",
"type": "number",
"desc": "Target a running instance by port number"
},
"url": {
"alias": "u",
"desc": "Provide the full the url to the running Browsersync instance"
}
}

120
node_modules/browser-sync/lib/cli/opts.start.json generated vendored Normal file
View File

@ -0,0 +1,120 @@
{
"server": {
"alias": "s",
"desc": "Run a Local server (uses your cwd as the web root)"
},
"serveStatic": {
"type": "array",
"alias": "ss",
"desc": "Directories to serve static files from"
},
"port": {
"type": "number",
"desc": "Specify a port to use"
},
"proxy": {
"alias": "p",
"desc": "Proxy an existing server",
"example": "$0 shane is cool"
},
"ws": {
"type": "boolean",
"desc": "Proxy mode only - enable websocket proxying"
},
"browser": {
"type": "array",
"alias": "b",
"desc": "Choose which browser should be auto-opened"
},
"files": {
"type": "array",
"alias": "f",
"desc": "File paths to watch"
},
"index": {
"type": "string",
"desc": "Specify which file should be used as the index page"
},
"plugins": {
"type": "array",
"desc": "Load Browsersync plugins"
},
"extensions": {
"type": "array",
"desc": "Specify file extension fallbacks"
},
"startPath": {
"type": "string",
"desc": "Specify the start path for the opened browser"
},
"https": {
"desc": "Enable SSL for local development"
},
"directory": {
"type": "boolean",
"desc": "Show a directory listing for the server"
},
"xip": {
"type": "boolean",
"desc": "Use xip.io domain routing"
},
"tunnel": {
"desc": "Use a public URL"
},
"open": {
"type": "string",
"desc": "Choose which URL is auto-opened (local, external or tunnel), or provide a url"
},
"cors": {
"type": "boolean",
"desc": "Add Access Control headers to every request"
},
"config": {
"type": "string",
"alias": "c",
"desc": "Specify a path to a configuration file"
},
"host": {
"desc": "Specify a hostname to use"
},
"logLevel": {
"desc": "Set the logger output level (silent, info or debug)"
},
"reload-delay": {
"type": "number",
"desc": "Time in milliseconds to delay the reload event following file changes"
},
"reload-debounce": {
"type": "number",
"desc": "Restrict the frequency in which browser:reload events can be emitted to connected clients"
},
"ui-port": {
"type": "number",
"desc": "Specify a port for the UI to use"
},
"watchEvents": {
"type": "array",
"desc": "Specify which file events to respond to"
},
"no-notify": {
"desc": "Disable the notify element in browsers"
},
"no-open": {
"desc": "Don't open a new browser window"
},
"no-online": {
"desc": "Force offline usage"
},
"no-ui": {
"desc": "Don't start the user interface"
},
"no-ghost-mode": {
"desc": "Disable Ghost Mode"
},
"no-inject-changes": {
"desc": "Reload on every file change"
},
"no-reload-on-restart": {
"desc": "Don't auto-reload all browsers following a restart"
}
}