This commit is contained in:
2019-02-17 18:07:28 +01:00
parent c69ffb9752
commit 95cff6f702
2301 changed files with 307810 additions and 5 deletions

54
Client/node_modules/vinyl-fs/lib/dest/index.js generated vendored Executable file
View File

@@ -0,0 +1,54 @@
'use strict';
var through2 = require('through2');
var sourcemaps = require('gulp-sourcemaps');
var duplexify = require('duplexify');
var sink = require('../sink');
var prepareWrite = require('../prepareWrite');
var writeContents = require('./writeContents');
function dest(outFolder, opt) {
if (!opt) {
opt = {};
}
function saveFile(file, enc, cb) {
prepareWrite(outFolder, file, opt, function(err, writePath) {
if (err) {
return cb(err);
}
writeContents(writePath, file, cb);
});
}
var saveStream = through2.obj(opt, saveFile);
if (!opt.sourcemaps) {
// Sink the save stream to start flowing
// Do this on nextTick, it will flow at slowest speed of piped streams
process.nextTick(sink(saveStream));
return saveStream;
}
var sourcemapOpt = opt.sourcemaps;
if (typeof sourcemapOpt === 'boolean') {
sourcemapOpt = {};
}
if (typeof sourcemapOpt === 'string') {
sourcemapOpt = {
path: sourcemapOpt,
};
}
var mapStream = sourcemaps.write(sourcemapOpt.path, sourcemapOpt);
var outputStream = duplexify.obj(mapStream, saveStream);
mapStream.pipe(saveStream);
// Sink the output stream to start flowing
// Do this on nextTick, it will flow at slowest speed of piped streams
process.nextTick(sink(outputStream));
return outputStream;
}
module.exports = dest;

59
Client/node_modules/vinyl-fs/lib/dest/writeContents/index.js generated vendored Executable file
View File

@@ -0,0 +1,59 @@
'use strict';
var writeDir = require('./writeDir');
var writeStream = require('./writeStream');
var writeBuffer = require('./writeBuffer');
var writeSymbolicLink = require('./writeSymbolicLink');
function writeContents(writePath, file, callback) {
// If directory then mkdirp it
if (file.isDirectory()) {
return writeDir(writePath, file, written);
}
// Stream it to disk yo
if (file.isStream()) {
return writeStream(writePath, file, written);
}
// Write it as a symlink
if (file.symlink) {
return writeSymbolicLink(writePath, file, written);
}
// Write it like normal
if (file.isBuffer()) {
return writeBuffer(writePath, file, written);
}
// If no contents then do nothing
if (file.isNull()) {
return written();
}
// This is invoked by the various writeXxx modules when they've finished
// writing the contents.
function written(err) {
if (isErrorFatal(err)) {
return callback(err);
}
callback(null, file);
}
function isErrorFatal(err) {
if (!err) {
return false;
}
if (err.code === 'EEXIST' && file.flag === 'wx') {
// Handle scenario for file overwrite failures.
return false; // "These aren't the droids you're looking for"
}
// Otherwise, this is a fatal error
return true;
}
}
module.exports = writeContents;

View File

@@ -0,0 +1,26 @@
'use strict';
var fo = require('../../fileOperations');
function writeBuffer(writePath, file, written) {
var opt = {
mode: file.stat.mode,
flag: file.flag,
};
fo.writeFile(writePath, file.contents, opt, onWriteFile);
function onWriteFile(writeErr, fd) {
if (writeErr) {
return fo.closeFd(writeErr, fd, written);
}
fo.updateMetadata(fd, file, onUpdate);
}
function onUpdate(statErr, fd) {
fo.closeFd(statErr, fd, written);
}
}
module.exports = writeBuffer;

View File

