This commit is contained in:
lalBi94
2023-03-05 13:23:23 +01:00
commit 7bc56c09b5
14034 changed files with 1834369 additions and 0 deletions

102
node_modules/caching-transform/index.js generated vendored Normal file
View File

@@ -0,0 +1,102 @@
'use strict';
const fs = require('fs');
const path = require('path');
const hasha = require('hasha');
const makeDir = require('make-dir');
const writeFileAtomic = require('write-file-atomic');
const packageHash = require('package-hash');
let ownHash = '';
function getOwnHash() {
ownHash = packageHash.sync(path.join(__dirname, 'package.json'));
return ownHash;
}
function wrap(opts) {
if (!(opts.factory || opts.transform) || (opts.factory && opts.transform)) {
throw new Error('Specify factory or transform but not both');
}
if (typeof opts.cacheDir !== 'string' && !opts.disableCache) {
throw new Error('cacheDir must be a string');
}
opts = {
ext: '',
salt: '',
hashData: () => [],
filenamePrefix: () => '',
onHash: () => {},
...opts
};
let transformFn = opts.transform;
const {factory, cacheDir, shouldTransform, disableCache, hashData, onHash, filenamePrefix, ext, salt} = opts;
const cacheDirCreated = opts.createCacheDir === false;
let created = transformFn && cacheDirCreated;
const encoding = opts.encoding === 'buffer' ? undefined : opts.encoding || 'utf8';
function transform(input, metadata, hash) {
if (!created) {
if (!cacheDirCreated && !disableCache) {
makeDir.sync(cacheDir);
}
if (!transformFn) {
transformFn = factory(cacheDir);
}
created = true;
}
return transformFn(input, metadata, hash);
}
return function (input, metadata) {
if (shouldTransform && !shouldTransform(input, metadata)) {
return input;
}
if (disableCache) {
return transform(input, metadata);
}
const data = [
ownHash || getOwnHash(),
input,
salt,
...[].concat(hashData(input, metadata))
];
const hash = hasha(data, {algorithm: 'sha256'});
const cachedPath = path.join(cacheDir, filenamePrefix(metadata) + hash + ext);
onHash(input, metadata, hash);
let result;
let retry = 0;
/* eslint-disable-next-line no-constant-condition */
while (true) {
try {
return fs.readFileSync(cachedPath, encoding);
} catch (readError) {
if (!result) {
result = transform(input, metadata, hash);
}
try {
writeFileAtomic.sync(cachedPath, result, {encoding});
return result;
} catch (error) {
/* Likely https://github.com/npm/write-file-atomic/issues/28
* Make up to 3 attempts to read or write the cache. */
retry++;
if (retry > 3) {
throw error;
}
}
}
}
};
}
module.exports = wrap;

21
node_modules/caching-transform/license generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) James Talmage <james@talmage.io> (github.com/jamestalmage)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,66 @@
/// <reference types="node"/>
import * as fs from 'fs';
declare namespace makeDir {
interface Options {
/**
Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
@default 0o777
*/
readonly mode?: number;
/**
Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
Using a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function.
@default require('fs')
*/
readonly fs?: typeof fs;
}
}
declare const makeDir: {
/**
Make a directory and its parents if needed - Think `mkdir -p`.
@param path - Directory to create.
@returns The path to the created directory.
@example
```
import makeDir = require('make-dir');
(async () => {
const path = await makeDir('unicorn/rainbow/cake');
console.log(path);
//=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
// Multiple directories:
const paths = await Promise.all([
makeDir('unicorn/rainbow'),
makeDir('foo/bar')
]);
console.log(paths);
// [
// '/Users/sindresorhus/fun/unicorn/rainbow',
// '/Users/sindresorhus/fun/foo/bar'
// ]
})();
```
*/
(path: string, options?: makeDir.Options): Promise<string>;
/**
Synchronously make a directory and its parents if needed - Think `mkdir -p`.
@param path - Directory to create.
@returns The path to the created directory.
*/
sync(path: string, options?: makeDir.Options): string;
};
export = makeDir;

View File

