@gitkraken/core-gitlens 0.62.0 → 0.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +22 -1
  2. package/dist/git/cache.d.ts +1 -0
  3. package/dist/git/cache.js +11 -0
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/errors.d.ts +15 -0
  6. package/dist/git/errors.js +9 -1
  7. package/dist/git/errors.js.map +1 -1
  8. package/dist/git/models/pullRequest.d.ts +3 -0
  9. package/dist/git/models/pullRequest.js.map +1 -1
  10. package/dist/git/providers/operations.d.ts +4 -3
  11. package/dist/git/providers/staging.d.ts +16 -8
  12. package/dist/git/run.types.d.ts +6 -0
  13. package/dist/git/utils/hiddenRefs.utils.d.ts +15 -0
  14. package/dist/git/utils/hiddenRefs.utils.js +68 -2
  15. package/dist/git/utils/hiddenRefs.utils.js.map +1 -1
  16. package/dist/git/utils/pullRequest.utils.d.ts +3 -6
  17. package/dist/git/utils/pullRequest.utils.js +6 -7
  18. package/dist/git/utils/pullRequest.utils.js.map +1 -1
  19. package/dist/git/watching/gitIgnoreFilter.d.ts +12 -5
  20. package/dist/git/watching/gitIgnoreFilter.js +26 -32
  21. package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
  22. package/dist/git/watching/provider.d.ts +18 -3
  23. package/dist/git/watching/watchGroup.d.ts +7 -2
  24. package/dist/git/watching/watchGroup.js +51 -3
  25. package/dist/git/watching/watchGroup.js.map +1 -1
  26. package/dist/git/watching/watchService.d.ts +6 -3
  27. package/dist/git/watching/watchService.js +94 -64
  28. package/dist/git/watching/watchService.js.map +1 -1
  29. package/dist/git-cli/cliGitProvider.d.ts +2 -0
  30. package/dist/git-cli/cliGitProvider.js +85 -24
  31. package/dist/git-cli/cliGitProvider.js.map +1 -1
  32. package/dist/git-cli/exec/git.js +4 -4
  33. package/dist/git-cli/exec/git.js.map +1 -1
  34. package/dist/git-cli/exec/indexLock.d.ts +7 -5
  35. package/dist/git-cli/exec/indexLock.js +19 -15
  36. package/dist/git-cli/exec/indexLock.js.map +1 -1
  37. package/dist/git-cli/providers/config.d.ts +1 -0
  38. package/dist/git-cli/providers/config.js +13 -3
  39. package/dist/git-cli/providers/config.js.map +1 -1
  40. package/dist/git-cli/providers/staging.d.ts +8 -8
  41. package/dist/git-cli/providers/staging.js +119 -24
  42. package/dist/git-cli/providers/staging.js.map +1 -1
  43. package/dist/plus/git-github/api/config.d.ts +5 -0
  44. package/dist/plus/git-github/api/config.js.map +1 -1
  45. package/dist/plus/git-github/api/github.js +24 -4
  46. package/dist/plus/git-github/api/github.js.map +1 -1
  47. package/dist/plus/git-github/models.d.ts +12 -0
  48. package/dist/plus/git-github/models.js +8 -3
  49. package/dist/plus/git-github/models.js.map +1 -1
  50. package/dist/plus/integrations/context.d.ts +5 -0
  51. package/dist/plus/integrations/extensionManager.d.ts +6 -0
  52. package/dist/plus/integrations/extensionManager.js +10 -0
  53. package/dist/plus/integrations/extensionManager.js.map +1 -0
  54. package/dist/plus/integrations/index.d.ts +5 -63
  55. package/dist/plus/integrations/index.js +4 -53
  56. package/dist/plus/integrations/index.js.map +1 -1
  57. package/dist/plus/integrations/integrationService.d.ts +14 -2
  58. package/dist/plus/integrations/integrationService.js +48 -12
  59. package/dist/plus/integrations/integrationService.js.map +1 -1
  60. package/dist/plus/integrations/manager.d.ts +10 -0
  61. package/dist/plus/integrations/managerContext.d.ts +69 -0
  62. package/dist/plus/integrations/managerContext.js +59 -0
  63. package/dist/plus/integrations/managerContext.js.map +1 -0
  64. package/dist/plus/integrations/models/gitlabMergeRequestWrites.d.ts +167 -0
  65. package/dist/plus/integrations/models/gitlabMergeRequestWrites.js +0 -0
  66. package/dist/plus/integrations/providers/github.js +6 -2
  67. package/dist/plus/integrations/providers/github.js.map +1 -1
  68. package/dist/plus/integrations/providers/gitlab/gitlab.d.ts +2 -2
  69. package/dist/plus/integrations/providers/gitlab/gitlab.js +3 -3
  70. package/dist/plus/integrations/providers/gitlab/gitlab.js.map +1 -1
  71. package/dist/plus/integrations/providers/gitlab/issueWrites.d.ts +4 -13
  72. package/dist/plus/integrations/providers/gitlab/issueWrites.js +33 -136
  73. package/dist/plus/integrations/providers/gitlab/issueWrites.js.map +1 -1
  74. package/dist/plus/integrations/providers/gitlab/mergeRequestWrites.d.ts +30 -0
  75. package/dist/plus/integrations/providers/gitlab/mergeRequestWrites.js +569 -0
  76. package/dist/plus/integrations/providers/gitlab/mergeRequestWrites.js.map +1 -0
  77. package/dist/plus/integrations/providers/gitlab/writeErrors.d.ts +12 -0
  78. package/dist/plus/integrations/providers/gitlab/writeErrors.js +101 -0
  79. package/dist/plus/integrations/providers/gitlab/writeErrors.js.map +1 -0
  80. package/dist/plus/integrations/providers/gitlab/writeTransport.d.ts +47 -0
  81. package/dist/plus/integrations/providers/gitlab/writeTransport.js +135 -0
  82. package/dist/plus/integrations/providers/gitlab/writeTransport.js.map +1 -0
  83. package/dist/plus/integrations/providers/gitlab.d.ts +6 -1
  84. package/dist/plus/integrations/providers/gitlab.js +9 -1
  85. package/dist/plus/integrations/providers/gitlab.js.map +1 -1
  86. package/dist/plus/integrations/reads/etag.d.ts +5 -0
  87. package/dist/plus/integrations/reads/etag.js +2 -0
  88. package/dist/plus/integrations/reads/etag.js.map +1 -1
  89. package/dist/plus/integrations/reads/sweeps.js +1 -1
  90. package/dist/utils/env/node/exec.d.ts +2 -0
  91. package/dist/utils/env/node/exec.js +2 -0
  92. package/dist/utils/env/node/exec.js.map +1 -1
  93. package/docs/integrations.md +86 -9
  94. package/package.json +1 -1
  95. package/dist/plus/integrations/providers/gitlab/issueWriteErrors.d.ts +0 -11
  96. package/dist/plus/integrations/providers/gitlab/issueWriteErrors.js +0 -73
  97. package/dist/plus/integrations/providers/gitlab/issueWriteErrors.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"exec.js","names":["joinPaths"],"sources":["../../../../../utils/src/env/node/exec.ts"],"sourcesContent":["import type { ChildProcess, ExecFileException, ExecFileOptions } from 'child_process';\nimport { execFile, spawn } from 'child_process';\nimport type { Stats } from 'fs';\nimport { access, constants } from 'fs';\nimport { stat } from 'fs/promises';\nimport { join as joinPaths } from 'path';\nimport * as process from 'process';\nimport type { Readable, Writable } from 'stream';\nimport type { CancellationReason } from '../../cancellation.js';\nimport { getScopedLogger, maybeStartScopedLogger } from '../../logger.scoped.js';\nimport { isWindows } from './platform.js';\n\n// -- Error types --\n\ninterface RunErrorContext {\n\tmessage: string;\n\tcmd?: string | undefined;\n\tkilled?: boolean | undefined;\n\tcode?: string | number | null | undefined;\n\tsignal?: NodeJS.Signals | undefined;\n}\n\nexport class RunError extends Error {\n\treadonly cmd?: string | undefined;\n\treadonly killed?: boolean | undefined;\n\treadonly code?: string | number | undefined;\n\treadonly signal?: NodeJS.Signals | undefined;\n\treadonly stdout: string;\n\treadonly stderr: string;\n\n\tconstructor(context: RunErrorContext, stdout: string, stderr: string) {\n\t\tsuper(context.message);\n\n\t\tthis.cmd = context.cmd;\n\t\tthis.killed = context.killed;\n\t\tthis.code = context.code ?? undefined;\n\t\tthis.signal = context.signal;\n\t\tthis.stdout = stdout?.trim() ?? '';\n\t\tthis.stderr = stderr?.trim() ?? '';\n\n\t\tthis.name = 'RunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class CancelledRunError extends RunError {\n\treadonly reason: CancellationReason;\n\n\tconstructor(\n\t\tcmd: string,\n\t\tkilled: boolean,\n\t\tcode?: number | string | undefined,\n\t\tsignal: NodeJS.Signals = 'SIGTERM',\n\t\treason: CancellationReason = 'unknown',\n\t) {\n\t\tsuper(\n\t\t\t{ message: `Operation cancelled; command=${cmd}`, cmd: cmd, killed: killed, code: code, signal: signal },\n\t\t\t'',\n\t\t\t'',\n\t\t);\n\n\t\tthis.reason = reason;\n\n\t\tthis.name = 'CancelledRunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n// -- Execution utilities --\n\nconst slashesRegex = /[\\\\/]/;\nconst ps1Regex = /\\.ps1$/i;\nconst batOrCmdRegex = /\\.(bat|cmd)$/i;\nconst jsRegex = /\\.(js)$/i;\n\n/**\n * Search PATH to see if a file exists in any of the path folders.\n *\n * @param {string} exe The file to search for\n * @return {string} A fully qualified path, or the original path if nothing\n * is found\n *\n * @private\n */\nasync function runDownPath(exe: string): Promise<string> {\n\t// NB: Windows won't search PATH looking for executables in spawn like\n\t// Posix does\n\n\t// Files with any directory path don't get this applied\n\tif (slashesRegex.test(exe)) return exe;\n\n\tconst target = joinPaths('.', exe);\n\ttry {\n\t\tconst stats = await stat(target);\n\t\tif (stats?.isFile() && isExecutable(stats)) return target;\n\t} catch {}\n\n\tconst path = process.env.PATH;\n\tif (path != null && path.length !== 0) {\n\t\tconst haystack = path.split(isWindows ? ';' : ':');\n\t\tfor (const p of haystack) {\n\t\t\tconst needle = joinPaths(p, exe);\n\t\t\ttry {\n\t\t\t\tconst stats = await stat(needle);\n\t\t\t\tif (stats?.isFile() && isExecutable(stats)) return needle;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn exe;\n}\n\nfunction isExecutable(stats: Stats) {\n\tif (isWindows) return true;\n\n\tconst isGroup = stats.gid ? stats.gid === process.getgid?.() : true;\n\tconst isUser = stats.uid ? stats.uid === process.getuid?.() : true;\n\n\treturn Boolean(stats.mode & 0o0001 || (stats.mode & 0o0010 && isGroup) || (stats.mode & 0o0100 && isUser));\n}\n\n/**\n * Finds the executable and parameters to run on Windows. This method\n * mimics the POSIX behavior of being able to run scripts as executables by\n * replacing the passed-in executable with the script runner, for PowerShell,\n * CMD, and node scripts.\n *\n * This method also does the work of running down PATH, which spawn on Windows\n * also doesn't do, unlike on POSIX.\n */\nexport async function findExecutable(exe: string, args: string[]): Promise<{ cmd: string; args: string[] }> {\n\t// POSIX can just execute scripts directly, no need for silly goosery\n\tif (!isWindows) return { cmd: await runDownPath(exe), args: args };\n\n\tif (!(await fsExists(exe))) {\n\t\t// NB: When you write something like `surf-client ... -- surf-build` on Windows,\n\t\t// a shell would normally convert that to surf-build.cmd, but since it's passed\n\t\t// in as an argument, it doesn't happen\n\t\tconst possibleExts = ['.exe', '.bat', '.cmd', '.ps1'];\n\t\tfor (const ext of possibleExts) {\n\t\t\tconst possibleFullPath = await runDownPath(`${exe}${ext}`);\n\n\t\t\tif (await fsExists(possibleFullPath)) return findExecutable(possibleFullPath, args);\n\t\t}\n\t}\n\n\tif (ps1Regex.test(exe)) {\n\t\tconst cmd = joinPaths(\n\t\t\tprocess.env.SYSTEMROOT ?? 'C:\\\\WINDOWS',\n\t\t\t'System32',\n\t\t\t'WindowsPowerShell',\n\t\t\t'v1.0',\n\t\t\t'PowerShell.exe',\n\t\t);\n\t\tconst psargs = ['-ExecutionPolicy', 'Unrestricted', '-NoLogo', '-NonInteractive', '-File', exe];\n\n\t\treturn { cmd: cmd, args: [...psargs, ...args] };\n\t}\n\n\tif (batOrCmdRegex.test(exe)) {\n\t\tconst cmd = joinPaths(process.env.SYSTEMROOT ?? 'C:\\\\WINDOWS', 'System32', 'cmd.exe');\n\t\tconst cmdArgs = ['/C', exe, ...args];\n\n\t\treturn { cmd: cmd, args: cmdArgs };\n\t}\n\n\tif (jsRegex.test(exe)) {\n\t\tconst cmd = process.execPath;\n\t\tconst nodeArgs = [exe];\n\n\t\treturn { cmd: cmd, args: [...nodeArgs, ...args] };\n\t}\n\n\treturn { cmd: exe, args: args };\n}\n\n/** What core uses of a spawned process; Node's `ChildProcess` satisfies it */\nexport interface SpawnedProcess {\n\treadonly stdin: Writable | null;\n\treadonly stdout: Readable | null;\n\treadonly stderr: Readable | null;\n\treadonly killed: boolean;\n\treadonly exitCode: number | null;\n\treadonly spawnargs: string[];\n\t/** Used to stop a run that passes its `maxBuffer`; without it the run destroys the output streams instead */\n\tkill?(signal?: NodeJS.Signals): boolean;\n\tonce(event: 'error', listener: (error: Error) => void): this;\n\tonce(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;\n\tremoveAllListeners(): this;\n}\n\nexport interface ProcessSpawnOptions {\n\treadonly cwd?: string;\n\t/** The child's whole environment, not additions to the spawner's own; an `undefined` value leaves the key out */\n\treadonly env?: Record<string, string | undefined>;\n\t/** Milliseconds; absent means none */\n\treadonly timeout?: number;\n\treadonly signal?: AbortSignal;\n\t/** A `null` entry means `'pipe'` */\n\treadonly stdio?: ['pipe' | 'ignore', null, null];\n}\n\n/**\n * Launches a process in place of Node's `spawn`, and must behave as it does:\n * - pipe stdout and stderr, and stdin unless `stdio[0]` is `'ignore'`, which leaves `stdin` null\n * - honour `signal`, including one already aborted: kill with SIGTERM, then emit `'error'` with `name` `AbortError`,\n * unless the process has already exited\n * - honour `timeout`: kill with SIGTERM and set `killed`, without emitting `'error'`\n * - report a killed process's `'close'` with a null code and its signal, not an exit code such as 143\n * - on Windows, end the process's whole tree when killing it (timeout, abort, or `kill`): a launcher such as Git for\n * Windows' `cmd\\git.exe` runs the real git as a child holding the same pipes, so killing only the launcher leaves\n * them open and `'close'` never comes\n * - emit no event before returning, `'error'` at most once, and `'close'` exactly once and last: also after `'error'`\n * (a failed launch, an abort), and only after `stdout` and `stderr` have ended or been destroyed, with `exitCode`\n * and `killed` already set\n * - close the child's stdout when `stdout` is destroyed, which is how a reader that stops early ends the process\n */\nexport type ProcessSpawner = (command: string, args: readonly string[], options: ProcessSpawnOptions) => SpawnedProcess;\n\n/**\n * The default {@link ProcessSpawner}: Node's `spawn`, but with its `timeout` handled here. Node clears its timeout\n * timer only on `'exit'`, which a failed launch (e.g. a missing `cwd`) never emits, so the timer outlives the\n * process and keeps Node alive for the full timeout. This mirrors Node's timeout handling but also clears on\n * `'close'`, as https://github.com/nodejs/node/pull/65506 does; remove it once the minimum supported Node/Electron\n * includes that fix.\n */\nexport function spawnProcess(command: string, args: readonly string[], options: ProcessSpawnOptions): ChildProcess {\n\tconst { timeout, ...spawnOptions } = options;\n\t// Node's own validation, thrown before anything spawns\n\tif (timeout != null && !(Number.isInteger(timeout) && timeout >= 0)) {\n\t\tconst ex = new RangeError(\n\t\t\t`The value of \"timeout\" is out of range. It must be an unsigned integer. Received ${String(timeout)}`,\n\t\t);\n\t\t(ex as RangeError & { code: string }).code = 'ERR_OUT_OF_RANGE';\n\t\tthrow ex;\n\t}\n\n\tconst child = spawn(command, args, spawnOptions);\n\tif (isWindows) {\n\t\tkillTreeOnKill(child);\n\t}\n\n\tif (timeout != null && timeout > 0) {\n\t\tkillOnTimeout(child, timeout);\n\t}\n\n\treturn child;\n}\n\n/** Node's spawn `timeout`, but also cleared on `'close'`; see {@link spawnProcess} */\nfunction killOnTimeout(child: ChildProcess, timeout: number): void {\n\tlet timeoutId: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n\t\tif (timeoutId != null) {\n\t\t\ttry {\n\t\t\t\tchild.kill();\n\t\t\t} catch (ex) {\n\t\t\t\tchild.emit('error', ex);\n\t\t\t}\n\t\t\ttimeoutId = undefined;\n\t\t}\n\t}, timeout);\n\n\tconst clear = () => {\n\t\tif (timeoutId != null) {\n\t\t\tclearTimeout(timeoutId);\n\t\t\ttimeoutId = undefined;\n\t\t}\n\t};\n\t// `'exit'` keeps Node's timing; `'close'` covers a launch that fails and never exits\n\tchild.once('exit', clear);\n\tchild.once('close', clear);\n}\n\nconst taskkillTimeout = 5000;\n\n/**\n * Makes `kill` end the child's whole tree (Windows only). There `kill` terminates just the child, and a launcher such\n * as Git for Windows' `cmd\\git.exe` runs the real git as its own child on the same stdout and stderr, so the pipes\n * stay open and `'close'` never comes. Node's abort and timeout paths call the instance's `kill`, so this covers them.\n */\nfunction killTreeOnKill(child: ChildProcess): void {\n\tconst kill = child.kill.bind(child);\n\tconst mutable = child as { killed: boolean; exitCode: number | null; signalCode: NodeJS.Signals | null };\n\tlet killing = false;\n\n\tchild.kill = (signal?: NodeJS.Signals | number): boolean => {\n\t\tif (child.pid == null || child.exitCode !== null || child.signalCode !== null || typeof signal === 'number') {\n\t\t\treturn kill(signal);\n\t\t}\n\t\tif (killing) return true;\n\n\t\tkilling = true;\n\t\tconst killSignal = signal ?? 'SIGTERM';\n\t\tmutable.killed = true;\n\n\t\t// Killed from outside, the child exits with taskkill's code 1 and no signal; report it as Node's own kill\n\t\t// would, a null code and the signal, which is what every caller keys on\n\t\tlet exitCode: number | null = child.exitCode;\n\t\tObject.defineProperty(child, 'exitCode', {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tget: () => exitCode,\n\t\t\tset: (value: number | null) => {\n\t\t\t\tif (value === 1) {\n\t\t\t\t\texitCode = null;\n\t\t\t\t\tmutable.signalCode = killSignal;\n\t\t\t\t} else {\n\t\t\t\t\texitCode = value;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\t// Once it's killed, a descendant left alive (taskkill failed, or its parent was already gone) can still hold the\n\t\t// pipes; destroying them lets `'close'` come anyway. A child that exited on its own keeps its output\n\t\tchild.once('exit', (_code, exitSignal) => {\n\t\t\tif (exitSignal == null) return;\n\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t});\n\n\t\t// taskkill failed: fall back to Node's kill, unless the child already exited on its own\n\t\tlet failed = false;\n\t\tconst fail = () => {\n\t\t\tif (failed || child.exitCode !== null || child.signalCode !== null) return;\n\n\t\t\tfailed = true;\n\t\t\ttry {\n\t\t\t\tkill(killSignal);\n\t\t\t} catch {}\n\t\t};\n\n\t\ttry {\n\t\t\t// By absolute path: Windows searches the current directory before PATH for a bare name. Its own time limit\n\t\t\t// keeps a stalled taskkill from leaving the kill, and so the run, hanging\n\t\t\tconst taskkill = spawn(\n\t\t\t\tjoinPaths(process.env.SystemRoot || 'C:\\\\Windows', 'System32', 'taskkill.exe'),\n\t\t\t\t['/T', '/F', '/PID', String(child.pid)],\n\t\t\t\t{ stdio: 'ignore', windowsHide: true },\n\t\t\t);\n\t\t\tkillOnTimeout(taskkill, taskkillTimeout);\n\t\t\ttaskkill.once('error', fail);\n\t\t\ttaskkill.once('exit', code => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tfail();\n\t\t\t\t}\n\t\t\t});\n\t\t} catch {\n\t\t\tfail();\n\t\t}\n\n\t\treturn true;\n\t};\n}\n\nexport interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {\n\tcwd?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly encoding?: TEncoding;\n\t/**\n\t * Decodes non-UTF-8 output. Called when `encoding` is not utf8/binary/buffer.\n\t * Provided by the host via the `GitOptions.decode` option.\n\t * If absent and a non-UTF-8 encoding is requested, throws at runtime.\n\t */\n\treadonly decode?: (data: Uint8Array, options?: { readonly encoding: string }) => string | Promise<string>;\n\t/**\n\t * The most bytes each of stdout and stderr may produce; past it the process is killed and the run rejects\n\t * with a `RunError` whose `code` is `ERR_CHILD_PROCESS_STDIO_MAXBUFFER`.\n\t *\n\t * If not specified, `run` allows 1000MB per stream and `runSpawn` allows unlimited output.\n\t */\n\treadonly maxBuffer?: number;\n\treadonly cancellation?: AbortSignal;\n\t/**\n\t * An optional string or buffer which will be written to\n\t * the child process stdin stream immediately immediately\n\t * after spawning the process.\n\t */\n\treadonly stdin?: string | Buffer;\n\t/**\n\t * The encoding to use when writing to stdin, if the stdin\n\t * parameter is a string.\n\t */\n\treadonly stdinEncoding?: string;\n\treadonly timeout?: number;\n\t/**\n\t * When true, suppresses the `[EXEC]` stderr warning emitted on debug-enabled scopes.\n\t * Use for commands whose failure is expected (e.g. paired with `errors: 'ignore'`).\n\t */\n\treadonly quiet?: boolean;\n\t/** Launches the process; defaults to {@link spawnProcess}. Only used by `runSpawn` */\n\treadonly spawn?: ProcessSpawner;\n}\n\nconst bufferExceededRegex = /stdout maxBuffer( length)? exceeded/;\n\ntype ExitCodeOnlyRunOptions<TEncoding = BufferEncoding | 'buffer'> = RunOptions<TEncoding> & { exitCodeOnly: true };\n\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions: ExitCodeOnlyRunOptions<BufferEncoding>,\n): Promise<number>;\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding>,\n): Promise<string>;\nexport function run<T extends number | string>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding> & { exitCodeOnly?: boolean },\n): Promise<T> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.run');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions<BufferEncoding> & ExecFileOptions = {\n\t\tmaxBuffer: 1000 * 1024 * 1024,\n\t\t...options,\n\t};\n\n\tconst promise = new Promise<T>((resolve, reject) => {\n\t\tconst proc = execFile(\n\t\t\tcommand,\n\t\t\targs,\n\t\t\t{ ...opts, signal: cancellation },\n\t\t\tasync (error: ExecFileException | null, stdout, stderr) => {\n\t\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t\tresolve((error?.code ?? proc.exitCode) as T);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error != null) {\n\t\t\t\t\tif (error.signal === 'SIGTERM') {\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\terror.code ?? undefined,\n\t\t\t\t\t\t\t\terror.signal,\n\t\t\t\t\t\t\t\tcancellation?.aborted ? 'aborted' : error.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (bufferExceededRegex.test(error.message)) {\n\t\t\t\t\t\terror.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet stdoutDecoded: string;\n\t\t\t\t\tlet stderrDecoded: string;\n\t\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\t\t// stdout & stderr can be `Buffer` or `string\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstdoutDecoded = stdout.toString();\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstderrDecoded = stderr.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstdoutDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstderrDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stderr, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treject(new RunError(error, stdoutDecoded, stderrDecoded));\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (stderr && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\tresolve(stdout as T);\n\t\t\t\t} else {\n\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(\n\t\t\t\t\t\t(await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t)) as T,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\n/**\n * Writes a child's whole input and closes it. A child can exit, or be killed on cancellation, before reading all of\n * it, and the pipe then errors (EPIPE, or EOF on Windows). Unlistened, that error is thrown as an uncaught exception\n * and takes down the whole host process, so it is dropped: the child's exit status and stderr already report the\n * failure, and a child that chose to stop reading answered from what it read.\n */\nexport function endStdin(stream: Writable | null, stdin: string | Buffer, stdinEncoding: string | undefined): void {\n\tif (stream == null) return;\n\n\tstream.on('error', () => {});\n\tif (typeof stdin === 'string') {\n\t\tstream.end(stdin, (stdinEncoding ?? 'utf8') as BufferEncoding);\n\t} else {\n\t\tstream.end(stdin);\n\t}\n}\n\nexport interface RunExitResult {\n\t/**\n\t * The process's exit code. ABSENT when the process never exited normally — killed by a signal, in which\n\t * case {@link signal} is set. Deliberately optional rather than defaulted to `0`: a signalled process\n\t * reported as `exitCode: 0` is indistinguishable from a clean success, so callers would read a partial\n\t * or empty stdout as a complete answer.\n\t */\n\treadonly exitCode?: number;\n\t/** Set when the process was terminated by a signal instead of exiting; {@link exitCode} is then absent. */\n\treadonly signal?: NodeJS.Signals;\n\t/** Whether Node itself killed the process (its spawn `timeout`), as opposed to an external signal. */\n\treadonly killed?: boolean;\n}\n\nexport interface RunResult<T extends string | Buffer> extends RunExitResult {\n\tstdout: T;\n\tstderr: T;\n}\n\nexport function runSpawn(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: ExitCodeOnlyRunOptions,\n): Promise<RunExitResult>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions,\n): Promise<RunResult<T>>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions & { exitCodeOnly?: boolean },\n): Promise<RunExitResult | RunResult<T>> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.runSpawn');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, spawn: spawner, ...opts }: RunOptions = options;\n\n\tconst promise = new Promise<RunExitResult | RunResult<T>>((resolve, reject) => {\n\t\tconst proc = (spawner ?? spawnProcess)(command, args, {\n\t\t\tcwd: opts.cwd,\n\t\t\tenv: opts.env,\n\t\t\t// 0 disables it, which the spawner contract spells as absent\n\t\t\ttimeout: opts.timeout === 0 ? undefined : opts.timeout,\n\t\t\tsignal: cancellation,\n\t\t\tstdio: [stdin != null ? 'pipe' : 'ignore', null, null],\n\t\t});\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst maxBuffer = opts.maxBuffer != null && opts.maxBuffer > 0 ? opts.maxBuffer : undefined;\n\t\tlet limitHit = false;\n\n\t\tfunction collector(buffers: Buffer[], name: 'stdout' | 'stderr'): (data: Buffer) => void {\n\t\t\tlet size = 0;\n\t\t\treturn (data: Buffer) => {\n\t\t\t\tif (limitHit) return;\n\n\t\t\t\tsize += data.length;\n\t\t\t\tif (maxBuffer != null && size > maxBuffer) {\n\t\t\t\t\texceedLimit(name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbuffers.push(data);\n\t\t\t};\n\t\t}\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tconst collectStdout = collector(stdoutBuffers, 'stdout');\n\t\tproc.stdout?.on('data', collectStdout);\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tconst collectStderr = collector(stderrBuffers, 'stderr');\n\t\tproc.stderr?.on('data', collectStderr);\n\n\t\t// Settles the run as soon as a stream passes the limit. Destroying the streams ends a spawner whose process\n\t\t// has no `kill`, and the late `'close'` or `'error'` is ignored through `limitHit`\n\t\tfunction exceedLimit(name: 'stdout' | 'stderr'): void {\n\t\t\tlimitHit = true;\n\t\t\tstdoutBuffers.length = 0;\n\t\t\tstderrBuffers.length = 0;\n\t\t\tproc.stdout?.off('data', collectStdout);\n\t\t\tproc.stderr?.off('data', collectStderr);\n\n\t\t\ttry {\n\t\t\t\tproc.kill?.();\n\t\t\t} catch {}\n\t\t\tproc.stdout?.destroy();\n\t\t\tproc.stderr?.destroy();\n\n\t\t\treject(\n\t\t\t\tnew RunError(\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Command output exceeded the allocated ${name} buffer. Set 'options.maxBuffer' to a larger value than ${maxBuffer} bytes`,\n\t\t\t\t\t\tcmd: `${command} ${args.join(' ')}`,\n\t\t\t\t\t\tkilled: true,\n\t\t\t\t\t\tcode: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',\n\t\t\t\t\t},\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tfunction getStdio<T>(\n\t\t\tencoding: BufferEncoding | 'buffer' | string,\n\t\t): { stdout: T; stderr: T } | Promise<{ stdout: T; stderr: T }> {\n\t\t\tconst stdout = Buffer.concat(stdoutBuffers);\n\t\t\tconst stderr = Buffer.concat(stderrBuffers);\n\t\t\tif (encoding === 'utf8' || encoding === 'binary') {\n\t\t\t\treturn { stdout: stdout.toString(encoding) as T, stderr: stderr.toString(encoding) as T };\n\t\t\t}\n\t\t\tif (encoding === 'buffer') {\n\t\t\t\treturn { stdout: stdout as T, stderr: stderr as T };\n\t\t\t}\n\n\t\t\tif (decode == null) {\n\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t}\n\n\t\t\treturn Promise.all([\n\t\t\t\tdecode(stdout, encoding ? { encoding: encoding } : undefined),\n\t\t\t\tdecode(stderr, encoding ? { encoding: encoding } : undefined),\n\t\t\t]).then(([decodedStdout, decodedStderr]) => ({\n\t\t\t\tstdout: decodedStdout as T,\n\t\t\t\tstderr: decodedStderr as T,\n\t\t\t}));\n\t\t}\n\n\t\t// An async listener's throw would be an unhandled rejection that leaves the promise pending forever, so\n\t\t// anything it throws (an undecodable output, a failing `decode`) rejects the run instead. It rejects as\n\t\t// thrown: wrapped in a `RunError` with the exit code, a clean exit would read as a run with no output\n\t\tconst rejectThrown = (ex: unknown): void => reject(ex instanceof Error ? ex : new Error(String(ex)));\n\t\tproc.once('error', ex => void onError(ex).catch(rejectThrown));\n\t\tproc.once('close', (code, signal) => void onClose(code, signal).catch(rejectThrown));\n\n\t\tasync function onError(ex: Error): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (ex?.name === 'AbortError') {\n\t\t\t\treject(new CancelledRunError(`${command} ${args.join(' ')}`, true, undefined, undefined, 'aborted'));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The launch failure is what the caller acts on, so output that can't be decoded is left out of it\n\t\t\tlet stdout = '';\n\t\t\tlet stderr = '';\n\t\t\ttry {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\t({ stdout, stderr } = stdio instanceof Promise ? await stdio : stdio);\n\t\t\t} catch {}\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t}\n\n\t\tasync function onClose(code: number | null, signal: NodeJS.Signals | null): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t// Resolves unconditionally, so this is the one path that can hand back a signalled run. `code`\n\t\t\t\t// is null exactly when the process was killed — report the signal rather than coercing to `0`,\n\t\t\t\t// which would claim a clean success for a command that never finished. Note this returns BEFORE\n\t\t\t\t// the SIGTERM-to-cancellation diversion below, so callers have to classify that themselves.\n\t\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, killed: proc.killed });\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (code !== 0 || signal) {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (signal === 'SIGTERM') {\n\t\t\t\t\t// Only Node's spawn `timeout` kills it (a caller abort rejected above, from `'error'`); an\n\t\t\t\t\t// external SIGTERM leaves `proc.killed` false\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tcode ?? undefined,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tproc.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treject(\n\t\t\t\t\tnew RunError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: `Command failed with exit code ${code}`,\n\t\t\t\t\t\t\tcode: code,\n\t\t\t\t\t\t\tsignal: signal ?? undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<T>(encoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${typeof stderr === 'string' ? stderr : stderr.toString()}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The guard above already rejected every non-zero and every signalled close, so this is a clean\n\t\t\t// zero exit — `code` cannot be null here. (The optional typing exists for the `exitCodeOnly`\n\t\t\t// branch, which is where a codeless result can genuinely surface.)\n\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, stdout: stdout, stderr: stderr });\n\t\t}\n\n\t\t// Only a host spawner can leave these out; reading no output as empty would pass for a clean answer\n\t\tif (proc.stdout == null || proc.stderr == null) {\n\t\t\treject(new Error(`'${command}' was spawned without stdout and stderr pipes`));\n\t\t}\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\nexport async function fsExists(path: string): Promise<boolean> {\n\treturn new Promise<boolean>(resolve => access(path, constants.F_OK, err => resolve(err == null)));\n}\n"],"mappings":";;;;;;;;AAsBA,IAAa,WAAb,cAA8B,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA0B,QAAgB,QAAgB;EACrE,MAAM,QAAQ,OAAO;EAErB,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ,QAAQ,KAAA;EAC5B,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ,KAAK,KAAK;EAChC,KAAK,SAAS,QAAQ,KAAK,KAAK;EAEhC,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAEA,IAAa,oBAAb,cAAuC,SAAS;CAC/C;CAEA,YACC,KACA,QACA,MACA,SAAyB,WACzB,SAA6B,WAC5B;EACD,MACC;GAAE,SAAS,gCAAgC;GAAY;GAAa;GAAc;GAAc;EAAO,GACvG,IACA,EACD;EAEA,KAAK,SAAS;EAEd,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAIA,MAAM,eAAe;AACrB,MAAM,WAAW;AACjB,MAAM,gBAAgB;AACtB,MAAM,UAAU;;;;;;;;;;AAWhB,eAAe,YAAY,KAA8B;CAKxD,IAAI,aAAa,KAAK,GAAG,GAAG,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KAAK,SAAS,YAAY,SAC3B,CACD;KAEA;IACD;IAEA,OACC,IAAI,SACH;KACC,SAAS,iCAAiC;KACpC;KACN,QAAQ,UAAU,KAAA;IACnB,GACA,QACA,MACD,CACD;IAEA;GACD;GAEA,MAAM,QAAQ,SAAY,QAAQ;GAClC,MAAM,EAAE,QAAQ,WAAW,iBAAiB,UAAU,MAAM,QAAQ;GACpE,IAAI,OAAO,UAAU,CAAC,SAAS,SAAS,OAAO,QAAQ,OAAO,GAC7D,OAAO,KACN,WAAW,QAAQ,GAAG,KAAK,KAAK,GAAG,EAAE,WAAW,OAAO,WAAW,WAAW,SAAS,OAAO,SAAS,GACvG;GAMD,QAAQ;IAAE,UAAU,QAAQ,KAAA;IAAW,QAAQ,UAAU,KAAA;IAAmB;IAAgB;GAAO,CAAC;EACrG;EAGA,IAAI,KAAK,UAAU,QAAQ,KAAK,UAAU,MACzC,uBAAO,IAAI,MAAM,IAAI,QAAQ,8CAA8C,CAAC;EAG7E,IAAI,SAAS,MACZ,SAAS,KAAK,OAAO,OAAO,aAAa;CAE3C,CAEa,CAAC,CAAC,cAAc,QAAQ,OAAO,QAAQ,CAAC,CAAC;AACvD;AAEA,eAAsB,SAAS,MAAgC;CAC9D,OAAO,IAAI,SAAiB,YAAW,OAAO,MAAM,UAAU,OAAM,QAAO,QAAQ,OAAO,IAAI,CAAC,CAAC;AACjG"}
