@socketsecurity/cli-with-sentry 1.8.4 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ var flags = require('./flags.js');
13
13
  var env = require('../external/@socketsecurity/registry/lib/env');
14
14
  var path = require('node:path');
15
15
  var words = require('../external/@socketsecurity/registry/lib/words');
16
- var fs$1 = require('node:fs');
16
+ var u = require('node:fs');
17
17
  var arrays = require('../external/@socketsecurity/registry/lib/arrays');
18
18
  var prompts = require('../external/@socketsecurity/registry/lib/prompts');
19
19
  var require$$0 = require('node:crypto');
@@ -21,7 +21,7 @@ var os = require('node:os');
21
21
  var spawn = require('../external/@socketsecurity/registry/lib/spawn');
22
22
  var bin = require('../external/@socketsecurity/registry/lib/bin');
23
23
  var childProcess = require('node:child_process');
24
- var fs$2 = require('../external/@socketsecurity/registry/lib/fs');
24
+ var fs$1 = require('../external/@socketsecurity/registry/lib/fs');
25
25
  var strings = require('../external/@socketsecurity/registry/lib/strings');
26
26
  var path$1 = require('../external/@socketsecurity/registry/lib/path');
27
27
  var objects = require('../external/@socketsecurity/registry/lib/objects');
@@ -1093,7 +1093,7 @@ async function fetchCreateOrgFullScan(packagePaths, orgSlug, config, options) {
1093
1093
  if (constants.default.ENV.SOCKET_CLI_DEBUG) {
1094
1094
  const fileInfo = await Promise.all(packagePaths.map(async p => {
1095
1095
  const absPath = path.resolve(process.cwd(), p);
1096
- const stat = await fs$1.promises.stat(absPath);
1096
+ const stat = await u.promises.stat(absPath);
1097
1097
  return {
1098
1098
  path: absPath,
1099
1099
  size: stat.size
@@ -2000,7 +2000,7 @@ async function performReachabilityAnalysis(options) {
2000
2000
  let sidecarPath;
2001
2001
  if (reachabilityOptions.dynamicSbomInference || resolvedPathsSidecar && hasResolvedPathsSidecarEntries(resolvedPathsSidecar)) {
2002
2002
  sidecarPath = path.join(os.tmpdir(), `socket-compute-artifacts-sidecar-${require$$0.randomUUID()}.json`);
2003
- await fs$1.promises.writeFile(sidecarPath, JSON.stringify(resolvedPathsSidecar ?? {}), 'utf8');
2003
+ await u.promises.writeFile(sidecarPath, JSON.stringify(resolvedPathsSidecar ?? {}), 'utf8');
2004
2004
  }
2005
2005
 
2006
2006
  // Build Coana arguments.
@@ -2030,7 +2030,7 @@ async function performReachabilityAnalysis(options) {
2030
2030
  const coanaStdio = outputKind === 'text' ? 'inherit' : ['inherit', 2, 'inherit'];
2031
2031
  try {
2032
2032
  // Run Coana with the manifests tar hash.
2033
- const coanaResult = await utils.spawnCoanaDlx(coanaArgs, orgSlug, {
2033
+ const coanaResult = await utils.spawnCoana(coanaArgs, orgSlug, {
2034
2034
  coanaVersion: reachabilityOptions.reachVersion,
2035
2035
  cwd,
2036
2036
  env: coanaEnv,
@@ -2041,7 +2041,7 @@ async function performReachabilityAnalysis(options) {
2041
2041
  spinner.start();
2042
2042
  }
2043
2043
  if (!coanaResult.ok) {
2044
- const coanaVersion = reachabilityOptions.reachVersion || constants.default.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION;
2044
+ const coanaVersion = reachabilityOptions.reachVersion || constants.COANA_CLI_VERSION;
2045
2045
  logger.logger.error(`Coana reachability analysis failed. Version: ${coanaVersion}, target: ${analysisTarget}, cwd: ${cwd}`);
2046
2046
  if (coanaResult.message) {
2047
2047
  logger.logger.error(`Details: ${coanaResult.message}`);
@@ -2069,7 +2069,7 @@ async function performReachabilityAnalysis(options) {
2069
2069
  // Best-effort cleanup of the temp sidecar.
2070
2070
  if (sidecarPath) {
2071
2071
  try {
2072
- await fs$1.promises.unlink(sidecarPath);
2072
+ await u.promises.unlink(sidecarPath);
2073
2073
  } catch {
2074
2074
  // File may already be gone or unwritable.
2075
2075
  }
@@ -2138,7 +2138,7 @@ async function addCoveredBuildFiles(covered, buildRoot, projects) {
2138
2138
  return path.join(await utils.realpathOrResolved(path.dirname(resolved)), path.basename(resolved));
2139
2139
  }));
2140
2140
  for (const file of files) {
2141
- if (file.startsWith(`${realBuildRoot}${path.sep}`) && fs$1.existsSync(file)) {
2141
+ if (file.startsWith(`${realBuildRoot}${path.sep}`) && u.existsSync(file)) {
2142
2142
  covered.add(file);
2143
2143
  }
2144
2144
  }
@@ -2317,14 +2317,14 @@ const ADDRESSED_BY_FILE = {
2317
2317
  // name, so an sbt run outside a build yields a plausible but bogus SBOM. Maven
2318
2318
  // and Gradle refuse such a directory themselves.
2319
2319
  function looksLikeSbtBuild(projectDir) {
2320
- return fs$1.existsSync(path.resolve(projectDir, 'build.sbt')) || fs$1.existsSync(path.resolve(projectDir, 'project'));
2320
+ return u.existsSync(path.resolve(projectDir, 'build.sbt')) || u.existsSync(path.resolve(projectDir, 'project'));
2321
2321
  }
2322
2322
  function resolveBuildToolBin(tool, projectDir, bin) {
2323
2323
  if (bin) {
2324
2324
  return bin;
2325
2325
  }
2326
2326
  const wrapperName = BUILD_TOOL_WRAPPER[tool];
2327
- if (wrapperName && fs$1.existsSync(path.resolve(projectDir, wrapperName))) {
2327
+ if (wrapperName && u.existsSync(path.resolve(projectDir, wrapperName))) {
2328
2328
  return `./${wrapperName}`;
2329
2329
  }
2330
2330
  return DEFAULT_BUILD_TOOL_BIN[tool];
@@ -2696,7 +2696,7 @@ function renderResolutionErrorReport(failures, scannedConfigs = [], tool = 'grad
2696
2696
 
2697
2697
  const PURL_TYPE_MAVEN = 'maven';
2698
2698
  function assembleFacts(parsed, opts = {}) {
2699
- const fileExists = opts.fileExists ?? fs$1.existsSync;
2699
+ const fileExists = opts.fileExists ?? u.existsSync;
2700
2700
  const perRoot = buildPerRoot(parsed);
2701
2701
  const finalNodes = mergeById(perRoot);
2702
2702
  const graphs = buildSubprojectGraphs(perRoot);
@@ -3471,15 +3471,15 @@ async function runNeverThrow(bin, args, opts) {
3471
3471
  }
3472
3472
  }
3473
3473
  async function writeSbtPlugin(globalBase, sourceFilename, destFilename) {
3474
- const src = await fs$1.promises.readFile(manifestScriptsPath(sourceFilename), 'utf8');
3474
+ const src = await u.promises.readFile(manifestScriptsPath(sourceFilename), 'utf8');
3475
3475
  const pluginsDir = path.join(globalBase, 'plugins');
3476
- await fs$1.promises.mkdir(pluginsDir, {
3476
+ await u.promises.mkdir(pluginsDir, {
3477
3477
  recursive: true
3478
3478
  });
3479
- await fs$1.promises.writeFile(path.join(pluginsDir, destFilename), src);
3479
+ await u.promises.writeFile(path.join(pluginsDir, destFilename), src);
3480
3480
  }
3481
3481
  async function assembleFromRecords(tool, out, recordsFile) {
3482
- const text = fs$1.existsSync(recordsFile) ? await fs$1.promises.readFile(recordsFile, 'utf8') : '';
3482
+ const text = u.existsSync(recordsFile) ? await u.promises.readFile(recordsFile, 'utf8') : '';
3483
3483
  const parsed = parseRecords(text);
3484
3484
  const factsFileName = socketFactsFileName(tool, parsed.entry || undefined);
3485
3485
  const {
@@ -3502,7 +3502,7 @@ async function assembleFromRecords(tool, out, recordsFile) {
3502
3502
  // Missing only in an unbuilt local checkout. Fail loudly: without the extension,
3503
3503
  // Maven silently emits an empty SBOM.
3504
3504
  function assertMavenExtensionBuilt(jarPath) {
3505
- if (fs$1.existsSync(jarPath)) {
3505
+ if (u.existsSync(jarPath)) {
3506
3506
  return;
3507
3507
  }
3508
3508
  throw new Error(`Maven manifest extension jar not found at ${jarPath}. It is bundled in the published CLI; for local dev build it with: bash src/commands/manifest/scripts/maven-extension/build-jar.sh`);
@@ -3799,14 +3799,14 @@ async function runManifestFacts({
3799
3799
  // Not a name producers write, so a copy here is stale and would be uploaded
3800
3800
  // alongside the new file.
3801
3801
  const legacyFactsPath = path.join(buildRoot, constants.default.DOT_SOCKET_DOT_FACTS_JSON);
3802
- if (fs$1.existsSync(legacyFactsPath)) {
3802
+ if (u.existsSync(legacyFactsPath)) {
3803
3803
  logger.logger.warn(`Found \`${legacyFactsPath}\`, which is uploaded alongside \`${factsFileName}\`. Delete it if an earlier \`socket manifest\` run left it behind.`);
3804
3804
  }
3805
3805
  const socketCliVersion = constants.default.ENV.INLINED_SOCKET_CLI_VERSION;
3806
3806
  if (facts.metadata && socketCliVersion) {
3807
3807
  facts.metadata.socketCliVersion = socketCliVersion;
3808
3808
  }
3809
- await fs$1.promises.writeFile(factsPath, JSON.stringify(facts), 'utf8');
3809
+ await u.promises.writeFile(factsPath, JSON.stringify(facts), 'utf8');
3810
3810
  if (sidecarAcc) {
3811
3811
  // Key by the symlink-resolved path so the sidecar's keys are comparable
3812
3812
  // regardless of which caller's cwd it was joined against (the recursive
@@ -4093,10 +4093,10 @@ async function runDynamicSbomInference({
4093
4093
 
4094
4094
  // Conda reads both spellings of the environment file.
4095
4095
  function findCondaFile(cwd) {
4096
- if (fs$1.existsSync(path.join(cwd, constants.ENVIRONMENT_YML))) {
4096
+ if (u.existsSync(path.join(cwd, constants.ENVIRONMENT_YML))) {
4097
4097
  return constants.ENVIRONMENT_YML;
4098
4098
  }
4099
- if (fs$1.existsSync(path.join(cwd, constants.ENVIRONMENT_YAML))) {
4099
+ if (u.existsSync(path.join(cwd, constants.ENVIRONMENT_YAML))) {
4100
4100
  return constants.ENVIRONMENT_YAML;
4101
4101
  }
4102
4102
  return '';
@@ -4118,21 +4118,21 @@ sockJson, cwd = process.cwd()) {
4118
4118
  };
4119
4119
  if (sockJson?.defaults?.manifest?.bazel?.disabled) {
4120
4120
  debug.debugLog('notice', `[DEBUG] - bazel auto-detection is disabled in ${constants.SOCKET_JSON}`);
4121
- } else if (fs$1.existsSync(path.join(cwd, 'MODULE.bazel')) || fs$1.existsSync(path.join(cwd, 'WORKSPACE')) || fs$1.existsSync(path.join(cwd, 'WORKSPACE.bazel'))) {
4121
+ } else if (u.existsSync(path.join(cwd, 'MODULE.bazel')) || u.existsSync(path.join(cwd, 'WORKSPACE')) || u.existsSync(path.join(cwd, 'WORKSPACE.bazel'))) {
4122
4122
  debug.debugLog('notice', '[DEBUG] - Detected a Bazel workspace');
4123
4123
  output.bazel = true;
4124
4124
  output.count += 1;
4125
4125
  }
4126
4126
  if (sockJson?.defaults?.manifest?.sbt?.disabled) {
4127
4127
  debug.debugLog('notice', `[DEBUG] - sbt auto-detection is disabled in ${constants.SOCKET_JSON}`);
4128
- } else if (fs$1.existsSync(path.join(cwd, 'build.sbt'))) {
4128
+ } else if (u.existsSync(path.join(cwd, 'build.sbt'))) {
4129
4129
  debug.debugLog('notice', '[DEBUG] - Detected a Scala sbt build file');
4130
4130
  output.sbt = true;
4131
4131
  output.count += 1;
4132
4132
  }
4133
4133
  if (sockJson?.defaults?.manifest?.gradle?.disabled) {
4134
4134
  debug.debugLog('notice', `[DEBUG] - gradle auto-detection is disabled in ${constants.SOCKET_JSON}`);
4135
- } else if (fs$1.existsSync(path.join(cwd, 'build.gradle')) || fs$1.existsSync(path.join(cwd, 'build.gradle.kts')) || fs$1.existsSync(path.join(cwd, 'settings.gradle')) || fs$1.existsSync(path.join(cwd, 'settings.gradle.kts'))) {
4135
+ } else if (u.existsSync(path.join(cwd, 'build.gradle')) || u.existsSync(path.join(cwd, 'build.gradle.kts')) || u.existsSync(path.join(cwd, 'settings.gradle')) || u.existsSync(path.join(cwd, 'settings.gradle.kts'))) {
4136
4136
  // Detect by build descriptor, not the `gradlew` wrapper (a project can build via
4137
4137
  // `gradle` on PATH). `settings.gradle(.kts)` covers Kotlin-DSL roots with no root build script.
4138
4138
  debug.debugLog('notice', '[DEBUG] - Detected a gradle build file');
@@ -4141,7 +4141,7 @@ sockJson, cwd = process.cwd()) {
4141
4141
  }
4142
4142
  if (sockJson?.defaults?.manifest?.maven?.disabled) {
4143
4143
  debug.debugLog('notice', `[DEBUG] - maven auto-detection is disabled in ${constants.SOCKET_JSON}`);
4144
- } else if (fs$1.existsSync(path.join(cwd, 'pom.xml'))) {
4144
+ } else if (u.existsSync(path.join(cwd, 'pom.xml'))) {
4145
4145
  debug.debugLog('notice', '[DEBUG] - Detected a Maven pom.xml build file');
4146
4146
  output.maven = true;
4147
4147
  output.count += 1;
@@ -4171,7 +4171,7 @@ sockJson, cwd = process.cwd()) {
4171
4171
  */
4172
4172
  async function resolveBazelBinary(explicit) {
4173
4173
  if (explicit) {
4174
- if (!fs$1.existsSync(explicit)) {
4174
+ if (!u.existsSync(explicit)) {
4175
4175
  throw new utils.InputError(`--bazel path does not exist: ${explicit}. Install bazelisk or bazel, or pass an existing path via --bazel.`);
4176
4176
  }
4177
4177
  return explicit;
@@ -4998,9 +4998,9 @@ function validateOutputBase(outputBase, cwd) {
4998
4998
  throw new utils.InputError(`--bazel-output-base must not contain '..' segments: ${outputBase}`);
4999
4999
  }
5000
5000
  const resolved = path.resolve(cwd, outputBase);
5001
- if (fs$1.existsSync(resolved)) {
5001
+ if (u.existsSync(resolved)) {
5002
5002
  try {
5003
- fs$1.accessSync(resolved, fs$1.constants.W_OK);
5003
+ u.accessSync(resolved, u.constants.W_OK);
5004
5004
  } catch {
5005
5005
  throw new utils.InputError(`--bazel-output-base is not writable: ${resolved}`);
5006
5006
  }
@@ -5008,7 +5008,7 @@ function validateOutputBase(outputBase, cwd) {
5008
5008
  }
5009
5009
  // Path does not exist yet — try to create it so bazel can populate it.
5010
5010
  try {
5011
- fs$1.mkdirSync(resolved, {
5011
+ u.mkdirSync(resolved, {
5012
5012
  recursive: true
5013
5013
  });
5014
5014
  } catch (e) {
@@ -5053,14 +5053,14 @@ async function provisionPythonShim() {
5053
5053
  throw new utils.InputError('Neither `python` nor `python3` found on PATH. Older versions of ' + 'rules_jvm_external require a `python` interpreter for repository ' + 'rules. Install Python 3 and ensure it is on PATH, then retry.');
5054
5054
  }
5055
5055
  const shimDir = path.join(os.tmpdir(), SHIM_SUBDIR);
5056
- fs$1.mkdirSync(shimDir, {
5056
+ u.mkdirSync(shimDir, {
5057
5057
  recursive: true
5058
5058
  });
5059
5059
  const linkPath = path.join(shimDir, 'python');
5060
5060
  // Replace the symlink defensively in case python3's resolved path moved.
5061
- if (fs$1.existsSync(linkPath)) {
5061
+ if (u.existsSync(linkPath)) {
5062
5062
  try {
5063
- fs$1.unlinkSync(linkPath);
5063
+ u.unlinkSync(linkPath);
5064
5064
  } catch {
5065
5065
  // Tolerate races; the next symlinkSync may still succeed.
5066
5066
  }
@@ -5070,9 +5070,9 @@ async function provisionPythonShim() {
5070
5070
  // unlinkSync and symlinkSync. Tolerate EEXIST when the link is back: the
5071
5071
  // other process won the race and left a usable shim in place.
5072
5072
  try {
5073
- fs$1.symlinkSync(python3OnPath, linkPath);
5073
+ u.symlinkSync(python3OnPath, linkPath);
5074
5074
  } catch (e) {
5075
- if (e.code === 'EEXIST' && fs$1.existsSync(linkPath)) ; else {
5075
+ if (e.code === 'EEXIST' && u.existsSync(linkPath)) ; else {
5076
5076
  throw e;
5077
5077
  }
5078
5078
  }
@@ -5355,8 +5355,8 @@ async function probeCandidate(repoName, probe, verbose) {
5355
5355
  // legacy WORKSPACE (WORKSPACE or WORKSPACE.bazel), or both (migration).
5356
5356
  // Throws InputError when neither marker file is present.
5357
5357
  function detectWorkspaceMode(cwd) {
5358
- const moduleBazel = fs$1.existsSync(path.join(cwd, 'MODULE.bazel'));
5359
- const workspaceFile = fs$1.existsSync(path.join(cwd, 'WORKSPACE')) || fs$1.existsSync(path.join(cwd, 'WORKSPACE.bazel'));
5358
+ const moduleBazel = u.existsSync(path.join(cwd, 'MODULE.bazel'));
5359
+ const workspaceFile = u.existsSync(path.join(cwd, 'WORKSPACE')) || u.existsSync(path.join(cwd, 'WORKSPACE.bazel'));
5360
5360
  if (!moduleBazel && !workspaceFile) {
5361
5361
  throw new utils.InputError(`No Bazel workspace found at ${cwd} (looked for MODULE.bazel, WORKSPACE, WORKSPACE.bazel).`);
5362
5362
  }
@@ -5448,7 +5448,7 @@ function findWorkspaceRoots(opts) {
5448
5448
  dirsVisited += 1;
5449
5449
  let entries;
5450
5450
  try {
5451
- entries = fs$1.readdirSync(dir, {
5451
+ entries = u.readdirSync(dir, {
5452
5452
  withFileTypes: true
5453
5453
  });
5454
5454
  } catch {
@@ -5745,7 +5745,7 @@ function committedLockfileCovers(args) {
5745
5745
  }
5746
5746
  let entries;
5747
5747
  try {
5748
- entries = fs$1.readdirSync(workspaceRootResolved, {
5748
+ entries = u.readdirSync(workspaceRootResolved, {
5749
5749
  withFileTypes: true
5750
5750
  });
5751
5751
  } catch {
@@ -5784,10 +5784,10 @@ async function writeCompletenessSummary(args) {
5784
5784
  workspaces: workspaceOutcomes
5785
5785
  };
5786
5786
  try {
5787
- fs$1.mkdirSync(manifestDir, {
5787
+ u.mkdirSync(manifestDir, {
5788
5788
  recursive: true
5789
5789
  });
5790
- await fs$1.promises.writeFile(path.join(manifestDir, COMPLETENESS_SUMMARY_FILE_NAME), JSON.stringify(summary, null, 2), 'utf8');
5790
+ await u.promises.writeFile(path.join(manifestDir, COMPLETENESS_SUMMARY_FILE_NAME), JSON.stringify(summary, null, 2), 'utf8');
5791
5791
  } catch (e) {
5792
5792
  if (verbose) {
5793
5793
  logger.logger.log(`[VERBOSE] completeness summary not written (${utils.getErrorCause(e)}); the run result still carries the signal`);
@@ -5826,11 +5826,11 @@ async function writeHubManifest(args) {
5826
5826
  }
5827
5827
  const fileName = hubManifestFileName(repoName);
5828
5828
  const hubDir = relPath ? path.join(manifestDir, relPath) : manifestDir;
5829
- fs$1.mkdirSync(hubDir, {
5829
+ u.mkdirSync(hubDir, {
5830
5830
  recursive: true
5831
5831
  });
5832
5832
  const manifestPath = path.join(hubDir, fileName);
5833
- await fs$1.promises.writeFile(manifestPath, JSON.stringify(json, null, 2), 'utf8');
5833
+ await u.promises.writeFile(manifestPath, JSON.stringify(json, null, 2), 'utf8');
5834
5834
  return {
5835
5835
  artifactCount,
5836
5836
  droppedArtifacts,
@@ -5957,7 +5957,7 @@ async function reapBazelServer(bin, outputUserRoot, verbose) {
5957
5957
  }
5958
5958
  async function removeTempdir(dir, verbose) {
5959
5959
  try {
5960
- await fs$1.promises.rm(dir, {
5960
+ await u.promises.rm(dir, {
5961
5961
  recursive: true,
5962
5962
  force: true
5963
5963
  });
@@ -5969,7 +5969,7 @@ async function removeTempdir(dir, verbose) {
5969
5969
  }
5970
5970
  }
5971
5971
  function makeOutputUserRoot() {
5972
- return fs$1.mkdtempSync(path.join(os.tmpdir(), 'socket-bazel-'));
5972
+ return u.mkdtempSync(path.join(os.tmpdir(), 'socket-bazel-'));
5973
5973
  }
5974
5974
 
5975
5975
  // Construct the BazelQueryOptions shape used for a single workspace's
@@ -6015,7 +6015,7 @@ async function extractBazelToMaven(opts) {
6015
6015
  logger.logger.group('bazel2maven:');
6016
6016
  logger.logger.info(`- src dir: \`${cwd}\``);
6017
6017
  logger.logger.info(`- out dir: \`${out}\``);
6018
- if (!fs$1.existsSync(cwd)) {
6018
+ if (!u.existsSync(cwd)) {
6019
6019
  logger.logger.warn(`Warning: cwd does not exist: ${cwd}`);
6020
6020
  }
6021
6021
  logger.logger.groupEnd();
@@ -6563,8 +6563,8 @@ async function convertGradleToMaven({
6563
6563
  // Note: use resolve because the bin could be an absolute path, away from cwd
6564
6564
  // TODO: what about $PATH resolved commands? (`gradlew` without dir prefix)
6565
6565
  const rBin = path.resolve(cwd, bin);
6566
- const binExists = fs$1.existsSync(rBin);
6567
- const cwdExists = fs$1.existsSync(cwd);
6566
+ const binExists = u.existsSync(rBin);
6567
+ const cwdExists = u.existsSync(cwd);
6568
6568
  logger.logger.group('gradle2maven:');
6569
6569
  logger.logger.info(`- executing: \`${rBin}\``);
6570
6570
  if (!binExists) {
@@ -6752,7 +6752,7 @@ async function convertSbtToMaven({
6752
6752
  // TODO: Maybe we can add an option to target a specific file to dump to stdout.
6753
6753
  if (out === '-' && poms.length === 1) {
6754
6754
  logger.logger.log('Result:\n```');
6755
- logger.logger.log(await fs$2.safeReadFile(poms[0]));
6755
+ logger.logger.log(await fs$1.safeReadFile(poms[0]));
6756
6756
  logger.logger.log('```');
6757
6757
  logger.logger.success(`OK`);
6758
6758
  } else if (out === '-') {
@@ -6791,11 +6791,11 @@ async function convertSbtToMaven({
6791
6791
  }
6792
6792
  try {
6793
6793
  // eslint-disable-next-line no-await-in-loop
6794
- await fs$1.promises.mkdir(path.dirname(destPath), {
6794
+ await u.promises.mkdir(path.dirname(destPath), {
6795
6795
  recursive: true
6796
6796
  });
6797
6797
  // eslint-disable-next-line no-await-in-loop
6798
- await fs$1.promises.copyFile(pomPath, destPath);
6798
+ await u.promises.copyFile(pomPath, destPath);
6799
6799
  copied.push(destPath);
6800
6800
  } catch (e) {
6801
6801
  logger.logger.warn(`Failed to copy \`${pomPath}\` to \`${destPath}\`: ${utils.getErrorCause(e)}`);
@@ -6869,14 +6869,14 @@ async function convertCondaToRequirements(filename, cwd, verbose) {
6869
6869
  if (verbose) {
6870
6870
  logger.logger.info(`[VERBOSE] target: ${filepath}`);
6871
6871
  }
6872
- if (!fs$1.existsSync(filepath)) {
6872
+ if (!u.existsSync(filepath)) {
6873
6873
  return {
6874
6874
  ok: false,
6875
6875
  message: 'Manifest Generation Failed',
6876
6876
  cause: `The file was not found at ${filepath}`
6877
6877
  };
6878
6878
  }
6879
- content = fs$1.readFileSync(filepath, 'utf8');
6879
+ content = u.readFileSync(filepath, 'utf8');
6880
6880
  if (!content) {
6881
6881
  return {
6882
6882
  ok: false,
@@ -6960,7 +6960,7 @@ async function outputRequirements(result, outputKind, out) {
6960
6960
  if (out === '-') {
6961
6961
  logger.logger.log(json);
6962
6962
  } else {
6963
- fs$1.writeFileSync(out, json, 'utf8');
6963
+ u.writeFileSync(out, json, 'utf8');
6964
6964
  }
6965
6965
  return;
6966
6966
  }
@@ -6978,7 +6978,7 @@ async function outputRequirements(result, outputKind, out) {
6978
6978
  if (out === '-') {
6979
6979
  logger.logger.log(md);
6980
6980
  } else {
6981
- fs$1.writeFileSync(out, md, 'utf8');
6981
+ u.writeFileSync(out, md, 'utf8');
6982
6982
  }
6983
6983
  return;
6984
6984
  }
@@ -6986,7 +6986,7 @@ async function outputRequirements(result, outputKind, out) {
6986
6986
  logger.logger.log(result.data.pip);
6987
6987
  logger.logger.log('');
6988
6988
  } else {
6989
- fs$1.writeFileSync(out, result.data.pip, 'utf8');
6989
+ u.writeFileSync(out, result.data.pip, 'utf8');
6990
6990
  }
6991
6991
  }
6992
6992
 
@@ -8982,7 +8982,7 @@ async function generateSocketFactsForFix({
8982
8982
  async function readStructuredDiscoveryResult(outputFile, silence) {
8983
8983
  let raw;
8984
8984
  try {
8985
- raw = await fs$1.promises.readFile(outputFile, 'utf8');
8985
+ raw = await u.promises.readFile(outputFile, 'utf8');
8986
8986
  } catch {
8987
8987
  return {
8988
8988
  ok: false,
@@ -9051,15 +9051,14 @@ async function discoverGhsaIds(orgSlug, tarHash, options) {
9051
9051
  // filteredArtifactCount }) via --output-file (available since coana 15.9.7,
9052
9052
  // older than the pinned @coana-tech/cli version).
9053
9053
  const outputFile = path.join(os.tmpdir(), `socket-fix-discovery-${Date.now()}.json`);
9054
- const foundCResult = await utils.spawnCoanaDlx(['find-vulnerabilities', cwd, '--manifests-tar-hash', tarHash, '--output-file', outputFile, ...(ecosystems?.length ? ['--purl-types', ...ecosystems] : []), ...(packageManagers?.length ? ['--package-managers', ...packageManagers] : []), ...factsFlags], orgSlug, {
9054
+ const foundCResult = await utils.spawnCoana(['find-vulnerabilities', cwd, '--manifests-tar-hash', tarHash, '--output-file', outputFile, ...(ecosystems?.length ? ['--purl-types', ...ecosystems] : []), ...(packageManagers?.length ? ['--package-managers', ...packageManagers] : []), ...factsFlags], orgSlug, {
9055
9055
  cwd,
9056
9056
  spinner: silence ? undefined : spinner,
9057
- coanaVersion: options?.coanaVersion
9058
- }, {
9057
+ coanaVersion: options?.coanaVersion,
9059
9058
  stdio: 'pipe'
9060
9059
  });
9061
9060
  if (!foundCResult.ok) {
9062
- await fs$1.promises.rm(outputFile, {
9061
+ await u.promises.rm(outputFile, {
9063
9062
  force: true
9064
9063
  }).catch(() => {});
9065
9064
  return foundCResult;
@@ -9067,7 +9066,7 @@ async function discoverGhsaIds(orgSlug, tarHash, options) {
9067
9066
  try {
9068
9067
  return await readStructuredDiscoveryResult(outputFile, silence);
9069
9068
  } finally {
9070
- await fs$1.promises.rm(outputFile, {
9069
+ await u.promises.rm(outputFile, {
9071
9070
  force: true
9072
9071
  }).catch(() => {});
9073
9072
  }
@@ -9091,7 +9090,7 @@ function selectFixedFiles(before, after, writtenFiles, scanBaseNames) {
9091
9090
  return [...after.modified.filter(isFromFix), ...after.untracked.filter(relPath => isFromFix(relPath) && (!!writtenFiles?.has(relPath) || scanBaseNames.has(path.basename(relPath))))];
9092
9091
  }
9093
9092
  function readWrittenFiles(outputFile) {
9094
- const result = fs$2.readJsonSync(outputFile, {
9093
+ const result = fs$1.readJsonSync(outputFile, {
9095
9094
  throws: false
9096
9095
  });
9097
9096
  const files = result?.modifiedFiles;
@@ -9301,7 +9300,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9301
9300
  const tmpDir = os.tmpdir();
9302
9301
  const tmpFile = path.join(tmpDir, `socket-fix-${Date.now()}.json`);
9303
9302
  try {
9304
- const fixCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...ids, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(include.length ? ['--include', ...include] : []), ...(coanaExcludePatterns.length ? ['--exclude', ...coanaExcludePatterns] : []), ...(ecosystems.length ? ['--purl-types', ...ecosystems] : []), ...(packageManagers.length ? ['--package-managers', ...packageManagers] : []), ...factsFlags, ...(!applyFixes ? [constants.FLAG_DRY_RUN] : []), '--output-file', tmpFile, ...(debug$1 ? ['--debug'] : []), ...(disableExternalToolChecks ? ['--disable-external-tool-checks'] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(allowOverrides ? ['--allow-overrides'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
9303
+ const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ...ids, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(include.length ? ['--include', ...include] : []), ...(coanaExcludePatterns.length ? ['--exclude', ...coanaExcludePatterns] : []), ...(ecosystems.length ? ['--purl-types', ...ecosystems] : []), ...(packageManagers.length ? ['--package-managers', ...packageManagers] : []), ...factsFlags, ...(!applyFixes ? [constants.FLAG_DRY_RUN] : []), '--output-file', tmpFile, ...(debug$1 ? ['--debug'] : []), ...(disableExternalToolChecks ? ['--disable-external-tool-checks'] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(allowOverrides ? ['--allow-overrides'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), ...fixConfig.unknownFlags], fixConfig.orgSlug, {
9305
9304
  coanaVersion,
9306
9305
  cwd,
9307
9306
  spinner: silence ? undefined : spinner,
@@ -9315,7 +9314,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9315
9314
  }
9316
9315
 
9317
9316
  // Read the temporary file to get the actual fixes result.
9318
- const fixesResultJson = fs$2.readJsonSync(tmpFile, {
9317
+ const fixesResultJson = fs$1.readJsonSync(tmpFile, {
9319
9318
  throws: false
9320
9319
  });
9321
9320
 
@@ -9324,8 +9323,8 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9324
9323
  if (!silence) {
9325
9324
  logger.logger.info(`Copying fixes result to ${outputFile}`);
9326
9325
  }
9327
- const tmpContent = await fs$1.promises.readFile(tmpFile, 'utf8');
9328
- await fs$1.promises.writeFile(outputFile, tmpContent, 'utf8');
9326
+ const tmpContent = await u.promises.readFile(tmpFile, 'utf8');
9327
+ await u.promises.writeFile(outputFile, tmpContent, 'utf8');
9329
9328
  }
9330
9329
  const ghsaDetails = fixesResultJson ? [fixesResultJson] : [];
9331
9330
  const notApplied = readNotAppliedFixes(fixesResultJson);
@@ -9351,7 +9350,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9351
9350
  } finally {
9352
9351
  // Clean up the temporary file.
9353
9352
  try {
9354
- await fs$1.promises.unlink(tmpFile);
9353
+ await u.promises.unlink(tmpFile);
9355
9354
  } catch {
9356
9355
  // Ignore cleanup errors.
9357
9356
  }
@@ -9446,7 +9445,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9446
9445
 
9447
9446
  // Apply fix for single GHSA ID.
9448
9447
  // eslint-disable-next-line no-await-in-loop
9449
- const fixCResult = await utils.spawnCoanaDlx(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ghsaId, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(include.length ? ['--include', ...include] : []), ...(coanaExcludePatterns.length ? ['--exclude', ...coanaExcludePatterns] : []), ...(ecosystems.length ? ['--purl-types', ...ecosystems] : []), ...(packageManagers.length ? ['--package-managers', ...packageManagers] : []), ...factsFlags, ...(debug$1 ? ['--debug'] : []), ...(disableExternalToolChecks ? ['--disable-external-tool-checks'] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(allowOverrides ? ['--allow-overrides'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), '--output-file', tmpFile, ...fixConfig.unknownFlags], fixConfig.orgSlug, {
9448
+ const fixCResult = await utils.spawnCoana(['compute-fixes-and-upgrade-purls', cwd, '--manifests-tar-hash', tarHash, '--apply-fixes-to', ghsaId, ...(fixConfig.rangeStyle ? ['--range-style', fixConfig.rangeStyle] : []), ...(minimumReleaseAge ? ['--minimum-release-age', minimumReleaseAge] : []), ...(include.length ? ['--include', ...include] : []), ...(coanaExcludePatterns.length ? ['--exclude', ...coanaExcludePatterns] : []), ...(ecosystems.length ? ['--purl-types', ...ecosystems] : []), ...(packageManagers.length ? ['--package-managers', ...packageManagers] : []), ...factsFlags, ...(debug$1 ? ['--debug'] : []), ...(disableExternalToolChecks ? ['--disable-external-tool-checks'] : []), ...(disableMajorUpdates ? ['--disable-major-updates'] : []), ...(allowOverrides ? ['--allow-overrides'] : []), ...(showAffectedDirectDependencies ? ['--show-affected-direct-dependencies'] : []), '--output-file', tmpFile, ...fixConfig.unknownFlags], fixConfig.orgSlug, {
9450
9449
  coanaVersion,
9451
9450
  cwd,
9452
9451
  spinner: silence ? undefined : spinner,
@@ -9454,7 +9453,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9454
9453
  });
9455
9454
  if (isFixesNotAppliedExit(fixCResult)) {
9456
9455
  if (!silence) {
9457
- logger.logger.warn(`Not every fix for ${ghsaId} was applied:\n${formatNotAppliedFixes(readNotAppliedFixes(fs$2.readJsonSync(tmpFile, {
9456
+ logger.logger.warn(`Not every fix for ${ghsaId} was applied:\n${formatNotAppliedFixes(readNotAppliedFixes(fs$1.readJsonSync(tmpFile, {
9458
9457
  throws: false
9459
9458
  })))}`);
9460
9459
  }
@@ -9465,7 +9464,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9465
9464
  // Clean up temp file on failure.
9466
9465
  try {
9467
9466
  // eslint-disable-next-line no-await-in-loop
9468
- await fs$1.promises.unlink(tmpFile);
9467
+ await u.promises.unlink(tmpFile);
9469
9468
  } catch {
9470
9469
  // Ignore cleanup errors.
9471
9470
  }
@@ -9479,7 +9478,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9479
9478
  // Clean up temp file before continuing.
9480
9479
  try {
9481
9480
  // eslint-disable-next-line no-await-in-loop
9482
- await fs$1.promises.unlink(tmpFile);
9481
+ await u.promises.unlink(tmpFile);
9483
9482
  } catch {
9484
9483
  // Ignore cleanup errors.
9485
9484
  }
@@ -9570,7 +9569,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9570
9569
  const prRef = `PR #${data.number}`;
9571
9570
 
9572
9571
  // Read the fix result JSON and merge with PR data.
9573
- const fixResultJson = fs$2.readJsonSync(tmpFile, {
9572
+ const fixResultJson = fs$1.readJsonSync(tmpFile, {
9574
9573
  throws: false
9575
9574
  });
9576
9575
  if (fixResultJson && typeof fixResultJson === 'object') {
@@ -9665,7 +9664,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9665
9664
  // Clean up temp file.
9666
9665
  try {
9667
9666
  // eslint-disable-next-line no-await-in-loop
9668
- await fs$1.promises.unlink(tmpFile);
9667
+ await u.promises.unlink(tmpFile);
9669
9668
  } catch {
9670
9669
  // Ignore cleanup errors.
9671
9670
  }
@@ -9880,7 +9879,7 @@ const DYNAMIC_SBOM_INFERENCE_DESCRIPTION = 'For Gradle, sbt, and Maven: generate
9880
9879
  const reachabilityFlags = {
9881
9880
  reachVersion: {
9882
9881
  type: 'string',
9883
- description: `Override the version of @coana-tech/cli used for reachability analysis. Default: ${constants.default.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION}.`
9882
+ description: `Override the version of @coana-tech/cli used for reachability analysis. Default: ${constants.COANA_CLI_VERSION}.`
9884
9883
  },
9885
9884
  reachAnalysisMemoryLimit: {
9886
9885
  type: 'string',
@@ -10016,7 +10015,7 @@ const generalFlags$2 = {
10016
10015
  },
10017
10016
  fixVersion: {
10018
10017
  type: 'string',
10019
- description: `Override the version of @coana-tech/cli used for fix analysis. Default: ${constants.default.ENV.INLINED_SOCKET_CLI_COANA_TECH_CLI_VERSION}.`
10018
+ description: `Override the version of @coana-tech/cli used for fix analysis. Default: ${constants.COANA_CLI_VERSION}.`
10020
10019
  },
10021
10020
  applyFixes: {
10022
10021
  aliases: ['onlyCompute'],
@@ -10342,7 +10341,7 @@ async function run$N(argv, importMeta, {
10342
10341
  cwd = path.resolve(process.cwd(), cwd);
10343
10342
 
10344
10343
  // Validate the target directory exists.
10345
- if (!fs$1.existsSync(cwd)) {
10344
+ if (!u.existsSync(cwd)) {
10346
10345
  logger.logger.fail(`Target directory does not exist: ${cwd}`);
10347
10346
  process.exitCode = 1;
10348
10347
  return;
@@ -10451,9 +10450,9 @@ async function setupTabCompletion(targetName) {
10451
10450
  // Target dir is something like ~/.local/share/socket/settings/completion (linux)
10452
10451
  const targetDir = path.dirname(targetPath);
10453
10452
  debug.debugFn('notice', 'target: path + dir', targetPath, targetDir);
10454
- if (!fs$1.existsSync(targetDir)) {
10453
+ if (!u.existsSync(targetDir)) {
10455
10454
  debug.debugFn('notice', 'create: target dir');
10456
- fs$1.mkdirSync(targetDir, {
10455
+ u.mkdirSync(targetDir, {
10457
10456
  recursive: true
10458
10457
  });
10459
10458
  }
@@ -10462,11 +10461,11 @@ async function setupTabCompletion(targetName) {
10462
10461
 
10463
10462
  // Add to ~/.bashrc if not already there
10464
10463
  const bashrcPath = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
10465
- const foundBashrc = Boolean(bashrcPath && fs$1.existsSync(bashrcPath));
10464
+ const foundBashrc = Boolean(bashrcPath && u.existsSync(bashrcPath));
10466
10465
  if (foundBashrc) {
10467
- const content = fs$1.readFileSync(bashrcPath, 'utf8');
10466
+ const content = u.readFileSync(bashrcPath, 'utf8');
10468
10467
  if (!content.includes(sourcingCommand)) {
10469
- fs$1.appendFileSync(bashrcPath, toAddToBashrc);
10468
+ u.appendFileSync(bashrcPath, toAddToBashrc);
10470
10469
  bashrcUpdated = true;
10471
10470
  }
10472
10471
  }
@@ -10487,7 +10486,7 @@ async function setupTabCompletion(targetName) {
10487
10486
  function getTabCompletionScriptRaw() {
10488
10487
  const sourceDir = path.dirname(require$$0$1.fileURLToPath((typeof document === 'undefined' ? require$$0$1.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href))));
10489
10488
  const sourcePath = path.join(sourceDir, 'socket-completion.bash');
10490
- if (!fs$1.existsSync(sourcePath)) {
10489
+ if (!u.existsSync(sourcePath)) {
10491
10490
  return {
10492
10491
  ok: false,
10493
10492
  message: 'Source not found.',
@@ -10496,7 +10495,7 @@ function getTabCompletionScriptRaw() {
10496
10495
  }
10497
10496
  return {
10498
10497
  ok: true,
10499
- data: fs$1.readFileSync(sourcePath, 'utf8')
10498
+ data: u.readFileSync(sourcePath, 'utf8')
10500
10499
  };
10501
10500
  }
10502
10501
  function updateInstalledTabCompletionScript(targetPath) {
@@ -10507,7 +10506,7 @@ function updateInstalledTabCompletionScript(targetPath) {
10507
10506
 
10508
10507
  // When installing set the current package.json version.
10509
10508
  // Later, we can call _socket_completion_version to get the installed version.
10510
- fs$1.writeFileSync(targetPath, content.data.replaceAll('%SOCKET_VERSION_TOKEN%', constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH), 'utf8');
10509
+ u.writeFileSync(targetPath, content.data.replaceAll('%SOCKET_VERSION_TOKEN%', constants.default.ENV.INLINED_SOCKET_CLI_VERSION_HASH), 'utf8');
10511
10510
  return {
10512
10511
  ok: true,
10513
10512
  data: undefined
@@ -10602,19 +10601,19 @@ async function outputCmdJson(cwd) {
10602
10601
  logger.logger.info('Target cwd:', constants.default.ENV.VITEST ? constants.REDACTED : utils.tildify(cwd));
10603
10602
  const sockJsonPath = path.join(cwd, constants.SOCKET_JSON);
10604
10603
  const tildeSockJsonPath = constants.default.ENV.VITEST ? constants.REDACTED : utils.tildify(sockJsonPath);
10605
- if (!fs$1.existsSync(sockJsonPath)) {
10604
+ if (!u.existsSync(sockJsonPath)) {
10606
10605
  logger.logger.fail(`Not found: ${tildeSockJsonPath}`);
10607
10606
  process.exitCode = 1;
10608
10607
  return;
10609
10608
  }
10610
- if (!fs$2.safeStatsSync(sockJsonPath)?.isFile()) {
10609
+ if (!fs$1.safeStatsSync(sockJsonPath)?.isFile()) {
10611
10610
  logger.logger.fail(`This is not a regular file (maybe a directory?): ${tildeSockJsonPath}`);
10612
10611
  process.exitCode = 1;
10613
10612
  return;
10614
10613
  }
10615
10614
  logger.logger.success(`This is the contents of ${tildeSockJsonPath}:`);
10616
10615
  logger.logger.error('');
10617
- const data = fs$2.safeReadFileSync(sockJsonPath);
10616
+ const data = fs$1.safeReadFileSync(sockJsonPath);
10618
10617
  logger.logger.log(data);
10619
10618
  }
10620
10619
 
@@ -11018,13 +11017,13 @@ async function runCdxgen(argvObj) {
11018
11017
  try {
11019
11018
  // TODO: Consider using trash instead of rmSync for safer deletion.
11020
11019
  // This removes the temporary package-lock.json we created for cdxgen.
11021
- fs$1.rmSync(`./${PACKAGE_LOCK_JSON}`);
11020
+ u.rmSync(`./${PACKAGE_LOCK_JSON}`);
11022
11021
  } catch {}
11023
11022
  }
11024
11023
  const outputPath = argvMutable['output'];
11025
11024
  if (outputPath) {
11026
11025
  const fullOutputPath = path.join(process.cwd(), outputPath);
11027
- if (fs$1.existsSync(fullOutputPath)) {
11026
+ if (u.existsSync(fullOutputPath)) {
11028
11027
  logger.logger.log(vendor.yoctocolorsCjsExports.cyanBright(`${outputPath} created!`));
11029
11028
  }
11030
11029
  }
@@ -11463,15 +11462,15 @@ function parseBazelModPipExtensionCandidates(stdout, verbose) {
11463
11462
  // Reads file contents, refusing files that exceed MAX_WORKSPACE_FILE_BYTES.
11464
11463
  // Returns null when the file is missing, oversized, or unreadable.
11465
11464
  function safeReadFile(file) {
11466
- if (!fs$1.existsSync(file)) {
11465
+ if (!u.existsSync(file)) {
11467
11466
  return null;
11468
11467
  }
11469
11468
  try {
11470
- const stat = fs$1.statSync(file);
11469
+ const stat = u.statSync(file);
11471
11470
  if (stat.size > MAX_WORKSPACE_FILE_BYTES) {
11472
11471
  return null;
11473
11472
  }
11474
- return fs$1.readFileSync(file, 'utf8');
11473
+ return u.readFileSync(file, 'utf8');
11475
11474
  } catch {
11476
11475
  return null;
11477
11476
  }
@@ -11485,13 +11484,13 @@ function listLegacyStarlarkFiles(cwd) {
11485
11484
  const candidates = ['WORKSPACE', 'WORKSPACE.bazel'];
11486
11485
  for (const c of candidates) {
11487
11486
  const p = path.join(cwd, c);
11488
- if (fs$1.existsSync(p)) {
11487
+ if (u.existsSync(p)) {
11489
11488
  files.push(p);
11490
11489
  }
11491
11490
  }
11492
11491
  // Top-level .bzl files only.
11493
11492
  try {
11494
- for (const entry of fs$1.readdirSync(cwd)) {
11493
+ for (const entry of u.readdirSync(cwd)) {
11495
11494
  if (entry.endsWith('.bzl')) {
11496
11495
  files.push(path.join(cwd, entry));
11497
11496
  }
@@ -11886,16 +11885,16 @@ function readRequirementsLockFile(resolvedPath) {
11886
11885
  if (!resolvedPath) {
11887
11886
  return undefined;
11888
11887
  }
11889
- if (!fs$1.existsSync(resolvedPath)) {
11888
+ if (!u.existsSync(resolvedPath)) {
11890
11889
  return undefined;
11891
11890
  }
11892
11891
  let text;
11893
11892
  try {
11894
- const stat = fs$1.statSync(resolvedPath);
11893
+ const stat = u.statSync(resolvedPath);
11895
11894
  if (stat.size > MAX_REQUIREMENTS_FILE_BYTES) {
11896
11895
  return undefined;
11897
11896
  }
11898
- text = fs$1.readFileSync(resolvedPath, 'utf8');
11897
+ text = u.readFileSync(resolvedPath, 'utf8');
11899
11898
  } catch {
11900
11899
  return undefined;
11901
11900
  }
@@ -12028,7 +12027,7 @@ async function extractBazelToPypi(opts) {
12028
12027
  logger.logger.group('bazel2pypi:');
12029
12028
  logger.logger.info(`- src dir: \`${cwd}\``);
12030
12029
  logger.logger.info(`- out dir: \`${out}\``);
12031
- if (!fs$1.existsSync(cwd)) {
12030
+ if (!u.existsSync(cwd)) {
12032
12031
  logger.logger.warn(`Warning: cwd does not exist: ${cwd}`);
12033
12032
  }
12034
12033
  logger.logger.groupEnd();
@@ -12166,11 +12165,11 @@ async function extractBazelToPypi(opts) {
12166
12165
  const lines = sorted.map(p => `${p.name}==${p.version}\n`);
12167
12166
  const layout = opts.outLayout ?? 'standalone';
12168
12167
  const manifestDir = layout === 'flat' ? path.join(out, '.socket-auto-manifest') : out;
12169
- fs$1.mkdirSync(manifestDir, {
12168
+ u.mkdirSync(manifestDir, {
12170
12169
  recursive: true
12171
12170
  });
12172
12171
  const manifestPath = path.join(manifestDir, 'requirements.txt');
12173
- await fs$1.promises.writeFile(manifestPath, lines.join(''), 'utf8');
12172
+ await u.promises.writeFile(manifestPath, lines.join(''), 'utf8');
12174
12173
  if (verbose) {
12175
12174
  logger.logger.log('[VERBOSE] outputs:', {
12176
12175
  artifactCount: allLines.length,
@@ -14071,7 +14070,7 @@ async function setupManifestConfig(cwd, defaultOnReadError = false) {
14071
14070
  // - record them to the socket.yml (or socket-cli.yml ? or just socket.json ?)
14072
14071
 
14073
14072
  const jsonPath = path.join(cwd, constants.SOCKET_JSON);
14074
- if (fs$1.existsSync(jsonPath)) {
14073
+ if (u.existsSync(jsonPath)) {
14075
14074
  logger.logger.info(`Found ${constants.SOCKET_JSON} at ${jsonPath}`);
14076
14075
  } else {
14077
14076
  logger.logger.info(`No ${constants.SOCKET_JSON} found at ${cwd}, will generate a new one`);
@@ -15251,7 +15250,7 @@ async function askYesNo(message) {
15251
15250
  // normal, not an abort.
15252
15251
  async function setupRecursiveRootDefaults(cwd, defaultOnReadError, ecosystems, ecosystemsAtCwd) {
15253
15252
  const jsonPath = path.join(cwd, constants.SOCKET_JSON);
15254
- if (fs$1.existsSync(jsonPath)) {
15253
+ if (u.existsSync(jsonPath)) {
15255
15254
  logger.logger.info(`Found ${constants.SOCKET_JSON} at ${jsonPath}`);
15256
15255
  } else {
15257
15256
  logger.logger.info(`No ${constants.SOCKET_JSON} found at ${cwd}, will generate a new one`);
@@ -18406,7 +18405,7 @@ function resolveSocketPatchBin() {
18406
18405
  let dir = __dirname;
18407
18406
  for (let i = 0; i < 10; i += 1) {
18408
18407
  const candidate = path.join(dir, 'node_modules', '.bin', 'socket-patch');
18409
- if (fs$1.existsSync(candidate)) {
18408
+ if (u.existsSync(candidate)) {
18410
18409
  return candidate;
18411
18410
  }
18412
18411
  const parent = path.dirname(dir);
@@ -19760,7 +19759,7 @@ async function generateUvMemberSboms(memberDirs) {
19760
19759
  const files = [];
19761
19760
  const removeFilesSync = () => {
19762
19761
  for (const file of files) {
19763
- fs$1.rmSync(file, {
19762
+ u.rmSync(file, {
19764
19763
  force: true
19765
19764
  });
19766
19765
  }
@@ -19776,7 +19775,7 @@ async function generateUvMemberSboms(memberDirs) {
19776
19775
  for (const signal of CLEANUP_SIGNALS) {
19777
19776
  process.removeListener(signal, removeFilesSync);
19778
19777
  }
19779
- await Promise.all(files.map(file => fs$1.promises.rm(file, {
19778
+ await Promise.all(files.map(file => u.promises.rm(file, {
19780
19779
  force: true
19781
19780
  })));
19782
19781
  };
@@ -19786,7 +19785,7 @@ async function generateUvMemberSboms(memberDirs) {
19786
19785
  // and the reachability target line up with the member directory.
19787
19786
  const filename = path.join(memberDirs[i], UV_SBOM_FILENAME);
19788
19787
  // eslint-disable-next-line no-await-in-loop
19789
- await fs$1.promises.writeFile(filename, JSON.stringify(sboms[i]), {
19788
+ await u.promises.writeFile(filename, JSON.stringify(sboms[i]), {
19790
19789
  flag: 'wx'
19791
19790
  });
19792
19791
  files.push(filename);
@@ -19805,13 +19804,13 @@ function resolveUvMemberDirs(targets, cwd) {
19805
19804
  for (const target of targets) {
19806
19805
  const memberDir = path.resolve(cwd, target);
19807
19806
  const relativeDir = path.relative(cwd, memberDir);
19808
- if (relativeDir === '..' || relativeDir.startsWith(`..${path.sep}`) || path.isAbsolute(relativeDir) || !fs$2.isDirSync(memberDir)) {
19807
+ if (relativeDir === '..' || relativeDir.startsWith(`..${path.sep}`) || path.isAbsolute(relativeDir) || !fs$1.isDirSync(memberDir)) {
19809
19808
  throw new utils.InputError(`--uv-members requires every TARGET to be a directory inside --cwd, but got ${target}`);
19810
19809
  }
19811
- if (!fs$1.existsSync(path.join(memberDir, 'pyproject.toml'))) {
19810
+ if (!u.existsSync(path.join(memberDir, 'pyproject.toml'))) {
19812
19811
  throw new utils.InputError(`--uv-members requires a pyproject.toml in every TARGET, but ${target} has none`);
19813
19812
  }
19814
- if (fs$1.existsSync(path.join(memberDir, UV_SBOM_FILENAME))) {
19813
+ if (u.existsSync(path.join(memberDir, UV_SBOM_FILENAME))) {
19815
19814
  throw new utils.InputError(`${path.join(target, UV_SBOM_FILENAME)} already exists. Remove it and run the scan again.`);
19816
19815
  }
19817
19816
  memberDirs.add(memberDir);
@@ -19864,9 +19863,9 @@ async function validateReachabilityTarget(targets, cwd) {
19864
19863
  // Check if target is inside cwd.
19865
19864
  const relativePath = path.relative(absoluteCwd, targetPath);
19866
19865
  result.isInsideCwd = !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
19867
- result.targetExists = fs$1.existsSync(targetPath);
19866
+ result.targetExists = u.existsSync(targetPath);
19868
19867
  if (result.targetExists) {
19869
- const targetStat = await fs$1.promises.stat(targetPath);
19868
+ const targetStat = await u.promises.stat(targetPath);
19870
19869
  result.isDirectory = targetStat.isDirectory();
19871
19870
  }
19872
19871
  return result;
@@ -19990,7 +19989,7 @@ const generalFlags$1 = {
19990
19989
  };
19991
19990
  function hasSocketFactsFileIn(dir) {
19992
19991
  try {
19993
- return fs$1.readdirSync(dir).some(utils.isSocketFactsFile);
19992
+ return u.readdirSync(dir).some(utils.isSocketFactsFile);
19994
19993
  } catch {
19995
19994
  return false;
19996
19995
  }
@@ -20562,7 +20561,7 @@ async function handleJson(data, file, dashboardMessage) {
20562
20561
  const json = utils.serializeResultJson(data);
20563
20562
  if (file && file !== '-') {
20564
20563
  logger.logger.log(`Writing json to \`${file}\``);
20565
- fs$1.writeFile(file, json, err => {
20564
+ u.writeFile(file, json, err => {
20566
20565
  if (err) {
20567
20566
  logger.logger.fail(`Writing to \`${file}\` failed...`);
20568
20567
  logger.logger.error(err);
@@ -21018,7 +21017,7 @@ async function scanOneRepo(repoSlug, {
21018
21017
  }
21019
21018
  };
21020
21019
  }
21021
- const tmpDir = fs$1.mkdtempSync(path.join(os.tmpdir(), repoSlug));
21020
+ const tmpDir = u.mkdtempSync(path.join(os.tmpdir(), repoSlug));
21022
21021
  debug.debugFn('notice', 'init: temp dir for scan root', tmpDir);
21023
21022
  const downloadResult = await testAndDownloadManifestFiles({
21024
21023
  files,
@@ -21293,12 +21292,12 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
21293
21292
  // Make sure the dir exists. It may be nested and we need to construct that
21294
21293
  // before starting the download.
21295
21294
  const dir = path.dirname(localPath);
21296
- if (!fs$1.existsSync(dir)) {
21297
- fs$1.mkdirSync(dir, {
21295
+ if (!u.existsSync(dir)) {
21296
+ u.mkdirSync(dir, {
21298
21297
  recursive: true
21299
21298
  });
21300
21299
  }
21301
- const fileStream = fs$1.createWriteStream(localPath);
21300
+ const fileStream = u.createWriteStream(localPath);
21302
21301
 
21303
21302
  // Using stream.pipeline for better error handling and cleanup
21304
21303
 
@@ -21317,11 +21316,11 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
21317
21316
  debug.debugDir('error', e);
21318
21317
 
21319
21318
  // If an error occurs and fileStream was created, attempt to clean up.
21320
- if (fs$1.existsSync(localPath)) {
21319
+ if (u.existsSync(localPath)) {
21321
21320
  // Check if fileStream was even opened before trying to delete
21322
21321
  // This check might be too simplistic depending on when error occurs
21323
21322
  try {
21324
- await fs$1.promises.unlink(localPath);
21323
+ await u.promises.unlink(localPath);
21325
21324
  } catch (e) {
21326
21325
  logger.logger.fail(utils.formatErrorWithDetail(`Error deleting partial file ${localPath}`, e));
21327
21326
  }
@@ -22764,7 +22763,7 @@ async function outputScanConfigResult(result) {
22764
22763
 
22765
22764
  async function setupScanConfig(cwd, defaultOnReadError = false) {
22766
22765
  const jsonPath = path.join(cwd, constants.SOCKET_JSON);
22767
- if (fs$1.existsSync(jsonPath)) {
22766
+ if (u.existsSync(jsonPath)) {
22768
22767
  logger.logger.info(`Found ${constants.SOCKET_JSON} at ${jsonPath}`);
22769
22768
  } else {
22770
22769
  logger.logger.info(`No ${constants.SOCKET_JSON} found at ${cwd}, will generate a new one`);
@@ -23870,15 +23869,15 @@ async function teardownTabCompletion(targetName) {
23870
23869
 
23871
23870
  // Remove from ~/.bashrc if found
23872
23871
  const bashrc = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
23873
- if (bashrc && fs$1.existsSync(bashrc)) {
23874
- const content = fs$1.readFileSync(bashrc, 'utf8');
23872
+ if (bashrc && u.existsSync(bashrc)) {
23873
+ const content = u.readFileSync(bashrc, 'utf8');
23875
23874
  if (content.includes(toAddToBashrc)) {
23876
23875
  const newContent = content
23877
23876
  // Try to remove the whole thing with comment first
23878
23877
  .replaceAll(toAddToBashrc, '')
23879
23878
  // Comment may have been edited away, try to remove the command at least
23880
23879
  .replaceAll(sourcingCommand, '').replaceAll(completionCommand, '');
23881
- fs$1.writeFileSync(bashrc, newContent, 'utf8');
23880
+ u.writeFileSync(bashrc, newContent, 'utf8');
23882
23881
  return {
23883
23882
  ok: true,
23884
23883
  data: {
@@ -23991,7 +23990,7 @@ const cmdUninstall = {
23991
23990
  };
23992
23991
 
23993
23992
  function addSocketWrapper(file) {
23994
- return fs$1.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
23993
+ return u.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
23995
23994
  if (err) {
23996
23995
  return new Error(`There was an error setting up the alias: ${err}`);
23997
23996
  }
@@ -24008,7 +24007,7 @@ function addSocketWrapper(file) {
24008
24007
  }
24009
24008
 
24010
24009
  function checkSocketWrapperSetup(file) {
24011
- const fileContent = fs$1.readFileSync(file, 'utf8');
24010
+ const fileContent = u.readFileSync(file, 'utf8');
24012
24011
  const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
24013
24012
  if (linesWithSocketAlias.length) {
24014
24013
  logger.logger.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
@@ -24027,7 +24026,7 @@ async function postinstallWrapper() {
24027
24026
  bashRcPath,
24028
24027
  zshRcPath
24029
24028
  } = constants.default;
24030
- const socketWrapperEnabled = fs$1.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || fs$1.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
24029
+ const socketWrapperEnabled = u.existsSync(bashRcPath) && checkSocketWrapperSetup(bashRcPath) || u.existsSync(zshRcPath) && checkSocketWrapperSetup(zshRcPath);
24031
24030
  if (!socketWrapperEnabled) {
24032
24031
  await setupShadowNpm(`
24033
24032
  The Socket CLI is now successfully installed! 🎉
@@ -24043,7 +24042,7 @@ Do you want to install the Socket npm wrapper (this will create an alias to the
24043
24042
  try {
24044
24043
  const details = utils.getBashrcDetails(''); // Note: command is not relevant, we just want the config path
24045
24044
  if (details.ok) {
24046
- if (fs$1.existsSync(details.data.targetPath)) {
24045
+ if (u.existsSync(details.data.targetPath)) {
24047
24046
  // Replace the file with the one from this installation
24048
24047
  const result = updateInstalledTabCompletionScript(details.data.targetPath);
24049
24048
  if (result.ok) {
@@ -24082,10 +24081,10 @@ async function setupShadowNpm(query) {
24082
24081
  zshRcPath
24083
24082
  } = constants.default;
24084
24083
  try {
24085
- if (fs$1.existsSync(bashRcPath)) {
24084
+ if (u.existsSync(bashRcPath)) {
24086
24085
  addSocketWrapper(bashRcPath);
24087
24086
  }
24088
- if (fs$1.existsSync(zshRcPath)) {
24087
+ if (u.existsSync(zshRcPath)) {
24089
24088
  addSocketWrapper(zshRcPath);
24090
24089
  }
24091
24090
  } catch (e) {
@@ -24097,7 +24096,7 @@ async function setupShadowNpm(query) {
24097
24096
  function removeSocketWrapper(filepath) {
24098
24097
  let content;
24099
24098
  try {
24100
- content = fs$1.readFileSync(filepath, 'utf8');
24099
+ content = u.readFileSync(filepath, 'utf8');
24101
24100
  } catch (e) {
24102
24101
  logger.logger.fail(`There was an error removing the alias${e ? ':' : '.'}`);
24103
24102
  if (e) {
@@ -24108,7 +24107,7 @@ function removeSocketWrapper(filepath) {
24108
24107
  const linesWithoutSocketAlias = content.split('\n').filter(l => l !== 'alias npm="socket npm"' && l !== 'alias npx="socket npx"');
24109
24108
  const updatedContent = linesWithoutSocketAlias.join('\n');
24110
24109
  try {
24111
- fs$1.writeFileSync(filepath, updatedContent, 'utf8');
24110
+ u.writeFileSync(filepath, updatedContent, 'utf8');
24112
24111
  } catch (e) {
24113
24112
  if (e) {
24114
24113
  logger.logger.error(e);
@@ -24202,21 +24201,21 @@ async function run$1(argv, importMeta, {
24202
24201
  zshRcPath
24203
24202
  } = constants.default;
24204
24203
  if (enable) {
24205
- if (fs$1.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
24204
+ if (u.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
24206
24205
  addSocketWrapper(bashRcPath);
24207
24206
  }
24208
- if (fs$1.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
24207
+ if (u.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
24209
24208
  addSocketWrapper(zshRcPath);
24210
24209
  }
24211
24210
  } else {
24212
- if (fs$1.existsSync(bashRcPath)) {
24211
+ if (u.existsSync(bashRcPath)) {
24213
24212
  removeSocketWrapper(bashRcPath);
24214
24213
  }
24215
- if (fs$1.existsSync(zshRcPath)) {
24214
+ if (u.existsSync(zshRcPath)) {
24216
24215
  removeSocketWrapper(zshRcPath);
24217
24216
  }
24218
24217
  }
24219
- if (!fs$1.existsSync(bashRcPath) && !fs$1.existsSync(zshRcPath)) {
24218
+ if (!u.existsSync(bashRcPath) && !u.existsSync(zshRcPath)) {
24220
24219
  logger.logger.fail('There was an issue setting up the alias in your bash profile');
24221
24220
  }
24222
24221
  }
@@ -24540,5 +24539,5 @@ process.on('unhandledRejection', async (reason, promise) => {
24540
24539
  // eslint-disable-next-line n/no-process-exit
24541
24540
  process.exit(1);
24542
24541
  });
24543
- //# debugId=f7aeb17e-13e2-4a73-b5ed-da37ea72d476
24542
+ //# debugId=c715fb1e-bcb7-40c4-b394-2bc4db5e64a
24544
24543
  //# sourceMappingURL=cli.js.map