@gitkraken/core-gitlens 0.28.0 → 0.30.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 (120) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/dist/git/cache.d.ts +39 -1
  3. package/dist/git/cache.js +108 -7
  4. package/dist/git/cache.js.map +1 -1
  5. package/dist/git/providers/branches.d.ts +17 -12
  6. package/dist/git/providers/revision.d.ts +4 -0
  7. package/dist/git/watching/worktreeSummary.d.ts +16 -7
  8. package/dist/git/watching/worktreeSummary.js +44 -14
  9. package/dist/git/watching/worktreeSummary.js.map +1 -1
  10. package/dist/git-cli/cliGitProvider.js +3 -3
  11. package/dist/git-cli/cliGitProvider.js.map +1 -1
  12. package/dist/git-cli/exec/exec.d.ts +2 -2
  13. package/dist/git-cli/exec/exec.js +2 -2
  14. package/dist/git-cli/exec/gitDirResolver.d.ts +6 -1
  15. package/dist/git-cli/exec/gitDirResolver.js +9 -4
  16. package/dist/git-cli/exec/gitDirResolver.js.map +1 -1
  17. package/dist/git-cli/providers/branches.d.ts +91 -13
  18. package/dist/git-cli/providers/branches.js +673 -176
  19. package/dist/git-cli/providers/branches.js.map +1 -1
  20. package/dist/git-cli/providers/config.js +1 -1
  21. package/dist/git-cli/providers/config.js.map +1 -1
  22. package/dist/git-cli/providers/revision.d.ts +4 -0
  23. package/dist/git-cli/providers/revision.js +64 -3
  24. package/dist/git-cli/providers/revision.js.map +1 -1
  25. package/dist/ipc/ipcServer.d.ts +6 -1
  26. package/dist/ipc/ipcServer.js +15 -6
  27. package/dist/ipc/ipcServer.js.map +1 -1
  28. package/dist/plus/ai/errors.js +4 -4
  29. package/dist/plus/ai/errors.js.map +1 -1
  30. package/dist/plus/ai/models/model.d.ts +1 -1
  31. package/dist/plus/ai/models/model.js.map +1 -1
  32. package/dist/plus/ai/models/promptTemplates.d.ts +45 -2
  33. package/dist/plus/ai/models/results.d.ts +41 -0
  34. package/dist/plus/ai/models/results.js +14 -0
  35. package/dist/plus/ai/models/results.js.map +1 -0
  36. package/dist/plus/ai/prompts.d.ts +6 -0
  37. package/dist/plus/ai/prompts.js +255 -5
  38. package/dist/plus/ai/prompts.js.map +1 -1
  39. package/dist/plus/ai/providers/gitkrakenProvider.js +2 -2
  40. package/dist/plus/ai/providers/gitkrakenProvider.js.map +1 -1
  41. package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -0
  42. package/dist/plus/ai/providers/openAICompatibleProviderBase.js.map +1 -1
  43. package/dist/plus/ai/utils/ai.utils.d.ts +4 -0
  44. package/dist/plus/ai/utils/ai.utils.js +8 -1
  45. package/dist/plus/ai/utils/ai.utils.js.map +1 -1
  46. package/dist/plus/ai/utils/results.utils.d.ts +15 -1
  47. package/dist/plus/ai/utils/results.utils.js +80 -4
  48. package/dist/plus/ai/utils/results.utils.js.map +1 -1
  49. package/dist/plus/integrations/authentication/integrationAuthenticationService.js +2 -0
  50. package/dist/plus/integrations/authentication/integrationAuthenticationService.js.map +1 -1
  51. package/dist/plus/integrations/authentication/models.d.ts +1 -1
  52. package/dist/plus/integrations/authentication/models.js +2 -0
  53. package/dist/plus/integrations/authentication/models.js.map +1 -1
  54. package/dist/plus/integrations/constants.d.ts +2 -1
  55. package/dist/plus/integrations/constants.js +12 -2
  56. package/dist/plus/integrations/constants.js.map +1 -1
  57. package/dist/plus/integrations/fieldPresence.js +17 -1
  58. package/dist/plus/integrations/fieldPresence.js.map +1 -1
  59. package/dist/plus/integrations/integrationService.d.ts +1 -1
  60. package/dist/plus/integrations/integrationService.js +8 -2
  61. package/dist/plus/integrations/integrationService.js.map +1 -1
  62. package/dist/plus/integrations/lite.js +5 -6
  63. package/dist/plus/integrations/lite.js.map +1 -1
  64. package/dist/plus/integrations/models/gitHostIntegration.d.ts +11 -1
  65. package/dist/plus/integrations/models/gitHostIntegration.js.map +1 -1
  66. package/dist/plus/integrations/providers/asana.d.ts +91 -0
  67. package/dist/plus/integrations/providers/asana.js +344 -0
  68. package/dist/plus/integrations/providers/asana.js.map +1 -0
  69. package/dist/plus/integrations/providers/azure/azure.js +3 -2
  70. package/dist/plus/integrations/providers/azure/azure.js.map +1 -1
  71. package/dist/plus/integrations/providers/azure/models.js +3 -2
  72. package/dist/plus/integrations/providers/azure/models.js.map +1 -1
  73. package/dist/plus/integrations/providers/azureDevOps.d.ts +7 -1
  74. package/dist/plus/integrations/providers/azureDevOps.js +9 -1
  75. package/dist/plus/integrations/providers/azureDevOps.js.map +1 -1
  76. package/dist/plus/integrations/providers/bitbucket-server/discovery.js +2 -1
  77. package/dist/plus/integrations/providers/bitbucket-server/discovery.js.map +1 -1
  78. package/dist/plus/integrations/providers/bitbucket-server/models.js.map +1 -1
  79. package/dist/plus/integrations/providers/github.d.ts +2 -2
  80. package/dist/plus/integrations/providers/github.js +2 -2
  81. package/dist/plus/integrations/providers/github.js.map +1 -1
  82. package/dist/plus/integrations/providers/issueSorts.d.ts +5 -0
  83. package/dist/plus/integrations/providers/issueSorts.js +6 -1
  84. package/dist/plus/integrations/providers/issueSorts.js.map +1 -1
  85. package/dist/plus/integrations/providers/jiraIssueByKey.js +2 -1
  86. package/dist/plus/integrations/providers/jiraIssueByKey.js.map +1 -1
  87. package/dist/plus/integrations/providers/models.d.ts +19 -3
  88. package/dist/plus/integrations/providers/models.js +12 -1
  89. package/dist/plus/integrations/providers/models.js.map +1 -1
  90. package/dist/plus/integrations/providers/providerApiClient.d.ts +0 -3
  91. package/dist/plus/integrations/providers/providerApiClient.js +1 -3
  92. package/dist/plus/integrations/providers/providerApiClient.js.map +1 -1
  93. package/dist/plus/integrations/providers/providersApi.d.ts +22 -1
  94. package/dist/plus/integrations/providers/providersApi.js +63 -12
  95. package/dist/plus/integrations/providers/providersApi.js.map +1 -1
  96. package/dist/plus/integrations/providers/utils.d.ts +1 -0
  97. package/dist/plus/integrations/providers/utils.js +8 -2
  98. package/dist/plus/integrations/providers/utils.js.map +1 -1
  99. package/dist/plus/integrations/reads/hierarchy.utils.d.ts +3 -3
  100. package/dist/plus/integrations/reads/hierarchy.utils.js +4 -4
  101. package/dist/plus/integrations/reads/hierarchy.utils.js.map +1 -1
  102. package/dist/plus/integrations/reads/resolveRepository.js +29 -21
  103. package/dist/plus/integrations/reads/resolveRepository.js.map +1 -1
  104. package/dist/plus/integrations/results.d.ts +18 -10
  105. package/dist/plus/integrations/results.js.map +1 -1
  106. package/dist/plus/integrations/utils/domain.utils.js +2 -1
  107. package/dist/plus/integrations/utils/domain.utils.js.map +1 -1
  108. package/dist/plus/integrations/utils/integration.utils.js +5 -13
  109. package/dist/plus/integrations/utils/integration.utils.js.map +1 -1
  110. package/dist/utils/diff.d.ts +19 -0
  111. package/dist/utils/diff.js +121 -3
  112. package/dist/utils/diff.js.map +1 -1
  113. package/dist/utils/env/node/exec.d.ts +0 -1
  114. package/dist/utils/env/node/exec.js +2 -14
  115. package/dist/utils/env/node/exec.js.map +1 -1
  116. package/dist/utils/path.d.ts +2 -0
  117. package/dist/utils/path.js +7 -1
  118. package/dist/utils/path.js.map +1 -1
  119. package/docs/integrations.md +72 -43
  120. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"diff.js","names":[],"sources":["../../../utils/src/diff.ts"],"sourcesContent":["// Annotates diff to make is easier for agentic reference to line number.\n// Brackets sit AFTER the line-type marker so file-level diff parsers\n// (e.g. `filterDiffFiles`) that key off `diff --git` / `+++` / `---` headers still work.\nexport function annotateDiffWithNewLineNumbers(diff: string): string {\n\tif (!diff) return diff;\n\n\tconst lines = diff.split('\\n');\n\tconst out: string[] = new Array(lines.length);\n\tlet newLine = 0;\n\tlet inHunk = false;\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\n\t\tif (line.startsWith('@@')) {\n\t\t\tconst match = /\\+(\\d+)(?:,\\d+)?\\s/.exec(line);\n\t\t\tnewLine = match != null ? parseInt(match[1], 10) : 0;\n\t\t\tinHunk = true;\n\t\t\tout[i] = line;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\tline.startsWith('diff --git') ||\n\t\t\tline.startsWith('index ') ||\n\t\t\tline.startsWith('--- ') ||\n\t\t\tline.startsWith('+++ ') ||\n\t\t\tline.startsWith('new file') ||\n\t\t\tline.startsWith('deleted file') ||\n\t\t\tline.startsWith('rename ') ||\n\t\t\tline.startsWith('copy ') ||\n\t\t\tline.startsWith('similarity ') ||\n\t\t\tline.startsWith('dissimilarity ') ||\n\t\t\tline.startsWith('Binary files')\n\t\t) {\n\t\t\tinHunk = false;\n\t\t\tout[i] = line;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!inHunk || line.startsWith('\\\\')) {\n\t\t\tout[i] = line;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst marker = line[0];\n\t\tif (marker === '-') {\n\t\t\tout[i] = `-[ ]${line.slice(1)}`;\n\t\t\tcontinue;\n\t\t}\n\t\tif (marker === '+' || marker === ' ') {\n\t\t\tout[i] = `${marker}[${String(newLine).padStart(5, ' ')}]${line.slice(1)}`;\n\t\t\tnewLine++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tout[i] = line;\n\t}\n\n\treturn out.join('\\n');\n}\n"],"mappings":";AAGA,SAAgB,+BAA+B,MAAsB;CACpE,IAAI,CAAC,MAAM,OAAO;CAElB,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,MAAM,MAAgB,IAAI,MAAM,MAAM,MAAM;CAC5C,IAAI,UAAU;CACd,IAAI,SAAS;CAEb,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACtC,MAAM,OAAO,MAAM;EAEnB,IAAI,KAAK,WAAW,IAAI,GAAG;GAC1B,MAAM,QAAQ,qBAAqB,KAAK,IAAI;GAC5C,UAAU,SAAS,OAAO,SAAS,MAAM,IAAI,EAAE,IAAI;GACnD,SAAS;GACT,IAAI,KAAK;GACT;EACD;EAEA,IACC,KAAK,WAAW,YAAY,KAC5B,KAAK,WAAW,QAAQ,KACxB,KAAK,WAAW,MAAM,KACtB,KAAK,WAAW,MAAM,KACtB,KAAK,WAAW,UAAU,KAC1B,KAAK,WAAW,cAAc,KAC9B,KAAK,WAAW,SAAS,KACzB,KAAK,WAAW,OAAO,KACvB,KAAK,WAAW,aAAa,KAC7B,KAAK,WAAW,gBAAgB,KAChC,KAAK,WAAW,cAAc,GAC7B;GACD,SAAS;GACT,IAAI,KAAK;GACT;EACD;EAEA,IAAI,CAAC,UAAU,KAAK,WAAW,IAAI,GAAG;GACrC,IAAI,KAAK;GACT;EACD;EAEA,MAAM,SAAS,KAAK;EACpB,IAAI,WAAW,KAAK;GACnB,IAAI,KAAK,WAAW,KAAK,MAAM,CAAC;GAChC;EACD;EACA,IAAI,WAAW,OAAO,WAAW,KAAK;GACrC,IAAI,KAAK,GAAG,OAAO,GAAG,OAAO,OAAO,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;GACtE;GACA;EACD;EAEA,IAAI,KAAK;CACV;CAEA,OAAO,IAAI,KAAK,IAAI;AACrB"}