@@ -0,0 +1,156 @@
'use strict';
const fs = require('fs');
const path = require('path');
const {promisify} = require('util');
const semver = require('semver');
const useNativeRecursiveOption = semver.satisfies(process.version, '>=10.12.0');
// https://github.com/nodejs/node/issues/8987
// https://github.com/libuv/libuv/pull/1088
const checkPath = pth => {
if (process.platform === 'win32') {
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''));
if (pathHasInvalidWinCharacters) {
const error = new Error(`Path contains invalid characters: ${pth}`);
error.code = 'EINVAL';
throw error;
}
}
};
const processOptions = options => {
// https://github.com/sindresorhus/make-dir/issues/18
const defaults = {
mode: 0o777,
fs
};
return {
...defaults,
...options
};
};
const permissionError = pth => {
// This replicates the exception of `fs.mkdir` with native the
// `recusive` option when run on an invalid drive under Windows.
const error = new Error(`operation not permitted, mkdir '${pth}'`);
error.code = 'EPERM';
error.errno = -4048;
error.path = pth;
error.syscall = 'mkdir';
return error;
};
const makeDir = async (input, options) => {
checkPath(input);
options = processOptions(options);
const mkdir = promisify(options.fs.mkdir);
const stat = promisify(options.fs.stat);
if (useNativeRecursiveOption && options.fs.mkdir === fs.mkdir) {
const pth = path.resolve(input);
await mkdir(pth, {
mode: options.mode,
recursive: true
});
return pth;
}
const make = async pth => {
try {
await mkdir(pth, options.mode);
return pth;
} catch (error) {
if (error.code === 'EPERM') {
throw error;
}
if (error.code === 'ENOENT') {
if (path.dirname(pth) === pth) {
throw permissionError(pth);
}
if (error.message.includes('null bytes')) {
throw error;
}
await make(path.dirname(pth));
return make(pth);
}
try {
const stats = await stat(pth);
if (!stats.isDirectory()) {
throw new Error('The path is not a directory');
}
} catch (_) {
throw error;
}
return pth;
}
};
return make(path.resolve(input));
};
module.exports = makeDir;
module.exports.sync = (input, options) => {
checkPath(input);
options = processOptions(options);
if (useNativeRecursiveOption && options.fs.mkdirSync === fs.mkdirSync) {
const pth = path.resolve(input);
fs.mkdirSync(pth, {
mode: options.mode,
recursive: true
});
return pth;
}
const make = pth => {
try {
options.fs.mkdirSync(pth, options.mode);
} catch (error) {
if (error.code === 'EPERM') {
throw error;
}
if (error.code === 'ENOENT') {
if (path.dirname(pth) === pth) {
throw permissionError(pth);
}
if (error.message.includes('null bytes')) {
throw error;
}
make(path.dirname(pth));
return make(pth);
}
try {
if (!options.fs.statSync(pth).isDirectory()) {
throw new Error('The path is not a directory');
}
} catch (_) {
throw error;
}
}
return pth;
};
return make(path.resolve(input));
};

View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -0,0 +1,59 @@
{
"name": "make-dir",
"version": "3.1.0",
"description": "Make a directory and its parents if needed - Think `mkdir -p`",
"license": "MIT",
"repository": "sindresorhus/make-dir",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && nyc ava && tsd"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"mkdir",
"mkdirp",
"make",
"directories",
"dir",
"dirs",
"folders",
"directory",
"folder",
"path",
"parent",
"parents",
"intermediate",
"recursively",
"recursive",
"create",
"fs",
"filesystem",
"file-system"
],
"dependencies": {
"semver": "^6.0.0"
},
"devDependencies": {
"@types/graceful-fs": "^4.1.3",
"@types/node": "^13.7.1",
"ava": "^1.4.0",
"codecov": "^3.2.0",
"graceful-fs": "^4.1.15",
"nyc": "^15.0.0",
"path-type": "^4.0.0",
"tempy": "^0.2.1",
"tsd": "^0.11.0",
"xo": "^0.25.4"
}
}

View File

