Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 9.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. function _crypto() {
  7. const data = require('crypto');
  8. _crypto = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function path() {
  14. const data = _interopRequireWildcard(require('path'));
  15. path = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _core() {
  21. const data = require('@babel/core');
  22. _core = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _chalk() {
  28. const data = _interopRequireDefault(require('chalk'));
  29. _chalk = function () {
  30. return data;
  31. };
  32. return data;
  33. }
  34. function fs() {
  35. const data = _interopRequireWildcard(require('graceful-fs'));
  36. fs = function () {
  37. return data;
  38. };
  39. return data;
  40. }
  41. function _slash() {
  42. const data = _interopRequireDefault(require('slash'));
  43. _slash = function () {
  44. return data;
  45. };
  46. return data;
  47. }
  48. var _loadBabelConfig = require('./loadBabelConfig');
  49. function _interopRequireDefault(obj) {
  50. return obj && obj.__esModule ? obj : {default: obj};
  51. }
  52. function _getRequireWildcardCache(nodeInterop) {
  53. if (typeof WeakMap !== 'function') return null;
  54. var cacheBabelInterop = new WeakMap();
  55. var cacheNodeInterop = new WeakMap();
  56. return (_getRequireWildcardCache = function (nodeInterop) {
  57. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  58. })(nodeInterop);
  59. }
  60. function _interopRequireWildcard(obj, nodeInterop) {
  61. if (!nodeInterop && obj && obj.__esModule) {
  62. return obj;
  63. }
  64. if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
  65. return {default: obj};
  66. }
  67. var cache = _getRequireWildcardCache(nodeInterop);
  68. if (cache && cache.has(obj)) {
  69. return cache.get(obj);
  70. }
  71. var newObj = {};
  72. var hasPropertyDescriptor =
  73. Object.defineProperty && Object.getOwnPropertyDescriptor;
  74. for (var key in obj) {
  75. if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
  76. var desc = hasPropertyDescriptor
  77. ? Object.getOwnPropertyDescriptor(obj, key)
  78. : null;
  79. if (desc && (desc.get || desc.set)) {
  80. Object.defineProperty(newObj, key, desc);
  81. } else {
  82. newObj[key] = obj[key];
  83. }
  84. }
  85. }
  86. newObj.default = obj;
  87. if (cache) {
  88. cache.set(obj, newObj);
  89. }
  90. return newObj;
  91. }
  92. /**
  93. * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
  94. *
  95. * This source code is licensed under the MIT license found in the
  96. * LICENSE file in the root directory of this source tree.
  97. */
  98. const THIS_FILE = fs().readFileSync(__filename);
  99. const jestPresetPath = require.resolve('babel-preset-jest');
  100. const babelIstanbulPlugin = require.resolve('babel-plugin-istanbul');
  101. function assertLoadedBabelConfig(babelConfig, cwd, filename) {
  102. if (!babelConfig) {
  103. throw new Error(
  104. `babel-jest: Babel ignores ${_chalk().default.bold(
  105. (0, _slash().default)(path().relative(cwd, filename))
  106. )} - make sure to include the file in Jest's ${_chalk().default.bold(
  107. 'transformIgnorePatterns'
  108. )} as well.`
  109. );
  110. }
  111. }
  112. function addIstanbulInstrumentation(babelOptions, transformOptions) {
  113. if (transformOptions.instrument) {
  114. const copiedBabelOptions = {...babelOptions};
  115. copiedBabelOptions.auxiliaryCommentBefore = ' istanbul ignore next '; // Copied from jest-runtime transform.js
  116. copiedBabelOptions.plugins = (copiedBabelOptions.plugins || []).concat([
  117. [
  118. babelIstanbulPlugin,
  119. {
  120. // files outside `cwd` will not be instrumented
  121. cwd: transformOptions.config.cwd,
  122. exclude: []
  123. }
  124. ]
  125. ]);
  126. return copiedBabelOptions;
  127. }
  128. return babelOptions;
  129. }
  130. function getCacheKeyFromConfig(
  131. sourceText,
  132. sourcePath,
  133. babelOptions,
  134. transformOptions
  135. ) {
  136. const {config, configString, instrument} = transformOptions;
  137. const configPath = [babelOptions.config || '', babelOptions.babelrc || ''];
  138. return (0, _crypto().createHash)('md5')
  139. .update(THIS_FILE)
  140. .update('\0', 'utf8')
  141. .update(JSON.stringify(babelOptions.options))
  142. .update('\0', 'utf8')
  143. .update(sourceText)
  144. .update('\0', 'utf8')
  145. .update(path().relative(config.rootDir, sourcePath))
  146. .update('\0', 'utf8')
  147. .update(configString)
  148. .update('\0', 'utf8')
  149. .update(configPath.join(''))
  150. .update('\0', 'utf8')
  151. .update(instrument ? 'instrument' : '')
  152. .update('\0', 'utf8')
  153. .update(process.env.NODE_ENV || '')
  154. .update('\0', 'utf8')
  155. .update(process.env.BABEL_ENV || '')
  156. .digest('hex');
  157. }
  158. function loadBabelConfig(cwd, filename, transformOptions) {
  159. const babelConfig = (0, _loadBabelConfig.loadPartialConfig)(transformOptions);
  160. assertLoadedBabelConfig(babelConfig, cwd, filename);
  161. return babelConfig;
  162. }
  163. async function loadBabelConfigAsync(cwd, filename, transformOptions) {
  164. const babelConfig = await (0, _loadBabelConfig.loadPartialConfigAsync)(
  165. transformOptions
  166. );
  167. assertLoadedBabelConfig(babelConfig, cwd, filename);
  168. return babelConfig;
  169. }
  170. function loadBabelOptions(
  171. cwd,
  172. filename,
  173. transformOptions,
  174. jestTransformOptions
  175. ) {
  176. const {options} = loadBabelConfig(cwd, filename, transformOptions);
  177. return addIstanbulInstrumentation(options, jestTransformOptions);
  178. }
  179. async function loadBabelOptionsAsync(
  180. cwd,
  181. filename,
  182. transformOptions,
  183. jestTransformOptions
  184. ) {
  185. const {options} = await loadBabelConfigAsync(cwd, filename, transformOptions);
  186. return addIstanbulInstrumentation(options, jestTransformOptions);
  187. }
  188. const createTransformer = userOptions => {
  189. var _inputOptions$plugins, _inputOptions$presets;
  190. const inputOptions =
  191. userOptions !== null && userOptions !== void 0 ? userOptions : {};
  192. const options = {
  193. ...inputOptions,
  194. caller: {
  195. name: 'babel-jest',
  196. supportsDynamicImport: false,
  197. supportsExportNamespaceFrom: false,
  198. supportsStaticESM: false,
  199. supportsTopLevelAwait: false,
  200. ...inputOptions.caller
  201. },
  202. compact: false,
  203. plugins:
  204. (_inputOptions$plugins = inputOptions.plugins) !== null &&
  205. _inputOptions$plugins !== void 0
  206. ? _inputOptions$plugins
  207. : [],
  208. presets: ((_inputOptions$presets = inputOptions.presets) !== null &&
  209. _inputOptions$presets !== void 0
  210. ? _inputOptions$presets
  211. : []
  212. ).concat(jestPresetPath),
  213. sourceMaps: 'both'
  214. };
  215. function mergeBabelTransformOptions(filename, transformOptions) {
  216. var _transformOptions$sup,
  217. _transformOptions$sup2,
  218. _transformOptions$sup3,
  219. _transformOptions$sup4;
  220. const {cwd} = transformOptions.config; // `cwd` first to allow incoming options to override it
  221. return {
  222. cwd,
  223. ...options,
  224. caller: {
  225. ...options.caller,
  226. supportsDynamicImport:
  227. (_transformOptions$sup = transformOptions.supportsDynamicImport) !==
  228. null && _transformOptions$sup !== void 0
  229. ? _transformOptions$sup
  230. : options.caller.supportsDynamicImport,
  231. supportsExportNamespaceFrom:
  232. (_transformOptions$sup2 =
  233. transformOptions.supportsExportNamespaceFrom) !== null &&
  234. _transformOptions$sup2 !== void 0
  235. ? _transformOptions$sup2
  236. : options.caller.supportsExportNamespaceFrom,
  237. supportsStaticESM:
  238. (_transformOptions$sup3 = transformOptions.supportsStaticESM) !==
  239. null && _transformOptions$sup3 !== void 0
  240. ? _transformOptions$sup3
  241. : options.caller.supportsStaticESM,
  242. supportsTopLevelAwait:
  243. (_transformOptions$sup4 = transformOptions.supportsTopLevelAwait) !==
  244. null && _transformOptions$sup4 !== void 0
  245. ? _transformOptions$sup4
  246. : options.caller.supportsTopLevelAwait
  247. },
  248. filename
  249. };
  250. }
  251. return {
  252. canInstrument: true,
  253. getCacheKey(sourceText, sourcePath, transformOptions) {
  254. const babelOptions = loadBabelConfig(
  255. transformOptions.config.cwd,
  256. sourcePath,
  257. mergeBabelTransformOptions(sourcePath, transformOptions)
  258. );
  259. return getCacheKeyFromConfig(
  260. sourceText,
  261. sourcePath,
  262. babelOptions,
  263. transformOptions
  264. );
  265. },
  266. async getCacheKeyAsync(sourceText, sourcePath, transformOptions) {
  267. const babelOptions = await loadBabelConfigAsync(
  268. transformOptions.config.cwd,
  269. sourcePath,
  270. mergeBabelTransformOptions(sourcePath, transformOptions)
  271. );
  272. return getCacheKeyFromConfig(
  273. sourceText,
  274. sourcePath,
  275. babelOptions,
  276. transformOptions
  277. );
  278. },
  279. process(sourceText, sourcePath, transformOptions) {
  280. const babelOptions = loadBabelOptions(
  281. transformOptions.config.cwd,
  282. sourcePath,
  283. mergeBabelTransformOptions(sourcePath, transformOptions),
  284. transformOptions
  285. );
  286. const transformResult = (0, _core().transformSync)(
  287. sourceText,
  288. babelOptions
  289. );
  290. if (transformResult) {
  291. const {code, map} = transformResult;
  292. if (typeof code === 'string') {
  293. return {
  294. code,
  295. map
  296. };
  297. }
  298. }
  299. return sourceText;
  300. },
  301. async processAsync(sourceText, sourcePath, transformOptions) {
  302. const babelOptions = await loadBabelOptionsAsync(
  303. transformOptions.config.cwd,
  304. sourcePath,
  305. mergeBabelTransformOptions(sourcePath, transformOptions),
  306. transformOptions
  307. );
  308. const transformResult = await (0, _core().transformAsync)(
  309. sourceText,
  310. babelOptions
  311. );
  312. if (transformResult) {
  313. const {code, map} = transformResult;
  314. if (typeof code === 'string') {
  315. return {
  316. code,
  317. map
  318. };
  319. }
  320. }
  321. return sourceText;
  322. }
  323. };
  324. };
  325. const transformer = {
  326. ...createTransformer(),
  327. // Assigned here so only the exported transformer has `createTransformer`,
  328. // instead of all created transformers by the function
  329. createTransformer
  330. };
  331. var _default = transformer;
  332. exports.default = _default;