@socketsecurity/cli-with-sentry 1.8.3 → 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,13 +9090,14 @@ 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;
9098
9097
  return Array.isArray(files) && files.every(f => typeof f === 'string') ? new Set(files) : undefined;
9099
9098
  }
9100
9099
  // Coana exits with this code after writing an --output-file that lists computed fixes it left unapplied.
9100
+ // Local mode exits with it too, so automation can tell unapplied fixes from a failed run.
9101
9101
  const COANA_FIXES_NOT_APPLIED_EXIT_CODE = 5;
9102
9102
  function isFixesNotAppliedExit(result) {
9103
9103
  return !result.ok && result.data?.code === COANA_FIXES_NOT_APPLIED_EXIT_CODE;
@@ -9300,7 +9300,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9300
9300
  const tmpDir = os.tmpdir();
9301
9301
  const tmpFile = path.join(tmpDir, `socket-fix-${Date.now()}.json`);
9302
9302
  try {
9303
- 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, {
9304
9304
  coanaVersion,
9305
9305
  cwd,
9306
9306
  spinner: silence ? undefined : spinner,
@@ -9314,7 +9314,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9314
9314
  }
9315
9315
 
9316
9316
  // Read the temporary file to get the actual fixes result.
9317
- const fixesResultJson = fs$2.readJsonSync(tmpFile, {
9317
+ const fixesResultJson = fs$1.readJsonSync(tmpFile, {
9318
9318
  throws: false
9319
9319
  });
9320
9320
 
@@ -9323,14 +9323,15 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9323
9323
  if (!silence) {
9324
9324
  logger.logger.info(`Copying fixes result to ${outputFile}`);
9325
9325
  }
9326
- const tmpContent = await fs$1.promises.readFile(tmpFile, 'utf8');
9327
- 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');
9328
9328
  }
9329
9329
  const ghsaDetails = fixesResultJson ? [fixesResultJson] : [];
9330
9330
  const notApplied = readNotAppliedFixes(fixesResultJson);
9331
9331
  if (!fixCResult.ok || notApplied.length) {
9332
9332
  return {
9333
9333
  ok: false,
9334
+ code: COANA_FIXES_NOT_APPLIED_EXIT_CODE,
9334
9335
  message: fixesResultJson?.type === 'no-fixes-applied' ? 'No computed fixes were applied' : 'Some computed fixes were not applied',
9335
9336
  cause: formatNotAppliedFixes(notApplied),
9336
9337
  data: {
@@ -9349,7 +9350,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9349
9350
  } finally {
9350
9351
  // Clean up the temporary file.
9351
9352
  try {
9352
- await fs$1.promises.unlink(tmpFile);
9353
+ await u.promises.unlink(tmpFile);
9353
9354
  } catch {
9354
9355
  // Ignore cleanup errors.
9355
9356
  }
@@ -9444,7 +9445,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9444
9445
 
9445
9446
  // Apply fix for single GHSA ID.
9446
9447
  // eslint-disable-next-line no-await-in-loop
9447
- 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, {
9448
9449
  coanaVersion,
9449
9450
  cwd,
9450
9451
  spinner: silence ? undefined : spinner,
@@ -9452,7 +9453,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9452
9453
  });
9453
9454
  if (isFixesNotAppliedExit(fixCResult)) {
9454
9455
  if (!silence) {
9455
- 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, {
9456
9457
  throws: false
9457
9458
  })))}`);
9458
9459
  }
@@ -9463,7 +9464,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9463
9464
  // Clean up temp file on failure.
9464
9465
  try {
9465
9466
  // eslint-disable-next-line no-await-in-loop
9466
- await fs$1.promises.unlink(tmpFile);
9467
+ await u.promises.unlink(tmpFile);
9467
9468
  } catch {
9468
9469
  // Ignore cleanup errors.
9469
9470
  }
@@ -9477,7 +9478,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9477
9478
  // Clean up temp file before continuing.
9478
9479
  try {
9479
9480
  // eslint-disable-next-line no-await-in-loop
9480
- await fs$1.promises.unlink(tmpFile);
9481
+ await u.promises.unlink(tmpFile);
9481
9482
  } catch {
9482
9483
  // Ignore cleanup errors.
9483
9484
  }
@@ -9568,7 +9569,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9568
9569
  const prRef = `PR #${data.number}`;
9569
9570
 
9570
9571
  // Read the fix result JSON and merge with PR data.
9571
- const fixResultJson = fs$2.readJsonSync(tmpFile, {
9572
+ const fixResultJson = fs$1.readJsonSync(tmpFile, {
9572
9573
  throws: false
9573
9574
  });
9574
9575
  if (fixResultJson && typeof fixResultJson === 'object') {
@@ -9663,7 +9664,7 @@ async function coanaFixWithFacts(fixConfig, factsSlot) {
9663
9664
  // Clean up temp file.
9664
9665
  try {
9665
9666
  // eslint-disable-next-line no-await-in-loop
9666
- await fs$1.promises.unlink(tmpFile);
9667
+ await u.promises.unlink(tmpFile);
9667
9668
  } catch {
9668
9669
  // Ignore cleanup errors.
9669
9670
  }
@@ -9878,7 +9879,7 @@ const DYNAMIC_SBOM_INFERENCE_DESCRIPTION = 'For Gradle, sbt, and Maven: generate
9878
9879
  const reachabilityFlags = {
9879
9880
  reachVersion: {
9880
9881
  type: 'string',
9881
- 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}.`
9882
9883
  },
9883
9884
  reachAnalysisMemoryLimit: {
9884
9885
  type: 'string',
@@ -10014,7 +10015,7 @@ const generalFlags$2 = {
10014
10015
  },
10015
10016
  fixVersion: {
10016
10017
  type: 'string',
10017
- 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}.`
10018
10019
  },
10019
10020
  applyFixes: {
10020
10021
  aliases: ['onlyCompute'],
@@ -10340,7 +10341,7 @@ async function run$N(argv, importMeta, {
10340
10341
  cwd = path.resolve(process.cwd(), cwd);
10341
10342
 
10342
10343
  // Validate the target directory exists.
10343
- if (!fs$1.existsSync(cwd)) {
10344
+ if (!u.existsSync(cwd)) {
10344
10345
  logger.logger.fail(`Target directory does not exist: ${cwd}`);
10345
10346
  process.exitCode = 1;
10346
10347
  return;
@@ -10449,9 +10450,9 @@ async function setupTabCompletion(targetName) {
10449
10450
  // Target dir is something like ~/.local/share/socket/settings/completion (linux)
10450
10451
  const targetDir = path.dirname(targetPath);
10451
10452
  debug.debugFn('notice', 'target: path + dir', targetPath, targetDir);
10452
- if (!fs$1.existsSync(targetDir)) {
10453
+ if (!u.existsSync(targetDir)) {
10453
10454
  debug.debugFn('notice', 'create: target dir');
10454
- fs$1.mkdirSync(targetDir, {
10455
+ u.mkdirSync(targetDir, {
10455
10456
  recursive: true
10456
10457
  });
10457
10458
  }
@@ -10460,11 +10461,11 @@ async function setupTabCompletion(targetName) {
10460
10461
 
10461
10462
  // Add to ~/.bashrc if not already there
10462
10463
  const bashrcPath = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
10463
- const foundBashrc = Boolean(bashrcPath && fs$1.existsSync(bashrcPath));
10464
+ const foundBashrc = Boolean(bashrcPath && u.existsSync(bashrcPath));
10464
10465
  if (foundBashrc) {
10465
- const content = fs$1.readFileSync(bashrcPath, 'utf8');
10466
+ const content = u.readFileSync(bashrcPath, 'utf8');
10466
10467
  if (!content.includes(sourcingCommand)) {
10467
- fs$1.appendFileSync(bashrcPath, toAddToBashrc);
10468
+ u.appendFileSync(bashrcPath, toAddToBashrc);
10468
10469
  bashrcUpdated = true;
10469
10470
  }
10470
10471
  }
@@ -10485,7 +10486,7 @@ async function setupTabCompletion(targetName) {
10485
10486
  function getTabCompletionScriptRaw() {
10486
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))));
10487
10488
  const sourcePath = path.join(sourceDir, 'socket-completion.bash');
10488
- if (!fs$1.existsSync(sourcePath)) {
10489
+ if (!u.existsSync(sourcePath)) {
10489
10490
  return {
10490
10491
  ok: false,
10491
10492
  message: 'Source not found.',
@@ -10494,7 +10495,7 @@ function getTabCompletionScriptRaw() {
10494
10495
  }
10495
10496
  return {
10496
10497
  ok: true,
10497
- data: fs$1.readFileSync(sourcePath, 'utf8')
10498
+ data: u.readFileSync(sourcePath, 'utf8')
10498
10499
  };
10499
10500
  }
10500
10501
  function updateInstalledTabCompletionScript(targetPath) {
@@ -10505,7 +10506,7 @@ function updateInstalledTabCompletionScript(targetPath) {
10505
10506
 
10506
10507
  // When installing set the current package.json version.
10507
10508
  // Later, we can call _socket_completion_version to get the installed version.
10508
- 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');
10509
10510
  return {
10510
10511
  ok: true,
10511
10512
  data: undefined
@@ -10600,19 +10601,19 @@ async function outputCmdJson(cwd) {
10600
10601
  logger.logger.info('Target cwd:', constants.default.ENV.VITEST ? constants.REDACTED : utils.tildify(cwd));
10601
10602
  const sockJsonPath = path.join(cwd, constants.SOCKET_JSON);
10602
10603
  const tildeSockJsonPath = constants.default.ENV.VITEST ? constants.REDACTED : utils.tildify(sockJsonPath);
10603
- if (!fs$1.existsSync(sockJsonPath)) {
10604
+ if (!u.existsSync(sockJsonPath)) {
10604
10605
  logger.logger.fail(`Not found: ${tildeSockJsonPath}`);
10605
10606
  process.exitCode = 1;
10606
10607
  return;
10607
10608
  }
10608
- if (!fs$2.safeStatsSync(sockJsonPath)?.isFile()) {
10609
+ if (!fs$1.safeStatsSync(sockJsonPath)?.isFile()) {
10609
10610
  logger.logger.fail(`This is not a regular file (maybe a directory?): ${tildeSockJsonPath}`);
10610
10611
  process.exitCode = 1;
10611
10612
  return;
10612
10613
  }
10613
10614
  logger.logger.success(`This is the contents of ${tildeSockJsonPath}:`);
10614
10615
  logger.logger.error('');
10615
- const data = fs$2.safeReadFileSync(sockJsonPath);
10616
+ const data = fs$1.safeReadFileSync(sockJsonPath);
10616
10617
  logger.logger.log(data);
10617
10618
  }
10618
10619
 
@@ -11016,13 +11017,13 @@ async function runCdxgen(argvObj) {
11016
11017
  try {
11017
11018
  // TODO: Consider using trash instead of rmSync for safer deletion.
11018
11019
  // This removes the temporary package-lock.json we created for cdxgen.
11019
- fs$1.rmSync(`./${PACKAGE_LOCK_JSON}`);
11020
+ u.rmSync(`./${PACKAGE_LOCK_JSON}`);
11020
11021
  } catch {}
11021
11022
  }
11022
11023
  const outputPath = argvMutable['output'];
11023
11024
  if (outputPath) {
11024
11025
  const fullOutputPath = path.join(process.cwd(), outputPath);
11025
- if (fs$1.existsSync(fullOutputPath)) {
11026
+ if (u.existsSync(fullOutputPath)) {
11026
11027
  logger.logger.log(vendor.yoctocolorsCjsExports.cyanBright(`${outputPath} created!`));
11027
11028
  }
11028
11029
  }
@@ -11461,15 +11462,15 @@ function parseBazelModPipExtensionCandidates(stdout, verbose) {
11461
11462
  // Reads file contents, refusing files that exceed MAX_WORKSPACE_FILE_BYTES.
11462
11463
  // Returns null when the file is missing, oversized, or unreadable.
11463
11464
  function safeReadFile(file) {
11464
- if (!fs$1.existsSync(file)) {
11465
+ if (!u.existsSync(file)) {
11465
11466
  return null;
11466
11467
  }
11467
11468
  try {
11468
- const stat = fs$1.statSync(file);
11469
+ const stat = u.statSync(file);
11469
11470
  if (stat.size > MAX_WORKSPACE_FILE_BYTES) {
11470
11471
  return null;
11471
11472
  }
11472
- return fs$1.readFileSync(file, 'utf8');
11473
+ return u.readFileSync(file, 'utf8');
11473
11474
  } catch {
11474
11475
  return null;
11475
11476
  }
@@ -11483,13 +11484,13 @@ function listLegacyStarlarkFiles(cwd) {
11483
11484
  const candidates = ['WORKSPACE', 'WORKSPACE.bazel'];
11484
11485
  for (const c of candidates) {
11485
11486
  const p = path.join(cwd, c);
11486
- if (fs$1.existsSync(p)) {
11487
+ if (u.existsSync(p)) {
11487
11488
  files.push(p);
11488
11489
  }
11489
11490
  }
11490
11491
  // Top-level .bzl files only.
11491
11492
  try {
11492
- for (const entry of fs$1.readdirSync(cwd)) {
11493
+ for (const entry of u.readdirSync(cwd)) {
11493
11494
  if (entry.endsWith('.bzl')) {
11494
11495
  files.push(path.join(cwd, entry));
11495
11496
  }
@@ -11884,16 +11885,16 @@ function readRequirementsLockFile(resolvedPath) {
11884
11885
  if (!resolvedPath) {
11885
11886
  return undefined;
11886
11887
  }
11887
- if (!fs$1.existsSync(resolvedPath)) {
11888
+ if (!u.existsSync(resolvedPath)) {
11888
11889
  return undefined;
11889
11890
  }
11890
11891
  let text;
11891
11892
  try {
11892
- const stat = fs$1.statSync(resolvedPath);
11893
+ const stat = u.statSync(resolvedPath);
11893
11894
  if (stat.size > MAX_REQUIREMENTS_FILE_BYTES) {
11894
11895
  return undefined;
11895
11896
  }
11896
- text = fs$1.readFileSync(resolvedPath, 'utf8');
11897
+ text = u.readFileSync(resolvedPath, 'utf8');
11897
11898
  } catch {
11898
11899
  return undefined;
11899
11900
  }
@@ -12026,7 +12027,7 @@ async function extractBazelToPypi(opts) {
12026
12027
  logger.logger.group('bazel2pypi:');
12027
12028
  logger.logger.info(`- src dir: \`${cwd}\``);
12028
12029
  logger.logger.info(`- out dir: \`${out}\``);
12029
- if (!fs$1.existsSync(cwd)) {
12030
+ if (!u.existsSync(cwd)) {
12030
12031
  logger.logger.warn(`Warning: cwd does not exist: ${cwd}`);
12031
12032
  }
12032
12033
  logger.logger.groupEnd();
@@ -12164,11 +12165,11 @@ async function extractBazelToPypi(opts) {
12164
12165
  const lines = sorted.map(p => `${p.name}==${p.version}\n`);
12165
12166
  const layout = opts.outLayout ?? 'standalone';
12166
12167
  const manifestDir = layout === 'flat' ? path.join(out, '.socket-auto-manifest') : out;
12167
- fs$1.mkdirSync(manifestDir, {
12168
+ u.mkdirSync(manifestDir, {
12168
12169
  recursive: true
12169
12170
  });
12170
12171
  const manifestPath = path.join(manifestDir, 'requirements.txt');
12171
- await fs$1.promises.writeFile(manifestPath, lines.join(''), 'utf8');
12172
+ await u.promises.writeFile(manifestPath, lines.join(''), 'utf8');
12172
12173
  if (verbose) {
12173
12174
  logger.logger.log('[VERBOSE] outputs:', {
12174
12175
  artifactCount: allLines.length,
@@ -14069,7 +14070,7 @@ async function setupManifestConfig(cwd, defaultOnReadError = false) {
14069
14070
  // - record them to the socket.yml (or socket-cli.yml ? or just socket.json ?)
14070
14071
 
14071
14072
  const jsonPath = path.join(cwd, constants.SOCKET_JSON);
14072
- if (fs$1.existsSync(jsonPath)) {
14073
+ if (u.existsSync(jsonPath)) {
14073
14074
  logger.logger.info(`Found ${constants.SOCKET_JSON} at ${jsonPath}`);
14074
14075
  } else {
14075
14076
  logger.logger.info(`No ${constants.SOCKET_JSON} found at ${cwd}, will generate a new one`);
@@ -15249,7 +15250,7 @@ async function askYesNo(message) {
15249
15250
  // normal, not an abort.
15250
15251
  async function setupRecursiveRootDefaults(cwd, defaultOnReadError, ecosystems, ecosystemsAtCwd) {
15251
15252
  const jsonPath = path.join(cwd, constants.SOCKET_JSON);
15252
- if (fs$1.existsSync(jsonPath)) {
15253
+ if (u.existsSync(jsonPath)) {
15253
15254
  logger.logger.info(`Found ${constants.SOCKET_JSON} at ${jsonPath}`);
15254
15255
  } else {
15255
15256
  logger.logger.info(`No ${constants.SOCKET_JSON} found at ${cwd}, will generate a new one`);
@@ -18404,7 +18405,7 @@ function resolveSocketPatchBin() {
18404
18405
  let dir = __dirname;
18405
18406
  for (let i = 0; i < 10; i += 1) {
18406
18407
  const candidate = path.join(dir, 'node_modules', '.bin', 'socket-patch');
18407
- if (fs$1.existsSync(candidate)) {
18408
+ if (u.existsSync(candidate)) {
18408
18409
  return candidate;
18409
18410
  }
18410
18411
  const parent = path.dirname(dir);
@@ -19758,7 +19759,7 @@ async function generateUvMemberSboms(memberDirs) {
19758
19759
  const files = [];
19759
19760
  const removeFilesSync = () => {
19760
19761
  for (const file of files) {
19761
- fs$1.rmSync(file, {
19762
+ u.rmSync(file, {
19762
19763
  force: true
19763
19764
  });
19764
19765
  }
@@ -19774,7 +19775,7 @@ async function generateUvMemberSboms(memberDirs) {
19774
19775
  for (const signal of CLEANUP_SIGNALS) {
19775
19776
  process.removeListener(signal, removeFilesSync);
19776
19777
  }
19777
- await Promise.all(files.map(file => fs$1.promises.rm(file, {
19778
+ await Promise.all(files.map(file => u.promises.rm(file, {
19778
19779
  force: true
19779
19780
  })));
19780
19781
  };
@@ -19784,7 +19785,7 @@ async function generateUvMemberSboms(memberDirs) {
19784
19785
  // and the reachability target line up with the member directory.
19785
19786
  const filename = path.join(memberDirs[i], UV_SBOM_FILENAME);
19786
19787
  // eslint-disable-next-line no-await-in-loop
19787
- await fs$1.promises.writeFile(filename, JSON.stringify(sboms[i]), {
19788
+ await u.promises.writeFile(filename, JSON.stringify(sboms[i]), {
19788
19789
  flag: 'wx'
19789
19790
  });
19790
19791
  files.push(filename);
@@ -19803,13 +19804,13 @@ function resolveUvMemberDirs(targets, cwd) {
19803
19804
  for (const target of targets) {
19804
19805
  const memberDir = path.resolve(cwd, target);
19805
19806
  const relativeDir = path.relative(cwd, memberDir);
19806
- 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)) {
19807
19808
  throw new utils.InputError(`--uv-members requires every TARGET to be a directory inside --cwd, but got ${target}`);
19808
19809
  }
19809
- if (!fs$1.existsSync(path.join(memberDir, 'pyproject.toml'))) {
19810
+ if (!u.existsSync(path.join(memberDir, 'pyproject.toml'))) {
19810
19811
  throw new utils.InputError(`--uv-members requires a pyproject.toml in every TARGET, but ${target} has none`);
19811
19812
  }
19812
- if (fs$1.existsSync(path.join(memberDir, UV_SBOM_FILENAME))) {
19813
+ if (u.existsSync(path.join(memberDir, UV_SBOM_FILENAME))) {
19813
19814
  throw new utils.InputError(`${path.join(target, UV_SBOM_FILENAME)} already exists. Remove it and run the scan again.`);
19814
19815
  }
19815
19816
  memberDirs.add(memberDir);
@@ -19862,9 +19863,9 @@ async function validateReachabilityTarget(targets, cwd) {
19862
19863
  // Check if target is inside cwd.
19863
19864
  const relativePath = path.relative(absoluteCwd, targetPath);
19864
19865
  result.isInsideCwd = !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
19865
- result.targetExists = fs$1.existsSync(targetPath);
19866
+ result.targetExists = u.existsSync(targetPath);
19866
19867
  if (result.targetExists) {
19867
- const targetStat = await fs$1.promises.stat(targetPath);
19868
+ const targetStat = await u.promises.stat(targetPath);
19868
19869
  result.isDirectory = targetStat.isDirectory();
19869
19870
  }
19870
19871
  return result;
@@ -19988,7 +19989,7 @@ const generalFlags$1 = {
19988
19989
  };
19989
19990
  function hasSocketFactsFileIn(dir) {
19990
19991
  try {
19991
- return fs$1.readdirSync(dir).some(utils.isSocketFactsFile);
19992
+ return u.readdirSync(dir).some(utils.isSocketFactsFile);
19992
19993
  } catch {
19993
19994
  return false;
19994
19995
  }
@@ -20560,7 +20561,7 @@ async function handleJson(data, file, dashboardMessage) {
20560
20561
  const json = utils.serializeResultJson(data);
20561
20562
  if (file && file !== '-') {
20562
20563
  logger.logger.log(`Writing json to \`${file}\``);
20563
- fs$1.writeFile(file, json, err => {
20564
+ u.writeFile(file, json, err => {
20564
20565
  if (err) {
20565
20566
  logger.logger.fail(`Writing to \`${file}\` failed...`);
20566
20567
  logger.logger.error(err);
@@ -21016,7 +21017,7 @@ async function scanOneRepo(repoSlug, {
21016
21017
  }
21017
21018
  };
21018
21019
  }
21019
- const tmpDir = fs$1.mkdtempSync(path.join(os.tmpdir(), repoSlug));
21020
+ const tmpDir = u.mkdtempSync(path.join(os.tmpdir(), repoSlug));
21020
21021
  debug.debugFn('notice', 'init: temp dir for scan root', tmpDir);
21021
21022
  const downloadResult = await testAndDownloadManifestFiles({
21022
21023
  files,
@@ -21291,12 +21292,12 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
21291
21292
  // Make sure the dir exists. It may be nested and we need to construct that
21292
21293
  // before starting the download.
21293
21294
  const dir = path.dirname(localPath);
21294
- if (!fs$1.existsSync(dir)) {
21295
- fs$1.mkdirSync(dir, {
21295
+ if (!u.existsSync(dir)) {
21296
+ u.mkdirSync(dir, {
21296
21297
  recursive: true
21297
21298
  });
21298
21299
  }
21299
- const fileStream = fs$1.createWriteStream(localPath);
21300
+ const fileStream = u.createWriteStream(localPath);
21300
21301
 
21301
21302
  // Using stream.pipeline for better error handling and cleanup
21302
21303
 
@@ -21315,11 +21316,11 @@ async function streamDownloadWithFetch(localPath, downloadUrl) {
21315
21316
  debug.debugDir('error', e);
21316
21317
 
21317
21318
  // If an error occurs and fileStream was created, attempt to clean up.
21318
- if (fs$1.existsSync(localPath)) {
21319
+ if (u.existsSync(localPath)) {
21319
21320
  // Check if fileStream was even opened before trying to delete
21320
21321
  // This check might be too simplistic depending on when error occurs
21321
21322
  try {
21322
- await fs$1.promises.unlink(localPath);
21323
+ await u.promises.unlink(localPath);
21323
21324
  } catch (e) {
21324
21325
  logger.logger.fail(utils.formatErrorWithDetail(`Error deleting partial file ${localPath}`, e));
21325
21326
  }
@@ -22762,7 +22763,7 @@ async function outputScanConfigResult(result) {
22762
22763
 
22763
22764
  async function setupScanConfig(cwd, defaultOnReadError = false) {
22764
22765
  const jsonPath = path.join(cwd, constants.SOCKET_JSON);
22765
- if (fs$1.existsSync(jsonPath)) {
22766
+ if (u.existsSync(jsonPath)) {
22766
22767
  logger.logger.info(`Found ${constants.SOCKET_JSON} at ${jsonPath}`);
22767
22768
  } else {
22768
22769
  logger.logger.info(`No ${constants.SOCKET_JSON} found at ${cwd}, will generate a new one`);
@@ -23868,15 +23869,15 @@ async function teardownTabCompletion(targetName) {
23868
23869
 
23869
23870
  // Remove from ~/.bashrc if found
23870
23871
  const bashrc = constants.default.homePath ? path.join(constants.default.homePath, '.bashrc') : '';
23871
- if (bashrc && fs$1.existsSync(bashrc)) {
23872
- const content = fs$1.readFileSync(bashrc, 'utf8');
23872
+ if (bashrc && u.existsSync(bashrc)) {
23873
+ const content = u.readFileSync(bashrc, 'utf8');
23873
23874
  if (content.includes(toAddToBashrc)) {
23874
23875
  const newContent = content
23875
23876
  // Try to remove the whole thing with comment first
23876
23877
  .replaceAll(toAddToBashrc, '')
23877
23878
  // Comment may have been edited away, try to remove the command at least
23878
23879
  .replaceAll(sourcingCommand, '').replaceAll(completionCommand, '');
23879
- fs$1.writeFileSync(bashrc, newContent, 'utf8');
23880
+ u.writeFileSync(bashrc, newContent, 'utf8');
23880
23881
  return {
23881
23882
  ok: true,
23882
23883
  data: {
@@ -23989,7 +23990,7 @@ const cmdUninstall = {
23989
23990
  };
23990
23991
 
23991
23992
  function addSocketWrapper(file) {
23992
- 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 => {
23993
23994
  if (err) {
23994
23995
  return new Error(`There was an error setting up the alias: ${err}`);
23995
23996
  }
@@ -24006,7 +24007,7 @@ function addSocketWrapper(file) {
24006
24007
  }
24007
24008
 
24008
24009
  function checkSocketWrapperSetup(file) {
24009
- const fileContent = fs$1.readFileSync(file, 'utf8');
24010
+ const fileContent = u.readFileSync(file, 'utf8');
24010
24011
  const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
24011
24012
  if (linesWithSocketAlias.length) {
24012
24013
  logger.logger.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
@@ -24025,7 +24026,7 @@ async function postinstallWrapper() {
24025
24026
  bashRcPath,
24026
24027
  zshRcPath
24027
24028
  } = constants.default;
24028
- 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);
24029
24030
  if (!socketWrapperEnabled) {
24030
24031
  await setupShadowNpm(`
24031
24032
  The Socket CLI is now successfully installed! 🎉
@@ -24041,7 +24042,7 @@ Do you want to install the Socket npm wrapper (this will create an alias to the
24041
24042
  try {
24042
24043
  const details = utils.getBashrcDetails(''); // Note: command is not relevant, we just want the config path
24043
24044
  if (details.ok) {
24044
- if (fs$1.existsSync(details.data.targetPath)) {
24045
+ if (u.existsSync(details.data.targetPath)) {
24045
24046
  // Replace the file with the one from this installation
24046
24047
  const result = updateInstalledTabCompletionScript(details.data.targetPath);
24047
24048
  if (result.ok) {
@@ -24080,10 +24081,10 @@ async function setupShadowNpm(query) {
24080
24081
  zshRcPath
24081
24082
  } = constants.default;
24082
24083
  try {
24083
- if (fs$1.existsSync(bashRcPath)) {
24084
+ if (u.existsSync(bashRcPath)) {
24084
24085
  addSocketWrapper(bashRcPath);
24085
24086
  }
24086
- if (fs$1.existsSync(zshRcPath)) {
24087
+ if (u.existsSync(zshRcPath)) {
24087
24088
  addSocketWrapper(zshRcPath);
24088
24089
  }
24089
24090
  } catch (e) {
@@ -24095,7 +24096,7 @@ async function setupShadowNpm(query) {
24095
24096
  function removeSocketWrapper(filepath) {
24096
24097
  let content;
24097
24098
  try {
24098
- content = fs$1.readFileSync(filepath, 'utf8');
24099
+ content = u.readFileSync(filepath, 'utf8');
24099
24100
  } catch (e) {
24100
24101
  logger.logger.fail(`There was an error removing the alias${e ? ':' : '.'}`);
24101
24102
  if (e) {
@@ -24106,7 +24107,7 @@ function removeSocketWrapper(filepath) {
24106
24107
  const linesWithoutSocketAlias = content.split('\n').filter(l => l !== 'alias npm="socket npm"' && l !== 'alias npx="socket npx"');
24107
24108
  const updatedContent = linesWithoutSocketAlias.join('\n');
24108
24109
  try {
24109
- fs$1.writeFileSync(filepath, updatedContent, 'utf8');
24110
+ u.writeFileSync(filepath, updatedContent, 'utf8');
24110
24111
  } catch (e) {
24111
24112
  if (e) {
24112
24113
  logger.logger.error(e);
@@ -24200,21 +24201,21 @@ async function run$1(argv, importMeta, {
24200
24201
  zshRcPath
24201
24202
  } = constants.default;
24202
24203
  if (enable) {
24203
- if (fs$1.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
24204
+ if (u.existsSync(bashRcPath) && !checkSocketWrapperSetup(bashRcPath)) {
24204
24205
  addSocketWrapper(bashRcPath);
24205
24206
  }
24206
- if (fs$1.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
24207
+ if (u.existsSync(zshRcPath) && !checkSocketWrapperSetup(zshRcPath)) {
24207
24208
  addSocketWrapper(zshRcPath);
24208
24209
  }
24209
24210
  } else {
24210
- if (fs$1.existsSync(bashRcPath)) {
24211
+ if (u.existsSync(bashRcPath)) {
24211
24212
  removeSocketWrapper(bashRcPath);
24212
24213
  }
24213
- if (fs$1.existsSync(zshRcPath)) {
24214
+ if (u.existsSync(zshRcPath)) {
24214
24215
  removeSocketWrapper(zshRcPath);
24215
24216
  }
24216
24217
  }
24217
- if (!fs$1.existsSync(bashRcPath) && !fs$1.existsSync(zshRcPath)) {
24218
+ if (!u.existsSync(bashRcPath) && !u.existsSync(zshRcPath)) {
24218
24219
  logger.logger.fail('There was an issue setting up the alias in your bash profile');
24219
24220
  }
24220
24221
  }
@@ -24538,5 +24539,5 @@ process.on('unhandledRejection', async (reason, promise) => {
24538
24539
  // eslint-disable-next-line n/no-process-exit
24539
24540
  process.exit(1);
24540
24541
  });
24541
- //# debugId=22616eb7-71e2-4c79-9e60-bfde9a2cdb49
24542
+ //# debugId=c715fb1e-bcb7-40c4-b394-2bc4db5e64a
24542
24543
  //# sourceMappingURL=cli.js.map