Updating NPM dependencies
This commit is contained in:
5
node_modules/jest-haste-map/build/crawlers/node.d.ts
generated
vendored
5
node_modules/jest-haste-map/build/crawlers/node.d.ts
generated
vendored
@@ -4,10 +4,9 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { InternalHasteMap, CrawlerOptions } from '../types';
|
||||
import type { CrawlerOptions, FileData, InternalHasteMap } from '../types';
|
||||
declare const _default: (options: CrawlerOptions) => Promise<{
|
||||
removedFiles: Map<string, [string, number, number, 0 | 1, string, string | null | undefined]>;
|
||||
removedFiles: FileData;
|
||||
hasteMap: InternalHasteMap;
|
||||
}>;
|
||||
export = _default;
|
||||
//# sourceMappingURL=node.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/crawlers/node.d.ts.map
generated
vendored
1
node_modules/jest-haste-map/build/crawlers/node.d.ts.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/crawlers/node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,EAEL,gBAAgB,EAChB,cAAc,EAEf,MAAM,UAAU,CAAC;;;;;AAsHlB,kBA6CE"}
|
||||
315
node_modules/jest-haste-map/build/crawlers/node.js
generated
vendored
315
node_modules/jest-haste-map/build/crawlers/node.js
generated
vendored
@@ -1,107 +1,140 @@
|
||||
'use strict';
|
||||
|
||||
function _fs() {
|
||||
const data = _interopRequireDefault(require('fs'));
|
||||
|
||||
_fs = function _fs() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _child_process() {
|
||||
const data = require('child_process');
|
||||
|
||||
_child_process = function _child_process() {
|
||||
_child_process = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var _constants = _interopRequireDefault(require('../constants'));
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('../lib/fast_path'));
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
function fs() {
|
||||
const data = _interopRequireWildcard(require('graceful-fs'));
|
||||
|
||||
fs = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _constants() {
|
||||
const data = _interopRequireDefault(require('../constants'));
|
||||
|
||||
_constants = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function fastPath() {
|
||||
const data = _interopRequireWildcard(require('../lib/fast_path'));
|
||||
|
||||
fastPath = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return (
|
||||
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
|
||||
);
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError('Invalid attempt to destructure non-iterable instance');
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (
|
||||
var _i = arr[Symbol.iterator](), _s;
|
||||
!(_n = (_s = _i.next()).done);
|
||||
_n = true
|
||||
) {
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i['return'] != null) _i['return']();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
async function hasNativeFindSupport(forceNodeFilesystemAPI) {
|
||||
if (forceNodeFilesystemAPI) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return await new Promise(resolve => {
|
||||
// Check the find binary supports the non-POSIX -iname parameter wrapped in parens.
|
||||
const args = [
|
||||
'.',
|
||||
'-type',
|
||||
'f',
|
||||
'(',
|
||||
'-iname',
|
||||
'*.ts',
|
||||
'-o',
|
||||
'-iname',
|
||||
'*.js',
|
||||
')'
|
||||
];
|
||||
const child = (0, _child_process().spawn)('find', args, {
|
||||
cwd: __dirname
|
||||
});
|
||||
child.on('error', () => {
|
||||
resolve(false);
|
||||
});
|
||||
child.on('exit', code => {
|
||||
resolve(code === 0);
|
||||
});
|
||||
});
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function find(roots, extensions, ignore, callback) {
|
||||
@@ -110,51 +143,69 @@ function find(roots, extensions, ignore, callback) {
|
||||
|
||||
function search(directory) {
|
||||
activeCalls++;
|
||||
fs().readdir(
|
||||
directory,
|
||||
{
|
||||
withFileTypes: true
|
||||
},
|
||||
(err, entries) => {
|
||||
activeCalls--;
|
||||
|
||||
_fs().default.readdir(directory, (err, names) => {
|
||||
activeCalls--;
|
||||
|
||||
if (err) {
|
||||
callback(result);
|
||||
return;
|
||||
}
|
||||
|
||||
names.forEach(file => {
|
||||
file = _path().default.join(directory, file);
|
||||
|
||||
if (ignore(file)) {
|
||||
if (err) {
|
||||
callback(result);
|
||||
return;
|
||||
}
|
||||
} // node < v10.10 does not support the withFileTypes option, and
|
||||
// entry will be a string.
|
||||
|
||||
activeCalls++;
|
||||
entries.forEach(entry => {
|
||||
const file = path().join(
|
||||
directory,
|
||||
typeof entry === 'string' ? entry : entry.name
|
||||
);
|
||||
|
||||
_fs().default.lstat(file, (err, stat) => {
|
||||
activeCalls--;
|
||||
if (ignore(file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!err && stat && !stat.isSymbolicLink()) {
|
||||
if (stat.isDirectory()) {
|
||||
if (typeof entry !== 'string') {
|
||||
if (entry.isSymbolicLink()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
search(file);
|
||||
} else {
|
||||
const ext = _path()
|
||||
.default.extname(file)
|
||||
.substr(1);
|
||||
|
||||
if (extensions.indexOf(ext) !== -1) {
|
||||
result.push([file, stat.mtime.getTime(), stat.size]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (activeCalls === 0) {
|
||||
callback(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
activeCalls++;
|
||||
fs().lstat(file, (err, stat) => {
|
||||
activeCalls--; // This logic is unnecessary for node > v10.10, but leaving it in
|
||||
// since we need it for backwards-compatibility still.
|
||||
|
||||
if (activeCalls === 0) {
|
||||
callback(result);
|
||||
if (!err && stat && !stat.isSymbolicLink()) {
|
||||
if (stat.isDirectory()) {
|
||||
search(file);
|
||||
} else {
|
||||
const ext = path().extname(file).substr(1);
|
||||
|
||||
if (extensions.indexOf(ext) !== -1) {
|
||||
result.push([file, stat.mtime.getTime(), stat.size]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (activeCalls === 0) {
|
||||
callback(result);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (activeCalls === 0) {
|
||||
callback(result);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
}
|
||||
|
||||
if (roots.length > 0) {
|
||||
@@ -208,7 +259,7 @@ function findNative(roots, extensions, ignore, callback) {
|
||||
callback([]);
|
||||
} else {
|
||||
lines.forEach(path => {
|
||||
_fs().default.stat(path, (err, stat) => {
|
||||
fs().stat(path, (err, stat) => {
|
||||
if (!err && stat) {
|
||||
result.push([path, stat.mtime.getTime(), stat.size]);
|
||||
}
|
||||
@@ -222,27 +273,29 @@ function findNative(roots, extensions, ignore, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = function nodeCrawl(options) {
|
||||
const data = options.data,
|
||||
extensions = options.extensions,
|
||||
forceNodeFilesystemAPI = options.forceNodeFilesystemAPI,
|
||||
ignore = options.ignore,
|
||||
rootDir = options.rootDir,
|
||||
roots = options.roots;
|
||||
module.exports = async function nodeCrawl(options) {
|
||||
const {
|
||||
data,
|
||||
extensions,
|
||||
forceNodeFilesystemAPI,
|
||||
ignore,
|
||||
rootDir,
|
||||
roots
|
||||
} = options;
|
||||
const useNativeFind = await hasNativeFindSupport(forceNodeFilesystemAPI);
|
||||
return new Promise(resolve => {
|
||||
const callback = list => {
|
||||
const files = new Map();
|
||||
const removedFiles = new Map(data.files);
|
||||
list.forEach(fileData => {
|
||||
const _fileData = _slicedToArray(fileData, 3),
|
||||
filePath = _fileData[0],
|
||||
mtime = _fileData[1],
|
||||
size = _fileData[2];
|
||||
|
||||
const relativeFilePath = fastPath.relative(rootDir, filePath);
|
||||
const [filePath, mtime, size] = fileData;
|
||||
const relativeFilePath = fastPath().relative(rootDir, filePath);
|
||||
const existingFile = data.files.get(relativeFilePath);
|
||||
|
||||
if (existingFile && existingFile[_constants.default.MTIME] === mtime) {
|
||||
if (
|
||||
existingFile &&
|
||||
existingFile[_constants().default.MTIME] === mtime
|
||||
) {
|
||||
files.set(relativeFilePath, existingFile);
|
||||
} else {
|
||||
// See ../constants.js; SHA-1 will always be null and fulfilled later.
|
||||
@@ -258,10 +311,10 @@ module.exports = function nodeCrawl(options) {
|
||||
});
|
||||
};
|
||||
|
||||
if (forceNodeFilesystemAPI || process.platform === 'win32') {
|
||||
find(roots, extensions, ignore, callback);
|
||||
} else {
|
||||
if (useNativeFind) {
|
||||
findNative(roots, extensions, ignore, callback);
|
||||
} else {
|
||||
find(roots, extensions, ignore, callback);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
7
node_modules/jest-haste-map/build/crawlers/watchman.d.ts
generated
vendored
7
node_modules/jest-haste-map/build/crawlers/watchman.d.ts
generated
vendored
@@ -4,11 +4,10 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
import { InternalHasteMap, CrawlerOptions } from '../types';
|
||||
import type { CrawlerOptions, FileData, InternalHasteMap } from '../types';
|
||||
declare const _default: (options: CrawlerOptions) => Promise<{
|
||||
changedFiles?: Map<string, [string, number, number, 0 | 1, string, string | null | undefined]> | undefined;
|
||||
removedFiles: Map<string, [string, number, number, 0 | 1, string, string | null | undefined]>;
|
||||
changedFiles?: FileData | undefined;
|
||||
removedFiles: FileData;
|
||||
hasteMap: InternalHasteMap;
|
||||
}>;
|
||||
export = _default;
|
||||
//# sourceMappingURL=watchman.d.ts.map
|
||||
1
node_modules/jest-haste-map/build/crawlers/watchman.d.ts.map
generated
vendored
1
node_modules/jest-haste-map/build/crawlers/watchman.d.ts.map
generated
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"watchman.d.ts","sourceRoot":"","sources":["../../src/crawlers/watchman.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,OAAO,EACL,gBAAgB,EAChB,cAAc,EAGf,MAAM,UAAU,CAAC;;;;;;AAclB,kBAwOE"}
|
||||
809
node_modules/jest-haste-map/build/crawlers/watchman.js
generated
vendored
809
node_modules/jest-haste-map/build/crawlers/watchman.js
generated
vendored
@@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
function _path() {
|
||||
const data = _interopRequireDefault(require('path'));
|
||||
function path() {
|
||||
const data = _interopRequireWildcard(require('path'));
|
||||
|
||||
_path = function _path() {
|
||||
path = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -13,125 +13,96 @@ function _path() {
|
||||
function _fbWatchman() {
|
||||
const data = _interopRequireDefault(require('fb-watchman'));
|
||||
|
||||
_fbWatchman = function _fbWatchman() {
|
||||
_fbWatchman = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
var fastPath = _interopRequireWildcard(require('../lib/fast_path'));
|
||||
function _constants() {
|
||||
const data = _interopRequireDefault(require('../constants'));
|
||||
|
||||
var _normalizePathSep = _interopRequireDefault(
|
||||
require('../lib/normalizePathSep')
|
||||
);
|
||||
_constants = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
var _constants = _interopRequireDefault(require('../constants'));
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
} else {
|
||||
var newObj = {};
|
||||
if (obj != null) {
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: {};
|
||||
if (desc.get || desc.set) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
return newObj;
|
||||
}
|
||||
function fastPath() {
|
||||
const data = _interopRequireWildcard(require('../lib/fast_path'));
|
||||
|
||||
fastPath = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _normalizePathSep() {
|
||||
const data = _interopRequireDefault(require('../lib/normalizePathSep'));
|
||||
|
||||
_normalizePathSep = function () {
|
||||
return data;
|
||||
};
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
function _interopRequireDefault(obj) {
|
||||
return obj && obj.__esModule ? obj : {default: obj};
|
||||
}
|
||||
|
||||
function _slicedToArray(arr, i) {
|
||||
return (
|
||||
_arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest()
|
||||
);
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError('Invalid attempt to destructure non-iterable instance');
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (
|
||||
var _i = arr[Symbol.iterator](), _s;
|
||||
!(_n = (_s = _i.next()).done);
|
||||
_n = true
|
||||
) {
|
||||
_arr.push(_s.value);
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i['return'] != null) _i['return']();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
||||
try {
|
||||
var info = gen[key](arg);
|
||||
var value = info.value;
|
||||
} catch (error) {
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
if (info.done) {
|
||||
resolve(value);
|
||||
} else {
|
||||
Promise.resolve(value).then(_next, _throw);
|
||||
}
|
||||
}
|
||||
|
||||
function _asyncToGenerator(fn) {
|
||||
return function() {
|
||||
var self = this,
|
||||
args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
var gen = fn.apply(self, args);
|
||||
function _next(value) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value);
|
||||
}
|
||||
function _throw(err) {
|
||||
asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err);
|
||||
}
|
||||
_next(undefined);
|
||||
});
|
||||
function _getRequireWildcardCache() {
|
||||
if (typeof WeakMap !== 'function') return null;
|
||||
var cache = new WeakMap();
|
||||
_getRequireWildcardCache = function () {
|
||||
return cache;
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
|
||||
const watchmanURL =
|
||||
'https://facebook.github.io/watchman/docs/troubleshooting.html';
|
||||
function _interopRequireWildcard(obj) {
|
||||
if (obj && obj.__esModule) {
|
||||
return obj;
|
||||
}
|
||||
if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
return {default: obj};
|
||||
}
|
||||
var cache = _getRequireWildcardCache();
|
||||
if (cache && cache.has(obj)) {
|
||||
return cache.get(obj);
|
||||
}
|
||||
var newObj = {};
|
||||
var hasPropertyDescriptor =
|
||||
Object.defineProperty && Object.getOwnPropertyDescriptor;
|
||||
for (var key in obj) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
var desc = hasPropertyDescriptor
|
||||
? Object.getOwnPropertyDescriptor(obj, key)
|
||||
: null;
|
||||
if (desc && (desc.get || desc.set)) {
|
||||
Object.defineProperty(newObj, key, desc);
|
||||
} else {
|
||||
newObj[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
newObj.default = obj;
|
||||
if (cache) {
|
||||
cache.set(obj, newObj);
|
||||
}
|
||||
return newObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
const watchmanURL = 'https://facebook.github.io/watchman/docs/troubleshooting';
|
||||
|
||||
function WatchmanError(error) {
|
||||
error.message =
|
||||
@@ -140,449 +111,217 @@ function WatchmanError(error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
module.exports =
|
||||
/*#__PURE__*/
|
||||
(function() {
|
||||
var _watchmanCrawl = _asyncToGenerator(function*(options) {
|
||||
const fields = ['name', 'exists', 'mtime_ms', 'size'];
|
||||
const data = options.data,
|
||||
extensions = options.extensions,
|
||||
ignore = options.ignore,
|
||||
rootDir = options.rootDir,
|
||||
roots = options.roots;
|
||||
const defaultWatchExpression = [
|
||||
'allof',
|
||||
['type', 'f'],
|
||||
['anyof', ...extensions.map(extension => ['suffix', extension])]
|
||||
];
|
||||
const clocks = data.clocks;
|
||||
const client = new (_fbWatchman()).default.Client();
|
||||
let clientError;
|
||||
client.on('error', error => (clientError = WatchmanError(error))); // TODO: type better than `any`
|
||||
module.exports = async function watchmanCrawl(options) {
|
||||
const fields = ['name', 'exists', 'mtime_ms', 'size'];
|
||||
const {data, extensions, ignore, rootDir, roots} = options;
|
||||
const defaultWatchExpression = [
|
||||
'allof',
|
||||
['type', 'f'],
|
||||
['anyof', ...extensions.map(extension => ['suffix', extension])]
|
||||
];
|
||||
const clocks = data.clocks;
|
||||
const client = new (_fbWatchman().default.Client)();
|
||||
let clientError;
|
||||
client.on('error', error => (clientError = WatchmanError(error))); // TODO: type better than `any`
|
||||
|
||||
const cmd = (...args) =>
|
||||
new Promise((resolve, reject) =>
|
||||
client.command(args, (error, result) =>
|
||||
error ? reject(WatchmanError(error)) : resolve(result)
|
||||
)
|
||||
);
|
||||
const cmd = (...args) =>
|
||||
new Promise((resolve, reject) =>
|
||||
client.command(args, (error, result) =>
|
||||
error ? reject(WatchmanError(error)) : resolve(result)
|
||||
)
|
||||
);
|
||||
|
||||
if (options.computeSha1) {
|
||||
const _ref = yield cmd('list-capabilities'),
|
||||
capabilities = _ref.capabilities;
|
||||
if (options.computeSha1) {
|
||||
const {capabilities} = await cmd('list-capabilities');
|
||||
|
||||
if (capabilities.indexOf('field-content.sha1hex') !== -1) {
|
||||
fields.push('content.sha1hex');
|
||||
if (capabilities.indexOf('field-content.sha1hex') !== -1) {
|
||||
fields.push('content.sha1hex');
|
||||
}
|
||||
}
|
||||
|
||||
async function getWatchmanRoots(roots) {
|
||||
const watchmanRoots = new Map();
|
||||
await Promise.all(
|
||||
roots.map(async root => {
|
||||
const response = await cmd('watch-project', root);
|
||||
const existing = watchmanRoots.get(response.watch); // A root can only be filtered if it was never seen with a
|
||||
// relative_path before.
|
||||
|
||||
const canBeFiltered = !existing || existing.length > 0;
|
||||
|
||||
if (canBeFiltered) {
|
||||
if (response.relative_path) {
|
||||
watchmanRoots.set(
|
||||
response.watch,
|
||||
(existing || []).concat(response.relative_path)
|
||||
);
|
||||
} else {
|
||||
// Make the filter directories an empty array to signal that this
|
||||
// root was already seen and needs to be watched for all files or
|
||||
// directories.
|
||||
watchmanRoots.set(response.watch, []);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
return watchmanRoots;
|
||||
}
|
||||
|
||||
function getWatchmanRoots(_x2) {
|
||||
return _getWatchmanRoots.apply(this, arguments);
|
||||
}
|
||||
async function queryWatchmanForDirs(rootProjectDirMappings) {
|
||||
const files = new Map();
|
||||
let isFresh = false;
|
||||
await Promise.all(
|
||||
Array.from(rootProjectDirMappings).map(
|
||||
async ([root, directoryFilters]) => {
|
||||
const expression = Array.from(defaultWatchExpression);
|
||||
const glob = [];
|
||||
|
||||
function _getWatchmanRoots() {
|
||||
_getWatchmanRoots = _asyncToGenerator(function*(roots) {
|
||||
const watchmanRoots = new Map();
|
||||
yield Promise.all(
|
||||
roots.map(
|
||||
/*#__PURE__*/
|
||||
(function() {
|
||||
var _ref2 = _asyncToGenerator(function*(root) {
|
||||
const response = yield cmd('watch-project', root);
|
||||
const existing = watchmanRoots.get(response.watch); // A root can only be filtered if it was never seen with a
|
||||
// relative_path before.
|
||||
if (directoryFilters.length > 0) {
|
||||
expression.push([
|
||||
'anyof',
|
||||
...directoryFilters.map(dir => ['dirname', dir])
|
||||
]);
|
||||
|
||||
const canBeFiltered = !existing || existing.length > 0;
|
||||
|
||||
if (canBeFiltered) {
|
||||
if (response.relative_path) {
|
||||
watchmanRoots.set(
|
||||
response.watch,
|
||||
(existing || []).concat(response.relative_path)
|
||||
);
|
||||
} else {
|
||||
// Make the filter directories an empty array to signal that this
|
||||
// root was already seen and needs to be watched for all files or
|
||||
// directories.
|
||||
watchmanRoots.set(response.watch, []);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return function(_x4) {
|
||||
return _ref2.apply(this, arguments);
|
||||
};
|
||||
})()
|
||||
)
|
||||
);
|
||||
return watchmanRoots;
|
||||
});
|
||||
return _getWatchmanRoots.apply(this, arguments);
|
||||
}
|
||||
|
||||
function queryWatchmanForDirs(_x3) {
|
||||
return _queryWatchmanForDirs.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _queryWatchmanForDirs() {
|
||||
_queryWatchmanForDirs = _asyncToGenerator(function*(
|
||||
rootProjectDirMappings
|
||||
) {
|
||||
const files = new Map();
|
||||
let isFresh = false;
|
||||
yield Promise.all(
|
||||
Array.from(rootProjectDirMappings).map(
|
||||
/*#__PURE__*/
|
||||
(function() {
|
||||
var _ref3 = _asyncToGenerator(function*([
|
||||
root,
|
||||
directoryFilters
|
||||
]) {
|
||||
const expression = Array.from(defaultWatchExpression);
|
||||
const glob = [];
|
||||
|
||||
if (directoryFilters.length > 0) {
|
||||
expression.push([
|
||||
'anyof',
|
||||
...directoryFilters.map(dir => ['dirname', dir])
|
||||
]);
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator2 = directoryFilters[Symbol.iterator](),
|
||||
_step2;
|
||||
!(_iteratorNormalCompletion2 = (_step2 = _iterator2.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion2 = true
|
||||
) {
|
||||
const directory = _step2.value;
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator3 = extensions[Symbol.iterator](),
|
||||
_step3;
|
||||
!(_iteratorNormalCompletion3 = (_step3 = _iterator3.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion3 = true
|
||||
) {
|
||||
const extension = _step3.value;
|
||||
glob.push(`${directory}/**/*.${extension}`);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion3 &&
|
||||
_iterator3.return != null
|
||||
) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion2 &&
|
||||
_iterator2.return != null
|
||||
) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var _iteratorNormalCompletion4 = true;
|
||||
var _didIteratorError4 = false;
|
||||
var _iteratorError4 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator4 = extensions[Symbol.iterator](), _step4;
|
||||
!(_iteratorNormalCompletion4 = (_step4 = _iterator4.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion4 = true
|
||||
) {
|
||||
const extension = _step4.value;
|
||||
glob.push(`**/*.${extension}`);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError4 = true;
|
||||
_iteratorError4 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion4 &&
|
||||
_iterator4.return != null
|
||||
) {
|
||||
_iterator4.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError4) {
|
||||
throw _iteratorError4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const relativeRoot = fastPath.relative(rootDir, root);
|
||||
const query = clocks.has(relativeRoot) // Use the `since` generator if we have a clock available
|
||||
? {
|
||||
expression,
|
||||
fields,
|
||||
since: clocks.get(relativeRoot)
|
||||
} // Otherwise use the `glob` filter
|
||||
: {
|
||||
expression,
|
||||
fields,
|
||||
glob
|
||||
};
|
||||
const response = yield cmd('query', root, query);
|
||||
|
||||
if ('warning' in response) {
|
||||
console.warn('watchman warning: ', response.warning);
|
||||
}
|
||||
|
||||
isFresh = isFresh || response.is_fresh_instance;
|
||||
files.set(root, response);
|
||||
});
|
||||
|
||||
return function(_x5) {
|
||||
return _ref3.apply(this, arguments);
|
||||
};
|
||||
})()
|
||||
)
|
||||
);
|
||||
return {
|
||||
files,
|
||||
isFresh
|
||||
};
|
||||
});
|
||||
return _queryWatchmanForDirs.apply(this, arguments);
|
||||
}
|
||||
|
||||
let files = data.files;
|
||||
let removedFiles = new Map();
|
||||
const changedFiles = new Map();
|
||||
let watchmanFiles;
|
||||
let isFresh = false;
|
||||
|
||||
try {
|
||||
const watchmanRoots = yield getWatchmanRoots(roots);
|
||||
const watchmanFileResults = yield queryWatchmanForDirs(watchmanRoots); // Reset the file map if watchman was restarted and sends us a list of
|
||||
// files.
|
||||
|
||||
if (watchmanFileResults.isFresh) {
|
||||
files = new Map();
|
||||
removedFiles = new Map(data.files);
|
||||
isFresh = true;
|
||||
}
|
||||
|
||||
watchmanFiles = watchmanFileResults.files;
|
||||
} finally {
|
||||
client.end();
|
||||
}
|
||||
|
||||
if (clientError) {
|
||||
throw clientError;
|
||||
} // TODO: remove non-null
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator = watchmanFiles[Symbol.iterator](), _step;
|
||||
!(_iteratorNormalCompletion = (_step = _iterator.next()).done);
|
||||
_iteratorNormalCompletion = true
|
||||
) {
|
||||
const _step$value = _slicedToArray(_step.value, 2),
|
||||
watchRoot = _step$value[0],
|
||||
response = _step$value[1];
|
||||
|
||||
const fsRoot = (0, _normalizePathSep.default)(watchRoot);
|
||||
const relativeFsRoot = fastPath.relative(rootDir, fsRoot);
|
||||
clocks.set(relativeFsRoot, response.clock);
|
||||
var _iteratorNormalCompletion5 = true;
|
||||
var _didIteratorError5 = false;
|
||||
var _iteratorError5 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator5 = response.files[Symbol.iterator](), _step5;
|
||||
!(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done);
|
||||
_iteratorNormalCompletion5 = true
|
||||
) {
|
||||
const fileData = _step5.value;
|
||||
const filePath =
|
||||
fsRoot +
|
||||
_path().default.sep +
|
||||
(0, _normalizePathSep.default)(fileData.name);
|
||||
const relativeFilePath = fastPath.relative(rootDir, filePath);
|
||||
const existingFileData = data.files.get(relativeFilePath); // If watchman is fresh, the removed files map starts with all files
|
||||
// and we remove them as we verify they still exist.
|
||||
|
||||
if (isFresh && existingFileData && fileData.exists) {
|
||||
removedFiles.delete(relativeFilePath);
|
||||
}
|
||||
|
||||
if (!fileData.exists) {
|
||||
// No need to act on files that do not exist and were not tracked.
|
||||
if (existingFileData) {
|
||||
files.delete(relativeFilePath); // If watchman is not fresh, we will know what specific files were
|
||||
// deleted since we last ran and can track only those files.
|
||||
|
||||
if (!isFresh) {
|
||||
removedFiles.set(relativeFilePath, existingFileData);
|
||||
}
|
||||
}
|
||||
} else if (!ignore(filePath)) {
|
||||
const mtime =
|
||||
typeof fileData.mtime_ms === 'number'
|
||||
? fileData.mtime_ms
|
||||
: fileData.mtime_ms.toNumber();
|
||||
const size = fileData.size;
|
||||
let sha1hex = fileData['content.sha1hex'];
|
||||
|
||||
if (typeof sha1hex !== 'string' || sha1hex.length !== 40) {
|
||||
sha1hex = null;
|
||||
}
|
||||
|
||||
let nextData;
|
||||
|
||||
if (
|
||||
existingFileData &&
|
||||
existingFileData[_constants.default.MTIME] === mtime
|
||||
) {
|
||||
nextData = existingFileData;
|
||||
} else if (
|
||||
existingFileData &&
|
||||
sha1hex &&
|
||||
existingFileData[_constants.default.SHA1] === sha1hex
|
||||
) {
|
||||
nextData = [
|
||||
existingFileData[0],
|
||||
mtime,
|
||||
existingFileData[2],
|
||||
existingFileData[3],
|
||||
existingFileData[4],
|
||||
existingFileData[5]
|
||||
];
|
||||
} else {
|
||||
// See ../constants.ts
|
||||
nextData = ['', mtime, size, 0, '', sha1hex];
|
||||
}
|
||||
|
||||
const mappings = options.mapper
|
||||
? options.mapper(filePath)
|
||||
: null;
|
||||
|
||||
if (mappings) {
|
||||
var _iteratorNormalCompletion6 = true;
|
||||
var _didIteratorError6 = false;
|
||||
var _iteratorError6 = undefined;
|
||||
|
||||
try {
|
||||
for (
|
||||
var _iterator6 = mappings[Symbol.iterator](), _step6;
|
||||
!(_iteratorNormalCompletion6 = (_step6 = _iterator6.next())
|
||||
.done);
|
||||
_iteratorNormalCompletion6 = true
|
||||
) {
|
||||
const absoluteVirtualFilePath = _step6.value;
|
||||
|
||||
if (!ignore(absoluteVirtualFilePath)) {
|
||||
const relativeVirtualFilePath = fastPath.relative(
|
||||
rootDir,
|
||||
absoluteVirtualFilePath
|
||||
);
|
||||
files.set(relativeVirtualFilePath, nextData);
|
||||
changedFiles.set(relativeVirtualFilePath, nextData);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError6 = true;
|
||||
_iteratorError6 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (
|
||||
!_iteratorNormalCompletion6 &&
|
||||
_iterator6.return != null
|
||||
) {
|
||||
_iterator6.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError6) {
|
||||
throw _iteratorError6;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
files.set(relativeFilePath, nextData);
|
||||
changedFiles.set(relativeFilePath, nextData);
|
||||
}
|
||||
for (const directory of directoryFilters) {
|
||||
for (const extension of extensions) {
|
||||
glob.push(`${directory}/**/*.${extension}`);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError5 = true;
|
||||
_iteratorError5 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion5 && _iterator5.return != null) {
|
||||
_iterator5.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError5) {
|
||||
throw _iteratorError5;
|
||||
}
|
||||
} else {
|
||||
for (const extension of extensions) {
|
||||
glob.push(`**/*.${extension}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.files = files;
|
||||
return {
|
||||
changedFiles: isFresh ? undefined : changedFiles,
|
||||
hasteMap: data,
|
||||
removedFiles
|
||||
};
|
||||
});
|
||||
const relativeRoot = fastPath().relative(rootDir, root);
|
||||
const query = clocks.has(relativeRoot) // Use the `since` generator if we have a clock available
|
||||
? {
|
||||
expression,
|
||||
fields,
|
||||
since: clocks.get(relativeRoot)
|
||||
} // Otherwise use the `glob` filter
|
||||
: {
|
||||
expression,
|
||||
fields,
|
||||
glob,
|
||||
glob_includedotfiles: true
|
||||
};
|
||||
const response = await cmd('query', root, query);
|
||||
|
||||
function watchmanCrawl(_x) {
|
||||
return _watchmanCrawl.apply(this, arguments);
|
||||
if ('warning' in response) {
|
||||
console.warn('watchman warning: ', response.warning);
|
||||
}
|
||||
|
||||
isFresh = isFresh || response.is_fresh_instance;
|
||||
files.set(root, response);
|
||||
}
|
||||
)
|
||||
);
|
||||
return {
|
||||
files,
|
||||
isFresh
|
||||
};
|
||||
}
|
||||
|
||||
let files = data.files;
|
||||
let removedFiles = new Map();
|
||||
const changedFiles = new Map();
|
||||
let watchmanFiles;
|
||||
let isFresh = false;
|
||||
|
||||
try {
|
||||
const watchmanRoots = await getWatchmanRoots(roots);
|
||||
const watchmanFileResults = await queryWatchmanForDirs(watchmanRoots); // Reset the file map if watchman was restarted and sends us a list of
|
||||
// files.
|
||||
|
||||
if (watchmanFileResults.isFresh) {
|
||||
files = new Map();
|
||||
removedFiles = new Map(data.files);
|
||||
isFresh = true;
|
||||
}
|
||||
|
||||
return watchmanCrawl;
|
||||
})();
|
||||
watchmanFiles = watchmanFileResults.files;
|
||||
} finally {
|
||||
client.end();
|
||||
}
|
||||
|
||||
if (clientError) {
|
||||
throw clientError;
|
||||
} // TODO: remove non-null
|
||||
|
||||
for (const [watchRoot, response] of watchmanFiles) {
|
||||
const fsRoot = (0, _normalizePathSep().default)(watchRoot);
|
||||
const relativeFsRoot = fastPath().relative(rootDir, fsRoot);
|
||||
clocks.set(relativeFsRoot, response.clock);
|
||||
|
||||
for (const fileData of response.files) {
|
||||
const filePath =
|
||||
fsRoot + path().sep + (0, _normalizePathSep().default)(fileData.name);
|
||||
const relativeFilePath = fastPath().relative(rootDir, filePath);
|
||||
const existingFileData = data.files.get(relativeFilePath); // If watchman is fresh, the removed files map starts with all files
|
||||
// and we remove them as we verify they still exist.
|
||||
|
||||
if (isFresh && existingFileData && fileData.exists) {
|
||||
removedFiles.delete(relativeFilePath);
|
||||
}
|
||||
|
||||
if (!fileData.exists) {
|
||||
// No need to act on files that do not exist and were not tracked.
|
||||
if (existingFileData) {
|
||||
files.delete(relativeFilePath); // If watchman is not fresh, we will know what specific files were
|
||||
// deleted since we last ran and can track only those files.
|
||||
|
||||
if (!isFresh) {
|
||||
removedFiles.set(relativeFilePath, existingFileData);
|
||||
}
|
||||
}
|
||||
} else if (!ignore(filePath)) {
|
||||
const mtime =
|
||||
typeof fileData.mtime_ms === 'number'
|
||||
? fileData.mtime_ms
|
||||
: fileData.mtime_ms.toNumber();
|
||||
const size = fileData.size;
|
||||
let sha1hex = fileData['content.sha1hex'];
|
||||
|
||||
if (typeof sha1hex !== 'string' || sha1hex.length !== 40) {
|
||||
sha1hex = null;
|
||||
}
|
||||
|
||||
let nextData;
|
||||
|
||||
if (
|
||||
existingFileData &&
|
||||
existingFileData[_constants().default.MTIME] === mtime
|
||||
) {
|
||||
nextData = existingFileData;
|
||||
} else if (
|
||||
existingFileData &&
|
||||
sha1hex &&
|
||||
existingFileData[_constants().default.SHA1] === sha1hex
|
||||
) {
|
||||
nextData = [
|
||||
existingFileData[0],
|
||||
mtime,
|
||||
existingFileData[2],
|
||||
existingFileData[3],
|
||||
existingFileData[4],
|
||||
existingFileData[5]
|
||||
];
|
||||
} else {
|
||||
// See ../constants.ts
|
||||
nextData = ['', mtime, size, 0, '', sha1hex];
|
||||
}
|
||||
|
||||
files.set(relativeFilePath, nextData);
|
||||
changedFiles.set(relativeFilePath, nextData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data.files = files;
|
||||
return {
|
||||
changedFiles: isFresh ? undefined : changedFiles,
|
||||
hasteMap: data,
|
||||
removedFiles
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user