@socketsecurity/cli-with-sentry 0.15.16 → 0.15.18

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.
Files changed (35) hide show
  1. package/dist/.config/tsconfig.dts.tsbuildinfo +1 -1
  2. package/dist/cli.js +3086 -3053
  3. package/dist/cli.js.map +1 -1
  4. package/dist/constants.js +3 -3
  5. package/dist/constants.js.map +1 -1
  6. package/dist/shadow-bin.js +5 -6
  7. package/dist/shadow-bin.js.map +1 -1
  8. package/dist/socket-completion.bash +3 -3
  9. package/dist/types/commands/ci/cmd-ci.d.mts.map +1 -1
  10. package/dist/types/commands/ci/handle-ci.d.mts +1 -1
  11. package/dist/types/commands/ci/handle-ci.d.mts.map +1 -1
  12. package/dist/types/commands/fix/git.d.mts +1 -1
  13. package/dist/types/commands/fix/git.d.mts.map +1 -1
  14. package/dist/types/commands/fix/npm-fix.d.mts.map +1 -1
  15. package/dist/types/commands/fix/open-pr.d.mts +7 -2
  16. package/dist/types/commands/fix/open-pr.d.mts.map +1 -1
  17. package/dist/types/commands/fix/pnpm-fix.d.mts.map +1 -1
  18. package/dist/types/commands/manifest/cmd-manifest-auto.d.mts.map +1 -1
  19. package/dist/types/commands/manifest/convert_gradle_to_maven.d.mts.map +1 -1
  20. package/dist/types/commands/manifest/detect-manifest-actions.d.mts +4 -2
  21. package/dist/types/commands/manifest/detect-manifest-actions.d.mts.map +1 -1
  22. package/dist/types/commands/manifest/generate_auto_manifest.d.mts +4 -0
  23. package/dist/types/commands/manifest/generate_auto_manifest.d.mts.map +1 -0
  24. package/dist/types/commands/scan/cmd-scan-create.d.mts.map +1 -1
  25. package/dist/types/commands/scan/handle-create-new-scan.d.mts +2 -1
  26. package/dist/types/commands/scan/handle-create-new-scan.d.mts.map +1 -1
  27. package/dist/types/shadow/npm/bin.d.mts.map +1 -1
  28. package/dist/vendor.js +18 -14
  29. package/dist/vendor.js.map +1 -1
  30. package/external/@socketsecurity/registry/lib/constants/skip-tests-by-ecosystem.js +1 -5
  31. package/external/@socketsecurity/registry/lib/promises.d.ts +18 -4
  32. package/external/@socketsecurity/registry/lib/promises.js +112 -22
  33. package/external/@socketsecurity/registry/manifest.json +2 -2
  34. package/external/@socketsecurity/registry/package.json +2 -2
  35. package/package.json +4 -4
@@ -38,11 +38,7 @@ module.exports = new Map([
38
38
  // which is no longer the case.
39
39
  // https://github.com/ChALkeR/safer-buffer/issues/16
40
40
  // https://github.com/ChALkeR/safer-buffer/blob/v2.1.2/tests.js
41
- 'safer-buffer',
42
- // yocto-spinner has an open issue with its '✖' string containing an invisible
43
- // U+FE0F character. Skipping tests until issues/8 is resolved.
44
- // https://github.com/sindresorhus/yocto-spinner/issues/8
45
- 'yocto-spinner'
41
+ 'safer-buffer'
46
42
  ])
47
43
  ]
48
44
  ])
@@ -1,8 +1,22 @@
1
+ declare type pRetryOptions =
2
+ | number
3
+ | {
4
+ backoffFactor?: number | undefined
5
+ baseDelayMs?: number | undefined
6
+ jitter?: boolean | undefined
7
+ maxDelayMs?: number | undefined
8
+ onRetry?: (
9
+ attempt: number,
10
+ error: unknown,
11
+ delay: number
12
+ ) => void | undefined
13
+ retries?: number | undefined
14
+ signal?: AbortSignal | undefined
15
+ }
1
16
  declare type pOptions = {
2
- retries?: number | undefined
17
+ retries?: pRetryOptions | undefined
3
18
  signal?: AbortSignal | undefined
4
19
  }
