@socketsecurity/cli 0.14.73 → 0.14.75

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.
@@ -911,7 +911,7 @@ function emitBanner(name) {
911
911
  logger.logger.error(getAsciiHeader(name))
912
912
  }
913
913
  function getAsciiHeader(command) {
914
- const cliVersion = '0.14.73:3036c50:e5664d53:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
914
+ const cliVersion = '0.14.75:48886e4:2e791c39:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
915
915
  const nodeVersion = process$1.version
916
916
  const apiToken = shadowNpmInject.getDefaultToken()
917
917
  const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
@@ -3185,6 +3185,28 @@ async function commitAndPushFix(branchName, commitMsg, cwd) {
3185
3185
  cwd
3186
3186
  })
3187
3187
  }
3188
+ async function waitForBranchToBeReadable(octokit, owner, repo, branch) {
3189
+ const maxRetries = 10
3190
+ const delay = 1500
3191
+ for (let i = 0; i < maxRetries; i++) {
3192
+ try {
3193
+ // eslint-disable-next-line no-await-in-loop
3194
+ const ref = await octokit.git.getRef({
3195
+ owner,
3196
+ repo,
3197
+ ref: `heads/${branch}`
3198
+ })
3199
+ if (ref) {
3200
+ return
3201
+ }
3202
+ } catch (err) {
3203
+ // Still not ready
3204
+ }
3205
+ // eslint-disable-next-line no-await-in-loop
3206
+ await new Promise(resolve => setTimeout(resolve, delay))
3207
+ }
3208
+ throw new Error(`Branch "${branch}" never became visible to GitHub API`)
3209
+ }
3188
3210
  async function createPullRequest({
3189
3211
  base = 'main',
3190
3212
  body,
@@ -3196,7 +3218,7 @@ async function createPullRequest({
3196
3218
  const octokit = new vendor.Octokit({
3197
3219
  auth: process.env['SOCKET_AUTOFIX_PAT'] ?? process.env['GITHUB_TOKEN']
3198
3220
  })
3199
- await new Promise(resolve => setTimeout(resolve, 3000)) // 3s
3221
+ await waitForBranchToBeReadable(octokit, owner, repo, head)
3200
3222
  await octokit.pulls.create({
3201
3223
  owner,
3202
3224
  repo,
@@ -3342,6 +3364,19 @@ async function pnpmFix(pkgEnvDetails, options) {
3342
3364
  const commitMsg = `fix: upgrade ${name} to ${targetVersion}`
3343
3365
  const { owner, repo } = getRepoInfo()
3344
3366
  // eslint-disable-next-line no-await-in-loop
3367
+ await spawn.spawn(
3368
+ 'git',
3369
+ [
3370
+ 'remote',
3371
+ 'set-url',
3372
+ 'origin',
3373
+ `https://x-access-token:${process.env['SOCKET_AUTOFIX_PAT']}@github.com/${owner}/${repo}`
3374
+ ],
3375
+ {
3376
+ cwd
3377
+ }
3378
+ )
3379
+ // eslint-disable-next-line no-await-in-loop
3345
3380
  await commitAndPushFix(branchName, commitMsg, cwd)
3346
3381
  // eslint-disable-next-line no-await-in-loop
3347
3382
  await createPullRequest({
@@ -11016,7 +11051,7 @@ void (async () => {
11016
11051
  await vendor.updater({
11017
11052
  name: SOCKET_CLI_BIN_NAME,
11018
11053
  // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
11019
- version: '0.14.73',
11054
+ version: '0.14.75',
11020
11055
  ttl: 86_400_000 /* 24 hours in milliseconds */
11021
11056
  })
11022
11057
  try {
@@ -11087,5 +11122,5 @@ void (async () => {
11087
11122
  await shadowNpmInject.captureException(e)
11088
11123
  }
11089
11124
  })()
11090
- //# debugId=825a78ba-f858-4468-95cb-b2f5c0462a07
11125
+ //# debugId=93b6c368-e5b7-4e14-bf24-719f4e722075
11091
11126
  //# sourceMappingURL=cli.js.map