Lines 1-32javascript
2import * as fs from "fs";
3import * as path from "path";
4import { createHash } from "crypto";
5import { createRequire } from "module";
6import { tryGetActiveOtelContext, resolveTraceUrl } from "executable-stories-core/utils/otel-detect";
7import { buildHtmlDocEntry } from "executable-stories-core/utils/doc-builders";
8var storyRegistry = globalThis.__jestExecutableStoriesRegistry ??= /* @__PURE__ */ new Map();
9var attachmentRegistry = /* @__PURE__ */ new Map();
10var otelSpansRegistry = /* @__PURE__ */ new Map();
11var exitHandlerRegistered = globalThis.__jestExecutableStoriesExitHandler ?? false;
12function getOutputDir() {
13 const baseDir = process.env.JEST_STORY_DOCS_DIR ?? ".jest-executable-stories";
14 return path.resolve(process.cwd(), baseDir);
15}
LowWeak Crypto
Package source references weak cryptographic algorithms.
dist/index.jsView on unpkg · L12 16function flushStories() {
17 if (storyRegistry.size === 0) return;
18 const workerId = process.env.JEST_WORKER_ID ?? "0";
19 const outputDir = path.join(getOutputDir(), `worker-${workerId}`);
20 fs.mkdirSync(outputDir, { recursive: true });
21 for (const [testFilePath, scenarios] of storyRegistry) {
22 if (!scenarios.length) continue;
23 const hash = createHash("sha1").update(testFilePath).digest("hex").slice(0, 12);
24 const baseName = testFilePath === "unknown" ? "unknown" : path.basename(testFilePath);
25 const outFile = path.join(outputDir, `${baseName}.${hash}.json`);
26 const fileAttachments = attachmentRegistry.get(testFilePath);
27 const fileOtelSpans = otelSpansRegistry.get(testFilePath);
28 const scenariosWithAttachments = scenarios.map((s, i) => ({
30 _attachments: fileAttachments?.get(i) ?? [],
31 ...fileOtelSpans?.get(i) ? { _otelSpans: fileOtelSpans.get(i) } : {}