@@ -0,0 +1,53 @@
'use strict';
var fs = require('graceful-fs');
var mkdirp = require('mkdirp');
var fo = require('../../fileOperations');
function writeDir(writePath, file, written) {
var mkdirpOpts = {
mode: file.stat.mode,
fs: fs,
};
mkdirp(writePath, mkdirpOpts, onMkdirp);
function onMkdirp(mkdirpErr) {
if (mkdirpErr) {
return written(mkdirpErr);
}
fs.open(writePath, 'r', onOpen);
}
function onOpen(openErr, fd) {
// If we don't have access, just move along
if (isInaccessible(openErr)) {
return fo.closeFd(null, fd, written);
}
if (openErr) {
return fo.closeFd(openErr, fd, written);
}
fo.updateMetadata(fd, file, onUpdate);
}
function onUpdate(statErr, fd) {
fo.closeFd(statErr, fd, written);
}
}
function isInaccessible(err) {
if (!err) {
return false;
}
if (err.code === 'EACCES') {
return true;
}
return false;
}
module.exports = writeDir;

View File

@@ -0,0 +1,57 @@
'use strict';
var fs = require('graceful-fs');
var fo = require('../../fileOperations');
var streamFile = require('../../src/getContents/streamFile');
function writeStream(writePath, file, written) {
var opt = {
mode: file.stat.mode,
flag: file.flag,
};
var outStream = fs.createWriteStream(writePath, opt);
file.contents.once('error', complete);
file.contents.once('end', readStreamEnd);
outStream.once('error', complete);
outStream.once('finish', complete);
// Streams are piped with end disabled, this prevents the
// WriteStream from closing the file descriptor after all
// data is written.
file.contents.pipe(outStream, { end: false });
function readStreamEnd() {
streamFile(file, complete);
}
function end(propagatedErr) {
outStream.end(onEnd);
function onEnd(endErr) {
written(propagatedErr || endErr);
}
}
// Cleanup
function complete(streamErr) {
file.contents.removeListener('error', complete);
file.contents.removeListener('end', readStreamEnd);
outStream.removeListener('error', complete);
outStream.removeListener('finish', complete);
if (streamErr) {
return end(streamErr);
}
if (typeof outStream.fd !== 'number') {
return end();
}
fo.updateMetadata(outStream.fd, file, end);
}
}
module.exports = writeStream;

View File

@@ -0,0 +1,20 @@
'use strict';
var fs = require('graceful-fs');
function writeSymbolicLink(writePath, file, written) {
// TODO handle symlinks properly
fs.symlink(file.symlink, writePath, function(err) {
if (isFatalError(err)) {
return written(err);
}
written();
});
}
function isFatalError(err) {
return (err && err.code !== 'EEXIST');
}
module.exports = writeSymbolicLink;

206
Client/node_modules/vinyl-fs/lib/fileOperations.js generated vendored Executable file
View File

