@autometa/jest-transformer 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ /dist
2
+ /out
3
+ node_modules
package/.eslintrc.cjs ADDED
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ root: true,
3
+ extends: ["custom"],
4
+ };
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) undefined Ben Aherne
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Introduction
2
+
3
+ There's nothing here yet
@@ -0,0 +1,26 @@
1
+ // src/index.ts
2
+ import crypto from "crypto";
3
+ import { transform } from "@babel/core";
4
+ var canInstrument;
5
+ var getCacheKey = (fileData, filename, _configString, instrument) => crypto.createHash("md5").update("\0", "utf8").update(fileData).update("\0", "utf8").update(filename).update("\0", "utf8").update("\0", "utf8").update("\0", "utf8").update(instrument ? "instrument" : "").digest("hex");
6
+ var src_default = {
7
+ getCacheKey,
8
+ process: (_src, filePath, jestConfig) => {
9
+ const windowsFix = filePath.replace(/\\/g, "/");
10
+ const testFile = `
11
+ const { Feature } = require('autometa-runner');
12
+ Feature('${windowsFix}')
13
+ `;
14
+ const featureFile = transform(testFile, {
15
+ filename: windowsFix,
16
+ root: jestConfig.cwd
17
+ });
18
+ return featureFile;
19
+ }
20
+ };
21
+ export {
22
+ canInstrument,
23
+ src_default as default,
24
+ getCacheKey
25
+ };
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import crypto from \"crypto\";\n\nimport { transform } from \"@babel/core\";\nimport type { Config } from \"@jest/types\";\n// import jestPreset from \"babel-preset-jest\";\n\nexport let canInstrument: false;\nexport const getCacheKey = (\n fileData: crypto.BinaryLike,\n filename: crypto.BinaryLike,\n _configString: crypto.BinaryLike,\n instrument: { instrument?: crypto.BinaryLike }\n) =>\n crypto\n .createHash(\"md5\")\n .update(\"\\0\", \"utf8\")\n .update(fileData)\n .update(\"\\0\", \"utf8\")\n .update(filename)\n .update(\"\\0\", \"utf8\")\n .update(\"\\0\", \"utf8\")\n .update(\"\\0\", \"utf8\")\n .update(instrument ? \"instrument\" : \"\")\n .digest(\"hex\");\n\nexport default {\n getCacheKey,\n process: (_src: string, filePath: string, jestConfig: Config.ProjectConfig) => {\n const windowsFix = filePath.replace(/\\\\/g, \"/\");\n const testFile = `\nconst { Feature } = require('autometa-runner'); \nFeature('${windowsFix}')\n`;\n\n const featureFile = transform(testFile, {\n filename: windowsFix,\n root: jestConfig.cwd,\n });\n\n return featureFile;\n },\n};\n"],"mappings":";AAAA,OAAO,YAAY;AAEnB,SAAS,iBAAiB;AAInB,IAAI;AACJ,IAAM,cAAc,CACzB,UACA,UACA,eACA,eAEA,OACG,WAAW,KAAK,EAChB,OAAO,MAAM,MAAM,EACnB,OAAO,QAAQ,EACf,OAAO,MAAM,MAAM,EACnB,OAAO,QAAQ,EACf,OAAO,MAAM,MAAM,EACnB,OAAO,MAAM,MAAM,EACnB,OAAO,MAAM,MAAM,EACnB,OAAO,aAAa,eAAe,EAAE,EACrC,OAAO,KAAK;AAEjB,IAAO,cAAQ;AAAA,EACb;AAAA,EACA,SAAS,CAAC,MAAc,UAAkB,eAAqC;AAC7E,UAAM,aAAa,SAAS,QAAQ,OAAO,GAAG;AAC9C,UAAM,WAAW;AAAA;AAAA,WAEV,UAAU;AAAA;AAGjB,UAAM,cAAc,UAAU,UAAU;AAAA,MACtC,UAAU;AAAA,MACV,MAAM,WAAW;AAAA,IACnB,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,16 @@
1
+ import * as _babel_core from '@babel/core';
2
+ import crypto from 'crypto';
3
+ import { Config } from '@jest/types';
4
+
5
+ declare let canInstrument: false;
6
+ declare const getCacheKey: (fileData: crypto.BinaryLike, filename: crypto.BinaryLike, _configString: crypto.BinaryLike, instrument: {
7
+ instrument?: crypto.BinaryLike | undefined;
8
+ }) => string;
9
+ declare const _default: {
10
+ getCacheKey: (fileData: crypto.BinaryLike, filename: crypto.BinaryLike, _configString: crypto.BinaryLike, instrument: {
11
+ instrument?: crypto.BinaryLike | undefined;
12
+ }) => string;
13
+ process: (_src: string, filePath: string, jestConfig: Config.ProjectConfig) => _babel_core.BabelFileResult | null;
14
+ };
15
+
16
+ export { canInstrument, _default as default, getCacheKey };
@@ -0,0 +1,16 @@
1
+ import * as _babel_core from '@babel/core';
2
+ import crypto from 'crypto';
3
+ import { Config } from '@jest/types';
4
+
5
+ declare let canInstrument: false;
6
+ declare const getCacheKey: (fileData: crypto.BinaryLike, filename: crypto.BinaryLike, _configString: crypto.BinaryLike, instrument: {
7
+ instrument?: crypto.BinaryLike | undefined;
8
+ }) => string;
9
+ declare const _default: {
10
+ getCacheKey: (fileData: crypto.BinaryLike, filename: crypto.BinaryLike, _configString: crypto.BinaryLike, instrument: {
11
+ instrument?: crypto.BinaryLike | undefined;
12
+ }) => string;
13
+ process: (_src: string, filePath: string, jestConfig: Config.ProjectConfig) => _babel_core.BabelFileResult | null;
14
+ };
15
+
16
+ export { canInstrument, _default as default, getCacheKey };
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ canInstrument: () => canInstrument,
34
+ default: () => src_default,
35
+ getCacheKey: () => getCacheKey
36
+ });
37
+ module.exports = __toCommonJS(src_exports);
38
+ var import_crypto = __toESM(require("crypto"));
39
+ var import_core = require("@babel/core");
40
+ var canInstrument;
41
+ var getCacheKey = (fileData, filename, _configString, instrument) => import_crypto.default.createHash("md5").update("\0", "utf8").update(fileData).update("\0", "utf8").update(filename).update("\0", "utf8").update("\0", "utf8").update("\0", "utf8").update(instrument ? "instrument" : "").digest("hex");
42
+ var src_default = {
43
+ getCacheKey,
44
+ process: (_src, filePath, jestConfig) => {
45
+ const windowsFix = filePath.replace(/\\/g, "/");
46
+ const testFile = `
47
+ const { Feature } = require('autometa-runner');
48
+ Feature('${windowsFix}')
49
+ `;
50
+ const featureFile = (0, import_core.transform)(testFile, {
51
+ filename: windowsFix,
52
+ root: jestConfig.cwd
53
+ });
54
+ return featureFile;
55
+ }
56
+ };
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ canInstrument,
60
+ getCacheKey
61
+ });
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import crypto from \"crypto\";\n\nimport { transform } from \"@babel/core\";\nimport type { Config } from \"@jest/types\";\n// import jestPreset from \"babel-preset-jest\";\n\nexport let canInstrument: false;\nexport const getCacheKey = (\n fileData: crypto.BinaryLike,\n filename: crypto.BinaryLike,\n _configString: crypto.BinaryLike,\n instrument: { instrument?: crypto.BinaryLike }\n) =>\n crypto\n .createHash(\"md5\")\n .update(\"\\0\", \"utf8\")\n .update(fileData)\n .update(\"\\0\", \"utf8\")\n .update(filename)\n .update(\"\\0\", \"utf8\")\n .update(\"\\0\", \"utf8\")\n .update(\"\\0\", \"utf8\")\n .update(instrument ? \"instrument\" : \"\")\n .digest(\"hex\");\n\nexport default {\n getCacheKey,\n process: (_src: string, filePath: string, jestConfig: Config.ProjectConfig) => {\n const windowsFix = filePath.replace(/\\\\/g, \"/\");\n const testFile = `\nconst { Feature } = require('autometa-runner'); \nFeature('${windowsFix}')\n`;\n\n const featureFile = transform(testFile, {\n filename: windowsFix,\n root: jestConfig.cwd,\n });\n\n return featureFile;\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAmB;AAEnB,kBAA0B;AAInB,IAAI;AACJ,IAAM,cAAc,CACzB,UACA,UACA,eACA,eAEA,cAAAA,QACG,WAAW,KAAK,EAChB,OAAO,MAAM,MAAM,EACnB,OAAO,QAAQ,EACf,OAAO,MAAM,MAAM,EACnB,OAAO,QAAQ,EACf,OAAO,MAAM,MAAM,EACnB,OAAO,MAAM,MAAM,EACnB,OAAO,MAAM,MAAM,EACnB,OAAO,aAAa,eAAe,EAAE,EACrC,OAAO,KAAK;AAEjB,IAAO,cAAQ;AAAA,EACb;AAAA,EACA,SAAS,CAAC,MAAc,UAAkB,eAAqC;AAC7E,UAAM,aAAa,SAAS,QAAQ,OAAO,GAAG;AAC9C,UAAM,WAAW;AAAA;AAAA,WAEV,UAAU;AAAA;AAGjB,UAAM,kBAAc,uBAAU,UAAU;AAAA,MACtC,UAAU;AAAA,MACV,MAAM,WAAW;AAAA,IACnB,CAAC;AAED,WAAO;AAAA,EACT;AACF;","names":["crypto"]}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@autometa/jest-transformer",
3
+ "version": "0.0.0",
4
+ "description": "",
5
+ "type": "commonjs",
6
+ "main": "dist/index.js",
7
+ "module": "dist/esm/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ "import": "./dist/esm/index.js",
11
+ "require": "./dist/index.js",
12
+ "default": "./dist/esm/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "license": "MIT",
16
+ "devDependencies": {
17
+ "@types/node": "^18.11.18",
18
+ "@types/uuid": "^9.0.1",
19
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
20
+ "@typescript-eslint/parser": "^5.54.1",
21
+ "eslint": "^8.37.0",
22
+ "eslint-config-custom": "0.5.1",
23
+ "eslint-config-prettier": "^8.3.0",
24
+ "rimraf": "^4.1.2",
25
+ "tsconfig": " *",
26
+ "tsup": "^7.2.0",
27
+ "typescript": "^4.9.5",
28
+ "vitest": "^0.29.8"
29
+ },
30
+ "dependencies": {
31
+ "@babel/core": "^7.21.4",
32
+ "@jest/types": "^29.4.3",
33
+ "@types/babel__core": "^7.20.0",
34
+ "autometa-runner": "^0.0.0",
35
+ "babel-preset-jest": "^29.5.0"
36
+ },
37
+ "scripts": {
38
+ "test": "vitest run --passWithNoTests",
39
+ "prettify": "prettier --config .prettierrc 'src/**/*.ts' --write",
40
+ "lint": "eslint . --max-warnings 0",
41
+ "lint:fix": "eslint . --fix",
42
+ "clean": "rimraf dist",
43
+ "build": "tsup",
44
+ "build:watch": "tsup --watch"
45
+ },
46
+ "readme": "# Introduction\n\nThere's nothing here yet"
47
+ }
package/tsup.config.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { defineConfig } from "tsup";
2
+
3
+ export default defineConfig({
4
+ clean: true, // clean up the dist folder
5
+ format: ["cjs", "esm"], // generate cjs and esm files
6
+ dts: true,
7
+ sourcemap:true, // generate sourcemaps
8
+ skipNodeModulesBundle: true,
9
+ entryPoints: ["src/index.ts"],
10
+ target: "es2020",
11
+ outDir: "dist",
12
+ legacyOutput: true,
13
+ external: ["dist"],
14
+ });