@socketsecurity/cli 0.14.39 → 0.14.41

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.
@@ -10,6 +10,7 @@ function _socketInterop(e) {
10
10
  return c ? e.default : e
11
11
  }
12
12
 
13
+ var process$1 = require('node:process');
13
14
  var node_url = require('node:url');
14
15
  var ponyCause = _socketInterop(require('pony-cause'));
15
16
  var updateNotifier = _socketInterop(require('tiny-updater'));
@@ -20,45 +21,46 @@ var yargsParse = _socketInterop(require('yargs-parser'));
20
21
  var npm$1 = require('@socketsecurity/registry/lib/npm');
21
22
  var words = require('@socketsecurity/registry/lib/words');
22
23
  var constants = require('./constants.js');
24
+ var spinner = require('@socketsecurity/registry/lib/spinner');
25
+ var spawn = _socketInterop(require('@npmcli/promise-spawn'));
26
+ var objects = require('@socketsecurity/registry/lib/objects');
27
+ var pathResolve = require('./path-resolve.js');
23
28
  var meow = _socketInterop(require('meow'));
24
- var yoctoSpinner = require('@socketregistry/yocto-spinner');
25
- var sdk = require('./sdk.js');
26
- var prompts = require('@socketsecurity/registry/lib/prompts');
27
- var isInteractive = _socketInterop(require('is-interactive'));
29
+ var registryConstants = require('@socketsecurity/registry/lib/constants');
30
+ var socketUrl = require('./socket-url.js');
28
31
  var terminalLink = _socketInterop(require('terminal-link'));
29
- var fs$1 = require('node:fs/promises');
30
- var spawn = _socketInterop(require('@npmcli/promise-spawn'));
32
+ var isInteractive = require('@socketregistry/is-interactive/index.cjs');
33
+ var prompts = require('@socketsecurity/registry/lib/prompts');
31
34
  var npa = _socketInterop(require('npm-package-arg'));
32
35
  var semver = _socketInterop(require('semver'));
33
36
  var tinyglobby = _socketInterop(require('tinyglobby'));
34
37
  var yaml = _socketInterop(require('yaml'));
35
38
  var registry = require('@socketsecurity/registry');
36
- var objects = require('@socketsecurity/registry/lib/objects');
37
39
  var packages = require('@socketsecurity/registry/lib/packages');
38
40
  var promises = require('@socketsecurity/registry/lib/promises');
39
41
  var regexps = require('@socketsecurity/registry/lib/regexps');
40
42
  var strings = require('@socketsecurity/registry/lib/strings');
41
43
  var browserslist = _socketInterop(require('browserslist'));
42
44
  var which = _socketInterop(require('which'));
43
- var hyrious__bun_lockb = require('@socketregistry/hyrious__bun.lockb');
44
- var pathResolve = require('./path-resolve.js');
45
+ var index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs');
46
+ var sorts = require('@socketsecurity/registry/lib/sorts');
45
47
  var betterAjvErrors = _socketInterop(require('@apideck/better-ajv-errors'));
46
48
  var config = require('@socketsecurity/config');
47
- var homedir = require('node:os');
49
+ var os = require('node:os');
48
50
  var readline = require('node:readline');
49
- var node_process = require('node:process');
50
51
  var readline$1 = require('node:readline/promises');
51
52
  var open = _socketInterop(require('open'));
52
53
  var chalkTable = _socketInterop(require('chalk-table'));
54
+ var fs$1 = require('node:fs/promises');
53
55
  var ScreenWidget = _socketInterop(require('blessed/lib/widgets/screen'));
54
- var BarChart = _socketInterop(require('blessed-contrib/lib/widget/charts/bar'));
55
56
  var GridLayout = _socketInterop(require('blessed-contrib/lib/layout/grid'));
57
+ var BarChart = _socketInterop(require('blessed-contrib/lib/widget/charts/bar'));
56
58
  var LineChart = _socketInterop(require('blessed-contrib/lib/widget/charts/line'));
57
59
  var util = require('node:util');
58
60
  var TableWidget = _socketInterop(require('blessed-contrib/lib/widget/table'));
59
61
 
60
62
  const {
61
- NPM: NPM$4,
63
+ NPM: NPM$5,
62
64
  PNPM: PNPM$2,
63
65
  cdxgenBinPath,
64
66
  synpBinPath
@@ -69,10 +71,10 @@ const {
69
71
  SBOM_SIGN_PRIVATE_KEY,
70
72
  // Location to the RSA private key
71
73
  SBOM_SIGN_PUBLIC_KEY // Optional. Location to the RSA public key
72
- } = process.env;
74
+ } = process$1.env;
73
75
  const toLower = arg => arg.toLowerCase();
74
76
  const arrayToLower = arg => arg.map(toLower);
75
- const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$4, PNPM$2, 'ts', 'tsx', 'typescript']);
77
+ const nodejsPlatformTypes = new Set(['javascript', 'js', 'nodejs', NPM$5, PNPM$2, 'ts', 'tsx', 'typescript']);
76
78
  const yargsConfig = {
77
79
  configuration: {
78
80
  'camel-case-expansion': false,
@@ -176,20 +178,20 @@ const cdxgen = {
176
178
  length: unknownLength
177
179
  } = unknown;
178
180
  if (unknownLength) {
181
+ process$1.exitCode = 1;
179
182
  console.error(`Unknown ${words.pluralize('argument', unknownLength)}: ${yargv._.join(', ')}`);
180
- process.exitCode = 1;
181
183
  return;
182
184
  }
183
185
  let cleanupPackageLock = false;
184
186
  if (yargv.type !== 'yarn' && nodejsPlatformTypes.has(yargv.type) && fs.existsSync('./yarn.lock')) {
185
187
  if (fs.existsSync('./package-lock.json')) {
186
- yargv.type = NPM$4;
188
+ yargv.type = NPM$5;
187
189
  } else {
188
190
  // Use synp to create a package-lock.json from the yarn.lock,
189
191
  // based on the node_modules folder, for a more accurate SBOM.
190
192
  try {
191
193
  await npm$1.runBin(await fs.promises.realpath(synpBinPath), ['--source-file', './yarn.lock']);
192
- yargv.type = NPM$4;
194
+ yargv.type = NPM$5;
193
195
  cleanupPackageLock = true;
194
196
  } catch {}
195
197
  }
@@ -211,13 +213,82 @@ const cdxgen = {
211
213
  await fs.promises.rm('./package-lock.json');
212
214
  } catch {}
213
215
  }
214
- const fullOutputPath = path.join(process.cwd(), yargv.output);
216
+ const fullOutputPath = path.join(process$1.cwd(), yargv.output);
215
217
  if (fs.existsSync(fullOutputPath)) {
216
218
  console.log(colors.cyanBright(`${yargv.output} created!`));
217
219
  }
218
220
  }
219
221
  };
220
222
 
