@socketsecurity/cli-with-sentry 1.1.48 → 1.1.50

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/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
6
6
 
7
+ ## [1.1.50](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.50) - 2025-12-19
8
+
9
+ ### Fixed
10
+ - Fixed exit code when blocking alerts are found
11
+
12
+ ## [1.1.49](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.49) - 2025-12-17
13
+
14
+ ### Added
15
+ - Added initial telemetry functionality to track CLI usage and help improve the Socket experience.
16
+
17
+ ### Fixed
18
+ - Fixed error propagation when npm package finalization failed in `socket fix`.
19
+
20
+ ### Changed
21
+ - Updated the Coana CLI to v `14.12.134`.
22
+
7
23
  ## [1.1.48](https://github.com/SocketDev/socket-cli/releases/tag/v1.1.48) - 2025-12-16
8
24
 
9
25
  ### Changed
package/bin/npm-cli.js CHANGED
@@ -11,7 +11,7 @@ void (async () => {
11
11
 
12
12
  process.exitCode = 1
13
13
 
14
- const { spawnPromise } = await shadowNpmBin('npm', process.argv.slice(2), {
14
+ const { spawnPromise } = await shadowNpmBin(process.argv.slice(2), {
15
15
  stdio: 'inherit',
16
16
  })
17
17
 
package/bin/npx-cli.js CHANGED
@@ -7,11 +7,11 @@ void (async () => {
7
7
  const rootPath = path.join(__dirname, '..')
8
8
  Module.enableCompileCache?.(path.join(rootPath, '.cache'))
9
9
 
10
- const shadowNpmBin = require(path.join(rootPath, 'dist/shadow-npm-bin.js'))
10
+ const shadowNpxBin = require(path.join(rootPath, 'dist/shadow-npx-bin.js'))
11
11
 
12
12
  process.exitCode = 1
13
13
 
14
- const { spawnPromise } = await shadowNpmBin('npx', process.argv.slice(2), {
14
+ const { spawnPromise } = await shadowNpxBin(process.argv.slice(2), {
15
15
  stdio: 'inherit',
16
16
  })
17
17
 
package/dist/cli.js CHANGED
@@ -1361,6 +1361,10 @@ async function outputScanReport(result, {
1361
1361
  logger.logger.fail(utils.failMsgWithBadge(scanReport.message, scanReport.cause));
1362
1362
  return;
1363
1363
  }
1364
+ if (!scanReport.data.healthy) {
1365
+ // When report contains healthy: false, process should exit with non-zero code.
1366
+ process.exitCode = 1;
1367
+ }
1364
1368
 
1365
1369
  // I don't think we emit the default error message with banner for an unhealthy report, do we?
1366
1370
  // if (!scanReport.data.healthy) {
@@ -6825,20 +6829,28 @@ async function run$x(argv, importMeta, context) {
6825
6829
  ...flags.commonFlags,
6826
6830
  ...flags.outputFlags
6827
6831
  }, [constants.FLAG_JSON]);
6832
+
6833
+ // Track subprocess start.
6834
+ const subprocessStartTime = await utils.trackSubprocessStart(constants.NPM);
6828
6835
  const {
6829
6836
  spawnPromise
6830
6837
  } = await shadowNpmBin(argsToForward, {
6831
6838
  stdio: 'inherit'
6832
6839
  });
6833
6840
 
6841
+ // Handle exit codes and signals using event-based pattern.
6834
6842
  // See https://nodejs.org/api/child_process.html#event-exit.
6835
6843
  spawnPromise.process.on('exit', (code, signalName) => {
6836
- if (signalName) {
6837
- process.kill(process.pid, signalName);
6838
- } else if (typeof code === 'number') {
6839
- // eslint-disable-next-line n/no-process-exit
6840
- process.exit(code);
6841
- }
6844
+ // Track subprocess exit and flush telemetry before exiting.
6845
+ // Use .then() to ensure telemetry completes before process.exit().
6846
+ void utils.trackSubprocessExit(constants.NPM, subprocessStartTime, code).then(() => {
6847
+ if (signalName) {
6848
+ process.kill(process.pid, signalName);
6849
+ } else if (typeof code === 'number') {
6850
+ // eslint-disable-next-line n/no-process-exit
6851
+ process.exit(code);
6852
+ }
6853
+ });
6842
6854
  });
6843
6855
  await spawnPromise;
6844
6856
  }
@@ -6892,20 +6904,28 @@ async function run$w(argv, importMeta, {
6892
6904
  }
6893
6905
  const shadowNpxBin = /*@__PURE__*/require$4(constants.default.shadowNpxBinPath);
6894
6906
  process.exitCode = 1;
6907
+
6908
+ // Track subprocess start.
6909
+ const subprocessStartTime = await utils.trackSubprocessStart(constants.NPX);
6895
6910
  const {
6896
6911
  spawnPromise
6897
6912
  } = await shadowNpxBin(argv, {
6898
6913
  stdio: 'inherit'
6899
6914
  });
6900
6915
 
6916
+ // Handle exit codes and signals using event-based pattern.
6901
6917
  // See https://nodejs.org/api/child_process.html#event-exit.
6902
6918
  spawnPromise.process.on('exit', (code, signalName) => {
6903
- if (signalName) {
6904
- process.kill(process.pid, signalName);
6905
- } else if (typeof code === 'number') {
6906
- // eslint-disable-next-line n/no-process-exit
6907
- process.exit(code);
6908
- }
6919
+ // Track subprocess exit and flush telemetry before exiting.
6920
+ // Use .then() to ensure telemetry completes before process.exit().
6921
+ void utils.trackSubprocessExit(constants.NPX, subprocessStartTime, code).then(() => {
6922
+ if (signalName) {
6923
+ process.kill(process.pid, signalName);
6924
+ } else if (typeof code === 'number') {
6925
+ // eslint-disable-next-line n/no-process-exit
6926
+ process.exit(code);
6927
+ }
6928
+ });
6909
6929
  });
6910
6930
  await spawnPromise;
6911
6931
  }
@@ -10014,13 +10034,30 @@ async function run$l(argv, importMeta, context) {
10014
10034
 
10015
10035
  // Filter Socket flags from argv.
10016
10036
  const filteredArgv = utils.filterFlags(argv, config.flags);
10037
+
10038
+ // Track subprocess start.
10039
+ const subprocessStartTime = await utils.trackSubprocessStart(constants.PNPM);
10017
10040
  const {
10018
10041
  spawnPromise
10019
10042
  } = await shadowPnpmBin(filteredArgv, {
10020
10043
  stdio: 'inherit'
10021
10044
  });
10045
+
10046
+ // Handle exit codes and signals using event-based pattern.
10047
+ // See https://nodejs.org/api/child_process.html#event-exit.
10048
+ spawnPromise.process.on('exit', (code, signalName) => {
10049
+ // Track subprocess exit and flush telemetry before exiting.
10050
+ // Use .then() to ensure telemetry completes before process.exit().
10051
+ void utils.trackSubprocessExit(constants.PNPM, subprocessStartTime, code).then(() => {
10052
+ if (signalName) {
10053
+ process.kill(process.pid, signalName);
10054
+ } else if (typeof code === 'number') {
10055
+ // eslint-disable-next-line n/no-process-exit
10056
+ process.exit(code);
10057
+ }
10058
+ });
10059
+ });
10022
10060
  await spawnPromise;
10023
- process.exitCode = 0;
10024
10061
  }
10025
10062
 
10026
10063
  async function runRawNpm(argv) {
@@ -15369,11 +15406,29 @@ async function run(argv, importMeta, context) {
15369
15406
 
15370
15407
  // Filter Socket flags from argv.
15371
15408
  const filteredArgv = utils.filterFlags(argv, config.flags);
15409
+
15410
+ // Track subprocess start.
15411
+ const subprocessStartTime = await utils.trackSubprocessStart(constants.YARN);
15372
15412
  const {
15373
15413
  spawnPromise
15374
15414
  } = await shadowYarnBin(filteredArgv, {
15375
15415
  stdio: 'inherit'
15376
15416
  });
15417
+
15418
+ // Handle exit codes and signals using event-based pattern.
15419
+ // See https://nodejs.org/api/child_process.html#event-exit.
15420
+ spawnPromise.process.on('exit', (code, signalName) => {
15421
+ // Track subprocess exit and flush telemetry before exiting.
15422
+ // Use .then() to ensure telemetry completes before process.exit().
15423
+ void utils.trackSubprocessExit(constants.YARN, subprocessStartTime, code).then(() => {
15424
+ if (signalName) {
15425
+ process.kill(process.pid, signalName);
15426
+ } else if (typeof code === 'number') {
15427
+ // eslint-disable-next-line n/no-process-exit
15428
+ process.exit(code);
15429
+ }
15430
+ });
15431
+ });
15377
15432
  await spawnPromise;
15378
15433
  process.exitCode = 0;
15379
15434
  }
@@ -15489,7 +15544,15 @@ const rootAliases = {
15489
15544
  };
15490
15545
 
15491
15546
  const __filename$1 = require$$0.fileURLToPath((typeof document === 'undefined' ? require$$0.pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
15547
+
15548
+ // Capture CLI start time at module level for global error handlers.
15549
+ const cliStartTime = Date.now();
15550
+
15551
+ // Set up telemetry exit handlers early to catch all exit scenarios.
15552
+ utils.setupTelemetryExitHandlers();
15492
15553
  void (async () => {
15554
+ // Track CLI start for telemetry.
15555
+ await utils.trackCliStart(process.argv);
15493
15556
  const registryUrl = vendor.registryUrl();
15494
15557
  await vendor.updater({
15495
15558
  authInfo: vendor.registryAuthTokenExports(registryUrl, {
@@ -15515,8 +15578,14 @@ void (async () => {
15515
15578
  }, {
15516
15579
  aliases: rootAliases
15517
15580
  });
15581
+
15582
+ // Track successful CLI completion.
15583
+ await utils.trackCliComplete(process.argv, cliStartTime, process.exitCode);
15518
15584
  } catch (e) {
15519
15585
  process.exitCode = 1;
15586
+
15587
+ // Track CLI error for telemetry.
15588
+ await utils.trackCliError(process.argv, cliStartTime, e, process.exitCode);
15520
15589
  require$$9.debugFn('error', 'CLI uncaught error');
15521
15590
  require$$9.debugDir('error', e);
15522
15591
  let errorBody;
@@ -15569,6 +15638,47 @@ void (async () => {
15569
15638
  }
15570
15639
  await utils.captureException(e);
15571
15640
  }
15572
- })();
15573
- //# debugId=b69f666d-f56b-4628-89f1-ad39341fe24f
15641
+ })().catch(async err => {
15642
+ // Fatal error in main async function.
15643
+ console.error('Fatal error:', err);
15644
+
15645
+ // Track CLI error for fatal exceptions.
15646
+ await utils.trackCliError(process.argv, cliStartTime, err, 1);
15647
+
15648
+ // Finalize telemetry before fatal exit.
15649
+ await utils.finalizeTelemetry();
15650
+
15651
+ // eslint-disable-next-line n/no-process-exit
15652
+ process.exit(1);
15653
+ });
15654
+
15655
+ // Handle uncaught exceptions.
15656
+ process.on('uncaughtException', async err => {
15657
+ console.error('Uncaught exception:', err);
15658
+
15659
+ // Track CLI error for uncaught exception.
15660
+ await utils.trackCliError(process.argv, cliStartTime, err, 1);
15661
+
15662
+ // Finalize telemetry before exit.
15663
+ await utils.finalizeTelemetry();
15664
+
15665
+ // eslint-disable-next-line n/no-process-exit
15666
+ process.exit(1);
15667
+ });
15668
+
15669
+ // Handle unhandled promise rejections.
15670
+ process.on('unhandledRejection', async (reason, promise) => {
15671
+ console.error('Unhandled rejection at:', promise, 'reason:', reason);
15672
+
15673
+ // Track CLI error for unhandled rejection.
15674
+ const error = reason instanceof Error ? reason : new Error(String(reason));
15675
+ await utils.trackCliError(process.argv, cliStartTime, error, 1);
15676
+
15677
+ // Finalize telemetry before exit.
15678
+ await utils.finalizeTelemetry();
15679
+
15680
+ // eslint-disable-next-line n/no-process-exit
15681
+ process.exit(1);
15682
+ });
15683
+ //# debugId=3f5f54d9-596a-4c89-8916-eb66d170a333
15574
15684
  //# sourceMappingURL=cli.js.map