1
+ {"version":3,"file":"diff.js","names":[],"sources":["../../../utils/src/diff.ts"],"sourcesContent":["// Annotates diff to make is easier for agentic reference to line number.\n// Brackets sit AFTER the line-type marker so file-level diff parsers\n// (e.g. `filterDiffFiles`) that key off `diff --git` / `+++` / `---` headers still work.\nexport function annotateDiffWithNewLineNumbers(diff: string): string {\n\tif (!diff) return diff;\n\n\tconst lines = diff.split('\\n');\n\tconst out: string[] = new Array(lines.length);\n\tlet newLine = 0;\n\tlet inHunk = false;\n\t// What the hunk header says is left of the hunk on each side. Inside a counted hunk every line is\n\t// content — a removed `-- comment` reads as `--- comment`, an added `++x` as `+++x` — so the header\n\t// check below applies only once the counts run out (or when a header had none to read)\n\tlet oldLeft = 0;\n\tlet newLeft = 0;\n\tlet counted = false;\n\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\n\t\tif (inHunk && counted) {\n\t\t\tif (oldLeft > 0 || newLeft > 0) {\n\t\t\t\tconst marker = line[0];\n\t\t\t\tif (marker === '\\\\') {\n\t\t\t\t\tout[i] = line;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (marker === '-' && oldLeft > 0) {\n\t\t\t\t\toldLeft--;\n\t\t\t\t\tout[i] = `-[ ]${line.slice(1)}`;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (marker === '+' && newLeft > 0) {\n\t\t\t\t\tnewLeft--;\n\t\t\t\t\tout[i] = `+[${String(newLine).padStart(5, ' ')}]${line.slice(1)}`;\n\t\t\t\t\tnewLine++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\t// An empty context line can lose its leading space to an editor or a copy\n\t\t\t\tif ((marker === ' ' || line === '') && oldLeft > 0 && newLeft > 0) {\n\t\t\t\t\toldLeft--;\n\t\t\t\t\tnewLeft--;\n\t\t\t\t\tout[i] = ` [${String(newLine).padStart(5, ' ')}]${line.slice(1)}`;\n\t\t\t\t\tnewLine++;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tinHunk = false;\n\t\t}\n\n\t\tif (line.startsWith('@@')) {\n\t\t\tconst match = /^@@ -\\d+(?:,(\\d+))? \\+(\\d+)(?:,(\\d+))? @@/.exec(line);\n\t\t\tcounted = match != null;\n\t\t\tif (match != null) {\n\t\t\t\toldLeft = match[1] != null ? parseInt(match[1], 10) : 1;\n\t\t\t\tnewLine = parseInt(match[2], 10);\n\t\t\t\tnewLeft = match[3] != null ? parseInt(match[3], 10) : 1;\n\t\t\t} else {\n\t\t\t\tconst start = /\\+(\\d+)(?:,\\d+)?\\s/.exec(line);\n\t\t\t\tnewLine = start != null ? parseInt(start[1], 10) : 0;\n\t\t\t}\n\t\t\tinHunk = true;\n\t\t\tout[i] = line;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (\n\t\t\tline.startsWith('diff --git') ||\n\t\t\tline.startsWith('index ') ||\n\t\t\tline.startsWith('--- ') ||\n\t\t\tline.startsWith('+++ ') ||\n\t\t\tline.startsWith('new file') ||\n\t\t\tline.startsWith('deleted file') ||\n\t\t\tline.startsWith('rename ') ||\n\t\t\tline.startsWith('copy ') ||\n\t\t\tline.startsWith('similarity ') ||\n\t\t\tline.startsWith('dissimilarity ') ||\n\t\t\tline.startsWith('Binary files')\n\t\t) {\n\t\t\tinHunk = false;\n\t\t\tout[i] = line;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!inHunk || line.startsWith('\\\\')) {\n\t\t\tout[i] = line;\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst marker = line[0];\n\t\tif (marker === '-') {\n\t\t\tout[i] = `-[ ]${line.slice(1)}`;\n\t\t\tcontinue;\n\t\t}\n\t\tif (marker === '+' || marker === ' ') {\n\t\t\tout[i] = `${marker}[${String(newLine).padStart(5, ' ')}]${line.slice(1)}`;\n\t\t\tnewLine++;\n\t\t\tcontinue;\n\t\t}\n\n\t\tout[i] = line;\n\t}\n\n\treturn out.join('\\n');\n}\n\nconst annotatedNewLineRegex = /^[+ ]\\[\\s*(\\d+)\\](.*)$/;\n\n/**\n * The new-side text an {@link annotateDiffWithNewLineNumbers} diff shows for each line number, by\n * new-side path. A path can appear in several parts of one diff (unstaged, staged and commit diffs\n * concatenated), each numbering its own new side, so a number can carry more than one text.\n */\nexport function getAnnotatedNewLines(annotatedDiff: string): Map<string, Map<number, string[]>> {\n\tconst files = new Map<string, Map<number, string[]>>();\n\tlet current: Map<number, string[]> | undefined;\n\tlet previous: string | undefined;\n\n\tfor (const line of annotatedDiff.split('\\n')) {\n\t\tconst before = previous;\n\t\tprevious = line;\n\n\t\tconst match = annotatedNewLineRegex.exec(line);\n\t\tif (match != null) {\n\t\t\tif (current == null) continue;\n\n\t\t\tconst lineNumber = parseInt(match[1], 10);\n\t\t\tconst texts = current.get(lineNumber);\n\t\t\tif (texts == null) {\n\t\t\t\tcurrent.set(lineNumber, [match[2]]);\n\t\t\t} else {\n\t\t\t\ttexts.push(match[2]);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// A file's new-side header always follows its old-side one; an unannotated `+++ ` anywhere else is\n\t\t// content, not a switch to another file\n\t\tif (line.startsWith('+++ ') && before?.startsWith('--- ')) {\n\t\t\tlet path = line.slice(4).trimEnd();\n\t\t\tif (path.startsWith('\"') && path.endsWith('\"')) {\n\t\t\t\tpath = path.slice(1, -1);\n\t\t\t}\n\t\t\tif (path === '/dev/null') {\n\t\t\t\tcurrent = undefined;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (path.startsWith('b/')) {\n\t\t\t\tpath = path.slice(2);\n\t\t\t}\n\t\t\tcurrent = files.get(path);\n\t\t\tif (current == null) {\n\t\t\t\tcurrent = new Map();\n\t\t\t\tfiles.set(path, current);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (line.startsWith('diff --git')) {\n\t\t\tcurrent = undefined;\n\t\t}\n\t}\n\n\treturn files;\n}\n\n/**\n * Moves a line range quoted against an annotated diff onto the file it belongs to: verifies the range's\n * first non-blank quoted line against `target` and, when it isn't there, shifts the range to the nearest\n * place that text is. Returns the range unchanged when nothing quoted can be checked, and `undefined`\n * when the quoted text isn't in `target` at all.\n */\nexport function reanchorLineRange(\n\trange: { readonly start: number; readonly end: number },\n\tquoted: ReadonlyMap<number, readonly string[]>,\n\ttarget: readonly string[],\n): { start: number; end: number } | undefined {\n\tlet anchor: number | undefined;\n\tlet texts: string[] | undefined;\n\tfor (let n = range.start; n <= range.end; n++) {\n\t\tconst candidates = quoted\n\t\t\t.get(n)\n\t\t\t?.map(t => t.trimEnd())\n\t\t\t.filter(t => t.trim().length > 0);\n\t\tif (candidates?.length) {\n\t\t\tanchor = n;\n\t\t\ttexts = candidates;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (anchor == null || texts == null) return { start: range.start, end: range.end };\n\n\tconst matches = (lineNumber: number): boolean => {\n\t\tconst text = target[lineNumber - 1]?.trimEnd();\n\t\treturn text != null && texts.includes(text);\n\t};\n\tif (matches(anchor)) return { start: range.start, end: range.end };\n\n\tfor (let distance = 1; distance < target.length; distance++) {\n\t\tfor (const lineNumber of [anchor - distance, anchor + distance]) {\n\t\t\tif (lineNumber < 1 || lineNumber > target.length || !matches(lineNumber)) continue;\n\n\t\t\tconst offset = lineNumber - anchor;\n\t\t\treturn {\n\t\t\t\tstart: Math.max(1, range.start + offset),\n\t\t\t\tend: Math.min(target.length, Math.max(range.start, range.end) + offset),\n\t\t\t};\n\t\t}\n\t}\n\treturn undefined;\n}\n"],"mappings":";AAGA,SAAgB,+BAA+B,MAAsB;CACpE,IAAI,CAAC,MAAM,OAAO;CAElB,MAAM,QAAQ,KAAK,MAAM,IAAI;CAC7B,MAAM,MAAgB,IAAI,MAAM,MAAM,MAAM;CAC5C,IAAI,UAAU;CACd,IAAI,SAAS;CAIb,IAAI,UAAU;CACd,IAAI,UAAU;CACd,IAAI,UAAU;CAEd,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACtC,MAAM,OAAO,MAAM;EAEnB,IAAI,UAAU,SAAS;GACtB,IAAI,UAAU,KAAK,UAAU,GAAG;IAC/B,MAAM,SAAS,KAAK;IACpB,IAAI,WAAW,MAAM;KACpB,IAAI,KAAK;KACT;IACD;IAEA,IAAI,WAAW,OAAO,UAAU,GAAG;KAClC;KACA,IAAI,KAAK,WAAW,KAAK,MAAM,CAAC;KAChC;IACD;IAEA,IAAI,WAAW,OAAO,UAAU,GAAG;KAClC;KACA,IAAI,KAAK,KAAK,OAAO,OAAO,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;KAC9D;KACA;IACD;IAGA,KAAK,WAAW,OAAO,SAAS,OAAO,UAAU,KAAK,UAAU,GAAG;KAClE;KACA;KACA,IAAI,KAAK,KAAK,OAAO,OAAO,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,KAAK,MAAM,CAAC;KAC9D;KAC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vB,SAAS;GACT,QAAQ;GACR;EACD;CACD;CACA,IAAI,UAAU,QAAQ,SAAS,MAAM,OAAO;EAAE,OAAO,MAAM;EAAO,KAAK,MAAM;CAAI;CAEjF,MAAM,WAAW,eAAgC;EAChD,MAAM,OAAO,OAAO,aAAa,EAAE,EAAE,QAAQ;EAC7C,OAAO,QAAQ,QAAQ,MAAM,SAAS,IAAI;CAC3C;CACA,IAAI,QAAQ,MAAM,GAAG,OAAO;EAAE,OAAO,MAAM;EAAO,KAAK,MAAM;CAAI;CAEjE,KAAK,IAAI,WAAW,GAAG,WAAW,OAAO,QAAQ,YAChD,KAAK,MAAM,cAAc,CAAC,SAAS,UAAU,SAAS,QAAQ,GAAG;EAChE,IAAI,aAAa,KAAK,aAAa,OAAO,UAAU,CAAC,QAAQ,UAAU,GAAG;EAE1E,MAAM,SAAS,aAAa;EAC5B,OAAO;GACN,OAAO,KAAK,IAAI,GAAG,MAAM,QAAQ,MAAM;GACvC,KAAK,KAAK,IAAI,OAAO,QAAQ,KAAK,IAAI,MAAM,OAAO,MAAM,GAAG,IAAI,MAAM;EACvE;CACD;AAGF"}
@@ -35,7 +35,6 @@ export declare function findExecutable(exe: string, args: string[]): Promise<{
35
35
  cmd: string;
36
36
  args: string[];
37
37
  }>;