223
+ const {
224
+ abortSignal: abortSignal$3
225
+ } = constants;
226
+ function shadowNpmInstall(opts) {
227
+ const {
228
+ flags = [],
229
+ ipc,
230
+ ...spawnOptions
231
+ } = {
232
+ __proto__: null,
233
+ ...opts
234
+ };
235
+ const useIpc = objects.isObject(ipc);
236
+ const useDebug = pathResolve.isDebug();
237
+ const promise = spawn(
238
+ // Lazily access constants.execPath.
239
+ constants.execPath, [
240
+ // Lazily access constants.rootBinPath.
241
+ path.join(constants.rootBinPath, 'npm-cli.js'), 'install',
242
+ // Even though the '--silent' flag is passed npm will still run through
243
+ // code paths for 'audit' and 'fund' unless '--no-audit' and '--no-fund'
244
+ // flags are passed.
245
+ ...(useDebug ? ['--no-audit', '--no-fund'] : ['--silent', '--no-audit', '--no-fund']), ...flags], {
246
+ signal: abortSignal$3,
247
+ // Set stdio to include 'ipc'.
248
+ // See https://github.com/nodejs/node/blob/v23.6.0/lib/child_process.js#L161-L166
249
+ // and https://github.com/nodejs/node/blob/v23.6.0/lib/internal/child_process.js#L238.
250
+ stdio: useDebug ?
251
+ // 'inherit'
252
+ useIpc ? [0, 1, 2, 'ipc'] : 'inherit' :
253
+ // 'ignore'
254
+ useIpc ? ['ignore', 'ignore', 'ignore', 'ipc'] : 'ignore',
255
+ ...spawnOptions,
256
+ env: {
257
+ ...process$1.env,
258
+ ...spawnOptions.env
259
+ }
260
+ });
261
+ if (useIpc) {
262
+ promise.process.send(ipc);
263
+ }
264
+ return promise;
265
+ }
266
+
267
+ const {
268
+ SOCKET_CLI_FIX_PACKAGE_LOCK_FILE,
269
+ SOCKET_IPC_HANDSHAKE: SOCKET_IPC_HANDSHAKE$1
270
+ } = constants;
271
+ const fix = {
272
+ description: 'Fix "fixable" Socket alerts',
273
+ hidden: true,
274
+ async run() {
275
+ const spinner$1 = new spinner.Spinner().start();
276
+ try {
277
+ await shadowNpmInstall({
278
+ ipc: {
279
+ [SOCKET_IPC_HANDSHAKE$1]: {
280
+ [SOCKET_CLI_FIX_PACKAGE_LOCK_FILE]: true
281
+ }
282
+ }
283
+ });
284
+ } catch (e) {
285
+ console.error(e);
286
+ } finally {
287
+ spinner$1.stop();
288
+ }
289
+ }
290
+ };
291
+
221
292
  const commonFlags = {
222
293
  help: {
223
294
  type: 'boolean',
@@ -265,47 +336,6 @@ const validationFlags = {
265
336
  }
266
337
  };
267
338
 
268
- const {
269
- API_V0_URL
270
- } = constants;
271
- function handleUnsuccessfulApiResponse(_name, result, spinner) {
272
- // SocketSdkErrorType['error'] is not typed.
273
- const resultErrorMessage = result.error?.message;
274
- const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
275
- if (result.status === 401 || result.status === 403) {
276
- spinner.stop();
277
- throw new sdk.AuthError(message);
278
- }
279
- spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
280
- process.exit(1);
281
- }
282
- async function handleApiCall(value, description) {
283
- let result;
284
- try {
285
- result = await value;
286
- } catch (cause) {
287
- throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
288
- cause
289
- });
290
- }
291
- return result;
292
- }
293
- async function handleAPIError(code) {
294
- if (code === 400) {
295
- return 'One of the options passed might be incorrect.';
296
- } else if (code === 403) {
297
- return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
298
- }
299
- }
300
- async function queryAPI(path, apiKey) {
301
- return await fetch(`${API_V0_URL}/${path}`, {
302
- method: 'GET',
303
- headers: {
304
- Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
305
- }
306
- });
307
- }
308
-
309
339
  function objectSome(obj) {
310
340
  for (const key in obj) {
311
341
  if (obj[key]) {
@@ -322,6 +352,22 @@ function pick(input, keys) {
322
352
  return result;
323
353
  }
324
354
 
355
+ function stringJoinWithSeparateFinalSeparator(list, separator = ' and ') {
356
+ const values = list.filter(Boolean);
357
+ const {
358
+ length
359
+ } = values;
360
+ if (!length) {
361
+ return '';
362
+ }
363
+ if (length === 1) {
364
+ return values[0];
365
+ }
366
+ const finalValue = values.pop();
367
+ return `${values.join(', ')}${separator}${finalValue}`;
368
+ }
369
+
370
+ // Ordered from most severe to least.
325
371
  const SEVERITIES_BY_ORDER = ['critical', 'high', 'middle', 'low'];
326
372
  function getDesiredSeverities(lowestToInclude) {
327
373
  const result = [];
@@ -340,7 +386,7 @@ function formatSeverityCount(severityCount) {
340
386
  summary.push(`${severityCount[severity]} ${severity}`);
341
387
  }
342
388
  }
343
- return sdk.stringJoinWithSeparateFinalSeparator(summary);
389
+ return stringJoinWithSeparateFinalSeparator(summary);
344
390
  }
345
391
  function getSeverityCount(issues, lowestToInclude) {
346
392
  const severityCount = pick({
@@ -350,7 +396,9 @@ function getSeverityCount(issues, lowestToInclude) {
350
396
  critical: 0
351
397
  }, getDesiredSeverities(lowestToInclude));
352
398
  for (const issue of issues) {
353
- const value = issue.value;
399
+ const {
400
+ value
401
+ } = issue;
354
402
  if (!value) {
355
403
  continue;
356
404
  }
@@ -361,18 +409,59 @@ function getSeverityCount(issues, lowestToInclude) {
361
409
  return severityCount;
362
410
  }
363
411
 
364
- function printFlagList(list, indent, {
412
+ const {
413
+ API_V0_URL
414
+ } = constants;
415
+ function handleUnsuccessfulApiResponse(_name, result, spinner) {
416
+ // SocketSdkErrorType['error'] is not typed.
417
+ const resultErrorMessage = result.error?.message;
418
+ const message = typeof resultErrorMessage === 'string' ? resultErrorMessage : 'No error message returned';
419
+ if (result.status === 401 || result.status === 403) {
420
+ spinner.stop();
421
+ throw new socketUrl.AuthError(message);
422
+ }
423
+ spinner.error(`${colors.bgRed(colors.white('API returned an error:'))} ${message}`);
424
+ process$1.exit(1);
425
+ }
426
+ async function handleApiCall(value, description) {
427
+ let result;
428
+ try {
429
+ result = await value;
430
+ } catch (cause) {
431
+ throw new ponyCause.ErrorWithCause(`Failed ${description}`, {
432
+ cause
433
+ });
434
+ }
435
+ return result;
436
+ }
437
+ async function handleAPIError(code) {
438
+ if (code === 400) {
439
+ return 'One of the options passed might be incorrect.';
440
+ } else if (code === 403) {
441
+ return 'You might be trying to access an organization that is not linked to the API key you are logged in with.';
442
+ }
443
+ }
444
+ async function queryAPI(path, apiKey) {
445
+ return await fetch(`${API_V0_URL}/${path}`, {
446
+ method: 'GET',
447
+ headers: {
448
+ Authorization: `Basic ${btoa(`${apiKey}:${apiKey}`)}`
449
+ }
450
+ });
451
+ }
452
+
453
+ function getFlagListOutput(list, indent, {
365
454
  keyPrefix = '--',
366
455
  padName
367
456
  } = {}) {
368
- return printHelpList({
457
+ return getHelpListOutput({
369
458
  ...list
370
459
  }, indent, {
371
460
  keyPrefix,
372
461
  padName
373
462
  });
374
463
  }
375
- function printHelpList(list, indent, {
464
+ function getHelpListOutput(list, indent, {
376
465
  keyPrefix = '',
377
466
  padName = 18
378
467
  } = {}) {
@@ -387,8 +476,8 @@ function printHelpList(list, indent, {
387
476
  }
388
477
 
389
478
  const {
390
- SOCKET_PUBLIC_API_KEY: SOCKET_PUBLIC_API_KEY$1
391
- } = constants;
479
+ NPM: NPM$4
480
+ } = registryConstants;
392
481
  const info = {
393
482
  description: 'Look up info regarding a package',
394
483
  async run(argv, importMeta, {
@@ -398,15 +487,15 @@ const info = {
398
487
  const commandContext = setupCommand$m(name, info.description, argv, importMeta);
399
488
  if (commandContext) {
400
489
  const spinnerText = commandContext.pkgVersion === 'latest' ? `Looking up data for the latest version of ${commandContext.pkgName}` : `Looking up data for version ${commandContext.pkgVersion} of ${commandContext.pkgName}`;
401
- const spinner = yoctoSpinner({
490
+ const spinner$1 = new spinner.Spinner({
402
491
  text: spinnerText
403
492
  }).start();
404
- const packageData = await fetchPackageData(commandContext.pkgName, commandContext.pkgVersion, commandContext, spinner);
493
+ const packageData = await fetchPackageData(commandContext.pkgName, commandContext.pkgVersion, commandContext, spinner$1);
405
494
  if (packageData) {
406
495
  formatPackageDataOutput(packageData, {
407
496
  name,
408
497
  ...commandContext
409
- }, spinner);
498
+ }, spinner$1);
410
499
  }
411
500
  }
412
501
  }
@@ -425,7 +514,7 @@ function setupCommand$m(name, description, argv, importMeta) {
425
514
  $ ${name} <name>
426
515
 
427
516
  Options
428
- ${printFlagList(flags, 6)}
517
+ ${getFlagListOutput(flags, 6)}
429
518
 
430
519
  Examples
431
520
  $ ${name} webtorrent
@@ -437,7 +526,7 @@ function setupCommand$m(name, description, argv, importMeta) {
437
526
  flags
438
527
  });
439
528
  if (cli.input.length > 1) {
440
- throw new sdk.InputError('Only one package lookup supported at once');
529
+ throw new socketUrl.InputError('Only one package lookup supported at once');
441
530
  }
442
531
  const {
443
532
  0: rawPkgName = ''
@@ -465,7 +554,7 @@ function setupCommand$m(name, description, argv, importMeta) {
465
554
  async function fetchPackageData(pkgName, pkgVersion, {
466
555
  includeAllIssues
467
556
  }, spinner) {
468
- const socketSdk = await sdk.setupSdk(sdk.getDefaultKey() ?? SOCKET_PUBLIC_API_KEY$1);
557
+ const socketSdk = await socketUrl.setupSdk(socketUrl.getPublicToken());
469
558
  const result = await handleApiCall(socketSdk.getIssuesByNPMPackage(pkgName, pkgVersion), 'looking up package');
470
559
  const scoreResult = await handleApiCall(socketSdk.getScoreByNPMPackage(pkgName, pkgVersion), 'looking up package score');
471
560
  if (result.success === false) {
@@ -512,8 +601,8 @@ function formatPackageDataOutput({
512
601
  } else {
513
602
  spinner.success('Package has no issues');
514
603
  }
515
- const format = new sdk.ColorOrMarkdown(!!outputMarkdown);
516
- const url = `https://socket.dev/npm/package/${pkgName}/overview/${pkgVersion}`;
604
+ const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
605
+ const url = socketUrl.getSocketDevPackageOverviewUrl(NPM$4, pkgName, pkgVersion);
517
606
  console.log('\n');
518
607
  if (pkgVersion === 'latest') {
519
608
  console.log(`Detailed info on socket.dev: ${format.hyperlink(`${pkgName}`, url, {
@@ -529,7 +618,7 @@ function formatPackageDataOutput({
529
618
  }
530
619
  }
531
620
  if (strict && objectSome(severityCount)) {
532
- process.exit(1);
621
+ process$1.exit(1);
533
622
  }
534
623
  }
535
624
  function formatPackageIssuesDetails(packageData, outputMarkdown) {
@@ -550,9 +639,9 @@ function formatPackageIssuesDetails(packageData, outputMarkdown) {
550
639
  }
551
640
  return acc;
552
641
  }, {});
553
- const format = new sdk.ColorOrMarkdown(!!outputMarkdown);
642
+ const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
554
643
  for (const issue of Object.keys(uniqueIssues)) {
555
- const issueWithLink = format.hyperlink(`${uniqueIssues[issue]?.label}`, `https://socket.dev/npm/issue/${issue}`, {
644
+ const issueWithLink = format.hyperlink(`${uniqueIssues[issue]?.label}`, socketUrl.getSocketDevAlertUrl(issue), {
556
645
  fallbackToUrl: true
557
646
  });
558
647
  if (uniqueIssues[issue]?.count === 1) {
@@ -572,7 +661,7 @@ function formatScore(score) {
572
661
  }
573
662
 
574
663
  const {
575
- SOCKET_PUBLIC_API_KEY
664
+ SOCKET_PUBLIC_API_TOKEN
576
665
  } = constants;
577
666
  const description$5 = 'Socket API login';
578
667
  const flags = {
@@ -601,7 +690,7 @@ const login = {
601
690
  Logs into the Socket API by prompting for an API key
602
691
 
603
692
  Options
604
- ${printFlagList({
693
+ ${getFlagListOutput({
605
694
  'api-base-url': flags['apiBaseUrl'].description,
606
695
  'api-proxy': flags['apiProxy'].description
607
696
  }, 8)}
@@ -623,29 +712,29 @@ const login = {
623
712
  return;
624
713
  }
625
714
  if (!isInteractive()) {
626
- throw new sdk.InputError('Cannot prompt for credentials in a non-interactive shell');
715
+ throw new socketUrl.InputError('Cannot prompt for credentials in a non-interactive shell');
627
716
  }
628
- const apiKey = (await prompts.password({
717
+ const apiToken = (await prompts.password({
629
718
  message: `Enter your ${terminalLink('Socket.dev API key', 'https://docs.socket.dev/docs/api-keys')} (leave blank for a public key)`
630
- })) || SOCKET_PUBLIC_API_KEY;
719
+ })) || SOCKET_PUBLIC_API_TOKEN;
631
720
  let apiBaseUrl = cli.flags['apiBaseUrl'];
632
- apiBaseUrl ??= sdk.getSetting('apiBaseUrl') ?? undefined;
721
+ apiBaseUrl ??= socketUrl.getSetting('apiBaseUrl') ?? undefined;
633
722
  let apiProxy = cli.flags['apiProxy'];
634
- apiProxy ??= sdk.getSetting('apiProxy') ?? undefined;
635
- const spinner = yoctoSpinner({
723
+ apiProxy ??= socketUrl.getSetting('apiProxy') ?? undefined;
724
+ const spinner$1 = new spinner.Spinner({
636
725
  text: 'Verifying API key...'
637
726
  }).start();
638
727
  let orgs;
639
728
  try {
640
- const sdk$1 = await sdk.setupSdk(apiKey, apiBaseUrl, apiProxy);
641
- const result = await sdk$1.getOrganizations();
729
+ const sdk = await socketUrl.setupSdk(apiToken, apiBaseUrl, apiProxy);
730
+ const result = await sdk.getOrganizations();
642
731
  if (!result.success) {
643
- throw new sdk.AuthError();
732
+ throw new socketUrl.AuthError();
644
733
  }
645
734
  orgs = result.data;
646
- spinner.success('API key verified');
735
+ spinner$1.success('API key verified');
647
736
  } catch {
648
- spinner.error('Invalid API key');
737
+ spinner$1.error('Invalid API key');
649
738
  return;
650
739
  }
651
740
  const enforcedChoices = Object.values(orgs.organizations).filter(nonNullish).filter(org => org.plan === 'enterprise').map(org => ({
@@ -677,12 +766,13 @@ const login = {
677
766
  }
678
767
  }
679
768
  }
680
- sdk.updateSetting('enforcedOrgs', enforcedOrgs);
681
- const oldKey = sdk.getSetting('apiKey');
682
- sdk.updateSetting('apiKey', apiKey);
683
- sdk.updateSetting('apiBaseUrl', apiBaseUrl);
684
- sdk.updateSetting('apiProxy', apiProxy);
685
- spinner.success(`API credentials ${oldKey ? 'updated' : 'set'}`);
769
+ socketUrl.updateSetting('enforcedOrgs', enforcedOrgs);
770
+ // TODO: Rename the 'apiKey' setting to 'apiToken'.
771
+ const oldToken = socketUrl.getSetting('apiKey');
772
+ socketUrl.updateSetting('apiKey', apiToken);
773
+ socketUrl.updateSetting('apiBaseUrl', apiBaseUrl);
774
+ socketUrl.updateSetting('apiProxy', apiProxy);
775
+ spinner$1.success(`API credentials ${oldToken ? 'updated' : 'set'}`);
686
776
  }
687
777
  };
688
778
 
@@ -714,11 +804,11 @@ const logout = {
714
804
  cli.showHelp();
715
805
  return;
716
806
  }
717
- sdk.updateSetting('apiKey', null);
718
- sdk.updateSetting('apiBaseUrl', null);
719
- sdk.updateSetting('apiProxy', null);
720
- sdk.updateSetting('enforcedOrgs', null);
721
- yoctoSpinner().success('Successfully logged out');
807
+ socketUrl.updateSetting('apiKey', null);
808
+ socketUrl.updateSetting('apiBaseUrl', null);
809
+ socketUrl.updateSetting('apiProxy', null);
810
+ socketUrl.updateSetting('enforcedOrgs', null);
811
+ new spinner.Spinner().success('Successfully logged out');
722
812
  }
723
813
  };
724
814
 
@@ -746,48 +836,6 @@ const npx = {
746
836
  }
747
837
  };
748
838
 
749
- function existsSync(filepath) {
750
- try {
751
- return filepath ? fs.existsSync(filepath) : false;
752
- } catch {}
753
- return false;
754
- }
755
- async function findUp(name, {
756
- cwd = process.cwd()
757
- }) {
758
- let dir = path.resolve(cwd);
759
- const {
760
- root
761
- } = path.parse(dir);
762
- const names = [name].flat();
763
- while (dir && dir !== root) {
764
- for (const name of names) {
765
- const filePath = path.join(dir, name);
766
- try {
767
- // eslint-disable-next-line no-await-in-loop
768
- const stats = await fs.promises.stat(filePath);
769
- if (stats.isFile()) {
770
- return filePath;
771
- }
772
- } catch {}
773
- }
774
- dir = path.dirname(dir);
775
- }
776
- return undefined;
777
- }
778
- async function readFileBinary(filepath, options) {
779
- return await fs.promises.readFile(filepath, {
780
- ...options,
781
- encoding: 'binary'
782
- });
783
- }
784
- async function readFileUtf8(filepath, options) {
785
- return await fs.promises.readFile(filepath, {
786
- ...options,
787
- encoding: 'utf8'
788
- });
789
- }
790
-
791
839
  const {
792
840
  BINARY_LOCK_EXT,
793
841
  BUN: BUN$1,
@@ -795,20 +843,25 @@ const {
795
843
  NPM: NPM$2,
796
844
  PNPM: PNPM$1,
797
845
  VLT: VLT$1,
846
+ YARN,
798
847
  YARN_BERRY: YARN_BERRY$1,
799
848
  YARN_CLASSIC: YARN_CLASSIC$1
800
849
  } = constants;
801
850
  const AGENTS = [BUN$1, NPM$2, PNPM$1, YARN_BERRY$1, YARN_CLASSIC$1, VLT$1];
802
- const {
803
- compare: alphanumericComparator
804
- } = new Intl.Collator(undefined, {
805
- numeric: true,
806
- sensitivity: 'base'
807
- });
851
+ const binByAgent = {
852
+ __proto__: null,
853
+ [BUN$1]: BUN$1,
854
+ [NPM$2]: NPM$2,
855
+ [PNPM$1]: PNPM$1,
856
+ [YARN_BERRY$1]: YARN,
857
+ [YARN_CLASSIC$1]: YARN,
858
+ [VLT$1]: VLT$1
859
+ };
808
860
  async function getAgentExecPath(agent) {
809
- return (await which(agent, {
861
+ const binName = binByAgent[agent];
862
+ return (await which(binName, {
810
863
  nothrow: true
811
- })) ?? agent;
864
+ })) ?? binName;
812
865
  }
813
866
  async function getAgentVersion(agentExecPath, cwd) {
814
867
  let result;
@@ -852,8 +905,8 @@ const readLockFileByAgent = (() => {
852
905
  return undefined;
853
906
  };
854
907
  }
855
- const binaryReader = wrapReader(readFileBinary);
856
- const defaultReader = wrapReader(async lockPath => await readFileUtf8(lockPath));
908
+ const binaryReader = wrapReader(socketUrl.readFileBinary);
909
+ const defaultReader = wrapReader(async lockPath => await socketUrl.readFileUtf8(lockPath));
857
910
  return {
858
911
  [BUN$1]: wrapReader(async (lockPath, agentExecPath) => {
859
912
  const ext = path.extname(lockPath);
@@ -864,7 +917,7 @@ const readLockFileByAgent = (() => {
864
917
  const lockBuffer = await binaryReader(lockPath);
865
918
  if (lockBuffer) {
866
919
  try {
867
- return hyrious__bun_lockb.parse(lockBuffer);
920
+ return index_cjs.parse(lockBuffer);
868
921
  } catch {}
869
922
  }
870
923
  // To print a Yarn lockfile to your console without writing it to disk
@@ -882,18 +935,18 @@ const readLockFileByAgent = (() => {
882
935
  };
883
936
  })();
884
937
  async function detect({
885
- cwd = process.cwd(),
938
+ cwd = process$1.cwd(),
886
939
  onUnknown
887
940
  } = {}) {
888
- let lockPath = await findUp(Object.keys(LOCKS), {
941
+ let lockPath = await socketUrl.findUp(Object.keys(LOCKS), {
889
942
  cwd
890
943
  });
891
944
  let lockBasename = lockPath ? path.basename(lockPath) : undefined;
892
945
  const isHiddenLockFile = lockBasename === '.package-lock.json';
893
- const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await findUp('package.json', {
946
+ const pkgJsonPath = lockPath ? path.resolve(lockPath, `${isHiddenLockFile ? '../' : ''}../package.json`) : await socketUrl.findUp('package.json', {
894
947
  cwd
895
948
  });
896
- const pkgPath = existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
949
+ const pkgPath = pkgJsonPath && fs.existsSync(pkgJsonPath) ? path.dirname(pkgJsonPath) : undefined;
897
950
  const editablePkgJson = pkgPath ? await packages.readPackageJson(pkgPath, {
898
951
  editable: true
899
952
  }) : undefined;
@@ -950,7 +1003,7 @@ async function detect({
950
1003
  }
951
1004
  const browserslistQuery = pkgJson['browserslist'];
952
1005
  if (Array.isArray(browserslistQuery)) {
953
- const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(alphanumericComparator);
1006
+ const browserslistTargets = browserslist(browserslistQuery).map(s => s.toLowerCase()).sort(sorts.naturalCompare);
954
1007
  const browserslistNodeTargets = browserslistTargets.filter(v => v.startsWith('node ')).map(v => v.slice(5 /*'node '.length*/));
955
1008
  if (!targets.browser && browserslistTargets.length) {
956
1009
  targets.browser = browserslistTargets.length !== browserslistNodeTargets.length;
@@ -989,25 +1042,25 @@ const {
989
1042
  BUN,
990
1043
  LOCK_EXT,
991
1044
  NPM: NPM$1,
1045
+ OVERRIDES,
992
1046
  PNPM,
993
- UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE,
1047
+ RESOLUTIONS,
1048
+ SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE,
1049
+ SOCKET_IPC_HANDSHAKE,
994
1050
  VLT,
995
1051
  YARN_BERRY,
996
1052
  YARN_CLASSIC,
997
- abortSignal: abortSignal$2,
998
- execPath,
999
- rootBinPath
1053
+ abortSignal: abortSignal$2
1000
1054
  } = constants;
1001
1055
  const COMMAND_TITLE = 'Socket Optimize';
1002
- const OVERRIDES_FIELD_NAME = 'overrides';
1003
1056
  const NPM_OVERRIDE_PR_URL = 'https://github.com/npm/cli/pull/7025';
1004
1057
  const PNPM_FIELD_NAME = PNPM;
1005
1058
  const PNPM_WORKSPACE = `${PNPM}-workspace`;
1006
- const RESOLUTIONS_FIELD_NAME = 'resolutions';
1007
1059
  const manifestNpmOverrides = registry.getManifestData(NPM$1);
1008
1060
  const getOverridesDataByAgent = {
1061
+ __proto__: null,
1009
1062
  [BUN](pkgJson) {
1010
- const overrides = pkgJson?.resolutions ?? {};
1063
+ const overrides = pkgJson?.[RESOLUTIONS] ?? {};
1011
1064
  return {
1012
1065
  type: YARN_BERRY,
1013
1066
  overrides
@@ -1016,7 +1069,7 @@ const getOverridesDataByAgent = {
1016
1069
  // npm overrides documentation:
1017
1070
  // https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides
1018
1071
  [NPM$1](pkgJson) {
1019
- const overrides = pkgJson?.overrides ?? {};
1072
+ const overrides = pkgJson?.[OVERRIDES] ?? {};
1020
1073
  return {
1021
1074
  type: NPM$1,
1022
1075
  overrides
@@ -1025,14 +1078,14 @@ const getOverridesDataByAgent = {
1025
1078
  // pnpm overrides documentation:
1026
1079
  // https://pnpm.io/package_json#pnpmoverrides
1027
1080
  [PNPM](pkgJson) {
1028
- const overrides = pkgJson?.pnpm?.overrides ?? {};
1081
+ const overrides = pkgJson?.pnpm?.[OVERRIDES] ?? {};
1029
1082
  return {
1030
1083
  type: PNPM,
1031
1084
  overrides
1032
1085
  };
1033
1086
  },
1034
1087
  [VLT](pkgJson) {
1035
- const overrides = pkgJson?.overrides ?? {};
1088
+ const overrides = pkgJson?.[OVERRIDES] ?? {};
1036
1089
  return {
1037
1090
  type: VLT,
1038
1091
  overrides
@@ -1041,7 +1094,7 @@ const getOverridesDataByAgent = {
1041
1094
  // Yarn resolutions documentation:
1042
1095
  // https://yarnpkg.com/configuration/manifest#resolutions
1043
1096
  [YARN_BERRY](pkgJson) {
1044
- const overrides = pkgJson?.resolutions ?? {};
1097
+ const overrides = pkgJson?.[RESOLUTIONS] ?? {};
1045
1098
  return {
1046
1099
  type: YARN_BERRY,
1047
1100
  overrides
@@ -1050,7 +1103,7 @@ const getOverridesDataByAgent = {
1050
1103
  // Yarn resolutions documentation:
1051
1104
  // https://classic.yarnpkg.com/en/docs/selective-version-resolutions
1052
1105
  [YARN_CLASSIC](pkgJson) {
1053
- const overrides = pkgJson?.resolutions ?? {};
1106
+ const overrides = pkgJson?.[RESOLUTIONS] ?? {};
1054
1107
  return {
1055
1108
  type: YARN_CLASSIC,
1056
1109
  overrides
@@ -1074,6 +1127,7 @@ const lockIncludesByAgent = (() => {
1074
1127
  `(?<=(?:^\\s*|,\\s*)"?)${escapedName}(?=@)`, 'm').test(lockSrc);
1075
1128
  }
1076
1129
  return {
1130
+ __proto__: null,
1077
1131
  [BUN](lockSrc, name, lockBasename) {
1078
1132
  // This is a bit counterintuitive. When lockBasename ends with a .lockb
1079
1133
  // we treat it as a yarn.lock. When lockBasename ends with a .lock we
@@ -1137,7 +1191,7 @@ const updateManifestByAgent = (() => {
1137
1191
  [field]: undefined
1138
1192
  });
1139
1193
  }
1140
- } else if (field === OVERRIDES_FIELD_NAME || field === RESOLUTIONS_FIELD_NAME) {
1194
+ } else if (field === OVERRIDES || field === RESOLUTIONS) {
1141
1195
  // Properties with undefined values are omitted when saved as JSON.
1142
1196
  editablePkgJson.update({
1143
1197
  [field]: objects.hasKeys(value) ? value : undefined
@@ -1149,7 +1203,7 @@ const updateManifestByAgent = (() => {
1149
1203
  }
1150
1204
  return;
1151
1205
  }
1152
- if ((field === OVERRIDES_FIELD_NAME || field === PNPM_FIELD_NAME || field === RESOLUTIONS_FIELD_NAME) && !objects.hasKeys(value)) {
1206
+ if ((field === OVERRIDES || field === PNPM_FIELD_NAME || field === RESOLUTIONS) && !objects.hasKeys(value)) {
1153
1207
  return;
1154
1208
  }
1155
1209
  // Since the field doesn't exist we want to insert it into the package.json
@@ -1158,17 +1212,17 @@ const updateManifestByAgent = (() => {
1158
1212
  const entries = Object.entries(pkgJson);
1159
1213
  let insertIndex = -1;
1160
1214
  let isPlacingHigher = false;
1161
- if (field === OVERRIDES_FIELD_NAME) {
1162
- insertIndex = getLowestEntryIndex(entries, [RESOLUTIONS_FIELD_NAME]);
1215
+ if (field === OVERRIDES) {
1216
+ insertIndex = getLowestEntryIndex(entries, [RESOLUTIONS]);
1163
1217
  if (insertIndex === -1) {
1164
1218
  isPlacingHigher = true;
1165
1219
  insertIndex = getHighestEntryIndex(entries, [...depFields, PNPM]);
1166
1220
  }
1167
- } else if (field === RESOLUTIONS_FIELD_NAME) {
1221
+ } else if (field === RESOLUTIONS) {
1168
1222
  isPlacingHigher = true;
1169
- insertIndex = getHighestEntryIndex(entries, [...depFields, OVERRIDES_FIELD_NAME, PNPM]);
1223
+ insertIndex = getHighestEntryIndex(entries, [...depFields, OVERRIDES, PNPM]);
1170
1224
  } else if (field === PNPM_FIELD_NAME) {
1171
- insertIndex = getLowestEntryIndex(entries, [OVERRIDES_FIELD_NAME, RESOLUTIONS_FIELD_NAME]);
1225
+ insertIndex = getLowestEntryIndex(entries, [OVERRIDES, RESOLUTIONS]);
1172
1226
  if (insertIndex === -1) {
1173
1227
  isPlacingHigher = true;
1174
1228
  insertIndex = getHighestEntryIndex(entries, depFields);
@@ -1190,12 +1244,13 @@ const updateManifestByAgent = (() => {
1190
1244
  editablePkgJson.fromJSON(`${JSON.stringify(Object.fromEntries(entries), null, 2)}\n`);
1191
1245
  }
1192
1246
  function updateOverrides(editablePkgJson, overrides) {
1193
- updatePkgJson(editablePkgJson, OVERRIDES_FIELD_NAME, overrides);
1247
+ updatePkgJson(editablePkgJson, OVERRIDES, overrides);
1194
1248
  }
1195
1249
  function updateResolutions(editablePkgJson, overrides) {
1196
- updatePkgJson(editablePkgJson, RESOLUTIONS_FIELD_NAME, overrides);
1250
+ updatePkgJson(editablePkgJson, RESOLUTIONS, overrides);
1197
1251
  }
1198
1252
  return {
1253
+ __proto__: null,
1199
1254
  [BUN]: updateResolutions,
1200
1255
  [NPM$1]: updateOverrides,
1201
1256
  [PNPM](editablePkgJson, overrides) {
@@ -1257,6 +1312,7 @@ const lsByAgent = (() => {
1257
1312
  return cleanupQueryStdout(stdout);
1258
1313
  }
1259
1314
  return {
1315
+ __proto__: null,
1260
1316
  async [BUN](agentExecPath, cwd) {
1261
1317
  try {
1262
1318
  // Bun does not support filtering by production packages yet.
@@ -1334,6 +1390,7 @@ const depsIncludesByAgent = (() => {
1334
1390
  return stdout.includes(`"${name}"`);
1335
1391
  }
1336
1392
  return {
1393
+ __proto__: null,
1337
1394
  [BUN]: matchHumanStdout,
1338
1395
  [NPM$1]: matchQueryStdout,
1339
1396
  [PNPM]: matchQueryStdout,
@@ -1343,7 +1400,7 @@ const depsIncludesByAgent = (() => {
1343
1400
  };
1344
1401
  })();
1345
1402
  function createActionMessage(verb, overrideCount, workspaceCount) {
1346
- return `${verb} ${overrideCount} Socket.dev optimized overrides${workspaceCount ? ` in ${workspaceCount} ${words.pluralize('workspace', workspaceCount)}` : ''}`;
1403
+ return `${verb} ${overrideCount} Socket.dev optimized ${words.pluralize('override', overrideCount)}${workspaceCount ? ` in ${workspaceCount} ${words.pluralize('workspace', workspaceCount)}` : ''}`;
1347
1404
  }
1348
1405
  function getDependencyEntries(pkgJson) {
1349
1406
  const {
@@ -1372,11 +1429,11 @@ async function getWorkspaceGlobs(agent, pkgPath, pkgJson) {
1372
1429
  let workspacePatterns;
1373
1430
  if (agent === PNPM) {
1374
1431
  for (const workspacePath of [path.join(pkgPath, `${PNPM_WORKSPACE}.yaml`), path.join(pkgPath, `${PNPM_WORKSPACE}.yml`)]) {
1375
- if (existsSync(workspacePath)) {
1432
+ // eslint-disable-next-line no-await-in-loop
1433
+ const yml = await socketUrl.safeReadFile(workspacePath, 'utf8');
1434
+ if (yml) {
1376
1435
  try {
1377
- workspacePatterns = yaml.parse(
1378
- // eslint-disable-next-line no-await-in-loop
1379
- await fs$1.readFile(workspacePath, 'utf8'))?.packages;
1436
+ workspacePatterns = yaml.parse(yml)?.packages;
1380
1437
  } catch {}
1381
1438
  if (workspacePatterns) {
1382
1439
  break;
@@ -1516,7 +1573,7 @@ async function addOverrides({
1516
1573
  const oldSpec = overrideExists ? overrides[origPkgName] : undefined;
1517
1574
  const depAlias = depAliasMap.get(origPkgName);
1518
1575
  const regSpecStartsLike = `${NPM$1}:${regPkgName}@`;
1519
- let newSpec = `${regSpecStartsLike}^${pin ? version : major}`;
1576
+ let newSpec = `${regSpecStartsLike}${pin ? version : `^${major}`}`;
1520
1577
  let thisVersion = version;
1521
1578
  if (depAlias && type === NPM$1) {
1522
1579
  // With npm one may not set an override for a package that one directly
@@ -1533,7 +1590,7 @@ async function addOverrides({
1533
1590
  if (pin) {
1534
1591
  thisVersion = semver.major(semver.coerce(npa(thisSpec).rawSpec)?.version ?? version) === major ? version : (await packages.fetchPackageManifest(thisSpec))?.version ?? version;
1535
1592
  }
1536
- newSpec = `${regSpecStartsLike}^${pin ? thisVersion : semver.major(thisVersion)}`;
1593
+ newSpec = `${regSpecStartsLike}${pin ? thisVersion : `^${semver.major(thisVersion)}`}`;
1537
1594
  } else {
1538
1595
  newSpec = oldSpec;
1539
1596
  }
@@ -1601,7 +1658,7 @@ const optimize = {
1601
1658
  pin,
1602
1659
  prod
1603
1660
  } = commandContext;
1604
- const cwd = process.cwd();
1661
+ const cwd = process$1.cwd();
1605
1662
  const {
1606
1663
  agent,
1607
1664
  agentExecPath,
@@ -1648,13 +1705,13 @@ const optimize = {
1648
1705
  if (lockPath && path.relative(cwd, lockPath).startsWith('.')) {
1649
1706
  console.warn(`⚠️ ${COMMAND_TITLE}: Package ${lockName} found at ${lockPath}`);
1650
1707
  }
1651
- const spinner = yoctoSpinner({
1708
+ const spinner$1 = new spinner.Spinner({
1652
1709
  text: 'Socket optimizing...'
1653
1710
  });
1654
1711
  const state = createAddOverridesState({
1655
- spinner
1712
+ spinner: spinner$1
1656
1713
  });
1657
- spinner.start();
1714
+ spinner$1.start();
1658
1715
  const nodeRange = `>=${minimumNodeVersion}`;
1659
1716
  const manifestEntries = manifestNpmOverrides.filter(({
1660
1717
  1: data
@@ -1672,7 +1729,7 @@ const optimize = {
1672
1729
  prod,
1673
1730
  rootPath: pkgPath
1674
1731
  }, state);
1675
- spinner.stop();
1732
+ spinner$1.stop();
1676
1733
  const addedCount = state.added.size;
1677
1734
  const updatedCount = state.updated.size;
1678
1735
  const pkgJsonChanged = addedCount > 0 || updatedCount > 0;
@@ -1690,23 +1747,24 @@ const optimize = {
1690
1747
  if (isNpm || pkgJsonChanged) {
1691
1748
  // Always update package-lock.json until the npm overrides PR lands:
1692
1749
  // https://github.com/npm/cli/pull/7025
1693
- spinner.start(`Updating ${lockName}...`);
1750
+ spinner$1.start(`Updating ${lockName}...`);
1694
1751
  try {
1695
1752
  if (isNpm) {
1696
- const wrapperPath = path.join(rootBinPath, 'npm-cli.js');
1697
- const npmSpawnOptions = {
1698
- signal: abortSignal$2,
1699
- stdio: 'ignore',
1700
- env: {
1701
- ...process.env,
1702
- [UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE]: '1'
1753
+ const ipc = {
1754
+ [SOCKET_IPC_HANDSHAKE]: {
1755
+ [SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE]: true
1703
1756
  }
1704
1757
  };
1705
- await spawn(execPath, [wrapperPath, 'install', '--silent'], npmSpawnOptions);
1758
+ await shadowNpmInstall({
1759
+ ipc
1760
+ });
1706
1761
  // TODO: This is a temporary workaround for a `npm ci` bug where it
1707
1762
  // will error out after Socket Optimize generates a lock file. More
1708
1763
  // investigation is needed.
1709
- await spawn(execPath, [wrapperPath, 'install', '--silent', '--ignore-scripts', '--package-lock-only'], npmSpawnOptions);
1764
+ await shadowNpmInstall({
1765
+ flags: ['--ignore-scripts', '--package-lock-only'],
1766
+ ipc
1767
+ });
1710
1768
  } else {
1711
1769
  // All package managers support the "install" command.
1712
1770
  await spawn(agentExecPath, ['install'], {
@@ -1714,12 +1772,13 @@ const optimize = {
1714
1772
  stdio: 'ignore'
1715
1773
  });
1716
1774
  }
1717
- spinner.stop();
1775
+ spinner$1.stop();
1718
1776
  if (isNpm) {
1719
1777
  console.log(`💡 Re-run ${COMMAND_TITLE} whenever ${lockName} changes.\n This can be skipped once npm ships ${NPM_OVERRIDE_PR_URL}.`);
1720
1778
  }
1721
- } catch {
1722
- spinner.error(`${COMMAND_TITLE}: ${agent} install failed to update ${lockName}`);
1779
+ } catch (e) {
1780
+ spinner$1.error(`${COMMAND_TITLE}: ${agent} install failed to update ${lockName}`);
1781
+ console.error(e);
1723
1782
  }
1724
1783
  }
1725
1784
  }
@@ -1746,7 +1805,7 @@ function setupCommand$l(name, description, argv, importMeta) {
1746
1805
  $ ${name}
1747
1806
 
1748
1807
  Options
1749
- ${printFlagList(flags, 6)}
1808
+ ${getFlagListOutput(flags, 6)}
1750
1809
 
1751
1810
  Examples
1752
1811
  $ ${name}
@@ -1794,20 +1853,20 @@ function setupCommand$k(name, description, argv, importMeta) {
1794
1853
  });
1795
1854
  }
1796
1855
  async function fetchOrganizations() {
1797
- const apiKey = sdk.getDefaultKey();
1856
+ const apiKey = socketUrl.getDefaultToken();
1798
1857
  if (!apiKey) {
1799
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
1858
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
1800
1859
  }
1801
- const spinner = yoctoSpinner({
1860
+ const spinner$1 = new spinner.Spinner({
1802
1861
  text: 'Fetching organizations...'
1803
1862
  }).start();
1804
- const socketSdk = await sdk.setupSdk(apiKey);
1863
+ const socketSdk = await socketUrl.setupSdk(apiKey);
1805
1864
  const result = await handleApiCall(socketSdk.getOrganizations(), 'looking up organizations');
1806
1865
  if (result.success === false) {
1807
- handleUnsuccessfulApiResponse('getOrganizations', result, spinner);
1866
+ handleUnsuccessfulApiResponse('getOrganizations', result, spinner$1);
1808
1867
  return;
1809
1868
  }
1810
- spinner.stop(`List of organizations associated with your API key: ${colors.italic(apiKey)}`);
1869
+ spinner$1.stop(`List of organizations associated with your API key: ${colors.italic(apiKey)}`);
1811
1870
  const organizations = Object.values(result.data.organizations);
1812
1871
  for (const o of organizations) {
1813
1872
  console.log(`
@@ -1841,7 +1900,7 @@ async function setupCommand$j(name, description, argv, importMeta) {
1841
1900
  $ ${name} <${binName$1} command>
1842
1901
 
1843
1902
  Options
1844
- ${printFlagList(flags, 6)}
1903
+ ${getFlagListOutput(flags, 6)}
1845
1904
 
1846
1905
  Examples
1847
1906
  $ ${name} install
@@ -1866,7 +1925,7 @@ async function setupCommand$j(name, description, argv, importMeta) {
1866
1925
  // The exit code 127 indicates that the command or binary being executed
1867
1926
  // could not be found.
1868
1927
  console.error(`Socket unable to locate ${binName$1}; ensure it is available in the PATH environment variable.`);
1869
- process.exit(127);
1928
+ process$1.exit(127);
1870
1929
  }
1871
1930
  const spawnPromise = spawn(binPath, argv, {
1872
1931
  signal: abortSignal$1,
@@ -1878,9 +1937,9 @@ async function setupCommand$j(name, description, argv, importMeta) {
1878
1937
  return;
1879
1938
  }
1880
1939
  if (signalName) {
1881
- process.kill(process.pid, signalName);
1940
+ process$1.kill(process$1.pid, signalName);
1882
1941
  } else if (code !== null) {
1883
- process.exit(code);
1942
+ process$1.exit(code);
1884
1943
  }
1885
1944
  });
1886
1945
  await spawnPromise;
@@ -1909,7 +1968,7 @@ async function setupCommand$i(name, description, argv, importMeta) {
1909
1968
  $ ${name} <${binName} command>
1910
1969
 
1911
1970
  Options
1912
- ${printFlagList(flags, 6)}
1971
+ ${getFlagListOutput(flags, 6)}
1913
1972
 
1914
1973
  Examples
1915
1974
  $ ${name} install
@@ -1934,7 +1993,7 @@ async function setupCommand$i(name, description, argv, importMeta) {
1934
1993
  // The exit code 127 indicates that the command or binary being executed
1935
1994
  // could not be found.
1936
1995
  console.error(`Socket unable to locate ${binName}; ensure it is available in the PATH environment variable.`);
1937
- process.exit(127);
1996
+ process$1.exit(127);
1938
1997
  }
1939
1998
  const spawnPromise = spawn(binPath, argv, {
1940
1999
  signal: abortSignal,
@@ -1946,9 +2005,9 @@ async function setupCommand$i(name, description, argv, importMeta) {
1946
2005
  return;
1947
2006
  }
1948
2007
  if (signalName) {
1949
- process.kill(process.pid, signalName);
2008
+ process$1.kill(process$1.pid, signalName);
1950
2009
  } else if (code !== null) {
1951
- process.exit(code);
2010
+ process$1.exit(code);
1952
2011
  }
1953
2012
  });
1954
2013
  await spawnPromise;
@@ -1984,7 +2043,7 @@ function setupCommand$h(name, description, argv, importMeta) {
1984
2043
  $ ${name} <report-identifier>
1985
2044
 
1986
2045
  Options
1987
- ${printFlagList(flags, 6)}
2046
+ ${getFlagListOutput(flags, 6)}
1988
2047
 
1989
2048
  Examples
1990
2049
  $ ${name} QXU8PmK7LfH608RAwfIKdbcHgwEd_ZeWJ9QEGv05FJUQ
@@ -2006,7 +2065,7 @@ function setupCommand$h(name, description, argv, importMeta) {
2006
2065
  }
2007
2066
  // Validate the input.
2008
2067
  if (extraInput.length) {
2009
- throw new sdk.InputError(`Can only handle a single report ID at a time, but got ${cli.input.length} report ID:s: ${cli.input.join(', ')}`);
2068
+ throw new socketUrl.InputError(`Can only handle a single report ID at a time, but got ${cli.input.length} report ID:s: ${cli.input.join(', ')}`);
2010
2069
  }
2011
2070
  return {
2012
2071
  includeAllIssues: cli.flags['all'],
@@ -2022,8 +2081,8 @@ async function fetchReportData(reportId, {
2022
2081
  strict
2023
2082
  }) {
2024
2083
  // Do the API call
2025
- const socketSdk = await sdk.setupSdk();
2026
- const spinner = yoctoSpinner({
2084
+ const socketSdk = await socketUrl.setupSdk();
2085
+ const spinner$1 = new spinner.Spinner({
2027
2086
  text: `Fetching report with ID ${reportId} (this could take a while)`
2028
2087
  }).start();
2029
2088
  let result;
@@ -2038,23 +2097,23 @@ async function fetchReportData(reportId, {
2038
2097
  }
2039
2098
  }
2040
2099
  if (result.success === false) {
2041
- return handleUnsuccessfulApiResponse('getReport', result, spinner);
2100
+ return handleUnsuccessfulApiResponse('getReport', result, spinner$1);
2042
2101
  }
2043
2102
 
2044
2103
  // Conclude the status of the API call
2045
2104
 
2046
2105
  if (strict) {
2047
2106
  if (result.data.healthy) {
2048
- spinner.success('Report result is healthy and great!');
2107
+ spinner$1.success('Report result is healthy and great!');
2049
2108
  } else {
2050
- spinner.error('Report result deemed unhealthy for project');
2109
+ spinner$1.error('Report result deemed unhealthy for project');
2051
2110
  }
2052
2111
  } else if (result.data.healthy === false) {
2053
2112
  const severityCount = getSeverityCount(result.data.issues, includeAllIssues ? undefined : 'high');
2054
2113
  const issueSummary = formatSeverityCount(severityCount);
2055
- spinner.success(`Report has these issues: ${issueSummary}`);
2114
+ spinner$1.success(`Report has these issues: ${issueSummary}`);
2056
2115
  } else {
2057
- spinner.success('Report has no issues');
2116
+ spinner$1.success('Report has no issues');
2058
2117
  }
2059
2118
  return result.data;
2060
2119
  }
@@ -2068,7 +2127,7 @@ function formatReportDataOutput(data, {
2068
2127
  if (outputJson) {
2069
2128
  console.log(JSON.stringify(data, undefined, 2));
2070
2129
  } else {
2071
- const format = new sdk.ColorOrMarkdown(!!outputMarkdown);
2130
+ const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
2072
2131
  console.log('\nDetailed info on socket.dev: ' + format.hyperlink(reportId, data.url, {
2073
2132
  fallbackToUrl: true
2074
2133
  }));
@@ -2077,7 +2136,7 @@ function formatReportDataOutput(data, {
2077
2136
  }
2078
2137
  }
2079
2138
  if (strict && data.healthy === false) {
2080
- process.exit(1);
2139
+ process$1.exit(1);
2081
2140
  }
2082
2141
  }
2083
2142
 
@@ -2092,7 +2151,6 @@ const create$2 = {
2092
2151
  const {
2093
2152
  config,
2094
2153
  cwd,
2095
- debugLog,
2096
2154
  dryRun,
2097
2155
  includeAllIssues,
2098
2156
  outputJson,
@@ -2104,7 +2162,6 @@ const create$2 = {
2104
2162
  const result = input && (await createReport(packagePaths, {
2105
2163
  config,
2106
2164
  cwd,
2107
- debugLog,
2108
2165
  dryRun
2109
2166
  }));
2110
2167
  if (result && view) {
@@ -2140,12 +2197,6 @@ async function setupCommand$g(name, description, argv, importMeta) {
2140
2197
  ...commonFlags,
2141
2198
  ...outputFlags,
2142
2199
  ...validationFlags,
2143
- debug: {
2144
- type: 'boolean',
2145
- shortFlag: 'd',
2146
- default: false,
2147
- description: 'Output debug information'
2148
- },
2149
2200
  dryRun: {
2150
2201
  type: 'boolean',
2151
2202
  default: false,
@@ -2172,9 +2223,8 @@ async function setupCommand$g(name, description, argv, importMeta) {
2172
2223
  default ignores from the "ignore-by-default" module.
2173
2224
 
2174
2225
  Options
2175
- ${printFlagList({
2226
+ ${getFlagListOutput({
2176
2227
  all: 'Include all issues',
2177
- debug: 'Output debug information',
2178
2228
  'dry-run': 'Only output what will be done without actually doing it',
2179
2229
  json: 'Output result as json',
2180
2230
  markdown: 'Output result as markdown',
@@ -2204,10 +2254,9 @@ async function setupCommand$g(name, description, argv, importMeta) {
2204
2254
  const {
2205
2255
  dryRun
2206
2256
  } = cli.flags;
2207
- const debugLog = sdk.createDebugLogger(!dryRun || cli.flags['debug']);
2208
2257
 
2209
2258
  // TODO: Allow setting a custom cwd and/or configFile path?
2210
- const cwd = process.cwd();
2259
+ const cwd = process$1.cwd();
2211
2260
  const absoluteConfigPath = path.join(cwd, 'socket.yml');
2212
2261
  const config$1 = await config.readSocketConfig(absoluteConfigPath).catch(cause => {
2213
2262
  if (cause && typeof cause === 'object' && cause instanceof config.SocketValidationError) {
@@ -2219,27 +2268,26 @@ async function setupCommand$g(name, description, argv, importMeta) {
2219
2268
  errors: cause.validationErrors,
2220
2269
  schema: cause.schema
2221
2270
  });
2222
- throw new sdk.InputError('The socket.yml config is not valid', betterErrors.map(err => `[${err.path}] ${err.message}.${err.suggestion ? err.suggestion : ''}`).join('\n'));
2271
+ throw new socketUrl.InputError('The socket.yml config is not valid', betterErrors.map(err => `[${err.path}] ${err.message}.${err.suggestion ? err.suggestion : ''}`).join('\n'));
2223
2272
  } else {
2224
2273
  throw new ponyCause.ErrorWithCause('Failed to read socket.yml config', {
2225
2274
  cause
2226
2275
  });
2227
2276
  }
2228
2277
  });
2229
- const socketSdk = await sdk.setupSdk();
2278
+ const socketSdk = await socketUrl.setupSdk();
2230
2279
  const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
2231
- if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, yoctoSpinner());
2280
+ if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, new spinner.Spinner());
2232
2281
  return res.data;
2233
2282
  }).catch(cause => {
2234
2283
  throw new ponyCause.ErrorWithCause('Failed getting supported files for report', {
2235
2284
  cause
2236
2285
  });
2237
2286
  });
2238
- const packagePaths = await pathResolve.getPackageFiles(cwd, cli.input, config$1, supportedFiles, debugLog);
2287
+ const packagePaths = await pathResolve.getPackageFiles(cwd, cli.input, config$1, supportedFiles);
2239
2288
  return {
2240
2289
  config: config$1,
2241
2290
  cwd,
2242
- debugLog,
2243
2291
  dryRun,
2244
2292
  includeAllIssues: cli.flags['all'],
2245
2293
  outputJson: cli.flags['json'],
@@ -2252,24 +2300,23 @@ async function setupCommand$g(name, description, argv, importMeta) {
2252
2300
  async function createReport(packagePaths, {
2253
2301
  config,
2254
2302
  cwd,
2255
- debugLog,
2256
2303
  dryRun
2257
2304
  }) {
2258
- debugLog('Uploading:', packagePaths.join(`\n${sdk.logSymbols.info} Uploading: `));
2305
+ pathResolve.debugLog('Uploading:', packagePaths.join(`\n${pathResolve.logSymbols.info} Uploading: `));
2259
2306
  if (dryRun) {
2260
2307
  return;
2261
2308
  }
2262
- const socketSdk = await sdk.setupSdk();
2263
- const spinner = yoctoSpinner({
2309
+ const socketSdk = await socketUrl.setupSdk();
2310
+ const spinner$1 = new spinner.Spinner({
2264
2311
  text: `Creating report with ${packagePaths.length} package files`
2265
2312
  }).start();
2266
2313
  const apiCall = socketSdk.createReportFromFilePaths(packagePaths, cwd, config?.issueRules);
2267
2314
  const result = await handleApiCall(apiCall, 'creating report');
2268
2315
  if (result.success) {
2269
- spinner.success();
2316
+ spinner$1.success();
2270
2317
  return result;
2271
2318
  }
2272
- handleUnsuccessfulApiResponse('createReport', result, spinner);
2319
+ handleUnsuccessfulApiResponse('createReport', result, spinner$1);
2273
2320
  return undefined;
2274
2321
  }
2275
2322
  function formatReportCreationOutput(data, {
@@ -2280,7 +2327,7 @@ function formatReportCreationOutput(data, {
2280
2327
  console.log(JSON.stringify(data, undefined, 2));
2281
2328
  return;
2282
2329
  }
2283
- const format = new sdk.ColorOrMarkdown(!!outputMarkdown);
2330
+ const format = new socketUrl.ColorOrMarkdown(!!outputMarkdown);
2284
2331
  console.log(`New report: ${format.hyperlink(data.id, data.url, {
2285
2332
  fallbackToUrl: true
2286
2333
  })}`);
@@ -2322,13 +2369,13 @@ async function meowWithSubcommands(subcommands, options) {
2322
2369
  $ ${name} <command>
2323
2370
 
2324
2371
  Commands
2325
- ${printHelpList({
2326
- ...objects.toSortedObject(subcommands),
2327
- ...objects.toSortedObject(aliases)
2372
+ ${getHelpListOutput({
2373
+ ...objects.toSortedObject(Object.fromEntries(Object.entries(subcommands).filter(entry => !entry[1].hidden))),
2374
+ ...objects.toSortedObject(Object.fromEntries(Object.entries(aliases).filter(entry => !subcommands[entry[1]?.argv[0]]?.hidden)))
2328
2375
  }, 6)}
2329
2376
 
2330
2377
  Options
2331
- ${printFlagList(flags, 6)}
2378
+ ${getFlagListOutput(flags, 6)}
2332
2379
 
2333
2380
  Examples
2334
2381
  $ ${name} --help
@@ -2359,8 +2406,9 @@ const report = {
2359
2406
  }
2360
2407
  };
2361
2408
 
2362
- const BASH_FILE = `${homedir.homedir()}/.bashrc`;
2363
- const ZSH_BASH_FILE = `${homedir.homedir()}/.zshrc`;
2409
+ const HOME_DIR = os.homedir();
2410
+ const BASH_FILE = `${HOME_DIR}/.bashrc`;
2411
+ const ZSH_BASH_FILE = `${HOME_DIR}/.zshrc`;
2364
2412
  const wrapper = {
2365
2413
  description: 'Enable or disable the Socket npm/npx wrapper',
2366
2414
  async run(argv, importMeta, {
@@ -2376,7 +2424,7 @@ function setupCommand$f(name, description, argv, importMeta) {
2376
2424
  $ ${name} <flag>
2377
2425
 
2378
2426
  Options
2379
- ${printFlagList(flags, 6)}
2427
+ ${getFlagListOutput(flags, 6)}
2380
2428
 
2381
2429
  Examples
2382
2430
  $ ${name} --enable
@@ -2431,21 +2479,18 @@ function setupCommand$f(name, description, argv, importMeta) {
2431
2479
  console.error('There was an issue setting up the alias in your bash profile');
2432
2480
  }
2433
2481
  }
2434
- const installSafeNpm = query => {
2435
- console.log(`
2436
- _____ _ _
2437
- | __|___ ___| |_ ___| |_
2438
- |__ | . | _| '_| -_| _|
2439
- |_____|___|___|_,_|___|_|
2440
-
2482
+ function addAlias(file) {
2483
+ return fs.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
2484
+ if (err) {
2485
+ return new Error(`There was an error setting up the alias: ${err}`);
2486
+ }
2487
+ console.log(`
2488
+ The alias was added to ${file}. Running 'npm install' will now be wrapped in Socket's "safe npm" 🎉
2489
+ If you want to disable it at any time, run \`socket wrapper --disable\`
2441
2490
  `);
2442
- const rl = readline.createInterface({
2443
- input: process.stdin,
2444
- output: process.stdout
2445
2491
  });
2446
- return askQuestion(rl, query);
2447
- };
2448
- const askQuestion = (rl, query) => {
2492
+ }
2493
+ function askQuestion(rl, query) {
2449
2494
  rl.question(query, ans => {
2450
2495
  if (ans.toLowerCase() === 'y') {
2451
2496
  try {
@@ -2465,19 +2510,31 @@ const askQuestion = (rl, query) => {
2465
2510
  rl.close();
2466
2511
  }
2467
2512
  });
2468
- };
2469
- const addAlias = file => {
2470
- return fs.appendFile(file, 'alias npm="socket npm"\nalias npx="socket npx"\n', err => {
2471
- if (err) {
2472
- return new Error(`There was an error setting up the alias: ${err}`);
2473
- }
2474
- console.log(`
2475
- The alias was added to ${file}. Running 'npm install' will now be wrapped in Socket's "safe npm" 🎉
2476
- If you want to disable it at any time, run \`socket wrapper --disable\`
2513
+ }
2514
+ function checkSocketWrapperAlreadySetup(file) {
2515
+ const fileContent = fs.readFileSync(file, 'utf8');
2516
+ const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
2517
+ if (linesWithSocketAlias.length) {
2518
+ console.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
2519
+ return true;
2520
+ }
2521
+ return false;
2522
+ }
2523
+ function installSafeNpm(query) {
2524
+ console.log(`
2525
+ _____ _ _
2526
+ | __|___ ___| |_ ___| |_
2527
+ |__ | . | _| '_| -_| _|
2528
+ |_____|___|___|_,_|___|_|
2529
+
2477
2530
  `);
2531
+ const rl = readline.createInterface({
2532
+ input: process$1.stdin,
2533
+ output: process$1.stdout
2478
2534
  });
2479
- };
2480
- const removeAlias = file => {
2535
+ return askQuestion(rl, query);
2536
+ }
2537
+ function removeAlias(file) {
2481
2538
  return fs.readFile(file, 'utf8', function (err, data) {
2482
2539
  if (err) {
2483
2540
  console.error(`There was an error removing the alias: ${err}`);
@@ -2494,16 +2551,7 @@ const removeAlias = file => {
2494
2551
  }
2495
2552
  });
2496
2553
  });
2497
- };
2498
- const checkSocketWrapperAlreadySetup = file => {
2499
- const fileContent = fs.readFileSync(file, 'utf8');
2500
- const linesWithSocketAlias = fileContent.split('\n').filter(l => l === 'alias npm="socket npm"' || l === 'alias npx="socket npx"');
2501
- if (linesWithSocketAlias.length) {
2502
- console.log(`The Socket npm/npx wrapper is set up in your bash profile (${file}).`);
2503
- return true;
2504
- }
2505
- return false;
2506
- };
2554
+ }
2507
2555
 
2508
2556
  const create$1 = {
2509
2557
  description: 'Create a scan',
@@ -2513,15 +2561,15 @@ const create$1 = {
2513
2561
  const name = `${parentName} create`;
2514
2562
  const input = await setupCommand$e(name, create$1.description, argv, importMeta);
2515
2563
  if (input) {
2516
- const apiKey = sdk.getDefaultKey();
2564
+ const apiKey = socketUrl.getDefaultToken();
2517
2565
  if (!apiKey) {
2518
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2566
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2519
2567
  }
2520
2568
  const spinnerText = 'Creating a scan... \n';
2521
- const spinner = yoctoSpinner({
2569
+ const spinner$1 = new spinner.Spinner({
2522
2570
  text: spinnerText
2523
2571
  }).start();
2524
- await createFullScan(input, spinner, apiKey);
2572
+ await createFullScan(input, spinner$1, apiKey);
2525
2573
  }
2526
2574
  }
2527
2575
  };
@@ -2592,7 +2640,7 @@ async function setupCommand$e(name, description, argv, importMeta) {
2592
2640
  $ ${name} [...options]
2593
2641
 
2594
2642
  Options
2595
- ${printFlagList(flags, 6)}
2643
+ ${getFlagListOutput(flags, 6)}
2596
2644
 
2597
2645
  Examples
2598
2646
  $ ${name} --org=FakeOrg --repo=test-repo --branch=main ./package.json
@@ -2613,10 +2661,10 @@ async function setupCommand$e(name, description, argv, importMeta) {
2613
2661
  const {
2614
2662
  0: orgSlug = ''
2615
2663
  } = cli.input;
2616
- const cwd = process.cwd();
2617
- const socketSdk = await sdk.setupSdk();
2664
+ const cwd = process$1.cwd();
2665
+ const socketSdk = await socketUrl.setupSdk();
2618
2666
  const supportedFiles = await socketSdk.getReportSupportedFiles().then(res => {
2619
- if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, yoctoSpinner());
2667
+ if (!res.success) handleUnsuccessfulApiResponse('getReportSupportedFiles', res, new spinner.Spinner());
2620
2668
  return res.data;
2621
2669
  }).catch(/** @type {(cause: Error) => never} */
2622
2670
  cause => {
@@ -2624,8 +2672,7 @@ async function setupCommand$e(name, description, argv, importMeta) {
2624
2672
  cause
2625
2673
  });
2626
2674
  });
2627
- const debugLog = sdk.createDebugLogger(false);
2628
- const packagePaths = await pathResolve.getPackageFilesFullScans(cwd, cli.input, supportedFiles, debugLog);
2675
+ const packagePaths = await pathResolve.getPackageFilesFullScans(cwd, cli.input, supportedFiles);
2629
2676
  const {
2630
2677
  branch: branchName,
2631
2678
  repo: repoName
@@ -2656,7 +2703,7 @@ async function setupCommand$e(name, description, argv, importMeta) {
2656
2703
  };
2657
2704
  }
2658
2705
  async function createFullScan(input, spinner, apiKey) {
2659
- const socketSdk = await sdk.setupSdk(apiKey);
2706
+ const socketSdk = await socketUrl.setupSdk(apiKey);
2660
2707
  const {
2661
2708
  branchName,
2662
2709
  commitMessage,
@@ -2683,8 +2730,8 @@ async function createFullScan(input, spinner, apiKey) {
2683
2730
  const link = colors.underline(colors.cyan(`${result.data.html_report_url}`));
2684
2731
  console.log(`Available at: ${link}`);
2685
2732
  const rl = readline$1.createInterface({
2686
- input: node_process.stdin,
2687
- output: node_process.stdout
2733
+ input: process$1.stdin,
2734
+ output: process$1.stdout
2688
2735
  });
2689
2736
  const answer = await rl.question('Would you like to open it in your browser? (y/n)');
2690
2737
  if (answer.toLowerCase() === 'y') {
@@ -2701,15 +2748,15 @@ const del$1 = {
2701
2748
  const name = `${parentName} del`;
2702
2749
  const input = setupCommand$d(name, del$1.description, argv, importMeta);
2703
2750
  if (input) {
2704
- const apiKey = sdk.getDefaultKey();
2751
+ const apiKey = socketUrl.getDefaultToken();
2705
2752
  if (!apiKey) {
2706
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2753
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2707
2754
  }
2708
2755
  const spinnerText = 'Deleting scan...';
2709
- const spinner = yoctoSpinner({
2756
+ const spinner$1 = new spinner.Spinner({
2710
2757
  text: spinnerText
2711
2758
  }).start();
2712
- await deleteOrgFullScan(input.orgSlug, input.fullScanId, spinner, apiKey);
2759
+ await deleteOrgFullScan(input.orgSlug, input.fullScanId, spinner$1, apiKey);
2713
2760
  }
2714
2761
  }
2715
2762
  };
@@ -2726,7 +2773,7 @@ function setupCommand$d(name, description, argv, importMeta) {
2726
2773
  $ ${name} <org slug> <scan ID>
2727
2774
 
2728
2775
  Options
2729
- ${printFlagList(flags, 6)}
2776
+ ${getFlagListOutput(flags, 6)}
2730
2777
 
2731
2778
  Examples
2732
2779
  $ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
@@ -2757,7 +2804,7 @@ function setupCommand$d(name, description, argv, importMeta) {
2757
2804
  };
2758
2805
  }
2759
2806
  async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
2760
- const socketSdk = await sdk.setupSdk(apiKey);
2807
+ const socketSdk = await socketUrl.setupSdk(apiKey);
2761
2808
  const result = await handleApiCall(socketSdk.deleteOrgFullScan(orgSlug, fullScanId), 'Deleting scan');
2762
2809
  if (result.success) {
2763
2810
  spinner.success('Scan deleted successfully');
@@ -2766,6 +2813,7 @@ async function deleteOrgFullScan(orgSlug, fullScanId, spinner, apiKey) {
2766
2813
  }
2767
2814
  }
2768
2815
 
2816
+ // @ts-ignore
2769
2817
  const list$1 = {
2770
2818
  description: 'List scans for an organization',
2771
2819
  async run(argv, importMeta, {
@@ -2774,15 +2822,15 @@ const list$1 = {
2774
2822
  const name = `${parentName} list`;
2775
2823
  const input = setupCommand$c(name, list$1.description, argv, importMeta);
2776
2824
  if (input) {
2777
- const apiKey = sdk.getDefaultKey();
2825
+ const apiKey = socketUrl.getDefaultToken();
2778
2826
  if (!apiKey) {
2779
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2827
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2780
2828
  }
2781
2829
  const spinnerText = 'Listing scans... \n';
2782
- const spinner = yoctoSpinner({
2830
+ const spinner$1 = new spinner.Spinner({
2783
2831
  text: spinnerText
2784
2832
  }).start();
2785
- await listOrgFullScan(input.orgSlug, input, spinner, apiKey);
2833
+ await listOrgFullScan(input.orgSlug, input, spinner$1, apiKey);
2786
2834
  }
2787
2835
  }
2788
2836
  };
@@ -2838,7 +2886,7 @@ function setupCommand$c(name, description, argv, importMeta) {
2838
2886
  $ ${name} <org slug>
2839
2887
 
2840
2888
  Options
2841
- ${printFlagList(flags, 6)}
2889
+ ${getFlagListOutput(flags, 6)}
2842
2890
 
2843
2891
  Examples
2844
2892
  $ ${name} FakeOrg
@@ -2873,7 +2921,7 @@ function setupCommand$c(name, description, argv, importMeta) {
2873
2921
  };
2874
2922
  }
2875
2923
  async function listOrgFullScan(orgSlug, input, spinner, apiKey) {
2876
- const socketSdk = await sdk.setupSdk(apiKey);
2924
+ const socketSdk = await socketUrl.setupSdk(apiKey);
2877
2925
  const result = await handleApiCall(socketSdk.getOrgFullScanList(orgSlug, input), 'Listing scans');
2878
2926
  if (!result.success) {
2879
2927
  handleUnsuccessfulApiResponse('getOrgFullScanList', result, spinner);
@@ -2918,15 +2966,15 @@ const metadata = {
2918
2966
  const name = `${parentName} metadata`;
2919
2967
  const input = setupCommand$b(name, metadata.description, argv, importMeta);
2920
2968
  if (input) {
2921
- const apiKey = sdk.getDefaultKey();
2969
+ const apiKey = socketUrl.getDefaultToken();
2922
2970
  if (!apiKey) {
2923
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2971
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2924
2972
  }
2925
2973
  const spinnerText = "Getting scan's metadata... \n";
2926
- const spinner = yoctoSpinner({
2974
+ const spinner$1 = new spinner.Spinner({
2927
2975
  text: spinnerText
2928
2976
  }).start();
2929
- await getOrgScanMetadata(input.orgSlug, input.scanID, spinner, apiKey);
2977
+ await getOrgScanMetadata(input.orgSlug, input.scanID, spinner$1, apiKey);
2930
2978
  }
2931
2979
  }
2932
2980
  };
@@ -2943,7 +2991,7 @@ function setupCommand$b(name, description, argv, importMeta) {
2943
2991
  $ ${name} <org slug> <scan id>
2944
2992
 
2945
2993
  Options
2946
- ${printFlagList(flags, 6)}
2994
+ ${getFlagListOutput(flags, 6)}
2947
2995
 
2948
2996
  Examples
2949
2997
  $ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0
@@ -2974,7 +3022,7 @@ function setupCommand$b(name, description, argv, importMeta) {
2974
3022
  };
2975
3023
  }
2976
3024
  async function getOrgScanMetadata(orgSlug, scanId, spinner, apiKey) {
2977
- const socketSdk = await sdk.setupSdk(apiKey);
3025
+ const socketSdk = await socketUrl.setupSdk(apiKey);
2978
3026
  const result = await handleApiCall(socketSdk.getOrgFullScanMetadata(orgSlug, scanId), 'Listing scans');
2979
3027
  if (!result.success) {
2980
3028
  handleUnsuccessfulApiResponse('getOrgFullScanMetadata', result, spinner);
@@ -2992,18 +3040,18 @@ const stream = {
2992
3040
  const name = `${parentName} stream`;
2993
3041
  const input = setupCommand$a(name, stream.description, argv, importMeta);
2994
3042
  if (input) {
2995
- const apiKey = sdk.getDefaultKey();
3043
+ const apiKey = socketUrl.getDefaultToken();
2996
3044
  if (!apiKey) {
2997
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3045
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
2998
3046
  }
2999
- const spinner = yoctoSpinner({
3047
+ const spinner$1 = new spinner.Spinner({
3000
3048
  text: 'Streaming scan...'
3001
3049
  }).start();
3002
3050
  const result = await getOrgFullScan(input.orgSlug, input.fullScanId, input.file, apiKey);
3003
3051
  if (result?.success) {
3004
- spinner.stop(input.file ? `Full scan details written to ${input.file}` : '');
3052
+ spinner$1.stop(input.file ? `Full scan details written to ${input.file}` : '');
3005
3053
  } else {
3006
- handleUnsuccessfulApiResponse('getOrgFullScan', result, spinner);
3054
+ handleUnsuccessfulApiResponse('getOrgFullScan', result, spinner$1);
3007
3055
  }
3008
3056
  }
3009
3057
  }
@@ -3021,7 +3069,7 @@ function setupCommand$a(name, description, argv, importMeta) {
3021
3069
  $ ${name} <org slug> <scan ID> <path to output file>
3022
3070
 
3023
3071
  Options
3024
- ${printFlagList(flags, 6)}
3072
+ ${getFlagListOutput(flags, 6)}
3025
3073
 
3026
3074
  Examples
3027
3075
  $ ${name} FakeOrg 000aaaa1-0000-0a0a-00a0-00a0000000a0 ./stream.txt
@@ -3054,7 +3102,7 @@ function setupCommand$a(name, description, argv, importMeta) {
3054
3102
  };
3055
3103
  }
3056
3104
  async function getOrgFullScan(orgSlug, fullScanId, file, apiKey) {
3057
- const socketSdk = await sdk.setupSdk(apiKey);
3105
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3058
3106
  return await handleApiCall(socketSdk.getOrgFullScan(orgSlug, fullScanId, file), 'Streaming a scan');
3059
3107
  }
3060
3108
 
@@ -3087,14 +3135,14 @@ const auditLog = {
3087
3135
  const name = parentName + ' audit-log';
3088
3136
  const input = setupCommand$9(name, auditLog.description, argv, importMeta);
3089
3137
  if (input) {
3090
- const apiKey = sdk.getDefaultKey();
3138
+ const apiKey = socketUrl.getDefaultToken();
3091
3139
  if (!apiKey) {
3092
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3140
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3093
3141
  }
3094
- const spinner = yoctoSpinner({
3142
+ const spinner$1 = new spinner.Spinner({
3095
3143
  text: `Looking up audit log for ${input.orgSlug}\n`
3096
3144
  }).start();
3097
- await fetchOrgAuditLog(input.orgSlug, input, spinner, apiKey);
3145
+ await fetchOrgAuditLog(input.orgSlug, input, spinner$1, apiKey);
3098
3146
  }
3099
3147
  }
3100
3148
  };
@@ -3132,7 +3180,7 @@ function setupCommand$9(name, description, argv, importMeta) {
3132
3180
  $ ${name} <org slug>
3133
3181
 
3134
3182
  Options
3135
- ${printFlagList(flags, 6)}
3183
+ ${getFlagListOutput(flags, 6)}
3136
3184
 
3137
3185
  Examples
3138
3186
  $ ${name} FakeOrg
@@ -3171,7 +3219,7 @@ function setupCommand$9(name, description, argv, importMeta) {
3171
3219
  };
3172
3220
  }
3173
3221
  async function fetchOrgAuditLog(orgSlug, input, spinner, apiKey) {
3174
- const socketSdk = await sdk.setupSdk(apiKey);
3222
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3175
3223
  const result = await handleApiCall(socketSdk.getAuditLogEvents(orgSlug, input), `Looking up audit log for ${orgSlug}\n`);
3176
3224
  if (!result.success) {
3177
3225
  handleUnsuccessfulApiResponse('getAuditLogEvents', result, spinner);
@@ -3211,15 +3259,15 @@ const create = {
3211
3259
  const name = `${parentName} create`;
3212
3260
  const input = setupCommand$8(name, create.description, argv, importMeta);
3213
3261
  if (input) {
3214
- const apiKey = sdk.getDefaultKey();
3262
+ const apiKey = socketUrl.getDefaultToken();
3215
3263
  if (!apiKey) {
3216
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3264
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3217
3265
  }
3218
3266
  const spinnerText = 'Creating repository... \n';
3219
- const spinner = yoctoSpinner({
3267
+ const spinner$1 = new spinner.Spinner({
3220
3268
  text: spinnerText
3221
3269
  }).start();
3222
- await createRepo(input.orgSlug, input, spinner, apiKey);
3270
+ await createRepo(input.orgSlug, input, spinner$1, apiKey);
3223
3271
  }
3224
3272
  }
3225
3273
  };
@@ -3269,7 +3317,7 @@ function setupCommand$8(name, description, argv, importMeta) {
3269
3317
  $ ${name} <org slug>
3270
3318
 
3271
3319
  Options
3272
- ${printFlagList(flags, 6)}
3320
+ ${getFlagListOutput(flags, 6)}
3273
3321
 
3274
3322
  Examples
3275
3323
  $ ${name} FakeOrg --repoName=test-repo
@@ -3307,7 +3355,7 @@ function setupCommand$8(name, description, argv, importMeta) {
3307
3355
  };
3308
3356
  }
3309
3357
  async function createRepo(orgSlug, input, spinner, apiKey) {
3310
- const socketSdk = await sdk.setupSdk(apiKey);
3358
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3311
3359
  const result = await handleApiCall(socketSdk.createOrgRepo(orgSlug, input), 'creating repository');
3312
3360
  if (result.success) {
3313
3361
  spinner.success('Repository created successfully');
@@ -3324,15 +3372,15 @@ const del = {
3324
3372
  const name = `${parentName} del`;
3325
3373
  const input = setupCommand$7(name, del.description, argv, importMeta);
3326
3374
  if (input) {
3327
- const apiKey = sdk.getDefaultKey();
3375
+ const apiKey = socketUrl.getDefaultToken();
3328
3376
  if (!apiKey) {
3329
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3377
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3330
3378
  }
3331
3379
  const spinnerText = 'Deleting repository... \n';
3332
- const spinner = yoctoSpinner({
3380
+ const spinner$1 = new spinner.Spinner({
3333
3381
  text: spinnerText
3334
3382
  }).start();
3335
- await deleteRepository(input.orgSlug, input.repoName, spinner, apiKey);
3383
+ await deleteRepository(input.orgSlug, input.repoName, spinner$1, apiKey);
3336
3384
  }
3337
3385
  }
3338
3386
  };
@@ -3370,7 +3418,7 @@ function setupCommand$7(name, description, argv, importMeta) {
3370
3418
  };
3371
3419
  }
3372
3420
  async function deleteRepository(orgSlug, repoName, spinner, apiKey) {
3373
- const socketSdk = await sdk.setupSdk(apiKey);
3421
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3374
3422
  const result = await handleApiCall(socketSdk.deleteOrgRepo(orgSlug, repoName), 'deleting repository');
3375
3423
  if (result.success) {
3376
3424
  spinner.success('Repository deleted successfully');
@@ -3379,6 +3427,7 @@ async function deleteRepository(orgSlug, repoName, spinner, apiKey) {
3379
3427
  }
3380
3428
  }
3381
3429
 
3430
+ // @ts-ignore
3382
3431
  const list = {
3383
3432
  description: 'List repositories in an organization',
3384
3433
  async run(argv, importMeta, {
@@ -3387,15 +3436,15 @@ const list = {
3387
3436
  const name = `${parentName} list`;
3388
3437
  const input = setupCommand$6(name, list.description, argv, importMeta);
3389
3438
  if (input) {
3390
- const apiKey = sdk.getDefaultKey();
3439
+ const apiKey = socketUrl.getDefaultToken();
3391
3440
  if (!apiKey) {
3392
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3441
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3393
3442
  }
3394
3443
  const spinnerText = 'Listing repositories... \n';
3395
- const spinner = yoctoSpinner({
3444
+ const spinner$1 = new spinner.Spinner({
3396
3445
  text: spinnerText
3397
3446
  }).start();
3398
- await listOrgRepos(input.orgSlug, input, spinner, apiKey);
3447
+ await listOrgRepos(input.orgSlug, input, spinner$1, apiKey);
3399
3448
  }
3400
3449
  }
3401
3450
  };
@@ -3438,7 +3487,7 @@ function setupCommand$6(name, description, argv, importMeta) {
3438
3487
  $ ${name} <org slug>
3439
3488
 
3440
3489
  Options
3441
- ${printFlagList(flags, 6)}
3490
+ ${getFlagListOutput(flags, 6)}
3442
3491
 
3443
3492
  Examples
3444
3493
  $ ${name} FakeOrg
@@ -3471,7 +3520,7 @@ function setupCommand$6(name, description, argv, importMeta) {
3471
3520
  };
3472
3521
  }
3473
3522
  async function listOrgRepos(orgSlug, input, spinner, apiKey) {
3474
- const socketSdk = await sdk.setupSdk(apiKey);
3523
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3475
3524
  const result = await handleApiCall(socketSdk.getOrgRepoList(orgSlug, input), 'listing repositories');
3476
3525
  if (!result.success) {
3477
3526
  handleUnsuccessfulApiResponse('getOrgRepoList', result, spinner);
@@ -3506,15 +3555,15 @@ const update = {
3506
3555
  const name = `${parentName} update`;
3507
3556
  const input = setupCommand$5(name, update.description, argv, importMeta);
3508
3557
  if (input) {
3509
- const apiKey = sdk.getDefaultKey();
3558
+ const apiKey = socketUrl.getDefaultToken();
3510
3559
  if (!apiKey) {
3511
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3560
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3512
3561
  }
3513
3562
  const spinnerText = 'Updating repository... \n';
3514
- const spinner = yoctoSpinner({
3563
+ const spinner$1 = new spinner.Spinner({
3515
3564
  text: spinnerText
3516
3565
  }).start();
3517
- await updateRepository(input.orgSlug, input, spinner, apiKey);
3566
+ await updateRepository(input.orgSlug, input, spinner$1, apiKey);
3518
3567
  }
3519
3568
  }
3520
3569
  };
@@ -3564,7 +3613,7 @@ function setupCommand$5(name, description, argv, importMeta) {
3564
3613
  $ ${name} <org slug>
3565
3614
 
3566
3615
  Options
3567
- ${printFlagList(flags, 6)}
3616
+ ${getFlagListOutput(flags, 6)}
3568
3617
 
3569
3618
  Examples
3570
3619
  $ ${name} FakeOrg
@@ -3602,7 +3651,7 @@ function setupCommand$5(name, description, argv, importMeta) {
3602
3651
  };
3603
3652
  }
3604
3653
  async function updateRepository(orgSlug, input, spinner, apiKey) {
3605
- const socketSdk = await sdk.setupSdk(apiKey);
3654
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3606
3655
  const result = await handleApiCall(socketSdk.updateOrgRepo(orgSlug, input.name, input), 'updating repository');
3607
3656
  if (result.success) {
3608
3657
  spinner.success('Repository updated successfully');
@@ -3611,6 +3660,7 @@ async function updateRepository(orgSlug, input, spinner, apiKey) {
3611
3660
  }
3612
3661
  }
3613
3662
 
3663
+ // @ts-ignore
3614
3664
  const view = {
3615
3665
  description: 'View repositories in an organization',
3616
3666
  async run(argv, importMeta, {
@@ -3619,15 +3669,15 @@ const view = {
3619
3669
  const name = `${parentName} view`;
3620
3670
  const input = setupCommand$4(name, view.description, argv, importMeta);
3621
3671
  if (input) {
3622
- const apiKey = sdk.getDefaultKey();
3672
+ const apiKey = socketUrl.getDefaultToken();
3623
3673
  if (!apiKey) {
3624
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3674
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3625
3675
  }
3626
3676
  const spinnerText = 'Fetching repository... \n';
3627
- const spinner = yoctoSpinner({
3677
+ const spinner$1 = new spinner.Spinner({
3628
3678
  text: spinnerText
3629
3679
  }).start();
3630
- await viewRepository(input.orgSlug, input.repositoryName, spinner, apiKey);
3680
+ await viewRepository(input.orgSlug, input.repositoryName, spinner$1, apiKey);
3631
3681
  }
3632
3682
  }
3633
3683
  };
@@ -3644,7 +3694,7 @@ function setupCommand$4(name, description, argv, importMeta) {
3644
3694
  $ ${name} <org slug>
3645
3695
 
3646
3696
  Options
3647
- ${printFlagList(flags, 6)}
3697
+ ${getFlagListOutput(flags, 6)}
3648
3698
 
3649
3699
  Examples
3650
3700
  $ ${name} FakeOrg
@@ -3675,7 +3725,7 @@ function setupCommand$4(name, description, argv, importMeta) {
3675
3725
  };
3676
3726
  }
3677
3727
  async function viewRepository(orgSlug, repoName, spinner, apiKey) {
3678
- const socketSdk = await sdk.setupSdk(apiKey);
3728
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3679
3729
  const result = await handleApiCall(socketSdk.getOrgRepo(orgSlug, repoName), 'fetching repository');
3680
3730
  if (!result.success) {
3681
3731
  handleUnsuccessfulApiResponse('getOrgRepo', result, spinner);
@@ -3729,6 +3779,7 @@ const repo = {
3729
3779
  }
3730
3780
  };
3731
3781
 
3782
+ // @ts-ignore
3732
3783
  const dependencies = {
3733
3784
  description: 'Search for any dependency that is being used in your organization',
3734
3785
  async run(argv, importMeta, {
@@ -3769,7 +3820,7 @@ function setupCommand$3(name, description, argv, importMeta) {
3769
3820
  $ ${name}
3770
3821
 
3771
3822
  Options
3772
- ${printFlagList(flags, 6)}
3823
+ ${getFlagListOutput(flags, 6)}
3773
3824
 
3774
3825
  Examples
3775
3826
  $ ${name}
@@ -3797,23 +3848,23 @@ async function searchDeps({
3797
3848
  offset,
3798
3849
  outputJson
3799
3850
  }) {
3800
- const apiKey = sdk.getDefaultKey();
3851
+ const apiKey = socketUrl.getDefaultToken();
3801
3852
  if (!apiKey) {
3802
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3853
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3803
3854
  }
3804
- const spinner = yoctoSpinner({
3855
+ const spinner$1 = new spinner.Spinner({
3805
3856
  text: 'Searching dependencies...'
3806
3857
  }).start();
3807
- const socketSdk = await sdk.setupSdk(apiKey);
3858
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3808
3859
  const result = await handleApiCall(socketSdk.searchDependencies({
3809
3860
  limit,
3810
3861
  offset
3811
3862
  }), 'Searching dependencies');
3812
3863
  if (!result.success) {
3813
- handleUnsuccessfulApiResponse('searchDependencies', result, spinner);
3864
+ handleUnsuccessfulApiResponse('searchDependencies', result, spinner$1);
3814
3865
  return;
3815
3866
  }
3816
- spinner.stop('Organization dependencies:');
3867
+ spinner$1.stop('Organization dependencies:');
3817
3868
  if (outputJson) {
3818
3869
  console.log(result.data);
3819
3870
  return;
@@ -3854,18 +3905,18 @@ const analytics = {
3854
3905
  const name = parentName + ' analytics';
3855
3906
  const input = setupCommand$2(name, analytics.description, argv, importMeta);
3856
3907
  if (input) {
3857
- const apiKey = sdk.getDefaultKey();
3908
+ const apiKey = socketUrl.getDefaultToken();
3858
3909
  if (!apiKey) {
3859
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3910
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
3860
3911
  }
3861
- const spinner = yoctoSpinner({
3912
+ const spinner$1 = new spinner.Spinner({
3862
3913
  text: 'Fetching analytics data'
3863
3914
  }).start();
3864
3915
  if (input.scope === 'org') {
3865
- await fetchOrgAnalyticsData(input.time, spinner, apiKey, input.outputJson, input.file);
3916
+ await fetchOrgAnalyticsData(input.time, spinner$1, apiKey, input.outputJson, input.file);
3866
3917
  } else {
3867
3918
  if (input.repo) {
3868
- await fetchRepoAnalyticsData(input.repo, input.time, spinner, apiKey, input.outputJson, input.file);
3919
+ await fetchRepoAnalyticsData(input.repo, input.time, spinner$1, apiKey, input.outputJson, input.file);
3869
3920
  }
3870
3921
  }
3871
3922
  }
@@ -3911,7 +3962,7 @@ function setupCommand$2(name, description, argv, importMeta) {
3911
3962
  $ ${name} --scope=<scope> --time=<time filter>
3912
3963
 
3913
3964
  Options
3914
- ${printFlagList(flags, 6)}
3965
+ ${getFlagListOutput(flags, 6)}
3915
3966
 
3916
3967
  Examples
3917
3968
  $ ${name} --scope=org --time=7
@@ -3929,10 +3980,10 @@ function setupCommand$2(name, description, argv, importMeta) {
3929
3980
  time
3930
3981
  } = cli.flags;
3931
3982
  if (scope !== 'org' && scope !== 'repo') {
3932
- throw new sdk.InputError("The scope must either be 'org' or 'repo'");
3983
+ throw new socketUrl.InputError("The scope must either be 'org' or 'repo'");
3933
3984
  }
3934
3985
  if (time !== 7 && time !== 30 && time !== 90) {
3935
- throw new sdk.InputError('The time filter must either be 7, 30 or 90');
3986
+ throw new socketUrl.InputError('The time filter must either be 7, 30 or 90');
3936
3987
  }
3937
3988
  let showHelp = cli.flags['help'];
3938
3989
  if (scope === 'repo' && !repo) {
@@ -3953,7 +4004,7 @@ function setupCommand$2(name, description, argv, importMeta) {
3953
4004
  }
3954
4005
  const METRICS = ['total_critical_alerts', 'total_high_alerts', 'total_medium_alerts', 'total_low_alerts', 'total_critical_added', 'total_medium_added', 'total_low_added', 'total_high_added', 'total_critical_prevented', 'total_high_prevented', 'total_medium_prevented', 'total_low_prevented'];
3955
4006
  async function fetchOrgAnalyticsData(time, spinner, apiKey, outputJson, filePath) {
3956
- const socketSdk = await sdk.setupSdk(apiKey);
4007
+ const socketSdk = await socketUrl.setupSdk(apiKey);
3957
4008
  const result = await handleApiCall(socketSdk.getOrgAnalytics(time.toString()), 'fetching analytics data');
3958
4009
  if (result.success === false) {
3959
4010
  return handleUnsuccessfulApiResponse('getOrgAnalytics', result, spinner);
@@ -4066,7 +4117,7 @@ const formatData = (data, scope) => {
4066
4117
  };
4067
4118
  };
4068
4119
  async function fetchRepoAnalyticsData(repo, time, spinner, apiKey, outputJson, filePath) {
4069
- const socketSdk = await sdk.setupSdk(apiKey);
4120
+ const socketSdk = await socketUrl.setupSdk(apiKey);
4070
4121
  const result = await handleApiCall(socketSdk.getRepoAnalytics(repo, time.toString()), 'fetching analytics data');
4071
4122
  if (result.success === false) {
4072
4123
  return handleUnsuccessfulApiResponse('getRepoAnalytics', result, spinner);
@@ -4154,15 +4205,15 @@ const get = {
4154
4205
  const name = `${parentName} get`;
4155
4206
  const input = setupCommand$1(name, get.description, argv, importMeta);
4156
4207
  if (input) {
4157
- const apiKey = sdk.getDefaultKey();
4208
+ const apiKey = socketUrl.getDefaultToken();
4158
4209
  if (!apiKey) {
4159
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
4210
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
4160
4211
  }
4161
4212
  const spinnerText = 'Getting diff scan... \n';
4162
- const spinner = yoctoSpinner({
4213
+ const spinner$1 = new spinner.Spinner({
4163
4214
  text: spinnerText
4164
4215
  }).start();
4165
- await getDiffScan(input, spinner, apiKey);
4216
+ await getDiffScan(input, spinner$1, apiKey);
4166
4217
  }
4167
4218
  }
4168
4219
  };
@@ -4206,7 +4257,7 @@ function setupCommand$1(name, description, argv, importMeta) {
4206
4257
  $ ${name} <org slug> --before=<before> --after=<after>
4207
4258
 
4208
4259
  Options
4209
- ${printFlagList(flags, 6)}
4260
+ ${getFlagListOutput(flags, 6)}
4210
4261
 
4211
4262
  Examples
4212
4263
  $ ${name} FakeCorp --before=aaa0aa0a-aaaa-0000-0a0a-0000000a00a0 --after=aaa1aa1a-aaaa-1111-1a1a-1111111a11a1
@@ -4297,7 +4348,6 @@ const diffScan = {
4297
4348
  }
4298
4349
  };
4299
4350
 
4300
- // @ts-ignore
4301
4351
  const threatFeed = {
4302
4352
  description: 'Look up the threat feed',
4303
4353
  async run(argv, importMeta, {
@@ -4306,14 +4356,14 @@ const threatFeed = {
4306
4356
  const name = `${parentName} threat-feed`;
4307
4357
  const input = setupCommand(name, threatFeed.description, argv, importMeta);
4308
4358
  {
4309
- const apiKey = sdk.getDefaultKey();
4359
+ const apiKey = socketUrl.getDefaultToken();
4310
4360
  if (!apiKey) {
4311
- throw new sdk.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
4361
+ throw new socketUrl.AuthError('User must be authenticated to run this command. To log in, run the command `socket login` and enter your API key.');
4312
4362
  }
4313
- const spinner = yoctoSpinner({
4363
+ const spinner$1 = new spinner.Spinner({
4314
4364
  text: 'Looking up the threat feed'
4315
4365
  }).start();
4316
- await fetchThreatFeed(input, spinner, apiKey);
4366
+ await fetchThreatFeed(input, spinner$1, apiKey);
4317
4367
  }
4318
4368
  }
4319
4369
  };
@@ -4357,7 +4407,7 @@ function setupCommand(name, description, argv, importMeta) {
4357
4407
  $ ${name}
4358
4408
 
4359
4409
  Options
4360
- ${printFlagList(flags, 6)}
4410
+ ${getFlagListOutput(flags, 6)}
4361
4411
 
4362
4412
  Examples
4363
4413
  $ ${name}
@@ -4433,7 +4483,7 @@ async function fetchThreatFeed({
4433
4483
  data: formattedOutput
4434
4484
  });
4435
4485
  screen.render();
4436
- screen.key(['escape', 'q', 'C-c'], () => process.exit(0));
4486
+ screen.key(['escape', 'q', 'C-c'], () => process$1.exit(0));
4437
4487
  }
4438
4488
  const formatResults = data => {
4439
4489
  return data.map(d => {
@@ -4458,6 +4508,7 @@ var cliCommands = {
4458
4508
  cdxgen: cdxgen,
4459
4509
  dependencies: dependencies,
4460
4510
  diffScan: diffScan,
4511
+ fix: fix,
4461
4512
  info: info,
4462
4513
  login: login,
4463
4514
  logout: logout,
@@ -4501,7 +4552,7 @@ void (async () => {
4501
4552
  argv: ['report', 'create', '--view', '--strict']
4502
4553
  }
4503
4554
  },
4504
- argv: process.argv.slice(2),
4555
+ argv: process$1.argv.slice(2),
4505
4556
  name: 'socket',
4506
4557
  importMeta: {
4507
4558
  url: `${node_url.pathToFileURL(__filename)}`
@@ -4511,10 +4562,10 @@ void (async () => {
4511
4562
  let errorBody;
4512
4563
  let errorTitle;
4513
4564
  let errorMessage = '';
4514
- if (err instanceof sdk.AuthError) {
4565
+ if (err instanceof socketUrl.AuthError) {
4515
4566
  errorTitle = 'Authentication error';
4516
4567
  errorMessage = err.message;
4517
- } else if (err instanceof sdk.InputError) {
4568
+ } else if (err instanceof socketUrl.InputError) {
4518
4569
  errorTitle = 'Invalid input';
4519
4570
  errorMessage = err.message;
4520
4571
  errorBody = err.body;
@@ -4525,10 +4576,10 @@ void (async () => {
4525
4576
  } else {
4526
4577
  errorTitle = 'Unexpected error with no details';
4527
4578
  }
4528
- console.error(`${sdk.logSymbols.error} ${colors.bgRed(colors.white(errorTitle + ':'))} ${errorMessage}`);
4579
+ console.error(`${pathResolve.logSymbols.error} ${colors.bgRed(colors.white(errorTitle + ':'))} ${errorMessage}`);
4529
4580
  if (errorBody) {
4530
4581
  console.error(`\n${errorBody}`);
4531
4582
  }
4532
- process.exit(1);
4583
+ process$1.exit(1);
4533
4584
  }
4534
4585
  })();