@@ -0,0 +1,125 @@
# make-dir [![Build Status](https://travis-ci.org/sindresorhus/make-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/make-dir) [![codecov](https://codecov.io/gh/sindresorhus/make-dir/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/make-dir)
> Make a directory and its parents if needed - Think `mkdir -p`
## Advantages over [`mkdirp`](https://github.com/substack/node-mkdirp)
- Promise API *(Async/await ready!)*
- Fixes many `mkdirp` issues: [#96](https://github.com/substack/node-mkdirp/pull/96) [#70](https://github.com/substack/node-mkdirp/issues/70) [#66](https://github.com/substack/node-mkdirp/issues/66)
- 100% test coverage
- CI-tested on macOS, Linux, and Windows
- Actively maintained
- Doesn't bundle a CLI
- Uses the native `fs.mkdir/mkdirSync` [`recursive` option](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_mkdir_path_options_callback) in Node.js >=10.12.0 unless [overridden](#fs)
## Install
```
$ npm install make-dir
```
## Usage
```
$ pwd
/Users/sindresorhus/fun
$ tree
.
```
```js
const makeDir = require('make-dir');
(async () => {
const path = await makeDir('unicorn/rainbow/cake');
console.log(path);
//=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
})();
```
```
$ tree
.
└── unicorn
└── rainbow
└── cake
```
Multiple directories:
```js
const makeDir = require('make-dir');
(async () => {
const paths = await Promise.all([
makeDir('unicorn/rainbow'),
makeDir('foo/bar')
]);
console.log(paths);
/*
[
'/Users/sindresorhus/fun/unicorn/rainbow',
'/Users/sindresorhus/fun/foo/bar'
]
*/
})();
```
## API
### makeDir(path, options?)
Returns a `Promise` for the path to the created directory.
### makeDir.sync(path, options?)
Returns the path to the created directory.
#### path
Type: `string`
Directory to create.
#### options
Type: `object`
##### mode
Type: `integer`\
Default: `0o777`
Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
##### fs
Type: `object`\
Default: `require('fs')`
Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
Using a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function.
## Related
- [make-dir-cli](https://github.com/sindresorhus/make-dir-cli) - CLI for this module
- [del](https://github.com/sindresorhus/del) - Delete files and directories
- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching
- [cpy](https://github.com/sindresorhus/cpy) - Copy files
- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line
- [move-file](https://github.com/sindresorhus/move-file) - Move a file
---
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-make-dir?utm_source=npm-make-dir&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>

46
node_modules/caching-transform/package.json generated vendored Normal file
View File

@@ -0,0 +1,46 @@
{
"name": "caching-transform",
"version": "4.0.0",
"description": "Wraps a transform and provides caching",
"license": "MIT",
"repository": "istanbuljs/caching-transform",
"engines": {
"node": ">=8"
},
"scripts": {
"test": "xo && nyc ava"
},
"files": [
"index.js"
],
"keywords": [
"transform",
"cache",
"require",
"transpile",
"fast",
"speed",
"hash"
],
"dependencies": {
"hasha": "^5.0.0",
"make-dir": "^3.0.0",
"package-hash": "^4.0.0",
"write-file-atomic": "^3.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"coveralls": "^3.0.3",
"nyc": "^14.1.0",
"proxyquire": "^2.1.0",
"rimraf": "^2.6.3",
"sinon": "^7.3.2",
"xo": "^0.24.0"
},
"nyc": {
"reporter": [
"lcov",
"text"
]
}
}

163
node_modules/caching-transform/readme.md generated vendored Normal file
View File

@@ -0,0 +1,163 @@
# caching-transform [![Build Status](https://travis-ci.org/istanbuljs/caching-transform.svg?branch=master)](https://travis-ci.org/istanbuljs/caching-transform) [![Coverage Status](https://coveralls.io/repos/github/istanbuljs/caching-transform/badge.svg?branch=master)](https://coveralls.io/github/istanbuljs/caching-transform?branch=master)
> Wraps a transform and provides caching.
Caching transform results can greatly improve performance. `nyc` saw [dramatic performance increases](https://github.com/bcoe/nyc/pull/101#issuecomment-165716069) when we implemented caching.
## Install
```
$ npm install caching-transform
```
## Usage
```js
const cachingTransform = require('caching-transform');
const transform = cachingTransform({
cacheDir: '/path/to/cache/directory',
salt: 'hash-salt',
transform: (input, metadata, hash) => {
// ... Expensive operations ...
return transformedResult;
}
});
transform('some input for transpilation')
// => fetch from the cache,
// or run the transform and save to the cache if not found there
```
## API
### cachingTransform(options)
Returns a transform callback that takes two arguments:
- `input` a string to be transformed
- `metadata` an arbitrary data object
Both arguments are passed to the wrapped transform. Results are cached in the cache directory using an `sha256` hash of `input` and an optional `salt` value. If a cache entry already exist for `input`, the wrapped transform function will never be called.
#### options
##### salt
Type: `string` `Buffer`<br>
Default: `''`
A value that uniquely identifies your transform:
```js
const pkg = require('my-transform/package.json');
const salt = pkg.name + ':' + pkg.version;
```
Including the version in the salt ensures existing cache entries will be automatically invalidated when you bump the version of your transform. If your transform relies on additional dependencies, and the transform output might change as those dependencies update, then your salt should incorporate the versions of those dependencies as well.
##### transform
Type: `Function(input: string|Buffer, metadata: *, hash: string): string|Buffer`
- `input`: The value to be transformed. It is passed through from the wrapper.
- `metadata`: An arbitrary data object passed through from the wrapper. A typical value might be a string filename.
- `hash`: The salted hash of `input`. Useful if you intend to create additional cache entries beyond the transform result (i.e. `nyc` also creates cache entries for source-map data). This value is not available if the cache is disabled, if you still need it, the default can be computed via [`hasha([input, salt])`](https://www.npmjs.com/package/hasha).
The transform function will return a `string` (or Buffer if `encoding === 'buffer'`) containing the result of transforming `input`.
##### factory
Type: `Function(cacheDir: string): transformFunction`
If the `transform` function is expensive to create, and it is reasonable to expect that it may never be called during the life of the process, you may supply a `factory` function that will be used to create the `transform` function the first time it is needed.
A typical usage would be to prevent eagerly `require`ing expensive dependencies like Babel:
```js
function factory() {
// Using the factory function, you can avoid loading Babel until you are sure it is needed.
const babel = require('babel-core');
return (code, metadata) => {
return babel.transform(code, {filename: metadata.filename, plugins: [/* ... */]});
};
}
```
##### cacheDir
*Required unless caching is disabled*<br>
Type: `string`
The directory where cached transform results will be stored. The directory is automatically created with [`mkdirp`](https://www.npmjs.com/package/mkdirp). You can set `options.createCacheDir = false` if you are certain the directory already exists.
##### ext
Type: `string`<br>
Default: `''`
An extension that will be appended to the salted hash to create the filename inside your cache directory. It is not required, but recommended if you know the file type. Appending the extension allows you to easily inspect the contents of the cache directory with your file browser.
##### shouldTransform
Type: `Function(input: string|Buffer, additionalData: *)`<br>
Default: Always transform
A function that examines `input` and `metadata` to determine whether the transform should be applied. Returning `false` means the transform will not be applied and `input` will be returned unmodified.
##### disableCache
Type: `boolean`<br>
Default: `false`
If `true`, the cache is ignored and the transform is used every time regardless of cache contents.
##### hashData
Type: `Function(input: string|Buffer, metadata: *): string|Buffer|Array[string|Buffer]`
Provide additional data that should be included in the hash.
One potential use is including the `metadata` in the hash by coercing it to a hashable string or buffer:
```js
function hashData(input, metadata) {
return JSON.stringify(metadata);
}
```
(Note that `metadata` is not taken into account otherwise.)
##### filenamePrefix
Type: `Function(metadata: *): string`
Provide a filename to prefix the cache entry. The return value may not contain any path separators.
```js
function filenamePrefix(metadata) {
return path.parse(metadata.filename || '').name + '-';
}
```
##### onHash
Type: `Function(input: string|Buffer, metadata: *, hash: string)`
Function that is called after input is hashed.
##### encoding
Type: `string`<br>
Default: `'utf8'`
The encoding to use when writing to / reading from the filesystem. If set it to `buffer`, then buffers will be returned from the cache instead of strings.
## License
MIT © [James Talmage](https://github.com/jamestalmage)