+9
-2
| { | ||
| "name": "ctrf", | ||
| "version": "0.0.16", | ||
| "version": "0.0.17", | ||
| "description": "Common library for working with CTRF reports", | ||
@@ -36,3 +36,10 @@ "type": "module", | ||
| ], | ||
| "repository": "github:ctrf-io/ctrf-core-js", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/ctrf-io/ctrf-core-js.git" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "provenance": true | ||
| }, | ||
| "homepage": "https://ctrf.io", | ||
@@ -39,0 +46,0 @@ "author": "Matthew Thomas", |
| /** | ||
| * CTRF framework-agnostic facade functions | ||
| * These functions call into the global runtime that's set by framework-specific packages | ||
| * Simplified API focusing on test.extra enrichment | ||
| */ | ||
| /** | ||
| * Test-related CTRF functions | ||
| */ | ||
| export declare const test: { | ||
| /** | ||
| * Add extra metadata to a test | ||
| */ | ||
| addExtra: (key: string, value: unknown) => Promise<void>; | ||
| }; |
| /** | ||
| * CTRF framework-agnostic facade functions | ||
| * These functions call into the global runtime that's set by framework-specific packages | ||
| * Simplified API focusing on test.extra enrichment | ||
| */ | ||
| import { getGlobalCtrfRuntimeWithAutoconfig } from './runtime.js'; | ||
| const callRuntimeMethod = (method, ...args) => { | ||
| const runtime = getGlobalCtrfRuntimeWithAutoconfig(); | ||
| if (runtime && typeof runtime.then !== 'function') { | ||
| // @ts-ignore | ||
| return runtime[method](...args); | ||
| } | ||
| return runtime.then((ctrfRuntime) => { | ||
| // @ts-ignore | ||
| return ctrfRuntime[method](...args); | ||
| }); | ||
| }; | ||
| /** | ||
| * Test-related CTRF functions | ||
| */ | ||
| export const test = { | ||
| /** | ||
| * Add extra metadata to a test | ||
| */ | ||
| addExtra: (key, value) => { | ||
| return callRuntimeMethod('addExtra', key, value); | ||
| } | ||
| }; |
| export type { CtrfRuntime } from './runtime.js'; | ||
| export { setGlobalCtrfRuntime, getGlobalCtrfRuntime, getGlobalCtrfRuntimeWithAutoconfig } from './runtime.js'; | ||
| export { test } from './facade.js'; |
| export { setGlobalCtrfRuntime, getGlobalCtrfRuntime, getGlobalCtrfRuntimeWithAutoconfig } from './runtime.js'; | ||
| export { test } from './facade.js'; |
| /** | ||
| * CTRF runtime system | ||
| */ | ||
| /** | ||
| * Interface that framework-specific runtimes must implement | ||
| */ | ||
| export interface CtrfRuntime { | ||
| addExtra(key: string, value: unknown): Promise<void>; | ||
| } | ||
| /** | ||
| * Set the global CTRF runtime (called by framework-specific packages) | ||
| */ | ||
| export declare const setGlobalCtrfRuntime: (runtime: CtrfRuntime) => void; | ||
| /** | ||
| * Get the current global CTRF runtime | ||
| */ | ||
| export declare const getGlobalCtrfRuntime: () => CtrfRuntime; | ||
| /** | ||
| * Get the global CTRF runtime with auto-configuration attempt | ||
| * This tries to auto-detect and configure framework-specific runtimes | ||
| */ | ||
| export declare const getGlobalCtrfRuntimeWithAutoconfig: () => CtrfRuntime | Promise<CtrfRuntime>; | ||
| export { test } from './facade.js'; |
| /** | ||
| * CTRF runtime system | ||
| */ | ||
| /** | ||
| * No-op runtime that logs warnings when no framework runtime is available | ||
| */ | ||
| class NoopCtrfRuntime { | ||
| warn(method) { | ||
| console.warn(`CTRF: ${method} called but no framework runtime is available. Make sure you have configured a CTRF reporter for your test framework.`); | ||
| } | ||
| async addExtra() { | ||
| this.warn('addExtra'); | ||
| } | ||
| } | ||
| const CTRF_RUNTIME_KEY = 'ctrfRuntime'; | ||
| const noopRuntime = new NoopCtrfRuntime(); | ||
| /** | ||
| * Set the global CTRF runtime (called by framework-specific packages) | ||
| */ | ||
| export const setGlobalCtrfRuntime = (runtime) => { | ||
| ; | ||
| globalThis[CTRF_RUNTIME_KEY] = runtime; | ||
| }; | ||
| /** | ||
| * Get the current global CTRF runtime | ||
| */ | ||
| export const getGlobalCtrfRuntime = () => { | ||
| const runtime = globalThis?.[CTRF_RUNTIME_KEY]; | ||
| return runtime ?? noopRuntime; | ||
| }; | ||
| /** | ||
| * Get the global CTRF runtime with auto-configuration attempt | ||
| * This tries to auto-detect and configure framework-specific runtimes | ||
| */ | ||
| export const getGlobalCtrfRuntimeWithAutoconfig = () => { | ||
| const runtime = getGlobalCtrfRuntime(); | ||
| if (runtime !== noopRuntime) { | ||
| return runtime; | ||
| } | ||
| // protection from bundlers tree-shaking visiting (webpack, rollup) | ||
| const pwAutoconfigModuleName = 'playwright-ctrf-json-reporter/autoconfig'; | ||
| return import(pwAutoconfigModuleName) | ||
| .then(() => { | ||
| return getGlobalCtrfRuntime(); | ||
| }) | ||
| .catch(() => { | ||
| return noopRuntime; | ||
| }); | ||
| }; | ||
| // Export facade functions (framework-agnostic API) | ||
| export { test } from './facade.js'; |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
11
-8.33%209846
-1.73%42
-12.5%4948
-2.39%