@compas/stdlib
Advanced tools
+1
-1
@@ -15,5 +15,5 @@ export { uuid } from "./src/datatypes.js"; | ||
| export { getSecondsSinceEpoch, gc, mainFn, noop, filenameForModule, dirnameForModule } from "./src/utils.js"; | ||
| export { newLogger, loggerGetGlobalDestination, loggerSetGlobalDestination, loggerGetPrettyPrinter, loggerExtendGlobalContext, loggerDetermineDefaultDestination } from "./src/logger.js"; | ||
| export { newLogger, loggerGetGlobalDestination, loggerSetGlobalDestination, loggerGetPrettyPrinter, loggerExtendGlobalContext, loggerDetermineDefaultDestination, asyncLocalStorageLogger, contextAwarelogger } from "./src/logger.js"; | ||
| export { bytesToHumanReadable, printProcessMemoryUsage } from "./src/memory.js"; | ||
| export { newEvent, eventStart, eventRename, eventStop, newEventFromEvent } from "./src/events.js"; | ||
| export { _compasSentryExport, compasWithSentry, _compasSentryEnableQuerySpans } from "./src/sentry.js"; |
+2
-0
@@ -84,2 +84,4 @@ /// <reference path="./types/advanced-types.d.ts"> | ||
| loggerDetermineDefaultDestination, | ||
| asyncLocalStorageLogger, | ||
| contextAwarelogger, | ||
| } from "./src/logger.js"; | ||
@@ -86,0 +88,0 @@ |
+5
-5
| { | ||
| "name": "@compas/stdlib", | ||
| "version": "0.19.4", | ||
| "version": "0.20.0", | ||
| "description": "All kinds of utility functions", | ||
@@ -21,6 +21,6 @@ "exports": { | ||
| "dependencies": { | ||
| "@types/node": "24.5.2", | ||
| "dotenv": "17.2.2", | ||
| "@types/node": "24.9.1", | ||
| "dotenv": "17.2.3", | ||
| "lodash.merge": "4.6.2", | ||
| "pino": "9.11.0" | ||
| "pino": "10.1.0" | ||
| }, | ||
@@ -51,4 +51,4 @@ "devDependencies": { | ||
| "engines": { | ||
| "node": ">=18" | ||
| "node": ">=24" | ||
| } | ||
| } |
+9
-2
@@ -8,4 +8,4 @@ # @compas/stdlib | ||
| <a href="https://github.com/compasjs/compas/actions/workflows/main-checks.yml" target="_blank"> | ||
| <img src="https://github.com/compasjs/compas/actions/workflows/main-checks.yml/badge.svg" alt="CI status badge"> | ||
| <a href="https://github.com/compasjs/compas/actions/workflows/checks.yml" target="_blank"> | ||
| <img src="https://github.com/compasjs/compas/actions/workflows/checks.yml/badge.svg" alt="CI status badge"> | ||
| </a> | ||
@@ -21,1 +21,8 @@ <a href="https://codecov.io/gh/compasjs/compas" target="_blank"> | ||
| [documentation](https://compasjs.com/getting-started.html). | ||
| ## Maintenance mode | ||
| Compas is in maintenance mode. The packages will be maintained for the | ||
| foreseeable future. New features might be added, but some will also be dropped | ||
| in favor of other ecosystem-available libraries. Please don't start new projects | ||
| using Compas. |
+1
-1
| /** | ||
| * This should only be necessary when you or a package mutates the environment variables. | ||
| * The `mainFn` / `mainTestFn` / `mainBenchFn` / ... will call this function by default | ||
| * The `mainFn` and `mainTestFn` will call this function by default | ||
| * after loading your `.env` file. | ||
@@ -5,0 +5,0 @@ * |
+1
-1
@@ -10,3 +10,3 @@ /** | ||
| * This should only be necessary when you or a package mutates the environment variables. | ||
| * The `mainFn` / `mainTestFn` / `mainBenchFn` / ... will call this function by default | ||
| * The `mainFn` and `mainTestFn` will call this function by default | ||
| * after loading your `.env` file. | ||
@@ -13,0 +13,0 @@ * |
+17
-0
@@ -67,2 +67,18 @@ /** | ||
| /** | ||
| * Control the ALS for the logger. | ||
| * | ||
| * @type {AsyncLocalStorage<{ log: Logger }>} | ||
| */ | ||
| export const asyncLocalStorageLogger: AsyncLocalStorage<{ | ||
| log: Logger; | ||
| }>; | ||
| /** | ||
| * Log via the current async local logger. | ||
| * | ||
| * All Compas internal usages | ||
| * | ||
| * @type {Logger} | ||
| */ | ||
| export const contextAwarelogger: Logger; | ||
| /** | ||
| * The logger only has two severities: | ||
@@ -84,1 +100,2 @@ * - info | ||
| }; | ||
| import { AsyncLocalStorage } from "node:async_hooks"; |
+38
-0
@@ -0,1 +1,2 @@ | ||
| import { AsyncLocalStorage } from "node:async_hooks"; | ||
| import { pino, destination } from "pino"; | ||
@@ -42,2 +43,39 @@ import { environment, isProduction } from "./env.js"; | ||
| /** | ||
| * Control the ALS for the logger. | ||
| * | ||
| * @type {AsyncLocalStorage<{ log: Logger }>} | ||
| */ | ||
| export const asyncLocalStorageLogger = new AsyncLocalStorage(); | ||
| /** | ||
| * Log via the current async local logger. | ||
| * | ||
| * All Compas internal usages | ||
| * | ||
| * @type {Logger} | ||
| */ | ||
| export const contextAwarelogger = { | ||
| info: (...args) => { | ||
| const store = asyncLocalStorageLogger.getStore(); | ||
| if (store) { | ||
| store.log.info(...args); | ||
| } else { | ||
| throw new Error( | ||
| `No logger found in AsyncLocalStorage. Did you forget to call 'asyncLocalStorageLogger.run()'?`, | ||
| ); | ||
| } | ||
| }, | ||
| error: (...args) => { | ||
| const store = asyncLocalStorageLogger.getStore(); | ||
| if (store) { | ||
| store.log.info(...args); | ||
| } else { | ||
| throw new Error( | ||
| `No logger found in AsyncLocalStorage. Did you forget to call 'asyncLocalStorageLogger.run()'?`, | ||
| ); | ||
| } | ||
| }, | ||
| }; | ||
| /** | ||
| * Deeply update the global logger context. This only affects newly created loggers | ||
@@ -44,0 +82,0 @@ * |
+2
-0
@@ -38,2 +38,3 @@ /** | ||
| * @returns {string} | ||
| * @deprecated use `import.meta.filename`. | ||
| */ | ||
@@ -48,2 +49,3 @@ export function filenameForModule(meta: ImportMeta): string; | ||
| * @returns {string} | ||
| * @deprecated Use `import.meta.dirname`. | ||
| */ | ||
@@ -50,0 +52,0 @@ export function dirnameForModule(meta: ImportMeta): string; |
+4
-2
@@ -176,5 +176,6 @@ import { lstatSync, realpathSync } from "node:fs"; | ||
| * @returns {string} | ||
| * @deprecated use `import.meta.filename`. | ||
| */ | ||
| export function filenameForModule(meta) { | ||
| return fileURLToPath(meta.url); | ||
| return meta.filename; | ||
| } | ||
@@ -189,5 +190,6 @@ | ||
| * @returns {string} | ||
| * @deprecated Use `import.meta.dirname`. | ||
| */ | ||
| export function dirnameForModule(meta) { | ||
| return path.dirname(filenameForModule(meta)); | ||
| return meta.dirname; | ||
| } | ||
@@ -194,0 +196,0 @@ |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances 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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances 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
78086
2.29%2594
2.33%27
35%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated
Updated