@@ -0,0 +1,206 @@
'use strict';
var fs = require('graceful-fs');
var assign = require('object-assign');
var isEqual = require('lodash.isequal');
var isValidDate = require('vali-date');
// TODO shared module
// TODO include sticky/setuid/setgid, i.e. 7777?
var MASK_MODE = parseInt('0777', 8);
var DEFAULT_FILE_MODE = parseInt('0666', 8);
var APPEND_MODE_REGEXP = /a/;
function closeFd(propagatedErr, fd, callback) {
if (typeof fd !== 'number') {
return callback(propagatedErr);
}
fs.close(fd, onClosed);
function onClosed(closeErr) {
if (propagatedErr || closeErr) {
return callback(propagatedErr || closeErr);
}
callback();
}
}
function getModeDiff(fsMode, vinylMode) {
var modeDiff = 0;
if (typeof vinylMode === 'number') {
modeDiff = (vinylMode ^ fsMode) & MASK_MODE;
}
return modeDiff;
}
function getTimesDiff(fsStat, vinylStat) {
if (!isValidDate(vinylStat.mtime)) {
return;
}
if (isEqual(vinylStat.mtime, fsStat.mtime) &&
isEqual(vinylStat.atime, fsStat.atime)) {
return;
}
var atime;
if (isValidDate(vinylStat.atime)) {
atime = vinylStat.atime;
} else {
atime = fsStat.atime;
}
if (!isValidDate(atime)) {
atime = undefined;
}
var timesDiff = {
mtime: vinylStat.mtime,
atime: atime,
};
return timesDiff;
}
function isOwner(fsStat) {
var hasGetuid = (typeof process.getuid === 'function');
var hasGeteuid = (typeof process.geteuid === 'function');
// If we don't have either, assume we don't have permissions.
// This should only happen on Windows.
// Windows basically noops fchmod and errors on futimes called on directories.
if (!hasGeteuid && !hasGetuid) {
return false;
}
var uid;
if (hasGeteuid) {
uid = process.geteuid();
} else {
uid = process.getuid();
}
if (fsStat.uid !== uid && uid !== 0) {
return false;
}
return true;
}
function updateMetadata(fd, file, callback) {
fs.fstat(fd, onStat);
function onStat(err, stat) {
if (err) {
return callback(err, fd);
}
// Check if mode needs to be updated
var modeDiff = getModeDiff(stat.mode, file.stat.mode);
// Check if atime/mtime need to be updated
var timesDiff = getTimesDiff(stat, file.stat);
// Set file.stat to the reflect current state on disk
assign(file.stat, stat);
// Nothing to do
if (!modeDiff && !timesDiff) {
return callback(null, fd);
}
// Check access, `futimes` and `fchmod` only work if we own the file,
// or if we are effectively root.
if (!isOwner(stat)) {
return callback(null, fd);
}
if (modeDiff) {
return mode();
}
times();
function mode() {
var mode = stat.mode ^ modeDiff;
fs.fchmod(fd, mode, onFchmod);
function onFchmod(fchmodErr) {
if (!fchmodErr) {
file.stat.mode = mode;
}
if (timesDiff) {
return times(fchmodErr);
}
callback(fchmodErr, fd);
}
}
function times(fchmodErr) {
fs.futimes(fd, timesDiff.atime, timesDiff.mtime, onFutimes);
function onFutimes(futimesErr) {
if (!futimesErr) {
file.stat.atime = timesDiff.atime;
file.stat.mtime = timesDiff.mtime;
}
callback(fchmodErr || futimesErr, fd);
}
}
}
}
/*
Custom writeFile implementation because we need access to the
file descriptor after the write is complete.
Most of the implementation taken from node core.
*/
function writeFile(path, data, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}
if (!Buffer.isBuffer(data)) {
callback(new TypeError('Data must be a Buffer'));
return;
}
if (!options) {
options = {};
}
// Default the same as node
var mode = options.mode || DEFAULT_FILE_MODE;
var flag = options.flag || 'w';
var position = APPEND_MODE_REGEXP.test(flag) ? null : 0;
fs.open(path, flag, mode, onOpen);
function onOpen(err, fd) {
if (err) {
return onComplete(err);
}
fs.write(fd, data, 0, data.length, position, onComplete);
function onComplete(err) {
callback(err, fd);
}
}
}
module.exports = {
closeFd: closeFd,
getModeDiff: getModeDiff,
getTimesDiff: getTimesDiff,
isOwner: isOwner,
updateMetadata: updateMetadata,
writeFile: writeFile,
};

16
Client/node_modules/vinyl-fs/lib/filterSince.js generated vendored Executable file
View File

@@ -0,0 +1,16 @@
'use strict';
var filter = require('through2-filter');
module.exports = function(d) {
var isValid = typeof d === 'number' ||
d instanceof Number ||
d instanceof Date;
if (!isValid) {
throw new Error('expected since option to be a date or a number');
}
return filter.obj(function(file) {
return file.stat && file.stat.mtime > d;
});
};

69
Client/node_modules/vinyl-fs/lib/prepareWrite.js generated vendored Executable file
View File

