🚀. Socket Launch Week Day 2:Introducing Manifest Alerts.Learn more
Sign In

@primitivedotdev/cli

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@primitivedotdev/cli - npm Package Compare versions

Comparing version
0.30.0
to
0.30.1
+6
-6
bin/run.js
#!/usr/bin/env node
import { execute } from "@oclif/core";
import { applyProxyAutoDetect } from "../dist/oclif/proxy-auto-detect.js";
import { restartWithProxyEnvIfNeeded } from "../dist/oclif/proxy-auto-detect.js";
// Auto-set NODE_USE_ENV_PROXY=1 when HTTP(S)_PROXY is in the env.
// Must run before any network init (e.g. before oclif loads commands
// that touch fetch). See proxy-auto-detect.ts for the full rationale.
applyProxyAutoDetect();
// Auto-restart with NODE_USE_ENV_PROXY=1 when HTTP(S)_PROXY is in the env.
// Node reads NODE_USE_ENV_PROXY during process startup, so mutating
// process.env inside this process is too late for built-in fetch.
restartWithProxyEnvIfNeeded();
const { execute } = await import("@oclif/core");
await execute({ dir: import.meta.url });

@@ -0,1 +1,2 @@

import { spawnSync } from "node:child_process";
//#region src/oclif/proxy-auto-detect.ts

@@ -18,3 +19,3 @@ const PROXY_ENV_VARS = [

}
function applyProxyAutoDetect(options = {}) {
function restartWithProxyEnvIfNeeded(options = {}) {
const env = options.env ?? process.env;

@@ -33,15 +34,40 @@ const stderr = options.stderr ?? process.stderr;

};
env.NODE_USE_ENV_PROXY = "1";
const argv = options.argv ?? process.argv;
const entrypoint = argv[1];
if (!entrypoint) return {
applied: false,
detectedVars,
reason: "missing_entrypoint"
};
const execPath = options.execPath ?? process.execPath;
const execArgv = options.execArgv ?? process.execArgv;
const spawn = options.spawn ?? spawnSync;
const exit = options.exit ?? ((code) => {
process.exit(code);
throw new Error("process.exit returned unexpectedly");
});
if (!hintPrinted) {
hintPrinted = true;
const names = detectedVars.join("/");
stderr.write(`primitive: proxy detected via ${names}, NODE_USE_ENV_PROXY=1 set automatically\n`);
stderr.write(`primitive: proxy detected via ${names}, restarting with NODE_USE_ENV_PROXY=1\n`);
}
return {
applied: true,
detectedVars,
reason: "applied"
};
const child = spawn(execPath, [
...execArgv,
entrypoint,
...argv.slice(2)
], {
env: {
...env,
NODE_USE_ENV_PROXY: "1"
},
stdio: "inherit"
});
if (child.error) throw child.error;
if (child.signal) {
(options.kill ?? process.kill)(options.pid ?? process.pid, child.signal);
return exit(1);
}
return exit(child.status ?? 1);
}
//#endregion
export { _resetHintLatchForTest, applyProxyAutoDetect };
export { _resetHintLatchForTest, restartWithProxyEnvIfNeeded };
{
"name": "@primitivedotdev/cli",
"version": "0.30.0",
"version": "0.30.1",
"description": "Official Primitive CLI: deploy Primitive Functions, send and inspect mail, manage endpoints, all from the terminal. Wraps the @primitivedotdev/sdk runtime client with one-shot commands.",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is too big to display