38
- export declare function getWindowsShortPath(path: string): Promise<string>;
39
38
  /** What core uses of a spawned process; Node's `ChildProcess` satisfies it */
40
39
  export interface SpawnedProcess {
41
40
  readonly stdin: Writable | null;
@@ -1,8 +1,7 @@
1
1
  import { getScopedLogger, maybeStartScopedLogger } from "../../logger.scoped.js";
2
- import { normalizePath } from "../../path.js";
3
2
  import { isWindows } from "./platform.js";
4
3
  import { join } from "path";
5
- import { exec, execFile, spawn } from "child_process";
4
+ import { execFile, spawn } from "child_process";
6
5
  import { access, constants } from "fs";
7
6
  import { stat } from "fs/promises";
8
7
  import * as process from "process";
@@ -131,17 +130,6 @@ async function findExecutable(exe, args) {
131
130
  args
132
131
  };
133
132
  }
134
- async function getWindowsShortPath(path) {
135
- return new Promise((resolve, reject) => {
136
- exec(`for %I in ("${path}") do @echo %~sI`, (error, stdout, _stderr) => {
137
- if (error != null) {
138
- reject(error);
139
- return;
140
- }
141
- resolve(normalizePath(stdout.trim()));
142
- });
143
- });
144
- }
145
133
  /**
146
134
  * The default {@link ProcessSpawner}: Node's `spawn`, but with its `timeout` handled here. Node clears its timeout
147
135
  * timer only on `'exit'`, which a failed launch (e.g. a missing `cwd`) never emits, so the timer outlives the
@@ -324,6 +312,6 @@ async function fsExists(path) {
324
312
  return new Promise((resolve) => access(path, constants.F_OK, (err) => resolve(err == null)));
325
313
  }
326
314
  //#endregion
327
- export { CancelledRunError, RunError, endStdin, findExecutable, fsExists, getWindowsShortPath, run, runSpawn, spawnProcess };
315
+ export { CancelledRunError, RunError, endStdin, findExecutable, fsExists, run, runSpawn, spawnProcess };
328
316
 
329
317
  //# sourceMappingURL=exec.js.map
@@ -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 { exec, 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 { normalizePath } from '../../path.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\nexport async function getWindowsShortPath(path: string): Promise<string> {\n\treturn new Promise<string>((resolve, reject) => {\n\t\texec(`for %I in (\"${path}\") do @echo %~sI`, (error, stdout, _stderr) => {\n\t\t\tif (error != null) {\n\t\t\t\treject(error);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tresolve(normalizePath(stdout.trim()));\n\t\t});\n\t});\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\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 * - 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\n\tif (timeout != null && timeout > 0) {\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n\t\t\tif (timeoutId != null) {\n\t\t\t\ttry {\n\t\t\t\t\tchild.kill();\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tchild.emit('error', ex);\n\t\t\t\t}\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}\n\t\t}, timeout);\n\n\t\tconst clear = () => {\n\t\t\tif (timeoutId != null) {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}\n\t\t};\n\t\t// `'exit'` keeps Node's timing; `'close'` covers a launch that fails and never exits\n\t\tchild.once('exit', clear);\n\t\tchild.once('close', clear);\n\t}\n\n\treturn child;\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 size the output buffer to allocate to the spawned process. Set this\n\t * if you are anticipating a large amount of output.\n\t *\n\t * If not specified, this will be 10MB (10485760 bytes) which should be\n\t * enough for most Git operations.\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: ['pipe', null, null],\n\t\t});\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tproc.stdout?.on('data', (data: Buffer) => stdoutBuffers.push(data));\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tproc.stderr?.on('data', (data: Buffer) => stderrBuffers.push(data));\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\tproc.once('error', async ex => {\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\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t});\n\n\t\tproc.once('close', async (code, signal) => {\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>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I,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,CAAC;EAGD,IAAI,KAAK,UAAU,QAAQ,KAAK,UAAU,MACzC,uBAAO,IAAI,MAAM,IAAI,QAAQ,8CAA8C,CAAC;EAG7E,IAAI,SAAS,MACZ,SAAS,KAAK,OAAO,OAAO,aAAa;CAE3C,CAEa,CAAC,CAAC,cAAc,QAAQ,OAAO,QAAQ,CAAC,CAAC;AACvD;AAEA,eAAsB,SAAS,MAAgC;CAC9D,OAAO,IAAI,SAAiB,YAAW,OAAO,MAAM,UAAU,OAAM,QAAO,QAAQ,OAAO,IAAI,CAAC,CAAC;AACjG"}
1
+ {"version":3,"file":"exec.js","names":["joinPaths"],"sources":["../../../../../utils/src/env/node/exec.ts"],"sourcesContent":["import type { ChildProcess, ExecFileException, ExecFileOptions } from 'child_process';\nimport { execFile, spawn } from 'child_process';\nimport type { Stats } from 'fs';\nimport { access, constants } from 'fs';\nimport { stat } from 'fs/promises';\nimport { join as joinPaths } from 'path';\nimport * as process from 'process';\nimport type { Readable, Writable } from 'stream';\nimport type { CancellationReason } from '../../cancellation.js';\nimport { getScopedLogger, maybeStartScopedLogger } from '../../logger.scoped.js';\nimport { isWindows } from './platform.js';\n\n// -- Error types --\n\ninterface RunErrorContext {\n\tmessage: string;\n\tcmd?: string | undefined;\n\tkilled?: boolean | undefined;\n\tcode?: string | number | null | undefined;\n\tsignal?: NodeJS.Signals | undefined;\n}\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\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 * - 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\n\tif (timeout != null && timeout > 0) {\n\t\tlet timeoutId: ReturnType<typeof setTimeout> | undefined = setTimeout(() => {\n\t\t\tif (timeoutId != null) {\n\t\t\t\ttry {\n\t\t\t\t\tchild.kill();\n\t\t\t\t} catch (ex) {\n\t\t\t\t\tchild.emit('error', ex);\n\t\t\t\t}\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}\n\t\t}, timeout);\n\n\t\tconst clear = () => {\n\t\t\tif (timeoutId != null) {\n\t\t\t\tclearTimeout(timeoutId);\n\t\t\t\ttimeoutId = undefined;\n\t\t\t}\n\t\t};\n\t\t// `'exit'` keeps Node's timing; `'close'` covers a launch that fails and never exits\n\t\tchild.once('exit', clear);\n\t\tchild.once('close', clear);\n\t}\n\n\treturn child;\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 size the output buffer to allocate to the spawned process. Set this\n\t * if you are anticipating a large amount of output.\n\t *\n\t * If not specified, this will be 10MB (10485760 bytes) which should be\n\t * enough for most Git operations.\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: ['pipe', null, null],\n\t\t});\n\t\tconst errorEncoding = encoding === 'buffer' ? 'utf8' : encoding;\n\n\t\tconst stdoutBuffers: Buffer[] = [];\n\t\tproc.stdout?.on('data', (data: Buffer) => stdoutBuffers.push(data));\n\n\t\tconst stderrBuffers: Buffer[] = [];\n\t\tproc.stderr?.on('data', (data: Buffer) => stderrBuffers.push(data));\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\tproc.once('error', async ex => {\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\tconst stdio = getStdio<string>(errorEncoding);\n\t\t\tconst { stdout, stderr } = stdio instanceof Promise ? await stdio : stdio;\n\n\t\t\treject(new RunError(ex, stdout, stderr));\n\t\t});\n\n\t\tproc.once('close', async (code, signal) => {\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)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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,CAAC;EAGD,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"}
@@ -20,6 +20,8 @@ export declare function stripFolderGlob(path: string): string;
20
20
  * split the name across folders wherever the result is used to derive a display name or a tree path.
21
21
  */
