This commit is contained in:
tatianamac
2019-11-26 14:50:43 -08:00
parent 8a55660ed0
commit 6d5445ecc5
13894 changed files with 2233957 additions and 0 deletions

13
node_modules/filing-cabinet/.eslintrc generated vendored Normal file
View File

@ -0,0 +1,13 @@
{
"rules": {
"no-undef": 2,
"no-unused-vars": 2,
"no-const-assign": 2
},
"env": {
"node": true
},
"parserOptions": {
"ecmaVersion": 2015
}
}

34
node_modules/filing-cabinet/bin/cli.js generated vendored Executable file
View File

@ -0,0 +1,34 @@
#!/usr/bin/env node
'use strict';
var program = require('commander');
var cabinet = require('../');
program
.version(require('../package.json').version)
.usage('[options] <path>')
.option('-d, --directory <path>', 'root of all files')
.option('-c, --config [path]', 'location of a RequireJS config file for AMD')
.option('-w, --webpack-config [path]', 'location of a webpack config file')
.option('-t, --ts-config [path]', 'location of a typescript config file')
.option('-f, --filename [path]', 'file containing the dependency')
.parse(process.argv);
var filename = program.filename;
var directory = program.directory;
var config = program.config;
var webpackConfig = program.webpackConfig;
var tsConfig = program.tsConfig;
var dep = program.args[0];
var result = cabinet({
partial: dep,
filename: filename,
directory: directory,
config: config,
webpackConfig: webpackConfig,
tsConfig: tsConfig
});
console.log(result);

346
node_modules/filing-cabinet/index.js generated vendored Normal file
View File