@@ -0,0 +1,69 @@
'use strict';
var assign = require('object-assign');
var path = require('path');
var mkdirp = require('mkdirp');
var fs = require('graceful-fs');
function booleanOrFunc(v, file) {
if (typeof v !== 'boolean' && typeof v !== 'function') {
return null;
}
return typeof v === 'boolean' ? v : v(file);
}
function stringOrFunc(v, file) {
if (typeof v !== 'string' && typeof v !== 'function') {
return null;
}
return typeof v === 'string' ? v : v(file);
}
function prepareWrite(outFolder, file, opt, cb) {
var options = assign({
cwd: process.cwd(),
mode: (file.stat ? file.stat.mode : null),
dirMode: null,
overwrite: true,
}, opt);
var overwrite = booleanOrFunc(options.overwrite, file);
options.flag = (overwrite ? 'w' : 'wx');
var cwd = path.resolve(options.cwd);
var outFolderPath = stringOrFunc(outFolder, file);
if (!outFolderPath) {
throw new Error('Invalid output folder');
}
var basePath = options.base ?
stringOrFunc(options.base, file) : path.resolve(cwd, outFolderPath);
if (!basePath) {
throw new Error('Invalid base option');
}
var writePath = path.resolve(basePath, file.relative);
var writeFolder = path.dirname(writePath);
// Wire up new properties
file.stat = (file.stat || new fs.Stats());
file.stat.mode = options.mode;
file.flag = options.flag;
file.cwd = cwd;
file.base = basePath;
file.path = writePath;
// Mkdirp the folder the file is going in
var mkdirpOpts = {
mode: options.dirMode,
fs: fs,
};
mkdirp(writeFolder, mkdirpOpts, function(err) {
if (err) {
return cb(err);
}
cb(null, writePath);
});
}
module.exports = prepareWrite;

53
Client/node_modules/vinyl-fs/lib/sink.js generated vendored Executable file
View File

@@ -0,0 +1,53 @@
'use strict';
var Writable = require('readable-stream/writable');
function listenerCount(stream, evt) {
return stream.listeners(evt).length;
}
function hasListeners(stream) {
return !!(listenerCount(stream, 'readable') || listenerCount(stream, 'data'));
}
function sink(stream) {
var sinkAdded = false;
var sinkStream = new Writable({
objectMode: true,
write: function(file, enc, cb) {
cb();
},
});
function addSink() {
if (sinkAdded) {
return;
}
if (hasListeners(stream)) {
return;
}
sinkAdded = true;
stream.pipe(sinkStream);
}
function removeSink(evt) {
if (evt !== 'readable' && evt !== 'data') {
return;
}
if (hasListeners(stream)) {
sinkAdded = false;
stream.unpipe(sinkStream);
}
}
stream.on('newListener', removeSink);
stream.on('removeListener', removeSink);
stream.on('removeListener', addSink);
return addSink;
}
module.exports = sink;

View File

@@ -0,0 +1,22 @@
'use strict';
var fs = require('graceful-fs');
var stripBom = require('strip-bom');
function bufferFile(file, opt, cb) {
fs.readFile(file.path, function(err, data) {
if (err) {
return cb(err);
}
if (opt.stripBOM) {
file.contents = stripBom(data);
} else {
file.contents = data;
}
cb(null, file);
});
}
module.exports = bufferFile;

31
Client/node_modules/vinyl-fs/lib/src/getContents/index.js generated vendored Executable file
View File

@@ -0,0 +1,31 @@
'use strict';
var through2 = require('through2');
var readDir = require('./readDir');
var readSymbolicLink = require('./readSymbolicLink');
var bufferFile = require('./bufferFile');
var streamFile = require('./streamFile');
function getContents(opt) {
return through2.obj(opt, function(file, enc, cb) {
// Don't fail to read a directory
if (file.isDirectory()) {
return readDir(file, opt, cb);
}
// Process symbolic links included with `followSymlinks` option
if (file.stat && file.stat.isSymbolicLink()) {
return readSymbolicLink(file, opt, cb);
}
// Read and pass full contents
if (opt.buffer !== false) {
return bufferFile(file, opt, cb);
}
// Don't buffer anything - just pass streams
return streamFile(file, opt, cb);
});
}
module.exports = getContents;

View File

@@ -0,0 +1,8 @@
'use strict';
function readDir(file, opt, cb) {
// Do nothing for now
cb(null, file);
}
module.exports = readDir;

View File

@@ -0,0 +1,18 @@
'use strict';
var fs = require('graceful-fs');
function readLink(file, opt, cb) {
fs.readlink(file.path, function(err, target) {
if (err) {
return cb(err);
}
// Store the link target path
file.symlink = target;
return cb(null, file);
});
}
module.exports = readLink;

View File