22
22
  export declare function trimTrailingSlash(path: string): string;
23
+ /** Trims every trailing `/`, where {@link trimTrailingSlash} trims one. A linear scan, since `/\/+$/` is quadratic on a long run of `/` that doesn't end the string */
24
+ export declare function trimTrailingSlashes(path: string): string;
23
25
  export declare function getBestPath(pathOrUri: string): string;
24
26
  export declare function isChild(path: string, base: string): boolean;
25
27
  export declare function isDescendant(path: string, base: string, ignoreCase?: boolean): boolean;
@@ -75,6 +75,12 @@ function stripFolderGlob(path) {
75
75
  function trimTrailingSlash(path) {
76
76
  return path.endsWith("/") ? path.slice(0, -1) : path;
77
77
  }
78
+ /** Trims every trailing `/`, where {@link trimTrailingSlash} trims one. A linear scan, since `/\/+$/` is quadratic on a long run of `/` that doesn't end the string */
79
+ function trimTrailingSlashes(path) {
80
+ let end = path.length;
81
+ while (end > 0 && path.charCodeAt(end - 1) === slash) end--;
82
+ return end === path.length ? path : path.slice(0, end);
83
+ }
78
84
  function getBestPath(pathOrUri) {
79
85
  if (!hasScheme(pathOrUri)) return normalizePath(pathOrUri);
80
86
  const uri = parseUri(pathOrUri);
@@ -131,6 +137,6 @@ function splitPath(pathOrUri, root, splitOnBaseIfMissing = false, ignoreCase) {
131
137
  return [pathOrUri, root];
132
138
  }
133
139
  //#endregion
134
- export { arePathsEqual, basename, commonBase, commonBaseIndex, dirname, extname, getBestPath, getScheme, isAbsolute, isChild, isDescendant, isFolderGlob, joinPaths, maybeUri, normalizePath, relative, relativeDir, splitPath, stripFolderGlob, trimTrailingSlash };
140
+ export { arePathsEqual, basename, commonBase, commonBaseIndex, dirname, extname, getBestPath, getScheme, isAbsolute, isChild, isDescendant, isFolderGlob, joinPaths, maybeUri, normalizePath, relative, relativeDir, splitPath, stripFolderGlob, trimTrailingSlash, trimTrailingSlashes };
135
141
 
136
142
  //# sourceMappingURL=path.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"path.js","names":["_isAbsolute","basename","dirname"],"sources":["../../../utils/src/path.ts"],"sourcesContent":["import { isAbsolute as _isAbsolute, basename, dirname } from 'path';\nimport { isLinux, isWindows } from './platform.js';\nimport type { Uri } from './uri.js';\nimport { hasScheme, parseUri } from './uri.js';\n\nexport { basename, dirname, extname, join as joinPaths } from 'path';\n\nconst driveLetterNormalizeRegex = /(^\\/?)([a-zA-Z])(?=:\\/)/;\nconst hasSchemeRegex = /^([a-zA-Z][\\w+.-]+):/;\nconst pathNormalizeRegex = /\\\\/g;\nconst slash = 47;\n\nexport function arePathsEqual(a: string, b: string, ignoreCase?: boolean): boolean {\n\tif (ignoreCase || (ignoreCase == null && !isLinux)) {\n\t\ta = a.toLowerCase();\n\t\tb = b.toLowerCase();\n\t}\n\treturn normalizePath(a) === normalizePath(b);\n}\n\nexport function commonBase(s: string[], delimiter: string, ignoreCase?: boolean): string | undefined {\n\tif (s.length === 0) return undefined;\n\n\tlet common = s[0];\n\tfor (let i = 1; i < s.length; i++) {\n\t\tconst index = commonBaseIndex(common, s[i], delimiter, ignoreCase);\n\t\tif (index === 0) return undefined;\n\n\t\tcommon = common.substring(0, index + 1);\n\t}\n\n\treturn common;\n}\n\nexport function commonBaseIndex(s1: string, s2: string, delimiter: string, ignoreCase?: boolean): number {\n\tif (s1.length === 0 || s2.length === 0) return 0;\n\n\tif (ignoreCase ?? !isLinux) {\n\t\ts1 = s1.toLowerCase();\n\t\ts2 = s2.toLowerCase();\n\t}\n\n\tlet char;\n\tlet index = 0;\n\tfor (let i = 0; i < s1.length; i++) {\n\t\tchar = s1[i];\n\t\tif (char !== s2[i]) break;\n\n\t\tif (char === delimiter) {\n\t\t\tindex = i;\n\t\t}\n\t}\n\n\treturn index;\n}\n\nexport function getScheme(path: string): string | undefined {\n\treturn hasSchemeRegex.exec(path)?.[1];\n}\n\nexport function isAbsolute(path: string): boolean {\n\treturn !maybeUri(path) && _isAbsolute(path);\n}\n\nexport function isFolderGlob(path: string): boolean {\n\treturn basename(path) === '*';\n}\n\nexport function maybeUri(path: string): boolean {\n\treturn hasScheme(path);\n}\n\nexport function normalizePath(path: string): string {\n\tif (!path) return path;\n\n\tpath = path.replace(pathNormalizeRegex, '/');\n\tif (path.charCodeAt(path.length - 1) === slash) {\n\t\t// Don't remove the trailing slash on Windows root folders, such as z:\\\n\t\tif (!isWindows || path.length !== 3 || path[1] !== ':') {\n\t\t\tpath = path.slice(0, -1);\n\t\t}\n\t}\n\n\tif (isWindows) {\n\t\t// Ensure that drive casing is normalized (lower case) and no leading slash\n\t\tpath = path.replace(driveLetterNormalizeRegex, (_, _slash, d: string) => d.toLowerCase());\n\t}\n\n\treturn path;\n}\n\nexport function stripFolderGlob(path: string): string {\n\treturn isFolderGlob(path) ? path.slice(0, -2) : path;\n}\n\n/**\n * Trims the trailing slash git puts on an untracked directory that is itself a repository\n * (`nested-repo/`), which it reports as one entry because it can't recurse past the embedded\n * repository boundary. Status is fetched with `-u` (= `all`), so ordinary untracked directories are\n * recursed into and a trailing slash identifies the nested-repository case unambiguously.\n *\n * Deliberately not {@link normalizePath}, which also rewrites backslashes: git paths always use `/`,\n * so a backslash here is a literal character in a (POSIX-legal) filename, and rewriting it would\n * split the name across folders wherever the result is used to derive a display name or a tree path.\n */\nexport function trimTrailingSlash(path: string): string {\n\treturn path.endsWith('/') ? path.slice(0, -1) : path;\n}\n\nexport function getBestPath(pathOrUri: string): string {\n\tif (!hasScheme(pathOrUri)) return normalizePath(pathOrUri);\n\n\tconst uri = parseUri(pathOrUri);\n\treturn normalizePath(uri.scheme === 'file' ? uri.fsPath : uri.path);\n}\n\nexport function isChild(path: string, base: string): boolean {\n\tif (!base.startsWith('/')) {\n\t\tbase = `/${base}`;\n\t}\n\n\treturn (\n\t\tisDescendant(path, base) && path.substring(base.length + (base.endsWith('/') ? 0 : 1)).split('/').length === 1\n\t);\n}\n\nexport function isDescendant(path: string, base: string, ignoreCase?: boolean): boolean {\n\tlet basePath = getBestPath(base);\n\tif (!basePath.startsWith('/')) {\n\t\tbasePath = `${basePath}/`;\n\t}\n\n\t// Handles folder globs and ensure ending with a trailing slash\n\tif (basePath.endsWith('/*')) {\n\t\tbasePath = basePath.substring(0, basePath.length - 1);\n\t} else if (!basePath.endsWith('/')) {\n\t\tbasePath = `${basePath}/`;\n\t}\n\n\tlet p = getBestPath(path);\n\tif (!p.startsWith('/')) {\n\t\tp = `${p}/`;\n\t}\n\n\tif (ignoreCase ?? !isLinux) {\n\t\tbasePath = basePath.toLowerCase();\n\t\tp = p.toLowerCase();\n\t}\n\n\treturn p.startsWith(basePath);\n}\n\nexport function relative(from: string, to: string, ignoreCase?: boolean): string {\n\tfrom = hasScheme(from) ? parseUri(from).path : normalizePath(from);\n\tto = hasScheme(to) ? parseUri(to).path : normalizePath(to);\n\n\tconst index = commonBaseIndex(`${to}/`, `${from}/`, '/', ignoreCase);\n\treturn index > 0 ? to.substring(index + 1) : to;\n}\n\nexport function relativeDir(relativePath: string, relativeTo?: string): string {\n\tconst dirPath = dirname(relativePath);\n\tif (!dirPath || dirPath === '.' || dirPath === relativeTo) return '';\n\tif (!relativeTo) return dirPath;\n\n\tconst [relativeDirPath] = splitPath(dirPath, relativeTo);\n\treturn relativeDirPath;\n}\n\nexport function splitPath(\n\tpathOrUri: string,\n\troot: string | undefined,\n\tsplitOnBaseIfMissing: boolean = false,\n\tignoreCase?: boolean,\n): [path: string, root: string] {\n\tpathOrUri = getBestPath(pathOrUri);\n\n\tif (root) {\n\t\tlet repoUri: Uri | undefined;\n\t\tif (hasScheme(root)) {\n\t\t\trepoUri = parseUri(root);\n\t\t\troot = getBestPath(root);\n\t\t} else {\n\t\t\troot = normalizePath(root);\n\t\t}\n\n\t\tconst index = commonBaseIndex(`${root}/`, `${pathOrUri}/`, '/', ignoreCase);\n\t\tif (index > 0) {\n\t\t\troot = pathOrUri.substring(0, index);\n\t\t\tpathOrUri = pathOrUri.substring(index + 1);\n\t\t} else if (pathOrUri.startsWith('/')) {\n\t\t\tpathOrUri = pathOrUri.slice(1);\n\t\t}\n\n\t\tif (repoUri != null) {\n\t\t\troot = repoUri.with({ path: root }).toString();\n\t\t}\n\t} else {\n\t\troot = normalizePath(splitOnBaseIfMissing ? dirname(pathOrUri) : '');\n\t\tpathOrUri = splitOnBaseIfMissing ? basename(pathOrUri) : pathOrUri;\n\t}\n\n\treturn [pathOrUri, root];\n}\n"],"mappings":";;;;AAOA,MAAM,4BAA4B;AAClC,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC3B,MAAM,QAAQ;AAEd,SAAgB,cAAc,GAAW,GAAW,YAA+B;CAClF,IAAI,cAAe,cAAc,QAAQ,CAAC,SAAU;EACnD,IAAI,EAAE,YAAY;EAClB,IAAI,EAAE,YAAY;CACnB;CACA,OAAO,cAAc,CAAC,MAAM,cAAc,CAAC;AAC5C;AAEA,SAAgB,WAAW,GAAa,WAAmB,YAA0C;CACpG,IAAI,EAAE,WAAW,GAAG,OAAO,KAAA;CAE3B,IAAI,SAAS,EAAE;CACf,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;EAClC,MAAM,QAAQ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AgB,GAAG,GAAG,IAAI,GAAG,KAAK,IAAI,KAAK,UAAU;CACnE,OAAO,QAAQ,IAAI,GAAG,UAAU,QAAQ,CAAC,IAAI;AAC9C;AAEA,SAAgB,YAAY,cAAsB,YAA6B;CAC9E,MAAM,UAAUC,UAAQ,YAAY;CACpC,IAAI,CAAC,WAAW,YAAY,OAAO,YAAY,YAAY,OAAO;CAClE,IAAI,CAAC,YAAY,OAAO;CAExB,MAAM,CAAC,mBAAmB,UAAU,SAAS,UAAU;CACvD,OAAO;AACR;AAEA,SAAgB,UACf,WACA,MACA,uBAAgC,OAChC,YAC+B;CAC/B,YAAY,YAAY,SAAS;CAEjC,IAAI,MAAM;EACT,IAAI;EACJ,IAAI,UAAU,IAAI,GAAG;GACpB,UAAU,SAAS,IAAI;GACvB,OAAO,YAAY,IAAI;EACxB,OACC,OAAO,cAAc,IAAI;EAG1B,MAAM,QAAQ,gBAAgB,GAAG,KAAK,IAAI,GAAG,UAAU,IAAI,KAAK,UAAU;EAC1E,IAAI,QAAQ,GAAG;GACd,OAAO,UAAU,UAAU,GAAG,KAAK;GACnC,YAAY,UAAU,UAAU,QAAQ,CAAC;EAC1C,OAAO,IAAI,UAAU,WAAW,GAAG,GAClC,YAAY,UAAU,MAAM,CAAC;EAG9B,IAAI,WAAW,MACd,OAAO,QAAQ,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,SAAS;CAE/C,OAAO;EACN,OAAO,cAAc,uBAAuBA,UAAQ,SAAS,IAAI,EAAE;EACnE,YAAY,uBAAuBD,WAAS,SAAS,IAAI;CAC1D;CAEA,OAAO,CAAC,WAAW,IAAI;AACxB"}
1
+ {"version":3,"file":"path.js","names":["_isAbsolute","basename","dirname"],"sources":["../../../utils/src/path.ts"],"sourcesContent":["import { isAbsolute as _isAbsolute, basename, dirname } from 'path';\nimport { isLinux, isWindows } from './platform.js';\nimport type { Uri } from './uri.js';\nimport { hasScheme, parseUri } from './uri.js';\n\nexport { basename, dirname, extname, join as joinPaths } from 'path';\n\nconst driveLetterNormalizeRegex = /(^\\/?)([a-zA-Z])(?=:\\/)/;\nconst hasSchemeRegex = /^([a-zA-Z][\\w+.-]+):/;\nconst pathNormalizeRegex = /\\\\/g;\nconst slash = 47;\n\nexport function arePathsEqual(a: string, b: string, ignoreCase?: boolean): boolean {\n\tif (ignoreCase || (ignoreCase == null && !isLinux)) {\n\t\ta = a.toLowerCase();\n\t\tb = b.toLowerCase();\n\t}\n\treturn normalizePath(a) === normalizePath(b);\n}\n\nexport function commonBase(s: string[], delimiter: string, ignoreCase?: boolean): string | undefined {\n\tif (s.length === 0) return undefined;\n\n\tlet common = s[0];\n\tfor (let i = 1; i < s.length; i++) {\n\t\tconst index = commonBaseIndex(common, s[i], delimiter, ignoreCase);\n\t\tif (index === 0) return undefined;\n\n\t\tcommon = common.substring(0, index + 1);\n\t}\n\n\treturn common;\n}\n\nexport function commonBaseIndex(s1: string, s2: string, delimiter: string, ignoreCase?: boolean): number {\n\tif (s1.length === 0 || s2.length === 0) return 0;\n\n\tif (ignoreCase ?? !isLinux) {\n\t\ts1 = s1.toLowerCase();\n\t\ts2 = s2.toLowerCase();\n\t}\n\n\tlet char;\n\tlet index = 0;\n\tfor (let i = 0; i < s1.length; i++) {\n\t\tchar = s1[i];\n\t\tif (char !== s2[i]) break;\n\n\t\tif (char === delimiter) {\n\t\t\tindex = i;\n\t\t}\n\t}\n\n\treturn index;\n}\n\nexport function getScheme(path: string): string | undefined {\n\treturn hasSchemeRegex.exec(path)?.[1];\n}\n\nexport function isAbsolute(path: string): boolean {\n\treturn !maybeUri(path) && _isAbsolute(path);\n}\n\nexport function isFolderGlob(path: string): boolean {\n\treturn basename(path) === '*';\n}\n\nexport function maybeUri(path: string): boolean {\n\treturn hasScheme(path);\n}\n\nexport function normalizePath(path: string): string {\n\tif (!path) return path;\n\n\tpath = path.replace(pathNormalizeRegex, '/');\n\tif (path.charCodeAt(path.length - 1) === slash) {\n\t\t// Don't remove the trailing slash on Windows root folders, such as z:\\\n\t\tif (!isWindows || path.length !== 3 || path[1] !== ':') {\n\t\t\tpath = path.slice(0, -1);\n\t\t}\n\t}\n\n\tif (isWindows) {\n\t\t// Ensure that drive casing is normalized (lower case) and no leading slash\n\t\tpath = path.replace(driveLetterNormalizeRegex, (_, _slash, d: string) => d.toLowerCase());\n\t}\n\n\treturn path;\n}\n\nexport function stripFolderGlob(path: string): string {\n\treturn isFolderGlob(path) ? path.slice(0, -2) : path;\n}\n\n/**\n * Trims the trailing slash git puts on an untracked directory that is itself a repository\n * (`nested-repo/`), which it reports as one entry because it can't recurse past the embedded\n * repository boundary. Status is fetched with `-u` (= `all`), so ordinary untracked directories are\n * recursed into and a trailing slash identifies the nested-repository case unambiguously.\n *\n * Deliberately not {@link normalizePath}, which also rewrites backslashes: git paths always use `/`,\n * so a backslash here is a literal character in a (POSIX-legal) filename, and rewriting it would\n * split the name across folders wherever the result is used to derive a display name or a tree path.\n */\nexport function trimTrailingSlash(path: string): string {\n\treturn path.endsWith('/') ? path.slice(0, -1) : path;\n}\n\n/** Trims every trailing `/`, where {@link trimTrailingSlash} trims one. A linear scan, since `/\\/+$/` is quadratic on a long run of `/` that doesn't end the string */\nexport function trimTrailingSlashes(path: string): string {\n\tlet end = path.length;\n\twhile (end > 0 && path.charCodeAt(end - 1) === slash) {\n\t\tend--;\n\t}\n\treturn end === path.length ? path : path.slice(0, end);\n}\n\nexport function getBestPath(pathOrUri: string): string {\n\tif (!hasScheme(pathOrUri)) return normalizePath(pathOrUri);\n\n\tconst uri = parseUri(pathOrUri);\n\treturn normalizePath(uri.scheme === 'file' ? uri.fsPath : uri.path);\n}\n\nexport function isChild(path: string, base: string): boolean {\n\tif (!base.startsWith('/')) {\n\t\tbase = `/${base}`;\n\t}\n\n\treturn (\n\t\tisDescendant(path, base) && path.substring(base.length + (base.endsWith('/') ? 0 : 1)).split('/').length === 1\n\t);\n}\n\nexport function isDescendant(path: string, base: string, ignoreCase?: boolean): boolean {\n\tlet basePath = getBestPath(base);\n\tif (!basePath.startsWith('/')) {\n\t\tbasePath = `${basePath}/`;\n\t}\n\n\t// Handles folder globs and ensure ending with a trailing slash\n\tif (basePath.endsWith('/*')) {\n\t\tbasePath = basePath.substring(0, basePath.length - 1);\n\t} else if (!basePath.endsWith('/')) {\n\t\tbasePath = `${basePath}/`;\n\t}\n\n\tlet p = getBestPath(path);\n\tif (!p.startsWith('/')) {\n\t\tp = `${p}/`;\n\t}\n\n\tif (ignoreCase ?? !isLinux) {\n\t\tbasePath = basePath.toLowerCase();\n\t\tp = p.toLowerCase();\n\t}\n\n\treturn p.startsWith(basePath);\n}\n\nexport function relative(from: string, to: string, ignoreCase?: boolean): string {\n\tfrom = hasScheme(from) ? parseUri(from).path : normalizePath(from);\n\tto = hasScheme(to) ? parseUri(to).path : normalizePath(to);\n\n\tconst index = commonBaseIndex(`${to}/`, `${from}/`, '/', ignoreCase);\n\treturn index > 0 ? to.substring(index + 1) : to;\n}\n\nexport function relativeDir(relativePath: string, relativeTo?: string): string {\n\tconst dirPath = dirname(relativePath);\n\tif (!dirPath || dirPath === '.' || dirPath === relativeTo) return '';\n\tif (!relativeTo) return dirPath;\n\n\tconst [relativeDirPath] = splitPath(dirPath, relativeTo);\n\treturn relativeDirPath;\n}\n\nexport function splitPath(\n\tpathOrUri: string,\n\troot: string | undefined,\n\tsplitOnBaseIfMissing: boolean = false,\n\tignoreCase?: boolean,\n): [path: string, root: string] {\n\tpathOrUri = getBestPath(pathOrUri);\n\n\tif (root) {\n\t\tlet repoUri: Uri | undefined;\n\t\tif (hasScheme(root)) {\n\t\t\trepoUri = parseUri(root);\n\t\t\troot = getBestPath(root);\n\t\t} else {\n\t\t\troot = normalizePath(root);\n\t\t}\n\n\t\tconst index = commonBaseIndex(`${root}/`, `${pathOrUri}/`, '/', ignoreCase);\n\t\tif (index > 0) {\n\t\t\troot = pathOrUri.substring(0, index);\n\t\t\tpathOrUri = pathOrUri.substring(index + 1);\n\t\t} else if (pathOrUri.startsWith('/')) {\n\t\t\tpathOrUri = pathOrUri.slice(1);\n\t\t}\n\n\t\tif (repoUri != null) {\n\t\t\troot = repoUri.with({ path: root }).toString();\n\t\t}\n\t} else {\n\t\troot = normalizePath(splitOnBaseIfMissing ? dirname(pathOrUri) : '');\n\t\tpathOrUri = splitOnBaseIfMissing ? basename(pathOrUri) : pathOrUri;\n\t}\n\n\treturn [pathOrUri, root];\n}\n"],"mappings":";;;;AAOA,MAAM,4BAA4B;AAClC,MAAM,iBAAiB;AACvB,MAAM,qBAAqB;AAC3B,MAAM,QAAQ;AAEd,SAAgB,cAAc,GAAW,GAAW,YAA+B;CAClF,IAAI,cAAe,cAAc,QAAQ,CAAC,SAAU;EACnD,IAAI,EAAE,YAAY;EAClB,IAAI,EAAE,YAAY;CACnB;CACA,OAAO,cAAc,CAAC,MAAM,cAAc,CAAC;AAC5C;AAEA,SAAgB,WAAW,GAAa,WAAmB,YAA0C;CACpG,IAAI,EAAE,WAAW,GAAG,OAAO,KAAA;CAE3B,IAAI,SAAS,EAAE;CACf,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;EAClC,MAAM,QAAQ,gBAAgB,QAAQ,EAAE,IAAI,WAAW,UAAU;EACjE,IAAI,UAAU,GAAG,OAAO,KAAA;EAExB,SAAS,OAAO,UAAU,GAAG,QAAQ,CAAC;CACvC;CAEA,OAAO;AACR;AAEA,SAAgB,gBAAgB,IAAY,IAAY,WAAmB,YAA8B;CACxG,IAAI,GAAG,WAAW,KAAK,GAAG,WAAW,GAAG,OAAO;CAE/C,IAAI,cAAc,CAAC,SAAS;EAC3B,KAAK,GAAG,YAAY;EACpB,KAAK,GAAG,YAAY;CACrB;CAEA,IAAI;CACJ,IAAI,QAAQ;CACZ,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,QAAQ,KAAK;EACnC,OAAO,GAAG;EACV,IAAI,SAAS,GAAG,IAAI;EAEpB,IAAI,SAAS,WACZ,QAAQ;CAEV;CAEA,OAAO;AACR;A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,UACf,WACA,MACA,uBAAgC,OAChC,YAC+B;CAC/B,YAAY,YAAY,SAAS;CAEjC,IAAI,MAAM;EACT,IAAI;EACJ,IAAI,UAAU,IAAI,GAAG;GACpB,UAAU,SAAS,IAAI;GACvB,OAAO,YAAY,IAAI;EACxB,OACC,OAAO,cAAc,IAAI;EAG1B,MAAM,QAAQ,gBAAgB,GAAG,KAAK,IAAI,GAAG,UAAU,IAAI,KAAK,UAAU;EAC1E,IAAI,QAAQ,GAAG;GACd,OAAO,UAAU,UAAU,GAAG,KAAK;GACnC,YAAY,UAAU,UAAU,QAAQ,CAAC;EAC1C,OAAO,IAAI,UAAU,WAAW,GAAG,GAClC,YAAY,UAAU,MAAM,CAAC;EAG9B,IAAI,WAAW,MACd,OAAO,QAAQ,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,SAAS;CAE/C,OAAO;EACN,OAAO,cAAc,uBAAuBA,UAAQ,SAAS,IAAI,EAAE;EACnE,YAAY,uBAAuBD,WAAS,SAAS,IAAI;CAC1D;CAEA,OAAO,CAAC,WAAW,IAAI;AACxB"}
@@ -128,7 +128,7 @@ it with `page` + `hasMore` + `cursor?`. **No read throws for a provider-side fai
128
128
  | `getIssuesBatch` | `IssueBatchResult` | Resolves N issues by coordinate or tracker identifier; an absence is proven. |
129
129
  | `getPullRequestsBatch` | `PullRequestBatchResult` | Resolves N PRs by `(owner, repo, number)`, in any state; an absence is proven. |
130
130
  | `getPullRequestsForBranches` | `PullRequestBranchResult` | Each branch's PRs, in any state and fork-aware; an empty list is a proven none. |
131
- | `listIssueTrackerIssuesPage` | `IssueShape` | Jira (Cloud + Data Center) / Linear / Trello (issues live under resource → project). |
131
+ | `listIssueTrackerIssuesPage` | `IssueShape` | Jira (Cloud + Data Center) / Linear / Trello / Asana (issues live under resource → project). |
132
132
  | `sweepPullRequests` | `ProviderSweepResult` | Drains **every** page across providers (`maxPages`, default 100). |
133
133
  | `sweepClosedPullRequests` | `ProviderSweepResult` | Same, pinned to `['closed','merged']`. |
134
134
  | `broadenIssues` | `ProviderBroadenResult` | Per-org fan-out for every visible issue, unfiltered by assignee. |
@@ -405,7 +405,8 @@ What holds for all of them:
405
405
  - **Substitutions.** Azure DevOps has no pull request assignees: both of its converters fill `assignees` with the
406
406
  reviewers, which `reviews` and `reviewRequests` already hold, so `assignees` is `unavailable` there. Votes are not
407
407
  reactions: a Jira issue's or Trello card's votes, and a Bitbucket issue's, land in `thumbsUpCount` (and read 0
408
- where voting is off), so `reactions` is `unavailable` for them. A GitLab upvote is a thumbs-up award, so it counts.
408
+ where voting is off), so `reactions` is `unavailable` for them. A GitLab upvote is a thumbs-up award, so it counts,
409
+ and so does an Asana like, which is a thumbs-up on the task.
409
410
  - **Placeholders.** GitLens' own reads leave a field they didn't fetch `undefined`, but provider-apis' converters,
410
411
  which GitLens doesn't own, still fill some: Bitbucket's and Bitbucket Data Center's `mergeableState` is a literal
411
412
  Mergeable, GitLab turns a null count into 0, Linear's `labels` is an empty list, and an Azure DevOps work item's
@@ -555,12 +556,25 @@ What holds for all of them:
555
556
  | reactions | unavailable | unavailable |
556
557
  | access | unavailable | unavailable |
557
558
 
559
+ <!-- field-presence: asana-issues -->
560
+
561
+ | Group | point | account | project |
562
+ | ----------- | ------------- | ------------- | ------------- |
563
+ | description | fetched | fetched | fetched |
564
+ | assignees | fetched | fetched | fetched |
565
+ | labels | fetched | fetched | fetched |
566
+ | comments | not-requested | not-requested | not-requested |
567
+ | reactions | fetched | fetched | fetched |
568
+ | access | unavailable | unavailable | unavailable |
569
+
558
570
  - Tracker issues belong to no repository, so `access` is `unavailable`.
559
571
  - provider-apis' Jira converter counts the comments embedded in the issue rather than reading their total, so only
560
572
  Jira Cloud's batch read, which is GitLens' own by-key read, has a comment count. Jira Data Center's batch read goes
561
573
  through provider-apis.
562
574
  - provider-apis' Linear fragment selects no labels (it fills an empty list), comments or reactions.
563
575
  - A Trello card's description is never read. Trello has no batch or account-wide read.
576
+ - An Asana task's tags are its labels and its likes, a thumbs-up on the task, its reactions. Its comments are stories, which a task doesn't
577
+ count, so reading them would cost a request per task. Asana has no batch read.
564
578
 
565
579
  ## 5. Paging
566
580
 
@@ -1080,12 +1094,16 @@ one.
1080
1094
 
1081
1095
  `resolveRepository` reports through `resolution.status` instead: `resolved` · `not-found` · `unauthorized` ·
1082
1096
  `unsupported-provider` · `invalid-remote-url` · `host-mismatch` · `undetermined`. A `resolved` identity
1083
- carries the provider's **canonical** owner/name plus `renamed: true` when the local remote is stale.
1097
+ carries the provider's **canonical** owner/name plus `renamed: true` when the local remote is stale (on Azure DevOps,
1098
+ when the repository or its project is named differently from where it was read). Owner and name are compared as one
1099
+ path, because the remote and the provider split a GitLab nested group differently. GitLab's lookup doesn't follow a
1100
+ renamed or moved path, so a stale GitLab remote is `not-found` rather than `renamed`.
1084
1101
  It also carries `isFork` and `parent` (the repository a fork was made from, on the same host; `project` only on Azure
1085
- DevOps) for GitHub, GitHub Enterprise, Bitbucket Cloud, Bitbucket Data Center and Azure DevOps, when the
1086
- `@gitkraken/provider-apis` repository returns `isFork` and `parent`, which it does not yet (a consumer can patch the
1087
- SDK to return them). Only `isFork: false` means "not a fork": an identity with no `parent` and no `isFork` is a provider
1088
- that didn't say.
1102
+ DevOps) for GitHub, GitHub Enterprise, Bitbucket Cloud, Bitbucket Data Center, Azure DevOps and gitlab.com, where a
1103
+ nested group is part of the owner (`group/subgroup`). Self-managed GitLab reports neither, because the field that names
1104
+ the parent needs GitLab 17.10 and an older server rejects the whole query. Only `isFork: false` means "not a fork": an
1105
+ identity with no `parent` and no `isFork` is a provider that didn't say, and `isFork: true` with no `parent` is a fork
1106
+ whose parent the provider didn't name (for example, one the token can't see).
1089
1107
 
1090
1108
  ## 7. Filters are all-or-nothing
1091
1109
 
@@ -1124,7 +1142,9 @@ const filters = wanted.filter(f => capability.includes(f));
1124
1142
  filtered issue search reports empty `relationships` and all-false flags, which is the signal to hide the
1125
1143
  surface rather than individual chips.
1126
1144
  - `issueStates` — whether the issue-tracker reads take a `state` other than open (`'closed'`, `'all'`). True for
1127
- Jira, Jira Data Center and Linear, which narrow server-side on every page of their drains; false for Trello,
1145
+ Jira, Jira Data Center and Linear, which narrow server-side on every page of their drains, and for Asana, whose
1146
+ only state is completion (an open read leaves completed tasks out server-side; a closed one is filtered from every
1147
+ task, so its pages can come back short); false for Trello,
1128
1148
  which can only read open cards and refuses the other two (warning + `fetchFailed`). An omitted `state` reads
1129
1149
  open issues on every tracker.
1130
1150
 
@@ -1215,30 +1235,30 @@ Derived from the provider models and `providersMetadata`. ✓ supported · ✗ r
1215
1235
  (warning + `fetchFailed`) · — not applicable. Self-managed variants inherit their cloud family's hooks unless a
1216
1236
  footnote says otherwise.
1217
1237
 
1218
- | Surface | GitHub / GHE | GitLab / self-hosted | Bitbucket | Bitbucket DC | Azure DevOps (+ Server) | Jira (+ DC) | Linear | Trello |
1219
- | ---------------------------- | :----------: | :------------------: | :-------: | :----------: | :---------------------: | :---------: | :----: | :----: |
1220
- | `listOrgs` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
1221
- | `listProjects` | — | — | — | — | ✓ | ✓ | ✓ | ✓ |
1222
- | `listLinearProjects` | — | — | — | — | — | — | ✓ | — |
1223
- | `listRepos` (`org`) | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
1224
- | `listRepos` (account-wide) | ✓ | ✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ |
1225
- | PRs, repo-scoped | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
1226
- | PRs, account-wide | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
1227
- | PR `states` account-wide | ✓ | ✓ | ✓ | ✓ | ✓ | — | — | — |
1228
- | `searchPullRequestsPage` | ✓ | ✗ | ✗ | ✓ | ✗² | ✗ | ✗ | ✗ |
1229
- | `countPullRequests` | ✓ | ✗ | ✗ | ✓ | ✗² | ✗ | ✗ | ✗ |
1230
- | Issues, repo-scoped | ✓ | ✓ | ✗ | ✗ | ✓ | — | — | — |
1231
- | Issues, account-wide | ✓ | ✓ | ✗ | ✗ | ✓ | — | — | — |
1232
- | `searchIssuesPage` | ✓ | ✗ | ✗ | ✗ | ✗² | ✗ | ✗ | ✗ |
1233
- | `countIssues` | ✓ | ✗ | ✗ | ✗ | ✗² | ✗ | ✗ | ✗ |
1234
- | `getIssuesBatch` | ✓ | ✓ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ |
1235
- | `getPullRequestsBatch` | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
1236
- | `getPullRequestsForBranches` | ✓ | ✓ | ✓ | ✓¹ | ✓¹ | ✗ | ✗ | ✗ |
1237
- | Issues by `org`/`project` | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ |
1238
- | `listIssueTrackerIssuesPage` | — | — | — | — | — | ✓ | ✓ | ✓ |
1239
- | `broadenIssues` | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | ✗ |
1240
- | `resolveRepository` | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ |
1241
- | `getCurrentAccount` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
1238
+ | Surface | GitHub / GHE | GitLab / self-hosted | Bitbucket | Bitbucket DC | Azure DevOps (+ Server) | Jira (+ DC) | Linear | Trello | Asana |
1239
+ | ---------------------------- | :----------: | :------------------: | :-------: | :----------: | :---------------------: | :---------: | :----: | :----: | :---: |
1240
+ | `listOrgs` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
1241
+ | `listProjects` | — | — | — | — | ✓ | ✓ | ✓ | ✓ | ✓ |
1242
+ | `listLinearProjects` | — | — | — | — | — | — | ✓ | — | — |
1243
+ | `listRepos` (`org`) | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
1244
+ | `listRepos` (account-wide) | ✓ | ✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ |
1245
+ | PRs, repo-scoped | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
1246
+ | PRs, account-wide | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
1247
+ | PR `states` account-wide | ✓ | ✓ | ✓ | ✓ | ✓ | — | — | — | — |
1248
+ | `searchPullRequestsPage` | ✓ | ✗ | ✗ | ✓ | ✗² | ✗ | ✗ | ✗ | ✗ |
1249
+ | `countPullRequests` | ✓ | ✗ | ✗ | ✓ | ✗² | ✗ | ✗ | ✗ | ✗ |
1250
+ | Issues, repo-scoped | ✓ | ✓ | ✗ | ✗ | ✓ | — | — | — | — |
1251
+ | Issues, account-wide | ✓ | ✓ | ✗ | ✗ | ✓ | — | — | — | — |
1252
+ | `searchIssuesPage` | ✓ | ✗ | ✗ | ✗ | ✗² | ✗ | ✗ | ✗ | ✗ |
1253
+ | `countIssues` | ✓ | ✗ | ✗ | ✗ | ✗² | ✗ | ✗ | ✗ | ✗ |
1254
+ | `getIssuesBatch` | ✓ | ✓ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ | ✗ |
1255
+ | `getPullRequestsBatch` | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
1256
+ | `getPullRequestsForBranches` | ✓ | ✓ | ✓ | ✓¹ | ✓¹ | ✗ | ✗ | ✗ | ✗ |
1257
+ | Issues by `org`/`project` | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✓ | ✓ |
1258
+ | `listIssueTrackerIssuesPage` | — | — | — | — | — | ✓ | ✓ | ✓ | ✓ |
1259
+ | `broadenIssues` | ✓ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ |
1260
+ | `resolveRepository` | ✓ | ✓ | ✓ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ |
1261
+ | `getCurrentAccount` | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
1242
1262
 
1243
1263
  Bitbucket Data Center exposes its projects through `listOrgs`: both `id` and `name` are the project key.
1244
1264
  Pass that key as `org` to `listRepos` to select a project, or omit `org` to enumerate all accessible repositories,
@@ -1310,7 +1330,7 @@ as "unset". The sort vocabulary is narrower than the issue search's on purpose:
1310
1330
  by a field a normalized pull request carries, and GitHub PRs have neither a priority nor a relevance that ranks
1311
1331
  stably under the result ceiling.
1312
1332
  Issue filters: GitHub/GHE + Azure + Jira `Author, Assignee, Mention` · GitLab `Author, Assignee` ·
1313
- Linear + Trello `Assignee` · Bitbucket family none. With no filter, Linear's user-scoped tracker read is the viewer's
1333
+ Linear + Trello + Asana `Assignee` · Bitbucket family none. With no filter, Linear's user-scoped tracker read is the viewer's
1314
1334
  assigned issues plus the GitHub-synced issues the viewer created (a GitHub issue attachment, and `syncedWith` not
1315
1335
  `[]`), since Linear's GitHub Issues sync gives the copy of a GitHub issue its author (when linked) as creator but no
1316
1336
  assignee; `Assignee` by name reads the assigned issues only.
@@ -1348,6 +1368,7 @@ present where the provider supplies it:
1348
1368
  | Jira DC | Status name | Yes | Yes, from the stable status-category key |
1349
1369
  | Linear | Workflow state name | Yes | Yes, mapped from the Linear state type |
1350
1370
  | Trello | Card list name | No | No |
1371
+ | Asana | Section name | No | `DONE` once the task is completed |
1351
1372
  | Azure DevOps | Work-item state | No | Yes, from the work item type's states |
1352
1373
  | GitHub | `open` / `closed` | No | No |
1353
1374
  | GitLab | `opened` / `closed` | No | No |
@@ -1548,18 +1569,26 @@ Markdown by this package.
1548
1569
  Azure's close date (or creation date while open), since Azure reports no last-activity date. `itemsPerPage`
1549
1570
  is per page here, not per facet. A repository name of `.` or `..` is refused rather than resolved as a path.
1550
1571
 
1551
- - **Jira (Cloud + Data Center) / Linear / Trello** — paged by **project**, not by issue: `itemsPerPage` counts projects (default
1572
+ - **Jira (Cloud + Data Center) / Linear / Trello / Asana** — paged by **project**, not by issue: `itemsPerPage` counts projects (default
1552
1573
  20), each drained in full. Passing none of `page`/`cursor`/`itemsPerPage` aggregates every matched project
1553
1574
  in one page. A single project exceeding its internal drain backstop shows up as `page.truncated`. On Jira it gets a
1554
1575
  warning of its own, naming it in its message and its `omission.scope`, published even when another project failed
1555
1576
  (when a request of the read failed, the omission is retracted as on every read, and only the message names it);
1556
- Linear and Trello report one warning for the page, only when nothing failed.
1577
+ Linear, Trello and Asana report one warning for the page, only when nothing failed.
1557
1578
  A Jira issue `@gitkraken/provider-apis` can't read is dropped from its page and reported instead: its siblings are
1558
1579
  served, with `fetchFailed`, an `unreadable-items` warning scoped to its project and naming its key, and
1559
1580
  `page.truncated` (never `narrow-scope`); a project that dropped one is not retried.
1560
1581
  Trello's issue `id` is the card's `idShort` — unique per board only, so correlate across boards by
1561
1582
  `nodeId`. For Trello, boards are both the resource and the project, so `listOrgs` and `listProjects`
1562
- return the same set; Linear's resource is the organization and its projects are teams.
1583
+ return the same set; Linear's resource is the organization and its projects are teams. Asana's resources are the
1584
+ workspaces and its projects their unarchived projects; an Asana task's `id` is its gid, unique across Asana.
1585
+ Asana's task list takes a project or an assignee but not both, so a user-scoped Asana read reads the viewer's tasks
1586
+ once per workspace and splits them into its projects: a task in no project, or only in a project outside the read,
1587
+ is not in it. provider-apis reports only the first project Asana lists for a task, so a task in several projects is
1588
+ listed under that one alone, and is missing from the read when that project isn't in it (archived, beyond
1589
+ discovery, or not selected), even if another of its projects is. When that read can't finish, each project is
1590
+ drained and filtered to the viewer instead, which lists such a task under every requested project it is in, and a
1591
+ project busy enough to reach its backstop is `page.truncated` with no narrower scope to retry.
1563
1592
  Linear's own Projects (Linear's `Project` entity, which can span teams) are a separate read, `listLinearProjects`:
1564
1593
  drained across Linear's pages up to 2,000, cached per connection for five minutes or until `forceSync`, and
1565
1594
  reported `fetchFailed` with a warning when the drain could not finish. Pass their `id`s as
@@ -1577,13 +1606,13 @@ Markdown by this package.
1577
1606
  error is incomplete, not an empty account: the page is `page.truncated` with a retry cursor and a "completeness
1578
1607
  could not be confirmed" warning, and `listOrgs` / `listProjects` report the provider `fetchFailed`. A discovery
1579
1608
  answering `[]` means no resources, and an unconnected tracker reads as empty.
1580
- `org` and `project` select by identifier. Linear and Trello match any of a resource's or project's id, name or
1581
- key. Jira (Cloud and Data Center) matches only the canonical key, so a selection whose site or project was removed
1582
- selects nothing instead of resolving to another one that carries the old value as a name or id. A selector that
1583
- matches nothing returns an empty page with a `selector` warning (see `selector` above). For Jira, `org` is the site's
1584
- id (`listOrgs`' `id`, or `listProjects`' `orgId`), never its label, and `project` is the project key, which is
1585
- `listProjects`' `name` for Jira. `listProjects({ org })` itself still matches any identifier, since it only lists
1586
- what a caller can then select.
1609
+ `org` and `project` select by identifier. Linear and Trello match any of a resource's or project's id, name or key.
1610
+ Jira (Cloud and Data Center) matches only the canonical key, and Asana only the gid, so a removed selection matches
1611
+ nothing instead of resolving to another resource that carries the old value as a name or id. A selector that matches
1612
+ nothing returns an empty page with a `selector` warning (see `selector` above). For Jira, `org` is the site's id
1613
+ (`listOrgs`' `id`, or `listProjects`' `orgId`), never its label, and `project` is the project key, which is
1614
+ `listProjects`' `name` for Jira. For Asana, pass the workspace or project gid, never its display name.
1615
+ `listProjects({ org })` itself still matches any identifier, since it only lists what a caller can then select.
1587
1616
 
1588
1617
  Self-managed descriptors keep `domain` as the normalized host and expose the configured installation address
1589
1618
  in `baseUrl`. Provider requests use the selected connection's address, including during account discovery.
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.28.0",
4
+ "version": "0.30.0",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "author": {
7
7
  "name": "GitKraken",
@@ -259,7 +259,7 @@
259
259
  }
260
260
  },
261
261
  "dependencies": {
262
- "@gitkraken/provider-apis": "0.65.7",
262
+ "@gitkraken/provider-apis": "0.67.0",
263
263
  "@octokit/graphql": "9.0.4",
264
264
  "@octokit/request": "10.0.14",
265
265
  "@octokit/request-error": "7.1.1",