1
+ {"version":3,"file":"exec.js","names":["joinPaths"],"sources":["../../../../../utils/src/env/node/exec.ts"],"sourcesContent":["import type { ChildProcess, ExecFileException, ExecFileOptions } from 'child_process';\nimport { execFile, spawn } from 'child_process';\nimport type { Stats } from 'fs';\nimport { access, constants } from 'fs';\nimport { stat } from 'fs/promises';\nimport { join as joinPaths } from 'path';\nimport * as process from 'process';\nimport type { Readable, Writable } from 'stream';\nimport type { CancellationReason } from '../../cancellation.js';\nimport { getScopedLogger, maybeStartScopedLogger } from '../../logger.scoped.js';\nimport { isWindows } from './platform.js';\n\n// -- Error types --\n\ninterface RunErrorContext {\n\tmessage: string;\n\tcmd?: string | undefined;\n\tkilled?: boolean | undefined;\n\tcode?: string | number | null | undefined;\n\tsignal?: NodeJS.Signals | undefined;\n\tsyscall?: string | undefined;\n}\n\nexport class RunError extends Error {\n\treadonly cmd?: string | undefined;\n\treadonly killed?: boolean | undefined;\n\treadonly code?: string | number | undefined;\n\treadonly signal?: NodeJS.Signals | undefined;\n\treadonly syscall?: string | undefined;\n\treadonly stdout: string;\n\treadonly stderr: string;\n\n\tconstructor(context: RunErrorContext, stdout: string, stderr: string) {\n\t\tsuper(context.message);\n\n\t\tthis.cmd = context.cmd;\n\t\tthis.killed = context.killed;\n\t\tthis.code = context.code ?? undefined;\n\t\tthis.signal = context.signal;\n\t\tthis.syscall = context.syscall;\n\t\tthis.stdout = stdout?.trim() ?? '';\n\t\tthis.stderr = stderr?.trim() ?? '';\n\n\t\tthis.name = 'RunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\nexport class CancelledRunError extends RunError {\n\treadonly reason: CancellationReason;\n\n\tconstructor(\n\t\tcmd: string,\n\t\tkilled: boolean,\n\t\tcode?: number | string | undefined,\n\t\tsignal: NodeJS.Signals = 'SIGTERM',\n\t\treason: CancellationReason = 'unknown',\n\t) {\n\t\tsuper(\n\t\t\t{ message: `Operation cancelled; command=${cmd}`, cmd: cmd, killed: killed, code: code, signal: signal },\n\t\t\t'',\n\t\t\t'',\n\t\t);\n\n\t\tthis.reason = reason;\n\n\t\tthis.name = 'CancelledRunError';\n\t\tError.captureStackTrace?.(this, new.target);\n\t}\n}\n\n// -- Execution utilities --\n\nconst slashesRegex = /[\\\\/]/;\nconst ps1Regex = /\\.ps1$/i;\nconst batOrCmdRegex = /\\.(bat|cmd)$/i;\nconst jsRegex = /\\.(js)$/i;\n\n/**\n * Search PATH to see if a file exists in any of the path folders.\n *\n * @param {string} exe The file to search for\n * @return {string} A fully qualified path, or the original path if nothing\n * is found\n *\n * @private\n */\nasync function runDownPath(exe: string): Promise<string> {\n\t// NB: Windows won't search PATH looking for executables in spawn like\n\t// Posix does\n\n\t// Files with any directory path don't get this applied\n\tif (slashesRegex.test(exe)) return exe;\n\n\tconst target = joinPaths('.', exe);\n\ttry {\n\t\tconst stats = await stat(target);\n\t\tif (stats?.isFile() && isExecutable(stats)) return target;\n\t} catch {}\n\n\tconst path = process.env.PATH;\n\tif (path != null && path.length !== 0) {\n\t\tconst haystack = path.split(isWindows ? ';' : ':');\n\t\tfor (const p of haystack) {\n\t\t\tconst needle = joinPaths(p, exe);\n\t\t\ttry {\n\t\t\t\tconst stats = await stat(needle);\n\t\t\t\tif (stats?.isFile() && isExecutable(stats)) return needle;\n\t\t\t} catch {}\n\t\t}\n\t}\n\n\treturn exe;\n}\n\nfunction isExecutable(stats: Stats) {\n\tif (isWindows) return true;\n\n\tconst isGroup = stats.gid ? stats.gid === process.getgid?.() : true;\n\tconst isUser = stats.uid ? stats.uid === process.getuid?.() : true;\n\n\treturn Boolean(stats.mode & 0o0001 || (stats.mode & 0o0010 && isGroup) || (stats.mode & 0o0100 && isUser));\n}\n\n/**\n * Finds the executable and parameters to run on Windows. This method\n * mimics the POSIX behavior of being able to run scripts as executables by\n * replacing the passed-in executable with the script runner, for PowerShell,\n * CMD, and node scripts.\n *\n * This method also does the work of running down PATH, which spawn on Windows\n * also doesn't do, unlike on POSIX.\n */\nexport async function findExecutable(exe: string, args: string[]): Promise<{ cmd: string; args: string[] }> {\n\t// POSIX can just execute scripts directly, no need for silly goosery\n\tif (!isWindows) return { cmd: await runDownPath(exe), args: args };\n\n\tif (!(await fsExists(exe))) {\n\t\t// NB: When you write something like `surf-client ... -- surf-build` on Windows,\n\t\t// a shell would normally convert that to surf-build.cmd, but since it's passed\n\t\t// in as an argument, it doesn't happen\n\t\tconst possibleExts = ['.exe', '.bat', '.cmd', '.ps1'];\n\t\tfor (const ext of possibleExts) {\n\t\t\tconst possibleFullPath = await runDownPath(`${exe}${ext}`);\n\n\t\t\tif (await fsExists(possibleFullPath)) return findExecutable(possibleFullPath, args);\n\t\t}\n\t}\n\n\tif (ps1Regex.test(exe)) {\n\t\tconst cmd = joinPaths(\n\t\t\tprocess.env.SYSTEMROOT ?? 'C:\\\\WINDOWS',\n\t\t\t'System32',\n\t\t\t'WindowsPowerShell',\n\t\t\t'v1.0',\n\t\t\t'PowerShell.exe',\n\t\t);\n\t\tconst psargs = ['-ExecutionPolicy', 'Unrestricted', '-NoLogo', '-NonInteractive', '-File', exe];\n\n\t\treturn { cmd: cmd, args: [...psargs, ...args] };\n\t}\n\n\tif (batOrCmdRegex.test(exe)) {\n\t\tconst cmd = joinPaths(process.env.SYSTEMROOT ?? 'C:\\\\WINDOWS', 'System32', 'cmd.exe');\n\t\tconst cmdArgs = ['/C', exe, ...args];\n\n\t\treturn { cmd: cmd, args: cmdArgs };\n\t}\n\n\tif (jsRegex.test(exe)) {\n\t\tconst cmd = process.execPath;\n\t\tconst nodeArgs = [exe];\n\n\t\treturn { cmd: cmd, args: [...nodeArgs, ...args] };\n\t}\n\n\treturn { cmd: exe, args: args };\n}\n\n/** What core uses of a spawned process; Node's `ChildProcess` satisfies it */\nexport interface SpawnedProcess {\n\treadonly stdin: Writable | null;\n\treadonly stdout: Readable | null;\n\treadonly stderr: Readable | null;\n\treadonly killed: boolean;\n\treadonly exitCode: number | null;\n\treadonly spawnargs: string[];\n\t/** Used to stop a run that passes its `maxBuffer`; without it the run destroys the output streams instead */\n\tkill?(signal?: NodeJS.Signals): boolean;\n\tonce(event: 'error', listener: (error: Error) => void): this;\n\tonce(event: 'close', listener: (code: number | null, signal: NodeJS.Signals | null) => void): this;\n\tremoveAllListeners(): this;\n}\n\nexport interface ProcessSpawnOptions {\n\treadonly cwd?: string;\n\t/** The child's whole environment, not additions to the spawner's own; an `undefined` value leaves the key out */\n\treadonly env?: Record<string, string | undefined>;\n\t/** Milliseconds; absent means none */\n\treadonly timeout?: number;\n\treadonly signal?: AbortSignal;\n\t/** A `null` entry means `'pipe'` */\n\treadonly stdio?: ['pipe' | 'ignore', null, null];\n}\n\n/**\n * Launches a process in place of Node's `spawn`, and must behave as it does:\n * - pipe stdout and stderr, and stdin unless `stdio[0]` is `'ignore'`, which leaves `stdin` null\n * - honour `signal`, including one already aborted: kill with SIGTERM, then emit `'error'` with `name` `AbortError`,\n * unless the process has already exited\n * - honour `timeout`: kill with SIGTERM and set `killed`, without emitting `'error'`\n * - report a killed process's `'close'` with a null code and its signal, not an exit code such as 143\n * - on Windows, end the process's whole tree when killing it (timeout, abort, or `kill`): a launcher such as Git for\n * Windows' `cmd\\git.exe` runs the real git as a child holding the same pipes, so killing only the launcher leaves\n * them open and `'close'` never comes\n * - emit no event before returning, `'error'` at most once, and `'close'` exactly once and last: also after `'error'`\n * (a failed launch, an abort), and only after `stdout` and `stderr` have ended or been destroyed, with `exitCode`\n * and `killed` already set\n * - close the child's stdout when `stdout` is destroyed, which is how a reader that stops early ends the process\n */\nexport type ProcessSpawner = (command: string, args: readonly string[], options: ProcessSpawnOptions) => SpawnedProcess;\n\n/**\n * The default {@link ProcessSpawner}: Node's `spawn`, but with its `timeout` handled here. Node clears its timeout\n * timer only on `'exit'`, which a failed launch (e.g. a missing `cwd`) never emits, so the timer outlives the\n * process and keeps Node alive for the full timeout. This mirrors Node's timeout handling but also clears on\n * `'close'`, as https://github.com/nodejs/node/pull/65506 does; remove it once the minimum supported Node/Electron\n * includes that fix.\n */\nexport function spawnProcess(command: string, args: readonly string[], options: ProcessSpawnOptions): ChildProcess {\n\tconst { timeout, ...spawnOptions } = options;\n\t// Node's own validation, thrown before anything spawns\n\tif (timeout != null && !(Number.isInteger(timeout) && timeout >= 0)) {\n\t\tconst ex = new RangeError(\n\t\t\t`The value of \"timeout\" is out of range. It must be an unsigned integer. Received ${String(timeout)}`,\n\t\t);\n\t\t(ex as RangeError & { code: string }).code = 'ERR_OUT_OF_RANGE';\n\t\tthrow ex;\n\t}\n\n\tconst child = spawn(command, args, spawnOptions);\n\tif (isWindows) {\n\t\tkillTreeOnKill(child);\n\t}\n\n\tif (timeout != null && timeout > 0) {\n\t\tkillOnTimeout(child, timeout);\n\t}\n\n\treturn child;\n}\n\n/** Node's spawn `timeout`, but also cleared on `'close'`; see {@link spawnProcess} */\nfunction killOnTimeout(child: ChildProcess, timeout: number): void {\n\tlet timeoutId: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n\t\tif (timeoutId != null) {\n\t\t\ttry {\n\t\t\t\tchild.kill();\n\t\t\t} catch (ex) {\n\t\t\t\tchild.emit('error', ex);\n\t\t\t}\n\t\t\ttimeoutId = undefined;\n\t\t}\n\t}, timeout);\n\n\tconst clear = () => {\n\t\tif (timeoutId != null) {\n\t\t\tclearTimeout(timeoutId);\n\t\t\ttimeoutId = undefined;\n\t\t}\n\t};\n\t// `'exit'` keeps Node's timing; `'close'` covers a launch that fails and never exits\n\tchild.once('exit', clear);\n\tchild.once('close', clear);\n}\n\nconst taskkillTimeout = 5000;\n\n/**\n * Makes `kill` end the child's whole tree (Windows only). There `kill` terminates just the child, and a launcher such\n * as Git for Windows' `cmd\\git.exe` runs the real git as its own child on the same stdout and stderr, so the pipes\n * stay open and `'close'` never comes. Node's abort and timeout paths call the instance's `kill`, so this covers them.\n */\nfunction killTreeOnKill(child: ChildProcess): void {\n\tconst kill = child.kill.bind(child);\n\tconst mutable = child as { killed: boolean; exitCode: number | null; signalCode: NodeJS.Signals | null };\n\tlet killing = false;\n\n\tchild.kill = (signal?: NodeJS.Signals | number): boolean => {\n\t\tif (child.pid == null || child.exitCode !== null || child.signalCode !== null || typeof signal === 'number') {\n\t\t\treturn kill(signal);\n\t\t}\n\t\tif (killing) return true;\n\n\t\tkilling = true;\n\t\tconst killSignal = signal ?? 'SIGTERM';\n\t\tmutable.killed = true;\n\n\t\t// Killed from outside, the child exits with taskkill's code 1 and no signal; report it as Node's own kill\n\t\t// would, a null code and the signal, which is what every caller keys on\n\t\tlet exitCode: number | null = child.exitCode;\n\t\tObject.defineProperty(child, 'exitCode', {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tget: () => exitCode,\n\t\t\tset: (value: number | null) => {\n\t\t\t\tif (value === 1) {\n\t\t\t\t\texitCode = null;\n\t\t\t\t\tmutable.signalCode = killSignal;\n\t\t\t\t} else {\n\t\t\t\t\texitCode = value;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\n\t\t// Once it's killed, a descendant left alive (taskkill failed, or its parent was already gone) can still hold the\n\t\t// pipes; destroying them lets `'close'` come anyway. A child that exited on its own keeps its output\n\t\tchild.once('exit', (_code, exitSignal) => {\n\t\t\tif (exitSignal == null) return;\n\n\t\t\tchild.stdout?.destroy();\n\t\t\tchild.stderr?.destroy();\n\t\t});\n\n\t\t// taskkill failed: fall back to Node's kill, unless the child already exited on its own\n\t\tlet failed = false;\n\t\tconst fail = () => {\n\t\t\tif (failed || child.exitCode !== null || child.signalCode !== null) return;\n\n\t\t\tfailed = true;\n\t\t\ttry {\n\t\t\t\tkill(killSignal);\n\t\t\t} catch {}\n\t\t};\n\n\t\ttry {\n\t\t\t// By absolute path: Windows searches the current directory before PATH for a bare name. Its own time limit\n\t\t\t// keeps a stalled taskkill from leaving the kill, and so the run, hanging\n\t\t\tconst taskkill = spawn(\n\t\t\t\tjoinPaths(process.env.SystemRoot || 'C:\\\\Windows', 'System32', 'taskkill.exe'),\n\t\t\t\t['/T', '/F', '/PID', String(child.pid)],\n\t\t\t\t{ stdio: 'ignore', windowsHide: true },\n\t\t\t);\n\t\t\tkillOnTimeout(taskkill, taskkillTimeout);\n\t\t\ttaskkill.once('error', fail);\n\t\t\ttaskkill.once('exit', code => {\n\t\t\t\tif (code !== 0) {\n\t\t\t\t\tfail();\n\t\t\t\t}\n\t\t\t});\n\t\t} catch {\n\t\t\tfail();\n\t\t}\n\n\t\treturn true;\n\t};\n}\n\nexport interface RunOptions<TEncoding = BufferEncoding | 'buffer'> {\n\tcwd?: string;\n\treadonly env?: Record<string, string | undefined>;\n\treadonly encoding?: TEncoding;\n\t/**\n\t * Decodes non-UTF-8 output. Called when `encoding` is not utf8/binary/buffer.\n\t * Provided by the host via the `GitOptions.decode` option.\n\t * If absent and a non-UTF-8 encoding is requested, throws at runtime.\n\t */\n\treadonly decode?: (data: Uint8Array, options?: { readonly encoding: string }) => string | Promise<string>;\n\t/**\n\t * The most bytes each of stdout and stderr may produce; past it the process is killed and the run rejects\n\t * with a `RunError` whose `code` is `ERR_CHILD_PROCESS_STDIO_MAXBUFFER`.\n\t *\n\t * If not specified, `run` allows 1000MB per stream and `runSpawn` allows unlimited output.\n\t */\n\treadonly maxBuffer?: number;\n\treadonly cancellation?: AbortSignal;\n\t/**\n\t * An optional string or buffer which will be written to\n\t * the child process stdin stream immediately immediately\n\t * after spawning the process.\n\t */\n\treadonly stdin?: string | Buffer;\n\t/**\n\t * The encoding to use when writing to stdin, if the stdin\n\t * parameter is a string.\n\t */\n\treadonly stdinEncoding?: string;\n\treadonly timeout?: number;\n\t/**\n\t * When true, suppresses the `[EXEC]` stderr warning emitted on debug-enabled scopes.\n\t * Use for commands whose failure is expected (e.g. paired with `errors: 'ignore'`).\n\t */\n\treadonly quiet?: boolean;\n\t/** Launches the process; defaults to {@link spawnProcess}. Only used by `runSpawn` */\n\treadonly spawn?: ProcessSpawner;\n}\n\nconst bufferExceededRegex = /stdout maxBuffer( length)? exceeded/;\n\ntype ExitCodeOnlyRunOptions<TEncoding = BufferEncoding | 'buffer'> = RunOptions<TEncoding> & { exitCodeOnly: true };\n\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions: ExitCodeOnlyRunOptions<BufferEncoding>,\n): Promise<number>;\nexport function run(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding>,\n): Promise<string>;\nexport function run<T extends number | string>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | string,\n\toptions?: RunOptions<BufferEncoding> & { exitCodeOnly?: boolean },\n): Promise<T> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.run');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, ...opts }: RunOptions<BufferEncoding> & ExecFileOptions = {\n\t\tmaxBuffer: 1000 * 1024 * 1024,\n\t\t...options,\n\t};\n\n\tconst promise = new Promise<T>((resolve, reject) => {\n\t\tconst proc = execFile(\n\t\t\tcommand,\n\t\t\targs,\n\t\t\t{ ...opts, signal: cancellation },\n\t\t\tasync (error: ExecFileException | null, stdout, stderr) => {\n\t\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t\tresolve((error?.code ?? proc.exitCode) as T);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (error != null) {\n\t\t\t\t\tif (error.signal === 'SIGTERM') {\n\t\t\t\t\t\treject(\n\t\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\t\terror.code ?? undefined,\n\t\t\t\t\t\t\t\terror.signal,\n\t\t\t\t\t\t\t\tcancellation?.aborted ? 'aborted' : error.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (bufferExceededRegex.test(error.message)) {\n\t\t\t\t\t\terror.message = `Command output exceeded the allocated stdout buffer. Set 'options.maxBuffer' to a larger value than ${opts.maxBuffer} bytes`;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet stdoutDecoded: string;\n\t\t\t\t\tlet stderrDecoded: string;\n\t\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\t\t// stdout & stderr can be `Buffer` or `string\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstdoutDecoded = stdout.toString();\n\t\t\t\t\t\t// oxlint-disable-next-line typescript/no-unnecessary-type-conversion\n\t\t\t\t\t\tstderrDecoded = stderr.toString();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tstdoutDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tstderrDecoded = await decode(\n\t\t\t\t\t\t\tBuffer.from(stderr, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treject(new RunError(error, stdoutDecoded, stderrDecoded));\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (stderr && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (encoding === 'utf8' || encoding === 'binary' || encoding === 'buffer') {\n\t\t\t\t\tresolve(stdout as T);\n\t\t\t\t} else {\n\t\t\t\t\tif (decode == null) {\n\t\t\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t\t\t}\n\n\t\t\t\t\tresolve(\n\t\t\t\t\t\t(await decode(\n\t\t\t\t\t\t\tBuffer.from(stdout, 'binary'),\n\t\t\t\t\t\t\tencoding ? { encoding: encoding } : undefined,\n\t\t\t\t\t\t)) as T,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\n/**\n * Writes a child's whole input and closes it. A child can exit, or be killed on cancellation, before reading all of\n * it, and the pipe then errors (EPIPE, or EOF on Windows). Unlistened, that error is thrown as an uncaught exception\n * and takes down the whole host process, so it is dropped: the child's exit status and stderr already report the\n * failure, and a child that chose to stop reading answered from what it read.\n */\nexport function endStdin(stream: Writable | null, stdin: string | Buffer, stdinEncoding: string | undefined): void {\n\tif (stream == null) return;\n\n\tstream.on('error', () => {});\n\tif (typeof stdin === 'string') {\n\t\tstream.end(stdin, (stdinEncoding ?? 'utf8') as BufferEncoding);\n\t} else {\n\t\tstream.end(stdin);\n\t}\n}\n\nexport interface RunExitResult {\n\t/**\n\t * The process's exit code. ABSENT when the process never exited normally — killed by a signal, in which\n\t * case {@link signal} is set. Deliberately optional rather than defaulted to `0`: a signalled process\n\t * reported as `exitCode: 0` is indistinguishable from a clean success, so callers would read a partial\n\t * or empty stdout as a complete answer.\n\t */\n\treadonly exitCode?: number;\n\t/** Set when the process was terminated by a signal instead of exiting; {@link exitCode} is then absent. */\n\treadonly signal?: NodeJS.Signals;\n\t/** Whether Node itself killed the process (its spawn `timeout`), as opposed to an external signal. */\n\treadonly killed?: boolean;\n}\n\nexport interface RunResult<T extends string | Buffer> extends RunExitResult {\n\tstdout: T;\n\tstderr: T;\n}\n\nexport function runSpawn(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: ExitCodeOnlyRunOptions,\n): Promise<RunExitResult>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions,\n): Promise<RunResult<T>>;\nexport function runSpawn<T extends string | Buffer>(\n\tcommand: string,\n\targs: readonly string[],\n\tencoding: BufferEncoding | 'buffer' | string,\n\toptions: RunOptions & { exitCodeOnly?: boolean },\n): Promise<RunExitResult | RunResult<T>> {\n\tconst scope = getScopedLogger() ?? maybeStartScopedLogger('Exec.runSpawn');\n\n\tconst { stdin, stdinEncoding, cancellation, decode, spawn: spawner, ...opts }: RunOptions = options;\n\n\tconst promise = new Promise<RunExitResult | RunResult<T>>((resolve, reject) => {\n\t\tconst proc = (spawner ?? spawnProcess)(command, args, {\n\t\t\tcwd: opts.cwd,\n\t\t\tenv: opts.env,\n\t\t\t// 0 disables it, which the spawner contract spells as absent\n\t\t\ttimeout: opts.timeout === 0 ? undefined : opts.timeout,\n\t\t\tsignal: cancellation,\n\t\t\tstdio: [stdin != null ? 'pipe' : 'ignore', null, null],\n\t\t});\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst maxBuffer = opts.maxBuffer != null && opts.maxBuffer > 0 ? opts.maxBuffer : undefined;\n\t\tlet limitHit = false;\n\n\t\tfunction collector(buffers: Buffer[], name: 'stdout' | 'stderr'): (data: Buffer) => void {\n\t\t\tlet size = 0;\n\t\t\treturn (data: Buffer) => {\n\t\t\t\tif (limitHit) return;\n\n\t\t\t\tsize += data.length;\n\t\t\t\tif (maxBuffer != null && size > maxBuffer) {\n\t\t\t\t\texceedLimit(name);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbuffers.push(data);\n\t\t\t};\n\t\t}\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tconst collectStdout = collector(stdoutBuffers, 'stdout');\n\t\tproc.stdout?.on('data', collectStdout);\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tconst collectStderr = collector(stderrBuffers, 'stderr');\n\t\tproc.stderr?.on('data', collectStderr);\n\n\t\t// Settles the run as soon as a stream passes the limit. Destroying the streams ends a spawner whose process\n\t\t// has no `kill`, and the late `'close'` or `'error'` is ignored through `limitHit`\n\t\tfunction exceedLimit(name: 'stdout' | 'stderr'): void {\n\t\t\tlimitHit = true;\n\t\t\tstdoutBuffers.length = 0;\n\t\t\tstderrBuffers.length = 0;\n\t\t\tproc.stdout?.off('data', collectStdout);\n\t\t\tproc.stderr?.off('data', collectStderr);\n\n\t\t\ttry {\n\t\t\t\tproc.kill?.();\n\t\t\t} catch {}\n\t\t\tproc.stdout?.destroy();\n\t\t\tproc.stderr?.destroy();\n\n\t\t\treject(\n\t\t\t\tnew RunError(\n\t\t\t\t\t{\n\t\t\t\t\t\tmessage: `Command output exceeded the allocated ${name} buffer. Set 'options.maxBuffer' to a larger value than ${maxBuffer} bytes`,\n\t\t\t\t\t\tcmd: `${command} ${args.join(' ')}`,\n\t\t\t\t\t\tkilled: true,\n\t\t\t\t\t\tcode: 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER',\n\t\t\t\t\t},\n\t\t\t\t\t'',\n\t\t\t\t\t'',\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tfunction getStdio<T>(\n\t\t\tencoding: BufferEncoding | 'buffer' | string,\n\t\t): { stdout: T; stderr: T } | Promise<{ stdout: T; stderr: T }> {\n\t\t\tconst stdout = Buffer.concat(stdoutBuffers);\n\t\t\tconst stderr = Buffer.concat(stderrBuffers);\n\t\t\tif (encoding === 'utf8' || encoding === 'binary') {\n\t\t\t\treturn { stdout: stdout.toString(encoding) as T, stderr: stderr.toString(encoding) as T };\n\t\t\t}\n\t\t\tif (encoding === 'buffer') {\n\t\t\t\treturn { stdout: stdout as T, stderr: stderr as T };\n\t\t\t}\n\n\t\t\tif (decode == null) {\n\t\t\t\tthrow new Error(`Non-UTF-8 encoding '${encoding}' requested but no decode function configured`);\n\t\t\t}\n\n\t\t\treturn Promise.all([\n\t\t\t\tdecode(stdout, encoding ? { encoding: encoding } : undefined),\n\t\t\t\tdecode(stderr, encoding ? { encoding: encoding } : undefined),\n\t\t\t]).then(([decodedStdout, decodedStderr]) => ({\n\t\t\t\tstdout: decodedStdout as T,\n\t\t\t\tstderr: decodedStderr as T,\n\t\t\t}));\n\t\t}\n\n\t\t// An async listener's throw would be an unhandled rejection that leaves the promise pending forever, so\n\t\t// anything it throws (an undecodable output, a failing `decode`) rejects the run instead. It rejects as\n\t\t// thrown: wrapped in a `RunError` with the exit code, a clean exit would read as a run with no output\n\t\tconst rejectThrown = (ex: unknown): void => reject(ex instanceof Error ? ex : new Error(String(ex)));\n\t\tproc.once('error', ex => void onError(ex).catch(rejectThrown));\n\t\tproc.once('close', (code, signal) => void onClose(code, signal).catch(rejectThrown));\n\n\t\tasync function onError(ex: Error): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (ex?.name === 'AbortError') {\n\t\t\t\treject(new CancelledRunError(`${command} ${args.join(' ')}`, true, undefined, undefined, 'aborted'));\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// The launch failure is what the caller acts on, so output that can't be decoded is left out of it\n\t\t\tlet stdout = '';\n\t\t\tlet stderr = '';\n\t\t\ttry {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\t({ stdout, stderr } = stdio instanceof Promise ? await stdio : stdio);\n\t\t\t} catch {}\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t}\n\n\t\tasync function onClose(code: number | null, signal: NodeJS.Signals | null): Promise<void> {\n\t\t\tif (limitHit) return;\n\n\t\t\tif (options?.exitCodeOnly) {\n\t\t\t\t// Resolves unconditionally, so this is the one path that can hand back a signalled run. `code`\n\t\t\t\t// is null exactly when the process was killed — report the signal rather than coercing to `0`,\n\t\t\t\t// which would claim a clean success for a command that never finished. Note this returns BEFORE\n\t\t\t\t// the SIGTERM-to-cancellation diversion below, so callers have to classify that themselves.\n\t\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, killed: proc.killed });\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (code !== 0 || signal) {\n\t\t\t\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\t\tscope?.warn(`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${stderr}`);\n\t\t\t\t}\n\n\t\t\t\tif (signal === 'SIGTERM') {\n\t\t\t\t\t// Only Node's spawn `timeout` kills it (a caller abort rejected above, from `'error'`); an\n\t\t\t\t\t// external SIGTERM leaves `proc.killed` false\n\t\t\t\t\treject(\n\t\t\t\t\t\tnew CancelledRunError(\n\t\t\t\t\t\t\t`${command} ${args.join(' ')}`,\n\t\t\t\t\t\t\ttrue,\n\t\t\t\t\t\t\tcode ?? undefined,\n\t\t\t\t\t\t\tsignal,\n\t\t\t\t\t\t\tproc.killed ? 'timeout' : 'unknown',\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treject(\n\t\t\t\t\tnew RunError(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmessage: `Command failed with exit code ${code}`,\n\t\t\t\t\t\t\tcode: code,\n\t\t\t\t\t\t\tsignal: signal ?? undefined,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tstdout,\n\t\t\t\t\t\tstderr,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst stdio = getStdio<T>(encoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\t\t\tif (stderr.length && !options?.quiet && scope?.enabled('debug')) {\n\t\t\t\tscope?.warn(\n\t\t\t\t\t`[EXEC] '${command} ${args.join(' ')}' \\u2022 ${typeof stderr === 'string' ? stderr : stderr.toString()}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// The guard above already rejected every non-zero and every signalled close, so this is a clean\n\t\t\t// zero exit — `code` cannot be null here. (The optional typing exists for the `exitCodeOnly`\n\t\t\t// branch, which is where a codeless result can genuinely surface.)\n\t\t\tresolve({ exitCode: code ?? undefined, signal: signal ?? undefined, stdout: stdout, stderr: stderr });\n\t\t}\n\n\t\t// Only a host spawner can leave these out; reading no output as empty would pass for a clean answer\n\t\tif (proc.stdout == null || proc.stderr == null) {\n\t\t\treject(new Error(`'${command}' was spawned without stdout and stderr pipes`));\n\t\t}\n\n\t\tif (stdin != null) {\n\t\t\tendStdin(proc.stdin, stdin, stdinEncoding);\n\t\t}\n\t});\n\n\treturn promise.finally(() => scope?.[Symbol.dispose]());\n}\n\nexport async function fsExists(path: string): Promise<boolean> {\n\treturn new Promise<boolean>(resolve => access(path, constants.F_OK, err => resolve(err == null)));\n}\n"],"mappings":";;;;;;;;AAuBA,IAAa,WAAb,cAA8B,MAAM;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CAEA,YAAY,SAA0B,QAAgB,QAAgB;EACrE,MAAM,QAAQ,OAAO;EAErB,KAAK,MAAM,QAAQ;EACnB,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ,QAAQ,KAAA;EAC5B,KAAK,SAAS,QAAQ;EACtB,KAAK,UAAU,QAAQ;EACvB,KAAK,SAAS,QAAQ,KAAK,KAAK;EAChC,KAAK,SAAS,QAAQ,KAAK,KAAK;EAEhC,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAEA,IAAa,oBAAb,cAAuC,SAAS;CAC/C;CAEA,YACC,KACA,QACA,MACA,SAAyB,WACzB,SAA6B,WAC5B;EACD,MACC;GAAE,SAAS,gCAAgC;GAAY;GAAa;GAAc;GAAc;EAAO,GACvG,IACA,EACD;EAEA,KAAK,SAAS;EAEd,KAAK,OAAO;EACZ,MAAM,oBAAoB,MAAM,UAAU;CAC3C;AACD;AAIA,MAAM,eAAe;AACrB,MAAM,WAAW;AACjB,MAAM,gBAAgB;AACtB,MAAM,UAAU;;;;;;;;;;AAWhB,eAAe,YAAY,KAA8B;CAKxD,IAAI,aAAa,KAAK,GAAG,GAAG,OAAO;CAEnC,MAAM,SAASA,KAAU,KAAK,GAAG;CACjC,IAAI;EACH,MAAM,QAAQ,MAAM,KAAK,MAAM;EAC/B,IAAI,OAAO,OAAO,KAAK,aAAa,KAAK,GAAG,OAAO;CACpD,QAAQ,CAAC;CAET,MAAM,OAAO,QAAQ,IAAI;CACzB,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Q,WAAW,iBAAiB,UAAU,MAAM,QAAQ;GACpE,IAAI,OAAO,UAAU,CAAC,SAAS,SAAS,OAAO,QAAQ,OAAO,GAC7D,OAAO,KACN,WAAW,QAAQ,GAAG,KAAK,KAAK,GAAG,EAAE,WAAW,OAAO,WAAW,WAAW,SAAS,OAAO,SAAS,GACvG;GAMD,QAAQ;IAAE,UAAU,QAAQ,KAAA;IAAW,QAAQ,UAAU,KAAA;IAAmB;IAAgB;GAAO,CAAC;EACrG;EAGA,IAAI,KAAK,UAAU,QAAQ,KAAK,UAAU,MACzC,uBAAO,IAAI,MAAM,IAAI,QAAQ,8CAA8C,CAAC;EAG7E,IAAI,SAAS,MACZ,SAAS,KAAK,OAAO,OAAO,aAAa;CAE3C,CAEa,CAAC,CAAC,cAAc,QAAQ,OAAO,QAAQ,CAAC,CAAC;AACvD;AAEA,eAAsB,SAAS,MAAgC;CAC9D,OAAO,IAAI,SAAiB,YAAW,OAAO,MAAM,UAAU,OAAM,QAAO,QAAQ,OAAO,IAAI,CAAC,CAAC;AACjG"}
@@ -93,15 +93,15 @@ a pull request from a provider with no arm.
93
93
  cross-boundary contract — the package never imports `vscode` and has no ambient globals. The extension host's
94
94
  broader `IntegrationServiceContext` is internal and is not part of the published facade.
95
95
 
96
- | Provider | Required | What it must do |
97
- | -------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
98
- | `storage` | yes | Global + workspace key/value, plus a secret store (tokens land here). |
99
- | `account` | yes | The GitKraken account and the GK-cloud connect/manage round-trips. Return `undefined` from `getAccount` if you don't use GK cloud (see below). |
100
- | `config` | yes | `getRemoteConfigs()` (self-managed hosts, SSL/protocol overrides), launchpad knobs, optional `getPullRequestReadOptions()` (`{ mergeQueue: true }` opts GitHub.com reads in to merge-queue data, unless a read says otherwise), a change event. |
101
- | `http` | yes | `fetch` + `wrapForForcedInsecureSSL` + `isWeb` + a User-Agent string. |
102
- | `cache` | no | `IntegrationManagerCacheProvider`: `getCurrentAccount` is required; the repository, pull-request and issue lookups and `deletePullRequests` are optional (see below). Omit it for correct uncached reads. |
103
- | `repositories` | yes | `getOpenRemotes()`; used only by the "across open repos" helpers. `async () => []` is fine. |
104
- | `hooks` | no | Auth strategy override, reauth/disconnect prompts, outbound behavioral events. |
96
+ | Provider | Required | What it must do |
97
+ | -------------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
98
+ | `storage` | yes | Global + workspace key/value, plus a secret store (tokens land here). |
99
+ | `account` | yes | The GitKraken account and the GK-cloud connect/manage round-trips. Return `undefined` from `getAccount` if you don't use GK cloud (see below). |
100
+ | `config` | yes | `getRemoteConfigs()` (self-managed hosts, SSL/protocol overrides), launchpad knobs, optional `getPullRequestReadOptions()` (`{ mergeQueue: true }` opts GitHub.com reads in to merge-queue data, unless a read says otherwise; `stackMergedLayers: true` to `stack.mergedLayers`), a change event. |
101
+ | `http` | yes | `fetch` + `wrapForForcedInsecureSSL` + `isWeb` + a User-Agent string. |
102
+ | `cache` | no | `IntegrationManagerCacheProvider`: `getCurrentAccount` is required; the repository, pull-request and issue lookups and `deletePullRequests` are optional (see below). Omit it for correct uncached reads. |
103
+ | `repositories` | yes | `getOpenRemotes()`; used only by the "across open repos" helpers. `async () => []` is fine. |
104
+ | `hooks` | no | Auth strategy override, reauth/disconnect prompts, outbound behavioral events. |
105
105
 
106
106
  A complete, type-checked, dependency-free example (including the optional-cache path) lives in
107
107
  [`tests/fixtures/integrations-consumer/src/consumer.test.ts`](https://github.com/gitkraken/vscode-gitlens/blob/core/tests/fixtures/integrations-consumer/src/consumer.test.ts).
@@ -1009,6 +1009,83 @@ as other operations. Failures with `mutationDispatched: false` stopped before se
1009
1009
  the write. An `applied: 'maybe'` failure requires reconciliation before another attempt.
1010
1010
  A `not-found` response can also mean GitLab hid a resource from the selected account.
1011
1011
 
1012
+ ### GitLab.com merge request writes
1013
+
1014
+ Use the same scope as GitLab.com issue writes. `project` and `projectId` always name the
1015
+ target project. A merge request is addressed by the target project, its project-local `iid`
1016
+ and its global `id`, all decimal strings. Writes may also pass `expectedProjectPath`, and
1017
+ a moved or renamed project then reports `conflict`.
1018
+
1019
+ | Method | Additional input and result |
1020
+ | -------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1021
+ | `getGitLabMergeRequestCreateOptions` | Pass `project` and, for a fork, `sourceProject`. Returns both canonical projects, the target's `defaultBranch`, creation fields, draft support and `createCapability`. |
1022
+ | `getGitLabMergeRequestWriteOptions` | Pass `project`, `iid`, and the optional `expectedMergeRequestId`. Returns the merge request, editable fields, and capabilities for edit, close, reopen, delete and merge. An open merge request carries the live `targetSha`. |
1023
+ | `resolveGitLabMergeRequestWriteTarget` | Pass the same address. `intent: 'delete'` checks permission before confirmation. `intent: 'merge'` also returns `merge`: the execution, merge method, squash state and source branch removal a merge would apply. |
1024
+ | `writeGitLabMergeRequest` | Pass the canonical `projectId` and `expectedAccountId`. `action: 'create'` takes `sourceBranch`, `targetBranch`, `title`, and optional `description`, `sourceProjectId` and `draft`. Edit, close, reopen and merge take `iid` and `expectedMergeRequestId`. The result `status` names what GitLab acknowledged. |
1025
+ | `deleteGitLabMergeRequest` | After caller confirmation, pass `projectId`, `expectedAccountId`, `iid`, and `expectedMergeRequestId`. GitLab lets project owners delete merge requests. Returns the pre-delete snapshot with `status: 'deleted'`. |
1026
+
1027
+ A create is posted to the source project and names the target, verifies that both branches
1028
+ exist, and reports `conflict` with the open merge request GitLab already has between the
1029
+ two branches. Core looks for it among the first 100 open merge requests with those branch
1030
+ names; past that, GitLab's own refusal still reports `conflict`, without the merge request.
1031
+ GitLab enforces that uniqueness, so a create that ended with `applied: 'maybe'` can be
1032
+ checked by reading again. GitLab marks a draft by its title: `draft: true` adds the
1033
+ `Draft:` prefix, a title edit keeps the merge request's current draft state, and a title
1034
+ that would change it is refused as `invalid-input`.
1035
+
1036
+ A title or description edit sends the `lock_version` GitLab reported with the merge request
1037
+ (GitLab 19.7 and later). An edit that raced another title, description or draft change
1038
+ reports `conflict`, and Core does not send it again. A response without `lock_version` is
1039
+ edited without that fence.
1040
+
1041
+ A delete may pass `expectedState`, and a merge request in another state reports `conflict`.
1042
+ Core deletes conditionally on the `updated_at` it read. Anything GitLab records on the
1043
+ merge request after that read, such as a reopen, an edit or a comment, reports `conflict`
1044
+ and deletes nothing. GitLab reports `updated_at` to the millisecond, so the fence cannot
1045
+ tell apart an update recorded in the same millisecond as the one Core read; past that,
1046
+ GitLab's own check at delete time is the last one. Core does not delete a merge request
1047
+ whose `updated_at` it could not read as a timestamp with at least millisecond precision.
1048
+
1049
+ A merge pins everything the caller approved: `expectedExecution`, `expectedMergeMethod`,
1050
+ `expectedRemovesSourceBranch`, `expectedSourceProjectId`, both branch names,
1051
+ `expectedSourceSha`, `expectedTargetSha` and `squash`. The project owns the merge method,
1052
+ and Core never chooses another. GitLab compares the source commit atomically. Core reads
1053
+ the target branch and its tip immediately before dispatch, and GitLab offers no atomic
1054
+ guard for them. The capability's `squash` says what the merge may pass: `required` takes
1055
+ `squash: true`, `unavailable` takes `false`, and `optional` takes either. A merge request
1056
+ already set to squash is `required`, because GitLab's merge endpoints cannot turn squashing
1057
+ off. A drifted source or target reports `source-changed` or `target-changed`, and any other
1058
+ drift reports `conflict`. `removesSourceBranch` is what the merge asks for: GitLab may keep
1059
+ a protected source branch, or one the merging user cannot delete.
1060
+
1061
+ Core reports `merged` only when GitLab's receipt still names the approved source project,
1062
+ both branches and the source commit. A merge it cannot tie to them, including one it
1063
+ observes after GitLab answered `422`, is `applied: 'maybe'`.
1064
+
1065
+ `execution: 'merge'` merges directly and returns `status: 'merged'`. On a project with
1066
+ merge trains, `execution` is `'train'`: Core adds the merge request to the train without
1067
+ auto-merge and returns `status: 'queued'` while the merge request stays open. Core never
1068
+ merges around a train, never schedules auto-merge, and never falls back from one execution
1069
+ to the other. A merge request that is already set to auto-merge, or that cannot join its
1070
+ train yet, reports merge as unavailable. A train answers the same `409` for a source commit
1071
+ that moved and for auto-merge enabled meanwhile, so a refused enqueue reports `conflict`.
1072
+ Core reports `queued` only when the train entry GitLab answers with, or the merge request's
1073
+ own train status when that page does not hold it, names this open merge request on the
1074
+ approved target branch. Anything else is `applied: 'maybe'`, and Core does not enqueue again.
1075
+
1076
+ An unavailable or refused merge reports `policy-blocked` with a `blocker` (`conflicts`,
1077
+ `pipeline`, `approvals`, `discussions`, `draft`, `rebase`, `status-checks`, `checking`,
1078
+ `merge-train`, `auto-merge` or `other`) and GitLab's `mergeStatus`. `checking` means
1079
+ GitLab is still computing mergeability, so read again. The other failure rules of
1080
+ GitLab.com issue writes apply.
1081
+
1082
+ What GitLab says about a rejected issue or merge request write is bounded before it reaches
1083
+ the caller. `fieldErrors` from GitLab name only `title` and `description`, and `messages`
1084
+ holds at most three entries. Each text is cut to 300 characters, loses control and format
1085
+ characters, has the connection's token and other credentials replaced with `[redacted]`,
1086
+ and is dropped when it carries markup. `mergeStatus` is present only when it is a GitLab
1087
+ status identifier.
1088
+
1012
1089
  ### Jira Cloud and Data Center issue writes
1013
1090
 
1014
1091
  Use the tracker methods on `IntegrationManager` from `@gitkraken/core-gitlens/plus/integrations/index.js`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gitkraken/core-gitlens",
3
3
  "description": "GitLens core — shared Git / AI / GitHub primitives for internal GitKraken consumption",
4
- "version": "0.62.0",
4
+ "version": "0.64.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",
@@ -1,11 +0,0 @@
1
- import { GitLabIssueWriteFailure } from "../../models/gitlabIssueWrites.js";
2
- //#region ../plus/integrations/src/providers/gitlab/issueWriteErrors.d.ts
3
- export declare function gitLabIssueWriteFailure(reason: GitLabIssueWriteFailure['reason'], fieldErrors?: GitLabIssueWriteFailure['fieldErrors']): GitLabIssueWriteFailure;
4
- export declare class GitLabIssueWriteError extends Error {
5
- readonly reason: GitLabIssueWriteFailure['reason'];
6
- constructor(reason: GitLabIssueWriteFailure['reason']);
7
- }
8
- export declare function toGitLabIssuePreflightFailure(ex: unknown): GitLabIssueWriteFailure;
9
- export declare function toGitLabIssueHttpFailure(response: Response, dispatched: boolean): Promise<GitLabIssueWriteFailure>;
10
- //#endregion
11
- //# sourceMappingURL=issueWriteErrors.d.ts.map
@@ -1,73 +0,0 @@
1
- import { RequestRateLimitError } from "../../../../git/errors.js";
2
- import { isRateLimitResponse } from "../../errors.js";
3
- import { getProviderResponseBodyMessage } from "../providerErrors.js";
4
- //#region ../plus/integrations/src/providers/gitlab/issueWriteErrors.ts
5
- function gitLabIssueWriteFailure(reason, fieldErrors) {
6
- return {
7
- ok: false,
8
- reason,
9
- mutationDispatched: false,
10
- ...fieldErrors && { fieldErrors }
11
- };
12
- }
13
- var GitLabIssueWriteError = class extends Error {
14
- reason;
15
- constructor(reason) {
16
- super(reason);
17
- this.reason = reason;
18
- }
19
- };
20
- function toGitLabIssuePreflightFailure(ex) {
21
- if (ex instanceof GitLabIssueWriteError) return gitLabIssueWriteFailure(ex.reason);
22
- return gitLabIssueWriteFailure(RequestRateLimitError.is(ex) ? "rate-limit" : "unknown");
23
- }
24
- async function toGitLabIssueHttpFailure(response, dispatched) {
25
- const body = await response.json().catch(() => void 0);
26
- const message = getProviderResponseBodyMessage(body);
27
- const status = response.status;
28
- let reason = "unknown";
29
- if (status === 409 && body?.needs_captcha_response === true) reason = "provider-policy";
30
- else if (status === 401 || status === 403) {
31
- const challenge = response.headers.get("www-authenticate");
32
- if (body?.error === "insufficient_scope" || /\binsufficient_scope\b/i.test(challenge ?? "")) reason = "insufficient-scope";
33
- else if (status === 403 && isRateLimitResponse({
34
- status,
35
- message
36
- })) reason = "rate-limit";
37
- else reason = status === 401 ? "no-connection" : "forbidden";
38
- } else if (status === 400 || status === 413 || status === 422) reason = "invalid-input";
39
- else if (status === 404 || status === 410) reason = "not-found";
40
- else if (status === 409 || status === 412) reason = "conflict";
41
- else if (status === 429) reason = "rate-limit";
42
- const failure = {
43
- ok: false,
44
- reason
45
- };
46
- if (!dispatched) failure.mutationDispatched = false;
47
- else if (reason === "unknown") failure.applied = "maybe";
48
- if (reason === "invalid-input") {
49
- const fieldErrors = readFieldErrors(body?.message);
50
- if (Object.keys(fieldErrors).length !== 0) failure.fieldErrors = fieldErrors;
51
- if (typeof body?.message === "string") failure.messages = [body.message];
52
- else if (body?.message != null && typeof body.message === "object") {
53
- const details = body.message;
54
- const messages = [details.base, details.error].flat().filter((value) => typeof value === "string");
55
- if (messages.length !== 0) failure.messages = messages;
56
- }
57
- }
58
- return failure;
59
- }
60
- function readFieldErrors(value) {
61
- const fields = {};
62
- if (typeof value !== "object" || value == null) return fields;
63
- for (const field of ["title", "description"]) {
64
- const message = value[field];
65
- if (typeof message === "string") fields[field] = message;
66
- else if (Array.isArray(message) && message.every((s) => typeof s === "string")) fields[field] = message.join(" ");
67
- }
68
- return fields;
69
- }
70
- //#endregion
71
- export { GitLabIssueWriteError, gitLabIssueWriteFailure, toGitLabIssueHttpFailure, toGitLabIssuePreflightFailure };
72
-
73
- //# sourceMappingURL=issueWriteErrors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"issueWriteErrors.js","names":[],"sources":["../../../../../../plus/integrations/src/providers/gitlab/issueWriteErrors.ts"],"sourcesContent":["import { isRateLimitResponse, RequestRateLimitError } from '../../errors.js';\nimport type { GitLabIssueWriteFailure } from '../../models/gitlabIssueWrites.js';\nimport { getProviderResponseBodyMessage } from '../providerErrors.js';\n\nexport function gitLabIssueWriteFailure(\n\treason: GitLabIssueWriteFailure['reason'],\n\tfieldErrors?: GitLabIssueWriteFailure['fieldErrors'],\n): GitLabIssueWriteFailure {\n\treturn { ok: false, reason: reason, mutationDispatched: false, ...(fieldErrors && { fieldErrors: fieldErrors }) };\n}\n\nexport class GitLabIssueWriteError extends Error {\n\tconstructor(readonly reason: GitLabIssueWriteFailure['reason']) {\n\t\tsuper(reason);\n\t}\n}\n\nexport function toGitLabIssuePreflightFailure(ex: unknown): GitLabIssueWriteFailure {\n\tif (ex instanceof GitLabIssueWriteError) return gitLabIssueWriteFailure(ex.reason);\n\treturn gitLabIssueWriteFailure(RequestRateLimitError.is(ex) ? 'rate-limit' : 'unknown');\n}\n\nexport async function toGitLabIssueHttpFailure(\n\tresponse: Response,\n\tdispatched: boolean,\n): Promise<GitLabIssueWriteFailure> {\n\tconst body = (await response.json().catch(() => undefined)) as\n\t\t| { message?: unknown; error?: unknown; needs_captcha_response?: boolean }\n\t\t| undefined;\n\tconst message = getProviderResponseBodyMessage(body);\n\tconst status = response.status;\n\tlet reason: GitLabIssueWriteFailure['reason'] = 'unknown';\n\n\tif (status === 409 && body?.needs_captcha_response === true) {\n\t\treason = 'provider-policy';\n\t} else if (status === 401 || status === 403) {\n\t\tconst challenge = response.headers.get('www-authenticate');\n\t\tif (body?.error === 'insufficient_scope' || /\\binsufficient_scope\\b/i.test(challenge ?? '')) {\n\t\t\treason = 'insufficient-scope';\n\t\t} else if (status === 403 && isRateLimitResponse({ status: status, message: message })) {\n\t\t\treason = 'rate-limit';\n\t\t} else {\n\t\t\treason = status === 401 ? 'no-connection' : 'forbidden';\n\t\t}\n\t} else if (status === 400 || status === 413 || status === 422) {\n\t\treason = 'invalid-input';\n\t} else if (status === 404 || status === 410) {\n\t\treason = 'not-found';\n\t} else if (status === 409 || status === 412) {\n\t\treason = 'conflict';\n\t} else if (status === 429) {\n\t\treason = 'rate-limit';\n\t}\n\n\tconst failure: GitLabIssueWriteFailure = { ok: false, reason: reason };\n\tif (!dispatched) {\n\t\tfailure.mutationDispatched = false;\n\t} else if (reason === 'unknown') {\n\t\tfailure.applied = 'maybe';\n\t}\n\n\tif (reason === 'invalid-input') {\n\t\tconst fieldErrors = readFieldErrors(body?.message);\n\t\tif (Object.keys(fieldErrors).length !== 0) {\n\t\t\tfailure.fieldErrors = fieldErrors;\n\t\t}\n\t\tif (typeof body?.message === 'string') {\n\t\t\tfailure.messages = [body.message];\n\t\t} else if (body?.message != null && typeof body.message === 'object') {\n\t\t\tconst details = body.message as { base?: unknown; error?: unknown };\n\t\t\tconst messages = [details.base, details.error]\n\t\t\t\t.flat()\n\t\t\t\t.filter((value): value is string => typeof value === 'string');\n\t\t\tif (messages.length !== 0) {\n\t\t\t\tfailure.messages = messages;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn failure;\n}\n\nfunction readFieldErrors(value: unknown): Record<string, string> {\n\tconst fields: Record<string, string> = {};\n\tif (typeof value !== 'object' || value == null) return fields;\n\n\tfor (const field of ['title', 'description'] as const) {\n\t\tconst message = (value as Record<string, unknown>)[field];\n\t\tif (typeof message === 'string') {\n\t\t\tfields[field] = message;\n\t\t} else if (Array.isArray(message) && message.every(s => typeof s === 'string')) {\n\t\t\tfields[field] = message.join(' ');\n\t\t}\n\t}\n\n\treturn fields;\n}\n"],"mappings":";;;;AAIA,SAAgB,wBACf,QACA,aAC0B;CAC1B,OAAO;EAAE,IAAI;EAAe;EAAQ,oBAAoB;EAAO,GAAI,eAAe,EAAe,YAAY;CAAG;AACjH;AAEA,IAAa,wBAAb,cAA2C,MAAM;CAC3B;CAArB,YAAY,QAAoD;EAC/D,MAAM,MAAM;EADQ,KAAA,SAAA;CAErB;AACD;AAEA,SAAgB,8BAA8B,IAAsC;CACnF,IAAI,cAAc,uBAAuB,OAAO,wBAAwB,GAAG,MAAM;CACjF,OAAO,wBAAwB,sBAAsB,GAAG,EAAE,IAAI,eAAe,SAAS;AACvF;AAEA,eAAsB,yBACrB,UACA,YACmC;CACnC,MAAM,OAAQ,MAAM,SAAS,KAAK,CAAC,CAAC,YAAY,KAAA,CAAS;CAGzD,MAAM,UAAU,+BAA+B,IAAI;CACnD,MAAM,SAAS,SAAS;CACxB,IAAI,SAA4C;CAEhD,IAAI,WAAW,OAAO,MAAM,2BAA2B,MACtD,SAAS;MACH,IAAI,WAAW,OAAO,WAAW,KAAK;EAC5C,MAAM,YAAY,SAAS,QA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