5
-
6
20
  declare const Promises: {
7
21
  pEach<T>(
8
22
  array: T[],
@@ -28,10 +42,10 @@ declare const Promises: {
28
42
  ): Promise<T[][]>
29
43
  pRetry<T, P extends (value: T, options: pOptions) => Promise<any>>(
30
44
  callbackFn: P,
31
- options?: pOptions | undefined
45
+ options?: pRetryOptions | undefined
32
46
  ): ReturnType<P>
33
47
  }
34
48
  declare namespace Promises {
35
- export { pOptions }
49
+ export { pOptions, pRetryOptions }
36
50
  }
37
51
  export = Promises
@@ -2,6 +2,59 @@
2
2
 
3
3
  const { arrayChunk } = /*@__PURE__*/ require('./arrays')
4
4
 
5
+ let _timers
6
+ /*@__NO_SIDE_EFFECTS__*/
7
+ function getTimers() {
8
+ if (_timers === undefined) {
9
+ // Use non-'node:' prefixed require to avoid Webpack errors.
10
+ // eslint-disable-next-line n/prefer-node-protocol
11
+ _timers = /*@__PURE__*/ require('timers/promises')
12
+ }
13
+ return _timers
14
+ }
15
+
16
+ /*@__NO_SIDE_EFFECTS__*/
17
+ function normalizeRetryOptions(options) {
18
+ const {
19
+ // Arguments to pass to the callback function.
20
+ args = [],
21
+ // Multiplier for exponential backoff (e.g., 2 doubles delay each retry).
22
+ backoffFactor = 2,
23
+ // Initial delay before the first retry (in milliseconds).
24
+ baseDelayMs = 200,
25
+ // Whether to apply randomness to spread out retries.
26
+ jitter = true,
27
+ // Upper limit for any backoff delay (in milliseconds).
28
+ maxDelayMs = 10000,
29
+ // Optional callback invoked on each retry attempt:
30
+ // (attempt: number, error: unknown, delay: number) => void
31
+ onRetry,
32
+ // Number of retry attempts (0 = no retries, only initial attempt).
33
+ retries = 0,
34
+ // AbortSignal used to support cancellation.
35
+ signal = /*@__PURE__*/ require('./constants/abort-signal')
36
+ } = resolveRetryOptions(options)
37
+ return {
38
+ __proto__: null,
39
+ args,
40
+ backoffFactor,
41
+ baseDelayMs,
42
+ jitter,
43
+ maxDelayMs,
44
+ onRetry,
45
+ retries,
46
+ signal
47
+ }
48
+ }
49
+
50
+ /*@__NO_SIDE_EFFECTS__*/
51
+ function resolveRetryOptions(options) {
52
+ return {
53
+ __proto__: null,
54
+ ...(typeof options === 'number' ? { retries: options } : options)
55
+ }
56
+ }
57
+
5
58
  /*@__NO_SIDE_EFFECTS__*/
6
59
  async function pEach(array, concurrency, callbackFn, options) {
7
60
  await pEachChunk(arrayChunk(array, concurrency), callbackFn, options)
@@ -26,7 +79,13 @@ async function pEachChunk(chunks, callbackFn, options) {
26
79
  }
27
80
  // eslint-disable-next-line no-await-in-loop
28
81
  await Promise.all(
29
- chunk.map(value => pRetry(callbackFn, { args: [value], retries, signal }))
82
+ chunk.map(value =>
83
+ pRetry(callbackFn, {
84
+ signal,
85
+ ...resolveRetryOptions(retries),
86
+ args: [value]
87
+ })
88
+ )
30
89
  )
31
90
  }
32
91
  }
