Преглед изворни кода

fix: patch arborist to get around bun bug (#23460)

Aiden Cline пре 15 часа
родитељ
комит
e539efe2b9

+ 4 - 0
bun.lock

@@ -354,6 +354,7 @@
         "@lydell/node-pty": "catalog:",
         "@modelcontextprotocol/sdk": "1.27.1",
         "@npmcli/arborist": "9.4.0",
+        "@npmcli/config": "10.8.1",
         "@octokit/graphql": "9.0.2",
         "@octokit/rest": "catalog:",
         "@openauthjs/openauth": "catalog:",
@@ -660,6 +661,7 @@
   "patchedDependencies": {
     "[email protected]": "patches/[email protected]",
     "@standard-community/[email protected]": "patches/@standard-community%[email protected]",
+    "@npmcli/[email protected]": "patches/@npmcli%[email protected]",
   },
   "overrides": {
     "@types/bun": "catalog:",
@@ -1468,6 +1470,8 @@
 
     "@npmcli/arborist": ["@npmcli/[email protected]", "", { "dependencies": { "@isaacs/string-locale-compare": "^1.1.0", "@npmcli/fs": "^5.0.0", "@npmcli/installed-package-contents": "^4.0.0", "@npmcli/map-workspaces": "^5.0.0", "@npmcli/metavuln-calculator": "^9.0.2", "@npmcli/name-from-folder": "^4.0.0", "@npmcli/node-gyp": "^5.0.0", "@npmcli/package-json": "^7.0.0", "@npmcli/query": "^5.0.0", "@npmcli/redact": "^4.0.0", "@npmcli/run-script": "^10.0.0", "bin-links": "^6.0.0", "cacache": "^20.0.1", "common-ancestor-path": "^2.0.0", "hosted-git-info": "^9.0.0", "json-stringify-nice": "^1.1.4", "lru-cache": "^11.2.1", "minimatch": "^10.0.3", "nopt": "^9.0.0", "npm-install-checks": "^8.0.0", "npm-package-arg": "^13.0.0", "npm-pick-manifest": "^11.0.1", "npm-registry-fetch": "^19.0.0", "pacote": "^21.0.2", "parse-conflict-json": "^5.0.1", "proc-log": "^6.0.0", "proggy": "^4.0.0", "promise-all-reject-late": "^1.0.0", "promise-call-limit": "^3.0.1", "semver": "^7.3.7", "ssri": "^13.0.0", "treeverse": "^3.0.0", "walk-up-path": "^4.0.0" }, "bin": { "arborist": "bin/index.js" } }, "sha512-4Bm8hNixJG/sii1PMnag0V9i/sGOX9VRzFrUiZMSBJpGlLR38f+Btl85d07G9GL56xO0l0OZjvrGNYsDYp0xKA=="],
 
+    "@npmcli/config": ["@npmcli/[email protected]", "", { "dependencies": { "@npmcli/map-workspaces": "^5.0.0", "@npmcli/package-json": "^7.0.0", "ci-info": "^4.0.0", "ini": "^6.0.0", "nopt": "^9.0.0", "proc-log": "^6.0.0", "semver": "^7.3.5", "walk-up-path": "^4.0.0" } }, "sha512-MAYk9IlIGiyC0c9fnjdBSQfIFPZT0g1MfeSiD1UXTq2zJOLX55jS9/sETJHqw/7LN18JjITrhYfgCfapbmZHiQ=="],
+
     "@npmcli/fs": ["@npmcli/[email protected]", "", { "dependencies": { "semver": "^7.3.5" } }, "sha512-7OsC1gNORBEawOa5+j2pXN9vsicaIOH5cPXxoR6fJOmH6/EXpJB2CajXOu1fPRFun2m1lktEFX11+P89hqO/og=="],
 
     "@npmcli/git": ["@npmcli/[email protected]", "", { "dependencies": { "@gar/promise-retry": "^1.0.0", "@npmcli/promise-spawn": "^9.0.0", "ini": "^6.0.0", "lru-cache": "^11.2.1", "npm-pick-manifest": "^11.0.1", "proc-log": "^6.0.0", "semver": "^7.3.5", "which": "^6.0.0" } }, "sha512-oeolHDjExNAJAnlYP2qzNjMX/Xi9bmu78C9dIGr4xjobrSKbuMYCph8lTzn4vnW3NjIqVmw/f8BCfouqyJXlRg=="],

+ 1 - 0
package.json

@@ -127,6 +127,7 @@
     "@types/node": "catalog:"
   },
   "patchedDependencies": {
+    "@npmcli/[email protected]": "patches/@npmcli%[email protected]",
     "@standard-community/[email protected]": "patches/@standard-community%[email protected]",
     "[email protected]": "patches/[email protected]"
   }

+ 1 - 0
packages/opencode/package.json

@@ -110,6 +110,7 @@
     "@lydell/node-pty": "catalog:",
     "@modelcontextprotocol/sdk": "1.27.1",
     "@npmcli/arborist": "9.4.0",
+    "@npmcli/config": "10.8.1",
     "@octokit/graphql": "9.0.2",
     "@octokit/rest": "catalog:",
     "@openauthjs/openauth": "catalog:",

+ 0 - 0
packages/opencode/src/npm/config.ts


+ 43 - 0
packages/opencode/src/npmcli-config.d.ts

@@ -0,0 +1,43 @@
+declare module "@npmcli/config" {
+  type Data = Record<string, unknown>
+  type Where = "default" | "builtin" | "global" | "user" | "project" | "env" | "cli"
+
+  namespace Config {
+    interface Options {
+      definitions: Data
+      shorthands: Record<string, string | string[]>
+      npmPath: string
+      flatten?: (input: Data, flat?: Data) => Data
+      nerfDarts?: string[]
+      argv?: string[]
+      cwd?: string
+      env?: NodeJS.ProcessEnv
+      execPath?: string
+      platform?: NodeJS.Platform
+      warn?: boolean
+    }
+  }
+
+  class Config {
+    constructor(input: Config.Options)
+
+    readonly data: Map<Where, { source: string | null }>
+    readonly flat: Data
+
+    load(): Promise<void>
+  }
+
+  export = Config
+}
+
+declare module "@npmcli/config/lib/definitions" {
+  export const definitions: Record<string, unknown>
+  export const shorthands: Record<string, string | string[]>
+  export const flatten: (input: Record<string, unknown>, flat?: Record<string, unknown>) => Record<string, unknown>
+  export const nerfDarts: string[]
+  export const proxyEnv: string[]
+}
+
+declare module "@npmcli/config/lib/definitions/index.js" {
+  export * from "@npmcli/config/lib/definitions"
+}

+ 2 - 0
packages/shared/src/types.d.ts

@@ -5,6 +5,7 @@ declare module "@npmcli/arborist" {
     progress?: boolean
     savePrefix?: string
     ignoreScripts?: boolean
+    [key: string]: unknown
   }
 
   export interface ArboristNode {
@@ -24,6 +25,7 @@ declare module "@npmcli/arborist" {
     add?: string[]
     save?: boolean
     saveType?: "prod" | "dev" | "optional" | "peer"
+    [key: string]: unknown
   }
 
   export class Arborist {

+ 13 - 0
patches/@npmcli%[email protected]

@@ -0,0 +1,13 @@
+diff --git a/lib/agents.js b/lib/agents.js
+index 45ec59c4c13757379095131c4f0a5ea6f7284f45..0763b031e355a755ec6a26f98461aa3f63b8339b 100644
+--- a/lib/agents.js
++++ b/lib/agents.js
+@@ -32,7 +32,7 @@ module.exports = class Agent extends AgentBase {
+   }
+ 
+   get proxy () {
+-    return this.#proxy ? { url: this.#proxy } : {}
++    return this.#proxy ? { url: this.#proxy.toString() } : {}
+   }
+ 
+   #getProxy (options) {