first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

21
node_modules/@jest/create-cache-key-function/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Meta Platforms, Inc. and affiliates.
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.

46
node_modules/@jest/create-cache-key-function/README.md generated vendored Normal file
View File

@@ -0,0 +1,46 @@
# jest-create-cache-key-function
This module creates a function which is used for generating cache keys used by code transformers in Jest.
## Install
```sh
$ npm install --save-dev @jest/create-cache-key-function
```
## API
### `createCacheKey(files?: Array<string>, values?: Array<String>, length?: number): GetCacheKeyFunction`
Returns a function that can be used to generate cache keys based on source code of provided files and provided values.
#### Parameters
- `files`: [Optional] Array of absolute paths to files whose code should be accounted for when generating cache key
- `values`: [Optional] Array of string values that should be accounted for when generating cache key
- `length`: [Optional] Length of the resulting key. The default is `32`, or `16` on Windows.
**Note:**
The source code for your test is already taken into account when generating the cache key. The `files` array should be used to provide files that are not directly related to your code such as external configuration files.
## Usage
Here is some sample usage code while creating a new transformer for Jest
```javascript
const createCacheKeyFunction =
require('@jest/create-cache-key-function').default;
const filesToAccountFor = [
__filename,
require.resolve('some-package-name/package.json'),
];
const valuesToAccountFor = [process.env.SOME_LOCAL_ENV, 'Some_Other_Value'];
module.exports = {
process(src, filename, config, options) {},
getCacheKey: createCacheKeyFunction(filesToAccountFor, valuesToAccountFor),
};
```

View File

@@ -0,0 +1,52 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {Config} from '@jest/types';
/**
* Returns a function that can be used to generate cache keys based on source code of provided files and provided values.
*
* @param files - Array of absolute paths to files whose code should be accounted for when generating cache key
* @param values - Array of string values that should be accounted for when generating cache key
* @param length - Length of the resulting key. The default is `32`, or `16` on Windows.
* @returns A function that can be used to generate cache keys.
*/
declare function createCacheKey(
files?: Array<string>,
values?: Array<string>,
length?: number,
): GetCacheKeyFunction;
export default createCacheKey;
declare type GetCacheKeyFunction =
| OldGetCacheKeyFunction
| NewGetCacheKeyFunction;
declare type NewCacheKeyOptions = {
config: Config.ProjectConfig;
configString: string;
instrument: boolean;
};
declare type NewGetCacheKeyFunction = (
sourceText: string,
sourcePath: string,
options: NewCacheKeyOptions,
) => string;
declare type OldCacheKeyOptions = {
config: Config.ProjectConfig;
instrument: boolean;
};
declare type OldGetCacheKeyFunction = (
fileData: string,
filePath: string,
configStr: string,
options: OldCacheKeyOptions,
) => string;
export {};

View File

@@ -0,0 +1,92 @@
'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
exports.default = createCacheKey;
function _crypto() {
const data = require('crypto');
_crypto = function () {
return data;
};
return data;
}
function _fs() {
const data = require('fs');
_fs = function () {
return data;
};
return data;
}
function _path() {
const data = require('path');
_path = function () {
return data;
};
return data;
}
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
// eslint-disable-next-line no-restricted-imports
// Should mirror `import('@jest/transform').TransformOptions`
// Should mirror `import('@jest/transform').Transformer['getCacheKey']`
const {NODE_ENV, BABEL_ENV} = process.env;
function getGlobalCacheKey(files, values, length) {
return [
NODE_ENV,
BABEL_ENV,
...values,
...files.map(file => (0, _fs().readFileSync)(file))
]
.reduce(
(hash, chunk) => hash.update('\0', 'utf8').update(chunk || ''),
(0, _crypto().createHash)('sha1')
)
.digest('hex')
.substring(0, length);
}
function getCacheKeyFunction(globalCacheKey, length) {
return (sourceText, sourcePath, configString, options) => {
// Jest 27 passes a single options bag which contains `configString` rather than as a separate argument.
// We can hide that API difference, though, so this module is usable for both jest@<27 and jest@>=27
const inferredOptions = options || configString;
const {config, instrument} = inferredOptions;
return (0, _crypto().createHash)('sha1')
.update(globalCacheKey)
.update('\0', 'utf8')
.update(sourceText)
.update('\0', 'utf8')
.update(
config.rootDir ? (0, _path().relative)(config.rootDir, sourcePath) : ''
)
.update('\0', 'utf8')
.update(instrument ? 'instrument' : '')
.digest('hex')
.substring(0, length);
};
}
/**
* Returns a function that can be used to generate cache keys based on source code of provided files and provided values.
*
* @param files - Array of absolute paths to files whose code should be accounted for when generating cache key
* @param values - Array of string values that should be accounted for when generating cache key
* @param length - Length of the resulting key. The default is `32`, or `16` on Windows.
* @returns A function that can be used to generate cache keys.
*/
function createCacheKey(
files = [],
values = [],
length = process.platform === 'win32' ? 16 : 32
) {
return getCacheKeyFunction(getGlobalCacheKey(files, values, length), length);
}

View File

@@ -0,0 +1,33 @@
{
"name": "@jest/create-cache-key-function",
"version": "29.7.0",
"repository": {
"type": "git",
"url": "https://github.com/jestjs/jest.git",
"directory": "packages/jest-create-cache-key-function"
},
"dependencies": {
"@jest/types": "^29.6.3"
},
"devDependencies": {
"@types/node": "*",
"jest-util": "^29.7.0"
},
"engines": {
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
},
"license": "MIT",
"main": "./build/index.js",
"types": "./build/index.d.ts",
"exports": {
".": {
"types": "./build/index.d.ts",
"default": "./build/index.js"
},
"./package.json": "./package.json"
},
"publishConfig": {
"access": "public"
},
"gitHead": "4e56991693da7cd4c3730dc3579a1dd1403ee630"
}