@ -0,0 +1,346 @@
'use strict';
const path = require('path');
const debug = require('debug')('cabinet');
const fs = require('fs');
/*
* most js resolver are lazy-loaded (only required when needed)
* e.g. dont load requirejs when we only have commonjs modules to resolve
* this makes testing your code using this lib much easier
*/
let getModuleType;
let resolve;
let amdLookup;
const stylusLookup = require('stylus-lookup');
const sassLookup = require('sass-lookup');
let ts;
let resolveDependencyPath;
const appModulePath = require('app-module-path');
let webpackResolve;
const isRelative = require('is-relative-path');
const defaultLookups = {
'.js': jsLookup,
'.jsx': jsLookup,
'.ts': tsLookup,
'.tsx': tsLookup,
'.scss': sassLookup,
'.sass': sassLookup,
'.styl': stylusLookup,
// Less and Sass imports are very similar
'.less': sassLookup
};
/**
* @param {Object} options
* @param {String} options.partial The dependency being looked up
* @param {String} options.filename The file that contains the dependency being looked up
* @param {String|Object} [options.config] Path to a requirejs config
* @param {String} [options.configPath] For AMD resolution, if the config is an object, this represents the location of the config file.
* @param {Object} [options.nodeModulesConfig] Config for overriding the entry point defined in a package json file
* @param {String} [options.nodeModulesConfig.entry] The new value for "main" in package json
* @param {String} [options.webpackConfig] Path to the webpack config
* @param {Object} [options.ast] A preparsed AST for the file identified by filename.
* @param {Object} [options.tsConfig] Path to a typescript config file
*/
module.exports = function cabinet(options) {
const {
partial,
filename,
} = options;
debug('Given filename: ' + filename);
const ext = path.extname(filename);
debug('which has the extension: ' + ext);
let resolver = defaultLookups[ext];
if (!resolver) {
debug('using generic resolver');
if (!resolveDependencyPath) {
resolveDependencyPath = require('resolve-dependency-path');
}
resolver = resolveDependencyPath;
}
debug(`found a resolver for ${ext}`);
options.dependency = partial;
const result = resolver(options);
debug(`resolved path for ${partial}: ${result}`);
return result;
};
module.exports.supportedFileExtensions = Object.keys(defaultLookups);
/**
* Register a custom lookup resolver for a file extension
*
* @param {String} extension - The file extension that should use the resolver
* @param {Function} lookupStrategy - A resolver of partial paths
*/
module.exports.register = function(extension, lookupStrategy) {
defaultLookups[extension] = lookupStrategy;
if (!this.supportedFileExtensions.includes(extension)) {
this.supportedFileExtensions.push(extension);
}
};
/**
* Exposed for testing
*
* @param {Object} options
* @param {String} options.config
* @param {String} options.webpackConfig
* @param {String} options.filename
* @param {Object} options.ast
* @return {String}
*/
module.exports._getJSType = function(options = {}) {
if (!getModuleType) {
getModuleType = require('module-definition');
}
if (options.config) {
return 'amd';
}
if (options.webpackConfig) {
return 'webpack';
}
if (options.ast) {
debug('reusing the given ast');
return getModuleType.fromSource(options.ast);
}
debug('using the filename to find the module type');
return getModuleType.sync(options.filename);
};
/**
* @private
* @param {Object} options
* @param {String} options.dependency
* @param {String} options.filename
* @param {String} options.directory
* @param {String} [options.config]
* @param {String} [options.webpackConfig]
* @param {String} [options.configPath]
* @param {Object} [options.nodeModulesConfig]
* @param {Object} [options.ast]
* @return {String}
*/
function jsLookup({dependency, filename, directory, config, webpackConfig, configPath, nodeModulesConfig, ast}) {
const type = module.exports._getJSType({
config: config,
webpackConfig: webpackConfig,
filename: filename,
ast: ast
});
switch (type) {
case 'amd':
debug('using amd resolver');
if (!amdLookup) {
amdLookup = require('module-lookup-amd');
}
return amdLookup({
config: config,
// Optional in case a pre-parsed config is being passed in
configPath: configPath,
partial: dependency,
directory: directory,
filename: filename
});
case 'commonjs':
debug('using commonjs resolver');
return commonJSLookup({dependency, filename, directory, nodeModulesConfig});
case 'webpack':
debug('using webpack resolver for es6');
return resolveWebpackPath({dependency, filename, directory, webpackConfig});
case 'es6':
default:
debug('using commonjs resolver for es6');
return commonJSLookup({dependency, filename, directory, nodeModulesConfig});
}
}
function tsLookup({dependency, filename, tsConfig}) {
debug('performing a typescript lookup');
const defaultTsConfig = {
compilerOptions: {}
};
if (!ts) {
ts = require('typescript');
}
debug('given typescript config: ', tsConfig);
if (!tsConfig) {
tsConfig = defaultTsConfig;
debug('no tsconfig given, defaulting');
} else if (typeof tsConfig === 'string') {
debug('string tsconfig given, parsing');
try {
tsConfig = JSON.parse(fs.readFileSync(tsConfig, 'utf8'));
debug('successfully parsed tsconfig');
} catch (e) {
debug('could not parse tsconfig');
throw new Error('could not read tsconfig');
}
}
debug('processed typescript config: ', tsConfig);
debug('processed typescript config type: ', typeof tsConfig);
const {options} = ts.convertCompilerOptionsFromJson(tsConfig.compilerOptions);
// Preserve for backcompat. Consider removing this as a breaking change.
if (!options.module) {
options.module = ts.ModuleKind.AMD;
}
const host = ts.createCompilerHost({});
debug('with options: ', options);
const namedModule = ts.resolveModuleName(dependency, filename, options, host);
let result = '';
if (namedModule.resolvedModule) {
result = namedModule.resolvedModule.resolvedFileName;
} else {
const suffix = '.d.ts';
const lookUpLocations = namedModule.failedLookupLocations
.filter((string) => string.endsWith(suffix))
.map((string) => string.substr(0, string.length - suffix.length));
result = lookUpLocations.find(ts.sys.fileExists) || '';
}
debug('result: ' + result);
return result ? path.resolve(result) : '';
}
function commonJSLookup({dependency, filename, directory, nodeModulesConfig}) {
if (!resolve) {
resolve = require('resolve');
}
if (!dependency) {
debug('blank dependency given. Returning early.');
return '';
}
// Need to resolve partials within the directory of the module, not filing-cabinet
const moduleLookupDir = path.join(directory, 'node_modules');
debug('adding ' + moduleLookupDir + ' to the require resolution paths');
appModulePath.addPath(moduleLookupDir);
// Make sure the partial is being resolved to the filename's context
// 3rd party modules will not be relative
if (dependency[0] === '.') {
dependency = path.resolve(path.dirname(filename), dependency);
}
let result = '';
// Allows us to configure what is used as the "main" entry point
function packageFilter(packageJson) {
packageJson.main = packageJson[nodeModulesConfig.entry] ? packageJson[nodeModulesConfig.entry] : packageJson.main;
return packageJson;
}
try {
result = resolve.sync(dependency, {
extensions: ['.js', '.jsx'],
basedir: directory,
packageFilter: nodeModulesConfig && nodeModulesConfig.entry ? packageFilter : undefined,
// Add fileDir to resolve index.js files in that dir
moduleDirectory: ['node_modules', directory]
});
debug('resolved path: ' + result);
} catch (e) {
debug('could not resolve ' + dependency);
}
return result;
}
function resolveWebpackPath({dependency, filename, directory, webpackConfig}) {
if (!webpackResolve) {
webpackResolve = require('enhanced-resolve');
}
webpackConfig = path.resolve(webpackConfig);
let loadedConfig;
try {
loadedConfig = require(webpackConfig);
if (typeof loadedConfig === 'function') {
loadedConfig = loadedConfig();
}
} catch (e) {
debug('error loading the webpack config at ' + webpackConfig);
debug(e.message);
debug(e.stack);
return '';
}
const resolveConfig = Object.assign({}, loadedConfig.resolve);
if (!resolveConfig.modules && (resolveConfig.root || resolveConfig.modulesDirectories)) {
resolveConfig.modules = [];
if (resolveConfig.root) {
resolveConfig.modules = resolveConfig.modules.concat(resolveConfig.root);
}
if (resolveConfig.modulesDirectories) {
resolveConfig.modules = resolveConfig.modules.concat(resolveConfig.modulesDirectories);
}
}
try {
const resolver = webpackResolve.create.sync(resolveConfig);
// We don't care about what the loader resolves the dependency to
// we only wnat the path of the resolved file
dependency = stripLoader(dependency);
const lookupPath = isRelative(dependency) ? path.dirname(filename) : directory;
return resolver(lookupPath, dependency);
} catch (e) {
debug('error when resolving ' + dependency);
debug(e.message);
debug(e.stack);
return '';
}
}
function stripLoader(dependency) {
const exclamationLocation = dependency.indexOf('!');
if (exclamationLocation === -1) { return dependency; }
return dependency.slice(exclamationLocation + 1);
}

