index.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use strict";
  2. var __read = (this && this.__read) || function (o, n) {
  3. var m = typeof Symbol === "function" && o[Symbol.iterator];
  4. if (!m) return o;
  5. var i = m.call(o), r, ar = [], e;
  6. try {
  7. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  8. }
  9. catch (error) { e = { error: error }; }
  10. finally {
  11. try {
  12. if (r && !r.done && (m = i["return"])) m.call(i);
  13. }
  14. finally { if (e) throw e.error; }
  15. }
  16. return ar;
  17. };
  18. var __spread = (this && this.__spread) || function () {
  19. for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
  20. return ar;
  21. };
  22. var _a;
  23. Object.defineProperty(exports, "__esModule", { value: true });
  24. var bs_logger_1 = require("bs-logger");
  25. var fs_1 = require("fs");
  26. var path_1 = require("path");
  27. var create_jest_preset_1 = require("./config/create-jest-preset");
  28. var paths_to_module_name_mapper_1 = require("./config/paths-to-module-name-mapper");
  29. var ts_jest_transformer_1 = require("./ts-jest-transformer");
  30. var logger_1 = require("./util/logger");
  31. var messages_1 = require("./util/messages");
  32. var testing_1 = require("./util/testing");
  33. var version_checkers_1 = require("./util/version-checkers");
  34. var warn = logger_1.rootLogger.child((_a = {}, _a[bs_logger_1.LogContexts.logLevel] = bs_logger_1.LogLevels.warn, _a));
  35. var helperMoved = function (name, helper) {
  36. return warn.wrap(messages_1.interpolate(messages_1.Deprecateds.HelperMovedToUtils, { helper: name }), helper);
  37. };
  38. exports.mocked = helperMoved('mocked', testing_1.mocked);
  39. exports.createJestPreset = helperMoved('createJestPreset', create_jest_preset_1.createJestPreset);
  40. exports.pathsToModuleNameMapper = helperMoved('pathsToModuleNameMapper', paths_to_module_name_mapper_1.pathsToModuleNameMapper);
  41. exports.version = require('../package.json').version;
  42. exports.digest = fs_1.readFileSync(path_1.resolve(__dirname, '..', '.ts-jest-digest'), 'utf8');
  43. var transformer;
  44. function defaultTransformer() {
  45. return transformer || (transformer = createTransformer());
  46. }
  47. function createTransformer(baseConfig) {
  48. version_checkers_1.VersionCheckers.jest.warn();
  49. return new ts_jest_transformer_1.TsJestTransformer(baseConfig);
  50. }
  51. exports.createTransformer = createTransformer;
  52. function process() {
  53. var _a;
  54. var args = [];
  55. for (var _i = 0; _i < arguments.length; _i++) {
  56. args[_i] = arguments[_i];
  57. }
  58. return (_a = defaultTransformer()).process.apply(_a, __spread(args));
  59. }
  60. exports.process = process;
  61. function getCacheKey() {
  62. var _a;
  63. var args = [];
  64. for (var _i = 0; _i < arguments.length; _i++) {
  65. args[_i] = arguments[_i];
  66. }
  67. return (_a = defaultTransformer()).getCacheKey.apply(_a, __spread(args));
  68. }
  69. exports.getCacheKey = getCacheKey;
  70. exports.canInstrument = false;
  71. var jestPreset = create_jest_preset_1.createJestPreset();
  72. exports.jestPreset = jestPreset;
  73. exports.__singleton = function () { return transformer; };
  74. exports.__resetModule = function () { return (transformer = undefined); };