Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@compas/cli

Package Overview
Dependencies
Maintainers
1
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@compas/cli - npm Package Compare versions

Comparing version 0.0.131 to 0.0.132

10

package.json
{
"name": "@compas/cli",
"version": "0.0.131",
"version": "0.0.132",
"description": "CLI containing utilities and simple script runner",

@@ -29,5 +29,5 @@ "main": "./index.js",

"dependencies": {
"@compas/insight": "0.0.131",
"@compas/stdlib": "0.0.131",
"c8": "7.7.1",
"@compas/insight": "0.0.132",
"@compas/stdlib": "0.0.132",
"c8": "7.7.2",
"chokidar": "3.5.1",

@@ -58,3 +58,3 @@ "http-proxy": "1.18.1",

},
"gitHead": "d946ba040e01848808337f117193bcbfb165e78e"
"gitHead": "049d95d965630ecf2d38c69df0e375a27f058ee3"
}

@@ -5,2 +5,3 @@ # @compas/cli

![lint-build-test](https://github.com/compasjs/compas/workflows/lint-build-test/badge.svg)
[![codecov](https://codecov.io/gh/compasjs/compas/branch/main/graph/badge.svg?token=81D84CV04U)](https://codecov.io/gh/compasjs/compas)

@@ -30,3 +31,3 @@ Unified backend tooling

My work involved doing many small projects. I had a hard time back-porting
My work involved doing many small projects. I had a hard time back porting
incremental fixes to existing projects. To facilitate my needs more and to stop

@@ -33,0 +34,0 @@ copying and pasting things around, this project was born.

import { pathToFileURL } from "url";
import {
AppError,
filenameForModule,

@@ -19,3 +20,13 @@ mainFn,

}
await import(pathToFileURL(file));
try {
await import(pathToFileURL(file));
} catch (e) {
throw AppError.serverError(
{
file,
},
e,
);
}
};

@@ -22,0 +33,0 @@

import { isNil } from "@compas/stdlib";
import { state } from "./state.js";
import { benchLogger, state } from "./state.js";

@@ -81,5 +81,10 @@ /**

while (i < InternalRunner.iterations.length) {
this.start = process.hrtime.bigint();
this.N = InternalRunner.iterations[i];
benchLogger.info({
name: this.state.name,
N: this.N,
});
this.start = process.hrtime.bigint();
const res = this.state.callback(createBenchRunner(this));

@@ -97,9 +102,9 @@ if (res && typeof res.then === "function") {

if (diff < 50_00_000) {
if (diff < 10_00_000) {
i = Math.min(i + 5, InternalRunner.iterations.length - 1);
} else if (diff < 50_000_000) {
i = Math.min(i + 4, InternalRunner.iterations.length - 1);
} else if (diff < 100_000_000) {
i = Math.min(i + 4, InternalRunner.iterations.length - 1);
i = Math.min(i + 3, InternalRunner.iterations.length - 1);
} else if (diff < 200_000_000) {
i = Math.min(i + 3, InternalRunner.iterations.length - 1);
} else if (diff < 300_000_000) {
i = Math.min(i + 2, InternalRunner.iterations.length - 1);

@@ -106,0 +111,0 @@ } else {

import { readFileSync } from "fs";
import { dirnameForModule, pathJoin } from "@compas/stdlib";
import {
dirnameForModule,
isNil,
pathJoin,
processDirectoryRecursiveSync,
} from "@compas/stdlib";

@@ -18,4 +23,6 @@ /**

const foundCompasVersions = findOtherCompasStdlibVersions(version);
let log = `${name} -- ${version}
${formatOtherVersions(foundCompasVersions)}
Usage:

@@ -67,1 +74,52 @@

}
/**
* @param {{ version: string, path: string }[]} versions
* @returns {string}
*/
function formatOtherVersions(versions) {
if (versions.length === 0) {
return "";
}
let result = `\nMultiple @compas versions found, to ensure a stable experience use the version that is commonly accepted by all your dependencies.\n`;
for (const { path, version } of versions) {
result += `@compas/stdlib@${version} - ${path}\n`;
}
return result;
}
/**
* Try to find other compas versions, by recursively going through the node_modules
*
* @param {string} cliVersion
* @returns {{ version: string, path: string }[]}
*/
function findOtherCompasStdlibVersions(cliVersion) {
const foundVersions = [];
processDirectoryRecursiveSync(
pathJoin(process.cwd()),
(file) => {
if (file.endsWith("/@compas/stdlib/package.json")) {
const { version } = JSON.parse(readFileSync(file, "utf-8"));
if (
cliVersion !== version &&
isNil(foundVersions.find((it) => it.version === version))
) {
foundVersions.push({
path: file,
version,
});
}
}
},
{
skipNodeModules: false,
},
);
return foundVersions;
}

@@ -12,14 +12,22 @@ import { createServer } from "http";

const verbose = command.arguments.indexOf("--verbose") !== -1;
const port = parseInt(
(environment.API_URL ?? environment.NEXT_PUBLIC_API_URL ?? "")
.split(":")
.pop(),
);
const apiUrlUsed =
environment.API_URL ?? environment.NEXT_PUBLIC_API_URL ?? "";
if (apiUrlUsed.length === 0) {
logger.error(
"Please add the `API_URL` or `NEXT_PUBLIC_API_URL` to your '.env' file.",
);
process.exit(1);
}
const port = parseInt(apiUrlUsed.split(":").pop());
if (isNaN(port)) {
logger.error(
"Please set the `API_URL` or `NEXT_PUBLIC_API_URL` environment variable",
"Make sure the `API_URL` or `NEXT_PUBLIC_API_URL` is in the format `http://localhost:$port` so the proxy knows on which port to listen.",
);
process.exit(1);
}
if ((environment.PROXY_URL ?? "").length === 0) {

@@ -26,0 +34,0 @@ logger.error("Please set the `PROXY_URL` environment variable");

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