@@ -0,0 +1,26 @@
'use strict';
var fs = require('graceful-fs');
var stripBom = require('strip-bom-stream');
var lazystream = require('lazystream');
function streamFile(file, opt, cb) {
if (typeof opt === 'function') {
cb = opt;
opt = {};
}
var filePath = file.path;
file.contents = new lazystream.Readable(function() {
return fs.createReadStream(filePath);
});
if (opt.stripBOM) {
file.contents = file.contents.pipe(stripBom());
}
cb(null, file);
}
module.exports = streamFile;

62
Client/node_modules/vinyl-fs/lib/src/index.js generated vendored Executable file
View File

@@ -0,0 +1,62 @@
'use strict';
var assign = require('object-assign');
var through2 = require('through2');
var gs = require('glob-stream');
var duplexify = require('duplexify');
var merge = require('merge-stream');
var sourcemaps = require('gulp-sourcemaps');
var filterSince = require('../filterSince');
var isValidGlob = require('is-valid-glob');
var getContents = require('./getContents');
var wrapWithVinylFile = require('./wrapWithVinylFile');
function src(glob, opt) {
var options = assign({
read: true,
buffer: true,
stripBOM: true,
sourcemaps: false,
passthrough: false,
followSymlinks: true,
}, opt);
// Don't pass `read` option on to through2
var read = options.read !== false;
options.read = undefined;
var inputPass;
if (!isValidGlob(glob)) {
throw new Error('Invalid glob argument: ' + glob);
}
var globStream = gs.create(glob, options);
var outputStream = globStream
.pipe(wrapWithVinylFile(options));
if (options.since != null) {
outputStream = outputStream
.pipe(filterSince(options.since));
}
if (read) {
outputStream = outputStream
.pipe(getContents(options));
}
if (options.passthrough === true) {
inputPass = through2.obj(options);
outputStream = duplexify.obj(inputPass, merge(outputStream, inputPass));
}
if (options.sourcemaps === true) {
outputStream = outputStream
.pipe(sourcemaps.init({ loadMaps: true }));
}
globStream.on('error', outputStream.emit.bind(outputStream, 'error'));
return outputStream;
}
module.exports = src;

51
Client/node_modules/vinyl-fs/lib/src/wrapWithVinylFile.js generated vendored Executable file
View File

@@ -0,0 +1,51 @@
'use strict';
var through2 = require('through2');
var fs = require('graceful-fs');
var File = require('vinyl');
function wrapWithVinylFile(options) {
// A stat property is exposed on file objects as a (wanted) side effect
function resolveFile(globFile, enc, cb) {
fs.lstat(globFile.path, function(err, stat) {
if (err) {
return cb(err);
}
globFile.stat = stat;
if (!stat.isSymbolicLink() || !options.followSymlinks) {
var vinylFile = new File(globFile);
if (globFile.originalSymlinkPath) {
// If we reach here, it means there is at least one
// symlink on the path and we need to rewrite the path
// to its original value.
// Updated file stats will tell getContents() to actually read it.
vinylFile.path = globFile.originalSymlinkPath;
}
return cb(null, vinylFile);
}
fs.realpath(globFile.path, function(err, filePath) {
if (err) {
return cb(err);
}
if (!globFile.originalSymlinkPath) {
// Store the original symlink path before the recursive call
// to later rewrite it back.
globFile.originalSymlinkPath = globFile.path;
}
globFile.path = filePath;
// Recurse to get real file stat
resolveFile(globFile, enc, cb);
});
});
}
return through2.obj(options, resolveFile);
}
module.exports = wrapWithVinylFile;

30
Client/node_modules/vinyl-fs/lib/symlink/index.js generated vendored Executable file
View File

@@ -0,0 +1,30 @@
'use strict';
var through2 = require('through2');
var fs = require('graceful-fs');
var prepareWrite = require('../prepareWrite');
function symlink(outFolder, opt) {
function linkFile(file, enc, cb) {
var srcPath = file.path;
var symType = (file.isDirectory() ? 'dir' : 'file');
prepareWrite(outFolder, file, opt, function(err, writePath) {
if (err) {
return cb(err);
}
fs.symlink(srcPath, writePath, symType, function(err) {
if (err && err.code !== 'EEXIST') {
return cb(err);
}
cb(null, file);
});
});
}
var stream = through2.obj(opt, linkFile);
// TODO: option for either backpressure or lossy
stream.resume();
return stream;
}
module.exports = symlink;