@@ -48,7 +107,11 @@ async function pFilterChunk(chunks, callbackFn, options) {
48
107
  // eslint-disable-next-line no-await-in-loop
49
108
  const predicateResults = await Promise.all(
50
109
  chunk.map(value =>
51
- pRetry(callbackFn, { args: [value], retries, signal })
110
+ pRetry(callbackFn, {
111
+ signal,
112
+ ...resolveRetryOptions(retries),
113
+ args: [value]
114
+ })
52
115
  )
53
116
  )
54
117
  filteredChunks[i] = chunk.filter((_v, i) => predicateResults[i])
@@ -60,35 +123,62 @@ async function pFilterChunk(chunks, callbackFn, options) {
60
123
  /*@__NO_SIDE_EFFECTS__*/
61
124
  async function pRetry(callbackFn, options) {
62
125
  const {
63
- args = [],
64
- retries = 0,
65
- signal = /*@__PURE__*/ require('./constants/abort-signal')
66
- } = { __proto__: null, ...options }
126
+ args,
127
+ backoffFactor,
128
+ baseDelayMs,
129
+ jitter,
130
+ maxDelayMs,
131
+ onRetry,
132
+ retries,
133
+ signal
134
+ } = normalizeRetryOptions(options)
67
135
  if (signal?.aborted) {
68
136
  return undefined
69
137
  }
70
138
  if (retries === 0) {
71
139
  return await callbackFn(...args, { signal })
72
140
  }
141
+
142
+ const UNDEFINED_TOKEN = /*@__PURE__*/ require('./constants/undefined-token')
143
+ const timers = getTimers()
144
+
73
145
  let attempts = retries
74
- return (async () => {
75
- const UNDEFINED_TOKEN = /*@__PURE__*/ require('./constants/undefined-token')
76
- let error = UNDEFINED_TOKEN
77
- while (attempts-- >= 0 && !signal?.aborted) {
78
- try {
79
- // eslint-disable-next-line no-await-in-loop
80
- return await callbackFn(...args, { signal })
81
- } catch (e) {
82
- if (error === UNDEFINED_TOKEN) {
83
- error = e
84
- }
146
+ let delay = baseDelayMs
147
+ let error = UNDEFINED_TOKEN
148
+
149
+ while (attempts-- >= 0 && !signal?.aborted) {
150
+ try {
151
+ // eslint-disable-next-line no-await-in-loop
152
+ return await callbackFn(...args, { signal })
153
+ } catch (e) {
154
+ if (error === UNDEFINED_TOKEN) {
155
+ error = e
85
156
  }
157
+ if (attempts < 0) {
158
+ break
159
+ }
160
+ let waitTime = delay
161
+ if (jitter) {
162
+ // Add randomness: Pick a value between 0 and `delay`.
163
+ waitTime += Math.floor(Math.random() * delay)
164
+ }
165
+ // Clamp wait time to max delay.
166
+ waitTime = Math.min(waitTime, maxDelayMs)
167
+ if (typeof onRetry === 'function') {
168
+ try {
169
+ onRetry(retries - attempts, e, waitTime)
170
+ } catch {}
171
+ }
172
+ // eslint-disable-next-line no-await-in-loop
173
+ await timers.wait(waitTime, undefined, { signal })
174
+ // Exponentially increase the delay for the next attempt, capping at maxDelayMs.
175
+ delay = Math.min(delay * backoffFactor, maxDelayMs)
86
176
  }
87
- if (error !== UNDEFINED_TOKEN) {
88
- throw error
89
- }
90
- return undefined
91
- })()
177
+ }
178
+ if (error !== UNDEFINED_TOKEN) {
179
+ throw error
180
+ }
181
+ return undefined
92
182
  }
93
183
 
94
184
  module.exports = {
@@ -1843,7 +1843,7 @@
1843
1843
  }
1844
1844
  ],
1845
1845
  [
1846
- "pkg:npm/%40socketregistry/yocto-spinner@1.0.16",
1846
+ "pkg:npm/%40socketregistry/yocto-spinner@1.0.17",
1847
1847
  {
1848
1848
  "categories": ["cleanup"],
1849
1849
  "engines": {
@@ -1853,7 +1853,7 @@
1853
1853
  "license": "MIT",
1854
1854
  "name": "@socketregistry/yocto-spinner",
1855
1855
  "package": "yocto-spinner",
1856
- "version": "1.0.16"
1856
+ "version": "1.0.17"
1857
1857
  }
1858
1858
  ],
1859
1859
  [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/registry",
3
- "version": "1.0.192",
3
+ "version": "1.0.194",
4
4
  "license": "MIT",
5
5
  "description": "Socket.dev registry helpers methods and metadata",
6
6
  "keywords": [
@@ -628,7 +628,7 @@
628
628
  "@rollup/plugin-replace": "6.0.2",
629
629
  "@socketregistry/is-unicode-supported": "1.0.4",
630
630
  "@socketregistry/packageurl-js": "1.0.6",
631
- "@socketregistry/yocto-spinner": "1.0.16",
631
+ "@socketregistry/yocto-spinner": "1.0.17",
632
632
  "@types/pacote": "11.1.8",
633
633
  "@yarnpkg/extensions": "2.0.5",
634
634
  "browserslist": "4.24.5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@socketsecurity/cli-with-sentry",
3
- "version": "0.15.16",
3
+ "version": "0.15.18",
4
4
  "description": "CLI tool for Socket.dev, includes Sentry error handling, otherwise identical to the regular `socket` package",
5
5
  "homepage": "https://github.com/SocketDev/socket-cli",
6
6
  "license": "MIT",
@@ -108,8 +108,8 @@
108
108
  "@socketregistry/is-interactive": "1.0.5",
109
109
  "@socketregistry/packageurl-js": "1.0.6",
110
110
  "@socketsecurity/config": "3.0.1",
111
- "@socketsecurity/registry": "1.0.192",
112
- "@socketsecurity/sdk": "1.4.36",
111
+ "@socketsecurity/registry": "1.0.194",
112
+ "@socketsecurity/sdk": "1.4.38",
113
113
  "@types/blessed": "0.1.25",
114
114
  "@types/cmd-shim": "5.0.2",
115
115
  "@types/js-yaml": "4.0.9",
@@ -142,7 +142,7 @@
142
142
  "husky": "9.1.7",
143
143
  "ignore": "7.0.4",
144
144
  "js-yaml": "npm:@zkochan/js-yaml@0.0.7",
145
- "knip": "5.57.0",
145
+ "knip": "5.57.1",
146
146
  "lint-staged": "16.0.0",
147
147
  "magic-string": "0.30.17",
148
148
  "meow": "13.2.0",