92
node_modules/filing-cabinet/package.json generated vendored Normal file
View File

@ -0,0 +1,92 @@
{
"_args": [
[
"filing-cabinet@2.3.3",
"/Users/tatiana/selfdefined"
]
],
"_from": "filing-cabinet@2.3.3",
"_id": "filing-cabinet@2.3.3",
"_inBundle": false,
"_integrity": "sha512-Lp9FNBm74UnZI/0tVcH8WlJZmnYf9/qImt1/VUaEj3rlBl+V7M5yVAzYPJ7X1T2WxQeCrSQN4jN64SlQa6Rbew==",
"_location": "/filing-cabinet",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "filing-cabinet@2.3.3",
"name": "filing-cabinet",
"escapedName": "filing-cabinet",
"rawSpec": "2.3.3",
"saveSpec": null,
"fetchSpec": "2.3.3"
},
"_requiredBy": [
"/dependency-tree"
],
"_resolved": "https://registry.npmjs.org/filing-cabinet/-/filing-cabinet-2.3.3.tgz",
"_spec": "2.3.3",
"_where": "/Users/tatiana/selfdefined",
"author": {
"name": "Joel Kemp",
"email": "joel@mrjoelkemp.com",
"url": "http://www.mrjoelkemp.com/"
},
"bin": {
"filing-cabinet": "bin/cli.js"
},
"bugs": {
"url": "https://github.com/mrjoelkemp/node-filing-cabinet/issues"
},
"dependencies": {
"app-module-path": "^2.2.0",
"commander": "^2.13.0",
"debug": "^4.1.1",
"enhanced-resolve": "^4.1.0",
"is-relative-path": "^1.0.2",
"module-definition": "^3.0.0",
"module-lookup-amd": "^6.1.0",
"resolve": "^1.11.1",
"resolve-dependency-path": "^2.0.0",
"sass-lookup": "^3.0.0",
"stylus-lookup": "^3.0.1",
"typescript": "^3.0.3"
},
"description": "Find files based on partial paths",
"devDependencies": {
"eslint": "^5.11.0",
"jscs": "^3.0.7",
"jscs-preset-mrjoelkemp": "^2.0.0",
"mocha": "^5.0.0",
"mock-fs": "^4.4.2",
"rewire": "^4.0.1",
"sinon": "^7.2.2"
},
"engines": {
"node": ">=6.0.0"
},
"homepage": "https://github.com/mrjoelkemp/node-filing-cabinet",
"keywords": [
"lookup",
"es6",
"amd",
"commonjs",
"sass",
"less",
"stylus",
"partial",
"resolution",
"paths"
],
"license": "MIT",
"main": "index.js",
"name": "filing-cabinet",
"repository": {
"type": "git",
"url": "git+https://github.com/mrjoelkemp/node-filing-cabinet.git"
},
"scripts": {
"test": "jscs index.js test/test.js && eslint index.js test/test.js && ./node_modules/.bin/mocha test/test.js"
},
"version": "2.3.3"
}

