New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@code-pushup/utils

Package Overview
Dependencies
Maintainers
3
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@code-pushup/utils - npm Package Compare versions

Comparing version 0.6.3 to 0.6.4

src/lib/constants.d.ts

94

index.js

@@ -540,2 +540,8 @@ // packages/utils/src/lib/execute-process.ts

// packages/utils/src/lib/constants.ts
var SCORE_COLOR_RANGE = {
GREEN_MIN: 0.9,
YELLOW_MIN: 0.5
};
// packages/utils/src/lib/file-system.ts

@@ -765,6 +771,6 @@ import { bundleRequire } from "bundle-require";

function getRoundScoreMarker(score) {
if (score >= 0.9) {
if (score >= SCORE_COLOR_RANGE.GREEN_MIN) {
return "\u{1F7E2}";
}
if (score >= 0.5) {
if (score >= SCORE_COLOR_RANGE.YELLOW_MIN) {
return "\u{1F7E1}";

@@ -775,6 +781,6 @@ }

function getSquaredScoreMarker(score) {
if (score >= 0.9) {
if (score >= SCORE_COLOR_RANGE.GREEN_MIN) {
return "\u{1F7E9}";
}
if (score >= 0.5) {
if (score >= SCORE_COLOR_RANGE.YELLOW_MIN) {
return "\u{1F7E8}";

@@ -984,34 +990,2 @@ }

}
function objectToCliArgs(params) {
if (!params) {
return [];
}
return Object.entries(params).flatMap(([key, value]) => {
if (key === "_") {
if (Array.isArray(value)) {
return value;
} else {
return [value + ""];
}
}
const prefix = key.length === 1 ? "-" : "--";
if (Array.isArray(value)) {
return value.map((v) => `${prefix}${key}="${v}"`);
}
if (Array.isArray(value)) {
return value.map((v) => `${prefix}${key}="${v}"`);
}
if (typeof value === "string") {
return [`${prefix}${key}="${value}"`];
}
if (typeof value === "number") {
return [`${prefix}${key}=${value}`];
}
if (typeof value === "boolean") {
return [`${prefix}${value ? "" : "no-"}${key}`];
}
throw new Error(`Unsupported type ${typeof value} for key ${key}`);
});
}
objectToCliArgs({ z: 5 });

@@ -1422,15 +1396,14 @@ // packages/utils/src/lib/git.ts

function withColor({ score, text }) {
let str = text ?? formatReportScore(score);
const formattedScore = text ?? formatReportScore(score);
const style2 = text ? chalk3 : chalk3.bold;
if (score < 0.5) {
str = style2.red(str);
} else if (score < 0.9) {
str = style2.yellow(str);
} else {
str = style2.green(str);
if (score >= SCORE_COLOR_RANGE.GREEN_MIN) {
return style2.green(formattedScore);
}
return str;
if (score >= SCORE_COLOR_RANGE.YELLOW_MIN) {
return style2.yellow(formattedScore);
}
return style2.red(formattedScore);
}
// packages/utils/src/lib/transformation.ts
// packages/utils/src/lib/transform.ts
function toArray(val) {

@@ -1474,2 +1447,33 @@ return Array.isArray(val) ? val : [val];

}
function objectToCliArgs(params) {
if (!params) {
return [];
}
return Object.entries(params).flatMap(([key, value]) => {
if (key === "_") {
if (Array.isArray(value)) {
return value;
} else {
return [value + ""];
}
}
const prefix = key.length === 1 ? "-" : "--";
if (Array.isArray(value)) {
return value.map((v) => `${prefix}${key}="${v}"`);
}
if (Array.isArray(value)) {
return value.map((v) => `${prefix}${key}="${v}"`);
}
if (typeof value === "string") {
return [`${prefix}${key}="${value}"`];
}
if (typeof value === "number") {
return [`${prefix}${key}=${value}`];
}
if (typeof value === "boolean") {
return [`${prefix}${value ? "" : "no-"}${key}`];
}
throw new Error(`Unsupported type ${typeof value} for key ${key}`);
});
}

@@ -1476,0 +1480,0 @@ // packages/utils/src/lib/scoring.ts

{
"name": "@code-pushup/utils",
"version": "0.6.3",
"version": "0.6.4",
"dependencies": {

@@ -5,0 +5,0 @@ "@code-pushup/models": "*",

@@ -1,3 +0,3 @@

export { CliArgsObject, ProcessConfig, ProcessError, ProcessObserver, ProcessResult, executeProcess, objectToCliArgs, } from './lib/execute-process';
export { FileResult, MultipleFileResults, CrawlFileSystemOptions, crawlFileSystem, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, toUnixPath, } from './lib/file-system';
export { ProcessConfig, ProcessError, ProcessObserver, ProcessResult, executeProcess, } from './lib/execute-process';
export { CrawlFileSystemOptions, FileResult, MultipleFileResults, crawlFileSystem, ensureDirectoryExists, fileExists, findLineNumberInText, importEsmModule, logMultipleFileResults, pluginWorkDir, readJsonFile, readTextFile, toUnixPath, } from './lib/file-system';
export { formatBytes, formatDuration, pluralize, pluralizeToken, slugify, truncateDescription, truncateText, truncateTitle, } from './lib/formatting';

@@ -13,3 +13,3 @@ export { getLatestCommit, git } from './lib/git';

export { ScoredReport, scoreReport } from './lib/scoring';
export { countOccurrences, distinct, factorOf, objectToEntries, objectToKeys, toArray, } from './lib/transformation';
export { CliArgsObject, countOccurrences, distinct, factorOf, objectToCliArgs, objectToEntries, objectToKeys, toArray, } from './lib/transform';
export { verboseUtils } from './lib/verbose-utils';

@@ -122,17 +122,1 @@ /**

export declare function executeProcess(cfg: ProcessConfig): Promise<ProcessResult>;
type ArgumentValue = number | string | boolean | string[];
export type CliArgsObject<T extends object = Record<string, ArgumentValue>> = T extends never ? Record<string, ArgumentValue | undefined> | {
_: string;
} : T;
/**
* Converts an object with different types of values into an array of command-line arguments.
*
* @example
* const args = objectToProcessArgs({
* _: ['node', 'index.js'], // node index.js
* name: 'Juanita', // --name=Juanita
* formats: ['json', 'md'] // --format=json --format=md
* });
*/
export declare function objectToCliArgs<T extends object = Record<string, ArgumentValue>>(params?: CliArgsObject<T>): string[];
export {};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc