@gitkraken/core-gitlens 0.62.0 → 0.63.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 (67) hide show
  1. package/CHANGELOG.md +15 -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 +15 -5
  39. package/dist/git-cli/providers/config.js.map +1 -1
  40. package/dist/git-cli/providers/pausedOperations.js +2 -2
  41. package/dist/git-cli/providers/pausedOperations.js.map +1 -1
  42. package/dist/git-cli/providers/staging.d.ts +8 -8
  43. package/dist/git-cli/providers/staging.js +120 -25
  44. package/dist/git-cli/providers/staging.js.map +1 -1
  45. package/dist/ipc/discovery.js +1 -1
  46. package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
  47. package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
  48. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
  49. package/dist/plus/git-github/api/config.d.ts +5 -0
  50. package/dist/plus/git-github/api/config.js.map +1 -1
  51. package/dist/plus/git-github/api/github.js +24 -4
  52. package/dist/plus/git-github/api/github.js.map +1 -1
  53. package/dist/plus/git-github/models.d.ts +12 -0
  54. package/dist/plus/git-github/models.js +8 -3
  55. package/dist/plus/git-github/models.js.map +1 -1
  56. package/dist/plus/integrations/context.d.ts +5 -0
  57. package/dist/plus/integrations/providers/azure/azure.js +1 -1
  58. package/dist/plus/integrations/providers/github.js +7 -3
  59. package/dist/plus/integrations/providers/github.js.map +1 -1
  60. package/dist/plus/integrations/reads/etag.d.ts +5 -0
  61. package/dist/plus/integrations/reads/etag.js +2 -0
  62. package/dist/plus/integrations/reads/etag.js.map +1 -1
  63. package/dist/utils/env/node/exec.d.ts +2 -0
  64. package/dist/utils/env/node/exec.js +4 -2
  65. package/dist/utils/env/node/exec.js.map +1 -1
  66. package/docs/integrations.md +9 -9
  67. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"etag.js","names":[],"sources":["../../../../../plus/integrations/src/reads/etag.ts"],"sourcesContent":["import type { IssueShape, IssueSyncedWith } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequestState } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestCheckRun,\n\tPullRequestMergeableState,\n\tPullRequestMergeQueueEntry,\n\tPullRequestReviewDecision,\n\tPullRequestReviewState,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStatusCheckRollupState,\n} from '@gitlens/git/models/pullRequest.js';\nimport { fnv1aHash64 } from '@gitlens/utils/hash.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n} from '../constants.js';\nimport { getIssueFieldPresence } from '../fieldPresence.js';\nimport { issueNamesPeople } from '../providers/models.js';\n\n/**\n * The etags the batch reads hand back (`getPullRequestsBatch`, `getIssuesBatch`): an opaque stamp of an item's\n * change state, which a caller sends back so a cheap check can answer \"unchanged\" without a full read.\n *\n * Computed by core, never the provider's HTTP ETag, and from the fields alone — not the item's id, since the\n * caller's key already identifies the target and ids cross vocabularies between reads. Not hashed: the stamp IS\n * the serialized fields, so two different change states can never collide into a false `unchanged` — except for two\n * 64-bit hashes, where a collision (about 2^-64) is the only way a change can hide: an Azure DevOps pull request's\n * `revision`, of the fields Azure changes without a timestamp, and a GitHub pull request's `checkRuns`, of its head's\n * checks, which keeps the stamp the same length at any number of checks. The prefix names the scheme (`pr1`, `is1`)\n * and every include it covers ({@link PullRequestEtagInclude}, {@link IssueEtagInclude}), in canonical order\n * (`pr1+mergeable+checks:`, `is1+reactions:`), so two different sets can never collide even when their values do (a\n * `null` mergeability and a `null` rollup). A stamp from another scheme or another set just compares unequal and\n * costs a full read.\n */\n\n/**\n * An input a pull request's etag can be widened to, each of which a host changes without moving `updatedAt`. Every\n * entry costs its own fields in the cheap check, so a caller picks only the ones it needs. `'checks'` is the check\n * rollup.\n */\nexport type PullRequestEtagInclude = 'mergeable' | 'reviewDecision' | 'checks';\n\n/** Every {@link PullRequestEtagInclude}, in the canonical order an etag lists them in. */\nexport const pullRequestEtagIncludes: readonly PullRequestEtagInclude[] = ['mergeable', 'reviewDecision', 'checks'];\n\n/**\n * The change state a batch read's etag is computed from ({@link pullRequestEtag}), in the NORMALIZED vocabulary of\n * `PullRequestShape` — the values a full row carries after its provider's whole conversion chain, so a cheap\n * check and a full read of the same pull request yield the same fields. Each of `mergeableState`, `reviewDecision`\n * and `statusCheckRollupState` counts only when its {@link PullRequestEtagInclude} is requested.\n */\nexport interface PullRequestEtagFields {\n\tstate: PullRequestState;\n\tisDraft?: boolean;\n\tupdatedDate: Date;\n\theadSha?: string;\n\tmergeableState?: PullRequestMergeableState;\n\treviewDecision?: PullRequestReviewDecision;\n\tstatusCheckRollupState?: PullRequestStatusCheckRollupState;\n\t/**\n\t * A fingerprint of the fields a host changes without moving an update time ({@link pullRequestRevision}); set\n\t * only for hosts that keep none (Azure DevOps and Server). Part of the etag whenever it is set, not an include.\n\t */\n\trevision?: string;\n\t/**\n\t * A full row marked `viewerUnresolved`, which no cheap check ever sets: such a row never compares unchanged, so it\n\t * is read in full again rather than kept without a viewer until the pull request changes.\n\t */\n\tviewerUnresolved?: true;\n\t/**\n\t * The pull request's merge-queue entry, as far as the etag reads it: whether it's queued, in which state and since\n\t * when, none of which moves `updatedDate`. Part of the etag whenever it is set, not an include, and set only on a\n\t * queued pull request, so every other pull request's etag is unchanged by it. Read only where the queue is\n\t * (github.com).\n\t */\n\tmergeQueue?: Pick<PullRequestMergeQueueEntry, 'state' | 'enqueuedAt'>;\n\t/**\n\t * When the pull request's `mergeQueueRemoval` happened, set only while it has one. Like `mergeQueue`, part of the\n\t * etag whenever it is set, not an include: a pull request that joins its queue and is removed between two checks\n\t * moves neither its update time nor, at either check, `mergeQueue`.\n\t */\n\tmergeQueueRemovedAt?: Date;\n\t/**\n\t * The read selected merge-queue data (GitHub.com, for a read that asks for it or a host that opts in), whatever\n\t * that data says. Part of the etag whenever it is set, as a marker: without it a pull request that isn't queued and\n\t * has no removal computes the etag it has without the data, so a host that starts asking for the data would keep a\n\t * held row lacking it as `unchanged`. A full row sets it from its `mergeQueueRequired`, which only a read that\n\t * selected the data carries; a cheap check sets it from the same selection.\n\t */\n\tmergeQueueRead?: true;\n\t/**\n\t * The head's checks, from {@link pullRequestCheckRunsEtag}, set whenever the read selected check runs (a count of 0\n\t * when the head has none), so it also marks such a read, as {@link mergeQueueRead} does.\n\t */\n\tcheckRuns?: PullRequestCheckRunsEtag;\n}\n\n/** A head's checks, as a pull request's etag reads them. */\nexport interface PullRequestCheckRunsEtag {\n\t/** A 64-bit hash of each check's id, kind, name, status and conclusion, in id order. */\n\treadonly hash: string;\n\treadonly count: number;\n\t/** The head has checks the read lacks (the row's `checkRunsTruncated`). */\n\treadonly truncated: boolean;\n}\n\n/**\n * {@link PullRequestEtagFields.checkRuns}, which the cheap check and the full read build alike from the same fields.\n * Hashed to keep the etag short at any number of checks, so a collision is the only way a change can hide, at about\n * 2^-64.\n */\nexport function pullRequestCheckRunsEtag(\n\truns: readonly Pick<PullRequestCheckRun, 'id' | 'kind' | 'name' | 'status' | 'conclusion'>[],\n\ttruncated: boolean,\n): PullRequestCheckRunsEtag {\n\tconst entries = runs\n\t\t.map(run => [run.id, run.kind, run.name, run.status, run.conclusion ?? null] as const)\n\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n\treturn { hash: fnv1aHash64(JSON.stringify(entries)), count: entries.length, truncated: truncated };\n}\n\n/**\n * The fields of a pull request {@link pullRequestRevision} reads, as a full row carries them. A `PullRequestShape`\n * is one, so a full read passes its row as is and a cheap check builds one from the same mapped values.\n */\nexport interface PullRequestRevisionSource {\n\treadonly title: string;\n\treadonly body?: string;\n\treadonly refs?: { readonly base: { readonly branch: string } };\n\treadonly reviewRequests?: readonly PullRequestRevisionReviewer[];\n\treadonly latestReviews?: readonly PullRequestRevisionReviewer[];\n}\n\ninterface PullRequestRevisionReviewer {\n\treadonly reviewer: { readonly id: string };\n\treadonly state: PullRequestReviewState;\n}\n\n/**\n * {@link PullRequestEtagFields.revision}: a 64-bit hash of a pull request's title, description, target branch and\n * reviewers (each one's id and review state, in a canonical order). Hashed to keep the etag short, so a collision is\n * the only way a change can hide, at about 2^-64.\n */\nexport function pullRequestRevision(pr: PullRequestRevisionSource): string {\n\treturn fnv1aHash64(\n\t\tJSON.stringify([\n\t\t\tpr.title,\n\t\t\tpr.body ?? null,\n\t\t\tpr.refs?.base.branch ?? null,\n\t\t\ttoRevisionReviewers(pr.reviewRequests),\n\t\t\ttoRevisionReviewers(pr.latestReviews),\n\t\t]),\n\t);\n}\n\n/** Each reviewer as its serialized `[id, state]`, sorted, so the host's order never moves the revision. */\nfunction toRevisionReviewers(reviewers: readonly PullRequestRevisionReviewer[] | undefined): string[] | null {\n\treturn reviewers?.map(r => JSON.stringify([r.reviewer.id, r.state])).sort() ?? null;\n}\n\n/**\n * An input an issue's etag can be widened to, which a host changes without moving `updatedAt`. `'reactions'` is the\n * thumbs-up count, and widens the etag only on hosts whose rows really fetch one (GitHub/GHE and GitLab).\n */\nexport type IssueEtagInclude = 'reactions';\n\n/** Every {@link IssueEtagInclude}, in the canonical order an etag lists them in. */\nexport const issueEtagIncludes: readonly IssueEtagInclude[] = ['reactions'];\n\n/** The issue twin of {@link PullRequestEtagFields}, in {@link IssueShape}'s normalized vocabulary. */\nexport interface IssueEtagFields {\n\tstate: IssueOrPullRequestState | undefined;\n\tupdatedDate: Date;\n\t/** Counts only when `'reactions'` is requested, and only from a row whose read fetched reactions. */\n\tthumbsUpCount?: number;\n\t/**\n\t * Azure DevOps only: the version of the rule a work item's body is read by ({@link azureWorkItemDescriptionRule}).\n\t * A change of rule changes the body without moving `updatedDate`, so a row read under an earlier one must not\n\t * compare unchanged.\n\t */\n\tdescriptionRule?: number;\n\t/**\n\t * Azure DevOps only: the version of the rule a work item's `viewer` is set by ({@link azureWorkItemViewerRule}).\n\t * A full row that names someone but got no viewer (its organization's identity couldn't be read) leaves it out, so\n\t * it never compares unchanged and is read in full again rather than kept without one.\n\t */\n\tviewerRule?: number;\n\t/**\n\t * Linear only: the row's `syncedWith` links as {@link linearSyncedWithEtagKeys} spells them, so a link added, removed\n\t * or moved to other coordinates changes the etag whether or not the issue's update time moves. `null` on a\n\t * full row without `syncedWith` (held from before it existed, or read while Linear failed to resolve it), which\n\t * never compares unchanged with a cheap check's list.\n\t */\n\tsyncedWithKeys?: readonly string[] | null;\n}\n\n/**\n * {@link IssueEtagFields.descriptionRule}: the version of the rule an Azure DevOps work item's body is read by, stamped\n * on both sides of its etag. Bumped whenever the rule changes which field a work item's body comes from, so every row\n * a caller holds from before is read in full once. 1: the first rich text field with content (provider-apis'\n * `getAzureWorkItemDescription`), where it used to be only Description. The rule lives in provider-apis, so a bump of\n * that package that changes it must bump this too; the etag tests pin the rule to catch one.\n *\n * It can't cover a row whose read found the organization's field catalog unavailable: that row's body falls back to\n * the built-in fields, and a cheap check, which reads no body, can't tell it from a complete one, so it stays as read\n * until the work item changes.\n */\nexport const azureWorkItemDescriptionRule = 1;\n\n/**\n * {@link IssueEtagFields.viewerRule}: the version of the rule an Azure DevOps work item's `viewer` is set by, stamped\n * on both sides of its etag, so every row a caller holds from before it was set is read in full once. 1: the user's\n * identity in the work item's organization (gitkraken/kepler#4291).\n */\nexport const azureWorkItemViewerRule = 1;\n\n/**\n * A Linear row's sync links in its etag, sorted: each as its GitHub id and, when known, the coordinates a host matches\n * the GitHub row by, so a link whose coordinates Linear fills in or changes later compares changed.\n */\nexport function linearSyncedWithEtagKeys(links: readonly IssueSyncedWith[]): string[] {\n\treturn links\n\t\t.map(link => (link.owner != null ? `${link.id}:${link.owner}/${link.repo}#${link.number}` : `${link.id}:`))\n\t\t.sort();\n}\n\n/**\n * Azure DevOps: a pull request there keeps no update time, so its etag adds a {@link pullRequestRevision}, and a work\n * item's etag adds the rule its body is read by (see `azureWorkItemDescriptionRule`).\n */\nconst azureProviderIds: ReadonlySet<string> = new Set([\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n]);\n\nexport function pullRequestEtagFieldsFromShape(pr: PullRequestShape): PullRequestEtagFields {\n\tconst fields: PullRequestEtagFields = {\n\t\tstate: pr.state,\n\t\tisDraft: pr.isDraft,\n\t\tupdatedDate: pr.updatedDate,\n\t\theadSha: pr.refs?.head.sha,\n\t\tmergeableState: pr.mergeableState,\n\t\treviewDecision: pr.reviewDecision,\n\t\t// On the class, not the shape: every provider's mapper builds a `PullRequest`. Read by name rather than by\n\t\t// `instanceof`, which a second copy of the model module fails, silently dropping the rollup from every full\n\t\t// row's etag so that no cheap check ever matches it again.\n\t\tstatusCheckRollupState: 'statusCheckRollupState' in pr ? (pr as PullRequest).statusCheckRollupState : undefined,\n\t};\n\t// Read defensively, as `timeOf` reads the date: a row without a provider must not fail the read.\n\tif (pr.provider != null && azureProviderIds.has(pr.provider.id)) {\n\t\tfields.revision = pullRequestRevision(pr);\n\t}\n\tif (pr.viewerUnresolved) {\n\t\tfields.viewerUnresolved = true;\n\t}\n\tif (pr.mergeQueue != null) {\n\t\tfields.mergeQueue = { state: pr.mergeQueue.state, enqueuedAt: pr.mergeQueue.enqueuedAt };\n\t}\n\tif (pr.mergeQueueRemoval != null) {\n\t\tfields.mergeQueueRemovedAt = pr.mergeQueueRemoval.removedAt;\n\t}\n\t// `mergeQueueRequired` is GitHub's non-null `isMergeQueueEnabled`, so only a row from a read that selected the\n\t// merge-queue data has it.\n\tif (pr.mergeQueueRequired != null) {\n\t\tfields.mergeQueueRead = true;\n\t}\n\tif (pr.checkRuns != null) {\n\t\tfields.checkRuns = pullRequestCheckRunsEtag(pr.checkRuns, pr.checkRunsTruncated === true);\n\t}\n\treturn fields;\n}\n\nexport function issueEtagFieldsFromShape(issue: IssueShape): IssueEtagFields {\n\tconst fields: IssueEtagFields = { state: issue.state, updatedDate: issue.updatedDate };\n\t// Only where the row's read really fetched reactions: elsewhere a count is a placeholder or a tracker's votes,\n\t// which no cheap check reads, so taking it would fail every check of that row under `'reactions'`.\n\tif (\n\t\tissue.thumbsUpCount != null &&\n\t\tissue.provider != null &&\n\t\tgetIssueFieldPresence(issue)?.reactions === 'fetched'\n\t) {\n\t\tfields.thumbsUpCount = issue.thumbsUpCount;\n\t}\n\tif (issue.provider != null && azureProviderIds.has(issue.provider.id)) {\n\t\tfields.descriptionRule = azureWorkItemDescriptionRule;\n\t\t// A row read while its organization's identity couldn't be must not compare unchanged, or it would be kept\n\t\t// without a viewer until the work item changes. Also a row that names someone and has neither field: one held\n\t\t// from before `viewerUnresolved` existed.\n\t\tif (!issue.viewerUnresolved && (issue.viewer != null || !issueNamesPeople(issue))) {\n\t\t\tfields.viewerRule = azureWorkItemViewerRule;\n\t\t}\n\t}\n\tif (issue.provider?.id === IssuesCloudHostIntegrationId.Linear) {\n\t\tfields.syncedWithKeys = issue.syncedWith != null ? linearSyncedWithEtagKeys(issue.syncedWith) : null;\n\t}\n\treturn fields;\n}\n\n/**\n * The distinct `includes` in canonical order, whatever order and repetition the caller gave. Values it doesn't know\n * are dropped, so a caller validates them first (see {@link findInvalidPullRequestEtagInclude}).\n */\nexport function normalizePullRequestEtagIncludes(\n\tincludes: readonly PullRequestEtagInclude[],\n): readonly PullRequestEtagInclude[] {\n\treturn pullRequestEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't a {@link PullRequestEtagInclude}, if any. */\nexport function findInvalidPullRequestEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(pullRequestEtagIncludes as readonly string[]).includes(include));\n}\n\n/**\n * Each of `includes` adds one input — mergeability, review decision or check rollup — which a host may change\n * without moving `updatedDate`. An input that isn't listed is left out, so its churn never forces a full read.\n */\nexport function pullRequestEtag(fields: PullRequestEtagFields, includes: readonly PullRequestEtagInclude[]): string {\n\tconst covered = normalizePullRequestEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, fields.isDraft ?? null, timeOf(fields.updatedDate), fields.headSha ?? null];\n\t// Only where it is set, so every other host's etag stays exactly what it was.\n\tif (fields.revision != null) {\n\t\tstate.push(fields.revision);\n\t}\n\tif (fields.viewerUnresolved) {\n\t\tstate.push('viewer-unresolved');\n\t}\n\t// Only while queued, so a pull request outside any queue keeps exactly the etag it always had, and joining,\n\t// moving through or leaving the queue (none of which moves the update time) still reads as a change. Tagged, so\n\t// it can never read as another input.\n\tif (fields.mergeQueue != null) {\n\t\tstate.push(['merge-queue', fields.mergeQueue.state, timeOf(fields.mergeQueue.enqueuedAt)]);\n\t}\n\t// Likewise only while the pull request's latest merge-queue event is a removal, so a pull request removed between\n\t// two checks, which neither moves its update time nor shows a queue entry at either check, still reads as a change.\n\tif (fields.mergeQueueRemovedAt != null) {\n\t\tstate.push(['merge-queue-removed', timeOf(fields.mergeQueueRemovedAt)]);\n\t}\n\t// Whenever the read selected the merge-queue data, so an etag from such a read never equals one from a read that\n\t// didn't, even for a pull request that was never queued, whose state is otherwise identical. Tagged, like the\n\t// terms above. A read that didn't select it adds nothing, so it computes the etag it did before.\n\tif (fields.mergeQueueRead) {\n\t\tstate.push(['merge-queue-read']);\n\t}\n\tif (fields.checkRuns != null) {\n\t\tconst { hash, count, truncated } = fields.checkRuns;\n\t\tstate.push(truncated ? ['check-runs', hash, count, 'truncated'] : ['check-runs', hash, count]);\n\t}\n\n\tif (covered.length === 0) return `pr1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'mergeable':\n\t\t\t\tstate.push(fields.mergeableState ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'reviewDecision':\n\t\t\t\tstate.push(fields.reviewDecision ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'checks':\n\t\t\t\tstate.push(fields.statusCheckRollupState ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `pr1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/** The issue twin of {@link normalizePullRequestEtagIncludes}; validate with {@link findInvalidIssueEtagInclude}. */\nexport function normalizeIssueEtagIncludes(includes: readonly IssueEtagInclude[]): readonly IssueEtagInclude[] {\n\treturn issueEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't an {@link IssueEtagInclude}, if any. */\nexport function findInvalidIssueEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(issueEtagIncludes as readonly string[]).includes(include));\n}\n\n/** `'reactions'` adds the thumbs-up count, which a host changes without moving `updatedDate`. */\nexport function issueEtag(fields: IssueEtagFields, includes: readonly IssueEtagInclude[]): string {\n\tconst covered = normalizeIssueEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, timeOf(fields.updatedDate)];\n\t// Only where it is set, so every other provider's etag stays exactly what it was.\n\tif (fields.descriptionRule != null) {\n\t\tstate.push(fields.descriptionRule);\n\t}\n\tif (fields.viewerRule != null) {\n\t\tstate.push(fields.viewerRule);\n\t}\n\t// Only where it is set, so every other provider's etag stays exactly what it was. An unknown list is spelled\n\t// apart from every known one, so it never compares unchanged.\n\tif (fields.syncedWithKeys !== undefined) {\n\t\tstate.push(fields.syncedWithKeys === null ? 'synced-with:unknown' : ['synced-with', ...fields.syncedWithKeys]);\n\t}\n\tif (covered.length === 0) return `is1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'reactions':\n\t\t\t\tstate.push(fields.thumbsUpCount ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `is1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/**\n * Never throws: an etag is computed for every fully read row, so a mapper that hands over a missing or unparseable\n * date must not fail the whole read. Such a row's etag just won't match a cheap check's, which always has a date,\n * so the cost is a full read, never a false `unchanged`.\n */\nfunction timeOf(date: Date): number | null {\n\tconst time = new Date(date).getTime();\n\treturn Number.isNaN(time) ? null : time;\n}\n"],"mappings":";;;;;;AA8CA,MAAa,0BAA6D;CAAC;CAAa;CAAkB;AAAQ;;;;;;AAoElH,SAAgB,yBACf,MACA,WAC2B;CA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M,QAAmB,CAAC,OAAO,OAAO,OAAO,OAAO,WAAW,CAAC;CAElE,IAAI,OAAO,mBAAmB,MAC7B,MAAM,KAAK,OAAO,eAAe;CAElC,IAAI,OAAO,cAAc,MACxB,MAAM,KAAK,OAAO,UAAU;CAI7B,IAAI,OAAO,mBAAmB,KAAA,GAC7B,MAAM,KAAK,OAAO,mBAAmB,OAAO,wBAAwB,CAAC,eAAe,GAAG,OAAO,cAAc,CAAC;CAE9G,IAAI,QAAQ,WAAW,GAAG,OAAO,OAAO,KAAK,UAAU,KAAK;CAE5D,KAAK,MAAM,WAAW,SACrB,QAAQ,SAAR;EACC,KAAK,aACJ,MAAM,KAAK,OAAO,iBAAiB,IAAI;CAEzC;CAGD,OAAO,OAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,KAAK,UAAU,KAAK;AACxD;;;;;;AAOA,SAAS,OAAO,MAA2B;CAC1C,MAAM,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,QAAQ;CACpC,OAAO,OAAO,MAAM,IAAI,IAAI,OAAO;AACpC"}
1
+ {"version":3,"file":"etag.js","names":[],"sources":["../../../../../plus/integrations/src/reads/etag.ts"],"sourcesContent":["import type { IssueShape, IssueSyncedWith } from '@gitlens/git/models/issue.js';\nimport type { IssueOrPullRequestState } from '@gitlens/git/models/issueOrPullRequest.js';\nimport type {\n\tPullRequest,\n\tPullRequestCheckRun,\n\tPullRequestMergeableState,\n\tPullRequestMergeQueueEntry,\n\tPullRequestReviewDecision,\n\tPullRequestReviewState,\n\tPullRequestShape,\n\tPullRequestState,\n\tPullRequestStatusCheckRollupState,\n} from '@gitlens/git/models/pullRequest.js';\nimport { fnv1aHash64 } from '@gitlens/utils/hash.js';\nimport {\n\tGitCloudHostIntegrationId,\n\tGitSelfManagedHostIntegrationId,\n\tIssuesCloudHostIntegrationId,\n} from '../constants.js';\nimport { getIssueFieldPresence } from '../fieldPresence.js';\nimport { issueNamesPeople } from '../providers/models.js';\n\n/**\n * The etags the batch reads hand back (`getPullRequestsBatch`, `getIssuesBatch`): an opaque stamp of an item's\n * change state, which a caller sends back so a cheap check can answer \"unchanged\" without a full read.\n *\n * Computed by core, never the provider's HTTP ETag, and from the fields alone — not the item's id, since the\n * caller's key already identifies the target and ids cross vocabularies between reads. Not hashed: the stamp IS\n * the serialized fields, so two different change states can never collide into a false `unchanged` — except for two\n * 64-bit hashes, where a collision (about 2^-64) is the only way a change can hide: an Azure DevOps pull request's\n * `revision`, of the fields Azure changes without a timestamp, and a GitHub pull request's `checkRuns`, of its head's\n * checks, which keeps the stamp the same length at any number of checks. The prefix names the scheme (`pr1`, `is1`)\n * and every include it covers ({@link PullRequestEtagInclude}, {@link IssueEtagInclude}), in canonical order\n * (`pr1+mergeable+checks:`, `is1+reactions:`), so two different sets can never collide even when their values do (a\n * `null` mergeability and a `null` rollup). A stamp from another scheme or another set just compares unequal and\n * costs a full read.\n */\n\n/**\n * An input a pull request's etag can be widened to, each of which a host changes without moving `updatedAt`. Every\n * entry costs its own fields in the cheap check, so a caller picks only the ones it needs. `'checks'` is the check\n * rollup.\n */\nexport type PullRequestEtagInclude = 'mergeable' | 'reviewDecision' | 'checks';\n\n/** Every {@link PullRequestEtagInclude}, in the canonical order an etag lists them in. */\nexport const pullRequestEtagIncludes: readonly PullRequestEtagInclude[] = ['mergeable', 'reviewDecision', 'checks'];\n\n/**\n * The change state a batch read's etag is computed from ({@link pullRequestEtag}), in the NORMALIZED vocabulary of\n * `PullRequestShape` — the values a full row carries after its provider's whole conversion chain, so a cheap\n * check and a full read of the same pull request yield the same fields. Each of `mergeableState`, `reviewDecision`\n * and `statusCheckRollupState` counts only when its {@link PullRequestEtagInclude} is requested.\n */\nexport interface PullRequestEtagFields {\n\tstate: PullRequestState;\n\tisDraft?: boolean;\n\tupdatedDate: Date;\n\theadSha?: string;\n\tmergeableState?: PullRequestMergeableState;\n\treviewDecision?: PullRequestReviewDecision;\n\tstatusCheckRollupState?: PullRequestStatusCheckRollupState;\n\t/**\n\t * A fingerprint of the fields a host changes without moving an update time ({@link pullRequestRevision}); set\n\t * only for hosts that keep none (Azure DevOps and Server). Part of the etag whenever it is set, not an include.\n\t */\n\trevision?: string;\n\t/**\n\t * A full row marked `viewerUnresolved`, which no cheap check ever sets: such a row never compares unchanged, so it\n\t * is read in full again rather than kept without a viewer until the pull request changes.\n\t */\n\tviewerUnresolved?: true;\n\t/**\n\t * The pull request's merge-queue entry, as far as the etag reads it: whether it's queued, in which state and since\n\t * when, none of which moves `updatedDate`. Part of the etag whenever it is set, not an include, and set only on a\n\t * queued pull request, so every other pull request's etag is unchanged by it. Read only where the queue is\n\t * (github.com).\n\t */\n\tmergeQueue?: Pick<PullRequestMergeQueueEntry, 'state' | 'enqueuedAt'>;\n\t/**\n\t * When the pull request's `mergeQueueRemoval` happened, set only while it has one. Like `mergeQueue`, part of the\n\t * etag whenever it is set, not an include: a pull request that joins its queue and is removed between two checks\n\t * moves neither its update time nor, at either check, `mergeQueue`.\n\t */\n\tmergeQueueRemovedAt?: Date;\n\t/**\n\t * The read selected merge-queue data (GitHub.com, for a read that asks for it or a host that opts in), whatever\n\t * that data says. Part of the etag whenever it is set, as a marker: without it a pull request that isn't queued and\n\t * has no removal computes the etag it has without the data, so a host that starts asking for the data would keep a\n\t * held row lacking it as `unchanged`. A full row sets it from its `mergeQueueRequired`, which only a read that\n\t * selected the data carries; a cheap check sets it from the same selection.\n\t */\n\tmergeQueueRead?: true;\n\t/**\n\t * The head's checks, from {@link pullRequestCheckRunsEtag}, set whenever the read selected check runs (a count of 0\n\t * when the head has none), so it also marks such a read, as {@link mergeQueueRead} does.\n\t */\n\tcheckRuns?: PullRequestCheckRunsEtag;\n\t/**\n\t * How many of the pull request's stack layers have merged, set only when the read selected them on a stacked pull\n\t * request. Part of the etag whenever it is set, not an include.\n\t */\n\tstackMergedLayers?: number;\n}\n\n/** A head's checks, as a pull request's etag reads them. */\nexport interface PullRequestCheckRunsEtag {\n\t/** A 64-bit hash of each check's id, kind, name, status and conclusion, in id order. */\n\treadonly hash: string;\n\treadonly count: number;\n\t/** The head has checks the read lacks (the row's `checkRunsTruncated`). */\n\treadonly truncated: boolean;\n}\n\n/**\n * {@link PullRequestEtagFields.checkRuns}, which the cheap check and the full read build alike from the same fields.\n * Hashed to keep the etag short at any number of checks, so a collision is the only way a change can hide, at about\n * 2^-64.\n */\nexport function pullRequestCheckRunsEtag(\n\truns: readonly Pick<PullRequestCheckRun, 'id' | 'kind' | 'name' | 'status' | 'conclusion'>[],\n\ttruncated: boolean,\n): PullRequestCheckRunsEtag {\n\tconst entries = runs\n\t\t.map(run => [run.id, run.kind, run.name, run.status, run.conclusion ?? null] as const)\n\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));\n\treturn { hash: fnv1aHash64(JSON.stringify(entries)), count: entries.length, truncated: truncated };\n}\n\n/**\n * The fields of a pull request {@link pullRequestRevision} reads, as a full row carries them. A `PullRequestShape`\n * is one, so a full read passes its row as is and a cheap check builds one from the same mapped values.\n */\nexport interface PullRequestRevisionSource {\n\treadonly title: string;\n\treadonly body?: string;\n\treadonly refs?: { readonly base: { readonly branch: string } };\n\treadonly reviewRequests?: readonly PullRequestRevisionReviewer[];\n\treadonly latestReviews?: readonly PullRequestRevisionReviewer[];\n}\n\ninterface PullRequestRevisionReviewer {\n\treadonly reviewer: { readonly id: string };\n\treadonly state: PullRequestReviewState;\n}\n\n/**\n * {@link PullRequestEtagFields.revision}: a 64-bit hash of a pull request's title, description, target branch and\n * reviewers (each one's id and review state, in a canonical order). Hashed to keep the etag short, so a collision is\n * the only way a change can hide, at about 2^-64.\n */\nexport function pullRequestRevision(pr: PullRequestRevisionSource): string {\n\treturn fnv1aHash64(\n\t\tJSON.stringify([\n\t\t\tpr.title,\n\t\t\tpr.body ?? null,\n\t\t\tpr.refs?.base.branch ?? null,\n\t\t\ttoRevisionReviewers(pr.reviewRequests),\n\t\t\ttoRevisionReviewers(pr.latestReviews),\n\t\t]),\n\t);\n}\n\n/** Each reviewer as its serialized `[id, state]`, sorted, so the host's order never moves the revision. */\nfunction toRevisionReviewers(reviewers: readonly PullRequestRevisionReviewer[] | undefined): string[] | null {\n\treturn reviewers?.map(r => JSON.stringify([r.reviewer.id, r.state])).sort() ?? null;\n}\n\n/**\n * An input an issue's etag can be widened to, which a host changes without moving `updatedAt`. `'reactions'` is the\n * thumbs-up count, and widens the etag only on hosts whose rows really fetch one (GitHub/GHE and GitLab).\n */\nexport type IssueEtagInclude = 'reactions';\n\n/** Every {@link IssueEtagInclude}, in the canonical order an etag lists them in. */\nexport const issueEtagIncludes: readonly IssueEtagInclude[] = ['reactions'];\n\n/** The issue twin of {@link PullRequestEtagFields}, in {@link IssueShape}'s normalized vocabulary. */\nexport interface IssueEtagFields {\n\tstate: IssueOrPullRequestState | undefined;\n\tupdatedDate: Date;\n\t/** Counts only when `'reactions'` is requested, and only from a row whose read fetched reactions. */\n\tthumbsUpCount?: number;\n\t/**\n\t * Azure DevOps only: the version of the rule a work item's body is read by ({@link azureWorkItemDescriptionRule}).\n\t * A change of rule changes the body without moving `updatedDate`, so a row read under an earlier one must not\n\t * compare unchanged.\n\t */\n\tdescriptionRule?: number;\n\t/**\n\t * Azure DevOps only: the version of the rule a work item's `viewer` is set by ({@link azureWorkItemViewerRule}).\n\t * A full row that names someone but got no viewer (its organization's identity couldn't be read) leaves it out, so\n\t * it never compares unchanged and is read in full again rather than kept without one.\n\t */\n\tviewerRule?: number;\n\t/**\n\t * Linear only: the row's `syncedWith` links as {@link linearSyncedWithEtagKeys} spells them, so a link added, removed\n\t * or moved to other coordinates changes the etag whether or not the issue's update time moves. `null` on a\n\t * full row without `syncedWith` (held from before it existed, or read while Linear failed to resolve it), which\n\t * never compares unchanged with a cheap check's list.\n\t */\n\tsyncedWithKeys?: readonly string[] | null;\n}\n\n/**\n * {@link IssueEtagFields.descriptionRule}: the version of the rule an Azure DevOps work item's body is read by, stamped\n * on both sides of its etag. Bumped whenever the rule changes which field a work item's body comes from, so every row\n * a caller holds from before is read in full once. 1: the first rich text field with content (provider-apis'\n * `getAzureWorkItemDescription`), where it used to be only Description. The rule lives in provider-apis, so a bump of\n * that package that changes it must bump this too; the etag tests pin the rule to catch one.\n *\n * It can't cover a row whose read found the organization's field catalog unavailable: that row's body falls back to\n * the built-in fields, and a cheap check, which reads no body, can't tell it from a complete one, so it stays as read\n * until the work item changes.\n */\nexport const azureWorkItemDescriptionRule = 1;\n\n/**\n * {@link IssueEtagFields.viewerRule}: the version of the rule an Azure DevOps work item's `viewer` is set by, stamped\n * on both sides of its etag, so every row a caller holds from before it was set is read in full once. 1: the user's\n * identity in the work item's organization (gitkraken/kepler#4291).\n */\nexport const azureWorkItemViewerRule = 1;\n\n/**\n * A Linear row's sync links in its etag, sorted: each as its GitHub id and, when known, the coordinates a host matches\n * the GitHub row by, so a link whose coordinates Linear fills in or changes later compares changed.\n */\nexport function linearSyncedWithEtagKeys(links: readonly IssueSyncedWith[]): string[] {\n\treturn links\n\t\t.map(link => (link.owner != null ? `${link.id}:${link.owner}/${link.repo}#${link.number}` : `${link.id}:`))\n\t\t.sort();\n}\n\n/**\n * Azure DevOps: a pull request there keeps no update time, so its etag adds a {@link pullRequestRevision}, and a work\n * item's etag adds the rule its body is read by (see `azureWorkItemDescriptionRule`).\n */\nconst azureProviderIds: ReadonlySet<string> = new Set([\n\tGitCloudHostIntegrationId.AzureDevOps,\n\tGitSelfManagedHostIntegrationId.AzureDevOpsServer,\n]);\n\nexport function pullRequestEtagFieldsFromShape(pr: PullRequestShape): PullRequestEtagFields {\n\tconst fields: PullRequestEtagFields = {\n\t\tstate: pr.state,\n\t\tisDraft: pr.isDraft,\n\t\tupdatedDate: pr.updatedDate,\n\t\theadSha: pr.refs?.head.sha,\n\t\tmergeableState: pr.mergeableState,\n\t\treviewDecision: pr.reviewDecision,\n\t\t// On the class, not the shape: every provider's mapper builds a `PullRequest`. Read by name rather than by\n\t\t// `instanceof`, which a second copy of the model module fails, silently dropping the rollup from every full\n\t\t// row's etag so that no cheap check ever matches it again.\n\t\tstatusCheckRollupState: 'statusCheckRollupState' in pr ? (pr as PullRequest).statusCheckRollupState : undefined,\n\t};\n\t// Read defensively, as `timeOf` reads the date: a row without a provider must not fail the read.\n\tif (pr.provider != null && azureProviderIds.has(pr.provider.id)) {\n\t\tfields.revision = pullRequestRevision(pr);\n\t}\n\tif (pr.viewerUnresolved) {\n\t\tfields.viewerUnresolved = true;\n\t}\n\tif (pr.mergeQueue != null) {\n\t\tfields.mergeQueue = { state: pr.mergeQueue.state, enqueuedAt: pr.mergeQueue.enqueuedAt };\n\t}\n\tif (pr.mergeQueueRemoval != null) {\n\t\tfields.mergeQueueRemovedAt = pr.mergeQueueRemoval.removedAt;\n\t}\n\t// `mergeQueueRequired` is GitHub's non-null `isMergeQueueEnabled`, so only a row from a read that selected the\n\t// merge-queue data has it.\n\tif (pr.mergeQueueRequired != null) {\n\t\tfields.mergeQueueRead = true;\n\t}\n\tif (pr.checkRuns != null) {\n\t\tfields.checkRuns = pullRequestCheckRunsEtag(pr.checkRuns, pr.checkRunsTruncated === true);\n\t}\n\tif (pr.stack?.mergedLayers != null) {\n\t\tfields.stackMergedLayers = pr.stack.mergedLayers;\n\t}\n\treturn fields;\n}\n\nexport function issueEtagFieldsFromShape(issue: IssueShape): IssueEtagFields {\n\tconst fields: IssueEtagFields = { state: issue.state, updatedDate: issue.updatedDate };\n\t// Only where the row's read really fetched reactions: elsewhere a count is a placeholder or a tracker's votes,\n\t// which no cheap check reads, so taking it would fail every check of that row under `'reactions'`.\n\tif (\n\t\tissue.thumbsUpCount != null &&\n\t\tissue.provider != null &&\n\t\tgetIssueFieldPresence(issue)?.reactions === 'fetched'\n\t) {\n\t\tfields.thumbsUpCount = issue.thumbsUpCount;\n\t}\n\tif (issue.provider != null && azureProviderIds.has(issue.provider.id)) {\n\t\tfields.descriptionRule = azureWorkItemDescriptionRule;\n\t\t// A row read while its organization's identity couldn't be must not compare unchanged, or it would be kept\n\t\t// without a viewer until the work item changes. Also a row that names someone and has neither field: one held\n\t\t// from before `viewerUnresolved` existed.\n\t\tif (!issue.viewerUnresolved && (issue.viewer != null || !issueNamesPeople(issue))) {\n\t\t\tfields.viewerRule = azureWorkItemViewerRule;\n\t\t}\n\t}\n\tif (issue.provider?.id === IssuesCloudHostIntegrationId.Linear) {\n\t\tfields.syncedWithKeys = issue.syncedWith != null ? linearSyncedWithEtagKeys(issue.syncedWith) : null;\n\t}\n\treturn fields;\n}\n\n/**\n * The distinct `includes` in canonical order, whatever order and repetition the caller gave. Values it doesn't know\n * are dropped, so a caller validates them first (see {@link findInvalidPullRequestEtagInclude}).\n */\nexport function normalizePullRequestEtagIncludes(\n\tincludes: readonly PullRequestEtagInclude[],\n): readonly PullRequestEtagInclude[] {\n\treturn pullRequestEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't a {@link PullRequestEtagInclude}, if any. */\nexport function findInvalidPullRequestEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(pullRequestEtagIncludes as readonly string[]).includes(include));\n}\n\n/**\n * Each of `includes` adds one input — mergeability, review decision or check rollup — which a host may change\n * without moving `updatedDate`. An input that isn't listed is left out, so its churn never forces a full read.\n */\nexport function pullRequestEtag(fields: PullRequestEtagFields, includes: readonly PullRequestEtagInclude[]): string {\n\tconst covered = normalizePullRequestEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, fields.isDraft ?? null, timeOf(fields.updatedDate), fields.headSha ?? null];\n\t// Only where it is set, so every other host's etag stays exactly what it was.\n\tif (fields.revision != null) {\n\t\tstate.push(fields.revision);\n\t}\n\tif (fields.viewerUnresolved) {\n\t\tstate.push('viewer-unresolved');\n\t}\n\t// Only while queued, so a pull request outside any queue keeps exactly the etag it always had, and joining,\n\t// moving through or leaving the queue (none of which moves the update time) still reads as a change. Tagged, so\n\t// it can never read as another input.\n\tif (fields.mergeQueue != null) {\n\t\tstate.push(['merge-queue', fields.mergeQueue.state, timeOf(fields.mergeQueue.enqueuedAt)]);\n\t}\n\t// Likewise only while the pull request's latest merge-queue event is a removal, so a pull request removed between\n\t// two checks, which neither moves its update time nor shows a queue entry at either check, still reads as a change.\n\tif (fields.mergeQueueRemovedAt != null) {\n\t\tstate.push(['merge-queue-removed', timeOf(fields.mergeQueueRemovedAt)]);\n\t}\n\t// Whenever the read selected the merge-queue data, so an etag from such a read never equals one from a read that\n\t// didn't, even for a pull request that was never queued, whose state is otherwise identical. Tagged, like the\n\t// terms above. A read that didn't select it adds nothing, so it computes the etag it did before.\n\tif (fields.mergeQueueRead) {\n\t\tstate.push(['merge-queue-read']);\n\t}\n\tif (fields.checkRuns != null) {\n\t\tconst { hash, count, truncated } = fields.checkRuns;\n\t\tstate.push(truncated ? ['check-runs', hash, count, 'truncated'] : ['check-runs', hash, count]);\n\t}\n\tif (fields.stackMergedLayers != null) {\n\t\tstate.push(['stack-merged-layers', fields.stackMergedLayers]);\n\t}\n\n\tif (covered.length === 0) return `pr1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'mergeable':\n\t\t\t\tstate.push(fields.mergeableState ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'reviewDecision':\n\t\t\t\tstate.push(fields.reviewDecision ?? null);\n\t\t\t\tbreak;\n\t\t\tcase 'checks':\n\t\t\t\tstate.push(fields.statusCheckRollupState ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `pr1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/** The issue twin of {@link normalizePullRequestEtagIncludes}; validate with {@link findInvalidIssueEtagInclude}. */\nexport function normalizeIssueEtagIncludes(includes: readonly IssueEtagInclude[]): readonly IssueEtagInclude[] {\n\treturn issueEtagIncludes.filter(include => includes.includes(include));\n}\n\n/** The first of `includes` that isn't an {@link IssueEtagInclude}, if any. */\nexport function findInvalidIssueEtagInclude(includes: readonly string[]): string | undefined {\n\treturn includes.find(include => !(issueEtagIncludes as readonly string[]).includes(include));\n}\n\n/** `'reactions'` adds the thumbs-up count, which a host changes without moving `updatedDate`. */\nexport function issueEtag(fields: IssueEtagFields, includes: readonly IssueEtagInclude[]): string {\n\tconst covered = normalizeIssueEtagIncludes(includes);\n\tconst state: unknown[] = [fields.state, timeOf(fields.updatedDate)];\n\t// Only where it is set, so every other provider's etag stays exactly what it was.\n\tif (fields.descriptionRule != null) {\n\t\tstate.push(fields.descriptionRule);\n\t}\n\tif (fields.viewerRule != null) {\n\t\tstate.push(fields.viewerRule);\n\t}\n\t// Only where it is set, so every other provider's etag stays exactly what it was. An unknown list is spelled\n\t// apart from every known one, so it never compares unchanged.\n\tif (fields.syncedWithKeys !== undefined) {\n\t\tstate.push(fields.syncedWithKeys === null ? 'synced-with:unknown' : ['synced-with', ...fields.syncedWithKeys]);\n\t}\n\tif (covered.length === 0) return `is1:${JSON.stringify(state)}`;\n\n\tfor (const include of covered) {\n\t\tswitch (include) {\n\t\t\tcase 'reactions':\n\t\t\t\tstate.push(fields.thumbsUpCount ?? null);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn `is1+${covered.join('+')}:${JSON.stringify(state)}`;\n}\n\n/**\n * Never throws: an etag is computed for every fully read row, so a mapper that hands over a missing or unparseable\n * date must not fail the whole read. Such a row's etag just won't match a cheap check's, which always has a date,\n * so the cost is a full read, never a false `unchanged`.\n */\nfunction timeOf(date: Date): number | null {\n\tconst time = new Date(date).getTime();\n\treturn Number.isNaN(time) ? null : time;\n}\n"],"mappings":";;;;;;AA8CA,MAAa,0BAA6D;CAAC;CAAa;CAAkB;AAAQ;;;;;;AAyElH,SAAgB,yBACf,MACA,WAC2B;CAC3B,MAAM,UAAU,KACd,KAAI,QAAO;EAAC,IAAI;EAAI,IAAI;EAAM,IAAI;EAAM,IAAI;EAAQ,IAAI,cAAc;CAAI,CAAU,CAAC,CACrF,MAAM,CAAC,IAAI,CAAC,OAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAE;CACjD,OAAO;EAAE,MAAM,YAAY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C7B,MAAM,KAAK,OAAO,eAAe;CAElC,IAAI,OAAO,cAAc,MACxB,MAAM,KAAK,OAAO,UAAU;CAI7B,IAAI,OAAO,mBAAmB,KAAA,GAC7B,MAAM,KAAK,OAAO,mBAAmB,OAAO,wBAAwB,CAAC,eAAe,GAAG,OAAO,cAAc,CAAC;CAE9G,IAAI,QAAQ,WAAW,GAAG,OAAO,OAAO,KAAK,UAAU,KAAK;CAE5D,KAAK,MAAM,WAAW,SACrB,QAAQ,SAAR;EACC,KAAK,aACJ,MAAM,KAAK,OAAO,iBAAiB,IAAI;CAEzC;CAGD,OAAO,OAAO,QAAQ,KAAK,GAAG,EAAE,GAAG,KAAK,UAAU,KAAK;AACxD;;;;;;AAOA,SAAS,OAAO,MAA2B;CAC1C,MAAM,OAAO,IAAI,KAAK,IAAI,CAAC,CAAC,QAAQ;CACpC,OAAO,OAAO,MAAM,IAAI,IAAI,OAAO;AACpC"}
@@ -8,12 +8,14 @@ interface RunErrorContext {
8
8
  killed?: boolean | undefined;
9
9
  code?: string | number | null | undefined;
10
10
  signal?: NodeJS.Signals | undefined;
11
+ syscall?: string | undefined;
11
12
  }
12
13
  export declare class RunError extends Error {
13
14
  readonly cmd?: string | undefined;
14
15
  readonly killed?: boolean | undefined;
15
16
  readonly code?: string | number | undefined;
16
17
  readonly signal?: NodeJS.Signals | undefined;
18
+ readonly syscall?: string | undefined;
17
19
  readonly stdout: string;
18
20
  readonly stderr: string;
19
21
  constructor(context: RunErrorContext, stdout: string, stderr: string);
@@ -1,16 +1,17 @@
1
1
  import { getScopedLogger, maybeStartScopedLogger } from "../../logger.scoped.js";
2
2
  import { isWindows } from "./platform.js";
3
3
  import { join } from "path";
4
- import { execFile, spawn } from "child_process";
5
- import { access, constants } from "fs";
6
4
  import { stat } from "fs/promises";
7
5
  import * as process from "process";
6
+ import { execFile, spawn } from "child_process";
7
+ import { access, constants } from "fs";
8
8
  //#region ../utils/src/env/node/exec.ts
9
9
  var RunError = class extends Error {
10
10
  cmd;
11
11
  killed;
12
12
  code;
13
13
  signal;
14
+ syscall;
14
15
  stdout;
15
16
  stderr;
16
17
  constructor(context, stdout, stderr) {
@@ -19,6 +20,7 @@ var RunError = class extends Error {
19
20
  this.killed = context.killed;
20
21
  this.code = context.code ?? void 0;
21
22
  this.signal = context.signal;
23
+ this.syscall = context.syscall;
22
24
  this.stdout = stdout?.trim() ?? "";
23
25
  this.stderr = stderr?.trim() ?? "";
24
26
  this.name = "RunError";
@@ -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,oB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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,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AK,WAAW,QAAQ,GAAG,KAAK,KAAK,GAAG,EAAE,WAAW,QAAQ;IAGrE,IAAI,WAAW,WAAW;KAGzB,OACC,IAAI,kBACH,GAAG,QAAQ,GAAG,KAAK,KAAK,GAAG,KAC3B,MACA,QAAQ,KAAA,GACR,QACA,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"}
@@ -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).
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.63.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",