73
node_modules/filing-cabinet/readme.md generated vendored Normal file
View File

@ -0,0 +1,73 @@
### filing-cabinet [![npm](http://img.shields.io/npm/v/filing-cabinet.svg)](https://npmjs.org/package/filing-cabinet) [![npm](http://img.shields.io/npm/dm/filing-cabinet.svg)](https://npmjs.org/package/filing-cabinet)
> Get the file associated with a dependency/partial's path
`npm install --save filing-cabinet`
### Usage
```js
var cabinet = require('filing-cabinet');
var result = cabinet({
partial: 'somePartialPath',
directory: 'path/to/all/files',
filename: 'path/to/parent/file',
ast: {}, // an optional AST representation of `filename`
// Only for JavaScript files
config: 'path/to/requirejs/config',
webpackConfig: 'path/to/webpack/config',
nodeModulesConfig: {
entry: 'module'
},
tsConfig: 'path/to/typescript/config'
});
console.log(result); // /absolute/path/to/somePartialPath
```
* `partial`: the dependency path
* This could be in any of the registered languages
* `directory`: the path to all files
* `filename`: the path to the file containing the `partial`
* `ast`: (optional) the parsed AST for `filename`.
* Useful optimization for avoiding a parse of filename
* `config`: (optional) requirejs config for resolving aliased JavaScript modules
* `webpackConfig`: (optional) webpack config for resolving aliased JavaScript modules
* `nodeModulesConfig`: (optional) config for resolving entry file for node_modules. This value overrides the `main` attribute in the package.json file; used in conjunction with the [packageFilter](https://github.com/browserify/resolve#resolveid-opts-cb) of the `resolve` package.
* `tsConfig`: (optional) path to a typescript configuration. Could also be an object representing a pre-parsed typescript config.
### Registered languages
By default, filing-cabinet provides support for the following languages:
* JavaScript: CommonJS, AMD, ES6
* TypeScript
* CSS Preprocessors: Sass (`.scss` and `.sass`), Stylus (`.styl`), and Less (`.less`)
You can register resolvers for new languages via `cabinet.register(extension, resolver)`.
* `extension`: the extension of the file that should use the custom resolver (ex: '.py', '.php')
* `resolver`: a function that accepts the following (ordered) arguments that were given to cabinet:
* `partial`
* `filename`
* `directory`
* `config`
For examples of resolver implementations, take a look at the default language resolvers:
* [sass-lookup](https://github.com/mrjoelkemp/node-sass-lookup)
* [stylus-lookup](https://github.com/mrjoelkemp/node-stylus-lookup)
* [amdLookup](https://github.com/mrjoelkemp/node-module-lookup-amd)
If a given extension does not have a registered resolver, cabinet will use
a generic file resolver which is basically `require('path').join` with a bit of extension defaulting logic.
### Shell script
* Requires a global install `npm install -g filing-cabinet`
`filing-cabinet [options] <dependencyPath>`
* See `filing-cabinet --help` for details on the options

10
node_modules/filing-cabinet/webpack-env.config.js generated vendored Normal file
View File

@ -0,0 +1,10 @@
module.exports = function() {
return {
entry: "./index.js",
resolve: {
alias: {
R: './node_modules/resolve'
}
}
};
};

12
node_modules/filing-cabinet/webpack-root.config.js generated vendored Normal file
View File

@ -0,0 +1,12 @@
var path = require('path');
module.exports = {
entry: "./index.js",
resolve: {
modulesDirectories: ['test/root1', 'node_modules'],
root: [
path.resolve(__dirname, './test/root2'),
path.resolve(__dirname, './node_modules')
]
}
};